fern-api 0.93.1 → 0.93.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +6 -5
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -2161,7 +2161,7 @@ ${omy.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&Oyf(th
|
|
|
2161
2161
|
`+Rsa.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Rsa.default.cyan(hmy(t,this.opt.mask)):Rsa.default.italic(Rsa.default.dim("[hidden]")):this.opt.mask?hmy(t,this.opt.mask):Rsa.default.italic(Rsa.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 W1s=fa(use(),1);var hOy=fa(rvf(),1),U1s=require("child_process"),JZa=require("fs"),L1s=fa(require("path"),1),yOy=fa(require("os"),1),vOy=require("crypto"),Qvf=fa(pOy(),1);var x1s=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var EJo=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var z1s=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var Q1s=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function V1s(e="",t,r){let n=new Lvf(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 _Oy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function wrC(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 Lvf=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=wrC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??yOy.default.tmpdir(),r=(0,vOy.randomUUID)(),n=_Oy(this.fileOptions.prefix),i=_Oy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=L1s.default.resolve(t,a),c=L1s.default.resolve(t)+L1s.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let d={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(d.mode=this.fileOptions.mode),(0,JZa.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new x1s(t)}}readTemporaryFile(){try{let t=(0,JZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,hOy.detect)(t)??"utf8";Qvf.default.encodingExists(r)||(r="utf8"),this.text=Qvf.default.decode(t,r)}}catch(t){throw new z1s(t)}}removeTemporaryFile(){try{(0,JZa.unlinkSync)(this.tempFile)}catch(t){throw new Q1s(t)}}launchEditor(){try{let t=(0,U1s.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new EJo(t)}}launchEditorAsync(t){try{(0,U1s.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new EJo(r)}}};var bOy=fa(Int(),1);var SJo=class extends sse{_run(t){this.done=t,this.editorResult=new bOy.Subject;let r=Nbe(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"?W1s.default.dim("Received"):W1s.default.dim("Press <enter> to launch your preferred editor."),t&&(r=W1s.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),V1s(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 POy=require("stream");var OOy=fa(require("readline"),1),AOy=fa(mOy(),1),zsa=class{constructor(t){this.rl||=OOy.default.createInterface(ErC(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 ErC(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 AOy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var DJo=class extends zsa{constructor(t={}){super(t),this.log=new POy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return fJo(this.rl,this.bottomBar.split(`
|
|
2162
2162
|
`).length),this}updateBottomBar(t){return fJo(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+`
|
|
2163
2163
|
`}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&&d1s(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var W6=fa(Int(),1),EOy=fa(BGo(),1);var H1s=fa(Int(),1),wOy=fa(BGo(),1),G1s=function(e,t,r){return typeof e[t]!="function"?(0,H1s.of)(e):(0,H1s.from)((0,wOy.default)(e[t])(r).then(n=>(e[t]=n,e)))};var jOy={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}},KZa=class extends zsa{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,W6.from)(t):(0,W6.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,W6.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,W6.from)([t]),this.process=n.pipe((0,W6.concatMap)(this.processQuestion.bind(this)),(0,W6.publish)()),this.process.connect(),this.process.pipe((0,W6.reduce)((i,a)=>(jOy.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,W6.defer)(()=>(0,W6.of)(t).pipe((0,W6.concatMap)(this.setDefaultType.bind(this)),(0,W6.concatMap)(this.filterIfRunnable.bind(this)),(0,W6.concatMap)(()=>G1s(t,"message",this.answers)),(0,W6.concatMap)(()=>G1s(t,"default",this.answers)),(0,W6.concatMap)(()=>G1s(t,"choices",this.answers)),(0,W6.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,W6.defer)(()=>(0,W6.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,W6.defer)(()=>(0,W6.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&jOy.get(this.answers,t.name)!==void 0)return W6.EMPTY;if(t.when===!1)return W6.EMPTY;if(typeof t.when!="function")return(0,W6.of)(t);let{answers:r}=this;return(0,W6.defer)(()=>(0,W6.from)((0,EOy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,W6.filter)(n=>n!=null)))}};function SOy(e){let t=function(r,n){let i;try{i=new KZa(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",pJo),this.registerPrompt("input",qsa),this.registerPrompt("number",_Jo),this.registerPrompt("confirm",hJo),this.registerPrompt("rawlist",yJo),this.registerPrompt("expand",vJo),this.registerPrompt("checkbox",bJo),this.registerPrompt("password",gJo),this.registerPrompt("editor",SJo)},t.restoreDefaultPrompts(),t}var Vvf=SOy();function DrC(e,t){Vvf.registerPrompt(e,t)}function CrC(){Vvf.restoreDefaultPrompts()}var IrC={prompt:Vvf,ui:{BottomBar:DJo,Prompt:KZa},createPromptModule:SOy,registerPrompt:DrC,restoreDefaultPrompts:CrC,Separator:Nxe},J1s=IrC;var uka=require("path"),pPy=require("fs"),_Py=require("readline"),xAy="posthog-node";function vaC(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[yEs.POSTHOG_ID_TAG];if(c===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,d).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(A=>({...A,stacktrace:A.stacktrace?{...A.stacktrace,type:"raw",frames:(A.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var yEs=class{constructor(t,r,n,i){this.name=xAy,this.name=xAy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(vaC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};yEs.POSTHOG_ID_TAG="posthog_distinct_id";var fEs="0123456789abcdef",vEs=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+=fEs.charAt(this.bytes[r]>>>4),t+=fEs.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+=fEs.charAt(this.bytes[r]>>>4),t+=fEs.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}},Mbf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??baC()}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 vEs.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,vEs.ofInner(t)}},baC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),zAy,Bbf=()=>gaC().toString(),gaC=()=>(zAy||(zAy=new Mbf)).generate();function maC(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 OaC(e,t){global.process.on("uncaughtException",maC(e,t))}function AaC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var dEs,QAy,pEs;function PaC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return pEs&&r.length===QAy||(QAy=r.length,pEs=r.reduce((n,i)=>{dEs||(dEs={});let a=dEs[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[i];if(s&&u){n[s]=u,dEs[i]=[s,u];break}}}return n},{})),pEs}function waC(e){return typeof Event<"u"&&hPy(e,Event)}function jaC(e){return yPy(e,"Object")}function Qbf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return hPy(e,Error)}}function hPy(e,t){try{return e instanceof t}catch{return!1}}function EaC(e){return yPy(e,"ErrorEvent")}function yPy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function SaC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=vPy(a,r,n);return{$exception_list:await Promise.all(o.map(async s=>{let u=await qaC(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function vPy(e,t,r){let n=DaC(e,t,r);return n.cause?[n,...vPy(e,n.cause,r)]:[n]}function DaC(e,t,r){if(Qbf(t))return t;if(e.synthetic=!0,jaC(t)){let i=CaC(t);if(i)return i;let a=IaC(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 CaC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(Qbf(r))return r}}function IaC(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=BaC(e);if(EaC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=MaC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function MaC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function BaC(e,t=40){let r=Object.keys(TaC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return LAy(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:LAy(a,t)}return""}function LAy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function TaC(e){return Qbf(e)?{message:e.message,name:e.name,stack:e.stack,...UAy(e)}:waC(e)?{type:e.type,target:VAy(e.target),currentTarget:VAy(e.currentTarget),...UAy(e)}:e}function UAy(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 VAy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function qaC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=RaC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function RaC(e,t){return NaC(e(t.stack||"",1),e)}function NaC(e,t){let r=PaC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var FaC=2e3,ika=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await SaC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||Bbf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(OaC(this.onException.bind(this),this.onFatalError.bind(this)),AaC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(FaC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function xaC(e=process.argv[1]?(0,uka.dirname)(process.argv[1]):process.cwd(),t=uka.sep==="\\"){let r=t?WAy(e):e;return n=>{if(!n)return;let i=t?WAy(n):n,{dir:a,base:o,ext:c}=uka.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let d=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${d}`:d}return d}}function WAy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var bEs=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)}}},hEs=new bEs(25),bPy=new bEs(20),Lbf=7,zaC=1e3,QaC=1e4;async function LaC(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"||HaC(o)||GaC(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(bPy.get(i))continue;let a=t[i];if(!a)continue;a.sort((d,s)=>d-s);let o=KaC(a);if(o.every(d=>JaC(i,d)))continue;let c=$aC(hEs,i,{});n.push(UaC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&VaC(e,hEs),hEs.reduce(),e}function UaC(e,t,r){return new Promise(n=>{let i=(0,pPy.createReadStream)(e),a=(0,_Py.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,d=0,s=t[d];if(s===void 0){o();return}let u=s[0],l=s[1];function m(){bPy.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",A=>{if(c++,!(c<u)&&(r[c]=YaC(A,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let P=t[d];if(P===void 0){a.close(),a.removeAllListeners();return}u=P[0],l=P[1]}})})}function VaC(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;WaC(r.lineno,r,n)}}function WaC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=gPy(e);i<e;i++){let a=r[i];if(a===void 0){HAy(t);return}t.pre_context.push(a)}if(r[e]===void 0){HAy(t);return}t.context_line=r[e];let n=mPy(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 HAy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function HaC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function GaC(e){return e.lineno!==void 0&&e.lineno>QaC||e.colno!==void 0&&e.colno>zaC}function JaC(e,t){let r=hEs.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 KaC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=GAy(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+Lbf:(i.push(n),n=GAy(a)),t++}return i}function GAy(e){return[gPy(e),mPy(e)]}function gPy(e){return Math.max(1,e-Lbf)}function mPy(e){return e+Lbf}function $aC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function YaC(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 XaC="4.18.0",Lxe;(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"})(Lxe||(Lxe={}));var JAy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(JAy||(JAy={}));var KAy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(KAy||(KAy={}));var $Ay;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})($Ay||($Ay={}));var YAy;(function(e){e.Html="html",e.Text="text"})(YAy||(YAy={}));var XAy;(function(e){e.Number="number",e.Emoji="emoji"})(XAy||(XAy={}));var ZAy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(ZAy||(ZAy={}));var kAy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(kAy||(kAy={}));var ePy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(ePy||(ePy={}));var tPy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(tPy||(tPy={}));var ZaC=e=>{if("flags"in e){let t=eoC(e.flags),r=toC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,OPy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,kaC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function kaC(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 eoC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,Ubf(r)]).filter(([,t])=>t!==void 0)),toC=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?OPy(n):void 0]}))},Ubf=e=>e===void 0?void 0:e.variant??e.enabled,OPy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},roC=1,noC=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"]),ioC="utf8";function aoC(e,t){if(!e||typeof e!="string"||ooC(e))throw new Error(t)}function ooC(e){return e.trim().length===0}function uoC(e){return e?.replace(/\/+$/,"")}async function soC(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 rPy(){return new Date().getTime()}function Cbf(){return new Date().toISOString()}function gEs(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function coC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function loC(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 foC(e,t=0,r){let n=loC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function nPy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var xJo=String.fromCharCode,iPy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_Es={};function doC(e,t){if(!_Es[e]){_Es[e]={};for(let r=0;r<e.length;r++)_Es[e][e.charAt(r)]=r}return _Es[e][t]}var rka={compressToBase64:function(e){if(e==null)return"";let t=rka._compress(e,6,function(r){return iPy.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:rka._decompress(e.length,32,function(t){return doC(iPy,e.charAt(t))})},compress:function(e){return rka._compress(e,16,function(t){return xJo(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,d="",s="",u="",l=2,m=3,A=2,P=0,C=0,M;for(M=0;M<e.length;M+=1)if(d=e.charAt(M),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),s=u+d,Object.prototype.hasOwnProperty.call(n,s))u=s;else{if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=u.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[u]}else for(c=n[u],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++),n[s]=m++,u=String(d)}if(u!==""){if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=u.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[u]}else for(c=n[u],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++)}for(c=2,o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:rka._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,d=3,s="",u,l,m,A,P,C,M;for(u=0;u<3;u+=1)n[u]=u;for(m=0,P=Math.pow(2,2),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=xJo(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=xJo(m);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,d),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(M=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=xJo(m),M=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=xJo(m),M=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,d),d++),n[M])s=n[M];else if(M===c)s=l+l.charAt(0);else return null;i.push(s),n[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,d),d++)}}},Tbf=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)}},aka=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()}},zJo=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function aPy(e){if(e instanceof aka){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 Ibf(e){return typeof e=="object"&&(e instanceof aka||e instanceof zJo)}function oPy(e){return typeof e=="object"&&e instanceof aka&&e.status===413}var qbf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(qbf||(qbf={}));var Rbf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new Tbf,this._isInitialized=!1,aoC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=uoC(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:Ibf},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(Lxe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(Lxe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(Lxe.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=Bbf();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=foC(this.apiKey,roC,noC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={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,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>ZaC(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let d=Ubf(c.response);return d===void 0&&(d=!1),{response:d,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 d=c[t];return d===void 0?null:d}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 d=await this.getDecide(t,r,n,i,c);if(d!==void 0)return d.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"),d.quotaLimited?.includes(qbf.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:d?.requestId}):d}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(Lxe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(Lxe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(Lxe.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(Lxe.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(Lxe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=gEs(()=>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:Cbf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${rPy()}&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(rka.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Cbf(),uuid:n?.uuid?n.uuid:Bbf()};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 aPy(t)})}async flush(){let t=nPy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),nPy([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(Lxe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let A=(this.getPersistedProperty(Lxe.Queue)||[]).slice(i.length);this.setPersistedProperty(Lxe.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:Cbf()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${rPy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(rka.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},l={retryCheck:m=>oPy(m)?!1:Ibf(m)};try{await this.fetchWithRetry(s,u,l)}catch(m){if(oPy(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 zJo||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,ioC)}catch{c=new TextEncoder().encode(o).length}return await soC(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(u){throw new zJo(u)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new aka(d,c);return d},{...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(Lxe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!Ibf(i))throw i;await aPy(i)}};return Promise.race([new Promise((i,a)=>{gEs(()=>{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}},Nbf=coC();if(!Nbf){let e=FAy();Nbf=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 APy=Nbf,mEs=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()}},PPy=new mEs(async()=>{try{return await import("crypto")}catch{return}});async function poC(){return await PPy.getValue()}var _oC=new mEs(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await PPy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function hoC(){return await _oC.getValue()}async function yoC(e){let t=await poC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await hoC();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 voC=60*1e3,boC=1152921504606847e3,goC=["is_not"],nka=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},cse=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Fbf=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||APy,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 d of this.featureFlags)if(t===d.key){c=d;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(d){d instanceof cse?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}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 d=>{try{let s=await this.computeFlagLocally(d,t,r,n,i);a[d.key]=s;let u=await this.computeFeatureFlagPayloadLocally(d.key,s);u&&(o[d.key]=u)}catch(s){s instanceof cse||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new cse("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let d=this.groupTypeMapping[String(c)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new cse("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return await this.matchFeatureFlagProperties(t,n[d],s)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,d=[...a].sort((s,u)=>{let l=!!s.variant,m=!!u.variant;return l&&m?0:l?-1:m?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,n)){let u=s.variant,l=i.multivariate?.variants||[];u&&l.some(m=>m.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof cse)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new cse("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 d=c.type,s=!1;if(d==="cohort"?s=jPy(c,i,this.cohorts,this.debugMode):s=wPy(c,i,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await uPy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await uPy(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(voC,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 nka(`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 nka(`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 nka(`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 nka&&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=gEs(()=>{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=gEs(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function uPy(e,t,r=""){let n=await yoC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/boC}function wPy(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 cse("Operator is_not_set is not supported")}else throw new cse(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!goC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return sPy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return sPy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof i=="number"?i:null;if(typeof i=="string")try{s=parseFloat(i)}catch{}return s!=null&&o!=null?typeof o=="string"?d(o,String(i),a):d(o,s,a):d(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let s=moC(String(i));if(s==null&&(s=cPy(i)),s==null)throw new cse(`Invalid date: ${i}`);let u=cPy(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new cse(`Unknown operator: ${a}`)}}function jPy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new cse("can't match cohort without a given cohort property value");let a=r[i];return EPy(a,t,r,n)}function EPy(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 d=EPy(c,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof cse)n&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new cse("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let d;c.type==="cohort"?d=jPy(c,t,r,n):d=wPy(c,t);let s=c.negation||!1;if(i==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof cse)n&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new cse("can't match cohort without a given cohort property value");return i==="AND"}}function sPy(e){try{return new RegExp(e),!0}catch{return!1}}function cPy(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 cse(`${e} is in an invalid date format`)}else throw new cse(`The date provided ${e} must be a string, number, or date object`)}function moC(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 xbf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},OoC=100,lPy=30*1e3,AoC=50*1e3,zbf=class extends Rbf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new xbf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,OoC):lPy,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 Fbf({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 ika(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||AoC}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):APy(t,r)}getLibraryVersion(){return XaC}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:d,uuid:s}=t,u=A=>{super.captureStateless(r,n,A,{timestamp:c,disableGeoip:d,uuid:s})},l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,d);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...A,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=A=>super.captureStatelessImmediate(r,n,A,{timestamp:c,disableGeoip:d,uuid:s}),l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,d);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...A,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=lPy){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:d,groupProperties:s}=n||{},u=this.addLocalPersonAndGroupProperties(r,i,d,s);d=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,s),m=l!==void 0,A,P;if(!m&&!o){let M=await super.getFeatureFlagDetailStateless(t,r,i,d,s,a);if(M===void 0)return;P=M.response,l=Ubf(P),A=M?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:A},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:d,personProperties:s,groupProperties:u}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),d==null&&(d=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,o,c);o=d.allPersonProperties,c=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),u={},l={},m=!0;if(s&&(u=s.response,l=s.payloads,m=s.fallbackToDecide),m&&!a){let A=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);u={...u,...A.flags||{}},l={...l,...A.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");ika.captureException(this,t,{syntheticException:i},r,n)}},fPy=/\(error: (.*)\)/,SPy=50,DPy="?";function PoC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,d,s;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let A=a.indexOf(".Module");A>0&&(c=c.slice(A+1),a=a.slice(0,A))}d=void 0}o&&(d=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||DPy,c=d?`${d}.${s}`:s);let u=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&i[5]&&!l&&(u=i[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:dPy(i[3]),colno:dPy(i[4]),in_app:woC(u||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function woC(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 dPy(e){return parseInt(e||"",10)||void 0}function joC(e){return[90,PoC(e)]}function EoC(e){let r=[joC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
|
|
2164
|
-
`);for(let c=i;c<o.length;c++){let d=o[c];if(d.length>1024)continue;let s=fPy.test(d)?d.replace(fPy,"$1"):d;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=SPy)break}}return SoC(a)}}function SoC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,SPy).map(r=>({...r,filename:r.filename||DoC(t).filename,function:r.function||DPy}))}function DoC(e){return e[e.length-1]||{}}ika.stackParser=EoC(xaC());ika.frameModifiers=[LaC];var oka=class extends zbf{getLibraryId(){return"posthog-node"}};var OEs=class{posthog;constructor({posthogApiKey:t}){this.posthog=new oka(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.93.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var QJo=class{async sendEvent(){}async identify(){}async flush(){}};var ska=require("fs/promises"),BPy=require("os"),TPy=require("path");var CPy=fa(require("crypto")),PEs=new Uint8Array(256),AEs=PEs.length;function Vbf(){return AEs>PEs.length-16&&(CPy.default.randomFillSync(PEs),AEs=0),PEs.slice(AEs,AEs+=16)}var xbe=[];for(let e=0;e<256;++e)xbe.push((e+256).toString(16).slice(1));function IPy(e,t=0){return xbe[e[t+0]]+xbe[e[t+1]]+xbe[e[t+2]]+xbe[e[t+3]]+"-"+xbe[e[t+4]]+xbe[e[t+5]]+"-"+xbe[e[t+6]]+xbe[e[t+7]]+"-"+xbe[e[t+8]]+xbe[e[t+9]]+"-"+xbe[e[t+10]]+xbe[e[t+11]]+xbe[e[t+12]]+xbe[e[t+13]]+xbe[e[t+14]]+xbe[e[t+15]]}var MPy=fa(require("crypto")),Wbf={randomUUID:MPy.default.randomUUID};function CoC(e,t,r){if(Wbf.randomUUID&&!t&&!e)return Wbf.randomUUID();e=e||{};let n=e.random||(e.rng||Vbf)();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 IPy(n)}var Pht=CoC;var IoC="id",MoC=".fern",LJo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new oka(r),this.userId=t==null?void 0:iff(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.93.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(x_.of((0,BPy.homedir)()),ys.of(MoC),ys.of(IoC));await Tv(t)||(await(0,ska.mkdir)((0,TPy.dirname)(t),{recursive:!0}),await(0,ska.writeFile)(t,Pht())),this.persistedDistinctId=(await(0,ska.readFile)(t)).toString()}return this.persistedDistinctId}};var Hbf;async function cka(){return Hbf==null&&(Hbf=await BoC()),Hbf}async function BoC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new QJo;let r=await Bms();return r!=null?new LJo({token:r,posthogApiKey:e}):await cXa()!=null?new OEs({posthogApiKey:e}):new LJo({token:void 0,posthogApiKey:e})}catch{return new QJo}}function UJo(e,t){return function(){return e.apply(t,arguments)}}var{toString:ToC}=Object.prototype,{getPrototypeOf:Jbf}=Object,{iterator:jEs,toStringTag:RPy}=Symbol,EEs=(e=>t=>{let r=ToC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),nqr=e=>(e=e.toLowerCase(),t=>EEs(t)===e),SEs=e=>t=>typeof t===e,{isArray:fka}=Array,lka=SEs("undefined");function VJo(e){return e!==null&&!lka(e)&&e.constructor!==null&&!lka(e.constructor)&&Uxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var NPy=nqr("ArrayBuffer");function qoC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&NPy(e.buffer),t}var RoC=SEs("string"),Uxe=SEs("function"),FPy=SEs("number"),WJo=e=>e!==null&&typeof e=="object",NoC=e=>e===!0||e===!1,wEs=e=>{if(EEs(e)!=="object")return!1;let t=Jbf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(RPy in e)&&!(jEs in e)},FoC=e=>{if(!WJo(e)||VJo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xoC=nqr("Date"),zoC=nqr("File"),QoC=nqr("Blob"),LoC=nqr("FileList"),UoC=e=>WJo(e)&&Uxe(e.pipe),VoC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Uxe(e.append)&&((t=EEs(e))==="formdata"||t==="object"&&Uxe(e.toString)&&e.toString()==="[object FormData]"))},WoC=nqr("URLSearchParams"),[HoC,GoC,JoC,KoC]=["ReadableStream","Request","Response","Headers"].map(nqr),$oC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function HJo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),fka(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(VJo(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 xPy(e,t){if(VJo(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 Hsa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zPy=e=>!lka(e)&&e!==Hsa;function Gbf(){let{caseless:e,skipUndefined:t}=zPy(this)&&this||{},r={},n=(i,a)=>{let o=e&&xPy(r,a)||a;wEs(r[o])&&wEs(i)?r[o]=Gbf(r[o],i):wEs(i)?r[o]=Gbf({},i):fka(i)?r[o]=i.slice():(!t||!lka(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&HJo(arguments[i],n);return r}var YoC=(e,t,r,{allOwnKeys:n}={})=>(HJo(t,(i,a)=>{r&&Uxe(i)?e[a]=UJo(i,r):e[a]=i},{allOwnKeys:n}),e),XoC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ZoC=(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)},koC=(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&&Jbf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},euC=(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},tuC=e=>{if(!e)return null;if(fka(e))return e;let t=e.length;if(!FPy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ruC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Jbf(Uint8Array)),nuC=(e,t)=>{let n=(e&&e[jEs]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},iuC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},auC=nqr("HTMLFormElement"),ouC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),qPy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),uuC=nqr("RegExp"),QPy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};HJo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},suC=e=>{QPy(e,(t,r)=>{if(Uxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Uxe(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+"'")})}})},cuC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return fka(e)?n(e):n(String(e).split(t)),r},luC=()=>{},fuC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function duC(e){return!!(e&&Uxe(e.append)&&e[RPy]==="FormData"&&e[jEs])}var puC=e=>{let t=new Array(10),r=(n,i)=>{if(WJo(n)){if(t.indexOf(n)>=0)return;if(VJo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=fka(n)?[]:{};return HJo(n,(o,c)=>{let d=r(o,i+1);!lka(d)&&(a[c]=d)}),t[i]=void 0,a}}return n};return r(e,0)},_uC=nqr("AsyncFunction"),huC=e=>e&&(WJo(e)||Uxe(e))&&Uxe(e.then)&&Uxe(e.catch),LPy=((e,t)=>e?setImmediate:t?((r,n)=>(Hsa.addEventListener("message",({source:i,data:a})=>{i===Hsa&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Hsa.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Uxe(Hsa.postMessage)),yuC=typeof queueMicrotask<"u"?queueMicrotask.bind(Hsa):typeof process<"u"&&process.nextTick||LPy,vuC=e=>e!=null&&Uxe(e[jEs]),Yf={isArray:fka,isArrayBuffer:NPy,isBuffer:VJo,isFormData:VoC,isArrayBufferView:qoC,isString:RoC,isNumber:FPy,isBoolean:NoC,isObject:WJo,isPlainObject:wEs,isEmptyObject:FoC,isReadableStream:HoC,isRequest:GoC,isResponse:JoC,isHeaders:KoC,isUndefined:lka,isDate:xoC,isFile:zoC,isBlob:QoC,isRegExp:uuC,isFunction:Uxe,isStream:UoC,isURLSearchParams:WoC,isTypedArray:ruC,isFileList:LoC,forEach:HJo,merge:Gbf,extend:YoC,trim:$oC,stripBOM:XoC,inherits:ZoC,toFlatObject:koC,kindOf:EEs,kindOfTest:nqr,endsWith:euC,toArray:tuC,forEachEntry:nuC,matchAll:iuC,isHTMLForm:auC,hasOwnProperty:qPy,hasOwnProp:qPy,reduceDescriptors:QPy,freezeMethods:suC,toObjectSet:cuC,toCamelCase:ouC,noop:luC,toFiniteNumber:fuC,findKey:xPy,global:Hsa,isContextDefined:zPy,isSpecCompliantForm:duC,toJSONObject:puC,isAsyncFn:_uC,isThenable:huC,setImmediate:LPy,asap:yuC,isIterable:vuC};function dka(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)}Yf.inherits(dka,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:Yf.toJSONObject(this.config),code:this.code,status:this.status}}});var UPy=dka.prototype,VPy={};["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=>{VPy[e]={value:e}});Object.defineProperties(dka,VPy);Object.defineProperty(UPy,"isAxiosError",{value:!0});dka.from=(e,t,r,n,i,a)=>{let o=Object.create(UPy);Yf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return dka.call(o,c,d,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 Dm=dka;var WPy=fa(Y1s(),1),DEs=WPy.default;function Kbf(e){return Yf.isPlainObject(e)||Yf.isArray(e)}function GPy(e){return Yf.endsWith(e,"[]")?e.slice(0,-2):e}function HPy(e,t,r){return e?e.concat(t).map(function(i,a){return i=GPy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function buC(e){return Yf.isArray(e)&&!e.some(Kbf)}var guC=Yf.toFlatObject(Yf,{},null,function(t){return/^is[A-Z]/.test(t)});function muC(e,t,r){if(!Yf.isObject(e))throw new TypeError("target must be an object");t=t||new(DEs||FormData),r=Yf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Yf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Yf.isSpecCompliantForm(t);if(!Yf.isFunction(i))throw new TypeError("visitor must be a function");function s(P){if(P===null)return"";if(Yf.isDate(P))return P.toISOString();if(Yf.isBoolean(P))return P.toString();if(!d&&Yf.isBlob(P))throw new Dm("Blob is not supported. Use a Buffer instead.");return Yf.isArrayBuffer(P)||Yf.isTypedArray(P)?d&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function u(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Yf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Yf.isArray(P)&&buC(P)||(Yf.isFileList(P)||Yf.endsWith(C,"[]"))&&(T=Yf.toArray(P)))return C=GPy(C),T.forEach(function(U,R){!(Yf.isUndefined(U)||U===null)&&t.append(o===!0?HPy([C],R,a):o===null?C:C+"[]",s(U))}),!1}return Kbf(P)?!0:(t.append(HPy(M,C,a),s(P)),!1)}let l=[],m=Object.assign(guC,{defaultVisitor:u,convertValue:s,isVisitable:Kbf});function A(P,C){if(!Yf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Yf.forEach(P,function(T,z){(!(Yf.isUndefined(T)||T===null)&&i.call(t,T,Yf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Yf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var I4i=muC;function JPy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function KPy(e,t){this._pairs=[],e&&I4i(e,this,t)}var $Py=KPy.prototype;$Py.append=function(t,r){this._pairs.push([t,r])};$Py.toString=function(t){let r=t?function(n){return t.call(this,n,JPy)}:JPy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var YPy=KPy;function OuC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Gsa(e,t,r){if(!t)return e;let n=r&&r.encode||OuC;Yf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Yf.isURLSearchParams(t)?t.toString():new YPy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var $bf=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){Yf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Ybf=$bf;var pka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ewy=fa(require("crypto"),1);var XPy=fa(require("url"),1),ZPy=XPy.default.URLSearchParams;var Xbf="abcdefghijklmnopqrstuvwxyz",kPy="0123456789",twy={DIGIT:kPy,ALPHA:Xbf,ALPHA_DIGIT:Xbf+Xbf.toUpperCase()+kPy},AuC=(e=16,t=twy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);ewy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},rwy={isNode:!0,classes:{URLSearchParams:ZPy,FormData:DEs,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:twy,generateString:AuC,protocols:["http","https","file","data"]};var egf={};ff(egf,{hasBrowserEnv:()=>kbf,hasStandardBrowserEnv:()=>PuC,hasStandardBrowserWebWorkerEnv:()=>wuC,navigator:()=>Zbf,origin:()=>juC});var kbf=typeof window<"u"&&typeof document<"u",Zbf=typeof navigator=="object"&&navigator||void 0,PuC=kbf&&(!Zbf||["ReactNative","NativeScript","NS"].indexOf(Zbf.product)<0),wuC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",juC=kbf&&window.location.href||"http://localhost";var V2={...egf,...rwy};function tgf(e,t){return I4i(e,new V2.classes.URLSearchParams,{visitor:function(r,n,i,a){return V2.isNode&&Yf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function EuC(e){return Yf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function SuC(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 DuC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&Yf.isArray(i)?i.length:o,d?(Yf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Yf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Yf.isArray(i[o])&&(i[o]=SuC(i[o])),!c)}if(Yf.isFormData(e)&&Yf.isFunction(e.entries)){let r={};return Yf.forEachEntry(e,(n,i)=>{t(EuC(n),i,r,0)}),r}return null}var CEs=DuC;function CuC(e,t,r){if(Yf.isString(e))try{return(t||JSON.parse)(e),Yf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var rgf={transitional:pka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Yf.isObject(t);if(a&&Yf.isHTMLForm(t)&&(t=new FormData(t)),Yf.isFormData(t))return i?JSON.stringify(CEs(t)):t;if(Yf.isArrayBuffer(t)||Yf.isBuffer(t)||Yf.isStream(t)||Yf.isFile(t)||Yf.isBlob(t)||Yf.isReadableStream(t))return t;if(Yf.isArrayBufferView(t))return t.buffer;if(Yf.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 tgf(t,this.formSerializer).toString();if((c=Yf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return I4i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),CuC(t)):t}],transformResponse:[function(t){let r=this.transitional||rgf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Yf.isResponse(t)||Yf.isReadableStream(t))return t;if(t&&Yf.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"?Dm.from(c,Dm.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:V2.classes.FormData,Blob:V2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Yf.forEach(["delete","get","head","post","put","patch"],e=>{rgf.headers[e]={}});var _ka=rgf;var IuC=Yf.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"]),nwy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2164
|
+
`);for(let c=i;c<o.length;c++){let d=o[c];if(d.length>1024)continue;let s=fPy.test(d)?d.replace(fPy,"$1"):d;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=SPy)break}}return SoC(a)}}function SoC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,SPy).map(r=>({...r,filename:r.filename||DoC(t).filename,function:r.function||DPy}))}function DoC(e){return e[e.length-1]||{}}ika.stackParser=EoC(xaC());ika.frameModifiers=[LaC];var oka=class extends zbf{getLibraryId(){return"posthog-node"}};var OEs=class{posthog;constructor({posthogApiKey:t}){this.posthog=new oka(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.93.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var QJo=class{async sendEvent(){}async identify(){}async flush(){}};var ska=require("fs/promises"),BPy=require("os"),TPy=require("path");var CPy=fa(require("crypto")),PEs=new Uint8Array(256),AEs=PEs.length;function Vbf(){return AEs>PEs.length-16&&(CPy.default.randomFillSync(PEs),AEs=0),PEs.slice(AEs,AEs+=16)}var xbe=[];for(let e=0;e<256;++e)xbe.push((e+256).toString(16).slice(1));function IPy(e,t=0){return xbe[e[t+0]]+xbe[e[t+1]]+xbe[e[t+2]]+xbe[e[t+3]]+"-"+xbe[e[t+4]]+xbe[e[t+5]]+"-"+xbe[e[t+6]]+xbe[e[t+7]]+"-"+xbe[e[t+8]]+xbe[e[t+9]]+"-"+xbe[e[t+10]]+xbe[e[t+11]]+xbe[e[t+12]]+xbe[e[t+13]]+xbe[e[t+14]]+xbe[e[t+15]]}var MPy=fa(require("crypto")),Wbf={randomUUID:MPy.default.randomUUID};function CoC(e,t,r){if(Wbf.randomUUID&&!t&&!e)return Wbf.randomUUID();e=e||{};let n=e.random||(e.rng||Vbf)();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 IPy(n)}var Pht=CoC;var IoC="id",MoC=".fern",LJo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new oka(r),this.userId=t==null?void 0:iff(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.93.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(x_.of((0,BPy.homedir)()),ys.of(MoC),ys.of(IoC));await Tv(t)||(await(0,ska.mkdir)((0,TPy.dirname)(t),{recursive:!0}),await(0,ska.writeFile)(t,Pht())),this.persistedDistinctId=(await(0,ska.readFile)(t)).toString()}return this.persistedDistinctId}};var Hbf;async function cka(){return Hbf==null&&(Hbf=await BoC()),Hbf}async function BoC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new QJo;let r=await Bms();return r!=null?new LJo({token:r,posthogApiKey:e}):await cXa()!=null?new OEs({posthogApiKey:e}):new LJo({token:void 0,posthogApiKey:e})}catch{return new QJo}}function UJo(e,t){return function(){return e.apply(t,arguments)}}var{toString:ToC}=Object.prototype,{getPrototypeOf:Jbf}=Object,{iterator:jEs,toStringTag:RPy}=Symbol,EEs=(e=>t=>{let r=ToC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),nqr=e=>(e=e.toLowerCase(),t=>EEs(t)===e),SEs=e=>t=>typeof t===e,{isArray:fka}=Array,lka=SEs("undefined");function VJo(e){return e!==null&&!lka(e)&&e.constructor!==null&&!lka(e.constructor)&&Uxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var NPy=nqr("ArrayBuffer");function qoC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&NPy(e.buffer),t}var RoC=SEs("string"),Uxe=SEs("function"),FPy=SEs("number"),WJo=e=>e!==null&&typeof e=="object",NoC=e=>e===!0||e===!1,wEs=e=>{if(EEs(e)!=="object")return!1;let t=Jbf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(RPy in e)&&!(jEs in e)},FoC=e=>{if(!WJo(e)||VJo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},xoC=nqr("Date"),zoC=nqr("File"),QoC=nqr("Blob"),LoC=nqr("FileList"),UoC=e=>WJo(e)&&Uxe(e.pipe),VoC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Uxe(e.append)&&((t=EEs(e))==="formdata"||t==="object"&&Uxe(e.toString)&&e.toString()==="[object FormData]"))},WoC=nqr("URLSearchParams"),[HoC,GoC,JoC,KoC]=["ReadableStream","Request","Response","Headers"].map(nqr),$oC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function HJo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),fka(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(VJo(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 xPy(e,t){if(VJo(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 Hsa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zPy=e=>!lka(e)&&e!==Hsa;function Gbf(){let{caseless:e,skipUndefined:t}=zPy(this)&&this||{},r={},n=(i,a)=>{let o=e&&xPy(r,a)||a;wEs(r[o])&&wEs(i)?r[o]=Gbf(r[o],i):wEs(i)?r[o]=Gbf({},i):fka(i)?r[o]=i.slice():(!t||!lka(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&HJo(arguments[i],n);return r}var YoC=(e,t,r,{allOwnKeys:n}={})=>(HJo(t,(i,a)=>{r&&Uxe(i)?e[a]=UJo(i,r):e[a]=i},{allOwnKeys:n}),e),XoC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ZoC=(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)},koC=(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&&Jbf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},euC=(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},tuC=e=>{if(!e)return null;if(fka(e))return e;let t=e.length;if(!FPy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ruC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Jbf(Uint8Array)),nuC=(e,t)=>{let n=(e&&e[jEs]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},iuC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},auC=nqr("HTMLFormElement"),ouC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),qPy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),uuC=nqr("RegExp"),QPy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};HJo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},suC=e=>{QPy(e,(t,r)=>{if(Uxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Uxe(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+"'")})}})},cuC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return fka(e)?n(e):n(String(e).split(t)),r},luC=()=>{},fuC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function duC(e){return!!(e&&Uxe(e.append)&&e[RPy]==="FormData"&&e[jEs])}var puC=e=>{let t=new Array(10),r=(n,i)=>{if(WJo(n)){if(t.indexOf(n)>=0)return;if(VJo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=fka(n)?[]:{};return HJo(n,(o,c)=>{let d=r(o,i+1);!lka(d)&&(a[c]=d)}),t[i]=void 0,a}}return n};return r(e,0)},_uC=nqr("AsyncFunction"),huC=e=>e&&(WJo(e)||Uxe(e))&&Uxe(e.then)&&Uxe(e.catch),LPy=((e,t)=>e?setImmediate:t?((r,n)=>(Hsa.addEventListener("message",({source:i,data:a})=>{i===Hsa&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Hsa.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Uxe(Hsa.postMessage)),yuC=typeof queueMicrotask<"u"?queueMicrotask.bind(Hsa):typeof process<"u"&&process.nextTick||LPy,vuC=e=>e!=null&&Uxe(e[jEs]),Yf={isArray:fka,isArrayBuffer:NPy,isBuffer:VJo,isFormData:VoC,isArrayBufferView:qoC,isString:RoC,isNumber:FPy,isBoolean:NoC,isObject:WJo,isPlainObject:wEs,isEmptyObject:FoC,isReadableStream:HoC,isRequest:GoC,isResponse:JoC,isHeaders:KoC,isUndefined:lka,isDate:xoC,isFile:zoC,isBlob:QoC,isRegExp:uuC,isFunction:Uxe,isStream:UoC,isURLSearchParams:WoC,isTypedArray:ruC,isFileList:LoC,forEach:HJo,merge:Gbf,extend:YoC,trim:$oC,stripBOM:XoC,inherits:ZoC,toFlatObject:koC,kindOf:EEs,kindOfTest:nqr,endsWith:euC,toArray:tuC,forEachEntry:nuC,matchAll:iuC,isHTMLForm:auC,hasOwnProperty:qPy,hasOwnProp:qPy,reduceDescriptors:QPy,freezeMethods:suC,toObjectSet:cuC,toCamelCase:ouC,noop:luC,toFiniteNumber:fuC,findKey:xPy,global:Hsa,isContextDefined:zPy,isSpecCompliantForm:duC,toJSONObject:puC,isAsyncFn:_uC,isThenable:huC,setImmediate:LPy,asap:yuC,isIterable:vuC};function dka(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)}Yf.inherits(dka,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:Yf.toJSONObject(this.config),code:this.code,status:this.status}}});var UPy=dka.prototype,VPy={};["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=>{VPy[e]={value:e}});Object.defineProperties(dka,VPy);Object.defineProperty(UPy,"isAxiosError",{value:!0});dka.from=(e,t,r,n,i,a)=>{let o=Object.create(UPy);Yf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return dka.call(o,c,d,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 Dm=dka;var WPy=fa(Y1s(),1),DEs=WPy.default;function Kbf(e){return Yf.isPlainObject(e)||Yf.isArray(e)}function GPy(e){return Yf.endsWith(e,"[]")?e.slice(0,-2):e}function HPy(e,t,r){return e?e.concat(t).map(function(i,a){return i=GPy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function buC(e){return Yf.isArray(e)&&!e.some(Kbf)}var guC=Yf.toFlatObject(Yf,{},null,function(t){return/^is[A-Z]/.test(t)});function muC(e,t,r){if(!Yf.isObject(e))throw new TypeError("target must be an object");t=t||new(DEs||FormData),r=Yf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Yf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Yf.isSpecCompliantForm(t);if(!Yf.isFunction(i))throw new TypeError("visitor must be a function");function s(P){if(P===null)return"";if(Yf.isDate(P))return P.toISOString();if(Yf.isBoolean(P))return P.toString();if(!d&&Yf.isBlob(P))throw new Dm("Blob is not supported. Use a Buffer instead.");return Yf.isArrayBuffer(P)||Yf.isTypedArray(P)?d&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function u(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Yf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Yf.isArray(P)&&buC(P)||(Yf.isFileList(P)||Yf.endsWith(C,"[]"))&&(T=Yf.toArray(P)))return C=GPy(C),T.forEach(function(U,R){!(Yf.isUndefined(U)||U===null)&&t.append(o===!0?HPy([C],R,a):o===null?C:C+"[]",s(U))}),!1}return Kbf(P)?!0:(t.append(HPy(M,C,a),s(P)),!1)}let l=[],m=Object.assign(guC,{defaultVisitor:u,convertValue:s,isVisitable:Kbf});function A(P,C){if(!Yf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Yf.forEach(P,function(T,z){(!(Yf.isUndefined(T)||T===null)&&i.call(t,T,Yf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Yf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var I4i=muC;function JPy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function KPy(e,t){this._pairs=[],e&&I4i(e,this,t)}var $Py=KPy.prototype;$Py.append=function(t,r){this._pairs.push([t,r])};$Py.toString=function(t){let r=t?function(n){return t.call(this,n,JPy)}:JPy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var YPy=KPy;function OuC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Gsa(e,t,r){if(!t)return e;let n=r&&r.encode||OuC;Yf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Yf.isURLSearchParams(t)?t.toString():new YPy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var $bf=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){Yf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Ybf=$bf;var pka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ewy=fa(require("crypto"),1);var XPy=fa(require("url"),1),ZPy=XPy.default.URLSearchParams;var Xbf="abcdefghijklmnopqrstuvwxyz",kPy="0123456789",twy={DIGIT:kPy,ALPHA:Xbf,ALPHA_DIGIT:Xbf+Xbf.toUpperCase()+kPy},AuC=(e=16,t=twy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);ewy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},rwy={isNode:!0,classes:{URLSearchParams:ZPy,FormData:DEs,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:twy,generateString:AuC,protocols:["http","https","file","data"]};var egf={};ff(egf,{hasBrowserEnv:()=>kbf,hasStandardBrowserEnv:()=>PuC,hasStandardBrowserWebWorkerEnv:()=>wuC,navigator:()=>Zbf,origin:()=>juC});var kbf=typeof window<"u"&&typeof document<"u",Zbf=typeof navigator=="object"&&navigator||void 0,PuC=kbf&&(!Zbf||["ReactNative","NativeScript","NS"].indexOf(Zbf.product)<0),wuC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",juC=kbf&&window.location.href||"http://localhost";var V2={...egf,...rwy};function tgf(e,t){return I4i(e,new V2.classes.URLSearchParams,{visitor:function(r,n,i,a){return V2.isNode&&Yf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function EuC(e){return Yf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function SuC(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 DuC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&Yf.isArray(i)?i.length:o,d?(Yf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Yf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Yf.isArray(i[o])&&(i[o]=SuC(i[o])),!c)}if(Yf.isFormData(e)&&Yf.isFunction(e.entries)){let r={};return Yf.forEachEntry(e,(n,i)=>{t(EuC(n),i,r,0)}),r}return null}var CEs=DuC;function CuC(e,t,r){if(Yf.isString(e))try{return(t||JSON.parse)(e),Yf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var rgf={transitional:pka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Yf.isObject(t);if(a&&Yf.isHTMLForm(t)&&(t=new FormData(t)),Yf.isFormData(t))return i?JSON.stringify(CEs(t)):t;if(Yf.isArrayBuffer(t)||Yf.isBuffer(t)||Yf.isStream(t)||Yf.isFile(t)||Yf.isBlob(t)||Yf.isReadableStream(t))return t;if(Yf.isArrayBufferView(t))return t.buffer;if(Yf.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 tgf(t,this.formSerializer).toString();if((c=Yf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return I4i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),CuC(t)):t}],transformResponse:[function(t){let r=this.transitional||rgf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Yf.isResponse(t)||Yf.isReadableStream(t))return t;if(t&&Yf.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"?Dm.from(c,Dm.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:V2.classes.FormData,Blob:V2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Yf.forEach(["delete","get","head","post","put","patch"],e=>{rgf.headers[e]={}});var _ka=rgf;var IuC=Yf.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"]),nwy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2165
2165
|
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&IuC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var iwy=Symbol("internals");function GJo(e){return e&&String(e).trim().toLowerCase()}function IEs(e){return e===!1||e==null?e:Yf.isArray(e)?e.map(IEs):String(e)}function MuC(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 BuC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ngf(e,t,r,n,i){if(Yf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Yf.isString(t)){if(Yf.isString(n))return t.indexOf(n)!==-1;if(Yf.isRegExp(n))return n.test(t)}}function TuC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function quC(e,t){let r=Yf.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 hka=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,d,s){let u=GJo(d);if(!u)throw new Error("header name must be a non-empty string");let l=Yf.findKey(i,u);(!l||i[l]===void 0||s===!0||s===void 0&&i[l]!==!1)&&(i[l||d]=IEs(c))}let o=(c,d)=>Yf.forEach(c,(s,u)=>a(s,u,d));if(Yf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Yf.isString(t)&&(t=t.trim())&&!BuC(t))o(nwy(t),r);else if(Yf.isObject(t)&&Yf.isIterable(t)){let c={},d,s;for(let u of t){if(!Yf.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(d=c[s])?Yf.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=GJo(t),t){let n=Yf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return MuC(i);if(Yf.isFunction(r))return r.call(this,i,n);if(Yf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=GJo(t),t){let n=Yf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||ngf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=GJo(o),o){let c=Yf.findKey(n,o);c&&(!r||ngf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Yf.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||ngf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Yf.forEach(this,(i,a)=>{let o=Yf.findKey(n,a);if(o){r[o]=IEs(i),delete r[a];return}let c=t?TuC(a):String(a).trim();c!==a&&delete r[a],r[c]=IEs(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Yf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Yf.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(`
|
|
2166
2166
|
`)}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[iwy]=this[iwy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=GJo(o);n[c]||(quC(i,o),n[c]=!0)}return Yf.isArray(t)?t.forEach(a):a(t),this}};hka.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Yf.reduceDescriptors(hka.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Yf.freezeMethods(hka);var j$=hka;function JJo(e,t){let r=this||_ka,n=t||r,i=j$.from(n.headers),a=n.data;return Yf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function KJo(e){return!!(e&&e.__CANCEL__)}function awy(e,t,r){Dm.call(this,e??"canceled",Dm.ERR_CANCELED,t,r),this.name="CanceledError"}Yf.inherits(awy,Dm,{__CANCEL__:!0});var Bnt=awy;function S9r(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Dm("Request failed with status code "+r.status,[Dm.ERR_BAD_REQUEST,Dm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function igf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function agf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Jsa(e,t,r){let n=!igf(t);return e&&(n||r==!1)?agf(e,t):t}var Owy=fa(X1s(),1),Awy=fa(require("http"),1),Pwy=fa(require("https"),1),wwy=fa(require("util"),1),jwy=fa(obf(),1),PAi=fa(require("zlib"),1);var Ksa="1.12.2";function $Jo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var RuC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function ogf(e,t,r){let n=r&&r.Blob||V2.classes.Blob,i=$Jo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=RuC.exec(e);if(!a)throw new Dm("Invalid URL",Dm.ERR_INVALID_URL);let o=a[1],c=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(t){if(!n)throw new Dm("Blob is not supported",Dm.ERR_NOT_SUPPORT);return new n([s],{type:o})}return s}throw new Dm("Unsupported protocol "+i,Dm.ERR_NOT_SUPPORT)}var Ysa=fa(require("stream"),1);var owy=fa(require("stream"),1);var ugf=Symbol("internals"),sgf=class extends owy.default.Transform{constructor(t){t=Yf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Yf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[ugf]={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[ugf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[ugf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,d=1e3/c,s=a/d,u=i.minChunkSize!==!1?Math.max(i.minChunkSize,s*.01):0,l=(A,P)=>{let C=Buffer.byteLength(A);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(A)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(A,P)=>{let C=Buffer.byteLength(A),M=null,T=o,z,U=0;if(a){let R=Date.now();(!i.ts||(U=R-i.ts)>=c)&&(i.ts=R,z=s-i.bytes,i.bytes=z<0?-z:0,U=0),z=s-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,A)},c-U);z<T&&(T=z)}T&&C>T&&C-T>u&&(M=A.subarray(T),A=A.subarray(0,T)),l(A,M?()=>{process.nextTick(P,null,M)}:P)};m(t,function A(P,C){if(P)return n(P);C?m(C,A):n(null)})}},cgf=sgf;var Ewy=require("events");var swy=fa(require("util"),1),cwy=require("stream");var{asyncIterator:uwy}=Symbol,NuC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[uwy]?yield*e[uwy]():yield e},MEs=NuC;var FuC=V2.ALPHABET.ALPHA_DIGIT+"-_",YJo=typeof TextEncoder=="function"?new TextEncoder:new swy.default.TextEncoder,$sa=`\r
|
|
2167
2167
|
`,xuC=YJo.encode($sa),zuC=2,lgf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Yf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${$sa}`;i?r=YJo.encode(String(r).replace(/\r?\n|\r\n?/g,$sa)):a+=`Content-Type: ${r.type||"application/octet-stream"}${$sa}`,this.headers=YJo.encode(a+$sa),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+zuC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Yf.isTypedArray(t)?yield t:yield*MEs(t),yield xuC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},QuC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+V2.generateString(i,FuC)}=r||{};if(!Yf.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=YJo.encode("--"+a+$sa),c=YJo.encode("--"+a+"--"+$sa),d=c.byteLength,s=Array.from(e.entries()).map(([l,m])=>{let A=new lgf(l,m);return d+=A.size,A});d+=o.byteLength*s.length,d=Yf.toFiniteNumber(d);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(u["Content-Length"]=d),t&&t(u),cwy.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},lwy=QuC;var fwy=fa(require("stream"),1),fgf=class extends fwy.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)}},dwy=fgf;var LuC=(e,t)=>Yf.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,pwy=LuC;function UuC(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(d){let s=Date.now(),u=n[a];o||(o=s),r[i]=d,n[i]=s;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),s-o<t)return;let A=u&&s-u;return A?Math.round(m*1e3/A):void 0}}var _wy=UuC;function VuC(e,t){let r=0,n=1e3/t,i,a,o=(s,u=Date.now())=>{r=u,i=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=n?o(s,u):(i=s,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var hwy=VuC;var AAi=(e,t,r=3)=>{let n=0,i=_wy(50,250);return hwy(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,d=o-n,s=i(d),u=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:d,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},yka=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},vka=e=>(...t)=>Yf.asap(()=>e(...t));function dgf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let A=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,d=o-1,s=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);d>=0&&(n.charCodeAt(d)===61?(c++,d--):s(d)&&(c++,d-=3)),c===1&&d>=0&&(n.charCodeAt(d)===61||s(d))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var ywy={flush:PAi.default.constants.Z_SYNC_FLUSH,finishFlush:PAi.default.constants.Z_SYNC_FLUSH},WuC={flush:PAi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:PAi.default.constants.BROTLI_OPERATION_FLUSH},vwy=Yf.isFunction(PAi.default.createBrotliDecompress),{http:HuC,https:GuC}=jwy.default,JuC=/https:?/,bwy=V2.protocols.map(e=>e+":"),gwy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function KuC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Swy(e,t,r){let n=t;if(!n&&n!==!1){let i=Owy.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){Swy(a,t,a.href)}}var $uC=typeof process<"u"&&Yf.kindOf(process)==="process",YuC=e=>new Promise((t,r)=>{let n,i,a=(d,s)=>{i||(i=!0,n&&n(d,s))},o=d=>{a(d),t(d)},c=d=>{a(d,!0),r(d)};e(o,c,d=>n=d).catch(c)}),XuC=({address:e,family:t})=>{if(!Yf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},mwy=(e,t)=>XuC(Yf.isObject(e)?e:{address:e,family:t}),Dwy=$uC&&function(t){return YuC(async function(n,i,a){let{data:o,lookup:c,family:d}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),m,A=!1,P;if(c){let Se=pwy(c,St=>Yf.isArray(St)?St:[St]);c=(St,yt,Ne)=>{Se(St,yt,(De,Qt,Xe)=>{if(De)return Ne(De);let Yt=Yf.isArray(Qt)?Qt.map(Mt=>mwy(Mt)):[mwy(Qt,Xe)];yt.all?Ne(De,Yt):Ne(De,Yt[0].address,Yt[0].family)})}}let C=new Ewy.EventEmitter,M=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Se,St)=>{m=!0,St&&(A=!0,M())});function T(Se){C.emit("abort",!Se||Se.type?new Bnt(null,t,P):Se)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=Jsa(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,V2.hasBrowserEnv?V2.origin:void 0),R=U.protocol||bwy[0];if(R==="data:"){if(t.maxContentLength>-1){let St=String(t.url||z||"");if(dgf(St)>t.maxContentLength)return i(new Dm("maxContentLength size of "+t.maxContentLength+" exceeded",Dm.ERR_BAD_RESPONSE,t))}let Se;if(l!=="GET")return S9r(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=ogf(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(St){throw Dm.from(St,Dm.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(u),(!u||u==="utf8")&&(Se=Yf.stripBOM(Se))):s==="stream"&&(Se=Ysa.default.Readable.from(Se)),S9r(n,i,{data:Se,status:200,statusText:"OK",headers:new j$,config:t})}if(bwy.indexOf(R)===-1)return i(new Dm("Unsupported protocol "+R,Dm.ERR_BAD_REQUEST,t));let V=j$.from(t.headers).normalize();V.set("User-Agent","axios/"+Ksa,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,X=t.maxRate,ee,ne;if(Yf.isSpecCompliantForm(o)){let Se=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=lwy(o,St=>{V.set(St)},{tag:`axios-${Ksa}-boundary`,boundary:Se&&Se[1]||void 0})}else if(Yf.isFormData(o)&&Yf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Se=await wwy.default.promisify(o.getLength).call(o);Number.isFinite(Se)&&Se>=0&&V.setContentLength(Se)}catch{}}else if(Yf.isBlob(o)||Yf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=Ysa.default.Readable.from(MEs(o));else if(o&&!Yf.isStream(o)){if(!Buffer.isBuffer(o))if(Yf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Yf.isString(o))o=Buffer.from(o,"utf-8");else return i(new Dm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Dm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new Dm("Request body larger than maxBodyLength limit",Dm.ERR_BAD_REQUEST,t))}let Oe=Yf.toFiniteNumber(V.getContentLength());Yf.isArray(X)?(ee=X[0],ne=X[1]):ee=ne=X,o&&($||ee)&&(Yf.isStream(o)||(o=Ysa.default.Readable.from(o,{objectMode:!1})),o=Ysa.default.pipeline([o,new cgf({maxRate:Yf.toFiniteNumber(ee)})],Yf.noop),$&&o.on("progress",gwy(o,yka(Oe,AAi(vka($),!1,3)))));let be;if(t.auth){let Se=t.auth.username||"",St=t.auth.password||"";be=Se+":"+St}if(!be&&U.username){let Se=U.username,St=U.password;be=Se+":"+St}be&&V.delete("authorization");let me;try{me=Gsa(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let St=new Error(Se.message);return St.config=t,St.url=t.url,St.exists=!0,i(St)}V.set("Accept-Encoding","gzip, compress, deflate"+(vwy?", br":""),!1);let he={path:me,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:be,protocol:R,family:d,beforeRedirect:KuC,beforeRedirects:{}};!Yf.isUndefined(c)&&(he.lookup=c),t.socketPath?he.socketPath=t.socketPath:(he.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,he.port=U.port,Swy(he,t.proxy,R+"//"+U.hostname+(U.port?":"+U.port:"")+he.path));let Me,Be=JuC.test(he.protocol);if(he.agent=Be?t.httpsAgent:t.httpAgent,t.transport?Me=t.transport:t.maxRedirects===0?Me=Be?Pwy.default:Awy.default:(t.maxRedirects&&(he.maxRedirects=t.maxRedirects),t.beforeRedirect&&(he.beforeRedirects.config=t.beforeRedirect),Me=Be?GuC:HuC),t.maxBodyLength>-1?he.maxBodyLength=t.maxBodyLength:he.maxBodyLength=1/0,t.insecureHTTPParser&&(he.insecureHTTPParser=t.insecureHTTPParser),P=Me.request(he,function(St){if(P.destroyed)return;let yt=[St],Ne=+St.headers["content-length"];if(re||ne){let Mt=new cgf({maxRate:Yf.toFiniteNumber(ne)});re&&Mt.on("progress",gwy(Mt,yka(Ne,AAi(vka(re),!0,3)))),yt.push(Mt)}let De=St,Qt=St.req||P;if(t.decompress!==!1&&St.headers["content-encoding"])switch((l==="HEAD"||St.statusCode===204)&&delete St.headers["content-encoding"],(St.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":yt.push(PAi.default.createUnzip(ywy)),delete St.headers["content-encoding"];break;case"deflate":yt.push(new dwy),yt.push(PAi.default.createUnzip(ywy)),delete St.headers["content-encoding"];break;case"br":vwy&&(yt.push(PAi.default.createBrotliDecompress(WuC)),delete St.headers["content-encoding"])}De=yt.length>1?Ysa.default.pipeline(yt,Yf.noop):yt[0];let Xe=Ysa.default.finished(De,()=>{Xe(),M()}),Yt={status:St.statusCode,statusText:St.statusMessage,headers:new j$(St.headers),config:t,request:Qt};if(s==="stream")Yt.data=De,S9r(n,i,Yt);else{let Mt=[],Ke=0;De.on("data",function(sr){Mt.push(sr),Ke+=sr.length,t.maxContentLength>-1&&Ke>t.maxContentLength&&(A=!0,De.destroy(),i(new Dm("maxContentLength size of "+t.maxContentLength+" exceeded",Dm.ERR_BAD_RESPONSE,t,Qt)))}),De.on("aborted",function(){if(A)return;let sr=new Dm("stream has been aborted",Dm.ERR_BAD_RESPONSE,t,Qt);De.destroy(sr),i(sr)}),De.on("error",function(sr){P.destroyed||i(Dm.from(sr,null,t,Qt))}),De.on("end",function(){try{let sr=Mt.length===1?Mt[0]:Buffer.concat(Mt);s!=="arraybuffer"&&(sr=sr.toString(u),(!u||u==="utf8")&&(sr=Yf.stripBOM(sr))),Yt.data=sr}catch(sr){return i(Dm.from(sr,null,t,Yt.request,Yt))}S9r(n,i,Yt)})}C.once("abort",Mt=>{De.destroyed||(De.emit("error",Mt),De.destroy())})}),C.once("abort",Se=>{i(Se),P.destroy(Se)}),P.on("error",function(St){i(Dm.from(St,null,t,P))}),P.on("socket",function(St){St.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){i(new Dm("error trying to parse `config.timeout` to int",Dm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Se,function(){if(m)return;let yt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ne=t.transitional||pka;t.timeoutErrorMessage&&(yt=t.timeoutErrorMessage),i(new Dm(yt,Ne.clarifyTimeoutError?Dm.ETIMEDOUT:Dm.ECONNABORTED,t,P)),T()})}if(Yf.isStream(o)){let Se=!1,St=!1;o.on("end",()=>{Se=!0}),o.once("error",yt=>{St=!0,P.destroy(yt)}),o.on("close",()=>{!Se&&!St&&T(new Bnt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var Cwy=V2.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,V2.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(V2.origin),V2.navigator&&/(msie|trident)/i.test(V2.navigator.userAgent)):()=>!0;var Iwy=V2.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Yf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Yf.isString(n)&&o.push("path="+n),Yf.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 Mwy=e=>e instanceof j$?{...e}:e;function iqr(e,t){t=t||{};let r={};function n(s,u,l,m){return Yf.isPlainObject(s)&&Yf.isPlainObject(u)?Yf.merge.call({caseless:m},s,u):Yf.isPlainObject(u)?Yf.merge({},u):Yf.isArray(u)?u.slice():u}function i(s,u,l,m){if(Yf.isUndefined(u)){if(!Yf.isUndefined(s))return n(void 0,s,l,m)}else return n(s,u,l,m)}function a(s,u){if(!Yf.isUndefined(u))return n(void 0,u)}function o(s,u){if(Yf.isUndefined(u)){if(!Yf.isUndefined(s))return n(void 0,s)}else return n(void 0,u)}function c(s,u,l){if(l in t)return n(s,u);if(l in e)return n(void 0,s)}let d={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>i(Mwy(s),Mwy(u),l,!0)};return Yf.forEach(Object.keys({...e,...t}),function(u){let l=d[u]||i,m=l(e[u],t[u],u);Yf.isUndefined(m)&&l!==c||(r[u]=m)}),r}var BEs=e=>{let t=iqr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=j$.from(o),t.url=Gsa(Jsa(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Yf.isFormData(r)){if(V2.hasStandardBrowserEnv||V2.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Yf.isFunction(r.getHeaders)){let d=r.getHeaders(),s=["content-type","content-length"];Object.entries(d).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(V2.hasStandardBrowserEnv&&(n&&Yf.isFunction(n)&&(n=n(t)),n||n!==!1&&Cwy(t.url))){let d=i&&a&&Iwy.read(a);d&&o.set(i,d)}return t};var ZuC=typeof XMLHttpRequest<"u",Bwy=ZuC&&function(e){return new Promise(function(r,n){let i=BEs(e),a=i.data,o=j$.from(i.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:s}=i,u,l,m,A,P;function C(){A&&A(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let M=new XMLHttpRequest;M.open(i.method.toUpperCase(),i.url,!0),M.timeout=i.timeout;function T(){if(!M)return;let U=j$.from("getAllResponseHeaders"in M&&M.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?M.responseText:M.response,status:M.status,statusText:M.statusText,headers:U,config:e,request:M};S9r(function(re){r(re),C()},function(re){n(re),C()},V),M=null}"onloadend"in M?M.onloadend=T:M.onreadystatechange=function(){!M||M.readyState!==4||M.status===0&&!(M.responseURL&&M.responseURL.indexOf("file:")===0)||setTimeout(T)},M.onabort=function(){M&&(n(new Dm("Request aborted",Dm.ECONNABORTED,e,M)),M=null)},M.onerror=function(R){let V=R&&R.message?R.message:"Network Error",$=new Dm(V,Dm.ERR_NETWORK,e,M);$.event=R||null,n($),M=null},M.ontimeout=function(){let R=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||pka;i.timeoutErrorMessage&&(R=i.timeoutErrorMessage),n(new Dm(R,V.clarifyTimeoutError?Dm.ETIMEDOUT:Dm.ECONNABORTED,e,M)),M=null},a===void 0&&o.setContentType(null),"setRequestHeader"in M&&Yf.forEach(o.toJSON(),function(R,V){M.setRequestHeader(V,R)}),Yf.isUndefined(i.withCredentials)||(M.withCredentials=!!i.withCredentials),c&&c!=="json"&&(M.responseType=i.responseType),s&&([m,P]=AAi(s,!0),M.addEventListener("progress",m)),d&&M.upload&&([l,A]=AAi(d),M.upload.addEventListener("progress",l),M.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(u=U=>{M&&(n(!U||U.type?new Bnt(null,e,M):U),M.abort(),M=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));let z=$Jo(i.url);if(z&&V2.protocols.indexOf(z)===-1){n(new Dm("Unsupported protocol "+z+":",Dm.ERR_BAD_REQUEST,e));return}M.send(a||null)})};var kuC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(s){if(!i){i=!0,c();let u=s instanceof Error?s:this.reason;n.abort(u instanceof Dm?u:new Bnt(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new Dm(`timeout ${t} of ms exceeded`,Dm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=n;return d.unsubscribe=()=>Yf.asap(c),d}},Twy=kuC;var esC=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},tsC=async function*(e,t){for await(let r of rsC(e))yield*esC(r,t)},rsC=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()}},pgf=(e,t,r,n)=>{let i=tsC(e,t),a=0,o,c=d=>{o||(o=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:s,value:u}=await i.next();if(s){c(),d.close();return}let l=u.byteLength;if(r){let m=a+=l;r(m)}d.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(d){return c(d),i.return()}},{highWaterMark:2})};var qwy=64*1024,{isFunction:TEs}=Yf,nsC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Yf.global),{ReadableStream:Rwy,TextEncoder:Nwy}=Yf.global,Fwy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},isC=e=>{e=Yf.merge.call({skipUndefined:!0},nsC,e);let{fetch:t,Request:r,Response:n}=e,i=t?TEs(t):typeof fetch=="function",a=TEs(r),o=TEs(n);if(!i)return!1;let c=i&&TEs(Rwy),d=i&&(typeof Nwy=="function"?(P=>C=>P.encode(C))(new Nwy):async P=>new Uint8Array(await new r(P).arrayBuffer())),s=a&&c&&Fwy(()=>{let P=!1,C=new r(V2.origin,{body:new Rwy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),u=o&&c&&Fwy(()=>Yf.isReadableStream(new n("").body)),l={stream:u&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,M)=>{let T=C&&C[P];if(T)return T.call(C);throw new Dm(`Response type '${P}' is not supported`,Dm.ERR_NOT_SUPPORT,M)})});let m=async P=>{if(P==null)return 0;if(Yf.isBlob(P))return P.size;if(Yf.isSpecCompliantForm(P))return(await new r(V2.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Yf.isArrayBufferView(P)||Yf.isArrayBuffer(P))return P.byteLength;if(Yf.isURLSearchParams(P)&&(P=P+""),Yf.isString(P))return(await d(P)).byteLength},A=async(P,C)=>{let M=Yf.toFiniteNumber(P.getContentLength());return M??m(C)};return async P=>{let{url:C,method:M,data:T,signal:z,cancelToken:U,timeout:R,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:X,withCredentials:ee="same-origin",fetchOptions:ne}=BEs(P),Oe=t||fetch;re=re?(re+"").toLowerCase():"text";let be=Twy([z,U&&U.toAbortSignal()],R),me=null,he=be&&be.unsubscribe&&(()=>{be.unsubscribe()}),Me;try{if($&&s&&M!=="get"&&M!=="head"&&(Me=await A(X,T))!==0){let De=new r(C,{method:"POST",body:T,duplex:"half"}),Qt;if(Yf.isFormData(T)&&(Qt=De.headers.get("content-type"))&&X.setContentType(Qt),De.body){let[Xe,Yt]=yka(Me,AAi(vka($)));T=pgf(De.body,qwy,Xe,Yt)}}Yf.isString(ee)||(ee=ee?"include":"omit");let Be=a&&"credentials"in r.prototype,Se={...ne,signal:be,method:M.toUpperCase(),headers:X.normalize().toJSON(),body:T,duplex:"half",credentials:Be?ee:void 0};me=a&&new r(C,Se);let St=await(a?Oe(me,ne):Oe(C,Se)),yt=u&&(re==="stream"||re==="response");if(u&&(V||yt&&he)){let De={};["status","statusText","headers"].forEach(Mt=>{De[Mt]=St[Mt]});let Qt=Yf.toFiniteNumber(St.headers.get("content-length")),[Xe,Yt]=V&&yka(Qt,AAi(vka(V),!0))||[];St=new n(pgf(St.body,qwy,Xe,()=>{Yt&&Yt(),he&&he()}),De)}re=re||"text";let Ne=await l[Yf.findKey(l,re)||"text"](St,P);return!yt&&he&&he(),await new Promise((De,Qt)=>{S9r(De,Qt,{data:Ne,headers:j$.from(St.headers),status:St.status,statusText:St.statusText,config:P,request:me})})}catch(Be){throw he&&he(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new Dm("Network Error",Dm.ERR_NETWORK,P,me),{cause:Be.cause||Be}):Dm.from(Be,Be&&Be.code,P,me)}}},asC=new Map,_gf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,d,s,u=asC;for(;c--;)d=a[c],s=u.get(d),s===void 0&&u.set(d,s=c?new Map:isC(t)),u=s;return s},$T9=_gf();var hgf={http:Dwy,xhr:Bwy,fetch:{get:_gf}};Yf.forEach(hgf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var xwy=e=>`- ${e}`,usC=e=>Yf.isFunction(e)||e===null||e===!1,qEs={getAdapter:(e,t)=>{e=Yf.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,!usC(n)&&(i=hgf[(c=String(n)).toLowerCase()],i===void 0))throw new Dm(`Unknown adapter '${c}'`);if(i&&(Yf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([d,s])=>`adapter ${d} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -2402,15 +2402,16 @@ ${R}${z}${V}${ono}`});function XRs({message:e,error:t,logger:r,logLevel:n=K1.Err
|
|
|
2402
2402
|
Run ${od.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2403
2403
|
Run ${od.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),gka(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function ABf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!BWy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of o)i+=`
|
|
2404
2404
|
${await KLC(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+od.dim(c.currentVersion)+od.reset(" \u2192 ")+od.green(c.latestVersion);return i+=`
|
|
2405
|
-
`,n?gka(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function KLC(e){let r=await new MWy.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 $LC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await qWy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=hzi(u.name,l),A=await gLr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await qWy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=hzi(s.name,u),m=await gLr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function qWy({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 RTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(i!=null&&d.groupName!==i))for(let s of d.generators)n!=null&&s.name!==n||await r(a.workspaceName,d.groupName,s,o)}})}))}function RWy(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 d=a3e(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function tNs({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await $LC({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...RWy(s,d,t.logger));else o.push(...RWy(c.versions,void 0,t.logger))}return o}var FXo=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 lno=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var PBf=(()=>{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})(),NWy=typeof globalThis.AbortController=="function",FWy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",xWy=typeof globalThis.ReadableStream=="function",zWy=typeof globalThis.FormData=="function",rNs=["get","post","put","patch","head","delete"],YLC=()=>{};YLC();var QWy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},nNs=2147483647,LWy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,iNs=Symbol("stop"),UWy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},VWy={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 XLC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=LWy,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},WWy=(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))}}))},HWy=(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(WWy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},GWy=(e,t,r)=>{if(!e.body)return e;let n=XLC(r??e.body);return new Request(e,{duplex:"half",body:WWy(e.body,n,t)})};var fno=e=>e!==null&&typeof e=="object";var xXo=(...e)=>{for(let t of e)if((!fno(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return EBf({},...e)},wBf=(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 aNs(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:EBf(e[r]??[],t[r]??[])}var jBf=(e={},t={})=>({beforeRequest:aNs(e,t,"beforeRequest"),beforeRetry:aNs(e,t,"beforeRetry"),afterResponse:aNs(e,t,"afterResponse"),beforeError:aNs(e,t,"beforeError")}),EBf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(fno(i)){for(let[a,o]of Object.entries(i))fno(o)&&a in t&&(o=EBf(t[a],o)),t={...t,[a]:o};fno(i.hooks)&&(n=jBf(n,i.hooks),t.hooks=n),fno(i.headers)&&(r=wBf(r,i.headers),t.headers=r)}return t};var KWy=e=>rNs.includes(e)?e.toUpperCase():e,ZLC=["get","put","head","delete","options","trace"],kLC=[408,413,429,500,502,503,504],eUC=[413,429,503],JWy={limit:2,methods:ZLC,statusCodes:kLC,afterStatusCodes:eUC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},$Wy=(e={})=>{if(typeof e=="number")return{...JWy,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{...JWy,...e}};async function SBf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new lno(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function DBf(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 YWy=(e,t)=>{let r={};for(let n in t)!(n in VWy)&&!(n in UWy)&&!(n in e)&&(r[n]=t[n]);return r},XWy=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 zXo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>nNs)throw new RangeError(`The \`timeout\` option cannot be greater than ${nNs}`);await Promise.resolve();let c=await n._fetch();for(let d of n._options.hooks.afterResponse){let s=await d(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let d=new FXo(c,n.request,n._options);for(let s of n._options.hooks.beforeError)d=await s(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!xWy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return HWy(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,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),n.request.bodyUsed||d.push(n.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(QWy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:wBf(this._input.headers,r.headers),hooks:jBf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:KWy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:$Wy(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(NWy&&FWy){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(PBf&&(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),XWy(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);(zWy&&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(!PBf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=GWy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof lno)throw t;if(t instanceof FXo){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),nNs);if(this._retryCount<1)throw r;await DBf(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})===iNs)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=YWy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):SBf(this._originalRequest,t,this.abortController,this._options)}};var CBf=e=>{let t=(r,n)=>zXo.create(r,xXo(e,n));for(let r of rNs)t[r]=(n,i)=>zXo.create(n,xXo(e,i,{method:r}));return t.create=r=>CBf(xXo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),CBf(xXo(e,r))),t.stop=iNs,t},tUC=CBf(),ZWy=tUC;var OHy=fa(mHy(),1);function qBf(e){let t=(0,OHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var hGy=fa(_Gy(),1),yGy=fa(v5r(),1),JBf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},KBf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function $Bf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??qBf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,hGy.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await ZWy(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new JBf(e):l}if(t.allVersions)return s;let u=new KBf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=yGy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function HXo(e,t){let{version:r}=await $Bf(e.toLowerCase(),t);return r}async function t7i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:HXo(e.packageName,{version:t?"prerelease":"latest"})}var vGy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],vNs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=K1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new eNs(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.93.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${od.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new sie}failWithoutThrowing(t,r){this.didSucceed=!1,XRs({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await cka()).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 TWy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2405
|
+
`,n?gka(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function KLC(e){let r=await new MWy.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 $LC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await qWy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=hzi(u.name,l),A=await gLr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await qWy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=hzi(s.name,u),m=await gLr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function qWy({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 RTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(i!=null&&d.groupName!==i))for(let s of d.generators)n!=null&&s.name!==n||await r(a.workspaceName,d.groupName,s,o)}})}))}function RWy(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 d=a3e(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function tNs({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await $LC({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...RWy(s,d,t.logger));else o.push(...RWy(c.versions,void 0,t.logger))}return o}var FXo=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 lno=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var PBf=(()=>{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})(),NWy=typeof globalThis.AbortController=="function",FWy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",xWy=typeof globalThis.ReadableStream=="function",zWy=typeof globalThis.FormData=="function",rNs=["get","post","put","patch","head","delete"],YLC=()=>{};YLC();var QWy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},nNs=2147483647,LWy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,iNs=Symbol("stop"),UWy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},VWy={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 XLC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=LWy,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},WWy=(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))}}))},HWy=(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(WWy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},GWy=(e,t,r)=>{if(!e.body)return e;let n=XLC(r??e.body);return new Request(e,{duplex:"half",body:WWy(e.body,n,t)})};var fno=e=>e!==null&&typeof e=="object";var xXo=(...e)=>{for(let t of e)if((!fno(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return EBf({},...e)},wBf=(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 aNs(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:EBf(e[r]??[],t[r]??[])}var jBf=(e={},t={})=>({beforeRequest:aNs(e,t,"beforeRequest"),beforeRetry:aNs(e,t,"beforeRetry"),afterResponse:aNs(e,t,"afterResponse"),beforeError:aNs(e,t,"beforeError")}),EBf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(fno(i)){for(let[a,o]of Object.entries(i))fno(o)&&a in t&&(o=EBf(t[a],o)),t={...t,[a]:o};fno(i.hooks)&&(n=jBf(n,i.hooks),t.hooks=n),fno(i.headers)&&(r=wBf(r,i.headers),t.headers=r)}return t};var KWy=e=>rNs.includes(e)?e.toUpperCase():e,ZLC=["get","put","head","delete","options","trace"],kLC=[408,413,429,500,502,503,504],eUC=[413,429,503],JWy={limit:2,methods:ZLC,statusCodes:kLC,afterStatusCodes:eUC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},$Wy=(e={})=>{if(typeof e=="number")return{...JWy,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{...JWy,...e}};async function SBf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new lno(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function DBf(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 YWy=(e,t)=>{let r={};for(let n in t)!(n in VWy)&&!(n in UWy)&&!(n in e)&&(r[n]=t[n]);return r},XWy=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 zXo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>nNs)throw new RangeError(`The \`timeout\` option cannot be greater than ${nNs}`);await Promise.resolve();let c=await n._fetch();for(let d of n._options.hooks.afterResponse){let s=await d(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let d=new FXo(c,n.request,n._options);for(let s of n._options.hooks.beforeError)d=await s(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!xWy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return HWy(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,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),n.request.bodyUsed||d.push(n.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(QWy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:wBf(this._input.headers,r.headers),hooks:jBf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:KWy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:$Wy(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(NWy&&FWy){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(PBf&&(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),XWy(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);(zWy&&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(!PBf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=GWy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof lno)throw t;if(t instanceof FXo){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),nNs);if(this._retryCount<1)throw r;await DBf(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})===iNs)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=YWy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):SBf(this._originalRequest,t,this.abortController,this._options)}};var CBf=e=>{let t=(r,n)=>zXo.create(r,xXo(e,n));for(let r of rNs)t[r]=(n,i)=>zXo.create(n,xXo(e,i,{method:r}));return t.create=r=>CBf(xXo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),CBf(xXo(e,r))),t.stop=iNs,t},tUC=CBf(),ZWy=tUC;var OHy=fa(mHy(),1);function qBf(e){let t=(0,OHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var hGy=fa(_Gy(),1),yGy=fa(v5r(),1),JBf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},KBf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function $Bf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??qBf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,hGy.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await ZWy(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new JBf(e):l}if(t.allVersions)return s;let u=new KBf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=yGy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function HXo(e,t){let{version:r}=await $Bf(e.toLowerCase(),t);return r}async function t7i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:HXo(e.packageName,{version:t?"prerelease":"latest"})}var vGy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],vNs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=K1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new eNs(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.93.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${od.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new sie}failWithoutThrowing(t,r){this.didSucceed=!1,XRs({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await cka()).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 TWy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2406
2406
|
`)||(r+=`
|
|
2407
2407
|
`),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=C$l(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 MXo(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 sie}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await cka()).sendEvent(t)}logger=q5r((t,...r)=>this.log(t,...r));stderr=q5r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=bGy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?bGy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=vGy[this.numTasks++%vGy.length],o=od.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===bV.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=>C3i.indexOf(i.level)>=C3i.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===K1.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 t7i({cliEnvironment:this.environment,includePreReleases:t}),n=a3e(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await tNs({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await fBf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:od.yellow("?"),style:{answer:i=>od.cyan(i),message:i=>od.bold(i),highlight:i=>od.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|
|
2408
2408
|
Cancelled by user.`),new sie):n}}async getInput(t){return await uBf({message:t.message,default:t.default})}};function bGy(e){return`[${e}]:`}var Dqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var ait=class extends Dqr{definition;sources;type="fern";constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var hyt={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0,groupEnvironmentsByHost:!1};function GXo({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??hyt.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??hyt.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??hyt.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??hyt.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??hyt.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??hyt.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??hyt.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??hyt.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??hyt.respectForwardCompatibleEnums,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??hyt.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??hyt.coerceOptionalSchemasToNullable,groupEnvironmentsByHost:t?.groupEnvironmentsByHost??e?.groupEnvironmentsByHost??hyt.groupEnvironmentsByHost}}var gwe={openapi:e=>({...e,type:"openapi",_visit:function(t){return gwe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return gwe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var bno={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return bno._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Hde={basic:e=>({...e,type:"basic",_visit:function(t){return Hde._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Hde._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Hde._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Hde._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Hde._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var wS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return wS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return wS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return wS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return wS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return wS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return wS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return wS._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return wS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return wS._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"null":return t.null(e);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var wO={int:e=>({value:e,type:"int",_visit:function(t){return wO._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return wO._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return wO._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return wO._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return wO._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return wO._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return wO._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return wO._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return wO._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return wO._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return wO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var r7i={boolean:e=>({value:e,type:"boolean",_visit:function(t){return r7i._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return r7i._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var n7i={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return n7i._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return n7i._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var bNs={};ff(bNs,{Availability:()=>Gde,CustomCodeSample:()=>OVr,EndpointExample:()=>yyt,EndpointResponseExample:()=>vyt,HttpMethod:()=>Kde,LiteralSchemaValue:()=>FV,MultipartRequestPropertyEncoding:()=>ZBf,MultipartSchema:()=>AVr,OneOfSchema:()=>PVr,Pagination:()=>oit,PrimitiveSchemaValue:()=>Oq,Request:()=>Cqr,Response:()=>Wbe,RetriesConfiguration:()=>JXo,Schema:()=>kj,SupportedSdkLanguage:()=>Jde,WebhookHttpMethod:()=>XBf,WebsocketMessageOrigin:()=>YBf});var YBf={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case YBf.Client:return t.client();case YBf.Server:return t.server();default:return t._other()}}};var XBf={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case XBf.Get:return t.get();case XBf.Post:return t.post();default:return t._other()}}};var Gde={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case Gde.GenerallyAvailable:return t.generallyAvailable();case Gde.Beta:return t.beta();case Gde.Deprecated:return t.deprecated();default:return t._other()}}};var JXo={disabled:e=>({value:e,type:"disabled",_visit:function(t){return JXo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var oit={cursor:e=>({...e,type:"cursor",_visit:function(t){return oit._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return oit._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return oit._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var OVr={language:e=>({...e,type:"language",_visit:function(t){return OVr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return OVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var Jde={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case Jde.Curl:return t.curl();case Jde.Python:return t.python();case Jde.Javascript:return t.javascript();case Jde.Typescript:return t.typescript();case Jde.Go:return t.go();case Jde.Ruby:return t.ruby();case Jde.Csharp:return t.csharp();case Jde.Java:return t.java();case Jde.Js:return t.js();case Jde.Node:return t.node();case Jde.Ts:return t.ts();case Jde.Nodets:return t.nodets();case Jde.Golang:return t.golang();case Jde.Dotnet:return t.dotnet();case Jde.Jvm:return t.jvm();default:return t._other()}}};var yyt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return yyt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return yyt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var vyt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return vyt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return vyt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var Kde={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case Kde.Get:return t.get();case Kde.Post:return t.post();case Kde.Put:return t.put();case Kde.Patch:return t.patch();case Kde.Delete:return t.delete();case Kde.Head:return t.head();case Kde.Options:return t.options();case Kde.Trace:return t.trace();default:return t._other()}}};var Cqr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Cqr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Cqr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Cqr._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return Cqr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var ZBf={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case ZBf.Json:return t.json();case ZBf.Form:return t.form();default:return t._other()}}};var AVr={file:e=>({...e,type:"file",_visit:function(t){return AVr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return AVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var Wbe={file:e=>({...e,type:"file",_visit:function(t){return Wbe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Wbe._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Wbe._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Wbe._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Wbe._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Wbe._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Wbe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var kj={primitive:e=>({...e,type:"primitive",_visit:function(t){return kj._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return kj._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return kj._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return kj._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return kj._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return kj._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return kj._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return kj._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return kj._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return kj._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return kj._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Oq={int:e=>({...e,type:"int",_visit:function(t){return Oq._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Oq._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Oq._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Oq._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Oq._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Oq._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Oq._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Oq._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Oq._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Oq._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Oq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var FV={boolean:e=>({value:e,type:"boolean",_visit:function(t){return FV._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return FV._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var PVr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return PVr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return PVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var lIe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return lIe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return lIe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lIe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return lIe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var XL={file:e=>({...e,type:"file",_visit:function(t){return XL._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return XL._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return XL._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return XL._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return XL._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return XL._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return XL._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Oh={primitive:e=>({...e,type:"primitive",_visit:function(t){return Oh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Oh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Oh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Oh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Oh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Oh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Oh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Oh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Oh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Oh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Oh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var uit={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return uit._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return uit._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var U0={int:e=>({...e,type:"int",_visit:function(t){return U0._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return U0._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return U0._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return U0._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return U0._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return U0._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return U0._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return U0._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return U0._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return U0._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return U0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Mj={};ff(Mj,{AllOfPropertyConflict:()=>Wno,ArraySchema:()=>RFs,ArraySchemaWithExample:()=>dxs,Availability:()=>DNs,Base64WithExample:()=>uxs,BasicSecurityScheme:()=>INs,BearerSecurityScheme:()=>MNs,BooleanSchema:()=>CFs,BooleanWithExample:()=>sxs,BytesResponse:()=>qno,CasingOverrides:()=>qNs,CommonProperty:()=>VFs,CommonPropertyWithExample:()=>Oxs,CursorPagination:()=>dFs,CustomCodeSample:()=>lFs,CustomCodeSampleLanguage:()=>uFs,CustomCodeSampleSdk:()=>cFs,CustomPagination:()=>_Fs,DateWithExample:()=>oxs,DatetimeWithExample:()=>axs,DiscriminatedOneOfSchema:()=>LFs,DiscriminatedOneOfSchemaWithExample:()=>gxs,DoubleSchema:()=>SFs,DoubleWithExample:()=>nxs,Encoding:()=>SNs,Endpoint:()=>hFs,EndpointExample:()=>xno,EndpointResponseExample:()=>oFs,EndpointSdkName:()=>EVr,EndpointSecurity:()=>Eno,EndpointWithExample:()=>KGy,EnumSchema:()=>Pno,EnumSchemaWithExample:()=>lxs,EnumValue:()=>o7i,ErrorExample:()=>tFs,FernExample:()=>nFs,FileResponse:()=>Bno,FileSchema:()=>JNs,FloatWithExample:()=>rxs,FormUrlEncodedRequest:()=>ZNs,FullEndpointExample:()=>fFs,FullExample:()=>g5,FullObjectExample:()=>UNs,FullOneOfExample:()=>WNs,GlobalHeader:()=>MFs,Header:()=>s7i,HeaderExample:()=>Fno,HeaderSecurityScheme:()=>BNs,HeaderWithExample:()=>f7i,HttpEndpointServer:()=>Rno,HttpError:()=>rFs,HttpErrorWithExample:()=>XFs,HttpMethod:()=>Sno,IdempotencyHeader:()=>BFs,Int64WithExample:()=>kFs,IntSchema:()=>jFs,IntWithExample:()=>ZFs,JsonRequest:()=>XNs,JsonRequestWithExample:()=>JFs,JsonResponse:()=>Tno,JsonResponseWithExample:()=>Jno,KeyValuePair:()=>VNs,LiteralExample:()=>QNs,LiteralSchema:()=>Vno,LiteralSchemaValue:()=>TFs,LongSchema:()=>EFs,MapSchema:()=>NFs,MapSchemaWithExample:()=>pxs,MultipartRequest:()=>Mno,MultipartRequestProperty:()=>YNs,MultipartRequestPropertyEncoding:()=>$Ns,MultipartSchema:()=>KNs,NamedFullExample:()=>gyt,Namespace:()=>RNs,NamespaceId:()=>zNs,NullExample:()=>LNs,NullableSchema:()=>xFs,NullableSchemaWithExample:()=>hxs,OauthSecurityScheme:()=>FNs,ObjectProperty:()=>QFs,ObjectPropertyConflictInfo:()=>Hno,ObjectPropertyWithExample:()=>bxs,ObjectSchema:()=>qFs,ObjectSchemaWithExample:()=>yxs,OctetStreamRequest:()=>Ino,OffsetPagination:()=>pFs,OneOfSchema:()=>zFs,OneOfSchemaWithExample:()=>vxs,OpenApiIntermediateRepresentation:()=>GGy,OpenApiSource:()=>PNs,OptionalSchema:()=>FFs,OptionalSchemaWithExample:()=>_xs,Pagination:()=>zno,ParseFormUrlEncodedRequest:()=>KFs,ParseMultipartRequest:()=>GFs,ParseOctetStreamRequest:()=>HFs,PathParameter:()=>Dno,PathParameterExample:()=>iFs,PathParameterWithExample:()=>WFs,PrimitiveExample:()=>jno,PrimitiveSchema:()=>l7i,PrimitiveSchemaValue:()=>IFs,PrimitiveSchemaValueWithExample:()=>cxs,PrimitiveSchemaWithExample:()=>Kno,PropertyKey:()=>wno,ProtobufEncoding:()=>ENs,ProtobufSource:()=>wNs,QueryParameter:()=>Cno,QueryParameterExample:()=>Nno,QueryParameterWithExample:()=>Gno,QuerySecurityScheme:()=>TNs,ReferencedSchema:()=>SVr,Request:()=>kNs,RequestWithExample:()=>$Fs,Response:()=>eFs,ResponseWithExample:()=>YFs,RetriesConfiguration:()=>Qno,Schema:()=>SI,SchemaId:()=>fIe,SchemaWithExample:()=>J6,Schemas:()=>wFs,SdkGroup:()=>NNs,SdkGroupInfo:()=>HNs,SdkGroupName:()=>u7i,SecurityScheme:()=>xNs,SecuritySchemeId:()=>Ano,Server:()=>XXo,Source:()=>jNs,StatusCode:()=>wVr,StreamingResponseExample:()=>aFs,StringSchema:()=>DFs,StringSchemaWithExample:()=>ixs,SupportedSdkLanguage:()=>sFs,Tag:()=>CNs,TagId:()=>dIe,Tags:()=>GNs,TextResponse:()=>c7i,Uint64WithExample:()=>txs,UintWithExample:()=>exs,UnDiscriminatedOneOfSchema:()=>UFs,UnDiscriminatedOneOfSchemaWithExample:()=>mxs,UnknownSchemaWithExample:()=>fxs,Webhook:()=>yFs,WebhookExampleCall:()=>Uno,WebhookHttpMethod:()=>Lno,WebhookWithExample:()=>$Gy,WebsocketChannel:()=>PFs,WebsocketHandshake:()=>vFs,WebsocketHandshakeWithExample:()=>JGy,WebsocketMessageExample:()=>OFs,WebsocketMessageOrigin:()=>bFs,WebsocketMessageSchema:()=>gFs,WebsocketServer:()=>mFs,WebsocketSessionExample:()=>AFs,WithAvailability:()=>NP,WithDescription:()=>tv,WithEncoding:()=>u3e,WithInline:()=>G6,WithName:()=>fD,WithNamespace:()=>jS,WithSdkGroupName:()=>PM,WithSdkMethodName:()=>jVr,WithSource:()=>eP,WithStatusCode:()=>byt,WithTitle:()=>AM,commons:()=>nTf,example:()=>iTf,finalIr:()=>aTf,parseIr:()=>oTf});var nTf={};ff(nTf,{BasicSecurityScheme:()=>INs,BearerSecurityScheme:()=>MNs,Encoding:()=>SNs,HeaderSecurityScheme:()=>BNs,Namespace:()=>RNs,NamespaceId:()=>zNs,OauthSecurityScheme:()=>FNs,OpenApiSource:()=>PNs,ProtobufEncoding:()=>ENs,ProtobufSource:()=>wNs,QuerySecurityScheme:()=>TNs,SchemaId:()=>fIe,SdkGroup:()=>NNs,SdkGroupName:()=>u7i,SecurityScheme:()=>xNs,SecuritySchemeId:()=>Ano,Server:()=>XXo,Source:()=>jNs,StatusCode:()=>wVr,Tag:()=>CNs,TagId:()=>dIe,WithAvailability:()=>NP,WithDescription:()=>tv,WithEncoding:()=>u3e,WithInline:()=>G6,WithName:()=>fD,WithNamespace:()=>jS,WithSdkGroupName:()=>PM,WithSdkMethodName:()=>jVr,WithSource:()=>eP,WithStatusCode:()=>byt,WithTitle:()=>AM});var Gr={};ff(Gr,{JsonError:()=>gno,ParseError:()=>mno,any:()=>TGy,bigint:()=>mGy,boolean:()=>qGy,booleanLiteral:()=>BGy,date:()=>OGy,discriminant:()=>VGy,enum_:()=>mNs,getObjectLikeUtils:()=>Iqr,getObjectUtils:()=>cfa,getSchemaUtils:()=>b5,isProperty:()=>a7i,lazy:()=>AGy,lazyObject:()=>CGy,list:()=>ANs,number:()=>RGy,object:()=>ONs,objectWithoutOptionalProperties:()=>DGy,optional:()=>kBf,property:()=>wGy,record:()=>zGy,set:()=>QGy,string:()=>NGy,stringLiteral:()=>MGy,transform:()=>eTf,undiscriminatedUnion:()=>UGy,union:()=>HGy,unknown:()=>FGy,withParsedProperties:()=>rTf});var Aq={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function K2(e,t){return`Expected ${t}. Received ${u9C(e)}.`}function u9C(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function $de(e){return{...e,json:gGy(e.json),parse:gGy(e.parse)}}function gGy(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
2409
2409
|
`)),{ok:!0,value:t}):n}}function gNs(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var gno=class e extends Error{errors;constructor(t){super(t.map(gNs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var mno=class e extends Error{errors;constructor(t){super(t.map(gNs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function b5(e){return{optional:()=>kBf(e),transform:t=>eTf(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new mno(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new gno(n.errors)}}}function kBf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Aq.OPTIONAL};return{...t,...b5(t)}}function eTf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...b5(r)}}function mGy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:K2(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:K2(t,"bigint")}]},getType:()=>Aq.BIGINT};return{...$de(e),...b5(e)}}var s9C=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function OGy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:K2(t,"string")}]}:s9C.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:K2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:K2(t,"Date object")}]},getType:()=>Aq.DATE};return{...$de(e),...b5(e)}}function mwe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...$de(r),...b5(r)}}}function mNs(e){let t=new Set(e);return mwe(Aq.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:K2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:K2(n,"enum")}]}:{ok:!0,value:n})()}function AGy(e){let t=tTf(e);return{...t,...b5(t)}}function tTf(e){return{parse:(t,r)=>Ono(e).parse(t,r),json:(t,r)=>Ono(e).json(t,r),getType:()=>Ono(e).getType()}}function Ono(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function KXo(e){return Object.entries(e)}function $Xo(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function i7i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function YXo(e){return Object.keys(e)}function PGy(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function Iqr(e){return{withParsedProperties:t=>rTf(e,t)}}function rTf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(n,i)=>{if(!i7i(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:K2(n,"object")}]};let a=new Set(Object.keys(t)),o=$Xo(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(o,i)},getType:()=>e.getType()};return{...r,...b5(r),...Iqr(r)}}function wGy(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function a7i(e){return e.isProperty}function ONs(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>a7i(n)?n.rawKey:r),_getParsedProperties:()=>YXo(e),parse:(r,n)=>{let i={},a=[];for(let[o,c]of KXo(e)){let d=a7i(c)?c.rawKey:o,s=a7i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};i[d]=u,SGy(s)&&a.push(d)}return jGy({value:r,requiredKeys:a,getProperty:o=>{let c=i[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,o]of KXo(e)){let c=a7i(o)?o.valueSchema:o;SGy(c)&&i.push(a)}return jGy({value:r,requiredKeys:i,getProperty:a=>{let o=e[a];if(o!=null)return a7i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>Aq.OBJECT};return{...$de(t),...b5(t),...Iqr(t),...cfa(t)}}function jGy({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!i7i(e))return{ok:!1,errors:[{path:a,message:K2(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let m=l.transform(u);m.ok?d[l.transformedKey]=m.value:(d[s]=u,c.push(...m.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:d}:{ok:!1,errors:c}}function cfa(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>EGy({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>EGy({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>Aq.OBJECT};return{...r,...b5(r),...Iqr(r),...cfa(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>Aq.OBJECT};return{...t,...b5(t),...Iqr(t),...cfa(t)}}}}function EGy({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,o]=PGy(YXo(t),s=>i.has(s)),c=r($Xo(t,o)),d=n($Xo(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function SGy(e){return!c9C(e)}function c9C(e){switch(e.getType()){case Aq.ANY:case Aq.UNKNOWN:case Aq.OPTIONAL:return!0;default:return!1}}function DGy(e){return ONs(e)}function CGy(e){let t={...tTf(e),_getRawProperties:()=>Ono(e)._getRawProperties(),_getParsedProperties:()=>Ono(e)._getParsedProperties()};return{...t,...b5(t),...Iqr(t),...cfa(t)}}function ANs(e){let t={parse:(r,n)=>IGy(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>IGy(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Aq.LIST};return{...$de(t),...b5(t)}}function IGy(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:K2(e,"list"),path:[]}]}}function MGy(e){return mwe(Aq.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:K2(r,`"${e}"`)}]})()}function BGy(e){return mwe(Aq.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:K2(r,`${e.toString()}`)}]})()}var TGy=mwe(Aq.ANY,e=>({ok:!0,value:e}));var qGy=mwe(Aq.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:K2(e,"boolean")}]});var RGy=mwe(Aq.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:K2(e,"number")}]});var NGy=mwe(Aq.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:K2(e,"string")}]});var FGy=mwe(Aq.UNKNOWN,e=>({ok:!0,value:e}));function zGy(e,t){let r={parse:(n,i)=>xGy({value:n,isKeyNumeric:e.getType()===Aq.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>xGy({value:n,isKeyNumeric:e.getType()===Aq.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Aq.RECORD};return{...$de(r),...b5(r)}}function xGy({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return i7i(e)?KXo(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let A=o.length>0?Number(o):NaN;isNaN(A)||(s=A)}let u=r(s),l=n(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),u.ok||m.push(...u.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:K2(e,"object")}]}}function QGy(e){let t=ANs(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:K2(n,"Set")}]},getType:()=>Aq.SET};return{...$de(r),...b5(r)}}function UGy(e){let t={parse:(r,n)=>LGy((i,a)=>i.parse(r,a),e,n),json:(r,n)=>LGy((i,a)=>i.json(r,a),e,n),getType:()=>Aq.UNDISCRIMINATED_UNION};return{...$de(t),...b5(t)}}function LGy(e,t,r){let n=[];for(let[i,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function VGy(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function HGy(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=mNs(YXo(t)),a={parse:(o,c)=>WGy({value:o,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>WGy({value:o,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>Aq.UNION};return{...$de(a),...b5(a),...Iqr(a)}}function WGy({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!i7i(e))return{ok:!1,errors:[{path:c,message:K2(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=n(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=i(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let m=o(s,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var AM=Gr.objectWithoutOptionalProperties({title:Gr.string().optional()});var PNs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var wNs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var jNs=Gr.union("type",{openapi:PNs,protobuf:wNs}).transform({transform:e=>{switch(e.type){case"openapi":return gwe.openapi(e);case"protobuf":return gwe.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var eP=Gr.objectWithoutOptionalProperties({source:jNs.optional()});var ENs=Gr.objectWithoutOptionalProperties({typeName:Gr.string()});var SNs=Gr.union("type",{protobuf:ENs}).transform({transform:e=>{switch(e.type){case"protobuf":return bno.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var u3e=Gr.objectWithoutOptionalProperties({encoding:SNs.optional()});var tv=Gr.objectWithoutOptionalProperties({description:Gr.string().optional()});var DNs=Gr.enum_(["GenerallyAvailable","Beta","Deprecated"]);var NP=Gr.objectWithoutOptionalProperties({availability:DNs.optional()});var wVr=Gr.number();var byt=Gr.objectWithoutOptionalProperties({statusCode:wVr.optional()});var fD=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string()});var G6=Gr.objectWithoutOptionalProperties({inline:Gr.boolean().optional()});var fIe=Gr.string();var dIe=Gr.string();var CNs=Gr.objectWithoutOptionalProperties({id:dIe}).extend(tv);var Ano=Gr.string();var INs=Gr.objectWithoutOptionalProperties({usernameVariableName:Gr.string().optional(),usernameEnvVar:Gr.string().optional(),passwordVariableName:Gr.string().optional(),passwordEnvVar:Gr.string().optional()});var MNs=Gr.objectWithoutOptionalProperties({tokenVariableName:Gr.string().optional(),tokenEnvVar:Gr.string().optional()});var BNs=Gr.objectWithoutOptionalProperties({headerName:Gr.string(),prefix:Gr.string().optional(),headerVariableName:Gr.string().optional(),headerEnvVar:Gr.string().optional()});var TNs=Gr.objectWithoutOptionalProperties({queryParameterName:Gr.string()});var qNs=Gr.objectWithoutOptionalProperties({snake:Gr.string().optional(),camel:Gr.string().optional(),screamingSnake:Gr.string().optional(),pascal:Gr.string().optional()});var o7i=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string(),value:Gr.string(),casing:qNs.optional()}).extend(tv).extend(NP);var RNs=Gr.objectWithoutOptionalProperties({type:Gr.stringLiteral("namespace"),name:Gr.string()});var NNs=Gr.undiscriminatedUnion([Gr.string(),RNs]);var u7i=Gr.list(NNs);var PM=Gr.objectWithoutOptionalProperties({groupName:u7i.optional()});var jS=Gr.objectWithoutOptionalProperties({namespace:Gr.string().optional()});var Pno=Gr.objectWithoutOptionalProperties({default:o7i.optional(),values:Gr.list(o7i)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(eP).extend(AM).extend(G6);var FNs=Gr.objectWithoutOptionalProperties({scopesEnum:Pno.optional()});var xNs=Gr.union("type",{basic:INs,bearer:MNs,header:BNs,query:TNs,oauth:FNs}).transform({transform:e=>{switch(e.type){case"basic":return Hde.basic(e);case"bearer":return Hde.bearer(e);case"header":return Hde.header(e);case"query":return Hde.query(e);case"oauth":return Hde.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var XXo=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string(),audiences:Gr.list(Gr.string()).optional()}).extend(tv);var zNs=Gr.string();var jVr=Gr.objectWithoutOptionalProperties({sdkMethodName:Gr.string().optional()});var iTf={};ff(iTf,{FullExample:()=>g5,FullObjectExample:()=>UNs,FullOneOfExample:()=>WNs,KeyValuePair:()=>VNs,LiteralExample:()=>QNs,NullExample:()=>LNs,PrimitiveExample:()=>jno,PropertyKey:()=>wno});var wno=Gr.string();var jno=Gr.union("type",{int:Gr.object({value:Gr.number()}),int64:Gr.object({value:Gr.number()}),uint:Gr.object({value:Gr.number()}),uint64:Gr.object({value:Gr.number()}),float:Gr.object({value:Gr.number()}),double:Gr.object({value:Gr.number()}),string:Gr.object({value:Gr.string()}),datetime:Gr.object({value:Gr.string()}),date:Gr.object({value:Gr.string()}),base64:Gr.object({value:Gr.string()}),boolean:Gr.object({value:Gr.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return wO.int(e.value);case"int64":return wO.int64(e.value);case"uint":return wO.uint(e.value);case"uint64":return wO.uint64(e.value);case"float":return wO.float(e.value);case"double":return wO.double(e.value);case"string":return wO.string(e.value);case"datetime":return wO.datetime(e.value);case"date":return wO.date(e.value);case"base64":return wO.base64(e.value);case"boolean":return wO.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QNs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return r7i.boolean(e.value);case"string":return r7i.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var LNs=Gr.objectWithoutOptionalProperties({});var g5=Gr.union("type",{primitive:Gr.object({value:jno}),object:Gr.lazyObject(()=>UNs),array:Gr.object({value:Gr.list(Gr.lazy(()=>g5))}),map:Gr.object({value:Gr.list(Gr.lazyObject(()=>VNs))}),enum:Gr.object({value:Gr.string()}),literal:Gr.object({value:QNs}),oneOf:Gr.object({value:Gr.lazy(()=>WNs)}),null:LNs,unknown:Gr.object({value:Gr.lazy(()=>g5)})}).transform({transform:e=>{switch(e.type){case"primitive":return wS.primitive(e.value);case"object":return wS.object(e);case"array":return wS.array(e.value);case"map":return wS.map(e.value);case"enum":return wS.enum(e.value);case"literal":return wS.literal(e.value);case"oneOf":return wS.oneOf(e.value);case"null":return wS.null(e);case"unknown":return wS.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var UNs=Gr.objectWithoutOptionalProperties({properties:Gr.record(wno,Gr.lazy(()=>g5))});var VNs=Gr.objectWithoutOptionalProperties({key:jno,value:Gr.lazy(()=>g5)});var WNs=Gr.union("type",{discriminated:Gr.object({value:Gr.record(wno,Gr.lazy(()=>g5))}),undiscriminated:Gr.object({value:Gr.lazy(()=>g5)})}).transform({transform:e=>{switch(e.type){case"discriminated":return n7i.discriminated(e.value);case"undiscriminated":return n7i.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var aTf={};ff(aTf,{AllOfPropertyConflict:()=>Wno,ArraySchema:()=>RFs,Availability:()=>DNs,BooleanSchema:()=>CFs,BytesResponse:()=>qno,CasingOverrides:()=>qNs,CommonProperty:()=>VFs,CursorPagination:()=>dFs,CustomCodeSample:()=>lFs,CustomCodeSampleLanguage:()=>uFs,CustomCodeSampleSdk:()=>cFs,CustomPagination:()=>_Fs,DiscriminatedOneOfSchema:()=>LFs,DoubleSchema:()=>SFs,Endpoint:()=>hFs,EndpointExample:()=>xno,EndpointResponseExample:()=>oFs,EndpointSdkName:()=>EVr,EndpointSecurity:()=>Eno,EnumSchema:()=>Pno,EnumValue:()=>o7i,ErrorExample:()=>tFs,FernExample:()=>nFs,FileResponse:()=>Bno,FileSchema:()=>JNs,FormUrlEncodedRequest:()=>ZNs,FullEndpointExample:()=>fFs,GlobalHeader:()=>MFs,Header:()=>s7i,HeaderExample:()=>Fno,HttpEndpointServer:()=>Rno,HttpError:()=>rFs,HttpMethod:()=>Sno,IdempotencyHeader:()=>BFs,IntSchema:()=>jFs,JsonRequest:()=>XNs,JsonResponse:()=>Tno,LiteralSchema:()=>Vno,LiteralSchemaValue:()=>TFs,LongSchema:()=>EFs,MapSchema:()=>NFs,MultipartRequest:()=>Mno,MultipartRequestProperty:()=>YNs,MultipartRequestPropertyEncoding:()=>$Ns,MultipartSchema:()=>KNs,NullableSchema:()=>xFs,ObjectProperty:()=>QFs,ObjectPropertyConflictInfo:()=>Hno,ObjectSchema:()=>qFs,OctetStreamRequest:()=>Ino,OffsetPagination:()=>pFs,OneOfSchema:()=>zFs,OpenApiIntermediateRepresentation:()=>GGy,OptionalSchema:()=>FFs,Pagination:()=>zno,PathParameter:()=>Dno,PathParameterExample:()=>iFs,PrimitiveSchema:()=>l7i,PrimitiveSchemaValue:()=>IFs,QueryParameter:()=>Cno,QueryParameterExample:()=>Nno,ReferencedSchema:()=>SVr,Request:()=>kNs,Response:()=>eFs,RetriesConfiguration:()=>Qno,Schema:()=>SI,Schemas:()=>wFs,SdkGroupInfo:()=>HNs,StreamingResponseExample:()=>aFs,StringSchema:()=>DFs,SupportedSdkLanguage:()=>sFs,Tags:()=>GNs,TextResponse:()=>c7i,UnDiscriminatedOneOfSchema:()=>UFs,Webhook:()=>yFs,WebhookExampleCall:()=>Uno,WebhookHttpMethod:()=>Lno,WebsocketChannel:()=>PFs,WebsocketHandshake:()=>vFs,WebsocketMessageExample:()=>OFs,WebsocketMessageOrigin:()=>bFs,WebsocketMessageSchema:()=>gFs,WebsocketServer:()=>mFs,WebsocketSessionExample:()=>AFs});var HNs=Gr.objectWithoutOptionalProperties({summary:Gr.string().optional(),description:Gr.string().optional()});var GNs=Gr.objectWithoutOptionalProperties({tagsById:Gr.record(dIe,CNs),orderedTagIds:Gr.list(dIe).optional()});var Eno=Gr.list(Gr.record(Ano,Gr.list(Gr.string())));var Sno=Gr.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Dno=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>SI),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var Cno=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>SI),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var s7i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>SI),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var EVr=Gr.objectWithoutOptionalProperties({groupName:u7i,methodName:Gr.string()});var Ino=Gr.objectWithoutOptionalProperties({contentType:Gr.string().optional()}).extend(tv).extend(eP);var JNs=Gr.objectWithoutOptionalProperties({isOptional:Gr.boolean(),isArray:Gr.boolean()}).extend(tv);var KNs=Gr.union("type",{file:JNs,json:Gr.object({value:Gr.lazy(()=>SI)})}).transform({transform:e=>{switch(e.type){case"file":return AVr.file(e);case"json":return AVr.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var $Ns=Gr.enum_(["json","form"]);var YNs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:KNs,contentType:Gr.string().optional(),exploded:Gr.boolean().optional(),encoding:$Ns.optional()}).extend(tv);var Mno=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),properties:Gr.list(YNs)}).extend(tv).extend(eP);var XNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>SI),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(tv).extend(eP);var ZNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>SI),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(tv).extend(eP);var kNs=Gr.union("type",{octetStream:Ino,multipart:Mno,json:XNs,formUrlEncoded:ZNs}).transform({transform:e=>{switch(e.type){case"octetStream":return Cqr.octetStream(e);case"multipart":return Cqr.multipart(e);case"json":return Cqr.json(e);case"formUrlEncoded":return Cqr.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bno=Gr.objectWithoutOptionalProperties({}).extend(tv).extend(eP).extend(byt);var Tno=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>SI),responseProperty:Gr.string().optional()}).extend(tv).extend(eP).extend(byt);var c7i=Gr.objectWithoutOptionalProperties({}).extend(tv).extend(eP).extend(byt);var qno=Gr.objectWithoutOptionalProperties({}).extend(tv).extend(eP).extend(byt);var eFs=Gr.union("type",{file:Bno,json:Tno,text:c7i,bytes:qno,streamingSse:Tno,streamingText:c7i,streamingJson:Tno}).transform({transform:e=>{switch(e.type){case"file":return Wbe.file(e);case"json":return Wbe.json(e);case"text":return Wbe.text(e);case"bytes":return Wbe.bytes(e);case"streamingSse":return Wbe.streamingSse(e);case"streamingText":return Wbe.streamingText(e);case"streamingJson":return Wbe.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var tFs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),description:Gr.string().optional(),example:Gr.lazy(()=>g5)});var rFs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>SI).optional(),examples:Gr.list(tFs).optional()}).extend(tv).extend(fD).extend(eP);var Rno=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string().optional(),audiences:Gr.list(Gr.string()).optional()});var nFs=Gr.unknown();var iFs=Gr.objectWithoutOptionalProperties({name:Gr.string(),parameterNameOverride:Gr.string().optional(),value:Gr.lazy(()=>g5)});var Nno=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>g5)});var Fno=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>g5)});var aFs=Gr.objectWithoutOptionalProperties({sse:Gr.boolean(),events:Gr.list(Gr.lazy(()=>g5))});var oFs=Gr.union("type",{withStreaming:aFs,withoutStreaming:Gr.object({value:Gr.lazy(()=>g5)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return vyt.withStreaming(e);case"withoutStreaming":return vyt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var uFs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),language:Gr.string(),code:Gr.string(),install:Gr.string().optional()}).extend(tv);var sFs=Gr.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var cFs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),sdk:sFs,code:Gr.string()}).extend(tv);var lFs=Gr.union("type",{language:uFs,sdk:cFs}).transform({transform:e=>{switch(e.type){case"language":return OVr.language(e);case"sdk":return OVr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var fFs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),pathParameters:Gr.list(iFs).optional(),queryParameters:Gr.list(Nno).optional(),headers:Gr.list(Fno).optional(),request:Gr.lazy(()=>g5).optional(),response:oFs.optional(),codeSamples:Gr.list(lFs)}).extend(tv);var xno=Gr.union("type",{unknown:Gr.object({value:nFs}),full:fFs}).transform({transform:e=>{switch(e.type){case"unknown":return yyt.unknown(e.value);case"full":return yyt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var dFs=Gr.objectWithoutOptionalProperties({cursor:Gr.string(),nextCursor:Gr.property("next_cursor",Gr.string()),results:Gr.string()});var pFs=Gr.objectWithoutOptionalProperties({offset:Gr.string(),results:Gr.string(),step:Gr.string().optional(),hasNextPage:Gr.string().optional()});var _Fs=Gr.objectWithoutOptionalProperties({results:Gr.string()});var zno=Gr.union("type",{cursor:dFs,offset:pFs,custom:_Fs}).transform({transform:e=>{switch(e.type){case"cursor":return oit.cursor(e);case"offset":return oit.offset(e);case"custom":return oit.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qno=Gr.union("type",{disabled:Gr.object({value:Gr.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return JXo.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var hFs=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:Eno,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Sno,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(dIe),pathParameters:Gr.list(Dno),queryParameters:Gr.list(Cno),headers:Gr.list(s7i),sdkName:EVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:kNs.optional(),response:eFs.optional(),errors:Gr.record(wVr,rFs),servers:Gr.list(Rno),examples:Gr.list(xno),pagination:zno.optional(),retries:Qno.optional()}).extend(tv).extend(NP).extend(eP).extend(jS);var Lno=Gr.enum_(["GET","POST"]);var Uno=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),payload:Gr.lazy(()=>g5)}).extend(tv);var yFs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:EVr.optional(),method:Lno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(dIe),headers:Gr.list(s7i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>SI),examples:Gr.list(Uno)}).extend(tv).extend(eP).extend(jS);var vFs=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(Cno),headers:Gr.list(s7i),pathParameters:Gr.list(Dno)});var bFs=Gr.enum_(["client","server"]);var gFs=Gr.objectWithoutOptionalProperties({name:Gr.string(),origin:bFs,body:Gr.lazy(()=>SI)});var mFs=Gr.objectWithoutOptionalProperties({name:Gr.string(),url:Gr.string()});var OFs=Gr.objectWithoutOptionalProperties({messageType:Gr.string(),payload:Gr.lazy(()=>g5)}).extend(tv);var AFs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),queryParameters:Gr.list(Nno).optional(),headers:Gr.list(Fno).optional(),messages:Gr.list(OFs)}).extend(tv);var PFs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),path:Gr.string(),groupName:u7i,summary:Gr.string().optional(),handshake:vFs,messages:Gr.list(gFs),servers:Gr.list(mFs),examples:Gr.list(AFs)}).extend(tv).extend(eP);var wFs=Gr.objectWithoutOptionalProperties({rootSchemas:Gr.record(fIe,Gr.lazy(()=>SI)),namespacedSchemas:Gr.record(zNs,Gr.record(fIe,Gr.lazy(()=>SI)))});var jFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var EFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional()});var SFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var DFs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional()});var CFs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional()});var IFs=Gr.union("type",{int:jFs,int64:EFs,uint:Gr.object({}),uint64:Gr.object({}),float:Gr.object({}),double:SFs,string:DFs,datetime:Gr.object({}),date:Gr.object({}),base64:Gr.object({}),boolean:CFs}).transform({transform:e=>{switch(e.type){case"int":return Oq.int(e);case"int64":return Oq.int64(e);case"uint":return Oq.uint();case"uint64":return Oq.uint64();case"float":return Oq.float();case"double":return Oq.double(e);case"string":return Oq.string(e);case"datetime":return Oq.datetime();case"date":return Oq.date();case"base64":return Oq.base64();case"boolean":return Oq.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var l7i=Gr.objectWithoutOptionalProperties({schema:IFs}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM);var MFs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),optional:Gr.boolean().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>SI).optional()});var BFs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>SI).optional()});var GGy=Gr.objectWithoutOptionalProperties({apiVersion:Gr.unknown().optional(),title:Gr.string().optional(),description:Gr.string().optional(),basePath:Gr.string().optional(),servers:Gr.list(XXo),websocketServers:Gr.list(XXo),groups:Gr.record(Gr.string(),HNs),tags:GNs,hasEndpointsMarkedInternal:Gr.boolean(),endpoints:Gr.list(hFs),webhooks:Gr.list(yFs),channels:Gr.record(Gr.string(),PFs),groupedSchemas:wFs,variables:Gr.record(Gr.string(),l7i),nonRequestReferencedSchemas:Gr.set(fIe),securitySchemes:Gr.record(Ano,xNs),globalHeaders:Gr.list(MFs).optional(),idempotencyHeaders:Gr.list(BFs).optional()});var SVr=Gr.objectWithoutOptionalProperties({schema:fIe}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(eP).extend(AM);var TFs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return FV.boolean(e.value);case"string":return FV.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vno=Gr.objectWithoutOptionalProperties({value:TFs}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM);var SI=Gr.union("type",{primitive:l7i,object:Gr.lazyObject(()=>qFs),array:Gr.lazyObject(()=>RFs),map:Gr.lazyObject(()=>NFs),optional:Gr.lazyObject(()=>FFs),enum:Pno,reference:SVr,literal:Vno,oneOf:Gr.object({value:Gr.lazy(()=>zFs)}),nullable:Gr.lazyObject(()=>xFs),unknown:fD}).transform({transform:e=>{switch(e.type){case"primitive":return kj.primitive(e);case"object":return kj.object(e);case"array":return kj.array(e);case"map":return kj.map(e);case"optional":return kj.optional(e);case"enum":return kj.enum(e);case"reference":return kj.reference(e);case"literal":return kj.literal(e);case"oneOf":return kj.oneOf(e.value);case"nullable":return kj.nullable(e);case"unknown":return kj.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wno=Gr.objectWithoutOptionalProperties({propertyKey:Gr.string(),allOfSchemaIds:Gr.list(fIe),conflictingTypeSignatures:Gr.boolean()});var qFs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(SVr),properties:Gr.list(Gr.lazyObject(()=>QFs)),allOfPropertyConflicts:Gr.list(Wno),additionalProperties:Gr.boolean()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(eP).extend(AM).extend(G6);var Hno=Gr.objectWithoutOptionalProperties({differentSchema:Gr.boolean()});var QFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>SI),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),conflict:Gr.record(fIe,Hno),generatedName:Gr.string(),nameOverride:Gr.string().optional(),audiences:Gr.list(Gr.string())}).extend(NP);var RFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>SI)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var NFs=Gr.objectWithoutOptionalProperties({key:l7i,value:Gr.lazy(()=>SI)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(AM).extend(G6);var FFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>SI)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var xFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>SI)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var zFs=Gr.union("type",{discriminated:Gr.lazyObject(()=>LFs),undiscriminated:Gr.lazyObject(()=>UFs)}).transform({transform:e=>{switch(e.type){case"discriminated":return PVr.discriminated(e);case"undiscriminated":return PVr.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var LFs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>VFs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>SI))}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(eP).extend(AM).extend(G6);var VFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>SI)});var UFs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>SI))}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(eP).extend(AM).extend(G6);var oTf={};ff(oTf,{ArraySchemaWithExample:()=>dxs,Base64WithExample:()=>uxs,BooleanWithExample:()=>sxs,CommonPropertyWithExample:()=>Oxs,DateWithExample:()=>oxs,DatetimeWithExample:()=>axs,DiscriminatedOneOfSchemaWithExample:()=>gxs,DoubleWithExample:()=>nxs,EndpointWithExample:()=>KGy,EnumSchemaWithExample:()=>lxs,FloatWithExample:()=>rxs,HeaderWithExample:()=>f7i,HttpErrorWithExample:()=>XFs,Int64WithExample:()=>kFs,IntWithExample:()=>ZFs,JsonRequestWithExample:()=>JFs,JsonResponseWithExample:()=>Jno,MapSchemaWithExample:()=>pxs,NamedFullExample:()=>gyt,NullableSchemaWithExample:()=>hxs,ObjectPropertyWithExample:()=>bxs,ObjectSchemaWithExample:()=>yxs,OneOfSchemaWithExample:()=>vxs,OptionalSchemaWithExample:()=>_xs,ParseFormUrlEncodedRequest:()=>KFs,ParseMultipartRequest:()=>GFs,ParseOctetStreamRequest:()=>HFs,PathParameterWithExample:()=>WFs,PrimitiveSchemaValueWithExample:()=>cxs,PrimitiveSchemaWithExample:()=>Kno,QueryParameterWithExample:()=>Gno,RequestWithExample:()=>$Fs,ResponseWithExample:()=>YFs,SchemaWithExample:()=>J6,StringSchemaWithExample:()=>ixs,Uint64WithExample:()=>txs,UintWithExample:()=>exs,UnDiscriminatedOneOfSchemaWithExample:()=>mxs,UnknownSchemaWithExample:()=>fxs,WebhookWithExample:()=>$Gy,WebsocketHandshakeWithExample:()=>JGy});var gyt=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),value:Gr.unknown()}).extend(tv);var Gno=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>J6),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var f7i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>J6),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var JGy=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(Gno),headers:Gr.list(f7i)});var WFs=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>J6),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(tv).extend(NP).extend(eP);var HFs=Gr.objectWithoutOptionalProperties({}).extend(Ino).extend(jVr);var GFs=Gr.objectWithoutOptionalProperties({}).extend(Mno).extend(jVr);var JFs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>J6),contentType:Gr.string().optional(),fullExamples:Gr.list(gyt).optional(),additionalProperties:Gr.boolean()}).extend(tv).extend(eP).extend(jVr);var KFs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>J6),contentType:Gr.string().optional(),fullExamples:Gr.list(gyt).optional(),additionalProperties:Gr.boolean()}).extend(tv).extend(eP).extend(jVr);var $Fs=Gr.union("type",{octetStream:HFs,multipart:GFs,json:JFs,formUrlEncoded:KFs}).transform({transform:e=>{switch(e.type){case"octetStream":return lIe.octetStream(e);case"multipart":return lIe.multipart(e);case"json":return lIe.json(e);case"formUrlEncoded":return lIe.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jno=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>J6),responseProperty:Gr.string().optional(),fullExamples:Gr.list(gyt).optional()}).extend(tv).extend(eP).extend(byt);var YFs=Gr.union("type",{file:Bno,json:Jno,text:c7i,bytes:qno,streamingSse:Jno,streamingText:c7i,streamingJson:Jno}).transform({transform:e=>{switch(e.type){case"file":return XL.file(e);case"json":return XL.json(e);case"text":return XL.text(e);case"bytes":return XL.bytes(e);case"streamingSse":return XL.streamingSse(e);case"streamingText":return XL.streamingText(e);case"streamingJson":return XL.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var XFs=Gr.objectWithoutOptionalProperties({statusCode:wVr,schema:Gr.lazy(()=>J6),fullExamples:Gr.list(gyt).optional()}).extend(tv).extend(fD).extend(eP);var KGy=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:Eno,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Sno,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(dIe),pathParameters:Gr.list(WFs),queryParameters:Gr.list(Gno),headers:Gr.list(f7i),sdkName:EVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:$Fs.optional(),response:YFs.optional(),errors:Gr.record(wVr,XFs),servers:Gr.list(Rno),examples:Gr.list(xno),pagination:zno.optional(),retries:Qno.optional()}).extend(tv).extend(NP).extend(eP).extend(jS);var $Gy=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:EVr.optional(),method:Lno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(dIe),headers:Gr.list(f7i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>J6),examples:Gr.list(Uno)}).extend(tv).extend(eP).extend(jS);var ZFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var kFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var exs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var txs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var rxs=Gr.objectWithoutOptionalProperties({example:Gr.number().optional()});var nxs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var ixs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional(),example:Gr.string().optional()});var axs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var oxs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var uxs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var sxs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional(),example:Gr.boolean().optional()});var cxs=Gr.union("type",{int:ZFs,int64:kFs,uint:exs,uint64:txs,float:rxs,double:nxs,string:ixs,datetime:axs,date:oxs,base64:uxs,boolean:sxs}).transform({transform:e=>{switch(e.type){case"int":return U0.int(e);case"int64":return U0.int64(e);case"uint":return U0.uint(e);case"uint64":return U0.uint64(e);case"float":return U0.float(e);case"double":return U0.double(e);case"string":return U0.string(e);case"datetime":return U0.datetime(e);case"date":return U0.date(e);case"base64":return U0.base64(e);case"boolean":return U0.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kno=Gr.objectWithoutOptionalProperties({schema:cxs}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM);var lxs=Gr.objectWithoutOptionalProperties({default:o7i.optional(),values:Gr.list(o7i),example:Gr.string().optional()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(eP).extend(AM).extend(G6);var fxs=Gr.objectWithoutOptionalProperties({example:Gr.unknown()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM);var J6=Gr.union("type",{primitive:Kno,object:Gr.lazyObject(()=>yxs),array:Gr.lazyObject(()=>dxs),map:Gr.lazyObject(()=>pxs),optional:Gr.lazyObject(()=>_xs),enum:lxs,reference:SVr,literal:Vno,oneOf:Gr.object({value:Gr.lazy(()=>vxs)}),nullable:Gr.lazyObject(()=>hxs),unknown:fxs}).transform({transform:e=>{switch(e.type){case"primitive":return Oh.primitive(e);case"object":return Oh.object(e);case"array":return Oh.array(e);case"map":return Oh.map(e);case"optional":return Oh.optional(e);case"enum":return Oh.enum(e);case"reference":return Oh.reference(e);case"literal":return Oh.literal(e);case"oneOf":return Oh.oneOf(e.value);case"nullable":return Oh.nullable(e);case"unknown":return Oh.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var dxs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>J6),example:Gr.list(Gr.unknown()).optional()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var pxs=Gr.objectWithoutOptionalProperties({key:Kno,value:Gr.lazy(()=>J6),example:Gr.unknown().optional()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(AM).extend(G6);var _xs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>J6)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var hxs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>J6)}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(AM).extend(G6);var yxs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(SVr),properties:Gr.list(Gr.lazyObject(()=>bxs)),allOfPropertyConflicts:Gr.list(Wno),fullExamples:Gr.list(gyt).optional(),additionalProperties:Gr.boolean()}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(eP).extend(AM).extend(G6);var bxs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>J6),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),audiences:Gr.list(Gr.string()),conflict:Gr.record(fIe,Hno),nameOverride:Gr.string().optional(),generatedName:Gr.string()}).extend(NP);var vxs=Gr.union("type",{discriminated:Gr.lazyObject(()=>gxs),undiscriminated:Gr.lazyObject(()=>mxs)}).transform({transform:e=>{switch(e.type){case"discriminated":return uit.discriminated(e);case"undiscriminated":return uit.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var gxs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>Oxs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>J6))}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(eP).extend(AM).extend(G6);var Oxs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>J6)});var mxs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>J6))}).extend(PM).extend(jS).extend(fD).extend(tv).extend(NP).extend(u3e).extend(eP).extend(AM).extend(G6);var YGy=/^(\d+)/,$no=/^[a-zA-Z][a-zA-Z0-9_]*$/,XGy={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function d7i(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let o=Math.floor(e/10),c=e%10;return c===0?n[o]:`${n[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${d7i(c)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${d7i(a)}`}function ZXo(e){let t=e.match(YGy);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=d7i(i);return n.length>0?`${a}_${n}`:a}}}function Yno(e){let t=ZXo(e),r=XGy[e];return t!=null?n9(MA(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":n9(MA(e)))}function s3e(e,t){return e.type==="primitive"&&t.type==="primitive"?ZGy(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?l9C(e.values,t.values):e.type==="array"&&t.type==="array"?s3e(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?s3e(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?f9C(e.value,t.value):e.type==="object"&&t.type==="object"?d9C(e,t):e.type==="map"&&t.type==="map"?ZGy(e.key.schema,t.key.schema)&&s3e(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function ZGy(e,t){return e.type===t.type}function l9C(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Wue(r,n)}function f9C(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:s3e(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:s3e(r,i)}):!1}function d9C(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:s3e(a,i.schema)})}function RJ(e){switch(e){case Gde.Deprecated:return"deprecated";case Gde.Beta:return"pre-release";case Gde.GenerallyAvailable:return"generally-available";default:return}}function p9C(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function kGy(e){let t=e?p9C(e):void 0;if(t==null||t.length===0)return Maa;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(MA(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(MA(i.name)):r.push(i.name,Maa);break}default:tc(i.type)}else tc(i);return r.join("/")}function p7i(e){return sw.of(`${kGy(e)}.yml`)}function uTf({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Maa:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,kGy(r))}function eJy({sdkName:e,namespaceOverride:t}){return sw.of(`${uTf({sdkName:e,namespaceOverride:t})}.yml`)}function tJy({location:e,namespaceOverride:t}){return t!=null?WX(sw.of(t),e):e}function Axs(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:tc(e.type)}}function Xno(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:tc(e)}}function K6(e){return typeof e=="string"?e:e.type}function Zno(e){if(typeof e!="string")return e.docs}function kXo(e){if(typeof e!="string")return e.default}function sTf(e){if(typeof e!="string")return e.validation}function nJy(e){let t=K6(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?rJy(e):{...e,type:rJy(e.type)}}function rJy(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function lfa(e){return K6(e).startsWith("optional<")?e:typeof e=="string"?iJy(e):{...e,type:iJy(e.type)}}function iJy(e){return e.startsWith("optional<")?e:`optional<${e}>`}var _9C=-2147483648,h9C=2147483647,y9C=-17976931348623157e292,v9C=17976931348623157e292;function eC({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:a}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return Pxs(e);case"array":return fTf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"map":return dTf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"reference":return lTf({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return _Tf();case"optional":return wxs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"nullable":return pTf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"enum":return E9C({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:a});case"literal":return e.value,hTf(e);case"object":return S9C({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"oneOf":return D9C({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});default:tc(e)}}function Pxs(e){switch(e.schema.type){case"string":return m9C({description:e.description,schema:e.schema});case"int":return O9C({description:e.description,schema:e.schema});case"float":return A9C({description:e.description,schema:e.schema});case"double":return P9C({description:e.description,schema:e.schema});case"boolean":return b9C({description:e.description,schema:e.schema});case"int64":return g9C({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{}}}function b9C({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function g9C({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function m9C({description:e,schema:t}){let r="string",n=w9C(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function O9C({description:e,schema:t}){let r="integer",n=aJy(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function A9C({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function P9C({description:e,schema:t}){let r="double",n=aJy(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function w9C(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=j9C(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function j9C(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function aJy(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=cTf(r,t),n=cTf(n,t),i=cTf(i,t),!(r==null&&n==null&&a==null&&o==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:o,multipleOf:i}}function cTf(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[_9C,h9C]:[y9C,v9C];return e<r||e>n?void 0:e}function lTf({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=C9C(i)??e.schema,o=Xno(i),c=I9C(i),s=jxs({context:r,fileContainingReference:t,declarationFile:p7i(o),type:a});return i.type==="nullable"&&(s=r.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),i.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{}}}function fTf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=eC({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=`list<${K6(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{},type:c}}function dTf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=Pxs(e.key),c=eC({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),d=e.encoding!=null?Axs(e.encoding):void 0,s=`map<${K6(o)}, ${K6(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=d),e.availability!=null&&(u.availability=RJ(e.availability)),u}function pTf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){if(!n.respectNullableSchemas)return wxs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});let o=eC({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=K6(o),d=Zno(o),s=kXo(o),u=sTf(o),l=nJy(c);if(n.wrapReferencesToNullableInOptional&&(l=lfa(l)),e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=RJ(e.availability)),m}function wxs({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=eC({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=K6(o),d=Zno(o),s=kXo(o),u=sTf(o),l=lfa(c);if(e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=RJ(e.availability)),m}function _Tf(){return"unknown"}function hTf(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:tc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{}}}function E9C({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let a=eZo(e,i),o=e.nameOverride??e.generatedName;n.builder.addType(r,{name:o,schema:a.schema});let c=jxs({type:o,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=RJ(e.availability)),d}function S9C({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=yTf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=jxs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{}}}function D9C({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=vTf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=jxs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:RJ(e.availability)}:{}}}function jxs({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function C9C(e){return kj._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function I9C(e){return kj._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}var mse;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(mse||(mse={}));function APi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:tc(e)}}function uJy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a;switch(e.type){case"primitive":a=T9C(e);break;case"array":a=M9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":a=B9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":a=q9C({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":a=N9C(e.nameOverride,e.generatedName);break;case"optional":a=cJy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":a=R9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":a=eZo(e,i);break;case"literal":a=F9C(e,e.nameOverride,e.generatedName);break;case"object":a=yTf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":a=vTf({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:tc(e)}return a}function yTf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=t.isInState(mse.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},d=new Set;for(let A of e.properties){if(A.readonly&&(o=!0),a&&A.readonly)continue;if(Object.keys(A.conflict).length>0){if(Object.entries(A.conflict).every(([R,V])=>!V.differentSchema))continue;Object.entries(A.conflict).forEach(([R])=>{bTf({property:A.key,schemaId:R,context:t,namespace:n}).forEach($=>{d.add($)})})}let P=eC({schema:A.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),C=A.audiences,M=A.nameOverride,T=RJ(A.availability),z=L9C(A);c[A.key]=Q9C({typeReference:P,audiences:C,name:M,availability:T,propertyAccess:z})}let s=new Set;for(let A of e.allOfPropertyConflicts)A.allOfSchemaIds.forEach(P=>d.add(P)),A.conflictingTypeSignatures&&s.add(A.propertyKey);let u=[];for(let A of e.allOf){let P=lJy({schema:A.schema,context:t,namespace:n});if(P==null||d.has(A.schema)||d.has(P))continue;let C=eC({schema:kj.reference(A),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(K6(C))}for(let A of d){let P=gTf(t,A,n);for(let C of P.properties)c[C.key]==null&&(s.has(C.key)&&(c[C.key]="unknown"),c[C.key]=eC({schema:C.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let C of P.allOf){if(d.has(C.schema))continue;let M=eC({schema:kj.reference(C),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(K6(M))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([A,P])=>z9C(A)?[A,typeof P=="string"?{type:P,name:`_${A}`}:{...P,name:`_${A}`}]:[A,P]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=RJ(e.availability)),e.source!=null&&(l.source=APi(e.source)),l.inline=mTf(e,i);let m=e.nameOverride??e.generatedName;return{name:o&&t.respectReadonlySchemas&&!a?`${m}Read`:m,schema:l}}function bTf({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return bTf({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:o}=gTf(r,t,n),c=a.some(s=>s.key===e),d=[...o.flatMap(s=>bTf({property:e,context:r,schemaId:s.schema,namespace:n}))];if(c||d.length>0)return[t,...d]}return[]}function sJy(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?gTf(e,t.schema,r):t.type==="nullable"?sJy(e,t.value,r):{properties:[],allOf:[]}}function gTf(e,t,r){let n=e.getSchema(t,r);return n==null?{properties:[],allOf:[]}:sJy(e,n,r)}function M9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:fTf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function B9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:dTf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function T9C(e){let t=Pxs(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function oJy(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function eZo(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||oJy(a.casing)))return o;let d={value:a.value};if(o!==c&&(d.name=o),a.description!=null&&(d.docs=a.description),a.casing!=null&&!oJy(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=mTf(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?APi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;n.has(o.toLowerCase())||(i.enum.push(a),n.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function q9C({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:lTf({schema:e,context:t,fileContainingReference:r,namespace:n})}}function R9C({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:pTf({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:cJy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function cJy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:wxs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function N9C(e,t){return{name:e??t,schema:_Tf()}}function F9C(e,t,r){return{name:t??r,schema:hTf(e)}}function vTf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=e.encoding!=null?Axs(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=eC({schema:s.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let d={};for(let[s,u]of Object.entries(e.schemas))d[s]=eC({schema:u,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?RJ(e.availability):void 0,union:d,encoding:a,source:e.source!=null?APi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(eC({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?APi(e.source):void 0,inline:mTf(e,i)}}}var x9C=/^[0-9]/;function z9C(e){return x9C.test(e)}function lJy({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?lJy({context:t,schema:n.schema,namespace:r}):e}function Q9C({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function mTf(e,t){return e.inline===!0||t>0?!0:void 0}function L9C(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return YX.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return YX.ObjectPropertyAccess.WriteOnly}}function fJy(e){let t=e.replace(/^x-|^X-/,"");return MA(t)}var dJy="BasicAuthScheme",Exs="BearerAuthScheme";function pJy(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:dJy,schema:i}),t||(e.builder.setAuth(dJy),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:Exs,schema:i}),t||(e.builder.setAuth(Exs),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??fJy(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:Exs,schema:i}),t||(e.builder.setAuth(Exs),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(sw.of("__package__.yml"),{name:"OauthScope",schema:eZo(n.scopesEnum,0).schema})}}function DVr({header:e,context:t,fileContainingReference:r,namespace:n}){let i=eC({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),a=K6(i),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:MA(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=RJ(e.availability)),d}function Sxs({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=eC({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return K6(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:K6(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=RJ(e.availability)),a}function Cxs({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=OTf({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=K6(i.value),o=kXo(i.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),i.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=RJ(e.availability)),U9C(i.value)&&i.value.validation!==void 0&&(c.validation=i.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function OTf({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:eC({schema:kj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:sw.of(pF),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(i.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&($no.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:Yno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[c,d]=i.value.schemas;if(c!=null&&d!=null&&Dxs({array:c,primitive:d}))return{value:eC({schema:kj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Dxs({array:c,primitive:d}))return{value:eC({schema:kj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(i.value.schemas))return OTf({schema:d,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:eC({schema:e,context:t,fileContainingReference:r,declarationFile:sw.of(pF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?kj.optional:kj.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,n);if(a==null)return;if(a.type==="array")return{value:eC({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:sw.of(pF),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:eC({schema:e,context:t,fileContainingReference:r,declarationFile:sw.of(pF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:eC({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(e.value.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&($no.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:Yno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,d]=e.value.value.schemas;if(c!=null&&d!=null&&Dxs({array:c,primitive:d}))return{value:eC({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&Dxs({array:d,primitive:c}))return{value:eC({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:eC({schema:e,context:t,fileContainingReference:r,declarationFile:sw.of(pF),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[c,d]of Object.entries(e.value.value.schemas))return OTf({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:eC({schema:e,context:t,fileContainingReference:r,declarationFile:sw.of(pF),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:eC({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:eC({schema:kj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}:{value:eC({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function Dxs({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function U9C(e){return e.type!=null}function _Jy({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=V9C(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=W9C({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=_7i(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function V9C(e){let t={};return e.forEach(r=>{let n=_7i(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function W9C({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=_7i(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function _7i(e){switch(e.type){case"primitive":return hJy(e.value);case"object":return yJy(e.properties);case"array":return H9C(e.value);case"map":return G9C(e.value);case"oneOf":return J9C(e.value);case"enum":return e.value;case"literal":return K9C(e.value);case"unknown":return _7i(e.value);case"null":return null;default:tc(e)}}function hJy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function yJy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,_7i(r)]))}function H9C(e){return e.map(t=>_7i(t))}function G9C(e){return Object.fromEntries(e.map(t=>[hJy(t.key),_7i(t.value)]))}function J9C(e){return e.type==="discriminated"?yJy(e.value):_7i(e.value)}function K9C(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function tZo(e){try{let r=new URL(e).pathname.split("/").filter(n=>n.length>0);if(r.length>0)return r[r.length-1]}catch{}}function Ixs(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function Mxs(e,t,r=!1){let n=tZo(t);return r&&n!=null?n:e!=null&&n!=null?`${e}_${n}`:n??e??"websocket"}function PPi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Bxs(e,t){return t??(e?.groupName!=null?PPi(e.groupName):void 0)}function vJy({channel:e,context:t,declarationFile:r}){let n=e.servers[0],i=n!=null?t.groupEnvironmentsByHost?t.getUrlId(n.url)??Mxs(n.name,n.url,!0):n.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${n?.name}", server url="${n?.url}", resolved urlId="${i}" (from collision map: ${t.getUrlId(n?.url??"")!=null})`);let a={path:e.path,url:i,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=PPi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=Sxs({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let d={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=Cxs({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(d[u.name]=l)}Object.keys(d).length>0&&(a["query-parameters"]=d);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=DVr({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages)t.builder.addChannelMessage(r,{messageId:u.name,message:{origin:u.origin,body:eC({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=_Jy({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function ATf(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var myt="Base",mJy="Default";function bJy(e){try{return new URL(e).hostname}catch{return}}function gJy(e){return e??mJy}function $9C(e,t){let r=new Map;for(let n of e){if(ATf(n)||!("url"in n)||!n.url)continue;let i=bJy(n.url)??n.url;r.has(i)||r.set(i,{environmentName:gJy(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.httpServers.push({name:n.name,url:n.url,audiences:n.audiences})}for(let n of t){let i=bJy(n.url)??n.url;r.has(i)||r.set(i,{environmentName:gJy(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.websocketServers.push(n)}return r}function ffa(e){return Object.entries(e).reduce((t,[r,n])=>(Pnt(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function OJy(e){if(e.environmentOverrides!=null){for(let[T,z]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:T,schema:z});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],n=e.ir.servers.some(T=>ATf(T)),i=e.ir.servers;for(let T of i)if(ATf(T)){let z={urls:{}};for(let[U,R]of Object.entries(T.urls))z.urls[U]=R.url;T.name&&(t[T.name]=z)}else if("url"in T&&T.url){let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){r.push(z);continue}t[T.name]=z}let a={},o={},c=[];for(let T of e.ir.endpoints)for(let z of T.servers){if(z.url==null&&z.name!=null){a[z.name]||(a[z.name]=[]);continue}if(z.url==null)continue;let U=z.audiences?{url:z.url,audiences:z.audiences}:z.url;if(z.name==null){c.push(U);continue}a[z.name]||(a[z.name]=[]),a[z.name]?.push({url:z.url,audiences:z.audiences}),o[z.name]=U}let d={},s=[];for(let T of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${T.name}", url="${T.url}"`);let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){s.push(z);continue}d[T.name]=z}let u=Object.keys(t).length,l=u>0,m=Object.keys(o).length>0,A=Object.keys(a).some(T=>a[T]?.length===0),P=Object.keys(d).length>0;if(e.groupEnvironmentsByHost&&P&&(l||e.ir.servers.length>0)){let T=Object.entries(d).map(([U,R])=>({name:U,url:typeof R=="string"?R:R.url,audiences:typeof R=="string"?void 0:R.audiences})),z=$9C(i,T);if(z.size>0){let U=!0;for(let[R,V]of z.entries()){let $={},re=[...V.httpServers.map(ee=>({...ee,isHttp:!0})),...V.websocketServers.map(ee=>({...ee,isHttp:!1}))],X=new Map;for(let ee of re){let ne=tZo(ee.url),Oe=Ixs(ee.url);ne&&Oe&&(X.has(ne)||X.set(ne,new Set),X.get(ne)?.add(Oe))}if(V.httpServers.length>0){let ee=V.httpServers[0];ee!=null&&($[myt]=ee.url,e.setUrlId(ee.url,myt));for(let ne=1;ne<V.httpServers.length;ne++){let Oe=V.httpServers[ne];if(Oe!=null){let be=tZo(Oe.url),me=Ixs(Oe.url),he=be?X.get(be):void 0,Me=he&&he.size>1,Se=Me&&me!=="https"?`${be}_${me}`:be||`Http${ne+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${Oe.url}", pathSegment="${be}", protocol="${me}", hasCollision=${Me}, urlId="${Se}"`),$[Se]=Oe.url,e.setUrlId(Oe.url,Se)}}}for(let ee of V.websocketServers){let ne=tZo(ee.url),Oe=Ixs(ee.url),be=ne?X.get(ne):void 0,me=be&&be.size>1,he=me?`${ne}_${Oe}`:Mxs(ee.name,ee.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${ee.name}", url="${ee.url}", pathSegment="${ne}", protocol="${Oe}", hasCollision=${me}, urlId="${he}"`),$[he]=ee.url,e.setUrlId(ee.url,he)}if(Object.keys($).length>1)e.builder.addEnvironment({name:V.environmentName,schema:{urls:$}});else if(Object.keys($).length===1){let ee=Object.values($)[0];ee!=null&&e.builder.addEnvironment({name:V.environmentName,schema:ee})}U&&(e.builder.setDefaultEnvironment(V.environmentName),Object.keys($).length>1&&e.builder.setDefaultUrl(myt),U=!1)}return}}if(!l&&!m&&P&&e.ir.servers.length===0){for(let[T,z]of Object.entries(d))e.builder.addEnvironment({name:T,schema:z});e.builder.setDefaultEnvironment(Object.keys(d)[0]),e.builder.setDefaultUrl(myt);return}if(c.length>0&&e.logger.error(`Skipping endpoint level servers ${c.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),!l){let T=e.ir.servers[0]?.url,z=e.ir.servers[0]?.audiences;if(T!=null){let U=z?{url:T,audiences:z}:T;t[mJy]=U}}let C=Object.values(t).map(T=>typeof T=="string"?T:Pnt(T)?Object.values(T.urls)[0]:T.url),M=r.filter(T=>{let z=typeof T=="string"?T:T.url;return!C.includes(z)});if(M.length>0&&e.logger.error(`Skipping top level servers ${M.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),n){let T=!0;for(let[z,U]of Object.entries(t))if(e.builder.addEnvironment({name:z,schema:U}),T){if(e.builder.setDefaultEnvironment(z),Pnt(U)){let R=Object.keys(U.urls)[0];R&&e.builder.setDefaultUrl(R)}T=!1}return}if(!m&&!A){let T=!0;for(let[z,U]of Object.entries(t))if(T){if(P){let R=typeof U=="string"?U:Pnt(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[myt]:R??"",...ffa(d)}}})}else e.builder.addEnvironment({name:z,schema:U});e.builder.setDefaultEnvironment(z),T=!1}else if(P){let R=typeof U=="string"?U:Pnt(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[myt]:R??"",...ffa(d)}}})}else e.builder.addEnvironment({name:z,schema:U});P&&e.builder.setDefaultUrl(myt)}else if(u===1){let T=Object.keys(t)[0],z=Object.values(t)[0],U=typeof z=="string"?z:Pnt(z)?Object.values(z.urls)[0]:z.url;e.builder.addEnvironment({name:T,schema:{urls:{[myt]:U??"",...ffa(o),...ffa(d)}}}),e.builder.setDefaultEnvironment(T),e.builder.setDefaultUrl(myt)}else{let T=new Map;for(let z of e.ir.endpoints)for(let U of z.servers)if(U.url!=null&&U.name!=null){T.has(U.name)||T.set(U.name,new Map);let R=U.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",V=T.get(U.name);V&&V.set(R,U.url)}if(T.size>0){let z=!0;for(let[U,R]of Object.entries(t)){let V=typeof R=="string"?R:Pnt(R)?Object.values(R.urls)[0]:R.url;if(!V)continue;let $=V.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",re={[myt]:V};for(let[X,ee]of T.entries()){let ne=ee.get($)||ee.get("production")||ee.values().next().value;ne&&(re[X]=ne)}P&&Object.assign(re,ffa(d)),Object.keys(re).length>1?e.builder.addEnvironment({name:U,schema:{urls:re}}):e.builder.addEnvironment({name:U,schema:V}),z&&(e.builder.setDefaultEnvironment(U),z=!1)}T.size>0&&e.builder.setDefaultUrl(myt)}else{let z=!0;for(let[U,R]of Object.entries(t)){if(P||Object.keys(o).length>0){let V=typeof R=="string"?R:Pnt(R)?Object.values(R.urls)[0]:R.url;e.builder.addEnvironment({name:U,schema:{urls:{[myt]:V??"",...ffa(o),...ffa(d)}}})}else e.builder.addEnvironment({name:U,schema:R});z&&(e.builder.setDefaultEnvironment(U),z=!1)}}}}var PTf=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Y9C=.75,X9C=new Set("authorization");function AJy(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?Xno(n.schema):void 0,o=a!=null?PPi(a):void 0,c=sw.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?K6(eC({schema:n.schema,context:e,fileContainingReference:o?WX(sw.of(MA(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(X9C.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],d=DVr({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:sw.of(oee),context:e,namespace:void 0});o=new PTf(d),r[a.name]=o}o.increment()}let n=e.ir.endpoints.length*Y9C;for(let[i,a]of Object.entries(r)){let o=t[i],c=a.count===e.ir.endpoints.length,d=a.count>=n;o==null&&(c?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:lfa(a.schema)}))}}}function PJy(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Xno(t.schema):void 0,n=r!=null?PPi(r):void 0,i=DVr({header:{...t,schema:t.schema??kj.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Oq.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:sw.of(oee),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:lfa(i)})}}function Owe(e){switch(e.type){case"primitive":return jJy(e.value);case"object":return EJy(e.properties);case"array":return SJy(e.value);case"map":return k9C(e.value);case"oneOf":return eVC(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return tVC(e.value);case"unknown":return Owe(e.value);case"null":return null;default:tc(e)}}function wJy(e){switch(e.type){case"withStreaming":return e.sse?{stream:Z9C(e.events)}:{stream:SJy(e.events)};case"withoutStreaming":return{body:Owe(e.value)};default:tc(e)}}function jJy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function EJy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Owe(r)]))}function Z9C(e){return e.map(t=>({event:"",data:Owe(t)}))}function SJy(e){return e.map(t=>Owe(t))}function k9C(e){return Object.fromEntries(e.map(t=>[jJy(t.key),Owe(t.value)]))}function eVC(e){return e.type==="discriminated"?EJy(e.value):Owe(e.value)}function tVC(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function DJy({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=rVC(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=nVC(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),a=Object.keys(i).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(n||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(i))if(!o.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let u=mee({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Hc}});u!=null&&c.push({name:d,value:wS.literal(r7i.string(u))})}else c.push({name:d,value:wS.primitive(wO.string(d))});r.headers=iVC({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=Owe(e.request)),e.response!=null&&(r.response=wJy(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(kw)),r}function rVC(e){let t={};return e.forEach(r=>{let n=Owe(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function nVC(e){let t={};return e.forEach(r=>{let n=Owe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function iVC({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=Owe(n.value);i!=null&&(r[n.name]=i)}),r}function CJy(e){return Kde._visit(e,{get:()=>YX.HttpMethodSchema.Get,post:()=>YX.HttpMethodSchema.Post,put:()=>YX.HttpMethodSchema.Put,patch:()=>YX.HttpMethodSchema.Patch,delete:()=>YX.HttpMethodSchema.Delete,head:()=>YX.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function IJy(e){return e==="POST"||e==="PUT"||e==="PATCH"}function MJy({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,o=e.path,c=Bxs(e.sdkName,e.namespace),d={};for(let M of e.pathParameters)M.parameterNameOverride&&(o=o.replace(M.name,M.parameterNameOverride)),d[M.parameterNameOverride??M.name]=Sxs({pathParameter:M,context:r,fileContainingReference:t,namespace:c}),a.add(M.name);let s={};for(let M of e.queryParameters){let T=Cxs({queryParameter:M,context:r,fileContainingReference:t,namespace:c});T!=null&&(s[M.name]=T,a.add(M.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:tc(e.pagination)}let l={path:o,method:CJy(e.method),auth:Object.keys(e.security).length>0?e.security:void 0,docs:e.description??void 0,pagination:u,source:e.source!=null?APi(e.source):void 0};!sVC({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},A=r.builder.getGlobalHeaderNames(),P=r.builder.getAuthHeaderName();P!=null&&A.add(P);let C=e.headers.filter(M=>!A.has(M.name));for(let M of C){let T=DVr({header:M,context:r,fileContainingReference:t,namespace:c});m[M.name]=T,a.add(typeof T=="string"?M.name:T.name??M.name)}if(e.request!=null){r.setInState(mse.Request);let M=uVC({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:c});l.request=M.value,i=[...i,...M.schemaIdsToExclude??[]],r.unsetInState(mse.Request)}else{let M=r.inlinePathParameters&&Object.keys(d).length>0,T=Object.keys(s).length>0,z=Object.keys(m).length>0,U={};(M||T||z)&&(U.name=e.requestNameOverride??e.generatedRequestName),M&&(U["path-parameters"]=d),T&&(U["query-parameters"]=s),z&&(U.headers=m),Object.keys(U).length>0&&(l.request=U)}if(e.response!=null&&e.response._visit({json:M=>{let T=eC({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:M.description??void 0,type:K6(T)},M.statusCode!=null&&(l.response["status-code"]=M.statusCode),M.responseProperty!=null&&(l.response.property=M.responseProperty)},streamingJson:M=>{let T=eC({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:M.description??void 0,type:K6(T),format:"json"}},streamingSse:M=>{let T=eC({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:M.description??void 0,type:K6(T),format:"sse"}},file:M=>{l.response={docs:M.description??void 0,type:"file","status-code":M.statusCode}},bytes:M=>{l.response={docs:M.description??void 0,type:"bytes","status-code":M.statusCode}},streamingText:M=>{l["response-stream"]={docs:M.description??void 0,type:"text"}},text:M=>{l.response={docs:M.description??void 0,type:"text","status-code":M.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let M=r.getDefaultServerName(),T=e.servers[0];T==null?M!=null&&(l.url=M):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=RJ(e.availability)),Object.entries(e.errors).forEach(([M,T])=>{let z=T.generatedName,U=sw.of(pF);r.builder.enableUniqueErrorsPerEndpoint&&(z=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let R={"status-code":parseInt(M)},V=tJy({location:BJy,namespaceOverride:c});if(T.schema!=null){let X=eC({schema:T.schema,context:r,fileContainingReference:V,declarationFile:V,namespace:c,declarationDepth:0});R.type=K6(X),R.docs=T.description}r.builder.addError(V,{name:z,schema:r.isErrorUnknownSchema(parseInt(M))?{...R,type:"unknown"}:R}),l.errors==null&&(l.errors=[]);let $=r.builder.addImport({file:t,fileToImport:V});l.errors.push($!=null?`${$}.${z}`:z),R.type!=null&&T.examples?.forEach(X=>{let ee={value:Owe(X.example),name:X.name,docs:X.description};r.builder.addErrorExample(V,{name:z,example:ee})})}),e.examples.length>0&&(l.examples=aVC({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=oVC({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[wTf,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function aVC({endpointExamples:e,context:t}){return e.map(r=>{try{return DJy({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function oVC({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:tc(e)}}function uVC({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:u,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let m=n.schema.type==="reference"?n.schema.schema:void 0,A=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(A?.type!=="object"||m!=null&&d.includes(m)){let z=eC({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),U={schemaIdsToExclude:[],value:{body:z}},R=Object.keys(o??{}).length>0,V=Object.keys(c??{}).length>0,$=Object.keys(s??{}).length>0;return R&&(U.value["path-parameters"]=o),V&&(U.value["query-parameters"]=c),$&&(U.value.headers=s),(R||V||$)&&(U.value.name=i??a),n.contentType!=null&&(U.value["content-type"]=n.contentType),n.description!=null&&(U.value.docs=n.description),U}let P=Object.fromEntries(A.properties.filter(z=>z.readonly==null?!0:!(IJy(e.method)&&z.readonly)).map(z=>{let U=eC({schema:z.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),R=z.nameOverride??z.key,V=RJ(z.availability);if(!u.has(R)&&z.audiences.length<=0)return u.add(R),z.nameOverride!=null?[z.key,{type:K6(U),docs:Zno(U),name:z.nameOverride,availability:V}]:[z.key,V?{...typeof U=="string"?{type:U}:U,availability:V}:U];let $={type:K6(U),docs:Zno(U)};return u.has(R)&&($.name=z.generatedName),z.audiences.length>0&&($.audiences=z.audiences),V!=null&&($.availability=V),u.add(R),[z.key,$]})),C=A.allOf.map(z=>{let U=eC({schema:kj.reference(z),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return K6(U)}).filter(z=>z!=="unknown"),M={properties:P};C.length>0&&(M.extends=C),n.additionalProperties&&(M["extra-properties"]=!0);let T={name:i??A.nameOverride??A.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:M};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:m!=null?[m]:[],value:T}}else if(n.type==="octetStream"){let m={body:"bytes","content-type":n.contentType??z7.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(m.name=i??a),n.description!=null&&(m.docs=n.description),{schemaIdsToExclude:[],value:m}}else if(n.type==="multipart"){let m=Object.fromEntries(n.properties.map(A=>{if(A.schema.type==="file"){let P=A.schema.isArray?"list<file>":"file";if(P=A.schema.isOptional?`optional<${P}>`:P,A.description!=null||A.contentType!=null){let C={type:P};if(A.description!=null&&(C.docs=A.description),A.contentType!=null){let M=A.contentType.split(",")[0];C["content-type"]=M}return[A.key,C]}return[A.key,P]}else{let P=eC({schema:A.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(A.contentType||A.exploded||A.encoding){let C=typeof P=="string"?{type:P}:P;A.contentType!=null&&(C["content-type"]=A.contentType),A.encoding==="form"?C.style="form":A.encoding==="json"?C.style="json":A.exploded&&(C.style="exploded"),P=C}return[A.key,P]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:m},"content-type":z7.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else tc(n)}function sVC({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:tc(t)}}function cVC({location:e,namespaceOverride:t}){return t!=null?{...e,file:WX(sw.of(t),e.file)}:e}function lVC(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:sw.of(`${MA(r)}.yml`),endpointId:e.summary!=null?MA(e.summary):MA(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:sw.of(pF),endpointId:MA(e.summary)}:{file:sw.of(pF),endpointId:MA(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:sw.of(pF),endpointId:n};let i=rZo(r),a=rZo(n);if(Wue(i,a))return{file:sw.of("__package__.yml"),endpointId:r};let o=pVC({operationId:n,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let d=0;d<i.length;++d){let s=i[d];if(s!=null&&s===a[d])c.push(s);else{let u=MA(r);return{file:sw.of(`${u}.yml`),endpointId:n,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:sw.of(MA(c.join("_"))+".yml"),endpointId:MA(a.slice(c.length).join("_")),tag:r}}function nZo(e){let t=e.tags[0];if(e.sdkName!=null){let r=uTf({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:sw.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return cVC({namespaceOverride:e.namespace,location:lVC(e)})}function rZo(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=hpt(t),t}var fVC=new RegExp("[^a-zA-Z0-9{}]+"),dVC=new RegExp("[{}]","g");function pVC({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(fVC).join("_").replaceAll(dVC,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:sw.of(MA(t)+".yml"),endpointId:MA(e.slice(0,-1*a.length)),tag:t}}function TJy(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:o,file:c,tag:d}=nZo(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let A=e.ir.groups;for(let P of a.sdkName.groupName){let C=typeof P=="string"?P:P.name,M=A[C];if(M==null)break;if(M.summary!=null||M.description!=null){u=A[C];break}}}let l=d==null?void 0:n.tagsById[d];e.setInState(mse.Endpoint),e.setEndpointMethod(a.method);let m=MJy({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(mse.Endpoint),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:m.value,source:a.source!=null?APi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function qJy(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?PPi(r.groupName):void 0,i=eC({schema:kj.primitive(r),context:e,fileContainingReference:sw.of(pF),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:K6(i),docs:r.description??void 0}})}}function RJy(e){for(let t of e.ir.webhooks){let r=yVC({webhook:t,context:e});if(r==null)continue;let n=Bxs(t.sdkName,t.namespace),i={};for(let o of t.headers)i[o.name]=DVr({header:o,context:e,fileContainingReference:r.file,namespace:n});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:eC({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:Owe(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function _VC({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:WX(sw.of(t),e.file)}:e}function hVC({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:sw.of(pF),endpointId:n};let i=rZo(r),a=rZo(n);if(Wue(i,a))return{file:sw.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<i.length;++c){let d=i[c];if(d!=null&&d===a[c])o.push(d);else{let s=MA(r);return{file:sw.of(`${s}.yml`),endpointId:n,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:sw.of(MA(o.join("_"))+".yml"),endpointId:MA(a.slice(o.length).join("_")),tag:r}}function yVC({webhook:e,context:t}){return e.sdkName!=null?{file:eJy({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:_VC({namespaceOverride:e.namespace,location:hVC({webhook:e,context:t})})}var vVC=sw.of(pF);function FJy(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return NJy({namespace:e.namespace,groupName:e.groupName});case"oneOf":return NJy({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return vVC;default:tc(e)}}function NJy({namespace:e,groupName:t}){return e!=null&&t!=null?p7i([{type:"namespace",name:e},...t]):e!=null?p7i([{type:"namespace",name:e}]):p7i(t)}var wTf="external",BJy=sw.of(pF);function xJy({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let o=FJy(a),c=uJy({schema:a,context:n,declarationFile:o,namespace:r,declarationDepth:0});if(a6i(c.schema)){let d=K6(c.schema);if(d===(c.name??i)||d===`optional<${c.name??i}>`||d===`nullable<${c.name??i}>`||d===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(o,{name:c.name??i,schema:c.schema})}}function zJy(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),OJy(e),AJy(e),PJy(e),pJy(e),qJy(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(wTf);let t=TJy(e),r=t.sdkGroups;e.setInState(mse.Webhook),RJy(e),e.unsetInState(mse.Webhook),e.setInState(mse.Channel);for(let i of Object.values(e.ir.channels)){let a=p7i(i.groupName);vJy({channel:i,context:e,declarationFile:a})}e.unsetInState(mse.Channel);let n=bVC({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});xJy({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))xJy({schemas:a,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function bVC({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var iZo=class{context;constructor(t){this.context=t}};var Txs=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[o,c]of Object.entries(n.files)){let d=i!=null?sw.of(`${i}${"/"}${o}`):sw.of(o);t[d]=c}let a=Object.keys(n.directories).sort();for(let o of a){let c=i!=null?`${i}${"/"}${o}`:o,d=n.directories[o];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[sw.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var dfa=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new Txs,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":n,"display-name":i,docs:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),n!=null&&(o.service["base-path"]=n),i!=null&&(o.service["display-name"]=i),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return qLr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let n of Object.values(this.rootApiFile["auth-schemes"]))QJy(n)&&t.push(n.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(QJy(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??MA((Ipt(r)+"/"+Zaa(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===sw.of(oee))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=eos(Ipt(TJa.of(`/${t}`)),TJa.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=eos(Ipt(TJa.of(`/${t}`)),TJa.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===sw.of(oee))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Wue(c,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=WX(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:WX(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,o])=>[a,{...o,path:WX(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===pF?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function QJy(e){return e?.header!=null}var qxs=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;groupEnvironmentsByHost;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=o,this.globalHeaderOverrides=a,this.detectGlobalHeaders=n?.detectGlobalHeaders??!0,this.objectQueryParameters=n?.objectQueryParameters??!1,this.respectReadonlySchemas=n?.respectReadonlySchemas??!1,this.respectNullableSchemas=n?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=n?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=n?.inlinePathParameters??!1,this.useBytesForBinaryResponse=n?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=n?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=n?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=n?.enableUniqueErrorsPerEndpoint??!1,this.wrapReferencesToNullableInOptional=n?.wrapReferencesToNullableInOptional??!0,this.coerceOptionalSchemasToNullable=n?.coerceOptionalSchemasToNullable??!0,this.groupEnvironmentsByHost=n?.groupEnvironmentsByHost??!1,this.builder=new dfa(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,u]of Object.entries(d.errors)){let l=parseInt(s),m=c[l];m==null&&u.schema!=null?c[l]=u.schema:m!=null&&u.schema!=null&&s3e(m,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(mse.Channel,mse.Endpoint,mse.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:tc(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:tc(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function jTf(e){let t=new qxs(e);return zJy(t)}var Rxs=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let a=jTf({taskContext:t,ir:r,options:GXo({overrides:{...n,respectReadonlySchemas:n?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:n?.respectNullableSchemas??this.args.respectNullableSchemas,wrapReferencesToNullableInOptional:n?.wrapReferencesToNullableInOptional??this.args.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:n?.coerceOptionalSchemasToNullable??this.args.coerceOptionalSchemasToNullable,onlyIncludeReferencedSchemas:n?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:n?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:n?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:n?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:n?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums,groupEnvironmentsByHost:n?.groupEnvironmentsByHost??this.args.groupEnvironmentsByHost}}),authOverrides:n?.auth!=null?{auth:n.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Vg.dump(a.rootApiFile)},namedDefinitionFiles:{...yg(a.definitionFiles,o=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Vg.dump(o),contents:o})),[sw.of(pF)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Vg.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var aZo=class extends Dqr{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.wrapReferencesToNullableInOptional=t.wrapReferencesToNullableInOptional,this.coerceOptionalSchemasToNullable=t.coerceOptionalSchemasToNullable,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.converter=new Rxs(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:a,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new ait({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var Hbe={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var kno={of(e){return e}};var LJy={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},ETf={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:LJy,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},jb={SOURCE:kno.of("source"),SDK_NAMESPACE:kno.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:kno.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:kno.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:kno.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var _9={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0};function Oyt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??_9.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??_9.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??_9.useTitlesAsName,audiences:t?.audiences??e?.audiences??_9.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??_9.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??_9.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??_9.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??_9.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??_9.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??_9.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??_9.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??_9.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??_9.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??_9.objectQueryParameters,filter:t?.filter??e?.filter??_9.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??_9.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??_9.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??_9.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??_9.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??_9.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??_9.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??_9.inlineAllOfSchemas,resolveAliases:t?.resolveAliases??e?.resolveAliases??_9.resolveAliases,groupMultiApiEnvironments:t?.groupMultiApiEnvironments??e?.groupMultiApiEnvironments??_9.groupMultiApiEnvironments,groupEnvironmentsByHost:t?.groupEnvironmentsByHost??e?.groupEnvironmentsByHost??_9.groupEnvironmentsByHost,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??_9.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??_9.coerceOptionalSchemasToNullable}}var UJy={naming:"v1"};function Jy(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function oZo(e,t,r,n,i=[]){try{let a=Jy(e,t);if(a!=null)return r.parse(a)}catch{let o=hpt(i).join(" -> ");n.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function pfa(e){let t=Jy(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function VJy({schema:e,logger:t}){return Jy(e,jb.ENCODING)??void 0}function WJy(e){return Jy(e,jb.FERN_ENUM)}function HJy({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let o=Jy(n,jb.SDK_NAMESPACE),c=Jy(n,jb.SDK_GROUP_NAME),d=Jy(n,jb.TYPE_DEFINITION);if(d!=null)return uZo({fernType:d,nameOverride:e,generatedName:t,title:r,description:i,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function uZo({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c}){return mee({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.base64({example:void 0})});case"BOOLEAN":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.boolean({default:void 0,example:void 0})});case"DATE":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.date({example:void 0})});case"DATE_TIME":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.datetime({example:void 0})});case"FLOAT":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.float({example:void 0})});case"DOUBLE":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.uint({default:void 0,example:void 0})});case"INTEGER":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.uint64({default:void 0,example:void 0})});case"LONG":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Oh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:U0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:tc(d.v1)}},unknown:()=>Oh.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,namespace:o,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?Oh.map({nameOverride:t,generatedName:r,title:n,key:d,value:s,description:i,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?Oh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?Oh.optional({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?Oh.nullable({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:d=>d!=null?Oh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>Oh.literal({nameOverride:t,generatedName:r,title:n,value:d._visit({string:s=>FV.string(s),boolean:s=>FV.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,namespace:o,groupName:c}),named:d=>Oh.reference({schema:d,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,source:gwe.openapi({file:"<memory>"})})}})}function GJy(e){let t=Jy(e,jb.SOURCE);if(t!=null)return t.endsWith(".proto")?gwe.protobuf({file:t}):gwe.openapi({file:t})}function _fa(e){if(e!=null&&typeof e=="boolean")return e}function Wg(e){return e?.$ref!=null}function JJy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,encoding:A,source:P}){return i===void 0&&(i=s.options.additionalPropertiesDefaultsTo),STf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:U0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof i=="boolean"||sZo(i,s.options)?Oh.unknown({...gVC(i),generatedName:`${t}Value`}):KJy(ES(i,!1,s.options.optionalAdditionalProperties?d:!1,s,[...n,"Value"],P,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:m,encoding:A})}function KJy(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=KJy(e.value);break;case"oneOf":e.value.inline=!0;break;default:tc(e)}return e}function STf({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:d,namespace:s,groupName:u,example:l,encoding:m}){let A=Oh.map({nameOverride:e,generatedName:t,title:r,description:c,availability:d,key:n,value:i,namespace:s,groupName:u,encoding:m,example:l,inline:void 0});return o&&(A=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),a&&(A=Oh.optional({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),A}function sZo(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!(Wg(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null||"allOf"in e&&e.allOf!=null||"enum"in e&&e.enum!=null)}function gVC(e){let t={nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0};return e==null||typeof e=="boolean"||Wg(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function $Jy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,source:A}){let P=i==null?Oh.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):ES(i,!1,!1,s,[...n,"Item"],A,u);return mVC({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:P,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,example:m})}function mVC({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,example:u}){let l=Oh.array({nameOverride:e,generatedName:t,title:r,value:n,description:o,availability:c,namespace:d,groupName:s,example:u,inline:void 0});return a&&(l=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(l=Oh.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),l}function Awe(e){switch(Jy(e,jb.AVAILABILITY)){case"deprecated":return Gde.Deprecated;case"beta":return Gde.Beta;case"generally-available":return Gde.GenerallyAvailable;default:break}if(!Wg(e)&&e.deprecated)return Gde.Deprecated}function DTf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminator:u,context:l,namespace:m,groupName:A,encoding:P,source:C}){let M=u.propertyName,T=Object.fromEntries(Object.entries(u.mapping??{}).map(([U,R])=>{let V=wPi({$ref:R},!1,!1,l,[R],P,C,m);return l.markReferencedByDiscriminatedUnion({$ref:R},M,1),[U,V]})),z=Object.entries(i).filter(([U])=>U!==M).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=l.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],X=ES(R,$,re,l,[...n,U],C,m);return{key:U,schema:X}});return YJy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:M,subtypes:T,namespace:m,groupName:A,source:C})}function CTf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminant:u,variants:l,context:m,namespace:A,groupName:P,encoding:C,source:M}){let T=Object.fromEntries(Object.entries(l).map(([U,R])=>{if(Wg(R)){let V=wPi(R,!1,!1,m,[R.$ref],C,M,A);return m.markReferencedByDiscriminatedUnion(R,u,1),[U,V]}else{let V=eio(R,!1,!1,m,[...n,U],C,M,A,new Set([u]));return[U,V]}})),z=Object.entries(i).filter(([U])=>U!==u).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=m.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],X=ES(R,$,re,m,[...n,U],M,A);return{key:U,schema:X}});return YJy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:u,subtypes:T,namespace:A,groupName:P,source:M})}function YJy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,availability:c,discriminant:d,subtypes:s,namespace:u,groupName:l,source:m}){let A=Oh.oneOf(uit.discriminated({description:o,availability:c,discriminantProperty:d,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:m,inline:void 0}));return i&&(A=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),n&&(A=Oh.optional({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),A}function XJy(e){if(e.proto!=null)return bno.protobuf({typeName:e.proto.type})}function h7i({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:o,description:c,availability:d,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:m,context:A,source:P,inline:C}){let M=AVC(i??[]),T=new Set(a),z=Array.from(T).map((R,V)=>{let $=n?.[R],re=M[V],X=$no.test(R),ee=$?.name??re,ne=X?R:Yno(R);return ee!=null&&!$no.test(ee)&&(A?.logger.warn(`Enum name override ${ee} is not a valid name. Falling back on ${ne}.`),ee=void 0),{nameOverride:ee,generatedName:ne,value:R,description:$?.description,availability:d,casing:{snake:$?.casing?.snake??void 0,pascal:$?.casing?.pascal??void 0,screamingSnake:$?.casing?.screamingSnake??void 0,camel:$?.casing?.camel??void 0}}}),U=o!=null?z.find(R=>R.value===o):void 0;return OVC({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:z,_default:U,description:c,availability:d,namespace:l,groupName:m,source:P,inline:C})}function OVC({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:n,title:i,values:a,_default:o,description:c,availability:d,namespace:s,groupName:u,source:l,inline:m}){let A=Oh.enum({nameOverride:r,generatedName:n,title:i,values:a,description:c,availability:d,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:m});return t&&(A=Oh.nullable({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),e&&(A=Oh.optional({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),A}function AVC(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function ZJy({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:M}){return n==="int64"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="uint32"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="uint64"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M})}function PVC(e){return typeof e=="string"?FV.string(e):typeof e=="boolean"?FV.boolean(e):FV.string(`${e}`)}function kJy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,value:a,description:o,availability:c,namespace:d,groupName:s}){let u=Oh.literal({nameOverride:e,generatedName:t,title:r,value:PVC(a),description:o,availability:c,namespace:d,groupName:s});return i&&(u=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(u=Oh.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),u}function ITf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:M}){return n==null||n==="double"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.double({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="float"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="int32"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="int64"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="uint32"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="uint64"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):n==="time-delta"?Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M}):Ose({nameOverride:e,generatedName:t,title:r,primitive:U0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:M})}var wVC={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},jVC={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},EVC={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},SVC={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},DVC={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},CVC={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},IVC={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},MVC={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function cZo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[wVC,jVC,EVC,SVC,DVC,CVC,IVC,MVC],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==i.join(""));return r}function xie(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:n9(MA(i))).join("");return/^\d/.test(n)?ZXo(n)??n:n}function eKy(e){let t=e.join("_");return MA(t)}function L4(e){switch(e.type){case"object":return kj.object({allOf:e.allOf,properties:e.properties.map(t=>TVC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return kj.array({description:e.description,availability:e.availability,value:L4(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return kj.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return kj.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return kj.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:L4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return kj.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:L4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return kj.primitive({description:e.description,availability:e.availability,schema:tKy(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return kj.map({description:e.description,availability:e.availability,key:kj.primitive({description:e.key.description,availability:e.key.availability,schema:tKy(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:L4(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return kj.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return kj.oneOf(BVC(e.value));case"unknown":return kj.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:tc(e)}}function BVC(e){switch(e.type){case"discriminated":return PVr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:L4(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,L4(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return PVr.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>L4(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:tc(e)}}function tKy(e){switch(e.type){case"string":return Oq.string(e);case"base64":return Oq.base64();case"boolean":return Oq.boolean(e);case"date":return Oq.date();case"datetime":return Oq.datetime();case"double":return Oq.double(e);case"float":return Oq.float();case"int":return Oq.int(e);case"int64":return Oq.int64(e);case"uint":return Oq.uint();case"uint64":return Oq.uint64();default:tc(e)}}function TVC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:L4(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Nxs(e,t){return s3e(L4(e),L4(t))}function rKy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:o,wrapAsOptional:c,wrapAsNullable:d,allOf:s,context:u,propertiesToExclude:l,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:M,source:T}){let z=[...o??[]],U={...i},R=[],V=[];for(let ne of s)if(!u.options.inlineAllOfSchemas&&Wg(ne)){let Oe=u.resolveSchemaReference(ne);if(Oe.discriminator!=null&&Oe.discriminator.mapping!=null)continue;if(Oe.oneOf!=null||Oe.anyOf!=null){let me=Oe.oneOf??Oe.anyOf;if(me!=null){for(let he of me){let Me=Wg(he)?u.resolveSchemaReference(he):he,Be=ES(Me,!1,!1,u.DUMMY,n,T,m);Be.type==="object"&&R.push(...Be.properties.map(Se=>Se.schema.type!=="optional"&&Se.schema.type!=="nullable"?{...Se,schema:Oh.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Se.schema,description:void 0,availability:Se.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Se))}continue}}let be=y7i(ne);if(be==null)continue;V.push({schemaId:be,convertedSchema:MTf(ne,[be],T,u.options.preserveSchemaIds),properties:nKy({schema:ne,context:u,breadcrumbs:n,source:T,namespace:m})}),u.markSchemaAsReferencedByNonRequest(be)}else if(Wg(ne)){let Oe=u.resolveSchemaReference(ne),be=ES(Oe,!1,!1,u,n,T,m);be.type==="object"&&R.push(...be.properties)}else{let Oe=ne.required??[];R=R.map(me=>(me.schema.type==="optional"||me.schema.type==="nullable")&&Oe.includes(me.key)?{...me,schema:me.schema.value}:me);let be=ES(ne,!1,!1,u,n,T,m);be.type==="object"&&R.push(...be.properties)}let $={};for(let ne of V)for(let[Oe,be]of Object.entries(ne.properties)){let me=$[Oe];me!=null?(me.schemaIds.push(ne.schemaId),me.schemas.some(Me=>Nxs(Me,be))||me.schemas.push(be)):$[Oe]={schemaIds:[ne.schemaId],schemas:[be]}}let re=[];for(let[ne,Oe]of Object.entries($))Oe.schemaIds.length>1&&re.push({propertyKey:ne,allOfSchemaIds:Oe.schemaIds,conflictingTypeSignatures:Oe.schemas.length>1});let X=Object.fromEntries(Object.entries(U).filter(([ne,Oe])=>!(!Wg(Oe)&&Oe.type==="null"))),ee=Object.entries(X).map(([ne,Oe])=>{let be=Jy(Oe,jb.AUDIENCES)??[],me=Awe(Oe),he=Wg(Oe)?!1:Oe.readOnly,Me=Wg(Oe)?!1:Oe.writeOnly,Se=!(z.includes(ne)&&!he),St=Jy(Oe,jb.FERN_PROPERTY_NAME),yt=[...n,ne],Ne=eKy(yt),De=ES(Oe,Se,!1,u,yt,T,m),Qt={};for(let Xe of V){let Yt=Xe.properties[ne];Yt!=null&&!Nxs(De,Yt)?Qt[Xe.schemaId]={differentSchema:!0}:Yt!=null&&(Qt[Xe.schemaId]={differentSchema:!1})}return{key:ne,schema:De,nameOverride:St,audiences:be,conflict:Qt,generatedName:Ne,availability:me,readonly:he,writeonly:Me}});return ee.push(...R.map(ne=>{let Oe=ne.conflict;for(let be of V){let me=be.properties[ne.key];me!=null&&!Nxs(ne.schema,me)?Oe[be.schemaId]={differentSchema:!0}:me!=null&&(Oe[be.schemaId]={differentSchema:!1})}return{...ne,conflict:Oe}})),qVC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,properties:ee.filter(ne=>!l.has(ne.key)),description:a,allOf:V.map(ne=>ne.convertedSchema),allOfPropertyConflicts:re,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:M,source:T,context:u})}function qVC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:m,availability:A,source:P,context:C}){let M=Oh.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:sZo(m,C.options),availability:A,source:P,inline:void 0});return i&&(M=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:M,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),n&&(M=Oh.optional({nameOverride:e,generatedName:t,title:r,value:M,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),M}function nKy({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[o,c]=Wg(e)?[t.resolveSchemaReference(e),cZo(e.$ref)]:[e,r];for(let d of o.allOf??[])a={...a,...nKy({schema:d,context:t,breadcrumbs:c,source:n,namespace:i})};for(let[d,s]of Object.entries(o.properties??{})){let u=ES(s,!1,!1,t,[...c,d],n,i);a[d]=u}return a}function v7i({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:d,subtypes:s,namespace:u,groupName:l,encoding:m,source:A,subtypePrefixOverrides:P}){let C=FVC({schemas:s}),M=s.flatMap((z,U)=>{if(!Wg(z)&&z.enum!=null&&d.options.coerceEnumsToLiterals&&z.type==="string")return z.enum.map(V=>Oh.literal({nameOverride:void 0,generatedName:xie([t,V],d.options.preserveSchemaIds),title:void 0,value:FV.string(String(V)),namespace:u,groupName:void 0,description:void 0,availability:V.availability}));let R=C[U];if(P!=null){let V=P[U];V!=null&&"name"in V&&(R=V.name)}return[ES(z,!1,!1,d,[...n,R??`${U}`],A,u)]}),T=RVC(M);return NVC({uniqueSubtypes:T,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:i,availability:a,namespace:u,groupName:l,context:d,encoding:m,source:A})}function RVC(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(n!=null&&o!=null&&s3e(n,o)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function NVC({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,context:u,encoding:l,source:m}){if(Object.entries(e).every(([P,C])=>C.type==="literal")){let P={},C=[];return Object.entries(e).forEach(([M,T])=>{T.type==="literal"&&T.value.type==="string"&&(C.push(T.value.value),T.description!=null&&(P[T.value.value]={description:T.description}))}),h7i({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,fernEnum:P,enumVarNames:void 0,enumValues:C,_default:void 0,namespace:d,groupName:s,context:u,source:m,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let P=e[0];return a&&(P=Oh.nullable({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(P=Oh.optional({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),P}return iKy({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:d,groupName:s,encoding:l,source:m})}function BTf({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:d,groupName:s,discriminator:u,encoding:l,source:m}){let A=Object.entries(u.mapping??{}).map(([M,T],z)=>{let U={$ref:T},R=wPi(U,!1,!1,c,[T],l,m,d);return c.markSchemaWithDiscriminantValue(U,u.propertyName,M),R.type==="object"&&(R.properties={[u.propertyName]:Oh.literal({nameOverride:void 0,generatedName:xie([t,M],c.options.preserveSchemaIds),title:void 0,value:FV.string(M),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...R.properties.filter(V=>V.key!==u.propertyName)}),R}),P=[];for(let M=0;M<A.length;++M){let T=A[M],z=!1;for(let U=M+1;U<A.length;++U){let R=A[U];if(T!=null&&R!=null&&s3e(T,R)){z=!0;break}}T!=null&&!z&&P.push(T)}if(Object.entries(P).every(([M,T])=>T.type==="literal")){let M={},T=[];return Object.entries(P).forEach(([z,U])=>{U.type==="literal"&&U.value.type==="string"&&(T.push(U.value.value),U.description!=null&&(M[U.value.value]={description:U.description}))}),h7i({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,fernEnum:M,enumVarNames:void 0,enumValues:T,_default:void 0,namespace:d,groupName:s,context:c,source:m,inline:void 0})}return P.length===1&&P[0]!=null&&!c.options.preserveSingleSchemaOneOf?P[0]:iKy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,subtypes:P,namespace:d,groupName:s,encoding:l,source:m})}function FVC({schemas:e}){let t={},r=0;for(let a of e){if(!Wg(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let o=Object.keys(a.properties),c={},d=o;for(let[s,u]of Object.entries(t)){let l=Uts(u,o);d=Uts(d,u),c[s]=l}c[r]=d,t=c}}r++}let n=[],i=0;for(let a of e){let o=t[i];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null){n.push(c[0]),++i;continue}}Wg(a)?n.push(d7i(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(d7i(i)??`${i}`),++i}return n}function iKy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,description:a,availability:o,subtypes:c,namespace:d,groupName:s,encoding:u,source:l}){let m=Oh.oneOf(uit.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:d,groupName:s,encoding:u,source:l,inline:void 0}));return i&&(m=Oh.nullable({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),n&&(m=Oh.optional({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),m}function tio(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Fxs({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=pfa(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function aKy({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=pfa(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function CVr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=pfa(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function oKy({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=pfa(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var hfa="#/components/schemas/";function cKy(e,t){let r=Wg(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"string":case"integer":return!0;case"array":return cKy(r.items,t);case"object":return!1;case void 0:return!1;default:return t.logger.warn("Unhandled schema type. Will not inline this schema",JSON.stringify(r)),!1}}function xVC(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:cKy(t,r):!1}function ES(e,t,r,n,i,a,o,c=!1,d=new Set,s){let u=GJy(e)??a,l=GVC({schema:e,logger:n.logger});if(Wg(e)){let m=y7i(e);return m!=null?xVC(m,e,n)?eio(n.resolveSchemaReference(e),t,r,n,cZo(e.$ref),l,u,o,d,c,s):(c?n.markSchemaAsReferencedByRequest(m):n.markSchemaAsReferencedByNonRequest(m),wPi(e,t,r,n,i,l,u,o)):eio(n.resolveSchemaReference(e),t,r,n,cZo(e.$ref),l,u,o,d,c,s)}return eio(e,t,r,n,i,l,u,o,d,c,s)}function wPi(e,t,r,n,i,a,o,c){let d=e.$ref.includes("properties")?eio(n.resolveSchemaReference(e),t,r,n,i,a,o,c,new Set):Oh.reference(MTf(e,i,o,n.options.preserveSchemaIds));if(r===!1){let s=n.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(d=Oh.nullable({title:void 0,nameOverride:void 0,generatedName:xie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(d=Oh.optional({title:void 0,nameOverride:void 0,generatedName:xie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),d}function zVC(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function eio(e,t,r,n,i,a,o,c,d=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Jy(e,jb.TYPE_NAME)??(n.options.useTitlesAsName?zVC(e.title):void 0),m=Jy(e,jb.SDK_GROUP_NAME)??Jy(e,Hbe.TAGS)?.[0],A=(typeof m=="string"?[m]:m)??[];A=n.resolveGroupName(A);let P=xie(i,n.options.preserveSchemaIds),C=e.title,M=e.description,T=Awe(e),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0});let U=Jy(e,Hbe.EXAMPLES);U!=null&&Object.keys(U).length>0&&z.push(...Object.entries(U).map(([$,re])=>({name:re?.summary??$,value:re.value,description:re.description})));let R=pfa(e);R!=null&&Object.keys(R).length>0&&z.push(...R.map($=>({name:void 0,value:$,description:void 0})));let V=HJy({schema:e,description:M,title:C,nameOverride:l,generatedName:P,availability:T});if(V!=null){let $=V;return r&&($=Oh.nullable({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),t&&($=Oh.optional({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),$}try{if(Array.isArray(e.type)){let X=e.type.indexOf("null"),ee=X!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&ee)e.type.splice(X,1),e.type=e.type[0],e.nullable=!0;else if(ee&&(e.type.splice(X,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let ne=new Set([...e.oneOf,...e.type]);e.oneOf=[...ne]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(ee=>ee!==null),!Qxs(e.enum))return Ose({nameOverride:l,generatedName:P,title:C,primitive:U0.string({default:tio(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:CVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T});let X=WJy(e);return e.enum.length===1&&e.enum[0]!=null&&X==null?kJy({nameOverride:l,generatedName:P,title:C,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:M,availability:T,namespace:c,groupName:A}):h7i({nameOverride:l,generatedName:P,title:C,fernEnum:X,enumVarNames:Jy(e,[Hbe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0})}if(Qxs(e.type)&&e.type.length>1){let X=e.type.includes("null"),ee=e.type.filter(ne=>ne!=="null").map(ne=>({type:ne,nullable:X}));return v7i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:ee,namespace:c,groupName:A,encoding:a,source:o})}if(e.type==="boolean"){let X=Jy(e,jb.BOOLEAN_LITERAL);return X!=null?uKy({nameOverride:l,generatedName:P,title:C,literal:FV.boolean(X),wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T,namespace:c,groupName:A}):Ose({nameOverride:l,generatedName:P,title:C,primitive:U0.boolean({default:QVC(e.default),example:aKy({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T,namespace:c,groupName:A})}if(e.type==="number")return ITf({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:_fa(e.exclusiveMinimum),exclusiveMaximum:_fa(e.exclusiveMaximum),multipleOf:e.multipleOf,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:Fxs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="integer")return ZJy({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:_fa(e.exclusiveMinimum),exclusiveMaximum:_fa(e.exclusiveMaximum),multipleOf:e.multipleOf,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:Fxs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="float")return ITf({nameOverride:l,generatedName:P,title:C,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:_fa(e.exclusiveMinimum),exclusiveMaximum:_fa(e.exclusiveMaximum),multipleOf:e.multipleOf,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:Fxs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="string"){if(e.format==="date-time")return Ose({nameOverride:l,generatedName:P,title:C,primitive:U0.datetime({example:CVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T,namespace:c,groupName:A});if(e.format==="date"&&n.options.typeDatesAsStrings===!1)return Ose({nameOverride:l,generatedName:P,title:C,primitive:U0.date({example:CVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T,namespace:c,groupName:A});if(e.format==="json-string"){let ee=Oh.unknown({nameOverride:l,generatedName:P,title:C,description:M,availability:T,namespace:c,groupName:A,example:void 0});return r&&(ee=Oh.nullable({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:ee})),t&&(ee=Oh.optional({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:ee})),ee}let X=fKy(e,"const");return X!=null?uKy({nameOverride:l,generatedName:P,title:C,literal:FV.string(X),wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T,namespace:c,groupName:A}):Ose({nameOverride:l,generatedName:P,title:C,primitive:U0.string({default:tio(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:CVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:M,availability:T})}if(e.type==="array")return $Jy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,item:e.items,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,example:oKy({schema:e,logger:n.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&xxs(e))return JJy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,additionalProperties:e.additionalProperties,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Jy(e,jb.IS_DISCRIMINATED)===!1)return v7i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf,namespace:c,groupName:A,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return n.options.discriminatedUnionV2?BTf({nameOverride:l,generatedName:P,title:C,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):DTf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let X=Jy(e,jb.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return n.options.discriminatedUnionV2||X?BTf({nameOverride:l,generatedName:P,title:C,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):DTf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(n.options.preserveSingleSchemaOneOf)return v7i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf.filter(ne=>Wg(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o});let ee=ES(e.oneOf[0],t,r,n,i,o,c,s);return rio(ee,M,c,A)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let be=e.oneOf[0],me=e.oneOf[1];if(!Wg(be)&&be.type==="null")return ES(me,!1,!0,n,i,o,c);if(!Wg(me)&&me.type==="null")return ES(be,!1,!0,n,i,o,c)}let ee=VVC({schemas:e.oneOf});if(ee!=null)return h7i({nameOverride:l,generatedName:P,title:C,fernEnum:void 0,enumVarNames:void 0,enumValues:ee,_default:e.default,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0});let ne=sKy({schemas:e.oneOf,context:n});if(ne!=null&&!n.options.discriminatedUnionV2&&!X)return CTf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:ne.discriminant,variants:ne.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let Oe=e.oneOf.filter(be=>!Wg(be)&&be.type==="null").length>0;return v7i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r||Oe,context:n,subtypes:e.oneOf.filter(be=>Wg(be)||be.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ne=ES(e.anyOf[0],t,r,n,i,o,c,s);return rio(ne,M,c,A)}if(e.anyOf.length===2){let[ne,Oe]=e.anyOf;if(ne!=null&&Oe!=null){if(!Wg(ne)&&ne.type==="null"){let be=ES(Oe,!1,!0,n,i,o,c);return rio(be,M,c,A)}else if(!Wg(Oe)&&Oe.type==="null"){let be=ES(ne,!1,!0,n,i,o,c);return rio(be,M,c,A)}}}let X=sKy({schemas:e.anyOf,context:n});if(X!=null&&!n.options.discriminatedUnionV2)return CTf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:X.discriminant,variants:X.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let ee=e.anyOf.filter(ne=>!Wg(ne)&&ne.type==="null").length>0;return v7i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r||ee,context:n,subtypes:e.anyOf.filter(ne=>Wg(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}if(e.allOf!=null||e.properties!=null){let X=[];for(let ne of e.allOf??[])(Wg(ne)||Object.keys(ne).length>0)&&X.push(ne);if((e.properties==null||xxs(e))&&X.length===1&&X[0]!=null){let ne=ES(X[0],t,r,n,i,o,c,s);return rio(ne,M,c,A)}let ee=X.filter(ne=>{let Oe=zxs(ne);return Oe||n.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ne)}`),Oe});if((e.properties==null||xxs(e))&&ee.length===1&&ee[0]!=null){let ne=ES(ee[0],t,r,n,i,o,c,s);return rio(ne,M,c,A)}return rKy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},description:M,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:ee,context:n,propertiesToExclude:d,namespace:c,groupName:A,fullExamples:z,additionalProperties:e.additionalProperties,availability:T,encoding:a,source:o})}if(e.type==="object"&&LVC(e)&&UVC(e)&&xxs(e))return STf({nameOverride:l,generatedName:P,title:C,description:M,availability:T,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${P}Key`,title:void 0,description:void 0,availability:void 0,schema:U0.string({default:tio(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:CVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A},valueSchema:Oh.unknown({nameOverride:void 0,generatedName:`${P}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:A}),namespace:c,groupName:A,encoding:a,example:e.example});e.type!=null&&n.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${i.join("->")}. Coercing to unknown.`);let $=e.example??e.default,re=Oh.unknown({nameOverride:l,generatedName:P,title:C,description:M,availability:T,namespace:c,groupName:A,example:$});return r&&(re=Oh.nullable({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),t&&(re=Oh.optional({availability:T,namespace:c,groupName:A,description:M,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),re}catch($){return n.logger.debug(`Error converting schema: ${$.message}
|
|
2410
|
-
Location: ${i.join("-> ")}`),Oh.unknown({nameOverride:l,generatedName:P,title:C,description:M,availability:T,namespace:c,groupName:A,example:void 0})}}function QVC(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function y7i(e){if(e.$ref.startsWith(hfa))return e.$ref.replace(hfa,"")}function MTf(e,t,r,n){let i=Jy(e,jb.TYPE_NAME),a=xie(t,n),o=e.description,c=Awe(e),d=y7i(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return kj.reference({generatedName:a,nameOverride:i,title:void 0,schema:d,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function LVC(e){return e.oneOf==null||e.oneOf.length===0}function UVC(e){return e.allOf==null||e.allOf.length===0}function xxs(e){return e.properties==null||Q7(e.properties)===0}function Qxs(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function rio(e,t,r,n){return e.type==="reference"?Oh.reference({...e,description:t,availability:e.availability,namespace:r,groupName:n}):e.type==="optional"?Oh.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e.type==="nullable"?Oh.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e}function zxs(e){return Wg(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>zxs(t)):e.oneOf!=null?e.oneOf.every(t=>zxs(t)):e.anyOf!=null?e.anyOf.every(t=>zxs(t)):!1}function uKy({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,nameOverride:c,generatedName:d,title:s}){let u=Oh.literal({nameOverride:c,generatedName:d,title:s,value:e,namespace:n,groupName:i,description:a,availability:o});return r&&(u=Oh.nullable({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=Oh.optional({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function Ose({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,generatedName:c,nameOverride:d,title:s}){i=typeof i=="string"?[i]:i;let u=Oh.primitive({nameOverride:d,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:n,groupName:i});return r&&(u=Oh.nullable({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=Oh.optional({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function VVC({schemas:e}){let t=new Set;for(let r of e){if(Wg(r))return;if(r.enum!=null&&Qxs(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function sKy({schemas:e,context:t}){let r={};for(let n of e){let i=lKy({schema:n,context:t});for(let[a,o]of Object.entries(i)){let c=r[a];c!=null?c[o]=n:r[a]={[o]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function lKy({schema:e,context:t}){let r=Wg(e)?t.resolveSchemaReference(e):e;return WVC({schema:r,context:t})}function WVC({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=lKy({schema:n,context:t});for(let[a,o]of Object.entries(i??{}))r[a]=o}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Wg(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Qxs(a.enum)&&HVC(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let o=fKy(a,"const");a.type==="string"&&o!=null&&(r[n]=o),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function HVC(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function fKy(e,t){let r=e[t];if(r!=null)return r}function GVC({schema:e,logger:t}){let r=VJy({schema:e,logger:t});if(r!=null)return XJy(r)}var nio=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(hfa))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let n=t.$ref.substring(hfa.length).split("/"),i=this.document.components;if(i==null||i.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=n;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=i.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(Wg(d)&&(d=this.resolveSchemaReference(d)),o==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);Wg(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};var Lxs=class extends nio{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",n=this.document.components;if(n==null||n.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let i=t.$ref.substring(r.length),a=n.messages[i];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function iio(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let n={};for(let[i,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[i]=a;continue}let o=a.namespace;n[o]??={},n[o][i]=a;continue}case"oneOf":case"unknown":r[i]=a;continue;default:tc(a)}return{rootSchemas:r,namespacedSchemas:n}}function b7i(e){if(typeof e=="string")return wS.primitive(wO.string(e));if(typeof e=="number")return Number.isInteger(e)?wS.primitive(wO.int(e)):wS.primitive(wO.double(e));if(typeof e=="boolean")return wS.primitive(wO.boolean(e));if(Array.isArray(e)){let t=e.map(r=>b7i(r));return t.length===0?void 0:wS.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=b7i(n);i!=null&&t.push({key:wO.string(r),value:i})}return wS.map(t)}}function lZo(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function dKy(e){if(e!=null&&Array.isArray(e))return e}var g7i=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,n){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=n}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:o,skipReadonly:c}){switch(n.type){case"enum":return typeof r=="string"&&pKy({schema:n,value:r})?wS.enum(r):n.values[0]!=null?wS.enum(n.values[0]?.value):void 0;case"literal":return wS.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,o)&&this.exceedsMaxDepth(i,o))return wS.null({});let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d??wS.null({})}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(i,o))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:o});return wS.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(n.schema),u=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(n.schema),u}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},s={},u={},l=lZo(r),m=l?.[n.value.discriminantProperty],A=n.value.schemas[m],P=[],C=this.getDiscriminatedUnionVariantSchema(n.value,l);C!=null&&P.push(C),P.push(...Object.entries(n.value.schemas));for(let M of P)if(m!=null&&A!=null&&A.type==="object"){s=this.getAllProperties(A),u=this.getAllRequiredProperties(A),d[n.value.discriminantProperty]=wS.primitive(wO.string(m));break}else{let T=this.buildExampleHelper({exampleId:t,schema:M[1],example:void 0,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});if(T!=null){this.mergeExampleWith(T,d),d[n.value.discriminantProperty]=wS.primitive(wO.string(M[0]));break}}for(let M of n.value.commonProperties){s[M.key]={schema:M.schema,readonly:!1};let T=this.getResolvedSchema(M.schema);T.type!=="optional"&&T.type!=="nullable"&&(u[M.key]=M.schema)}for(let[M,T]of Object.entries(s)){let z=M in u;if(z&&l?.[M]!=null){let U=this.buildExampleHelper({schema:T.schema,exampleId:t,example:l[M],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[M]=U;else return}else{let U=this.buildExampleHelper({exampleId:t,schema:T.schema,example:l?.[M],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[M]=U;else if(z)return}}return wS.oneOf(n7i.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=b7i(r);if(d!=null)return wS.unknown(d)}return o.ignoreOptionals||this.exceedsMaxDepth(i,o)?void 0:o.isParameter?wS.primitive(wO.string(o.name??"string")):wS.map([{key:wO.string("key"),value:wS.primitive(wO.string("value"))}]);case"array":{let d=dKy(r),s=[];if(d!=null&&d.length>0)for(let u of d){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(n.example!=null&&n.example.length>0)for(let u of n.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return wS.array(s)}case"map":{let d=lZo(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,A]of Object.entries(d)){let P=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:o}),C=this.buildExampleHelper({exampleId:t,example:A,schema:n.value,visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});C!=null&&l.push({key:P,value:C})}return wS.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return wS.map([{key:wO.string("key"),value:wS.unknown(wS.primitive(wO.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?wS.map([{key:s,value:u}]):wS.map([])}case"object":{let d={},s=n.fullExamples?.find(A=>A.name===t)??n.fullExamples?.find(A=>A.name==null)??n.fullExamples?.[0],u=lZo(r)??(s!=null?lZo(s.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[A,P]of Object.entries(l)){if(c&&P.readonly||P.schema._visit({optional:z=>typeof z.availability=="string"&&z.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let C=A in m,M=Object.keys(u).includes(A),T=this.buildExampleHelper({schema:P.schema,exampleId:t,example:u[A],visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});if(C&&T!=null)d[A]=T;else{if(C)return;(M&&T!=null||!o.ignoreOptionals&&T!=null)&&(d[A]=T)}}if(n.additionalProperties){for(let[A,P]of Object.entries(u))if(!(A in d)){let C=this.buildExampleHelper({schema:Oh.unknown({example:P,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:P,visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});C!=null&&(d[A]=C)}}return wS.object({properties:d})}default:tc(n)}}mergeExampleWith(t,r){t._visit({array:Hc,enum:Hc,literal:Hc,map:n=>{for(let i of n){let a=i.key;a.type==="string"&&(r[a.value]=i.value)}},object:n=>{for(let[i,a]of Object.entries(n.properties))r[i]=a},oneOf:n=>{if(n.type==="discriminated")for(let[i,a]of Object.entries(n.value))r[i]=a;else this.mergeExampleWith(n.value,r)},primitive:Hc,unknown:Hc,null:Hc,_other:Hc})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return pKy({schema:t,value:r})?5:0;case"object":{if(!Zq(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,o]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(o.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!Zq(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let o of t.properties)if(this.hasExample(o.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let o=this.hasExample(a,r,n,i);return n.delete(t.schema),o}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?wO.string(t):r.example!=null?wO.string(r.example):wO.string(n.name??yP.STRING);case"base64":return t!=null&&typeof t=="string"?wO.base64(t):r.example!=null?wO.base64(r.example):wO.base64(yP.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?wO.boolean(t):r.example!=null?wO.boolean(r.example):wO.boolean(yP.BOOLEAN);case"date":return t!=null&&typeof t=="string"?wO.date(t):r.example!=null?wO.date(r.example):wO.date(yP.DATE);case"datetime":return t!=null&&typeof t=="string"?wO.datetime(t):r.example!=null?wO.datetime(r.example):wO.datetime(yP.DATE_TIME);case"double":return t!=null&&typeof t=="number"?wO.double(t):r.example!=null?wO.double(r.example):wO.double(yP.DOUBLE);case"float":return t!=null&&typeof t=="number"?wO.float(t):r.example!=null?wO.float(r.example):wO.float(yP.FLOAT);case"int":return t!=null&&typeof t=="number"?wO.int(t):r.example!=null?wO.int(r.example):wO.int(yP.INT);case"int64":return t!=null&&typeof t=="number"?wO.int64(t):r.example!=null?wO.int64(r.example):wO.int64(yP.INT64);case"uint":return t!=null&&typeof t=="number"?wO.uint(t):r.example!=null?wO.uint(r.example):wO.uint(yP.UINT);case"uint64":return t!=null&&typeof t=="number"?wO.uint64(t):r.example!=null?wO.uint64(r.example):wO.uint64(yP.UINT64);default:tc(r)}}};function pKy({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function Mqr(e){switch(e.type){case"object":return Oh.object({allOf:e.allOf,properties:e.properties.map(t=>KVC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return Oh.array({description:e.description,availability:e.availability,value:Mqr(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Oh.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return Oh.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return Oh.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Mqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return Oh.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Mqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return Oh.primitive({description:e.description,availability:e.availability,schema:_Ky(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Oh.map({description:e.description,availability:e.availability,key:Oh.primitive({description:e.key.description,availability:e.key.availability,schema:_Ky(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:Mqr(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Oh.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Oh.oneOf(JVC(e.value));case"unknown":return Oh.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:tc(e)}}function JVC(e){switch(e.type){case"discriminated":return uit.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Mqr(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,Mqr(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return uit.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>Mqr(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:tc(e)}}function _Ky(e){switch(e.type){case"string":return U0.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return U0.base64({example:void 0});case"boolean":return U0.boolean({default:e.default,example:void 0});case"date":return U0.date({example:void 0});case"datetime":return U0.datetime({example:void 0});case"double":return U0.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return U0.float({example:void 0});case"int":return U0.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return U0.int64({default:e.default,example:void 0});case"uint":return U0.uint({default:void 0,example:void 0});case"uint64":return U0.uint64({default:void 0,example:void 0});default:tc(e)}}function KVC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Mqr(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Uxs(e){return e.type!=="optional"&&e.type!=="nullable"}function TTf(e){return e==="POST"||e==="PUT"||e==="PATCH"}function fZo(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var Vxs=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,n){this.schemas=t,this.context=r,this.globalHeaders=n,this.schemas=t,this.exampleTypeFactory=new g7i(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=YVC(t.request),n=XVC(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:TTf(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:A}of r.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:TTf(t.method),schema:r.schema,exampleId:m,example:A,options:{isParameter:!1,ignoreOptionals:!0}});P!=null&&i.push([m,P])}if(l&&i.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,vyt.withoutStreaming(m)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,vyt.withStreaming({sse:t.response?.type==="streamingSse",events:[m]})]))}else for(let{name:m,value:A}of n.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:A,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});P!=null&&(t.response?.type==="json"?a.push([m,vyt.withoutStreaming(P)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,vyt.withStreaming({sse:t.response?.type==="streamingSse",events:[P]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let o=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&o.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:A})}let c=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&c.push({name:l.name,value:A})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&d.push({name:l.name,value:A})}for(let l of this.globalHeaders){let m=l.schema!=null?Mqr(l.schema):Oh.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:U0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),A=this.exampleTypeFactory.buildExample({schema:m,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),A==null)return[];A!=null&&d.push({name:l.header,value:A})}let s=[];t.request!=null&&t.response!=null?s=$VC(i,a):t.request!=null?s=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(s=a.map(([l,m])=>({id:l,request:void 0,response:m})));let u=t.examples.filter(l=>fZo(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>kw(l));return s.length===0?[yyt.full({name:void 0,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:u})]:s.map(({id:l,request:m,response:A})=>yyt.full({name:l,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:m,response:A,codeSamples:u}))}convertCodeSamples(t){return t.map(r=>"language"in r?OVr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):OVr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?Jde.Csharp:r.sdk,code:r.code})).filter(kw)}isSchemaRequired(t){return Uxs(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function $VC(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[o,c]of t)r.push({id:o??i,request:a,response:c});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[o,c]of e)r.push({id:o??i,request:c,response:a});return r}let n=new Set;for(let[i,a]of e){let o=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(o==null)continue;r.push({id:void 0,request:a,response:o});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,u]=t[d];s==null||n.has(d)||i===s&&(r.push({id:i,request:a,response:u}),s!=null&&n.add(d),c=!0)}!c&&o!=null&&r.push({id:i,request:a,response:o})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,o]=t[i],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:o})}return r}function YVC(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:ZVC(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function XVC(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function Bqr(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return Bqr(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return Bqr(e.value.value);default:return!1}case"null":return!0;default:tc(e)}}function ZVC(e){return Oh.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:Mqr(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(kw),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var aio=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new g7i(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:n,source:i,namespace:a}){let o=[];for(let c of r){let d=[];for(let l of n.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!Bqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&d.push({name:l.name,value:A})}let s=[];for(let l of n.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!Bqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&s.push({name:l.name,value:A})}let u=[];for(let l of c.messages){let m=t.getExampleMessageReference(l),A=t.resolveMessageReference({$ref:m}),P=Wg(A.payload)?t.resolveSchemaReference(A.payload):A.payload,C=this.exampleTypeFactory.buildExample({schema:ES(P,!1,!1,t,[l.messageId],i,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});C!=null&&u.push({messageType:l.type,payload:C,description:void 0})}o.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:u})}return o}buildWebsocketSessionExample({handshake:t,messages:r}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},i=[];for(let o of t.queryParameters){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!Bqr(d)&&(d=void 0),c&&d==null)return;d!=null&&i.push({name:o.name,value:d})}let a=[];for(let o of t.headers){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!Bqr(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:o.name,value:d})}for(let o of r){let c=this.exampleTypeFactory.buildExample({schema:o.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&n.messages.push({messageType:o.type,payload:c,description:void 0})}return n}isSchemaRequired(t){return Uxs(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var pIe={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Wxs(e){return Jy(e,pIe.FERN_EXAMPLES)??[]}function Hxs(e,t){return t.includes("://")?t:`${e}://${t}`}function Gxs(e){return e.startsWith("/")?e:"/"+e}function vKy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={};for(let[s,u]of Object.entries(i.components?.schemas??{})){let l=ES(u,!1,!1,e,[s],r,e.namespace);a[s]=l}let c=new aio(a,e),d={};for(let[s,u]of Object.entries(i.servers??{}))d[s]={name:s,url:Hxs(u.protocol,u.url)};for(let[s,u]of Object.entries(i.channels??{})){let l=Jy(u,pIe.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let m=[];if(u.parameters!=null)for(let[T,z]of Object.entries(u.parameters??{}))m.push({name:T,description:z.description,parameterNameOverride:void 0,schema:z.schema!=null?ES(z.schema,!1,!1,e,t,r,e.namespace):Oh.primitive({schema:U0.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:Awe(z),source:r});let A=[],P=[];if(u.bindings?.ws!=null){if(u.bindings.ws.headers!=null){let T=u.bindings.ws.headers.required??[];for(let[z,U]of Object.entries(u.bindings.ws.headers.properties??{})){if(Wg(U)){let re=e.resolveSchemaReference(U);A.push({name:z,schema:wPi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,env:void 0,availability:Awe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];A.push({name:z,schema:ES(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,env:void 0,availability:Awe(U),source:r})}}if(u.bindings.ws.query!=null){let T=u.bindings.ws.query.required??[];for(let[z,U]of Object.entries(u.bindings.ws.query.properties??{})){if(Wg(U)){let re=e.resolveSchemaReference(U);P.push({name:z,schema:wPi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,availability:Awe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];P.push({name:z,schema:ES(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,availability:Awe(U),source:r})}}}let C;u.publish!=null&&("oneOf"in u.publish.message?C=hKy({generatedName:u.publish.operationId??"PublishEvent",event:u.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):C=yKy({action:"Publish",channelPath:s,message:u.publish.message,context:e,source:r}));let M;if(u.subscribe!=null&&("oneOf"in u.subscribe.message?M=hKy({generatedName:u.subscribe.operationId??"SubscribeEvent",event:u.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):M=yKy({action:"Subscribe",channelPath:s,message:u.subscribe.message,context:e,source:r})),A.length>0||P.length>0||C!=null||M!=null){let T=Wxs(u),z=[];if(T.length>0)z=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:T,handshake:{headers:A,queryParameters:P},source:r,namespace:e.namespace});else{let $=[];C!=null&&$.push({type:"publish",payload:C}),M!=null&&$.push({type:"subscribe",payload:M});let re=c.buildWebsocketSessionExample({handshake:{headers:A,queryParameters:P},messages:$});re!=null&&z.push(re)}let U=Jy(u,pIe.FERN_CHANNEL_ADDRESS),R=U??Gxs(s),V=[];C!=null&&V.push({origin:"client",name:"publish",body:L4(C)}),M!=null&&V.push({origin:"server",name:"subscribe",body:L4(M)}),o[s]={audiences:Jy(u,jb.AUDIENCES)??[],handshake:{headers:A.map($=>({...$,schema:L4($.schema),env:$.env})),queryParameters:P.map($=>({...$,schema:L4($.schema)})),pathParameters:m.map($=>({...$,parameterNameOverride:void 0,schema:L4($.schema)}))},groupName:e.resolveGroupName([Jy(u,pIe.FERN_SDK_GROUP_NAME)??s]),messages:V,servers:(u.servers?.map($=>d[$])??Object.values(d)).filter($=>$!=null&&$.name!=null).map($=>({...$,name:$.name})),summary:Jy(u,pIe.FERN_DISPLAY_NAME),path:R,description:u.description,examples:z,source:r}}}return{groupedSchemas:iio(e.namespace,a),channels:o??void 0,servers:Object.values(d).map(s=>({...s,name:s.name})),basePath:Jy(i,pIe.BASE_PATH)}}function hKy({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:o}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let u,l={type:"notFound"};if(Wg(s)){let m=r.resolveMessageReference(s);!Wg(m.payload)&&o.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,u={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):u=m.payload}else u=s;d.push(l),c.push(u)}return v7i({description:t.description??t.message.description,availability:Awe(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsOptional:!1,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:o.naming==="v2"?d:[]})}}function yKy({action:e,channelPath:t,message:r,context:n,source:i}){if(r.payload!=null){let a=r.payload;return Wg(r.payload)&&(a=n.resolveSchemaReference(r.payload)),ES(a,!1,!1,n,[t,e],i,n.namespace)}}var Jxs=class extends nio{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(r.length),i=this.document.components.parameters[n];if(i==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in i?this.resolveParameterReference(i):i}resolveMessageReference(t){let r="#/channels/",n="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let i=this.document.components;if(!t.$ref.startsWith(n)||!i?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(n.length),o=i.messages[a];if(o==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...o}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var bKy="#/channels/",gKy="#/servers/",qTf="$message.";function OKy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={},c={},d=[],s={};for(let[P,C]of Object.entries(i.components?.schemas??{}))a[P]=ES(C,!1,!1,e,[P],r,e.namespace);for(let[P,C]of Object.entries(i.channels??{}))if(o[P]||(o[P]={}),C.messages){for(let[M,T]of Object.entries(C.messages))if(e.isReferenceObject(T)||e.isMessageWithPayload(T))if(c[M]||(c[M]=[]),e.isReferenceObject(T)){let z=e.resolveMessageReference(T);c[M].push({channelId:P,payload:z.payload})}else c[M].push({channelId:P,payload:T.payload})}for(let[P,C]of Object.entries(c))if(C.length===1){let M=C[0],T=M.channelId;o[T]=o[T]||{},o[T][P]=ES(M.payload,!1,!1,e,[P],r,e.namespace)}else{d.push(P);for(let{channelId:M,payload:T}of C){let z=`${M}_${P}`;o[M]||(o[M]={}),o[M][z]=ES(T,!1,!1,e,[z],r,e.namespace)}}let u=Object.values(o).reduce((P,C)=>({...P,...C}),{}),l=new aio(u,e),m={};for(let[P,C]of Object.entries(i.servers??{}))m[P]={name:P,url:Hxs(C.protocol,C.host)};let A={};for(let[P,C]of Object.entries(i.operations??{})){if(Jy(C,pIe.IGNORE))continue;let M=kVC(C);if(A[M]||(A[M]={subscribe:[],publish:[],__parsedMessages:[]}),C.action==="receive")A[M].subscribe.push(...C.messages);else if(C.action==="send")A[M].publish.push(...C.messages);else throw new Error(`Operation ${P} has an invalid action: ${C.action}`)}for(let[P,C]of Object.entries(A)){let M=[];M.push(...mKy({messages:C.subscribe,channelPath:P,origin:"server",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),M.push(...mKy({messages:C.publish,channelPath:P,origin:"client",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),A[P]!=null&&(A[P].__parsedMessages=M)}for(let[P,C]of Object.entries(i.channels??{})){if(Jy(C,pIe.IGNORE))continue;let M=[],T=[],z=[];if(C.parameters!=null)for(let[U,R]of Object.entries(C.parameters)){let V=e.isReferenceObject(R)?e.resolveParameterReference(R):R,{type:$,parameterKey:re}=V.location!=null?eWC(V.location):{type:C.address?.includes(`={${U}}`)?"query":"path",parameterKey:U},X=Jy(V,pIe.FERN_PARAMETER_OPTIONAL),ee=n9(MA(P))+n9(MA(U)),ne={...V,type:"string",title:ee,example:V.examples?.[0],default:V.default,enum:V.enum,required:void 0},Oe=ES(ne,!1,!1,e,[re],r,e.namespace);X&&(Oe=Oh.optional({value:Oe,description:void 0,availability:void 0,generatedName:"",title:ee,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let be={name:re,description:V.description,parameterNameOverride:void 0,schema:Oe,variableReference:void 0,availability:Awe(R),source:r};$==="header"?M.push({...be,env:void 0}):$==="path"?T.push(be):($==="payload"||$==="query")&&z.push(be)}if(M.length>0||z.length>0||A[P]!=null&&(A[P].publish!=null||A[P].subscribe!=null)){let U=Wxs(C),R=A[P]?.__parsedMessages??[],V=[];if(U.length>0)V=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:U,handshake:{headers:M,queryParameters:z},source:r,namespace:e.namespace});else{let re=[],{examplePublishMessage:X,exampleSubscribeMessage:ee}=rWC({messages:R,messageSchemas:o[P]??{}});X!=null&&re.push(X),ee!=null&&re.push(ee);let ne=l.buildWebsocketSessionExample({handshake:{headers:M,queryParameters:z},messages:re});ne!=null&&V.push(ne)}let $=Jy(C,pIe.FERN_SDK_GROUP_NAME);s[P]={audiences:Jy(C,jb.AUDIENCES)??[],handshake:{headers:M.map(re=>({...re,schema:L4(re.schema),env:re.env})),queryParameters:z.map(re=>({...re,schema:L4(re.schema)})),pathParameters:T.map(re=>({...re,parameterNameOverride:void 0,schema:L4(re.schema)}))},groupName:e.resolveGroupName(typeof $=="string"?[$]:$??[P]),messages:R,summary:Jy(C,pIe.FERN_DISPLAY_NAME),servers:(C.servers?.map(re=>tWC(m,re))??Object.values(m)).map(re=>({...re,name:re.name})),path:C.address?.split("?")[0]??Gxs(P),description:C.description,examples:V,source:r}}}return{groupedSchemas:iio(e.namespace,a),channels:s,servers:Object.values(m).map(P=>({...P,name:P.name})),basePath:Jy(i,pIe.BASE_PATH)}}function kVC(e){if(!e.channel.$ref.startsWith(bKy))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(bKy.length)}function eWC(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(qTf))throw new Error(`Invalid location format: ${e}; expected ${qTf} prefix`);let n=t.substring(qTf.length);if(n!=="header"&&n!=="path"&&n!=="payload")throw new Error(`Invalid message type: ${n}. Must be one of: header, path, payload`);return{type:n,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function tWC(e,t){if(!t.$ref.startsWith(gKy))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(gKy.length),n=e[r];if(n==null)throw new Error(`Failed to find server with name ${r}`);return n}function mKy({messages:e,channelPath:t,origin:r,messageSchemas:n,duplicatedMessageIds:i,context:a}){let o=[];return e.forEach((c,d)=>{let u=a.resolveMessageReference(c).name;i.includes(u)&&(u=`${t}_${u}`);let l=n[u];l!=null&&o.push({origin:r,name:u??`${r}Message${d+1}`,body:L4(l)})}),o}function rWC({messages:e,messageSchemas:t}){let r=e.find(o=>o.origin==="client")?.name,n=e.find(o=>o.origin==="server")?.name,i=r!=null?t[r]:void 0,a=n!=null?t[n]:void 0;return{examplePublishMessage:i!=null&&r!=null?{type:r,payload:i}:void 0,exampleSubscribeMessage:a!=null&&n!=null?{type:n,payload:a}:void 0}}function AKy({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let o=[];if(a!=null&&o.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?o.push(c.tags[0].name):i.naming!=="v2"&&o.push("websocket");let d=new Lxs({document:c,taskContext:t,options:r,namespace:a});return vKy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}else{let c=e,d=new Jxs({document:c,taskContext:t,options:r,namespace:a});return OKy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}}function PKy(e){return Jy(e,jb.ASYNC_CONFIG)}var wKy="$request.";function jKy(e){let t=Jy(e,jb.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:nWC(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function nWC(e){return e.startsWith(wKy)?e.slice(wKy.length):e}function EKy(e){let t=e;if(t.cursor!=null)return oit.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return oit.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return oit.custom({results:r.results})}throw new Error("Invalid pagination extension")}function SKy(e,t){let r=Jy(t,jb.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Jy(e,jb.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:EKy(n)}return EKy(r)}}function DKy(e){let t=iWC(e),r={};return RTf({obj:t,occurrences:r,breadcrumbs:[]}),r}function RTf({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)RTf({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)RTf({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function iWC(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?dZo(r.get):void 0,put:r?.put!=null?dZo(r.put):void 0,post:r?.post!=null?dZo(r.post):void 0,patch:r?.patch!=null?dZo(r.patch):void 0,delete:r?.delete!=null?dZo(r.delete):void 0}]))}}function dZo(e){return{...e,requestBody:e.requestBody!=null?Wg(e.requestBody)?e.requestBody:aWC(e.requestBody):void 0}}function aWC(e){let t,r;for(let n in e.content){let i=z7.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[z7.MULTIPART_FORM_DATA]:r}}:e}var Kxs=class{endpoints;parser=new hua;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let n=[];for(let i of r){let a=this.parser.tryParse(i);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${i}"; expected format "POST /users/get"`);continue}n.push(`${a.method} ${a.path}`)}return n}};var CKy="#/components/parameters/",IKy="#/components/responses/",MKy="#/components/examples/",BKy="#/components/requestBodies/",TKy="#/components/securitySchemes/",oio=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=DKy(t),this.options=i,this.source=a,this.filter=new Kxs({context:r,options:i}),this.DUMMY=this.getDummy(),this.namespace=o}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown"};if(Array.isArray(n)){let a=parseInt(i,10);if(isNaN(a)||a<0||a>=n.length)return{"x-fern-type":"unknown"};n=n[a]}else n=n[i]}return n==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(Wg(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(CKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(CKy.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(BKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(BKy.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(IKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(IKy.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(MKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(MKy.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveExampleReference(n):n}resolveSecuritySchemeReference(t){if(this.document.components==null||this.document.components.securitySchemes==null||!t.$ref.startsWith(TKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(TKy.length),n=this.document.components.securitySchemes[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveSecuritySchemeReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var yfa=class extends oio{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var oWC=rl.object({lang:rl.string(),label:rl.optional(rl.string()),source:rl.string()}),NTf=rl.array(oWC);var qKy={README_EXT:"x-readme"};function uWC(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Zq(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function RKy(e){let t=Jy(e,qKy.README_EXT);if(!Zq(t))return[];let r=t["code-samples"];if(!uWC(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function NKy(e,t,r){let i=(Jy(t,jb.EXAMPLES)??[]).filter(s=>{let u=YX.serialization.ExampleEndpointCallSchema.parse(s);return u.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),u.ok}),a=oZo(t,Hbe.REDOCLY_CODE_SAMPLES_KEBAB,NTf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...oZo(t,Hbe.REDOCLY_CODE_SAMPLES_CAMEL,NTf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&i.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=RKy(t);return d.length>0&&i.push({"code-samples":d}),i.map(yyt.unknown)}function FKy(e){let t=Jy(e,jb.AVAILABILITY);if(t==="ga"||t==="generally-available")return Gde.GenerallyAvailable;if(t==="beta"||t==="pre-release")return Gde.Beta;if(t==="deprecated")return Gde.Deprecated;if(e.deprecated)return Gde.Deprecated}function xKy(e){let t=Jy(e,jb.RETRIES);if(t!=null&&t.disabled===!0)return bNs.RetriesConfiguration.disabled(t.disabled)}function $xs(e,t){return{url:sWC({url:e.url,variables:e.variables??{}}),description:e.description,name:cWC(e,t),audiences:Jy(e,jb.AUDIENCES)}}function sWC({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,encodeURIComponent(i));return e}function cWC(e,t){let r=Jy(e,[jb.SERVER_NAME_V1,jb.SERVER_NAME_V2]);if(r!=null)return r;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox";if(t?.groupMultiApiEnvironments&&e.description!=null&&e.description.trim()!==""){let n=e.description.toLowerCase();return n==="prd"?"Production":n==="sbx"?"Sandbox":n==="staging"||n==="stg"?"Staging":n==="development"||n==="dev"?"Development":e.description}}function zKy(e){return Jy(e,jb.PARAMETER_NAME)}function QKy(e){return Jy(e,jb.SDK_VARIABLE)}function Yxs({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let o={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=Jy(c,jb.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=Wg(c)?n.resolveParameterReference(c):c,u=s.required??!1,l=Awe(s),m=[...i,s.name],A=xie(m,n.options.preserveSchemaIds),[P,C]=n.options.coerceOptionalSchemasToNullable?[!1,!u]:[!u,!1],M=s.schema!=null?ES(s.schema,P,C,n,m,a,n.namespace,!1,new Set,CVr({schema:s,logger:n.logger})):u?Oh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:U0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:CVr({schema:s,logger:n.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):Oh.optional({nameOverride:void 0,generatedName:A,title:void 0,value:Oh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:U0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:CVr({schema:s,logger:n.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!Wg(s.schema)&&s.schema.default!=null){let z=s.schema.default;typeof z=="string"&&z.length>0&&(M=Oh.literal({nameOverride:void 0,generatedName:A,title:void 0,value:FV.string(z),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let T={name:s.name,schema:M,description:s.description,parameterNameOverride:zKy(s),availability:l,source:a};s.in==="query"?o.queryParameters.push(T):s.in==="path"?o.pathParameters.push({...T,variableReference:QKy(s)}):s.in==="header"?!lWC.has(s.name.toLowerCase())&&!n.authHeaders.has(s.name)?o.headers.push({...T,env:void 0}):n.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return o}var lWC=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function LKy(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:pZo(n,t)}}}function fWC(e){return e.includes("json")||e==="*/*"}function FTf({content:e,context:t}){for(let[r,n]of Object.entries(e))if(Xxs({mediaType:r,mediaTypeObject:n,context:t})!=null)return[r,n]}function Xxs({mediaType:e,mediaTypeObject:t,context:r}){if(!fWC(e))return;let n=t.schema;return{contentType:e.includes("*")?void 0:e,schema:n??{},examples:pZo(t,r)}}function Zxs({content:e,context:t}){let r=FTf({content:e,context:t});if(!r)return;let[n,i]=r;return Xxs({mediaType:n,mediaTypeObject:i,context:t})}function UKy(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:pZo(n,t)}}}function pZo(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Jy(e,Hbe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let o=Wg(a)?t.resolveExampleReference(a):a;return{name:o.summary??i,value:o.value,description:o.description}})),r}function dWC({content:e,context:t}){for(let[r,n]of Object.entries(e))if(WKy({mediaType:r,mediaTypeObject:n,context:t}))return[r,n]}function WKy({mediaType:e,mediaTypeObject:t,context:r}){if(z7.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:pZo(t,r)}}function pWC({content:e}){for(let[t,r]of Object.entries(e))if(HKy({mediaType:t,mediaTypeObject:r}))return[t,r]}function HKy({mediaType:e,mediaTypeObject:t}){if(z7.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function GKy({mediaType:e}){return z7.parse(e)?.isBinary()??!1}function _WC({content:e}){for(let[t,r]of Object.entries(e))if(GKy({mediaType:t}))return[t,r]}function hWC(e,t){let r=Wg(e)?xTf(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Wg(i)&&i.type==="string"&&i.format==="binary")!=null}function e3s({content:e,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}){let c=_WC({content:e});if(c){let[m,A]=c;return IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}let d=pWC({content:e}),s=FTf({content:e,context:n}),u=yWC({json:s,multipart:d,document:r,visitor:{json:([m,A])=>IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),multipart:([m,A])=>IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),neither:()=>{}}});if(u)return u;let l=dWC({content:e,context:n});if(l){let[m,A]=l;return IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}}function yWC({json:e,multipart:t,document:r,visitor:n}){if(!e&&!t)return n.neither();let[,i]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!i?.schema&&!a?.schema?n.neither():i?.schema&&a?.schema?i.schema&&hWC(i.schema,r)?n.multipart(t):n.json(e):i?.schema?n.json(e):a?.schema?n.multipart(t):n.neither()}function IVr({mediaType:e,mediaTypeObject:t,description:r,document:n,context:i,requestBreadcrumbs:a,source:o,namespace:c}){let d=vWC({mediaTypeObject:t});if(GKy({mediaType:e}))return lIe.octetStream({description:r,source:o,sdkMethodName:d,contentType:e});let s=HKy({mediaType:e,mediaTypeObject:t}),u=s?.schema,l=s?.encoding;if(u){let P=Wg(u)?xTf(u,n):{id:void 0,schema:u},C=ES(P.schema,!1,!1,i,a,o,c,!1),M=[];if(C.type==="object")for(let T of C.properties){let{isFile:z,isOptional:U,isArray:R,description:V}=kxs({schema:T.schema});if(z){let $=VKy(T.key,l);M.push({key:T.key,schema:AVr.file({isOptional:U,isArray:R,description:V}),description:V,contentType:$,exploded:!1,encoding:$==null?i.options.defaultFormParameterEncoding:void 0})}else{let $=VKy(T.key,l);M.push({key:T.key,schema:AVr.json(T.schema),description:void 0,contentType:$,exploded:l?.[T.key]?.explode,encoding:$==null?i.options.defaultFormParameterEncoding:gWC($)})}}return lIe.multipart({name:Wg(u)&&i.getNumberOfOccurrencesForRef(u)===1?P.id:void 0,description:P.schema.description,properties:M,source:o,sdkMethodName:d})}let m=Xxs({mediaType:e,mediaTypeObject:t,context:i});if(m){let P=ES(m.schema,!1,!1,i,a,o,c,!0);return lIe.json({description:void 0,schema:P,contentType:m.contentType,fullExamples:m.examples,additionalProperties:!Wg(m.schema)&&sZo(m.schema.additionalProperties,i.options),source:o,sdkMethodName:d})}let A=WKy({mediaType:e,mediaTypeObject:t,context:i});if(A!=null&&A.schema!=null){let P=ES(A.schema,!1,!1,i,a,o,c,!1);return lIe.formUrlEncoded({schema:P,description:r,contentType:A.contentType,source:o,fullExamples:A.examples,additionalProperties:!1,sdkMethodName:d})}}function vWC({mediaTypeObject:e}){return Jy(e,jb.SDK_METHOD_NAME)}var bWC={"application/json":"json"};function gWC(e){return e?bWC[e]:void 0}function xTf(e,t){if(!e.$ref.startsWith(hfa))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=y7i(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Wg(n)?xTf(n,t):{id:r,schema:n}}function kxs({schema:e,isOptional:t,isArray:r,description:n}){return OWC(e)?kxs({schema:e.value,isOptional:!0,isArray:r,description:e.description}):AWC(e)?kxs({schema:e.value,isOptional:t,isArray:r,description:e.description}):PWC(e)?kxs({schema:e.value,isOptional:t,isArray:!0,description:e.description}):mWC(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:n??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function mWC(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function OWC(e){return e.type==="optional"}function AWC(e){return e.type==="nullable"}function PWC(e){return e.type==="array"}function VKy(e,t){return t?.[e]?.contentType}var zTf={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},JKy=new Set(Object.values(zTf));var wWC=["200","201","202","204"];function $Ky({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:o}){if(t==null)return{value:void 0,errors:{}};let c=jWC({responses:t,context:r,source:o,namespace:r.namespace}),d=!1,s;for(let u of i!=null?[i]:wWC){let l=t[u];l!=null&&(d=!0,s==null&&(s=KKy({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace,statusCode:typeof u=="string"?parseInt(u):u})))}if(s==null&&!d&&t.default!=null&&(s=KKy({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:tc(s)}return{value:void 0,errors:c}}function KKy({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:o,statusCode:c}){let d=Wg(r)?n.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([m,A])=>{if(A.schema==null)return!1;let P=Wg(A.schema)?n.resolveSchemaReference(A.schema):A.schema;return P.type==="string"&&P.format==="binary"}))return n.options.useBytesForBinaryResponse&&t==null?XL.bytes({description:d.description,source:a,statusCode:c}):XL.file({description:d.description,source:a,statusCode:c});let s=LKy(d.content??{},n);if(s!=null&&t!=null)switch(t){case"json":return XL.streamingJson({statusCode:c,description:d.description,responseProperty:Jy(e.operation,jb.RESPONSE_PROPERTY),fullExamples:s.examples,schema:ES(s.schema,!1,!1,n,i,a,o),source:a});case"sse":return XL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:ES(s.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}let u=Zxs({context:n,content:d.content??{}});if(u){if(t!=null)switch(t){case"json":return XL.streamingJson({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:ES(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c});case"sse":return XL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:ES(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}return XL.json({description:d.description,schema:ES(u.schema,!1,!1,n,i,a,o),responseProperty:Jy(e.operation,jb.RESPONSE_PROPERTY),fullExamples:u.examples,source:a,statusCode:c})}for(let[l,m]of Object.entries(d.content??{})){let A=z7.parse(l);if(A!=null){if(A.isOctetStream()||A.isPDF()||A.isAudio()||A.isImage()||A.isVideo()||A.isMultiPartMixed())return XL.file({description:d.description,source:a,statusCode:c});if(A.isPlainText()){let P=m.schema;if(P==null)return XL.text({description:d.description,source:a,statusCode:c});let C=Wg(P)?n.resolveSchemaReference(P):P;return C.type==="string"&&C.format==="byte"?XL.file({description:d.description,source:a,statusCode:c}):XL.text({description:d.description,source:a,statusCode:c})}}}}function jWC({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,o]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=Wg(o)?t.resolveResponseReference(o):o,s=UKy(d.content??{},t),u=zTf[c];if(u==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[c]={statusCode:c,nameOverride:void 0,generatedName:u,description:d.description,schema:ES(s?.schema??{},!1,!1,t,[u,"Body"],r,n),fullExamples:s?.examples,source:r}}return i}function jPi({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:o,operation:c,path:d,method:s,baseBreadcrumbs:u}=e,l=Jy(c,jb.IDEMPOTENT),m=Jy(c,[jb.REQUEST_NAME_V1,jb.REQUEST_NAME_V2]),A=[...u,"Request"],P=Yxs({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:A,path:d,httpMethod:s,source:a}),C=/{([^}]+)}/g,M=[...d.matchAll(C)].map(ee=>ee[1]).filter(ee=>ee!==void 0);if(M.length>0){let ee=new Map(P.pathParameters.map(be=>[be.name,be])),ne=[],Oe=new Set;for(let be of M){let me=ee.get(be);Oe.add(be),me?ne.push(me):ne.push({name:be,variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Oh.primitive({schema:U0.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0})}for(let be of P.pathParameters)Oe.has(be.name)||ne.push(be);P.pathParameters=ne}let T=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let ee=Wg(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,ne=Object.values(ee.content).every(be=>SWC({mediaTypeObject:be})!=null),Oe=[];if(ne)return Oe.push(...Object.entries(ee.content).map(([be,me])=>{let he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:new yfa({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return YKy({context:t,convertedParameters:P})&&he!=null&&(he.type==="json"||he.type==="formUrlEncoded")&&he.schema.type!=="object"&&c.requestBody!=null?he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),he}).filter(be=>be!=null)),Oe.length===0?[void 0]:Oe;{let be=e3s({content:ee.content,description:ee.description,document:o,context:new yfa({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return YKy({context:t,convertedParameters:P})&&be!=null&&(be.type==="json"||be.type==="formUrlEncoded")&&be.schema.type!=="object"&&c.requestBody!=null?be=e3s({content:ee.content,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(be=e3s({content:ee.content,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),[be]}})(),z=T.length>1,U=[...u,"Response"],R=$Ky({operationContext:e,streamFormat:i,responses:c.responses,context:t,responseBreadcrumbs:U,responseStatusCode:r,source:a}),V=xKy(c),$=FKy(c),re=NKy(e,c,t),X=Jy(c,jb.SERVER_NAME_V2);return T.map(ee=>({summary:c.summary,internal:Jy(c,Hbe.INTERNAL),idempotent:l,audiences:Jy(c,jb.AUDIENCES)??[],operationId:c.operationId!=null&&n!=null?c.operationId+"_"+n:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:DWC({operationContext:e,request:ee}),pathParameters:P.pathParameters,queryParameters:P.queryParameters,headers:P.headers,requestNameOverride:m??void 0,generatedRequestName:xie(z?EWC({breadcrumbs:A,request:ee}):A,t.options.preserveSchemaIds),request:ee,response:R.value,errors:R.errors,servers:X!=null?[{name:X,url:void 0,audiences:void 0}]:(c.servers??[]).map(ne=>$xs(ne,{groupMultiApiEnvironments:t.options.groupMultiApiEnvironments})),description:c.description,authed:IWC(c,o),security:CWC(c),availability:$,method:s,path:d,examples:re,pagination:e.pagination,source:a,retries:V}))}function EWC({breadcrumbs:e,request:t}){return t?[...e,t.type]:e}function SWC({mediaTypeObject:e}){return Jy(e,jb.SDK_METHOD_NAME)}function DWC({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function CWC(e){return e.security??[]}function IWC(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function YKy({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function ZKy({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:o}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],u=XKy({context:t,headerToIgnore:c,parameters:a}),l=XKy({context:t,headerToIgnore:c,parameters:o}),m=jPi({operationContext:{...e,pathItemParameters:u,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([P])=>parseInt(P)!==s))}},context:t,streamFormat:void 0,source:n}),A=jPi({operationContext:{...e,pathItemParameters:u,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:n});return A.forEach(P=>{P.headers.push({name:c,schema:Oh.literal({nameOverride:void 0,generatedName:xie([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:FV.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n})}),{sync:m,async:A}}function XKy({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Wg(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var QTf="stream";function r$y({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:jPi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let n=kKy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let s=y7i(n.schemaReference);s!=null&&t.excludeSchema(s)}let i=e$y({operation:e.operation,response:r.responseStream}),a=jPi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+QTf}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,QTf]},context:t,streamFormat:r.format,suffix:QTf,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(u=>t$y(u,t)!==!1)});let o=kKy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=e$y({operation:e.operation,response:r.response}),d=jPi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:o?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(u=>t$y(u,t)!==!0)}),{streaming:a,nonStreaming:d}}default:tc(r)}}function kKy({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Wg(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Zxs({content:i.content,context:e});if(a==null)return;let o=Wg(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(o.allOf==null&&o.properties==null)return;let c=o.properties?.[r.streamConditionProperty];c!=null&&Wg(c)&&(c=void 0);let d={...o,properties:{...o.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...c??{}}},title:void 0,required:[...o.required??[],r.streamConditionProperty]};return{requestBody:{content:{[z7.APPLICATION_JSON]:{schema:d}}},schemaReference:Wg(a.schema)?a.schema:void 0}}function e$y({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[z7.APPLICATION_JSON]:{schema:t}}}}}function t$y(e,t){return e._visit({unknown:r=>{let n=YX.serialization.ExampleEndpointCallSchema.parse(r);if(n.ok&&n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function n$y({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:o,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],u=Yxs({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:o,source:r});if(i.requestBody==null)return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Missing a request body`),[];let l=i.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(o!=="POST"&&o!=="GET")return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Not POST or GET`),[];let m=Wg(i.requestBody)?e.resolveRequestBodyReference(i.requestBody):i.requestBody;return Object.entries(m.content).map(([A,P])=>IVr({mediaType:A,mediaTypeObject:P,description:m.description,document:n,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(A=>A!=null).map(A=>{if(A==null||A.type!=="json"&&A.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:i.summary,audiences:Jy(i,jb.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:o,operationId:l,tags:e.resolveTagsToTagIds(i.tags),headers:u.headers,generatedPayloadName:xie(s,e.options.preserveSchemaIds),payload:A.schema,description:i.description,examples:MWC(A.fullExamples),source:r}}).filter(A=>A!=null)}function MWC(e){if(e==null)return[];let t=[];for(let r of e){let n=b7i(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function LTf({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Jy(r,jb.IGNORE);if(i!=null&&i){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=BWC(r,e),o=SKy(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:TWC({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:o};if(n)return{type:"webhook",value:n$y({context:e,operationContext:c,source:e.source})};let d=jKy(r);if(d!=null){let l=r$y({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=PKy(r);if(s!=null){let l=ZKy({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:jPi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function BWC(e,t){let r=Jy(e,jb.SDK_METHOD_NAME),n=Jy(e,jb.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function TWC({sdkMethodName:e,operation:t,httpMethod:r,path:n,shouldUseIdiomaticRequestNames:i}){let a=[];if(e!=null){if(i&&a.push(e.methodName),e.groupName.length>0){let o=e.groupName[e.groupName.length-1];o!=null&&a.push(typeof o=="string"?o:o.name)}i||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(MA(`${r}_${n.split("/").join("_")}`));return a}function i$y(e,t,r,n){let i=[],a=o$y(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=qWC({operation:c.operation}),s=LTf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:d});s&&i.push(s)}return i}function a$y(e,t,r,n){let i=[],a=o$y(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=LTf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:!0});d&&i.push(d)}return i}function o$y(e){let t=[];return e.get!=null&&t.push({method:Kde.Get,operation:e.get}),e.post!=null&&t.push({method:Kde.Post,operation:e.post}),e.put!=null&&t.push({method:Kde.Put,operation:e.put}),e.delete!=null&&t.push({method:Kde.Delete,operation:e.delete}),e.patch!=null&&t.push({method:Kde.Patch,operation:e.patch}),e.head!=null&&t.push({method:Kde.Head,operation:e.head}),t}function qWC({operation:e}){return Jy(e,[jb.WEBHOOK])??!1}function u$y(e){let t=Jy(e,jb.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Jy(e,jb.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function s$y(e){return Jy(e,jb.FERN_BASIC_AUTH)}function l$y(e,t,r,n){if(Wg(e)){if(n==null)throw new Error(`Converting referenced security schemes requires context: ${JSON.stringify(e)}`);let i=n.resolveSecuritySchemeReference(e);return c$y(i,t,r)}return c$y(e,t,r)}function c$y(e,t,r){try{if(e.type==="apiKey"&&e.in==="header"){let n=Jy(e,Hbe.BEARER_FORMAT),i=Jy(e,jb.FERN_HEADER_AUTH);return Hde.header({headerName:e.name,prefix:n!=null?"Bearer":i?.prefix,headerVariableName:i?.name??Jy(e,jb.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let n=Jy(e,jb.FERN_BEARER_TOKEN);return Hde.bearer({tokenVariableName:n?.name??Jy(e,jb.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:n?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let n=s$y(e),i=u$y(e);return Hde.basic({usernameVariableName:n?.username?.name??i.usernameVariable,usernameEnvVar:n?.username?.env,passwordVariableName:n?.password?.name??i.passwordVariable,passwordEnvVar:n?.password?.env})}else{if(e.type==="openIdConnect")return Hde.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Hde.oauth({scopesEnum:RWC(e,t)})}}catch(n){r.logger.debug(`Error converting security scheme: ${n?.message}`)}r.logger.warn(`Skipping security scheme: ${JSON.stringify(e,null)} - not currently supported. Please reach out to Fern support team!`)}function RWC(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=h7i({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsOptional:!1,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),i=L4(n);if(i.type==="enum")return i}}function f$y(e){return Jy(e,jb.BASE_PATH)}var NWC=rl.record(rl.string(),rl.object({summary:rl.string().optional(),description:rl.string().optional()}));function d$y({document:e,context:t}){return oZo(e,jb.GROUPS,NWC,t.logger)}function p$y({context:e,document:t}){return Jy(t,jb.FERN_VERSION)??void 0}function _$y(e){let t=Jy(e,jb.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?uZo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function h$y(e){let t=Jy(e,jb.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?uZo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function y$y(e,t){let r=Jy(e,jb.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([n,i])=>{if(i.type==="string")return[n,{nameOverride:void 0,generatedName:xie([n],t),title:i.title,schema:Oq.string({default:tio(i),pattern:i.pattern,format:i.format,minLength:i.minLength,maxLength:i.maxLength}),description:i.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${n} has unsupported schema ${JSON.stringify(i)}`)}))}var FWC="webhooks";function v$y(e){return Jy(e,FWC)??{}}var _Zo=class extends oio{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o})}getDummy(){return new yfa({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discriminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discriminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function b$y(e){return Jy(e,jb.RESOLUTIONS)}function g$y({openapi:e}){let t=b$y(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=xWC({openapi:e,schemaReference:a,schemaName:n.name}),e=m$y({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(o=>[i,o]))}}return e}function xWC({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),i=e;for(let a of n){let o=i[a];if(o==null)return e;i=o}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function m$y({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let s=r.replace(i,d);return m$y({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),o=e;for(let d of a.slice(0,-1)){let s=o[d];if(s==null)return e;o=s}let c=a[a.length-1];return c==null||(o[c]={$ref:r}),e}function A$y({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=g$y({openapi:e});let a=new _Zo({document:e,taskContext:t,authHeaders:new Set,options:r,source:n,namespace:i}),o=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([ee,ne])=>{let Oe=l$y(ne,n,t,a);return Oe==null?null:[ee,Oe]}).filter(ee=>ee!==null)),c=new Set(...Object.entries(o).map(([ee,ne])=>ne.type==="basic"||ne.type==="bearer"?"Authorization":ne.type==="header"?ne.headerName:null)),d=y$y(e,r.preserveSchemaIds),s=_$y(e),u=h$y(e),l=r.audiences??[],m=[],A=[],P=new _Zo({document:e,taskContext:t,authHeaders:c,options:r,source:n,namespace:i});P.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([ee,ne])=>{if(ne==null)return;t.logger.debug(`Converting path ${ee}`);let Oe=i$y(ee,ne,e,P);for(let be of Oe){let me=O$y({operation:be});if(!(l.length>0&&!l.some(he=>me.includes(he))))switch(be.type){case"async":m.push(...be.sync),m.push(...be.async);break;case"http":m.push(...be.value);break;case"streaming":m.push(...be.streaming),be.nonStreaming&&m.push(...be.nonStreaming);break;case"webhook":A.push(...be.value);break;default:tc(be)}}}),Object.entries(v$y(e)).forEach(([ee,ne])=>{if(ne==null)return;t.logger.debug(`Converting path ${ee}`);let Oe=a$y(ee,ne,e,P);for(let be of Oe){let me=O$y({operation:be});l.length>0&&!l.some(he=>me.includes(he))||A.push(...be.value)}});let C=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([ee,ne])=>{let Oe=Jy(ne,jb.SDK_NAMESPACE);if(!Wg(ne)){let be=Jy(ne,jb.IGNORE);if(be!=null&&be)return[];if(JKy.has(ee))return[ee,ES({...ne,"x-fern-type-name":`${ee}Body`},!1,!1,P,[ee],n,Oe??i)]}return[ee,ES(ne,!1,!1,P,[ee],n,Oe??i)]}).filter(ee=>ee.length>0)),M=zWC(C,P,n),T=QWC(M,P),z={};for(let[ee,ne]of Object.entries(T)){let Oe=L4(ne);P.isSchemaExcluded(ee)||(z[ee]=Oe,t.logger.debug(`Converted schema ${ee}`))}let U=new g7i(T,P.nonRequestReferencedSchemas,P),R=A.map(ee=>{let Oe=ee.examples;if(!r.disableExamples&&Oe.length===0){let be=U.buildExample({schema:ee.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});be!=null&&(Oe=[{name:void 0,description:void 0,payload:be}])}return{...ee,payload:L4(ee.payload),examples:Oe}}),V=new Vxs(T,P,s),$=m.map(ee=>{let ne=ee.examples,Oe=ne;if(!r.disableExamples&&(ne.length===0||ne.every(fZo))){let he=V.buildEndpointExample(ee);he.length>0&&(Oe=[...he,...ne.filter(Me=>!fZo(Me))])}let be=ee.request,me=ee.response;return{...ee,request:be?.type==="json"||be?.type==="formUrlEncoded"?{...be,schema:L4(be.schema)}:be,response:me?.type==="json"?{...me,schema:L4(me.schema)}:me,queryParameters:ee.queryParameters.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,availability:he.availability,source:he.source})),pathParameters:ee.pathParameters.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,variableReference:he.variableReference,availability:he.availability,source:he.source})),headers:ee.headers.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,env:he.env,availability:he.availability,source:he.source})),examples:Oe,errors:yg(ee.errors,he=>{let Me=he.fullExamples?.map(Be=>{let Se=b7i(Be.value);if(Se!=null)return{name:Be.name,description:Be.description,example:Se}}).filter(kw);if(Me?.length===0){let Be=U.buildExample({schema:he.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Be!=null&&Me.push({name:void 0,description:void 0,example:Be})}return{generatedName:he.generatedName,nameOverride:he.nameOverride,schema:L4(he.schema),description:he.description,source:he.source,examples:Me}}),retries:ee.retries}}),re=d$y({document:e,context:P});return{apiVersion:p$y({context:P,document:e}),basePath:f$y(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(re??{}).map(([ee,ne])=>[ee,{summary:ne.summary??void 0,description:ne.description??void 0}])),servers:(e.servers??[]).map(ee=>$xs(ee,{groupMultiApiEnvironments:r.groupMultiApiEnvironments})),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(ee=>[ee.name,{id:ee.name,description:ee.description}])),orderedTagIds:e.tags?.map(ee=>ee.name)},endpoints:$,webhooks:R,channels:{},groupedSchemas:iio(i,z),securitySchemes:o,hasEndpointsMarkedInternal:$.some(ee=>ee.internal),nonRequestReferencedSchemas:P.getReferencedSchemas(),variables:d,globalHeaders:s,idempotencyHeaders:u}}function zWC(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let o={$ref:`#/components/schemas/${i}`},c=t.getReferencesFromDiscriminatedUnion(o);if(c==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(u=>!c.discriminants.has(u.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(u=>!c.discriminants.has(u.propertyKey)),source:r};n[i]=d;let s=P$y({schema:a,schemas:e});for(let u of[...new Set(s)]){let l=n[u]??e[u];l==null||l.type!=="object"||(n[u]={...l,type:"object",properties:l.properties.filter(m=>!c.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!c.discriminants.has(m.propertyKey))})}}return n}function QWC(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},o=t.getDiscriminatedUnionMetadata(a);if(o==null){r[n]=i;continue}let c=[];for(let s of i.properties)if(o.discriminants.has(s.key)){let u=o.discriminants.get(s.key);u!=null&&c.push({...s,schema:Oh.literal({nameOverride:void 0,generatedName:xie([i.generatedName,u],t.options.preserveSchemaIds),title:void 0,value:FV.string(u),namespace:void 0,groupName:void 0,description:void 0,availability:i.availability})})}else c.push(s);let d={...i,type:"object",properties:c};r[n]=d}return r}function P$y({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...P$y({schema:i,schemas:t}))}return r}function t3s(e){return[...new Set(e)]}function O$y({operation:e}){let t=[];switch(e.type){case"async":t=t3s(e.async.flatMap(r=>r.audiences));break;case"http":t=t3s(e.value.flatMap(r=>r.audiences));break;case"streaming":t=t3s(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=t3s(e.value.flatMap(r=>r.audiences));break;default:tc(e)}return t}function vfa({context:e,documents:t,options:r}){let n={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}},i=0;for(let a of t){let o=a.source!=null?a.source:gwe.openapi({file:"<memory>"});switch(a.type){case"openapi":{let c=A$y({taskContext:e,openApi:a.value,options:Oyt({options:a.settings,overrides:r}),source:o,namespace:a.namespace});n=WWC(n,c,Oyt({options:a.settings,overrides:r})),i++;break}case"asyncapi":{let c=AKy({document:a.value,taskContext:e,options:Oyt({options:a.settings,overrides:r}),source:o,asyncApiOptions:LWC({options:a.settings}),namespace:a.namespace});c.servers!=null&&(n.websocketServers=[...n.websocketServers,...c.servers.map(d=>({...d,audiences:void 0,description:void 0}))]),c.channels!=null&&(n.channels={...n.channels,...c.channels}),c.groupedSchemas!=null&&(n.groupedSchemas=r3s(n.groupedSchemas,c.groupedSchemas)),c.basePath!=null&&(n.basePath=c.basePath),i++;break}default:tc(a)}}return n}function LWC({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??UJy.naming}}function n3s(e){let t=String(e.description||e.name||e["x-fern-server-name"]||"default").trim(),r=t.toUpperCase();return r==="PRODUCTION"||r==="PRD"||r==="PROD"?"PRD":r==="SANDBOX"||r==="SBX"?"SBX":r==="STAGING"||r==="STG"?"STG":r==="PERFORMANCE"||r==="PRF"||r==="PERF"?"PRF":r==="E2E"||r==="E_2_E"?"E2E":r==="QAL"||r==="QUALITY"?"QAL":t}function UWC(e){try{let n=new URL(e).hostname.split("."),i=new Set(["api","www","service","services","example","com","org","net","io"]);for(let o of n){let c=o.split("-")[0];if(c&&!i.has(c.toLowerCase())&&c.length>2)return c.toLowerCase()}let a=n[0]?.split("-")[0];return a?a.toLowerCase():"api"}catch{let t=e.match(/https?:\/\/([^./-]+)/);return t&&t[1]?t[1].toLowerCase():"api"}}function VWC(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let r=new Map;for(let a of e){let o=n3s(a);r.set(o,a.url)}let n=!0,i=!0;for(let a of t){let o=n3s(a),c=r.get(o);c?c===a.url&&(i=!1):n=!1}return n&&i}function w$y(e){if(e.length===0||!e[0])return"api";let t=e[0].url;return UWC(t)}function WWC(e,t,r){if(!(r?.groupMultiApiEnvironments===!0))return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}};if(VWC(e.servers,t.servers)){let a=[],o=[],c=w$y(e.servers),d=w$y(t.servers),s=new Map;for(let m of e.servers){let A=n3s(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[c]={url:m.url,audiences:m.audiences})}for(let m of t.servers){let A=n3s(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[d]={url:m.url,audiences:m.audiences})}for(let[m,A]of s.entries()){let P={type:"grouped",name:m,description:`${m} environment`,urls:A};a.push(P)}let u=e.endpoints.map(m=>({...m,type:"multi-api",apiName:c,servers:[{name:c,url:void 0,audiences:void 0}]})),l=t.endpoints.map(m=>({...m,type:"multi-api",apiName:d,servers:[{name:d,url:void 0,audiences:void 0}]}));return o=[...u,...l],{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:a.map(m=>(m.type==="single",m)),websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:o.map(m=>{if(m.type==="multi-api"){let{type:C,apiName:M,servers:T,...z}=m;return{...z,__apiName:M,servers:T}}let{type:A,...P}=m;return P}),webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function r3s(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}var Riv=fa(Y4s(),1),X4s={config:new Riv.Config({apis:{},styleguide:{plugins:[ETf],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!1};function rao(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function bko(e){return e.swagger!=null}function kxf(e){return e.openapi!=null}function gko({options:e,overrides:t}={}){return{...Oyt({options:e,overrides:t}),...GXo({options:e,overrides:t})}}function J7i(e,t={}){return{...Object.fromEntries(iee(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...iee(e.importedDefinitions).reduce((r,[n,i])=>({...r,...f9o(J7i(i.definition,{defaultURL:i.url}),(a,o)=>WX(n,sw.of(o)))}),{})}}function mko(e,t={}){return{...Object.fromEntries(iee(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...iee(e.importedDefinitions).reduce((r,[n,i])=>({...r,...f9o(mko(i.definition,{defaultURL:i.url}),(a,o)=>WX(n,sw.of(o)))}),{})}}function VPi(e){return{...mko(e),...J7i(e)}}function h3e(e,t){return VPi(e.definition)[t]?.contents}function Lee(e,t){for(let[r,n]of iee(VPi(e.definition)))t(r,n.contents,{isPackageMarker:Zaa(r)===pF,defaultUrl:n.defaultUrl})}function Vfa(e,t){for(let[r,n]of iee(mko(e.definition)))t(r,n.contents)}function Iyt({breadcrumbs:e=[],title:t,subtitle:r}){let n=[];return e.length>0&&n.push(od.blue(e.join(" -> "))),n.push(t),r!=null&&n.push(od.dim(r)),n.join(`
|
|
2410
|
+
Location: ${i.join("-> ")}`),Oh.unknown({nameOverride:l,generatedName:P,title:C,description:M,availability:T,namespace:c,groupName:A,example:void 0})}}function QVC(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function y7i(e){if(e.$ref.startsWith(hfa))return e.$ref.replace(hfa,"")}function MTf(e,t,r,n){let i=Jy(e,jb.TYPE_NAME),a=xie(t,n),o=e.description,c=Awe(e),d=y7i(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return kj.reference({generatedName:a,nameOverride:i,title:void 0,schema:d,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function LVC(e){return e.oneOf==null||e.oneOf.length===0}function UVC(e){return e.allOf==null||e.allOf.length===0}function xxs(e){return e.properties==null||Q7(e.properties)===0}function Qxs(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function rio(e,t,r,n){return e.type==="reference"?Oh.reference({...e,description:t,availability:e.availability,namespace:r,groupName:n}):e.type==="optional"?Oh.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e.type==="nullable"?Oh.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e}function zxs(e){return Wg(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>zxs(t)):e.oneOf!=null?e.oneOf.every(t=>zxs(t)):e.anyOf!=null?e.anyOf.every(t=>zxs(t)):!1}function uKy({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,nameOverride:c,generatedName:d,title:s}){let u=Oh.literal({nameOverride:c,generatedName:d,title:s,value:e,namespace:n,groupName:i,description:a,availability:o});return r&&(u=Oh.nullable({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=Oh.optional({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function Ose({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,generatedName:c,nameOverride:d,title:s}){i=typeof i=="string"?[i]:i;let u=Oh.primitive({nameOverride:d,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:n,groupName:i});return r&&(u=Oh.nullable({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=Oh.optional({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function VVC({schemas:e}){let t=new Set;for(let r of e){if(Wg(r))return;if(r.enum!=null&&Qxs(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function sKy({schemas:e,context:t}){let r={};for(let n of e){let i=lKy({schema:n,context:t});for(let[a,o]of Object.entries(i)){let c=r[a];c!=null?c[o]=n:r[a]={[o]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function lKy({schema:e,context:t}){let r=Wg(e)?t.resolveSchemaReference(e):e;return WVC({schema:r,context:t})}function WVC({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=lKy({schema:n,context:t});for(let[a,o]of Object.entries(i??{}))r[a]=o}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Wg(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Qxs(a.enum)&&HVC(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let o=fKy(a,"const");a.type==="string"&&o!=null&&(r[n]=o),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function HVC(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function fKy(e,t){let r=e[t];if(r!=null)return r}function GVC({schema:e,logger:t}){let r=VJy({schema:e,logger:t});if(r!=null)return XJy(r)}var nio=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(hfa))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let n=t.$ref.substring(hfa.length).split("/"),i=this.document.components;if(i==null||i.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=n;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=i.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(Wg(d)&&(d=this.resolveSchemaReference(d)),o==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);Wg(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};var Lxs=class extends nio{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",n=this.document.components;if(n==null||n.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let i=t.$ref.substring(r.length),a=n.messages[i];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function iio(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let n={};for(let[i,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[i]=a;continue}let o=a.namespace;n[o]??={},n[o][i]=a;continue}case"oneOf":case"unknown":r[i]=a;continue;default:tc(a)}return{rootSchemas:r,namespacedSchemas:n}}function b7i(e){if(typeof e=="string")return wS.primitive(wO.string(e));if(typeof e=="number")return Number.isInteger(e)?wS.primitive(wO.int(e)):wS.primitive(wO.double(e));if(typeof e=="boolean")return wS.primitive(wO.boolean(e));if(Array.isArray(e)){let t=e.map(r=>b7i(r));return t.length===0?void 0:wS.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=b7i(n);i!=null&&t.push({key:wO.string(r),value:i})}return wS.map(t)}}function lZo(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function dKy(e){if(e!=null&&Array.isArray(e))return e}var g7i=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,n){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=n}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:o,skipReadonly:c}){switch(n.type){case"enum":return typeof r=="string"&&pKy({schema:n,value:r})?wS.enum(r):n.values[0]!=null?wS.enum(n.values[0]?.value):void 0;case"literal":return wS.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,o)&&this.exceedsMaxDepth(i,o))return wS.null({});let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d??wS.null({})}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(i,o))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:o});return wS.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(n.schema),u=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(n.schema),u}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},s={},u={},l=lZo(r),m=l?.[n.value.discriminantProperty],A=n.value.schemas[m],P=[],C=this.getDiscriminatedUnionVariantSchema(n.value,l);C!=null&&P.push(C),P.push(...Object.entries(n.value.schemas));for(let M of P)if(m!=null&&A!=null&&A.type==="object"){s=this.getAllProperties(A),u=this.getAllRequiredProperties(A),d[n.value.discriminantProperty]=wS.primitive(wO.string(m));break}else{let T=this.buildExampleHelper({exampleId:t,schema:M[1],example:void 0,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});if(T!=null){this.mergeExampleWith(T,d),d[n.value.discriminantProperty]=wS.primitive(wO.string(M[0]));break}}for(let M of n.value.commonProperties){s[M.key]={schema:M.schema,readonly:!1};let T=this.getResolvedSchema(M.schema);T.type!=="optional"&&T.type!=="nullable"&&(u[M.key]=M.schema)}for(let[M,T]of Object.entries(s)){let z=M in u;if(z&&l?.[M]!=null){let U=this.buildExampleHelper({schema:T.schema,exampleId:t,example:l[M],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[M]=U;else return}else{let U=this.buildExampleHelper({exampleId:t,schema:T.schema,example:l?.[M],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[M]=U;else if(z)return}}return wS.oneOf(n7i.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=b7i(r);if(d!=null)return wS.unknown(d)}return o.ignoreOptionals||this.exceedsMaxDepth(i,o)?void 0:o.isParameter?wS.primitive(wO.string(o.name??"string")):wS.map([{key:wO.string("key"),value:wS.primitive(wO.string("value"))}]);case"array":{let d=dKy(r),s=[];if(d!=null&&d.length>0)for(let u of d){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(n.example!=null&&n.example.length>0)for(let u of n.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return wS.array(s)}case"map":{let d=lZo(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,A]of Object.entries(d)){let P=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:o}),C=this.buildExampleHelper({exampleId:t,example:A,schema:n.value,visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});C!=null&&l.push({key:P,value:C})}return wS.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return wS.map([{key:wO.string("key"),value:wS.unknown(wS.primitive(wO.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?wS.map([{key:s,value:u}]):wS.map([])}case"object":{let d={},s=n.fullExamples?.find(A=>A.name===t)??n.fullExamples?.find(A=>A.name==null)??n.fullExamples?.[0],u=lZo(r)??(s!=null?lZo(s.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[A,P]of Object.entries(l)){if(c&&P.readonly||P.schema._visit({optional:z=>typeof z.availability=="string"&&z.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let C=A in m,M=Object.keys(u).includes(A),T=this.buildExampleHelper({schema:P.schema,exampleId:t,example:u[A],visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});if(C&&T!=null)d[A]=T;else{if(C)return;(M&&T!=null||!o.ignoreOptionals&&T!=null)&&(d[A]=T)}}if(n.additionalProperties){for(let[A,P]of Object.entries(u))if(!(A in d)){let C=this.buildExampleHelper({schema:Oh.unknown({example:P,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:P,visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});C!=null&&(d[A]=C)}}return wS.object({properties:d})}default:tc(n)}}mergeExampleWith(t,r){t._visit({array:Hc,enum:Hc,literal:Hc,map:n=>{for(let i of n){let a=i.key;a.type==="string"&&(r[a.value]=i.value)}},object:n=>{for(let[i,a]of Object.entries(n.properties))r[i]=a},oneOf:n=>{if(n.type==="discriminated")for(let[i,a]of Object.entries(n.value))r[i]=a;else this.mergeExampleWith(n.value,r)},primitive:Hc,unknown:Hc,null:Hc,_other:Hc})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return pKy({schema:t,value:r})?5:0;case"object":{if(!Zq(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,o]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(o.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!Zq(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let o of t.properties)if(this.hasExample(o.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let o=this.hasExample(a,r,n,i);return n.delete(t.schema),o}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?wO.string(t):r.example!=null?wO.string(r.example):wO.string(n.name??yP.STRING);case"base64":return t!=null&&typeof t=="string"?wO.base64(t):r.example!=null?wO.base64(r.example):wO.base64(yP.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?wO.boolean(t):r.example!=null?wO.boolean(r.example):wO.boolean(yP.BOOLEAN);case"date":return t!=null&&typeof t=="string"?wO.date(t):r.example!=null?wO.date(r.example):wO.date(yP.DATE);case"datetime":return t!=null&&typeof t=="string"?wO.datetime(t):r.example!=null?wO.datetime(r.example):wO.datetime(yP.DATE_TIME);case"double":return t!=null&&typeof t=="number"?wO.double(t):r.example!=null?wO.double(r.example):wO.double(yP.DOUBLE);case"float":return t!=null&&typeof t=="number"?wO.float(t):r.example!=null?wO.float(r.example):wO.float(yP.FLOAT);case"int":return t!=null&&typeof t=="number"?wO.int(t):r.example!=null?wO.int(r.example):wO.int(yP.INT);case"int64":return t!=null&&typeof t=="number"?wO.int64(t):r.example!=null?wO.int64(r.example):wO.int64(yP.INT64);case"uint":return t!=null&&typeof t=="number"?wO.uint(t):r.example!=null?wO.uint(r.example):wO.uint(yP.UINT);case"uint64":return t!=null&&typeof t=="number"?wO.uint64(t):r.example!=null?wO.uint64(r.example):wO.uint64(yP.UINT64);default:tc(r)}}};function pKy({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function Mqr(e){switch(e.type){case"object":return Oh.object({allOf:e.allOf,properties:e.properties.map(t=>KVC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return Oh.array({description:e.description,availability:e.availability,value:Mqr(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Oh.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return Oh.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return Oh.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Mqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return Oh.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Mqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return Oh.primitive({description:e.description,availability:e.availability,schema:_Ky(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Oh.map({description:e.description,availability:e.availability,key:Oh.primitive({description:e.key.description,availability:e.key.availability,schema:_Ky(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:Mqr(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Oh.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Oh.oneOf(JVC(e.value));case"unknown":return Oh.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:tc(e)}}function JVC(e){switch(e.type){case"discriminated":return uit.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Mqr(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,Mqr(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return uit.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>Mqr(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:tc(e)}}function _Ky(e){switch(e.type){case"string":return U0.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return U0.base64({example:void 0});case"boolean":return U0.boolean({default:e.default,example:void 0});case"date":return U0.date({example:void 0});case"datetime":return U0.datetime({example:void 0});case"double":return U0.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return U0.float({example:void 0});case"int":return U0.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return U0.int64({default:e.default,example:void 0});case"uint":return U0.uint({default:void 0,example:void 0});case"uint64":return U0.uint64({default:void 0,example:void 0});default:tc(e)}}function KVC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Mqr(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Uxs(e){return e.type!=="optional"&&e.type!=="nullable"}function TTf(e){return e==="POST"||e==="PUT"||e==="PATCH"}function fZo(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var Vxs=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,n){this.schemas=t,this.context=r,this.globalHeaders=n,this.schemas=t,this.exampleTypeFactory=new g7i(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){let r=YVC(t.request),n=XVC(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:TTf(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:A}of r.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:TTf(t.method),schema:r.schema,exampleId:m,example:A,options:{isParameter:!1,ignoreOptionals:!0}});P!=null&&i.push([m,P])}if(l&&i.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,vyt.withoutStreaming(m)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,vyt.withStreaming({sse:t.response?.type==="streamingSse",events:[m]})]))}else for(let{name:m,value:A}of n.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:A,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});P!=null&&(t.response?.type==="json"?a.push([m,vyt.withoutStreaming(P)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,vyt.withStreaming({sse:t.response?.type==="streamingSse",events:[P]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let o=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&o.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:A})}let c=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&c.push({name:l.name,value:A})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&d.push({name:l.name,value:A})}for(let l of this.globalHeaders){let m=l.schema!=null?Mqr(l.schema):Oh.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:U0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),A=this.exampleTypeFactory.buildExample({schema:m,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!Bqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),A==null)return[];A!=null&&d.push({name:l.header,value:A})}let s=[];t.request!=null&&t.response!=null?s=$VC(i,a):t.request!=null?s=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(s=a.map(([l,m])=>({id:l,request:void 0,response:m})));let u=t.examples.filter(l=>fZo(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>kw(l));return s.length===0?[yyt.full({name:void 0,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:u})]:s.map(({id:l,request:m,response:A})=>yyt.full({name:l,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:m,response:A,codeSamples:u}))}convertCodeSamples(t){return t.map(r=>"language"in r?OVr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):OVr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?Jde.Csharp:r.sdk,code:r.code})).filter(kw)}isSchemaRequired(t){return Uxs(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function $VC(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[o,c]of t)r.push({id:o??i,request:a,response:c});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[o,c]of e)r.push({id:o??i,request:c,response:a});return r}let n=new Set;for(let[i,a]of e){let o=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(o==null)continue;r.push({id:void 0,request:a,response:o});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,u]=t[d];s==null||n.has(d)||i===s&&(r.push({id:i,request:a,response:u}),s!=null&&n.add(d),c=!0)}!c&&o!=null&&r.push({id:i,request:a,response:o})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,o]=t[i],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:o})}return r}function YVC(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:ZVC(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function XVC(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function Bqr(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return Bqr(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return Bqr(e.value.value);default:return!1}case"null":return!0;default:tc(e)}}function ZVC(e){return Oh.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:Mqr(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(kw),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var aio=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new g7i(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:n,source:i,namespace:a}){let o=[];for(let c of r){let d=[];for(let l of n.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!Bqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&d.push({name:l.name,value:A})}let s=[];for(let l of n.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!Bqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&s.push({name:l.name,value:A})}let u=[];for(let l of c.messages){let m=t.getExampleMessageReference(l),A=t.resolveMessageReference({$ref:m}),P=Wg(A.payload)?t.resolveSchemaReference(A.payload):A.payload,C=this.exampleTypeFactory.buildExample({schema:ES(P,!1,!1,t,[l.messageId],i,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});C!=null&&u.push({messageType:l.type,payload:C,description:void 0})}o.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:u})}return o}buildWebsocketSessionExample({handshake:t,messages:r}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},i=[];for(let o of t.queryParameters){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!Bqr(d)&&(d=void 0),c&&d==null)return;d!=null&&i.push({name:o.name,value:d})}let a=[];for(let o of t.headers){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!Bqr(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:o.name,value:d})}for(let o of r){let c=this.exampleTypeFactory.buildExample({schema:o.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&n.messages.push({messageType:o.type,payload:c,description:void 0})}return n}isSchemaRequired(t){return Uxs(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var pIe={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Wxs(e){return Jy(e,pIe.FERN_EXAMPLES)??[]}function Hxs(e,t){return t.includes("://")?t:`${e}://${t}`}function Gxs(e){return e.startsWith("/")?e:"/"+e}function vKy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={};for(let[s,u]of Object.entries(i.components?.schemas??{})){let l=ES(u,!1,!1,e,[s],r,e.namespace);a[s]=l}let c=new aio(a,e),d={};for(let[s,u]of Object.entries(i.servers??{}))d[s]={name:s,url:Hxs(u.protocol,u.url)};for(let[s,u]of Object.entries(i.channels??{})){let l=Jy(u,pIe.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let m=[];if(u.parameters!=null)for(let[T,z]of Object.entries(u.parameters??{}))m.push({name:T,description:z.description,parameterNameOverride:void 0,schema:z.schema!=null?ES(z.schema,!1,!1,e,t,r,e.namespace):Oh.primitive({schema:U0.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:Awe(z),source:r});let A=[],P=[];if(u.bindings?.ws!=null){if(u.bindings.ws.headers!=null){let T=u.bindings.ws.headers.required??[];for(let[z,U]of Object.entries(u.bindings.ws.headers.properties??{})){if(Wg(U)){let re=e.resolveSchemaReference(U);A.push({name:z,schema:wPi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,env:void 0,availability:Awe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];A.push({name:z,schema:ES(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,env:void 0,availability:Awe(U),source:r})}}if(u.bindings.ws.query!=null){let T=u.bindings.ws.query.required??[];for(let[z,U]of Object.entries(u.bindings.ws.query.properties??{})){if(Wg(U)){let re=e.resolveSchemaReference(U);P.push({name:z,schema:wPi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,availability:Awe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];P.push({name:z,schema:ES(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,availability:Awe(U),source:r})}}}let C;u.publish!=null&&("oneOf"in u.publish.message?C=hKy({generatedName:u.publish.operationId??"PublishEvent",event:u.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):C=yKy({action:"Publish",channelPath:s,message:u.publish.message,context:e,source:r}));let M;if(u.subscribe!=null&&("oneOf"in u.subscribe.message?M=hKy({generatedName:u.subscribe.operationId??"SubscribeEvent",event:u.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):M=yKy({action:"Subscribe",channelPath:s,message:u.subscribe.message,context:e,source:r})),A.length>0||P.length>0||C!=null||M!=null){let T=Wxs(u),z=[];if(T.length>0)z=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:T,handshake:{headers:A,queryParameters:P},source:r,namespace:e.namespace});else{let $=[];C!=null&&$.push({type:"publish",payload:C}),M!=null&&$.push({type:"subscribe",payload:M});let re=c.buildWebsocketSessionExample({handshake:{headers:A,queryParameters:P},messages:$});re!=null&&z.push(re)}let U=Jy(u,pIe.FERN_CHANNEL_ADDRESS),R=U??Gxs(s),V=[];C!=null&&V.push({origin:"client",name:"publish",body:L4(C)}),M!=null&&V.push({origin:"server",name:"subscribe",body:L4(M)}),o[s]={audiences:Jy(u,jb.AUDIENCES)??[],handshake:{headers:A.map($=>({...$,schema:L4($.schema),env:$.env})),queryParameters:P.map($=>({...$,schema:L4($.schema)})),pathParameters:m.map($=>({...$,parameterNameOverride:void 0,schema:L4($.schema)}))},groupName:e.resolveGroupName([Jy(u,pIe.FERN_SDK_GROUP_NAME)??s]),messages:V,servers:(u.servers?.map($=>d[$])??Object.values(d)).filter($=>$!=null&&$.name!=null).map($=>({...$,name:$.name})),summary:Jy(u,pIe.FERN_DISPLAY_NAME),path:R,description:u.description,examples:z,source:r}}}return{groupedSchemas:iio(e.namespace,a),channels:o??void 0,servers:Object.values(d).map(s=>({...s,name:s.name})),basePath:Jy(i,pIe.BASE_PATH)}}function hKy({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:o}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let u,l={type:"notFound"};if(Wg(s)){let m=r.resolveMessageReference(s);!Wg(m.payload)&&o.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,u={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):u=m.payload}else u=s;d.push(l),c.push(u)}return v7i({description:t.description??t.message.description,availability:Awe(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsOptional:!1,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:o.naming==="v2"?d:[]})}}function yKy({action:e,channelPath:t,message:r,context:n,source:i}){if(r.payload!=null){let a=r.payload;return Wg(r.payload)&&(a=n.resolveSchemaReference(r.payload)),ES(a,!1,!1,n,[t,e],i,n.namespace)}}var Jxs=class extends nio{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(r.length),i=this.document.components.parameters[n];if(i==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in i?this.resolveParameterReference(i):i}resolveMessageReference(t){let r="#/channels/",n="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let i=this.document.components;if(!t.$ref.startsWith(n)||!i?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(n.length),o=i.messages[a];if(o==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...o}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var bKy="#/channels/",gKy="#/servers/",qTf="$message.";function OKy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={},c={},d=[],s={};for(let[P,C]of Object.entries(i.components?.schemas??{}))a[P]=ES(C,!1,!1,e,[P],r,e.namespace);for(let[P,C]of Object.entries(i.channels??{}))if(o[P]||(o[P]={}),C.messages){for(let[M,T]of Object.entries(C.messages))if(e.isReferenceObject(T)||e.isMessageWithPayload(T))if(c[M]||(c[M]=[]),e.isReferenceObject(T)){let z=e.resolveMessageReference(T);c[M].push({channelId:P,payload:z.payload})}else c[M].push({channelId:P,payload:T.payload})}for(let[P,C]of Object.entries(c))if(C.length===1){let M=C[0],T=M.channelId;o[T]=o[T]||{},o[T][P]=ES(M.payload,!1,!1,e,[P],r,e.namespace)}else{d.push(P);for(let{channelId:M,payload:T}of C){let z=`${M}_${P}`;o[M]||(o[M]={}),o[M][z]=ES(T,!1,!1,e,[z],r,e.namespace)}}let u=Object.values(o).reduce((P,C)=>({...P,...C}),{}),l=new aio(u,e),m={};for(let[P,C]of Object.entries(i.servers??{}))m[P]={name:P,url:Hxs(C.protocol,C.host)};let A={};for(let[P,C]of Object.entries(i.operations??{})){if(Jy(C,pIe.IGNORE))continue;let M=kVC(C);if(A[M]||(A[M]={subscribe:[],publish:[],__parsedMessages:[]}),C.action==="receive")A[M].subscribe.push(...C.messages);else if(C.action==="send")A[M].publish.push(...C.messages);else throw new Error(`Operation ${P} has an invalid action: ${C.action}`)}for(let[P,C]of Object.entries(A)){let M=[];M.push(...mKy({messages:C.subscribe,channelPath:P,origin:"server",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),M.push(...mKy({messages:C.publish,channelPath:P,origin:"client",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),A[P]!=null&&(A[P].__parsedMessages=M)}for(let[P,C]of Object.entries(i.channels??{})){if(Jy(C,pIe.IGNORE))continue;let M=[],T=[],z=[];if(C.parameters!=null)for(let[U,R]of Object.entries(C.parameters)){let V=e.isReferenceObject(R)?e.resolveParameterReference(R):R,{type:$,parameterKey:re}=V.location!=null?eWC(V.location):{type:C.address?.includes(`={${U}}`)?"query":"path",parameterKey:U},X=Jy(V,pIe.FERN_PARAMETER_OPTIONAL),ee=n9(MA(P))+n9(MA(U)),ne={...V,type:"string",title:ee,example:V.examples?.[0],default:V.default,enum:V.enum,required:void 0},Oe=ES(ne,!1,!1,e,[re],r,e.namespace);X&&(Oe=Oh.optional({value:Oe,description:void 0,availability:void 0,generatedName:"",title:ee,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let be={name:re,description:V.description,parameterNameOverride:void 0,schema:Oe,variableReference:void 0,availability:Awe(R),source:r};$==="header"?M.push({...be,env:void 0}):$==="path"?T.push(be):($==="payload"||$==="query")&&z.push(be)}if(M.length>0||z.length>0||A[P]!=null&&(A[P].publish!=null||A[P].subscribe!=null)){let U=Wxs(C),R=A[P]?.__parsedMessages??[],V=[];if(U.length>0)V=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:U,handshake:{headers:M,queryParameters:z},source:r,namespace:e.namespace});else{let re=[],{examplePublishMessage:X,exampleSubscribeMessage:ee}=rWC({messages:R,messageSchemas:o[P]??{}});X!=null&&re.push(X),ee!=null&&re.push(ee);let ne=l.buildWebsocketSessionExample({handshake:{headers:M,queryParameters:z},messages:re});ne!=null&&V.push(ne)}let $=Jy(C,pIe.FERN_SDK_GROUP_NAME);s[P]={audiences:Jy(C,jb.AUDIENCES)??[],handshake:{headers:M.map(re=>({...re,schema:L4(re.schema),env:re.env})),queryParameters:z.map(re=>({...re,schema:L4(re.schema)})),pathParameters:T.map(re=>({...re,parameterNameOverride:void 0,schema:L4(re.schema)}))},groupName:e.resolveGroupName(typeof $=="string"?[$]:$??[P]),messages:R,summary:Jy(C,pIe.FERN_DISPLAY_NAME),servers:(C.servers?.map(re=>tWC(m,re))??Object.values(m)).map(re=>({...re,name:re.name})),path:C.address?.split("?")[0]??Gxs(P),description:C.description,examples:V,source:r}}}return{groupedSchemas:iio(e.namespace,a),channels:s,servers:Object.values(m).map(P=>({...P,name:P.name})),basePath:Jy(i,pIe.BASE_PATH)}}function kVC(e){if(!e.channel.$ref.startsWith(bKy))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(bKy.length)}function eWC(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(qTf))throw new Error(`Invalid location format: ${e}; expected ${qTf} prefix`);let n=t.substring(qTf.length);if(n!=="header"&&n!=="path"&&n!=="payload")throw new Error(`Invalid message type: ${n}. Must be one of: header, path, payload`);return{type:n,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function tWC(e,t){if(!t.$ref.startsWith(gKy))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(gKy.length),n=e[r];if(n==null)throw new Error(`Failed to find server with name ${r}`);return n}function mKy({messages:e,channelPath:t,origin:r,messageSchemas:n,duplicatedMessageIds:i,context:a}){let o=[];return e.forEach((c,d)=>{let u=a.resolveMessageReference(c).name;i.includes(u)&&(u=`${t}_${u}`);let l=n[u];l!=null&&o.push({origin:r,name:u??`${r}Message${d+1}`,body:L4(l)})}),o}function rWC({messages:e,messageSchemas:t}){let r=e.find(o=>o.origin==="client")?.name,n=e.find(o=>o.origin==="server")?.name,i=r!=null?t[r]:void 0,a=n!=null?t[n]:void 0;return{examplePublishMessage:i!=null&&r!=null?{type:r,payload:i}:void 0,exampleSubscribeMessage:a!=null&&n!=null?{type:n,payload:a}:void 0}}function AKy({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let o=[];if(a!=null&&o.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?o.push(c.tags[0].name):i.naming!=="v2"&&o.push("websocket");let d=new Lxs({document:c,taskContext:t,options:r,namespace:a});return vKy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}else{let c=e,d=new Jxs({document:c,taskContext:t,options:r,namespace:a});return OKy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}}function PKy(e){return Jy(e,jb.ASYNC_CONFIG)}var wKy="$request.";function jKy(e){let t=Jy(e,jb.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:nWC(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function nWC(e){return e.startsWith(wKy)?e.slice(wKy.length):e}function EKy(e){let t=e;if(t.cursor!=null)return oit.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return oit.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return oit.custom({results:r.results})}throw new Error("Invalid pagination extension")}function SKy(e,t){let r=Jy(t,jb.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Jy(e,jb.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:EKy(n)}return EKy(r)}}function DKy(e){let t=iWC(e),r={};return RTf({obj:t,occurrences:r,breadcrumbs:[]}),r}function RTf({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)RTf({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)RTf({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function iWC(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?dZo(r.get):void 0,put:r?.put!=null?dZo(r.put):void 0,post:r?.post!=null?dZo(r.post):void 0,patch:r?.patch!=null?dZo(r.patch):void 0,delete:r?.delete!=null?dZo(r.delete):void 0}]))}}function dZo(e){return{...e,requestBody:e.requestBody!=null?Wg(e.requestBody)?e.requestBody:aWC(e.requestBody):void 0}}function aWC(e){let t,r;for(let n in e.content){let i=z7.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[z7.MULTIPART_FORM_DATA]:r}}:e}var Kxs=class{endpoints;parser=new hua;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let n=[];for(let i of r){let a=this.parser.tryParse(i);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${i}"; expected format "POST /users/get"`);continue}n.push(`${a.method} ${a.path}`)}return n}};var CKy="#/components/parameters/",IKy="#/components/responses/",MKy="#/components/examples/",BKy="#/components/requestBodies/",TKy="#/components/securitySchemes/",oio=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=DKy(t),this.options=i,this.source=a,this.filter=new Kxs({context:r,options:i}),this.DUMMY=this.getDummy(),this.namespace=o}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown"};if(Array.isArray(n)){let a=parseInt(i,10);if(isNaN(a)||a<0||a>=n.length)return{"x-fern-type":"unknown"};n=n[a]}else n=n[i]}return n==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(Wg(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(CKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(CKy.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(BKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(BKy.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(IKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(IKy.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(MKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(MKy.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveExampleReference(n):n}resolveSecuritySchemeReference(t){if(this.document.components==null||this.document.components.securitySchemes==null||!t.$ref.startsWith(TKy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(TKy.length),n=this.document.components.securitySchemes[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Wg(n)?this.resolveSecuritySchemeReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var yfa=class extends oio{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var oWC=rl.object({lang:rl.string(),label:rl.optional(rl.string()),source:rl.string()}),NTf=rl.array(oWC);var qKy={README_EXT:"x-readme"};function uWC(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Zq(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function RKy(e){let t=Jy(e,qKy.README_EXT);if(!Zq(t))return[];let r=t["code-samples"];if(!uWC(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function NKy(e,t,r){let i=(Jy(t,jb.EXAMPLES)??[]).filter(s=>{let u=YX.serialization.ExampleEndpointCallSchema.parse(s);return u.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),u.ok}),a=oZo(t,Hbe.REDOCLY_CODE_SAMPLES_KEBAB,NTf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...oZo(t,Hbe.REDOCLY_CODE_SAMPLES_CAMEL,NTf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&i.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=RKy(t);return d.length>0&&i.push({"code-samples":d}),i.map(yyt.unknown)}function FKy(e){let t=Jy(e,jb.AVAILABILITY);if(t==="ga"||t==="generally-available")return Gde.GenerallyAvailable;if(t==="beta"||t==="pre-release")return Gde.Beta;if(t==="deprecated")return Gde.Deprecated;if(e.deprecated)return Gde.Deprecated}function xKy(e){let t=Jy(e,jb.RETRIES);if(t!=null&&t.disabled===!0)return bNs.RetriesConfiguration.disabled(t.disabled)}function $xs(e,t){return{url:sWC({url:e.url,variables:e.variables??{}}),description:e.description,name:cWC(e,t),audiences:Jy(e,jb.AUDIENCES)}}function sWC({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,encodeURIComponent(i));return e}function cWC(e,t){let r=Jy(e,[jb.SERVER_NAME_V1,jb.SERVER_NAME_V2]);if(r!=null)return r;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox";if(t?.groupMultiApiEnvironments&&e.description!=null&&e.description.trim()!==""){let n=e.description.toLowerCase();return n==="prd"?"Production":n==="sbx"?"Sandbox":n==="staging"||n==="stg"?"Staging":n==="development"||n==="dev"?"Development":e.description}}function zKy(e){return Jy(e,jb.PARAMETER_NAME)}function QKy(e){return Jy(e,jb.SDK_VARIABLE)}function Yxs({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let o={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=Jy(c,jb.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=Wg(c)?n.resolveParameterReference(c):c,u=s.required??!1,l=Awe(s),m=[...i,s.name],A=xie(m,n.options.preserveSchemaIds),[P,C]=n.options.coerceOptionalSchemasToNullable?[!1,!u]:[!u,!1],M=s.schema!=null?ES(s.schema,P,C,n,m,a,n.namespace,!1,new Set,CVr({schema:s,logger:n.logger})):u?Oh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:U0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:CVr({schema:s,logger:n.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):Oh.optional({nameOverride:void 0,generatedName:A,title:void 0,value:Oh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:U0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:CVr({schema:s,logger:n.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!Wg(s.schema)&&s.schema.default!=null){let z=s.schema.default;typeof z=="string"&&z.length>0&&(M=Oh.literal({nameOverride:void 0,generatedName:A,title:void 0,value:FV.string(z),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let T={name:s.name,schema:M,description:s.description,parameterNameOverride:zKy(s),availability:l,source:a};s.in==="query"?o.queryParameters.push(T):s.in==="path"?o.pathParameters.push({...T,variableReference:QKy(s)}):s.in==="header"?!lWC.has(s.name.toLowerCase())&&!n.authHeaders.has(s.name)?o.headers.push({...T,env:void 0}):n.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return o}var lWC=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function LKy(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:pZo(n,t)}}}function fWC(e){return e.includes("json")||e==="*/*"}function FTf({content:e,context:t}){for(let[r,n]of Object.entries(e))if(Xxs({mediaType:r,mediaTypeObject:n,context:t})!=null)return[r,n]}function Xxs({mediaType:e,mediaTypeObject:t,context:r}){if(!fWC(e))return;let n=t.schema;return{contentType:e.includes("*")?void 0:e,schema:n??{},examples:pZo(t,r)}}function Zxs({content:e,context:t}){let r=FTf({content:e,context:t});if(!r)return;let[n,i]=r;return Xxs({mediaType:n,mediaTypeObject:i,context:t})}function UKy(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:pZo(n,t)}}}function pZo(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Jy(e,Hbe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let o=Wg(a)?t.resolveExampleReference(a):a;return{name:o.summary??i,value:o.value,description:o.description}})),r}function dWC({content:e,context:t}){for(let[r,n]of Object.entries(e))if(WKy({mediaType:r,mediaTypeObject:n,context:t}))return[r,n]}function WKy({mediaType:e,mediaTypeObject:t,context:r}){if(z7.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:pZo(t,r)}}function pWC({content:e}){for(let[t,r]of Object.entries(e))if(HKy({mediaType:t,mediaTypeObject:r}))return[t,r]}function HKy({mediaType:e,mediaTypeObject:t}){if(z7.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function GKy({mediaType:e}){return z7.parse(e)?.isBinary()??!1}function _WC({content:e}){for(let[t,r]of Object.entries(e))if(GKy({mediaType:t}))return[t,r]}function hWC(e,t){let r=Wg(e)?xTf(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Wg(i)&&i.type==="string"&&i.format==="binary")!=null}function e3s({content:e,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}){let c=_WC({content:e});if(c){let[m,A]=c;return IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}let d=pWC({content:e}),s=FTf({content:e,context:n}),u=yWC({json:s,multipart:d,document:r,visitor:{json:([m,A])=>IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),multipart:([m,A])=>IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),neither:()=>{}}});if(u)return u;let l=dWC({content:e,context:n});if(l){let[m,A]=l;return IVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}}function yWC({json:e,multipart:t,document:r,visitor:n}){if(!e&&!t)return n.neither();let[,i]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!i?.schema&&!a?.schema?n.neither():i?.schema&&a?.schema?i.schema&&hWC(i.schema,r)?n.multipart(t):n.json(e):i?.schema?n.json(e):a?.schema?n.multipart(t):n.neither()}function IVr({mediaType:e,mediaTypeObject:t,description:r,document:n,context:i,requestBreadcrumbs:a,source:o,namespace:c}){let d=vWC({mediaTypeObject:t});if(GKy({mediaType:e}))return lIe.octetStream({description:r,source:o,sdkMethodName:d,contentType:e});let s=HKy({mediaType:e,mediaTypeObject:t}),u=s?.schema,l=s?.encoding;if(u){let P=Wg(u)?xTf(u,n):{id:void 0,schema:u},C=ES(P.schema,!1,!1,i,a,o,c,!1),M=[];if(C.type==="object")for(let T of C.properties){let{isFile:z,isOptional:U,isArray:R,description:V}=kxs({schema:T.schema});if(z){let $=VKy(T.key,l);M.push({key:T.key,schema:AVr.file({isOptional:U,isArray:R,description:V}),description:V,contentType:$,exploded:!1,encoding:$==null?i.options.defaultFormParameterEncoding:void 0})}else{let $=VKy(T.key,l);M.push({key:T.key,schema:AVr.json(T.schema),description:void 0,contentType:$,exploded:l?.[T.key]?.explode,encoding:$==null?i.options.defaultFormParameterEncoding:gWC($)})}}return lIe.multipart({name:Wg(u)&&i.getNumberOfOccurrencesForRef(u)===1?P.id:void 0,description:P.schema.description,properties:M,source:o,sdkMethodName:d})}let m=Xxs({mediaType:e,mediaTypeObject:t,context:i});if(m){let P=ES(m.schema,!1,!1,i,a,o,c,!0);return lIe.json({description:void 0,schema:P,contentType:m.contentType,fullExamples:m.examples,additionalProperties:!Wg(m.schema)&&sZo(m.schema.additionalProperties,i.options),source:o,sdkMethodName:d})}let A=WKy({mediaType:e,mediaTypeObject:t,context:i});if(A!=null&&A.schema!=null){let P=ES(A.schema,!1,!1,i,a,o,c,!1);return lIe.formUrlEncoded({schema:P,description:r,contentType:A.contentType,source:o,fullExamples:A.examples,additionalProperties:!1,sdkMethodName:d})}}function vWC({mediaTypeObject:e}){return Jy(e,jb.SDK_METHOD_NAME)}var bWC={"application/json":"json"};function gWC(e){return e?bWC[e]:void 0}function xTf(e,t){if(!e.$ref.startsWith(hfa))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=y7i(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Wg(n)?xTf(n,t):{id:r,schema:n}}function kxs({schema:e,isOptional:t,isArray:r,description:n}){return OWC(e)?kxs({schema:e.value,isOptional:!0,isArray:r,description:e.description}):AWC(e)?kxs({schema:e.value,isOptional:t,isArray:r,description:e.description}):PWC(e)?kxs({schema:e.value,isOptional:t,isArray:!0,description:e.description}):mWC(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:n??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function mWC(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function OWC(e){return e.type==="optional"}function AWC(e){return e.type==="nullable"}function PWC(e){return e.type==="array"}function VKy(e,t){return t?.[e]?.contentType}var zTf={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},JKy=new Set(Object.values(zTf));var wWC=["200","201","202","204"];function $Ky({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:o}){if(t==null)return{value:void 0,errors:{}};let c=jWC({responses:t,context:r,source:o,namespace:r.namespace}),d=!1,s;for(let u of i!=null?[i]:wWC){let l=t[u];l!=null&&(d=!0,s==null&&(s=KKy({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace,statusCode:typeof u=="string"?parseInt(u):u})))}if(s==null&&!d&&t.default!=null&&(s=KKy({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:tc(s)}return{value:void 0,errors:c}}function KKy({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:o,statusCode:c}){let d=Wg(r)?n.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([m,A])=>{if(A.schema==null)return!1;let P=Wg(A.schema)?n.resolveSchemaReference(A.schema):A.schema;return P.type==="string"&&P.format==="binary"}))return n.options.useBytesForBinaryResponse&&t==null?XL.bytes({description:d.description,source:a,statusCode:c}):XL.file({description:d.description,source:a,statusCode:c});let s=LKy(d.content??{},n);if(s!=null&&t!=null)switch(t){case"json":return XL.streamingJson({statusCode:c,description:d.description,responseProperty:Jy(e.operation,jb.RESPONSE_PROPERTY),fullExamples:s.examples,schema:ES(s.schema,!1,!1,n,i,a,o),source:a});case"sse":return XL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:ES(s.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}let u=Zxs({context:n,content:d.content??{}});if(u){if(t!=null)switch(t){case"json":return XL.streamingJson({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:ES(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c});case"sse":return XL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:ES(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}return XL.json({description:d.description,schema:ES(u.schema,!1,!1,n,i,a,o),responseProperty:Jy(e.operation,jb.RESPONSE_PROPERTY),fullExamples:u.examples,source:a,statusCode:c})}for(let[l,m]of Object.entries(d.content??{})){let A=z7.parse(l);if(A!=null){if(A.isOctetStream()||A.isPDF()||A.isAudio()||A.isImage()||A.isVideo()||A.isMultiPartMixed())return XL.file({description:d.description,source:a,statusCode:c});if(A.isPlainText()){let P=m.schema;if(P==null)return XL.text({description:d.description,source:a,statusCode:c});let C=Wg(P)?n.resolveSchemaReference(P):P;return C.type==="string"&&C.format==="byte"?XL.file({description:d.description,source:a,statusCode:c}):XL.text({description:d.description,source:a,statusCode:c})}}}}function jWC({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,o]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=Wg(o)?t.resolveResponseReference(o):o,s=UKy(d.content??{},t),u=zTf[c];if(u==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[c]={statusCode:c,nameOverride:void 0,generatedName:u,description:d.description,schema:ES(s?.schema??{},!1,!1,t,[u,"Body"],r,n),fullExamples:s?.examples,source:r}}return i}function jPi({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:o,operation:c,path:d,method:s,baseBreadcrumbs:u}=e,l=Jy(c,jb.IDEMPOTENT),m=Jy(c,[jb.REQUEST_NAME_V1,jb.REQUEST_NAME_V2]),A=[...u,"Request"],P=Yxs({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:A,path:d,httpMethod:s,source:a}),C=/{([^}]+)}/g,M=[...d.matchAll(C)].map(ee=>ee[1]).filter(ee=>ee!==void 0);if(M.length>0){let ee=new Map(P.pathParameters.map(be=>[be.name,be])),ne=[],Oe=new Set;for(let be of M){let me=ee.get(be);Oe.add(be),me?ne.push(me):ne.push({name:be,variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Oh.primitive({schema:U0.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0})}for(let be of P.pathParameters)Oe.has(be.name)||ne.push(be);P.pathParameters=ne}let T=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let ee=Wg(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,ne=Object.values(ee.content).every(be=>SWC({mediaTypeObject:be})!=null),Oe=[];if(ne)return Oe.push(...Object.entries(ee.content).map(([be,me])=>{let he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:new yfa({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return YKy({context:t,convertedParameters:P})&&he!=null&&(he.type==="json"||he.type==="formUrlEncoded")&&he.schema.type!=="object"&&c.requestBody!=null?he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(he=IVr({mediaType:be,mediaTypeObject:me,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),he}).filter(be=>be!=null)),Oe.length===0?[void 0]:Oe;{let be=e3s({content:ee.content,description:ee.description,document:o,context:new yfa({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return YKy({context:t,convertedParameters:P})&&be!=null&&(be.type==="json"||be.type==="formUrlEncoded")&&be.schema.type!=="object"&&c.requestBody!=null?be=e3s({content:ee.content,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(be=e3s({content:ee.content,description:ee.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),[be]}})(),z=T.length>1,U=[...u,"Response"],R=$Ky({operationContext:e,streamFormat:i,responses:c.responses,context:t,responseBreadcrumbs:U,responseStatusCode:r,source:a}),V=xKy(c),$=FKy(c),re=NKy(e,c,t),X=Jy(c,jb.SERVER_NAME_V2);return T.map(ee=>({summary:c.summary,internal:Jy(c,Hbe.INTERNAL),idempotent:l,audiences:Jy(c,jb.AUDIENCES)??[],operationId:c.operationId!=null&&n!=null?c.operationId+"_"+n:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:DWC({operationContext:e,request:ee}),pathParameters:P.pathParameters,queryParameters:P.queryParameters,headers:P.headers,requestNameOverride:m??void 0,generatedRequestName:xie(z?EWC({breadcrumbs:A,request:ee}):A,t.options.preserveSchemaIds),request:ee,response:R.value,errors:R.errors,servers:X!=null?[{name:X,url:void 0,audiences:void 0}]:(c.servers??[]).map(ne=>$xs(ne,{groupMultiApiEnvironments:t.options.groupMultiApiEnvironments})),description:c.description,authed:IWC(c,o),security:CWC(c),availability:$,method:s,path:d,examples:re,pagination:e.pagination,source:a,retries:V}))}function EWC({breadcrumbs:e,request:t}){return t?[...e,t.type]:e}function SWC({mediaTypeObject:e}){return Jy(e,jb.SDK_METHOD_NAME)}function DWC({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function CWC(e){return e.security??[]}function IWC(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function YKy({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function ZKy({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:o}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],u=XKy({context:t,headerToIgnore:c,parameters:a}),l=XKy({context:t,headerToIgnore:c,parameters:o}),m=jPi({operationContext:{...e,pathItemParameters:u,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([P])=>parseInt(P)!==s))}},context:t,streamFormat:void 0,source:n}),A=jPi({operationContext:{...e,pathItemParameters:u,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:n});return A.forEach(P=>{P.headers.push({name:c,schema:Oh.literal({nameOverride:void 0,generatedName:xie([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:FV.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n})}),{sync:m,async:A}}function XKy({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Wg(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var QTf="stream";function r$y({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:jPi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let n=kKy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let s=y7i(n.schemaReference);s!=null&&t.excludeSchema(s)}let i=e$y({operation:e.operation,response:r.responseStream}),a=jPi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+QTf}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,QTf]},context:t,streamFormat:r.format,suffix:QTf,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(u=>t$y(u,t)!==!1)});let o=kKy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=e$y({operation:e.operation,response:r.response}),d=jPi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:o?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(u=>t$y(u,t)!==!0)}),{streaming:a,nonStreaming:d}}default:tc(r)}}function kKy({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Wg(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Zxs({content:i.content,context:e});if(a==null)return;let o=Wg(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(o.allOf==null&&o.properties==null)return;let c=o.properties?.[r.streamConditionProperty];c!=null&&Wg(c)&&(c=void 0);let d={...o,properties:{...o.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...c??{}}},title:void 0,required:[...o.required??[],r.streamConditionProperty]};return{requestBody:{content:{[z7.APPLICATION_JSON]:{schema:d}}},schemaReference:Wg(a.schema)?a.schema:void 0}}function e$y({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[z7.APPLICATION_JSON]:{schema:t}}}}}function t$y(e,t){return e._visit({unknown:r=>{let n=YX.serialization.ExampleEndpointCallSchema.parse(r);if(n.ok&&n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function n$y({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:o,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],u=Yxs({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:o,source:r});if(i.requestBody==null)return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Missing a request body`),[];let l=i.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(o!=="POST"&&o!=="GET")return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Not POST or GET`),[];let m=Wg(i.requestBody)?e.resolveRequestBodyReference(i.requestBody):i.requestBody;return Object.entries(m.content).map(([A,P])=>IVr({mediaType:A,mediaTypeObject:P,description:m.description,document:n,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(A=>A!=null).map(A=>{if(A==null||A.type!=="json"&&A.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:i.summary,audiences:Jy(i,jb.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:o,operationId:l,tags:e.resolveTagsToTagIds(i.tags),headers:u.headers,generatedPayloadName:xie(s,e.options.preserveSchemaIds),payload:A.schema,description:i.description,examples:MWC(A.fullExamples),source:r}}).filter(A=>A!=null)}function MWC(e){if(e==null)return[];let t=[];for(let r of e){let n=b7i(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function LTf({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Jy(r,jb.IGNORE);if(i!=null&&i){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=BWC(r,e),o=SKy(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:TWC({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:o};if(n)return{type:"webhook",value:n$y({context:e,operationContext:c,source:e.source})};let d=jKy(r);if(d!=null){let l=r$y({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=PKy(r);if(s!=null){let l=ZKy({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:jPi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function BWC(e,t){let r=Jy(e,jb.SDK_METHOD_NAME),n=Jy(e,jb.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function TWC({sdkMethodName:e,operation:t,httpMethod:r,path:n,shouldUseIdiomaticRequestNames:i}){let a=[];if(e!=null){if(i&&a.push(e.methodName),e.groupName.length>0){let o=e.groupName[e.groupName.length-1];o!=null&&a.push(typeof o=="string"?o:o.name)}i||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(MA(`${r}_${n.split("/").join("_")}`));return a}function i$y(e,t,r,n){let i=[],a=o$y(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=qWC({operation:c.operation}),s=LTf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:d});s&&i.push(s)}return i}function a$y(e,t,r,n){let i=[],a=o$y(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=LTf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:!0});d&&i.push(d)}return i}function o$y(e){let t=[];return e.get!=null&&t.push({method:Kde.Get,operation:e.get}),e.post!=null&&t.push({method:Kde.Post,operation:e.post}),e.put!=null&&t.push({method:Kde.Put,operation:e.put}),e.delete!=null&&t.push({method:Kde.Delete,operation:e.delete}),e.patch!=null&&t.push({method:Kde.Patch,operation:e.patch}),e.head!=null&&t.push({method:Kde.Head,operation:e.head}),t}function qWC({operation:e}){return Jy(e,[jb.WEBHOOK])??!1}function u$y(e){let t=Jy(e,jb.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Jy(e,jb.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function s$y(e){return Jy(e,jb.FERN_BASIC_AUTH)}function l$y(e,t,r,n){if(Wg(e)){if(n==null)throw new Error(`Converting referenced security schemes requires context: ${JSON.stringify(e)}`);let i=n.resolveSecuritySchemeReference(e);return c$y(i,t,r)}return c$y(e,t,r)}function c$y(e,t,r){try{if(e.type==="apiKey"&&e.in==="header"){let n=Jy(e,Hbe.BEARER_FORMAT),i=Jy(e,jb.FERN_HEADER_AUTH);return Hde.header({headerName:e.name,prefix:n!=null?"Bearer":i?.prefix,headerVariableName:i?.name??Jy(e,jb.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let n=Jy(e,jb.FERN_BEARER_TOKEN);return Hde.bearer({tokenVariableName:n?.name??Jy(e,jb.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:n?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let n=s$y(e),i=u$y(e);return Hde.basic({usernameVariableName:n?.username?.name??i.usernameVariable,usernameEnvVar:n?.username?.env,passwordVariableName:n?.password?.name??i.passwordVariable,passwordEnvVar:n?.password?.env})}else{if(e.type==="openIdConnect")return Hde.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Hde.oauth({scopesEnum:RWC(e,t)})}}catch(n){r.logger.debug(`Error converting security scheme: ${n?.message}`)}r.logger.warn(`Skipping security scheme: ${JSON.stringify(e,null)} - not currently supported. Please reach out to Fern support team!`)}function RWC(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=h7i({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsOptional:!1,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),i=L4(n);if(i.type==="enum")return i}}function f$y(e){return Jy(e,jb.BASE_PATH)}var NWC=rl.record(rl.string(),rl.object({summary:rl.string().optional(),description:rl.string().optional()}));function d$y({document:e,context:t}){return oZo(e,jb.GROUPS,NWC,t.logger)}function p$y({context:e,document:t}){return Jy(t,jb.FERN_VERSION)??void 0}function _$y(e){let t=Jy(e,jb.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?uZo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function h$y(e){let t=Jy(e,jb.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?uZo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function y$y(e,t){let r=Jy(e,jb.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([n,i])=>{if(i.type==="string")return[n,{nameOverride:void 0,generatedName:xie([n],t),title:i.title,schema:Oq.string({default:tio(i),pattern:i.pattern,format:i.format,minLength:i.minLength,maxLength:i.maxLength}),description:i.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${n} has unsupported schema ${JSON.stringify(i)}`)}))}var FWC="webhooks";function v$y(e){return Jy(e,FWC)??{}}var _Zo=class extends oio{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o})}getDummy(){return new yfa({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discriminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discriminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function b$y(e){return Jy(e,jb.RESOLUTIONS)}function g$y({openapi:e}){let t=b$y(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=xWC({openapi:e,schemaReference:a,schemaName:n.name}),e=m$y({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(o=>[i,o]))}}return e}function xWC({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),i=e;for(let a of n){let o=i[a];if(o==null)return e;i=o}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function m$y({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let s=r.replace(i,d);return m$y({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),o=e;for(let d of a.slice(0,-1)){let s=o[d];if(s==null)return e;o=s}let c=a[a.length-1];return c==null||(o[c]={$ref:r}),e}function A$y({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=g$y({openapi:e});let a=new _Zo({document:e,taskContext:t,authHeaders:new Set,options:r,source:n,namespace:i}),o=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([ee,ne])=>{let Oe=l$y(ne,n,t,a);return Oe==null?null:[ee,Oe]}).filter(ee=>ee!==null)),c=new Set(...Object.entries(o).map(([ee,ne])=>ne.type==="basic"||ne.type==="bearer"?"Authorization":ne.type==="header"?ne.headerName:null)),d=y$y(e,r.preserveSchemaIds),s=_$y(e),u=h$y(e),l=r.audiences??[],m=[],A=[],P=new _Zo({document:e,taskContext:t,authHeaders:c,options:r,source:n,namespace:i});P.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([ee,ne])=>{if(ne==null)return;let Oe=i$y(ee,ne,e,P);for(let be of Oe){let me=O$y({operation:be});if(!(l.length>0&&!l.some(he=>me.includes(he))))switch(be.type){case"async":m.push(...be.sync),m.push(...be.async);break;case"http":m.push(...be.value);break;case"streaming":m.push(...be.streaming),be.nonStreaming&&m.push(...be.nonStreaming);break;case"webhook":A.push(...be.value);break;default:tc(be)}}}),Object.entries(v$y(e)).forEach(([ee,ne])=>{if(ne==null)return;t.logger.debug(`Converting path ${ee}`);let Oe=a$y(ee,ne,e,P);for(let be of Oe){let me=O$y({operation:be});l.length>0&&!l.some(he=>me.includes(he))||A.push(...be.value)}});let C=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([ee,ne])=>{let Oe=Jy(ne,jb.SDK_NAMESPACE);if(!Wg(ne)){let be=Jy(ne,jb.IGNORE);if(be!=null&&be)return[];if(JKy.has(ee))return[ee,ES({...ne,"x-fern-type-name":`${ee}Body`},!1,!1,P,[ee],n,Oe??i)]}return[ee,ES(ne,!1,!1,P,[ee],n,Oe??i)]}).filter(ee=>ee.length>0)),M=zWC(C,P,n),T=QWC(M,P),z={};for(let[ee,ne]of Object.entries(T)){let Oe=L4(ne);P.isSchemaExcluded(ee)||(z[ee]=Oe)}let U=new g7i(T,P.nonRequestReferencedSchemas,P),R=A.map(ee=>{let Oe=ee.examples;if(!r.disableExamples&&Oe.length===0){let be=U.buildExample({schema:ee.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});be!=null&&(Oe=[{name:void 0,description:void 0,payload:be}])}return{...ee,payload:L4(ee.payload),examples:Oe}}),V=new Vxs(T,P,s),$=m.map(ee=>{let ne=ee.examples,Oe=ne;if(!r.disableExamples&&(ne.length===0||ne.every(fZo))){let he=V.buildEndpointExample(ee);he.length>0&&(Oe=[...he,...ne.filter(Me=>!fZo(Me))])}let be=ee.request,me=ee.response;return{...ee,request:be?.type==="json"||be?.type==="formUrlEncoded"?{...be,schema:L4(be.schema)}:be,response:me?.type==="json"?{...me,schema:L4(me.schema)}:me,queryParameters:ee.queryParameters.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,availability:he.availability,source:he.source})),pathParameters:ee.pathParameters.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,variableReference:he.variableReference,availability:he.availability,source:he.source})),headers:ee.headers.map(he=>({description:he.description,name:he.name,schema:L4(he.schema),parameterNameOverride:he.parameterNameOverride,env:he.env,availability:he.availability,source:he.source})),examples:Oe,errors:yg(ee.errors,he=>{let Me=he.fullExamples?.map(Be=>{let Se=b7i(Be.value);if(Se!=null)return{name:Be.name,description:Be.description,example:Se}}).filter(kw);if(Me?.length===0){let Be=U.buildExample({schema:he.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Be!=null&&Me.push({name:void 0,description:void 0,example:Be})}return{generatedName:he.generatedName,nameOverride:he.nameOverride,schema:L4(he.schema),description:he.description,source:he.source,examples:Me}}),retries:ee.retries}}),re=d$y({document:e,context:P});return{apiVersion:p$y({context:P,document:e}),basePath:f$y(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(re??{}).map(([ee,ne])=>[ee,{summary:ne.summary??void 0,description:ne.description??void 0}])),servers:(e.servers??[]).map(ee=>$xs(ee,{groupMultiApiEnvironments:r.groupMultiApiEnvironments})),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(ee=>[ee.name,{id:ee.name,description:ee.description}])),orderedTagIds:e.tags?.map(ee=>ee.name)},endpoints:$,webhooks:R,channels:{},groupedSchemas:iio(i,z),securitySchemes:o,hasEndpointsMarkedInternal:$.some(ee=>ee.internal),nonRequestReferencedSchemas:P.getReferencedSchemas(),variables:d,globalHeaders:s,idempotencyHeaders:u}}function zWC(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let o={$ref:`#/components/schemas/${i}`},c=t.getReferencesFromDiscriminatedUnion(o);if(c==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(u=>!c.discriminants.has(u.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(u=>!c.discriminants.has(u.propertyKey)),source:r};n[i]=d;let s=P$y({schema:a,schemas:e});for(let u of[...new Set(s)]){let l=n[u]??e[u];l==null||l.type!=="object"||(n[u]={...l,type:"object",properties:l.properties.filter(m=>!c.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!c.discriminants.has(m.propertyKey))})}}return n}function QWC(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},o=t.getDiscriminatedUnionMetadata(a);if(o==null){r[n]=i;continue}let c=[];for(let s of i.properties)if(o.discriminants.has(s.key)){let u=o.discriminants.get(s.key);u!=null&&c.push({...s,schema:Oh.literal({nameOverride:void 0,generatedName:xie([i.generatedName,u],t.options.preserveSchemaIds),title:void 0,value:FV.string(u),namespace:void 0,groupName:void 0,description:void 0,availability:i.availability})})}else c.push(s);let d={...i,type:"object",properties:c};r[n]=d}return r}function P$y({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...P$y({schema:i,schemas:t}))}return r}function t3s(e){return[...new Set(e)]}function O$y({operation:e}){let t=[];switch(e.type){case"async":t=t3s(e.async.flatMap(r=>r.audiences));break;case"http":t=t3s(e.value.flatMap(r=>r.audiences));break;case"streaming":t=t3s(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=t3s(e.value.flatMap(r=>r.audiences));break;default:tc(e)}return t}function vfa({context:e,documents:t,options:r}){let n={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}},i=0;for(let a of t)try{let o=a.source!=null?a.source:gwe.openapi({file:"<memory>"});switch(a.type){case"openapi":{let c=A$y({taskContext:e,openApi:a.value,options:Oyt({options:a.settings,overrides:r}),source:o,namespace:a.namespace});n=WWC(n,c,Oyt({options:a.settings,overrides:r})),i++;break}case"asyncapi":{let c=AKy({document:a.value,taskContext:e,options:Oyt({options:a.settings,overrides:r}),source:o,asyncApiOptions:LWC({options:a.settings}),namespace:a.namespace});c.servers!=null&&(n.websocketServers=[...n.websocketServers,...c.servers.map(d=>({...d,audiences:void 0,description:void 0}))]),c.channels!=null&&(n.channels={...n.channels,...c.channels}),c.groupedSchemas!=null&&(n.groupedSchemas=r3s(n.groupedSchemas,c.groupedSchemas)),c.basePath!=null&&(n.basePath=c.basePath),i++;break}default:tc(a)}}catch(o){e.logger.error(`Skipping parsing document ${a.type==="openapi"?a.value.info?.title:a.source?.file}`),o instanceof Error&&e.logger.debug(o.message,o.stack?`
|
|
2411
|
+
`+o.stack:"")}return n}function LWC({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??UJy.naming}}function n3s(e){let t=String(e.description||e.name||e["x-fern-server-name"]||"default").trim(),r=t.toUpperCase();return r==="PRODUCTION"||r==="PRD"||r==="PROD"?"PRD":r==="SANDBOX"||r==="SBX"?"SBX":r==="STAGING"||r==="STG"?"STG":r==="PERFORMANCE"||r==="PRF"||r==="PERF"?"PRF":r==="E2E"||r==="E_2_E"?"E2E":r==="QAL"||r==="QUALITY"?"QAL":t}function UWC(e){try{let n=new URL(e).hostname.split("."),i=new Set(["api","www","service","services","example","com","org","net","io"]);for(let o of n){let c=o.split("-")[0];if(c&&!i.has(c.toLowerCase())&&c.length>2)return c.toLowerCase()}let a=n[0]?.split("-")[0];return a?a.toLowerCase():"api"}catch{let t=e.match(/https?:\/\/([^./-]+)/);return t&&t[1]?t[1].toLowerCase():"api"}}function VWC(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let r=new Map;for(let a of e){let o=n3s(a);r.set(o,a.url)}let n=!0,i=!0;for(let a of t){let o=n3s(a),c=r.get(o);c?c===a.url&&(i=!1):n=!1}return n&&i}function w$y(e){if(e.length===0||!e[0])return"api";let t=e[0].url;return UWC(t)}function WWC(e,t,r){if(!(r?.groupMultiApiEnvironments===!0))return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}};if(VWC(e.servers,t.servers)){let a=[],o=[],c=w$y(e.servers),d=w$y(t.servers),s=new Map;for(let m of e.servers){let A=n3s(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[c]={url:m.url,audiences:m.audiences})}for(let m of t.servers){let A=n3s(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[d]={url:m.url,audiences:m.audiences})}for(let[m,A]of s.entries()){let P={type:"grouped",name:m,description:`${m} environment`,urls:A};a.push(P)}let u=e.endpoints.map(m=>({...m,type:"multi-api",apiName:c,servers:[{name:c,url:void 0,audiences:void 0}]})),l=t.endpoints.map(m=>({...m,type:"multi-api",apiName:d,servers:[{name:d,url:void 0,audiences:void 0}]}));return o=[...u,...l],{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:a.map(m=>(m.type==="single",m)),websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:o.map(m=>{if(m.type==="multi-api"){let{type:C,apiName:M,servers:T,...z}=m;return{...z,__apiName:M,servers:T}}let{type:A,...P}=m;return P}),webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:r3s(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function r3s(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}var Riv=fa(Y4s(),1),X4s={config:new Riv.Config({apis:{},styleguide:{plugins:[ETf],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!1};function rao(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function bko(e){return e.swagger!=null}function kxf(e){return e.openapi!=null}function gko({options:e,overrides:t}={}){return{...Oyt({options:e,overrides:t}),...GXo({options:e,overrides:t})}}function J7i(e,t={}){return{...Object.fromEntries(iee(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...iee(e.importedDefinitions).reduce((r,[n,i])=>({...r,...f9o(J7i(i.definition,{defaultURL:i.url}),(a,o)=>WX(n,sw.of(o)))}),{})}}function mko(e,t={}){return{...Object.fromEntries(iee(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...iee(e.importedDefinitions).reduce((r,[n,i])=>({...r,...f9o(mko(i.definition,{defaultURL:i.url}),(a,o)=>WX(n,sw.of(o)))}),{})}}function VPi(e){return{...mko(e),...J7i(e)}}function h3e(e,t){return VPi(e.definition)[t]?.contents}function Lee(e,t){for(let[r,n]of iee(VPi(e.definition)))t(r,n.contents,{isPackageMarker:Zaa(r)===pF,defaultUrl:n.defaultUrl})}function Vfa(e,t){for(let[r,n]of iee(mko(e.definition)))t(r,n.contents)}function Iyt({breadcrumbs:e=[],title:t,subtitle:r}){let n=[];return e.length>0&&n.push(od.blue(e.join(" -> "))),n.push(t),r!=null&&n.push(od.dim(r)),n.join(`
|
|
2411
2412
|
`)}var Niv={None:"none",Header:"header"};var m2s={};ff(m2s,{ConjureAliasDeclaration:()=>i2s,ConjureArgument:()=>v2s,ConjureArgumentWithParamType:()=>y2s,ConjureAuthDefinition:()=>oao,ConjureAuthDefinitionType:()=>_2s,ConjureDefinitions:()=>d2s,ConjureEndpointDefinition:()=>b2s,ConjureEnumDeclaration:()=>l2s,ConjureEnumVariant:()=>c2s,ConjureEnumWithDocs:()=>s2s,ConjureObjectDeclaration:()=>u2s,ConjureParamType:()=>h2s,ConjurePrimitive:()=>n2s,ConjureService:()=>g2s,ConjureServiceName:()=>r2s,ConjureType:()=>Y7i,ConjureTypeDeclaration:()=>f2s,ConjureTypeReference:()=>X7i,ConjureTypeWithDocs:()=>a2s,ConjureTypes:()=>p2s,ConjureUnionDeclaration:()=>o2s,DefinitionFile:()=>lav,WithDocs:()=>zVr,commons:()=>i3f,conjure:()=>a3f,services:()=>o3f,types:()=>u3f});var i3f={};ff(i3f,{WithDocs:()=>zVr});var V0={};ff(V0,{JsonError:()=>nao,ParseError:()=>iao,any:()=>Xiv,bigint:()=>xiv,boolean:()=>Ziv,booleanLiteral:()=>Yiv,date:()=>ziv,discriminant:()=>uav,enum_:()=>k4s,getObjectLikeUtils:()=>Lqr,getObjectUtils:()=>Wfa,getSchemaUtils:()=>m5,isProperty:()=>$7i,lazy:()=>Qiv,lazyObject:()=>Jiv,list:()=>t2s,number:()=>kiv,object:()=>e2s,objectWithoutOptionalProperties:()=>Giv,optional:()=>e3f,property:()=>Uiv,record:()=>nav,set:()=>iav,string:()=>eav,stringLiteral:()=>$iv,transform:()=>t3f,undiscriminatedUnion:()=>oav,union:()=>cav,unknown:()=>tav,withParsedProperties:()=>n3f});var wq={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function $2(e,t){return`Expected ${t}. Received ${B_I(e)}.`}function B_I(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function Zde(e){return{...e,json:Fiv(e.json),parse:Fiv(e.parse)}}function Fiv(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
2412
2413
|
`)),{ok:!0,value:t}):n}}function Z4s(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var nao=class e extends Error{errors;constructor(t){super(t.map(Z4s).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var iao=class e extends Error{errors;constructor(t){super(t.map(Z4s).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function m5(e){return{optional:()=>e3f(e),transform:t=>t3f(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new iao(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new nao(n.errors)}}}function e3f(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>wq.OPTIONAL};return{...t,...m5(t)}}function t3f(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...m5(r)}}function xiv(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$2(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:$2(t,"bigint")}]},getType:()=>wq.BIGINT};return{...Zde(e),...m5(e)}}var T_I=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function ziv(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$2(t,"string")}]}:T_I.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:$2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:$2(t,"Date object")}]},getType:()=>wq.DATE};return{...Zde(e),...m5(e)}}function Dwe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Zde(r),...m5(r)}}}function k4s(e){let t=new Set(e);return Dwe(wq.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:$2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:$2(n,"enum")}]}:{ok:!0,value:n})()}function Qiv(e){let t=r3f(e);return{...t,...m5(t)}}function r3f(e){return{parse:(t,r)=>aao(e).parse(t,r),json:(t,r)=>aao(e).json(t,r),getType:()=>aao(e).getType()}}function aao(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Oko(e){return Object.entries(e)}function Ako(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function K7i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Pko(e){return Object.keys(e)}function Liv(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function Lqr(e){return{withParsedProperties:t=>n3f(e,t)}}function n3f(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(n,i)=>{if(!K7i(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:$2(n,"object")}]};let a=new Set(Object.keys(t)),o=Ako(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(o,i)},getType:()=>e.getType()};return{...r,...m5(r),...Lqr(r)}}function Uiv(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function $7i(e){return e.isProperty}function e2s(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>$7i(n)?n.rawKey:r),_getParsedProperties:()=>Pko(e),parse:(r,n)=>{let i={},a=[];for(let[o,c]of Oko(e)){let d=$7i(c)?c.rawKey:o,s=$7i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};i[d]=u,Hiv(s)&&a.push(d)}return Viv({value:r,requiredKeys:a,getProperty:o=>{let c=i[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,o]of Oko(e)){let c=$7i(o)?o.valueSchema:o;Hiv(c)&&i.push(a)}return Viv({value:r,requiredKeys:i,getProperty:a=>{let o=e[a];if(o!=null)return $7i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>wq.OBJECT};return{...Zde(t),...m5(t),...Lqr(t),...Wfa(t)}}function Viv({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!K7i(e))return{ok:!1,errors:[{path:a,message:$2(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let m=l.transform(u);m.ok?d[l.transformedKey]=m.value:(d[s]=u,c.push(...m.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:d}:{ok:!1,errors:c}}function Wfa(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Wiv({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>Wiv({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>wq.OBJECT};return{...r,...m5(r),...Lqr(r),...Wfa(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>wq.OBJECT};return{...t,...m5(t),...Lqr(t),...Wfa(t)}}}}function Wiv({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,o]=Liv(Pko(t),s=>i.has(s)),c=r(Ako(t,o)),d=n(Ako(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function Hiv(e){return!q_I(e)}function q_I(e){switch(e.getType()){case wq.ANY:case wq.UNKNOWN:case wq.OPTIONAL:return!0;default:return!1}}function Giv(e){return e2s(e)}function Jiv(e){let t={...r3f(e),_getRawProperties:()=>aao(e)._getRawProperties(),_getParsedProperties:()=>aao(e)._getParsedProperties()};return{...t,...m5(t),...Lqr(t),...Wfa(t)}}function t2s(e){let t={parse:(r,n)=>Kiv(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>Kiv(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>wq.LIST};return{...Zde(t),...m5(t)}}function Kiv(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:$2(e,"list"),path:[]}]}}function $iv(e){return Dwe(wq.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`"${e}"`)}]})()}function Yiv(e){return Dwe(wq.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`${e.toString()}`)}]})()}var Xiv=Dwe(wq.ANY,e=>({ok:!0,value:e}));var Ziv=Dwe(wq.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"boolean")}]});var kiv=Dwe(wq.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"number")}]});var eav=Dwe(wq.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"string")}]});var tav=Dwe(wq.UNKNOWN,e=>({ok:!0,value:e}));function nav(e,t){let r={parse:(n,i)=>rav({value:n,isKeyNumeric:e.getType()===wq.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>rav({value:n,isKeyNumeric:e.getType()===wq.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>wq.RECORD};return{...Zde(r),...m5(r)}}function rav({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return K7i(e)?Oko(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let A=o.length>0?Number(o):NaN;isNaN(A)||(s=A)}let u=r(s),l=n(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),u.ok||m.push(...u.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:$2(e,"object")}]}}function iav(e){let t=t2s(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:$2(n,"Set")}]},getType:()=>wq.SET};return{...Zde(r),...m5(r)}}function oav(e){let t={parse:(r,n)=>aav((i,a)=>i.parse(r,a),e,n),json:(r,n)=>aav((i,a)=>i.json(r,a),e,n),getType:()=>wq.UNDISCRIMINATED_UNION};return{...Zde(t),...m5(t)}}function aav(e,t,r){let n=[];for(let[i,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function uav(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function cav(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=k4s(Pko(t)),a={parse:(o,c)=>sav({value:o,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>sav({value:o,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>wq.UNION};return{...Zde(a),...m5(a),...Lqr(a)}}function sav({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!K7i(e))return{ok:!1,errors:[{path:c,message:$2(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=n(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=i(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let m=o(s,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var zVr=V0.objectWithoutOptionalProperties({docs:V0.string().optional()});var a3f={};ff(a3f,{ConjureServiceName:()=>r2s,DefinitionFile:()=>lav});var r2s=V0.string();var n2s=V0.enum_(["rid","string","safelong","integer","double","boolean"]);var Y7i=V0.undiscriminatedUnion([n2s,V0.string()]);var i2s=V0.objectWithoutOptionalProperties({alias:Y7i,docs:V0.string().optional()});var a2s=V0.objectWithoutOptionalProperties({type:Y7i,docs:V0.string().optional()});var X7i=V0.undiscriminatedUnion([Y7i,a2s]);var o2s=V0.objectWithoutOptionalProperties({union:V0.record(V0.string(),X7i)});var u2s=V0.objectWithoutOptionalProperties({fields:V0.record(V0.string(),X7i)});var s2s=V0.objectWithoutOptionalProperties({value:V0.string()}).extend(zVr);var c2s=V0.undiscriminatedUnion([V0.string(),s2s]);var l2s=V0.objectWithoutOptionalProperties({values:V0.list(c2s)});var f2s=V0.undiscriminatedUnion([i2s,o2s,u2s,l2s]);var d2s=V0.objectWithoutOptionalProperties({objects:V0.record(V0.string(),f2s).optional()});var p2s=V0.objectWithoutOptionalProperties({conjureImports:V0.property("conjure-imports",V0.record(V0.string(),V0.string()).optional()),definitions:d2s.optional()});var _2s=V0.enum_(["none","header"]);var oao=V0.undiscriminatedUnion([_2s,V0.string()]);var h2s=V0.enum_(["path","query","body"]);var y2s=V0.objectWithoutOptionalProperties({paramType:V0.property("param-type",h2s),type:V0.string()}).extend(zVr);var v2s=V0.undiscriminatedUnion([V0.string(),y2s]);var b2s=V0.objectWithoutOptionalProperties({http:V0.string(),auth:oao.optional(),args:V0.record(V0.string(),v2s).optional(),returns:X7i.optional()}).extend(zVr);var g2s=V0.objectWithoutOptionalProperties({name:V0.string().optional(),package:V0.string().optional(),basePath:V0.property("base-path",V0.string().optional()),defaultAuth:V0.property("default-auth",oao.optional()),endpoints:V0.record(V0.string(),b2s).optional()}).extend(zVr);var lav=V0.objectWithoutOptionalProperties({types:p2s.optional(),services:V0.record(r2s,g2s).optional()});var o3f={};ff(o3f,{ConjureArgument:()=>v2s,ConjureArgumentWithParamType:()=>y2s,ConjureAuthDefinition:()=>oao,ConjureAuthDefinitionType:()=>_2s,ConjureEndpointDefinition:()=>b2s,ConjureParamType:()=>h2s,ConjureService:()=>g2s});var u3f={};ff(u3f,{ConjureAliasDeclaration:()=>i2s,ConjureDefinitions:()=>d2s,ConjureEnumDeclaration:()=>l2s,ConjureEnumVariant:()=>c2s,ConjureEnumWithDocs:()=>s2s,ConjureObjectDeclaration:()=>u2s,ConjurePrimitive:()=>n2s,ConjureType:()=>Y7i,ConjureTypeDeclaration:()=>f2s,ConjureTypeReference:()=>X7i,ConjureTypeWithDocs:()=>a2s,ConjureTypes:()=>p2s,ConjureUnionDeclaration:()=>o2s});var fav=require("fs/promises");async function dav(e,t){let r=[];for(let n of await OFe(e,t))r.push(await R_I({relativeFilepath:l5(e,n),absoluteFilepath:n}));return r}async function R_I({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,fav.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string
|
|
2413
|
-
`).replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:m2s.DefinitionFile.parseOrThrow(Vg.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function pav(e,t){if(N_I(e))return t.alias(e);if(F_I(e))return t.enum(e);if(x_I(e))return t.object(e);if(z_I(e))return t.union(e);tc(e)}function N_I(e){return e?.alias!=null}function F_I(e){return e?.values!=null}function x_I(e){return e?.fields!=null}function z_I(e){return e?.union!=null}var wko=class extends iZo{fernDefinitionBuilder=new dfa(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,o]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:o});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,o]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:o});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await _av(t,(a,o,c)=>{for(let[u,l]of Object.entries(c.services??{})){let m=Vts({value:u,suffix:"Service"});this.conjureFilepathToFernFilepath[o]=ys.of(`${m}/__package__.yml`);return}let s=hVo(o)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[o]=ys.of(`${s}/__package__.yml`))}),await _av(t,(a,o,c)=>{if(c.services==null||Object.keys(c.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[o];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${o}`);for(let[s,u]of Object.entries(c.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ys.of(u)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:ys.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let u=Vts({value:d,suffix:"Service"}),l=ys.of(`${u}/__package__.yml`),m={};s.basePath!=null&&(m["base-path"]=s.basePath),s.docs!=null&&(m.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(l,m),this.importAllTypes({conjureFile:c,fernFilePath:l});for(let[A,P]of Object.entries(c.types?.conjureImports??{})){let C=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ys.of(P)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:ys.of(C),alias:A})}for(let[A,P]of Object.entries(s.endpoints??{})){let C=z$l(P.http);if(C.type==="failure"){this.context?.logger.error(`Failed to parse ${P.http}. Skipping.`);continue}let T={auth:(P.auth??s.defaultAuth)!==Niv.None,path:C.path,method:C.method,response:P.returns==="binary"?"file":P.returns};P.docs!=null&&(T.docs=P.docs);let z={};if(P.args!=null)for(let U of C.pathParameters){let R=P.args[U];if(R==null)throw new Error(`Failed to find path parameter ${U} in ${P.http}`);z[U]=typeof R=="string"?R:{type:R.type}}Object.entries(z).length>0&&(T["path-parameters"]=z);for(let[U,R]of Object.entries(P.args??{}))if(z[U]==null)if(typeof R=="string")T.request?typeof T.request=="string"&&(T.request={body:T.request}):T.request={},T.request.body=R==="binary"?"bytes":R;else switch(R.paramType){case"body":T.request={body:R.type==="binary"?"bytes":R.type};break;case"query":T.request==null?T.request={"query-parameters":{[U]:R.type}}:typeof T.request!="string"&&T.request?.["query-parameters"]==null?T.request["query-parameters"]={[U]:R.type}:typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request["query-parameters"][U]=R.type)}T.request!=null&&typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request.name=`${A}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:A,schema:T,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))pav(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{union:Object.fromEntries(Object.entries(a.union).map(([o,c])=>[o,{type:typeof c=="string"?c:c.type,docs:typeof c=="string"?void 0:c.docs,key:o}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=Jl(Ug(t),ys.of(r)),a=AFe(n,i),o=this.conjureFilepathToFernFilepath[a];if(o==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return o}};async function _av(e,t){for(let r of await dav(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function hav(e,t){return yg(e,t)}var O2s=class extends Dqr{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Jl(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new ait({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new wko(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:x_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:Vg.dump(i.rootApiFile)},namedDefinitionFiles:{...hav(i.definitionFiles,a=>({absoluteFilepath:x_.of("/DUMMY_PATH"),rawContents:Vg.dump(a),contents:a})),[ys.of(pF)]:{absoluteFilepath:x_.of("/DUMMY_PATH"),rawContents:Vg.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var qsv=fa(Oav(),1);var yT;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(yT||(yT={}));function A2s(e,t){for(let[r,n]of iee(e))L_I({relativeFilepath:r,failure:n,logger:t})}function L_I({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case yT.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case yT.FILE_READ:r.error("Failed to open file: "+e);break;case yT.FILE_MISSING:r.error("Missing file: "+e);break;case yT.FILE_PARSE:t.error instanceof xVo?r.error(Iyt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case yT.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of U_I(n))r.error(Iyt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case yT.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case yT.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${zrs}: `+t.dependencyName);break;case yT.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case yT.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case yT.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Iyt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));for(let n of t.error.allErrors)n!==t.error.error&&r.debug(Iyt({title:n.message??"Unknown error",breadcrumbs:[e,...n.instancePath.split("/").filter(i=>i!=="")]}));break;default:tc(t)}}function U_I(e){switch(e.code){case my.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${od.underline(e.expected)} but received ${od.underline(e.received)}`}];case my.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${od.underline(t)}`}));case my.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>od.underline(t)).join(", ")}`}];case my.invalid_union:case my.invalid_arguments:case my.invalid_return_type:case my.invalid_date:case my.invalid_string:case my.too_small:case my.too_big:case my.invalid_intersection_types:case my.not_multiple_of:case my.custom:default:return[{title:e.message}]}}var Aav=require("fs/promises");async function Pav(e,t){let r=[];for(let n of await OFe(e,t))r.push(await V_I({relativeFilepath:l5(e,n),absoluteFilepath:n}));return r}async function V_I({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,Aav.readFile)(t)).toString()}}async function wav(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:Vg.load(i.fileContents,{schema:Vg.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:yT.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Xzf=fa(D6i(),1);var Psv=require("fs"),Mao=require("fs/promises");var wsv=require("os"),jsv=fa(require("path"),1),Esv=require("stream/promises"),Ssv=fa(C7s(),1),Dsv=fa(OCe(),1);var gvI=oAi();async function Csv({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:o}){let c,d={type:yT.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:yT.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${EvI(s)}`},async u=>{switch(s.type){case"version":c=await wvI({context:u,dependency:s,cliVersion:i,settings:a,loadAPIWorkspace:o});return;case"local":c=await PvI({context:u,dependency:s,cliVersion:i,settings:a,loadAPIWorkspace:o});return;default:tc(s)}}),c!=null?{didSucceed:!0,definition:c}:{didSucceed:!1,failure:d}}var Isv="dependencies";var mvI="metadata.json",OvI=".fern";function AvI(e){return Jl(x_.of((0,wsv.homedir)()),ys.of(OvI),ys.of(Isv),ys.of(e.organization),ys.of(e.apiName),ys.of(e.version))}async function PvI({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let o=await a.workspace.getDefinition({context:t,relativePathToDependency:ys.of(e.path)},n);return t.logger.info("Loaded..."),o}async function wvI({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=AvI(e),o=Jl(a,ys.of(Isv)),c=Jl(a,ys.of(mvI)),d;if(!await Tv(o)||!await Tv(c)){t.logger.info("Downloading manifest...");let l=await gvI.definitionRegistry.get(Xzf.FernFiddle.OrganizationId(e.organization),Xzf.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:C=>{t.failWithoutThrowing("Failed to download API manifest",C)}});return}let m=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,A=$la(r),P=$la(l.body.cliVersion);if(m!=null){if(m>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(m<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(A.major!==P.major||A.minor!==P.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${A.major}.${A.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,Mao.mkdir)(o,{recursive:!0});try{await jvI({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(C){t.failWithoutThrowing("Failed to download API",C);return}d=l.body,await(0,Mao.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,Mao.readFile)(c)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let s=await i({absolutePathToWorkspace:o,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},n)}async function jvI({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await rZ.get(e,{responseType:"stream"}),n=await Dsv.default.dir(),i=jsv.default.join(n.path,"api.tgz");await(0,Esv.pipeline)(r.data,(0,Psv.createWriteStream)(i)),await(0,Ssv.extract)({file:i,cwd:t})}function EvI(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:tc(e)}}async function Msv({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(iee(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...m}=u.contents;if(Q7(m)>0)d[s]={type:yT.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let A=Ug(s);if(JBr(t.namedDefinitionFiles).some(C=>C!==s&&C.startsWith(A)))d[s]={type:yT.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:A};else{let C=await Csv({dependencyName:typeof u.contents.export=="string"?u.contents.export:u.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});C.didSucceed?c[Ug(s)]={definition:C.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=C.failure}}}})),Q7(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var Bsv=fa(require("path"),1);var Zzf={};ff(Zzf,{additionalProperties:()=>IvI,default:()=>BvI,definitions:()=>MvI,properties:()=>DvI,required:()=>CvI,type:()=>SvI});var SvI="object",DvI={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},product:{oneOf:[{$ref:"#/definitions/products.ProductDeclarationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},CvI=["name"],IvI=!1,MvI={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.AuthScope":{type:"string"},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.TokenBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.InferredAuthenticatedRequestHeader":{type:"object",properties:{"response-property":{type:"string"},"header-name":{type:"string"},"value-prefix":{oneOf:[{type:"string"},{type:"null"}]}},required:["response-property","header-name"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchemaObject":{type:"object",properties:{endpoint:{type:"string"},"expiry-response-property":{oneOf:[{type:"string"},{type:"null"}]},"authenticated-request-headers":{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.InferredAuthenticatedRequestHeader"}},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.InferredGetTokenEndpointSchemaObject"}]},"auth.InferredBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},"get-token":{$ref:"#/definitions/auth.InferredGetTokenEndpointSchema"}},required:["scheme","get-token"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{anyOf:[{$ref:"#/definitions/auth.TokenBearerAuthSchema"},{$ref:"#/definitions/auth.InferredBearerAuthSchema"}]},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1},"products.ProductValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},versions:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"products.ProductValue":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductValueDetailed"}]},"products.ProductDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"products.ProductDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductDeclarationHeaderObjectSchema"}]},"products.ProductDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/products.ProductValue"}},header:{$ref:"#/definitions/products.ProductDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},BvI={type:SvI,properties:DvI,required:CvI,additionalProperties:IvI,definitions:MvI};var kzf={};ff(kzf,{additionalProperties:()=>RvI,default:()=>FvI,definitions:()=>NvI,properties:()=>qvI,type:()=>TvI});var TvI="object",qvI={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},RvI=!1,NvI={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/service.HttpEndpointAuth"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},FvI={type:TvI,properties:qvI,additionalProperties:RvI,definitions:NvI};var e6f={};ff(e6f,{additionalProperties:()=>QvI,default:()=>UvI,definitions:()=>LvI,properties:()=>zvI,type:()=>xvI});var xvI="object",zvI={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},QvI=!1,LvI={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/service.HttpEndpointAuth"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},UvI={type:xvI,properties:zvI,additionalProperties:QvI,definitions:LvI};function Tsv({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[o,c]of iee(e)){let d=c.contents,s=u=>{a[o]={type:yT.JSONSCHEMA_VALIDATION,error:u}};if(o===oee){let u=ZBr(d,Zzf);if(u.success){let l=YX.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(Bsv.default.basename(o)===pF){let u=ZBr(d,e6f);if(u.success){let l=YX.serialization.PackageMarkerFileSchema.parseOrThrow(d);i[o]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:c.rawContents}}else s(u)}else{let u=ZBr(d,kzf);if(u.success){let l=YX.serialization.DefinitionFileSchema.parseOrThrow(d);n[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:Jl(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[ys.of(oee)]:{type:yT.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var JVr=class extends Dqr{type="fern";context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,qsv.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,o=Jl(this.absoluteFilePath,ys.of(uie)),c=await zkl({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await Pav(o,"{yml,yaml}"),s=await wav(d);if(!s.didSucceed)return A2s(s.failures,a.logger),a.failAndThrow();let u=Tsv({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return A2s(u.failures,a.logger),a.failAndThrow();let l=await Msv({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return A2s(l.failures,a.logger),a.failAndThrow();let m={absoluteFilePath:o,rootApiFile:u.rootApiFile,namedDefinitionFiles:u.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions};r?.auth!=null&&(m={...m,rootApiFile:{...m.rootApiFile,contents:{...m.rootApiFile.contents,auth:r?.auth}}}),i=new ait({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:c,workspaceName:this.workspaceName,definition:m,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var Jdv=require("fs/promises");var Vdv=fa(Udv(),1);async function zeu(e){return(await(0,Vdv.convertObj)(e,{})).openapi}var Hdv=require("fs/promises");var Wdv=require("fs/promises");async function Xao({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:n}){let i=null;try{let a=(await(0,Wdv.readFile)(e,"utf8")).toString();try{i=JSON.parse(a)}catch{i=Vg.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return R$l({data:t,overrides:i,allowNullKeys:n})}async function n2f({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let n=(await(0,Hdv.readFile)(t)).toString(),i=await Vg.load(n);return r!=null?await Xao({absoluteFilePathToOverrides:r,context:e,data:i}):i}var Leu=fa(Y4s(),1);var Gdv=fa(Y4s(),1),i2f=fa(require("path"),1),Qeu=class extends Gdv.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let n=super.resolveExternalRef(t,r);return n.startsWith("http://")||n.startsWith("https://")||rTr(x_.of(n))?n:this.absolutePathToOpenAPIOverrides!=null?i2f.default.resolve(i2f.default.dirname(this.absolutePathToOpenAPIOverrides),r):n}};async function a2f({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){try{return(r!=null?await(0,Leu.bundle)({...X4s,doc:{source:new Leu.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Qeu(t)}):await(0,Leu.bundle)({...X4s,ref:e,externalRefResolver:new Qeu(t)})).bundle.parsed}catch(n){throw n instanceof Error?new Error(`Failed to parse OpenAPI document at ${e}: ${n.message}`):new Error(`Failed to parse OpenAPI document at ${e}: ${String(n)}`)}}var ePI=["examples","example",jb.EXAMPLES,Hbe.REDOCLY_CODE_SAMPLES_CAMEL,Hbe.REDOCLY_CODE_SAMPLES_KEBAB];async function Ueu({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let n=await a2f({absolutePathToOpenAPI:t}),i;if(r!=null?i=r:typeof n=="object"&&n[jb.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=Jl(Ug(t),ys.of(n[jb.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await Xao({absoluteFilePathToOverrides:i,context:e,data:n,allowNullKeys:ePI});return await a2f({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return n}var Gqr=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let n=[];for(let i of r)try{let a=(await(0,Jdv.readFile)(i.absoluteFilepath)).toString(),o=l5(this.absoluteFilePath,i.source.file);i.source.relativePathToDependency!=null&&(o=Jl(i.source.relativePathToDependency,o));let c=i.source.type==="protobuf"?gwe.protobuf({file:o}):gwe.openapi({file:o});if(a.includes("openapi")||a.includes("swagger"))try{let d=await Ueu({absolutePathToOpenAPI:i.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:i.absoluteFilepathToOverrides});if(kxf(d)){n.push({type:"openapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}else if(bko(d)){(!d.schemes||d.schemes.length===0)&&(d.schemes=["https"]);let s=await zeu(d);n.push({type:"openapi",value:s,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}}catch(d){t.logger.error(`Failed to parse OpenAPI document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("asyncapi"))try{let d=await n2f({context:t,absoluteFilePath:i.absoluteFilepath,absoluteFilePathToOverrides:i.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}catch(d){t.logger.error(`Failed to parse AsyncAPI document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("openrpc"))try{let d=await n2f({context:t,absoluteFilePath:i.absoluteFilepath,absoluteFilePathToOverrides:i.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}catch(d){t.logger.error(`Failed to parse OpenRPC document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}t.logger.warn(`${i.absoluteFilepath} is not a valid OpenAPI, AsyncAPI, or OpenRPC file. Skipping...`)}catch(a){t.logger.error(`Failed to read or process file ${i.absoluteFilepath}: ${a}. Skipping...`);continue}return n}};var tPI=rl.object({type:rl.string(),channelId:rl.string().optional(),messageId:rl.string(),value:rl.any()}),rPI=rl.object({summary:rl.string().optional(),description:rl.string().optional(),"query-parameters":rl.record(rl.string()).optional(),headers:rl.record(rl.string()).optional(),messages:rl.array(tPI)}),Kdv=rl.array(rPI);var F8s=class extends jC{channel;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t??[],context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=Kdv.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-examples extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data.map(n=>({summary:n.summary,description:n.description,queryParameters:n["query-parameters"],headers:n.headers,messages:n.messages.map(i=>({type:i.type,channelId:i.channelId,messageId:i.messageId,value:i.value}))}))}};var Zao=class extends oO{channel;channelPath;inlinedTypes={};websocketGroup;constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}){super({context:t,breadcrumbs:r}),this.websocketGroup=n,this.channel=i,this.channelPath=a}convertExamples({fullPath:t,baseUrl:r,asyncApiVersion:n}){let a=new F8s({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel}).convert();return a==null?{}:Object.fromEntries(a.map((o,c)=>[c.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:o.queryParameters,headers:o.headers,messages:o.messages.map(d=>({type:n==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var C8i=class extends Q4.AbstractConverters.AbstractParameterConverter{parameterNamePrefix;constructor({context:t,breadcrumbs:r,parameter:n,parameterNamePrefix:i}){super({context:t,breadcrumbs:r,parameter:n}),this.parameterNamePrefix=i}convert(){let t,r={},i=new Ube.FernOptionalExtension({breadcrumbs:this.breadcrumbs,parameter:this.parameter,context:this.context}).convert()??this.parameter.required===!1,a=this.parameter.schema??{...this.parameter,type:"string",enum:this.parameter.enum,default:this.parameter.default,example:this.parameter.example??this.parameter.name,examples:Object.values(this.parameter.examples??{}),deprecated:this.parameter.deprecated,required:void 0},c=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaIdOverride:this.parameterNamePrefix?`${this.parameterNamePrefix}_${this.parameter.name}`:this.parameter.name,schemaOrReference:a,wrapAsOptional:i}).convert();return c!=null&&(t=c.type,r=c.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var x8s=class extends jC{channel;key="x-fern-address";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t,context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var kao=class extends jC{channel;key="x-fern-display-name";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t,context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var z8s=class extends Zao{inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}){super({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a})}convert(){let t=[],r=[],n=[],a=new kao({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".");this.channel.parameters&&this.convertPathParameters({context:this.context,pathParameters:t}),this.channel.bindings?.ws!=null&&(this.convertHeaders({context:this.context,headers:n}),this.convertBindingQueryParameters({context:this.context,queryParameters:r}));let o;this.channel.subscribe!=null&&(o=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let c;this.channel.publish!=null&&(c=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];o!=null&&d.push(o),c!=null&&d.push(c);let u=new x8s({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),l=this.transformToValidPath(u??this.channelPath),m=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],A=fZ(l),P=MA(this.channelPath),C=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(P),displayName:a,baseUrl:m,path:A,auth:!1,headers:n,queryParameters:r,pathParameters:t,messages:d,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:l,baseUrl:m,asyncApiVersion:"v2"})}},audiences:C,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:n}){let i,a=n==="server"?"subscribe":"publish",o=[...this.breadcrumbs,a],c=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:o});c!=null&&(r.message=c);let d=gaa(MA(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:r.message,schemaIdOverride:d}).convert();u!=null&&u.schema!=null&&(i=u.schema,this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:o});if(s!=null){let l=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:s,schemaIdOverride:d}).convert();l!=null&&l.schema!=null&&(i=l.schema,this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes})}}if(i!=null){let s=i,u=mh.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=yde.reference({bodyType:u,docs:r.description}),m=n==="server"?"subscribe":"publish";return{type:m,displayName:m,origin:n,body:l,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description}}}convertPathParameters({context:t,pathParameters:r}){for(let[n,i]of Object.entries(this.channel.parameters??{})){let a=t.resolveMaybeReference({schemaOrReference:i,breadcrumbs:this.breadcrumbs});if(a==null)continue;let c=new C8i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:n,in:"path",description:a.description,required:a.required??!0}}).convert();c!=null&&(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type==="path"&&r.push(c.parameter))}}convertHeaders({context:t,headers:r}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[i,a]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,i]});if(o==null)continue;let d=new C8i({context:this.context,breadcrumbs:[...this.breadcrumbs,i],parameter:{name:i,in:"header",required:n.includes(i),schema:o,description:"description"in o?o.description:void 0}}).convert();d!=null&&d.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}convertBindingQueryParameters({context:t,queryParameters:r}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[i,a]of Object.entries(this.channel.bindings.ws.query.properties??{})){let o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,i]});if(o==null)continue;let d=new C8i({context:this.context,breadcrumbs:[...this.breadcrumbs,i],parameter:{name:i,in:"query",required:n.includes(i),schema:o,description:"description"in o?o.description:void 0,deprecated:o.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var eoo=class extends oO{servers;constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r}),this.servers=n}convert(){if(this.servers==null||Object.keys(this.servers).length===0)return;let t=[],r;for(let[n,i]of Object.entries(this.servers)){let a=this.buildSingleBaseUrlEnvironment(this.context,n,i);t.push(a),r==null&&(r=a.id)}return{defaultEnvironment:r,environments:mJ.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var Q8s=class extends eoo{constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r,servers:n})}buildSingleBaseUrlEnvironment(t,r,n){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(n.protocol,n.url),docs:void 0}}};var o2f="$message.",$dv="#/channels/",Ydv="#/servers/",L8s=class extends Zao{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a,operations:o}){super({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}),this.operations=o}convert(){let t=[],r=[],n=[],a=new kao({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".")??this.channelPath;this.channel.parameters&&this.convertChannelParameters({pathParameters:t,queryParameters:r,headers:n,channelPath:this.channelPath});let o=Object.entries(this.operations).reduce((m,[A,P])=>{try{this.getChannelPathFromOperation(P)===this.channelPath&&(m[A]=P)}catch{}return m},{}),c=[];for(let[m,A]of Object.entries(o))for(let P of A.messages){let C=this.context.convertReferenceToTypeReference({reference:P});if(C.ok){let M=yde.reference({bodyType:C.reference,docs:A.description});c.push({type:m,displayName:m,origin:A.action==="send"?"client":"server",body:M,availability:this.context.getAvailability({node:A,breadcrumbs:this.breadcrumbs}),docs:A.description})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),u=fZ(s),l=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:u,auth:!1,headers:n,queryParameters:r,pathParameters:t,messages:c,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:s,baseUrl:d,asyncApiVersion:"v3"})}},audiences:l,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:n,channelPath:i}){for(let a of Object.values(this.channel.parameters??{})){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(o==null)continue;let c=this.convertChannelParameterLocation(o.location);if(c==null)continue;let{type:d,parameterKey:s}=c,l=new C8i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...o,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(l!=null)switch(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type){case"path":t.push(l.parameter);break;case"query":r.push(l.parameter);break;case"header":n.push(l.parameter);break}}}convertChannelParameterLocation(t){try{let[r,n]=t.split("#/");if(r==null||n==null){this.context.errorCollector.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!r.startsWith(o2f)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${o2f} prefix`,path:this.breadcrumbs});return}let i=r.substring(o2f.length);if(i!=="header"&&i!=="path"&&i!=="payload"){this.context.errorCollector.collect({message:`Invalid message type: ${i}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return i==="payload"?{type:"query",parameterKey:n}:{type:i,parameterKey:n}}catch{this.context.errorCollector.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t){if(t==null||t.length===0||t[0]==null)return;let r=t[0];if(!r.$ref.startsWith(Ydv)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let n=r.$ref.substring(Ydv.length);if(n==null){this.context.errorCollector.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith($dv))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring($dv.length)}};var U8s=class extends eoo{constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r,servers:n})}buildSingleBaseUrlEnvironment(t,r,n){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(n.protocol,n.host),docs:void 0}}};var Veu=class extends mqr{constructor({context:t,breadcrumbs:r,audiences:n}){super({context:t,breadcrumbs:r,audiences:n})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.isAsyncAPIV3(this.context)?this.convertChannelMessages():this.convertComponentMessages(),this.convertSchemas(),this.convertServers(),this.convertChannels(),this.finalizeIr()}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}convertChannelMessages(){let t=this.context.spec;for(let[r,n]of Object.entries(t.channels??{}))for(let[i,a]of Object.entries(n.messages??{})){if(!this.context.isMessageWithPayload(a)&&!this.context.isReferenceObject(a))continue;let o=["channels",r,"messages",i],c=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:o});if(!this.context.isMessageWithPayload(c))continue;let d=this.context.resolveMaybeReference({schemaOrReference:c.payload,breadcrumbs:o});if(d==null)continue;let s=`${r}_${i}`;this.convertSchema({id:s,breadcrumbs:o,schema:d})}}convertComponentMessages(){for(let[t,r]of Object.entries(this.context.spec.components?.messages??{})){if(r.payload==null)continue;let n=["components","messages",t],i=this.context.resolveMaybeReference({schemaOrReference:r.payload,breadcrumbs:n});i!=null&&this.convertSchema({id:t,breadcrumbs:n,schema:i})}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{}))this.convertSchema({id:t,breadcrumbs:["components","schemas",t],schema:r})}convertSchema({id:t,breadcrumbs:r,schema:n}){let a=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:n}).convert();a!=null&&this.addSchemaOutputToIr(t,a)}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new U8s({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new Q8s({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}this.addEnvironmentsToIr({environmentConfig:t})}convertChannels(){for(let[t,r]of Object.entries(this.context.spec.channels??{})){let i=new Ube.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let c=this.context.spec.operations??{};a=new L8s({context:this.context,breadcrumbs:["channels",t],websocketGroup:i,channel:r,channelPath:t,operations:c}).convert()}else a=new z8s({context:this.context,breadcrumbs:["channels",t],websocketGroup:i,channel:r,channelPath:t}).convert();a!=null&&(this.addWebsocketChannelToIr({websocketChannel:a.channel,channelPath:t,audiences:a.audiences,websocketGroup:i}),this.addTypesToIr(a.inlinedTypes))}}};var Weu=class extends Tee{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a,o=t.$ref.match(/^.*\/schemas\/(.+)$/),c=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(o&&o[1])return a=o[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a});if(c&&c[2]){let s=c[1],u=c[2];return a=`${s}_${u}`,this.convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a})}else return d&&d[1]?(a=d[1],this.convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a})):{ok:!1}}convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.title:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.title??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.name:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.name??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.messageId??o.value.name:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.messageId??o.value.name??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var rpv=fa(V8s(),1);var W8s=class extends jC{document;key="x-fern-global-headers";constructor({breadcrumbs:t,document:r,context:n}){super({breadcrumbs:t,context:n}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(!Array.isArray(t)){this.context.errorCollector.collect({message:"Received unexpected non-array value for x-fern-global-headers",path:this.breadcrumbs});return}return t}}};function Xdv({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?oO.OPTIONAL_STRING:oO.STRING,env:r.env,v2Examples:r.optional?void 0:aPI({header:r,context:t}),availability:void 0,docs:void 0}))}function aPI({header:e,context:t}){let r=new ayt({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:n}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:n}}}var H8s=class extends Q4.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:n}){super({context:t,breadcrumbs:r,parameter:n})}convert(){let t,r={};if(this.parameter.schema!=null){let n=this.context.convertBreadcrumbsToName([...this.breadcrumbs,this.parameter.name]),a=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,this.parameter.name,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required,schemaIdOverride:n}).convert();a!=null&&(t=a.type,r=a.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var G8s=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{contentType;mediaType;description;required;schemaId;streamingExtension;constructor({context:t,breadcrumbs:r,contentType:n,mediaType:i,description:a,required:o,group:c,method:d,streamingExtension:s}){super({context:t,breadcrumbs:r,group:c,method:d}),this.contentType=n,this.mediaType=i,this.description=a,this.required=o,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=s}convert(){return this.streamingExtension?.type=="streamCondition"?this.convertStreamConditionRequestBody():this.convertNonStreamConditionRequestBody()}convertStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleStreamConditionJsonOrFormContent({contentType:this.contentType})}convertNonStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleJsonOrFormContent({contentType:this.contentType});if(z7.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=z7.parse(this.contentType);return t?t.isJSON()||t.isURLEncoded()||t.isPlainText()||t.isCSV()||t.isHTML()||t.isXML()||t.isDNS()||t.isApplicationText():!1}isBinaryContentType(){let t=z7.parse(this.contentType);return t?t.isBinary():!1}handleJsonOrFormContent({contentType:t}){let r=this.mediaType;if(r==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(n==null)return;let i=n.schema?.typeDeclaration.shape;return i?.type==="object"?{requestBody:F2.inlinedRequestBody({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:i.extendedProperties,extends:i.extends,properties:i.properties,extraProperties:i.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:n.inlinedTypes})}:{requestBody:F2.reference({contentType:t,docs:this.description,requestBodyType:n.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:n.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.mediaType;if(r==null||r.schema==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(n==null)return;let i=n.schema?.typeDeclaration.shape;if(i?.type==="object")return{requestBody:F2.fileUpload({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:i.properties.map(a=>{let o=r.encoding?.[a.name.wireValue];return this.convertRequestBodyProperty({property:a,contentType:t,encoding:o})}),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:n.inlinedTypes}),examples:n.examples}}handleBinaryContent({contentType:t}){let r=this.mediaType;if(r==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:F2.bytes({contentType:t,isOptional:this.required===!1,docs:this.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:n?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r,encoding:n}){let{isFile:i,isOptional:a,isArray:o}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return i?o?gie.file(oxe.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):gie.file(oxe.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):gie.bodyProperty({...t,contentType:n?.contentType??r,style:uPI({encoding:n}),name:t.name})}handleStreamConditionJsonOrFormContent({contentType:t}){if(this.streamingExtension?.type!=="streamCondition")return;let r=this.mediaType;if(r==null||r.schema==null)return;let n=this.context.resolveMaybeReference({schemaOrReference:r.schema,breadcrumbs:[...this.breadcrumbs,"content",t,"schema"]});if(n==null)return;let i=n.properties?.[this.streamingExtension.streamConditionProperty];if(i==null||this.context.isReferenceObject(i))return;let a=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:i,resolvedMediaTypeSchema:n,isStreaming:!0,contentType:t,mediaTypeObject:r}),o=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:i,resolvedMediaTypeSchema:n,isStreaming:!1,contentType:t,mediaTypeObject:r});if(!(a==null||o==null))return{requestBody:o.requestBody,streamRequestBody:a.requestBody,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:{...a.inlinedTypes,...o.inlinedTypes}})}}buildStreamConditionInlinedRequestBody({streamConditionProperty:t,resolvedMediaTypeSchema:r,isStreaming:n,contentType:i,mediaTypeObject:a}){if(this.streamingExtension==null||this.streamingExtension.type!=="streamCondition")return;let o={...r,properties:{...r.properties,[this.streamingExtension.streamConditionProperty]:{type:"boolean",const:n,...t}},required:[...r.required??[],this.streamingExtension.streamConditionProperty]},c={...a,schema:o},d=this.parseMediaTypeObject({mediaTypeObject:c,schemaId:this.schemaId,contentType:i});if(d==null)return;let s=d.schema?.typeDeclaration.shape;if(s?.type==="object")return{requestBody:F2.inlinedRequestBody({contentType:i,docs:void 0,name:this.context.casingsGenerator.generateName(n?`${this.schemaId}_streaming`:this.schemaId),extendedProperties:s.extendedProperties,extends:s.extends,properties:s.properties,extraProperties:s.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:c,exampleGenerationStrategy:"request"})}),inlinedTypes:d.inlinedTypes}}recursivelyCheckTypeReferenceIsFile({typeReference:t,isOptional:r,isArray:n}){return this.context.isList(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.list,isOptional:r,isArray:!0}):this.context.isOptional(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.optional,isOptional:!0,isArray:n}):this.context.isNullable(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.nullable,isOptional:r,isArray:n}):{isFile:this.context.isFile(t),isOptional:r??!1,isArray:n??!1}}},oPI={"application/json":"json"};function uPI({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return oPI[e.contentType]}}var sPI=/{([^}]+)}/g,cPI=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),too=class extends oO{operation;method;path;inlinedTypes={};constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a}){super({context:t,breadcrumbs:r}),this.operation=n,this.method=i,this.path=a}convertHttpMethod(){switch(this.method){case"get":return c9.Get;case"post":return c9.Post;case"put":return c9.Put;case"delete":return c9.Delete;case"patch":return c9.Patch;case"head":return c9.Head;default:return}}convertParameters({breadcrumbs:t}){let r=[],n=[],i=[];if(!this.operation.parameters)return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:n,headers:i};for(let a of this.operation.parameters){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(o==null)continue;let d=new H8s({context:this.context,breadcrumbs:t,parameter:o}).convert();if(d!=null)switch(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type){case"path":r.push(d.parameter);break;case"query":n.push(d.parameter);break;case"header":{let s=d.parameter.name.name.originalName,u=d.parameter.name.wireValue,l=!1,m=this.context.authOverrides?.["auth-schemes"];if(m!=null){for(let P of Object.values(m))if(pPI(P)&&P.header.toLowerCase()===u.toLowerCase()){l=!0;break}}let A=this.context.globalHeaderNames;if(A!=null){for(let P of A)if(P.toLowerCase()===u.toLowerCase()){l=!0;break}}!cPI.has(s.toLowerCase())&&!l&&i.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:n,headers:i}}checkMissingPathParameters(t){let n=[...this.path.matchAll(sPI)].map(i=>i[1]).filter(i=>!t.some(a=>a.name.originalName===i));for(let i of n){if(i==null)continue;let a=`${i}_example`;t.push({name:this.context.casingsGenerator.generateName(i),valueType:oO.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:i})}}})}}convertRequestBody({breadcrumbs:t,group:r,method:n,streamingExtension:i}){if(this.operation.requestBody==null)return;let a=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(a==null)return null;let o=[];for(let[c,d]of Object.entries(a.content)){let u=new G8s({context:this.context,breadcrumbs:t,contentType:c,mediaType:d,description:a.description,required:a.required,group:r??[],method:n,streamingExtension:i}).convert();u!=null&&(this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes},o.push({requestBody:u.requestBody,streamRequestBody:u.streamRequestBody,examples:u.examples}))}return o}computeGroupNameAndLocationFromExtensions(){let r=new Ube.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,i=new Ube.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.groups??[];if(r!=null)return{group:i,method:r}}evaluateMethodNameFromOperation(){let t=this.operation.operationId;return t??(this.operation.summary!=null?MA(this.operation.summary):MA(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let n=Zdv(t),i=Zdv(r);return Wue(n,i)?{method:t}:this.computeGroupAndMethodFromTokens({tag:t,tagTokens:n,methodName:r,methodNameTokens:i})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,methodName:n,methodNameTokens:i}){if(r.some((c,d)=>c!==i[d]))return{group:[t],method:n};let o=i.slice(r.length);return{group:[t],method:MA(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Q4.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:n}=r.convert();return n}};function Zdv(e){let t=lPI(e)?fPI(e):dPI(e);return t=t.map(r=>r.toLowerCase()),t=hpt(t),t}function lPI(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function fPI(e){return e.split(/(?=[A-Z])/)}function dPI(e){return e.split(/[^a-zA-Z0-9]+/)}function pPI(e){return e?.header!=null}var roo=class extends too{constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a}){super({context:t,breadcrumbs:r,operation:n,method:i,path:a})}convert(){if(this.operation.requestBody==null){this.context.errorCollector.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let t=this.convertHttpMethod();if(t==null)return;if(t!=="POST"&&t!=="GET"){this.context.errorCollector.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:r,method:n}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),i=[...this.breadcrumbs,"Payload"],{headers:a}=this.convertParameters({breadcrumbs:i}),o=this.convertRequestBody({breadcrumbs:i,group:r,method:n,streamingExtension:void 0});if(o==null)return;let c=o[0]?.requestBody;if(c==null)return;let d;if(c.type==="inlinedRequestBody")d=Abe.inlinedPayload({name:c.name,extends:c.extends,properties:c.properties});else if(c.type==="reference")d=Abe.reference({payloadType:c.requestBodyType,docs:c.docs});else return;return{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,webhook:{id:`${r?.join(".")??""}.${n}`,name:this.context.casingsGenerator.generateName(n),displayName:this.operation.summary,method:t,headers:a,payload:d,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:{autogeneratedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.autogeneratedExamples??{}),userSpecifiedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.userSpecifiedExamples??{})}},inlinedTypes:this.inlinedTypes}}getWebhookV2ExamplesFromRequestBodyV2Examples(t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,{name:r,payload:n}]))}};var c2f=fa(V8s(),1);var kdv=["get","post","put","delete","patch","head"];var J8s=class extends jC{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return t}}};var _PI=rl.object({cursor:rl.string(),next_cursor:rl.string(),results:rl.string()}),hPI=rl.object({offset:rl.string(),results:rl.string(),step:rl.string().optional(),"has-next-page":rl.string().optional()}),u2f=rl.union([rl.boolean(),_PI,hPI]);var s2f="$request.",K8s="$response.",$8s=class extends jC{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:n,context:i}){super({breadcrumbs:t,context:i}),this.operation=r,this.document=n}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=u2f.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean"){let n=this.getExtensionValue(this.document);if(n==null)return;if(typeof n=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let i=u2f.safeParse(n);if(!i.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${i.error.message}`,path:this.breadcrumbs});return}if(typeof i.data=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:i.data})}if(typeof r.data=="boolean"){this.context.errorCollector.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:r.data})}convertPaginationConfig({config:t}){let r=t;if("cursor"in r)return{type:"cursor",cursor:Tee.maybeTrimPrefix(r.cursor,s2f),nextCursor:Tee.maybeTrimPrefix(r.next_cursor,K8s),results:Tee.maybeTrimPrefix(r.results,K8s)};let n=t;return{type:"offset",offset:Tee.maybeTrimPrefix(n.offset,s2f),results:Tee.maybeTrimPrefix(n.results,K8s),step:n.step!=null?Tee.maybeTrimPrefix(n.step,s2f):void 0,hasNextPage:n["has-next-page"]!=null?Tee.maybeTrimPrefix(n["has-next-page"],K8s):void 0}}};var yPI="$request.",vPI=rl.object({"stream-condition":rl.string().optional(),format:rl.enum(["sse","json"]).optional(),"stream-description":rl.string().optional(),"response-stream":rl.any(),response:rl.any()}),bPI=rl.union([rl.boolean(),vPI]),Y8s=class extends jC{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=bPI.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-streaming extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean")return r.data?{type:"stream",format:"json"}:void 0;if(r.data["stream-condition"]==null&&r.data.format!=null)return{type:"stream",format:r.data.format};if(r.data["stream-condition"]==null){this.context.errorCollector.collect({message:"Missing stream-condition property without specified format.",path:this.breadcrumbs});return}return{type:"streamCondition",format:r.data.format??"json",streamDescription:r.data["stream-description"],streamConditionProperty:Tee.maybeTrimPrefix(r.data["stream-condition"],yPI),responseStream:r.data["response-stream"],response:r.data.response}}};var X8s=class extends jC{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return t}}};var noo={of(e){return e}};var epv={SOURCE:noo.of("source"),SDK_NAMESPACE:noo.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:noo.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:noo.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:noo.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var Z8s=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let n=t[this.key];if(n!=null)return n;if(r!=null)return t[r]}};var k8s=class extends Z8s{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var e5s=class extends jC{operation;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:n}){super({breadcrumbs:r,context:t}),this.operation=n}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).filter(i=>{let a=YX.serialization.ExampleEndpointCallSchema.parse(i);return a.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),a.ok})}};var Heu=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:n,group:i,method:a,statusCode:o,streamingExtension:c}){super({context:t,breadcrumbs:r,group:i,method:a}),this.responseBody=n,this.statusCode=o,this.streamingExtension=c}convert(){return this.shouldConvertAsStreaming()?this.convertStreamingResponseBody():this.convertNonStreamingResponseBody()}convertStreamingResponseBody(){if(this.streamingExtension!=null){if(this.streamingExtension.type=="streamCondition"){let t=this.streamingExtension.responseStream,r=this.streamingExtension.response,n=[...this.group,this.method,"Response",this.statusCode].join("_"),i=`${n}_streaming`,a=this.parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:i}),o=this.parseMediaTypeSchemaOrReference({schemaOrReference:r,schemaId:n});return this.convertStreamConditionResponse({convertedStreamingSchema:a,convertedNonStreamingSchema:o})}if(this.streamingExtension.type==="stream"){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{});for(let n of r){let i=this.responseBody.content?.[n];if(i==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:i,schemaId:t,contentType:this.streamingExtension.format});if(a!=null)return this.convertStreamingResponse({mediaTypeObject:i,convertedSchema:a})}}}}convertNonStreamingResponseBody(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(a=>a.includes("json"));for(let a of r){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null&&this.shouldReturnJsonResponse(a))return this.returnJsonResponse({mediaTypeObject:o,convertedSchema:c})}let n=Object.keys(this.responseBody.content??{}).filter(a=>!a.includes("json"));for(let a of n){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null){if(this.isBinarySchema(c))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:o}):this.returnFileDownloadResponse({mediaTypeObject:o});if(this.shouldReturnTextResponse(a))return this.returnTextResponse({mediaTypeObject:o})}}let i=parseInt(this.statusCode);if(!isNaN(i)&&i>=200&&i<300){let a={schema:{type:"object",description:"Empty response body"}},o=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:"application/json",resolveSchema:!0});if(o!=null)return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:o})}}convertStreamConditionResponse({convertedStreamingSchema:t,convertedNonStreamingSchema:r}){if(t==null||r==null)return;let n=this.responseBody.description;return this.streamingExtension?.type==="streamCondition"&&this.streamingExtension.streamDescription!=null&&(n=this.streamingExtension.streamDescription),{responseBody:oN.json(dde.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:oN.streaming(pde.json({docs:n,payload:t.type,terminator:void 0,v2Examples:t.schema?.typeDeclaration.v2Examples})),inlinedTypes:{...t.inlinedTypes,...r.inlinedTypes}}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:oN.streaming(pde.json({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};case"sse":return{responseBody:oN.streaming(pde.sse({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:oN.json(dde.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:oN.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:oN.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnTextResponse({mediaTypeObject:t}){return{responseBody:oN.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}shouldConvertAsStreaming(){return this.streamingExtension!=null}shouldReturnJsonResponse(t){return t.includes("json")}shouldReturnBytesResponse(){return this.context.settings.useBytesForBinaryResponse&&this.streamingExtension==null}shouldReturnTextResponse(t){return z7.parse(t)?.isText()??!1}};var t5s=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;constructor({context:t,breadcrumbs:r,responseError:n,group:i,method:a,methodName:o,statusCode:c}){super({context:t,breadcrumbs:r,group:i,method:a}),this.responseError=n,this.statusCode=c,this.methodName=o}convert(){if(!this.responseError.content){let n=pXo[this.statusCode];if(n==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}let i=this.getErrorIdFromErrorName(n);return{error:{error:{name:this.context.casingsGenerator.generateName(i),fernFilepath:{allParts:[],packagePath:[],file:void 0},errorId:i},docs:this.responseError.description},errorType:mh.unknown(),displayName:n,statusCode:this.statusCode,inlinedTypes:{},examples:{}}}let t=Object.keys(this.responseError.content).filter(n=>n.includes("json")),r=pXo[this.statusCode];if(r==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}for(let n of[...t]){let i=this.responseError.content?.[n];if(i==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:i,schemaId:tpv(`${this.methodName}Request${r}`),contentType:n});if(a==null)continue;let o=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.type.fernFilepath,convertedSchema:a})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:n,convertedSchema:i}){return{error:{error:{name:this.context.casingsGenerator.generateName(r),fernFilepath:n,errorId:r},docs:this.responseError.description},errorType:i.type,displayName:t,statusCode:this.statusCode,inlinedTypes:i.inlinedTypes,examples:i.examples}}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?tpv(`${this.methodName}Request${t}`):t}};function tpv(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var r5s=class e extends too{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a,idempotent:o,idToAuthScheme:c,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:n,method:i,path:a}),this.idempotent=o,this.idToAuthScheme=c,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:n}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),i=this.getGroupDisplayName(r),{headers:a,pathParameters:o,queryParameters:c}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),d=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:n,streamingExtension:this.streamingExtension}),s=d?.[0]?.requestBody,u=d?.[0]?.streamRequestBody,l={requestBodies:d?.map(be=>be.requestBody)},m=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:n,streamingExtension:this.streamingExtension}),A=m?.response,P=m?.streamResponse,C=m!=null?m.errors:[],M={},T=C.map(be=>be.error),z=fZ(this.path),U=this.getEndpointBaseUrl(),R=this.getEndpointBaseUrls(),V=this.convertExamples({httpPath:z,httpMethod:t,baseUrl:U}),$=new Set(this.operation.security?.flatMap(be=>Object.keys(be))??[]),re=this.authSchemeToHeaders(Array.from($));re.length>0&&a.push(...re);for(let be of C){let me=be.error,he=be.errorType,Me=me.error.errorId,Be=be.examples;M[Me]={name:me.error,displayName:be.displayName,discriminantValue:{name:me.error.name,wireValue:Me},type:he,statusCode:be.statusCode,docs:me.docs,examples:[],v2Examples:{userSpecifiedExamples:Be??{},autogeneratedExamples:{}}}}let X=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],ee={displayName:this.operation.summary,method:t,baseUrl:U,v2BaseUrls:R,path:z,pathParameters:o,queryParameters:c,headers:a.filter((be,me,he)=>me===he.findIndex(Me=>Me.name.wireValue===be.name.wireValue)),sdkRequest:void 0,errors:T,auth:this.operation.security!=null||this.context.spec.security!=null,security:this.operation.security??this.context.spec.security,availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:z,allPathParameters:o,pagination:void 0,transport:void 0,source:RPe.openapi(),audiences:X,retries:void 0},ne=this.context.namespace!=null?[this.context.namespace]:[],Oe=r?.map(be=>MA(be));return ne.push(...Oe??[]),{audiences:X,group:r,groupDisplayName:i,errors:M,endpoint:{...ee,id:`endpoint_${ne.join("/")}.${n}`,name:this.context.casingsGenerator.generateName(n),requestBody:s,v2RequestBodies:l,response:A,docs:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:V.examples},v2Responses:{responses:m?.v2Responses}},streamEndpoint:P!=null&&P.body!=null?{...ee,id:`endpoint_${ne.join("/")}.${n}_stream`,name:this.context.casingsGenerator.generateName(`${n}_stream`),requestBody:u,v2RequestBodies:void 0,response:P,docs:this.streamingExtension?.type==="streamCondition"?this.streamingExtension.streamDescription??this.operation.description:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:V.streamExamples},v2Responses:{responses:[{statusCode:200,body:P.body}]}}:void 0,inlinedTypes:this.inlinedTypes,servers:this.filterOutTopLevelServers(this.operation.servers??[])}}convertResponseBody({breadcrumbs:t,group:r,method:n,streamingExtension:i}){if(this.operation.responses==null)return;let a,o=!1;for(let[c,d]of Object.entries(this.operation.responses)){let s=parseInt(c);if(!(isNaN(s)||s<200||s>=300&&s<400)){if(a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{}}),s>=200&&s<300){let u=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(u==null)continue;let m=new Heu({context:this.context,breadcrumbs:[...t,c],responseBody:u,group:r??[],method:n,statusCode:c,streamingExtension:i}).convert();m!=null&&(this.inlinedTypes={...this.inlinedTypes,...m.inlinedTypes},o||(o=!0,a.response={statusCode:s,body:m.responseBody},a.streamResponse={statusCode:s,body:m.streamResponseBody}),a.v2Responses=[...a.v2Responses??[],{statusCode:s,body:m.responseBody}])}if(s>=400&&s<600){let u=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(u==null)continue;let m=new t5s({context:this.context,breadcrumbs:[...t,c],responseError:u,group:r??[],method:n,methodName:this.evaluateMethodNameFromOperation(),statusCode:s}).convert();m!=null&&(this.inlinedTypes={...this.inlinedTypes,...m.inlinedTypes},a.errors.push(m))}}}if(this.streamingExtension!=null){a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{}});let d=new Heu({context:this.context,breadcrumbs:[...t,"stream"],responseBody:{description:""},group:r??[],method:n,statusCode:"stream",streamingExtension:i}).convert();d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},a.response={statusCode:200,body:d.responseBody},a.streamResponse={statusCode:200,body:d.streamResponseBody},a.v2Responses=[{statusCode:200,body:d.responseBody}])}return a}authSchemeToHeaders(t){let r=[];for(let n of t){let i=this.idToAuthScheme?.[n];if(i==null)continue;let a={valueType:oO.STRING,availability:void 0,docs:void 0,env:void 0,v2Examples:void 0};switch(i.type){case"bearer":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"basic":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"header":r.push({name:i.name,...a});break}}return r}convertExamples({httpPath:t,httpMethod:r,baseUrl:n}){let a=new e5s({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation}).convert();return a==null?{examples:{},streamExamples:{}}:this.streamingExtension?.type==="streamCondition"?this.convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}):{examples:this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}),streamExamples:{}}}convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:i}){let a=i.filter(s=>!(s.response!=null&&"stream"in s.response)),o=i.filter(s=>s.response!=null&&"stream"in s.response),c=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}),d=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:o});return{examples:c,streamExamples:d}}convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:i}){return Object.fromEntries(i.map((a,o)=>[this.getExampleName({example:a,exampleIndex:o}),{displayName:void 0,request:a.request!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,a["path-parameters"]??{})},baseUrl:void 0,environment:n,auth:void 0,pathParameters:a["path-parameters"]??{},queryParameters:a["query-parameters"]??{},headers:a.headers??{},requestBody:a.request}:void 0,response:a.response!=null?{docs:void 0,statusCode:void 0,body:this.getExampleResponseBody({example:a})}:void 0,codeSamples:a["code-samples"]?.map(c=>{let d=("language"in c?c.language:c.sdk)??void 0;return{name:c.name,docs:void 0,language:d,code:c.code}})}]))}getExampleName({example:t,exampleIndex:r}){return t.name??t["code-samples"]?.[0]?.name??`Example_${r}`}getExampleResponseBody({example:t}){if(t.response!=null){if("stream"in t.response)return Jd.V2HttpEndpointResponseBody.stream(t.response.stream);if("body"in t.response)return Jd.V2HttpEndpointResponseBody.json(t.response.body)}}getEndpointBaseUrl(){let r=new k8s({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert();if(r!=null)return this.context.logger.debug(`[getEndpointBaseUrl] Endpoint ${this.method.toUpperCase()} ${this.path} specifies a server with "${epv.SERVER_NAME_V2}" extension. Returning server type: ${r}`),r;let n=this.operation.servers?.[0];if(n==null)return;let a=this.topLevelServers?.find(o=>o.url===n.url)??n;return Ynt.getServerName({server:a,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(n=>{let a=this.topLevelServers?.find(o=>o.url===n.url)??n;return Ynt.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(n=>`${r[n.pathParameter]?.toString()??n.pathParameter}${n.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(n=>n.url===r.url))}getGroupDisplayName(t){let r=this.operation.tags?.[0];r!=null&&(r=this.context.getDisplayNameForTag(r));let n=t?.[t.length-1];if(n!=null&&r!=null)return r.toLowerCase().replaceAll(" ","")===n?r:void 0}};var n5s=class extends oO{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:n,path:i,idToAuthScheme:a,topLevelServers:o}){super({context:t,breadcrumbs:r}),this.pathItem=n,this.path=i,this.idToAuthScheme=a,this.topLevelServers=o}convert(){let t=[],r=[],n={};for(let i of kdv){let a=this.pathItem[i];if(a==null)continue;let o=[...this.breadcrumbs,i],c=this.tryParseAsWebhook({operationBreadcrumbs:o,operation:a,method:i,context:this.context});if(c!=null){r.push(c),Object.assign(n,c.inlinedTypes);continue}let s=new Y8s({breadcrumbs:o,operation:a,context:this.context}).convert(),u=this.tryParseAsHttpEndpoint({operationBreadcrumbs:o,operation:a,method:i,streamingExtension:s});u!=null&&(t.push(u),Object.assign(n,u.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:n}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:n,context:i}){return new X8s({breadcrumbs:n,operation:t,context:i}).convert()?new roo({context:this.context,breadcrumbs:n,operation:t,method:c2f.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:n,streamingExtension:i}){new $8s({breadcrumbs:n,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new J8s({breadcrumbs:n,operation:t,context:this.context}).convert();return new r5s({context:this.context,breadcrumbs:n,operation:t,method:c2f.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:i}).convert()}};var i5s=class extends oO{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:n,schemeId:i}){super({context:t,breadcrumbs:r}),this.securityScheme=n,this.schemeId=i}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return N2.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return N2.basic({key:this.schemeId,username:this.context.casingsGenerator.generateName("username"),password:this.context.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return N2.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName("apiKey"),wireValue:this.securityScheme.name},valueType:oO.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return N2.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var Geu=class extends mqr{constructor({breadcrumbs:t,context:r,audiences:n}){super({breadcrumbs:t,context:r,audiences:n})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.convertSecuritySchemes(),this.convertGlobalHeaders(),this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:t,errors:r}=this.convertPaths();this.addErrorsToIr(r);let{defaultUrl:n}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(n),this.finalizeIr()}convertGlobalHeaders(){this.context.globalHeaderOverrides;let r=new W8s({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let n=Xdv({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(n),this.context.setGlobalHeaders(n)}}convertSecuritySchemes(){if(this.context.authOverrides){this.addAuthToIR(qIf({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator}));return}let t=[];for(let[r,n]of Object.entries(this.context.spec.components?.securitySchemes??{})){let i=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:["components","securitySchemes",r]});if(i==null)continue;let o=new i5s({context:this.context,breadcrumbs:["components","securitySchemes",r],securityScheme:i,schemeId:r}).convert();o!=null&&t.push(o)}t.length>0&&this.addAuthToIR({requirement:t.length===1?"ALL":"ANY",schemes:t,docs:void 0})}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let i=sXo({rawApiFileSchema:this.context.environmentOverrides,casingsGenerator:this.context.casingsGenerator});return i!=null&&this.addEnvironmentsToIr({environmentConfig:i.environmentsConfig,audiences:i.audiences}),{defaultUrl:this.context.environmentOverrides["default-url"]}}let n=new Ynt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:n?.value}),{defaultUrl:n?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let i=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();i!=null&&this.addSchemaOutputToIr(t,i)}}convertWebhooks(){for(let[,t]of Object.entries(this.context.spec.webhooks??{})){if(t==null){this.context.errorCollector.collect({message:"Skipping empty webhook",path:this.breadcrumbs});continue}if(!("post"in t)){this.context.errorCollector.collect({message:"Skipping webhook as it is not a POST method",path:this.breadcrumbs});continue}if(t.post?.operationId==null){this.context.errorCollector.collect({message:"Skipping webhook as no operationId is present",path:this.breadcrumbs});continue}let r=t.post.operationId,i=new roo({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:rpv.OpenAPIV3.HttpMethods.POST,path:r}).convert();i!=null&&(this.addWebhookToIr({webhook:i.webhook,operationId:r,audiences:i.audiences,group:i.group}),this.addTypesToIr(i.inlinedTypes))}}convertPaths(){let t=[],r={};for(let[n,i]of Object.entries(this.context.spec.paths??{})){if(i==null)continue;let o=new n5s({context:this.context,breadcrumbs:["paths",n],topLevelServers:this.context.spec.servers,pathItem:i,path:n}).convert();if(o!=null){for(let c of o.endpoints){if(c.streamEndpoint!=null&&this.addEndpointToIr({endpoint:c.streamEndpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),this.addEndpointToIr({endpoint:c.endpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),c.servers)for(let d of c.servers)this.shouldAddServerToCollectedServers({server:d,currentServers:t})&&t.push(d);if(c.errors)for(let[d,s]of Object.entries(c.errors))r[d]=s}for(let c of o.webhooks){let d=this.context.getGroup({groupParts:c.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:c.webhook,operationId:d.join("."),group:d,audiences:c.audiences})}this.addTypesToIr(o.inlinedTypes)}}return{endpointLevelServers:t,errors:r}}};var a5s=class extends jC{tag;key="x-displayName";constructor({breadcrumbs:t,tag:r,context:n}){super({breadcrumbs:t,context:n}),this.tag=r}convert(){if(typeof this.tag!="object"||this.tag==null)return;let t=this.tag[this.key];if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"x-displayName extension must be a string",path:this.breadcrumbs});return}if(t.trim().length!==0)return{displayName:t}}}};var Jeu=class extends Tee{globalHeaderNames;tagToDisplayName={};isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;i==="reference_identifier"?c=n??o.value.title:i==="discriminator_key"?c=o.value.title??n:i==="schema_identifier"&&(c=o.value.title);let d;if(a.includes("/")){let u=new Q4.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:mh.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:c}),inlinedTypes:d}}setGlobalHeaders(t){this.globalHeaderNames=t.map(r=>r.name.wireValue)}getDisplayNameForTag(t){if(Object.keys(this.tagToDisplayName).length===0)for(let r of this.spec.tags??[]){let i=new a5s({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=i}return this.tagToDisplayName[t]??t}};var gPI=rl.object({description:rl.string().optional(),required:rl.boolean().optional(),deprecated:rl.boolean().optional(),allowEmptyValue:rl.boolean().optional(),style:rl.string().optional(),explode:rl.boolean().optional(),allowReserved:rl.boolean().optional(),schema:rl.any().optional(),example:rl.any().optional(),examples:rl.record(rl.string(),rl.any()).optional(),content:rl.record(rl.string(),rl.any()).optional()}),mPI=gPI.extend({name:rl.string(),in:rl.string()}),OPI=rl.array(mPI),o5s=class extends jC{operation;key="x-fern-parameters";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null)try{return OPI.parse(t)}catch(r){this.context.errorCollector.collect({message:`Failed to parse x-fern-parameters extension: ${r instanceof Error?r.message:String(r)}`,path:this.breadcrumbs});return}}};var u5s=class extends oO{method;pathParameters;queryParameters;headers;topLevelServers;constructor({context:t,breadcrumbs:r,method:n,pathParameters:i=[],queryParameters:a=[],headers:o=[],topLevelServers:c=[]}){super({context:t,breadcrumbs:r}),this.method=n,this.pathParameters=i,this.queryParameters=a,this.headers=o,this.topLevelServers=c}convert(){let t={},r="";for(let s of this.pathParameters)r+=`/{${s.name.originalName}}`;let n=fZ(r),i=[];for(let[s,u]of this.method.params.entries()){let l;if(this.context.isReferenceObject(u)){let C=this.context.resolveReference({reference:u});if(C.resolved)l=C.value;else continue}else l=u;let m=[this.method.name,"Param",l.name].join("_"),P=new Q4.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",l.name],schemaIdOverride:m,context:this.context,schemaOrReference:l.schema,wrapAsOptional:!l.required}).convert();P!=null&&(i.push({docs:l.description,availability:this.context.getAvailability({node:u,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:l.name,wireValue:l.name}),valueType:P.type,v2Examples:P.schema?.typeDeclaration.v2Examples,propertyAccess:void 0}),t={...P.inlinedTypes,...t,...P.schema!=null?{[m]:P.schema}:{}})}let a;if(this.method.result!=null){let s=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(s!=null){let u=new Q4.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:s.schema}),l=[this.method.name,"Result"].join("_"),m=u.convert();m!=null&&(a={docs:s.description,v2Examples:m.schema?.typeDeclaration.v2Examples,responseBodyType:m.type},t={...m.inlinedTypes,...t,...m.schema!=null?{[l]:m.schema}:{}})}}let o=this.getEndpointBaseUrls(),c=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:o,basePath:void 0,auth:!1,security:void 0,method:"POST",id:this.method.name,docs:this.method.description,name:this.context.casingsGenerator.generateName(this.method.name),headers:this.headers,displayName:this.method.name,pathParameters:this.pathParameters,queryParameters:this.queryParameters,allPathParameters:this.pathParameters,path:n,fullPath:n,requestBody:i.length>0?F2.inlinedRequestBody({name:this.context.casingsGenerator.generateName([this.method.name,"Request"].join("_")),docs:void 0,properties:i,extends:[],extendedProperties:[],contentType:"application/json",extraProperties:!1,v2Examples:void 0}):void 0,v2RequestBodies:void 0,sdkRequest:void 0,response:a!=null?{body:oN.json(dde.response(a)),statusCode:void 0}:void 0,v2Responses:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:RPe.openrpc(),audiences:c,retries:void 0},audiences:c,inlinedTypes:t,servers:this.filterOutTopLevelServers(this.method.servers??[])}}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers.some(n=>n.url===r.url))}getEndpointBaseUrls(){let t=this.method.servers;return t?.map(n=>{if(this.topLevelServers.find(c=>c.name===n.name&&c.url!==n.url)!=null)return n.url;let o=this.topLevelServers.find(c=>c.url===n.url)??n;return Ynt.getServerName({server:o,context:this.context})})}convertExamples(){let t={},r=0;if(this.method.examples&&this.method.examples.length>0){for(let n of this.method.examples??[]){let i;if(this.context.isReferenceObject(n)){let d=this.context.resolveReference({reference:n});if(d.resolved)i=d.value;else continue}else i=n;let a;if(i.result)if(this.context.isReferenceObject(i.result)){let d=this.context.resolveReference({reference:i.result});d.resolved&&(a=d.value)}else a=i.result;let o=i.name??`Example ${r+1}`,c=[];if(i.params&&Array.isArray(i.params)){c=[];for(let d of i.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)c.push(s.value);else continue}else c.push(d)}t[o]={displayName:void 0,request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:c.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Jd.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:i.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var s5s=class extends Q4.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:n}){super({context:t,breadcrumbs:r,parameter:n})}convert(){let t,r={};if(this.parameter.schema!=null){let i=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();i!=null&&(t=i.type,r=i.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var Keu=class extends mqr{constructor({context:t,breadcrumbs:r,audiences:n}){super({context:t,breadcrumbs:r,audiences:n})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertSchemas();let{endpointLevelServers:t}=this.convertMethods(),{defaultUrl:r}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(r),this.finalizeIr()}convertServers({endpointLevelServers:t}){let n=new Ynt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:n?.value}),{defaultUrl:n?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let i=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();i!=null&&this.addSchemaOutputToIr(t,i)}}convertMethods(){let t=[],n=new o5s({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),i=[],a=[],o=[];if(n&&n.length>0)for(let[d,s]of n.entries()){let l=new s5s({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${d}]`],parameter:s}).convert();if(l!=null)switch(l.type){case"path":{i.push(l.parameter);break}case"query":{a.push(l.parameter);break}case"header":{o.push(l.parameter);break}}}let c=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let d of this.context.spec.methods??[]){let s=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:["methods"]});if(s==null)continue;let l=new u5s({context:this.context,breadcrumbs:["methods"],method:s,pathParameters:i,queryParameters:a,headers:o,topLevelServers:this.context.spec.servers}).convert();if(l!=null&&(this.addEndpointToIr({endpoint:l.endpoint,audiences:l.audiences,endpointGroup:c,serviceName:"service_root"}),this.addTypesToIr(l.inlinedTypes),l.servers))for(let m of l.servers)this.shouldAddServerToCollectedServers({server:m,currentServers:t,specType:"openrpc"})&&t.push(this.maybeDeduplicateServerName(m))}return{endpointLevelServers:t}}maybeDeduplicateServerName(t){return this.context.spec.servers?.find(n=>n.name===t.name&&n.url!==t.url)?{...t,name:t.url}:t}};var $eu=class extends Tee{isReferenceObject(t){return t!=null&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.title:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.title??n),{ok:!0,reference:mh.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var H_v=require("fs/promises");var npv={[JP.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,n9(e)])),[JP.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[JP.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[JP.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all","kwargs"]),[JP.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[JP.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime","object_id","hash","eql?","equal?","method","send","respond_to?","respond_to_missing?","instance_of?","kind_of?","is_a?","extend","singleton_class","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","remove_instance_variable","public_methods","private_methods","protected_methods","singleton_methods"]),[JP.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[JP.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[JP.GenerationLanguage.SWIFT]:new Set([])};var API=["go","ruby"];function f5s({generationLanguage:e,keywords:t,smartCasing:r}){let n={generateName:(i,a)=>{let o=l=>({unsafeName:l,safeName:PPI({name:l,keywords:wPI({generationLanguage:e,keywords:t})})}),c=MA(i),d=n9(c),s=baa(i),u=_aa(c);return r&&(!SPI(u)&&(e==null||API.includes(e))&&(c=u.map((l,m)=>{if(m>0){let A=c5s(l);if(A!=null)return A;if(l5s(l))return l.toUpperCase()}return l}).join(""),d=n9(u.map((l,m)=>{let A=c5s(l);return A??(l5s(l)?l.toUpperCase():m===0?n9(l):l)}).join(""))),s=i.split(" ").map(l=>l.split(/(\d+)/).map(baa).join("")).join("_")),{originalName:i,camelCase:o(a?.casingOverrides?.camel??c),snakeCase:o(a?.casingOverrides?.snake??s),screamingSnakeCase:o(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:o(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:i,wireValue:a,opts:o})=>({name:n.generateName(i,o),wireValue:a})};return n}function PPI({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":EPI(e)?"_"+e:e}function wPI({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return npv[e]}var jPI=/^[0-9]/;function EPI(e){return jPI.test(e)}function SPI(e){return e.some((t,r)=>{if(r===0)return!1;let n=e[r-1];if(n==null)return!1;let i=c5s(n)!=null||l5s(n),a=c5s(t)!=null||l5s(t);return i&&a})}function c5s(e){return CPI.get(e.toUpperCase())}function l5s(e){return DPI.has(e.toUpperCase())}var DPI=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),CPI=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var ipv=require("fs/promises");async function l2f({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let n=(await(0,ipv.readFile)(t)).toString(),i;try{i=JSON.parse(n)}catch{i=Vg.load(n)}return r!=null?await Xao({absoluteFilePathToOverrides:r,context:e,data:i}):i}var B_v=fa(M_v(),1);function M8i(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...o}={}){let c=i.reduce((s,u)=>({...s,[u]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,u]of Object.entries(c))d=d.replaceAll(s,u);return e?.debug(`+ ${d}`),(0,B_v.default)(t,r,o)}async function MH(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...o}={}){let c=M8i(e,t,r,{doNotPipeOutput:n,secrets:i,substitutions:a,...o});n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr));let d=await c;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function B8i(e,{logger:t,...r}={}){return(n,i)=>MH(t,e,n,{...r,...i})}var bit=require("fs/promises"),L_v=fa(require("path"),1),S2f=fa(OCe(),1);var T_v="buf.gen.yaml",AjI="output",q_v=`${AjI}/ir.json`,R_v="protoc-gen-fern",N_v=`version: v1
|
|
2414
|
+
`).replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:m2s.DefinitionFile.parseOrThrow(Vg.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function pav(e,t){if(N_I(e))return t.alias(e);if(F_I(e))return t.enum(e);if(x_I(e))return t.object(e);if(z_I(e))return t.union(e);tc(e)}function N_I(e){return e?.alias!=null}function F_I(e){return e?.values!=null}function x_I(e){return e?.fields!=null}function z_I(e){return e?.union!=null}var wko=class extends iZo{fernDefinitionBuilder=new dfa(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,o]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:o});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,o]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:o});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await _av(t,(a,o,c)=>{for(let[u,l]of Object.entries(c.services??{})){let m=Vts({value:u,suffix:"Service"});this.conjureFilepathToFernFilepath[o]=ys.of(`${m}/__package__.yml`);return}let s=hVo(o)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[o]=ys.of(`${s}/__package__.yml`))}),await _av(t,(a,o,c)=>{if(c.services==null||Object.keys(c.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[o];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${o}`);for(let[s,u]of Object.entries(c.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ys.of(u)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:ys.of(l),alias:s})}this.importAllTypes({conjureFile:c,fernFilePath:d});return}for(let[d,s]of Object.entries(c.services)){let u=Vts({value:d,suffix:"Service"}),l=ys.of(`${u}/__package__.yml`),m={};s.basePath!=null&&(m["base-path"]=s.basePath),s.docs!=null&&(m.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(l,m),this.importAllTypes({conjureFile:c,fernFilePath:l});for(let[A,P]of Object.entries(c.types?.conjureImports??{})){let C=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:ys.of(P)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:ys.of(C),alias:A})}for(let[A,P]of Object.entries(s.endpoints??{})){let C=z$l(P.http);if(C.type==="failure"){this.context?.logger.error(`Failed to parse ${P.http}. Skipping.`);continue}let T={auth:(P.auth??s.defaultAuth)!==Niv.None,path:C.path,method:C.method,response:P.returns==="binary"?"file":P.returns};P.docs!=null&&(T.docs=P.docs);let z={};if(P.args!=null)for(let U of C.pathParameters){let R=P.args[U];if(R==null)throw new Error(`Failed to find path parameter ${U} in ${P.http}`);z[U]=typeof R=="string"?R:{type:R.type}}Object.entries(z).length>0&&(T["path-parameters"]=z);for(let[U,R]of Object.entries(P.args??{}))if(z[U]==null)if(typeof R=="string")T.request?typeof T.request=="string"&&(T.request={body:T.request}):T.request={},T.request.body=R==="binary"?"bytes":R;else switch(R.paramType){case"body":T.request={body:R.type==="binary"?"bytes":R.type};break;case"query":T.request==null?T.request={"query-parameters":{[U]:R.type}}:typeof T.request!="string"&&T.request?.["query-parameters"]==null?T.request["query-parameters"]={[U]:R.type}:typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request["query-parameters"][U]=R.type)}T.request!=null&&typeof T.request!="string"&&T.request?.["query-parameters"]!=null&&(T.request.name=`${A}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:A,schema:T,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))pav(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{union:Object.fromEntries(Object.entries(a.union).map(([o,c])=>[o,{type:typeof c=="string"?c:c.type,docs:typeof c=="string"?void 0:c.docs,key:o}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=Jl(Ug(t),ys.of(r)),a=AFe(n,i),o=this.conjureFilepathToFernFilepath[a];if(o==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return o}};async function _av(e,t){for(let r of await dav(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function hav(e,t){return yg(e,t)}var O2s=class extends Dqr{type="conjure";absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=Jl(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new ait({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new wko(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:x_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:Vg.dump(i.rootApiFile)},namedDefinitionFiles:{...hav(i.definitionFiles,a=>({absoluteFilepath:x_.of("/DUMMY_PATH"),rawContents:Vg.dump(a),contents:a})),[ys.of(pF)]:{absoluteFilepath:x_.of("/DUMMY_PATH"),rawContents:Vg.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};var qsv=fa(Oav(),1);var yT;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(yT||(yT={}));function A2s(e,t){for(let[r,n]of iee(e))L_I({relativeFilepath:r,failure:n,logger:t})}function L_I({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case yT.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case yT.FILE_READ:r.error("Failed to open file: "+e);break;case yT.FILE_MISSING:r.error("Missing file: "+e);break;case yT.FILE_PARSE:t.error instanceof xVo?r.error(Iyt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case yT.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of U_I(n))r.error(Iyt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case yT.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case yT.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${zrs}: `+t.dependencyName);break;case yT.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case yT.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case yT.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Iyt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));for(let n of t.error.allErrors)n!==t.error.error&&r.debug(Iyt({title:n.message??"Unknown error",breadcrumbs:[e,...n.instancePath.split("/").filter(i=>i!=="")]}));break;default:tc(t)}}function U_I(e){switch(e.code){case my.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${od.underline(e.expected)} but received ${od.underline(e.received)}`}];case my.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${od.underline(t)}`}));case my.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>od.underline(t)).join(", ")}`}];case my.invalid_union:case my.invalid_arguments:case my.invalid_return_type:case my.invalid_date:case my.invalid_string:case my.too_small:case my.too_big:case my.invalid_intersection_types:case my.not_multiple_of:case my.custom:default:return[{title:e.message}]}}var Aav=require("fs/promises");async function Pav(e,t){let r=[];for(let n of await OFe(e,t))r.push(await V_I({relativeFilepath:l5(e,n),absoluteFilepath:n}));return r}async function V_I({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,Aav.readFile)(t)).toString()}}async function wav(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:Vg.load(i.fileContents,{schema:Vg.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:yT.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}var Xzf=fa(D6i(),1);var Psv=require("fs"),Mao=require("fs/promises");var wsv=require("os"),jsv=fa(require("path"),1),Esv=require("stream/promises"),Ssv=fa(C7s(),1),Dsv=fa(OCe(),1);var gvI=oAi();async function Csv({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:o}){let c,d={type:yT.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?d={type:yT.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${EvI(s)}`},async u=>{switch(s.type){case"version":c=await wvI({context:u,dependency:s,cliVersion:i,settings:a,loadAPIWorkspace:o});return;case"local":c=await PvI({context:u,dependency:s,cliVersion:i,settings:a,loadAPIWorkspace:o});return;default:tc(s)}}),c!=null?{didSucceed:!0,definition:c}:{didSucceed:!1,failure:d}}var Isv="dependencies";var mvI="metadata.json",OvI=".fern";function AvI(e){return Jl(x_.of((0,wsv.homedir)()),ys.of(OvI),ys.of(Isv),ys.of(e.organization),ys.of(e.apiName),ys.of(e.version))}async function PvI({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let o=await a.workspace.getDefinition({context:t,relativePathToDependency:ys.of(e.path)},n);return t.logger.info("Loaded..."),o}async function wvI({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=AvI(e),o=Jl(a,ys.of(Isv)),c=Jl(a,ys.of(mvI)),d;if(!await Tv(o)||!await Tv(c)){t.logger.info("Downloading manifest...");let l=await gvI.definitionRegistry.get(Xzf.FernFiddle.OrganizationId(e.organization),Xzf.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:C=>{t.failWithoutThrowing("Failed to download API manifest",C)}});return}let m=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,A=$la(r),P=$la(l.body.cliVersion);if(m!=null){if(m>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(m<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(A.major!==P.major||A.minor!==P.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${A.major}.${A.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,Mao.mkdir)(o,{recursive:!0});try{await jvI({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:o})}catch(C){t.failWithoutThrowing("Failed to download API",C);return}d=l.body,await(0,Mao.writeFile)(c,JSON.stringify(d))}else d=JSON.parse((await(0,Mao.readFile)(c)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let s=await i({absolutePathToWorkspace:o,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},n)}async function jvI({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await rZ.get(e,{responseType:"stream"}),n=await Dsv.default.dir(),i=jsv.default.join(n.path,"api.tgz");await(0,Esv.pipeline)(r.data,(0,Psv.createWriteStream)(i)),await(0,Ssv.extract)({file:i,cwd:t})}function EvI(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:tc(e)}}async function Msv({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let o={},c={},d={};return await Promise.all(iee(t.packageMarkers).map(async([s,u])=>{if(u.contents.export==null)o[s]=u;else{let{export:l,...m}=u.contents;if(Q7(m)>0)d[s]={type:yT.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let A=Ug(s);if(JBr(t.namedDefinitionFiles).some(C=>C!==s&&C.startsWith(A)))d[s]={type:yT.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:A};else{let C=await Csv({dependencyName:typeof u.contents.export=="string"?u.contents.export:u.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});C.didSucceed?c[Ug(s)]={definition:C.definition,url:typeof u.contents.export=="object"?u.contents.export.url:void 0}:d[s]=C.failure}}}})),Q7(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:o,importedDefinitions:c}}var Bsv=fa(require("path"),1);var Zzf={};ff(Zzf,{additionalProperties:()=>IvI,default:()=>BvI,definitions:()=>MvI,properties:()=>DvI,required:()=>CvI,type:()=>SvI});var SvI="object",DvI={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},product:{oneOf:[{$ref:"#/definitions/products.ProductDeclarationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},CvI=["name"],IvI=!1,MvI={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.AuthScope":{type:"string"},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"token-header":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.TokenBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.InferredAuthenticatedRequestHeader":{type:"object",properties:{"response-property":{type:"string"},"header-name":{type:"string"},"value-prefix":{oneOf:[{type:"string"},{type:"null"}]}},required:["response-property","header-name"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchemaObject":{type:"object",properties:{endpoint:{type:"string"},"expiry-response-property":{oneOf:[{type:"string"},{type:"null"}]},"authenticated-request-headers":{oneOf:[{type:"array",items:{$ref:"#/definitions/auth.InferredAuthenticatedRequestHeader"}},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.InferredGetTokenEndpointSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.InferredGetTokenEndpointSchemaObject"}]},"auth.InferredBearerAuthSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},"get-token":{$ref:"#/definitions/auth.InferredGetTokenEndpointSchema"}},required:["scheme","get-token"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{anyOf:[{$ref:"#/definitions/auth.TokenBearerAuthSchema"},{$ref:"#/definitions/auth.InferredBearerAuthSchema"}]},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1},"products.ProductValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},versions:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"products.ProductValue":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductValueDetailed"}]},"products.ProductDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"products.ProductDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/products.ProductDeclarationHeaderObjectSchema"}]},"products.ProductDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/products.ProductValue"}},header:{$ref:"#/definitions/products.ProductDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},BvI={type:SvI,properties:DvI,required:CvI,additionalProperties:IvI,definitions:MvI};var kzf={};ff(kzf,{additionalProperties:()=>RvI,default:()=>FvI,definitions:()=>NvI,properties:()=>qvI,type:()=>TvI});var TvI="object",qvI={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},RvI=!1,NvI={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/service.HttpEndpointAuth"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},FvI={type:TvI,properties:qvI,additionalProperties:RvI,definitions:NvI};var e6f={};ff(e6f,{additionalProperties:()=>QvI,default:()=>UvI,definitions:()=>LvI,properties:()=>zvI,type:()=>xvI});var xvI="object",zvI={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},QvI=!1,LvI={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.ObjectPropertyAccess":{type:"string",enum:["read-only","write-only"]},"types.ObjectPropertyWithAccessSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},access:{oneOf:[{$ref:"#/definitions/types.ObjectPropertyAccess"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.ObjectPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectPropertyWithAccessSchema"}]},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},inline:{oneOf:[{type:"boolean"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE","HEAD"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"auth.AuthScope":{type:"string"},"service.HttpEndpointSecurityItem":{type:"object",additionalProperties:{type:"array",items:{$ref:"#/definitions/auth.AuthScope"}}},"service.HttpEndpointSecurity":{type:"array",items:{$ref:"#/definitions/service.HttpEndpointSecurityItem"}},"service.HttpEndpointAuth":{anyOf:[{type:"boolean"},{$ref:"#/definitions/service.HttpEndpointSecurity"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.FormDataBodyEncodingStyle":{type:"string",enum:["json","exploded","form"]},"service.HttpInlineFileRequestBodyPropertySchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},style:{oneOf:[{$ref:"#/definitions/service.FormDataBodyEncodingStyle"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpInlineFileRequestBodyPropertySchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.CustomPaginationSchema":{type:"object",properties:{type:{const:"custom"},results:{type:"string"}},required:["type","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"},{$ref:"#/definitions/pagination.CustomPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.RetriesDisabledSchema":{type:"object",properties:{disabled:{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"service.RetriesConfiguration":{anyOf:[{$ref:"#/definitions/service.RetriesDisabledSchema"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/service.HttpEndpointAuth"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},retries:{oneOf:[{$ref:"#/definitions/service.RetriesConfiguration"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},UvI={type:xvI,properties:zvI,additionalProperties:QvI,definitions:LvI};function Tsv({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[o,c]of iee(e)){let d=c.contents,s=u=>{a[o]={type:yT.JSONSCHEMA_VALIDATION,error:u}};if(o===oee){let u=ZBr(d,Zzf);if(u.success){let l=YX.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:c.rawContents}}else s(u)}else if(Bsv.default.basename(o)===pF){let u=ZBr(d,e6f);if(u.success){let l=YX.serialization.PackageMarkerFileSchema.parseOrThrow(d);i[o]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:c.rawContents}}else s(u)}else{let u=ZBr(d,kzf);if(u.success){let l=YX.serialization.DefinitionFileSchema.parseOrThrow(d);n[o]={defaultUrl:void 0,contents:l,rawContents:c.rawContents,absoluteFilePath:Jl(t,o)}}else s(u)}}return r==null?{didSucceed:!1,failures:{[ys.of(oee)]:{type:yT.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var JVr=class extends Dqr{type="fern";context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,qsv.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,o=Jl(this.absoluteFilePath,ys.of(uie)),c=await zkl({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await Pav(o,"{yml,yaml}"),s=await wav(d);if(!s.didSucceed)return A2s(s.failures,a.logger),a.failAndThrow();let u=Tsv({files:s.files,absolutePathToDefinition:o});if(!u.didSucceed)return A2s(u.failures,a.logger),a.failAndThrow();let l=await Msv({dependenciesConfiguration:c,structuralValidationResult:u,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return A2s(l.failures,a.logger),a.failAndThrow();let m={absoluteFilePath:o,rootApiFile:u.rootApiFile,namedDefinitionFiles:u.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions};r?.auth!=null&&(m={...m,rootApiFile:{...m.rootApiFile,contents:{...m.rootApiFile.contents,auth:r?.auth}}}),i=new ait({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:c,workspaceName:this.workspaceName,definition:m,cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var Jdv=require("fs/promises");var Vdv=fa(Udv(),1);async function zeu(e){return(await(0,Vdv.convertObj)(e,{})).openapi}var Hdv=require("fs/promises");var Wdv=require("fs/promises");async function Xao({absoluteFilePathToOverrides:e,data:t,context:r,allowNullKeys:n}){let i=null;try{let a=(await(0,Wdv.readFile)(e,"utf8")).toString();try{i=JSON.parse(a)}catch{i=Vg.load(a,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return R$l({data:t,overrides:i,allowNullKeys:n})}async function n2f({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let n=(await(0,Hdv.readFile)(t)).toString(),i=await Vg.load(n);return r!=null?await Xao({absoluteFilePathToOverrides:r,context:e,data:i}):i}var Leu=fa(Y4s(),1);var Gdv=fa(Y4s(),1),i2f=fa(require("path"),1),Qeu=class extends Gdv.BaseResolver{absolutePathToOpenAPIOverrides;constructor(t){super(),this.absolutePathToOpenAPIOverrides=t}resolveExternalRef(t,r){let n=super.resolveExternalRef(t,r);return n.startsWith("http://")||n.startsWith("https://")||rTr(x_.of(n))?n:this.absolutePathToOpenAPIOverrides!=null?i2f.default.resolve(i2f.default.dirname(this.absolutePathToOpenAPIOverrides),r):n}};async function a2f({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,parsed:r}){return(r!=null?await(0,Leu.bundle)({...X4s,doc:{source:new Leu.Source(e,"<openapi>"),parsed:r},externalRefResolver:new Qeu(t)}):await(0,Leu.bundle)({...X4s,ref:e,externalRefResolver:new Qeu(t)})).bundle.parsed}var ePI=["examples","example",jb.EXAMPLES,Hbe.REDOCLY_CODE_SAMPLES_CAMEL,Hbe.REDOCLY_CODE_SAMPLES_KEBAB];async function Ueu({context:e,absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r}){let n=await a2f({absolutePathToOpenAPI:t}),i;if(r!=null?i=r:typeof n=="object"&&n[jb.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=Jl(Ug(t),ys.of(n[jb.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await Xao({absoluteFilePathToOverrides:i,context:e,data:n,allowNullKeys:ePI});return await a2f({absolutePathToOpenAPI:t,absolutePathToOpenAPIOverrides:r,parsed:a})}return n}var Gqr=class{absoluteFilePath;constructor(t){this.absoluteFilePath=t}async loadDocuments({context:t,specs:r}){let n=[];for(let i of r)try{let a=(await(0,Jdv.readFile)(i.absoluteFilepath)).toString(),o=l5(this.absoluteFilePath,i.source.file);i.source.relativePathToDependency!=null&&(o=Jl(i.source.relativePathToDependency,o));let c=i.source.type==="protobuf"?gwe.protobuf({file:o}):gwe.openapi({file:o});if(a.includes("openapi")||a.includes("swagger"))try{let d=await Ueu({absolutePathToOpenAPI:i.absoluteFilepath,context:t,absolutePathToOpenAPIOverrides:i.absoluteFilepathToOverrides});if(kxf(d)){n.push({type:"openapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}else if(bko(d)){(!d.schemes||d.schemes.length===0)&&(d.schemes=["https"]);let s=await zeu(d);n.push({type:"openapi",value:s,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}}catch(d){t.logger.error(`Failed to parse OpenAPI document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("asyncapi"))try{let d=await n2f({context:t,absoluteFilePath:i.absoluteFilepath,absoluteFilePathToOverrides:i.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}catch(d){t.logger.error(`Failed to parse AsyncAPI document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}if(a.includes("openrpc"))try{let d=await n2f({context:t,absoluteFilePath:i.absoluteFilepath,absoluteFilePathToOverrides:i.absoluteFilepathToOverrides});n.push({type:"asyncapi",value:d,source:c,namespace:i.namespace,settings:Oyt({options:i.settings})});continue}catch(d){t.logger.error(`Failed to parse OpenRPC document at ${i.absoluteFilepath}: ${d}. Skipping...`);continue}t.logger.warn(`${i.absoluteFilepath} is not a valid OpenAPI, AsyncAPI, or OpenRPC file. Skipping...`)}catch(a){t.logger.error(`Failed to read or process file ${i.absoluteFilepath}: ${a}. Skipping...`);continue}return n}};var tPI=rl.object({type:rl.string(),channelId:rl.string().optional(),messageId:rl.string(),value:rl.any()}),rPI=rl.object({summary:rl.string().optional(),description:rl.string().optional(),"query-parameters":rl.record(rl.string()).optional(),headers:rl.record(rl.string()).optional(),messages:rl.array(tPI)}),Kdv=rl.array(rPI);var F8s=class extends jC{channel;key="x-fern-examples";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t??[],context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(t==null)return;let r=Kdv.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-examples extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data.map(n=>({summary:n.summary,description:n.description,queryParameters:n["query-parameters"],headers:n.headers,messages:n.messages.map(i=>({type:i.type,channelId:i.channelId,messageId:i.messageId,value:i.value}))}))}};var Zao=class extends oO{channel;channelPath;inlinedTypes={};websocketGroup;constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}){super({context:t,breadcrumbs:r}),this.websocketGroup=n,this.channel=i,this.channelPath=a}convertExamples({fullPath:t,baseUrl:r,asyncApiVersion:n}){let a=new F8s({context:this.context,breadcrumbs:this.breadcrumbs,channel:this.channel}).convert();return a==null?{}:Object.fromEntries(a.map((o,c)=>[c.toString(),{channel:{method:"GET",path:t},baseUrl:t,environment:r,auth:void 0,pathParameters:{},queryParameters:o.queryParameters,headers:o.headers,messages:o.messages.map(d=>({type:n==="v2"?d.type:d.messageId,body:d.value}))}]))}transformToValidPath(t){return t.startsWith("/")?t:"/"+t}};var C8i=class extends Q4.AbstractConverters.AbstractParameterConverter{parameterNamePrefix;constructor({context:t,breadcrumbs:r,parameter:n,parameterNamePrefix:i}){super({context:t,breadcrumbs:r,parameter:n}),this.parameterNamePrefix=i}convert(){let t,r={},i=new Ube.FernOptionalExtension({breadcrumbs:this.breadcrumbs,parameter:this.parameter,context:this.context}).convert()??this.parameter.required===!1,a=this.parameter.schema??{...this.parameter,type:"string",enum:this.parameter.enum,default:this.parameter.default,example:this.parameter.example??this.parameter.name,examples:Object.values(this.parameter.examples??{}),deprecated:this.parameter.deprecated,required:void 0},c=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaIdOverride:this.parameterNamePrefix?`${this.parameterNamePrefix}_${this.parameter.name}`:this.parameter.name,schemaOrReference:a,wrapAsOptional:i}).convert();return c!=null&&(t=c.type,r=c.inlinedTypes??{}),this.convertToOutput({schema:a,typeReference:t,inlinedTypes:r})}};var x8s=class extends jC{channel;key="x-fern-address";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t,context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var kao=class extends jC{channel;key="x-fern-display-name";constructor({breadcrumbs:t,channel:r,context:n}){super({breadcrumbs:t,context:n}),this.channel=r}convert(){let t=this.getExtensionValue(this.channel);if(!(t==null||typeof t!="string"))return t}};var z8s=class extends Zao{inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}){super({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a})}convert(){let t=[],r=[],n=[],a=new kao({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".");this.channel.parameters&&this.convertPathParameters({context:this.context,pathParameters:t}),this.channel.bindings?.ws!=null&&(this.convertHeaders({context:this.context,headers:n}),this.convertBindingQueryParameters({context:this.context,queryParameters:r}));let o;this.channel.subscribe!=null&&(o=this.convertMessage({context:this.context,operation:this.channel.subscribe,origin:"server"}));let c;this.channel.publish!=null&&(c=this.convertMessage({context:this.context,operation:this.channel.publish,origin:"client"}));let d=[];o!=null&&d.push(o),c!=null&&d.push(c);let u=new x8s({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert(),l=this.transformToValidPath(u??this.channelPath),m=this.channel.servers?.[0]??Object.keys(this.context.spec.servers??{})[0],A=fZ(l),P=MA(this.channelPath),C=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(P),displayName:a,baseUrl:m,path:A,auth:!1,headers:n,queryParameters:r,pathParameters:t,messages:d,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:l,baseUrl:m,asyncApiVersion:"v2"})}},audiences:C,inlinedTypes:this.inlinedTypes}}convertMessage({context:t,operation:r,origin:n}){let i,a=n==="server"?"subscribe":"publish",o=[...this.breadcrumbs,a],c=t.resolveMaybeReference({schemaOrReference:r.message,breadcrumbs:o});c!=null&&(r.message=c);let d=gaa(MA(`${this.channelPath}_${a}`)).replace(/ /g,"");if("oneOf"in r.message){let u=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:r.message,schemaIdOverride:d}).convert();u!=null&&u.schema!=null&&(i=u.schema,this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes})}else if(t.isMessageWithPayload(r.message)){let s=t.resolveMaybeReference({schemaOrReference:r.message.payload,breadcrumbs:o});if(s!=null){let l=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:o,schemaOrReference:s,schemaIdOverride:d}).convert();l!=null&&l.schema!=null&&(i=l.schema,this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes})}}if(i!=null){let s=i,u=mh.named({fernFilepath:t.createFernFilepath(),name:s.typeDeclaration.name.name,typeId:s.typeDeclaration.name.typeId,displayName:void 0,default:void 0,inline:!1}),l=yde.reference({bodyType:u,docs:r.description}),m=n==="server"?"subscribe":"publish";return{type:m,displayName:m,origin:n,body:l,availability:t.getAvailability({node:r,breadcrumbs:this.breadcrumbs}),docs:r.description}}}convertPathParameters({context:t,pathParameters:r}){for(let[n,i]of Object.entries(this.channel.parameters??{})){let a=t.resolveMaybeReference({schemaOrReference:i,breadcrumbs:this.breadcrumbs});if(a==null)continue;let c=new C8i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...a,name:n,in:"path",description:a.description,required:a.required??!0}}).convert();c!=null&&(this.inlinedTypes={...this.inlinedTypes,...c.inlinedTypes},c.type==="path"&&r.push(c.parameter))}}convertHeaders({context:t,headers:r}){if(this.channel.bindings?.ws?.headers!=null){let n=this.channel.bindings.ws.headers.required??[];for(let[i,a]of Object.entries(this.channel.bindings.ws.headers.properties??{})){let o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,i]});if(o==null)continue;let d=new C8i({context:this.context,breadcrumbs:[...this.breadcrumbs,i],parameter:{name:i,in:"header",required:n.includes(i),schema:o,description:"description"in o?o.description:void 0}}).convert();d!=null&&d.type==="header"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}convertBindingQueryParameters({context:t,queryParameters:r}){if(this.channel.bindings?.ws?.query!=null){let n=this.channel.bindings.ws.query.required??[];for(let[i,a]of Object.entries(this.channel.bindings.ws.query.properties??{})){let o=t.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,i]});if(o==null)continue;let d=new C8i({context:this.context,breadcrumbs:[...this.breadcrumbs,i],parameter:{name:i,in:"query",required:n.includes(i),schema:o,description:"description"in o?o.description:void 0,deprecated:o.deprecated??!1}}).convert();d!=null&&d.type==="query"&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},r.push(d.parameter))}}}};var eoo=class extends oO{servers;constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r}),this.servers=n}convert(){if(this.servers==null||Object.keys(this.servers).length===0)return;let t=[],r;for(let[n,i]of Object.entries(this.servers)){let a=this.buildSingleBaseUrlEnvironment(this.context,n,i);t.push(a),r==null&&(r=a.id)}return{defaultEnvironment:r,environments:mJ.singleBaseUrl({environments:t})}}constructServerUrl(t,r){return r.includes("://")?r:`${t}://${r}`}};var Q8s=class extends eoo{constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r,servers:n})}buildSingleBaseUrlEnvironment(t,r,n){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(n.protocol,n.url),docs:void 0}}};var o2f="$message.",$dv="#/channels/",Ydv="#/servers/",L8s=class extends Zao{operations;inlinedTypes={};constructor({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a,operations:o}){super({context:t,breadcrumbs:r,websocketGroup:n,channel:i,channelPath:a}),this.operations=o}convert(){let t=[],r=[],n=[],a=new kao({breadcrumbs:this.breadcrumbs,channel:this.channel,context:this.context}).convert()??this.websocketGroup?.join(".")??this.channelPath;this.channel.parameters&&this.convertChannelParameters({pathParameters:t,queryParameters:r,headers:n,channelPath:this.channelPath});let o=Object.entries(this.operations).reduce((m,[A,P])=>{try{this.getChannelPathFromOperation(P)===this.channelPath&&(m[A]=P)}catch{}return m},{}),c=[];for(let[m,A]of Object.entries(o))for(let P of A.messages){let C=this.context.convertReferenceToTypeReference({reference:P});if(C.ok){let M=yde.reference({bodyType:C.reference,docs:A.description});c.push({type:m,displayName:m,origin:A.action==="send"?"client":"server",body:M,availability:this.context.getAvailability({node:A,breadcrumbs:this.breadcrumbs}),docs:A.description})}}let d=this.resolveChannelServersFromReference(this.channel.servers??[])??Object.keys(this.context.spec.servers??{})[0],s=this.transformToValidPath(this.channel.address??this.channelPath),u=fZ(s),l=this.context.getAudiences({operation:this.channel,breadcrumbs:this.breadcrumbs})??[];return{channel:{name:this.context.casingsGenerator.generateName(a),displayName:a,baseUrl:d,path:u,auth:!1,headers:n,queryParameters:r,pathParameters:t,messages:c,availability:this.context.getAvailability({node:this.channel,breadcrumbs:this.breadcrumbs}),docs:this.channel.description,examples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples({fullPath:s,baseUrl:d,asyncApiVersion:"v3"})}},audiences:l,inlinedTypes:this.inlinedTypes}}convertChannelParameters({pathParameters:t,queryParameters:r,headers:n,channelPath:i}){for(let a of Object.values(this.channel.parameters??{})){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:[...this.breadcrumbs,"parameters"]});if(o==null)continue;let c=this.convertChannelParameterLocation(o.location);if(c==null)continue;let{type:d,parameterKey:s}=c,l=new C8i({context:this.context,breadcrumbs:this.breadcrumbs,parameter:{...o,name:s,in:d},parameterNamePrefix:this.channelPath}).convert();if(l!=null)switch(this.inlinedTypes={...this.inlinedTypes,...l.inlinedTypes},l.type){case"path":t.push(l.parameter);break;case"query":r.push(l.parameter);break;case"header":n.push(l.parameter);break}}}convertChannelParameterLocation(t){try{let[r,n]=t.split("#/");if(r==null||n==null){this.context.errorCollector.collect({message:`Invalid location format: ${t}; unable to parse message type and parameter key`,path:this.breadcrumbs});return}if(!r.startsWith(o2f)){this.context.errorCollector.collect({message:`Invalid location format: ${t}; expected ${o2f} prefix`,path:this.breadcrumbs});return}let i=r.substring(o2f.length);if(i!=="header"&&i!=="path"&&i!=="payload"){this.context.errorCollector.collect({message:`Invalid message type: ${i}. Must be one of: header, path, payload`,path:this.breadcrumbs});return}return i==="payload"?{type:"query",parameterKey:n}:{type:i,parameterKey:n}}catch{this.context.errorCollector.collect({message:`Invalid location format: ${t}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`,path:this.breadcrumbs});return}}resolveChannelServersFromReference(t){if(t==null||t.length===0||t[0]==null)return;let r=t[0];if(!r.$ref.startsWith(Ydv)){this.context.errorCollector.collect({message:`Failed to resolve server name from server ref ${r.$ref}`,path:this.breadcrumbs});return}let n=r.$ref.substring(Ydv.length);if(n==null){this.context.errorCollector.collect({message:`Failed to find server with name ${n}`,path:this.breadcrumbs});return}return n}getChannelPathFromOperation(t){if(!t.channel.$ref.startsWith($dv))throw new Error(`Failed to resolve channel path from operation ${t.channel.$ref}`);return t.channel.$ref.substring($dv.length)}};var U8s=class extends eoo{constructor({context:t,breadcrumbs:r,servers:n}){super({context:t,breadcrumbs:r,servers:n})}buildSingleBaseUrlEnvironment(t,r,n){return{id:r,name:t.casingsGenerator.generateName(r),url:this.constructServerUrl(n.protocol,n.host),docs:void 0}}};var Veu=class extends mqr{constructor({context:t,breadcrumbs:r,audiences:n}){super({context:t,breadcrumbs:r,audiences:n})}async convert(){return this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.isAsyncAPIV3(this.context)?this.convertChannelMessages():this.convertComponentMessages(),this.convertSchemas(),this.convertServers(),this.convertChannels(),this.finalizeIr()}isAsyncAPIV3(t){return parseFloat(t.spec.asyncapi)>=3}convertChannelMessages(){let t=this.context.spec;for(let[r,n]of Object.entries(t.channels??{}))for(let[i,a]of Object.entries(n.messages??{})){if(!this.context.isMessageWithPayload(a)&&!this.context.isReferenceObject(a))continue;let o=["channels",r,"messages",i],c=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:o});if(!this.context.isMessageWithPayload(c))continue;let d=this.context.resolveMaybeReference({schemaOrReference:c.payload,breadcrumbs:o});if(d==null)continue;let s=`${r}_${i}`;this.convertSchema({id:s,breadcrumbs:o,schema:d})}}convertComponentMessages(){for(let[t,r]of Object.entries(this.context.spec.components?.messages??{})){if(r.payload==null)continue;let n=["components","messages",t],i=this.context.resolveMaybeReference({schemaOrReference:r.payload,breadcrumbs:n});i!=null&&this.convertSchema({id:t,breadcrumbs:n,schema:i})}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{}))this.convertSchema({id:t,breadcrumbs:["components","schemas",t],schema:r})}convertSchema({id:t,breadcrumbs:r,schema:n}){let a=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:r,schema:n}).convert();a!=null&&this.addSchemaOutputToIr(t,a)}convertServers(){let t;if(this.isAsyncAPIV3(this.context)){let r=this.context.spec.servers;t=new U8s({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}else{let r=this.context.spec.servers;t=new Q8s({context:this.context,breadcrumbs:["servers"],servers:r}).convert()}this.addEnvironmentsToIr({environmentConfig:t})}convertChannels(){for(let[t,r]of Object.entries(this.context.spec.channels??{})){let i=new Ube.SdkGroupNameExtension({breadcrumbs:["channels",t],operation:r,context:this.context}).convert()?.groups,a;if(this.isAsyncAPIV3(this.context)){let c=this.context.spec.operations??{};a=new L8s({context:this.context,breadcrumbs:["channels",t],websocketGroup:i,channel:r,channelPath:t,operations:c}).convert()}else a=new z8s({context:this.context,breadcrumbs:["channels",t],websocketGroup:i,channel:r,channelPath:t}).convert();a!=null&&(this.addWebsocketChannelToIr({websocketChannel:a.channel,channelPath:t,audiences:a.audiences,websocketGroup:i}),this.addTypesToIr(a.inlinedTypes))}}};var Weu=class extends Tee{isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}getTypeIdFromMessageReference(t){let r=t.$ref.match(/\/messages\/(.+)$/);if(!(!r||!r[1]))return r[1]}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a,o=t.$ref.match(/^.*\/schemas\/(.+)$/),c=t.$ref.match(/^.*\/channels\/([^/]+)\/messages\/(.+)$/),d=t.$ref.match(/^.*\/messages\/(.+)$/);if(o&&o[1])return a=o[1],this.convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a});if(c&&c[2]){let s=c[1],u=c[2];return a=`${s}_${u}`,this.convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a})}else return d&&d[1]?(a=d[1],this.convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a})):{ok:!1}}convertSchemaReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.title:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.title??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV3MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.name:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.name??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}convertV2MessageReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i,typeId:a}){let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.messageId??o.value.name:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.messageId??o.value.name??n),{ok:!0,reference:mh.named({fernFilepath:this.createFernFilepath(),name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var rpv=fa(V8s(),1);var W8s=class extends jC{document;key="x-fern-global-headers";constructor({breadcrumbs:t,document:r,context:n}){super({breadcrumbs:t,context:n}),this.document=r}convert(){let t=this.getExtensionValue(this.document);if(t!=null){if(!Array.isArray(t)){this.context.errorCollector.collect({message:"Received unexpected non-array value for x-fern-global-headers",path:this.breadcrumbs});return}return t}}};function Xdv({globalHeaders:e,context:t}){return e.map(r=>({name:t.casingsGenerator.generateNameAndWireValue({name:r.name??"",wireValue:r.header}),valueType:r.optional?oO.OPTIONAL_STRING:oO.STRING,env:r.env,v2Examples:r.optional?void 0:aPI({header:r,context:t}),availability:void 0,docs:void 0}))}function aPI({header:e,context:t}){let r=new ayt({breadcrumbs:[],context:t,schema:{type:"string"},example:e.header}),{validExample:n}=r.convert();return{userSpecifiedExamples:{},autogeneratedExamples:{globalHeaderExample:n}}}var H8s=class extends Q4.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:n}){super({context:t,breadcrumbs:r,parameter:n})}convert(){let t,r={};if(this.parameter.schema!=null){let n=this.context.convertBreadcrumbsToName([...this.breadcrumbs,this.parameter.name]),a=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,this.parameter.name,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required,schemaIdOverride:n}).convert();a!=null&&(t=a.type,r=a.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var G8s=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{contentType;mediaType;description;required;schemaId;streamingExtension;constructor({context:t,breadcrumbs:r,contentType:n,mediaType:i,description:a,required:o,group:c,method:d,streamingExtension:s}){super({context:t,breadcrumbs:r,group:c,method:d}),this.contentType=n,this.mediaType=i,this.description=a,this.required=o,this.schemaId=[...this.group,this.method,"Request"].join("_"),this.streamingExtension=s}convert(){return this.streamingExtension?.type=="streamCondition"?this.convertStreamConditionRequestBody():this.convertNonStreamConditionRequestBody()}convertStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleStreamConditionJsonOrFormContent({contentType:this.contentType})}convertNonStreamConditionRequestBody(){if(this.isOrderedJsonOrFormContentType())return this.handleJsonOrFormContent({contentType:this.contentType});if(z7.parse(this.contentType)?.isMultipart())return this.handleMultipartContent({contentType:this.contentType});if(this.isBinaryContentType())return this.handleBinaryContent({contentType:this.contentType})}isOrderedJsonOrFormContentType(){let t=z7.parse(this.contentType);return t?t.isJSON()||t.isURLEncoded()||t.isPlainText()||t.isCSV()||t.isHTML()||t.isXML()||t.isDNS()||t.isApplicationText():!1}isBinaryContentType(){let t=z7.parse(this.contentType);return t?t.isBinary():!1}handleJsonOrFormContent({contentType:t}){let r=this.mediaType;if(r==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});if(n==null)return;let i=n.schema?.typeDeclaration.shape;return i?.type==="object"?{requestBody:F2.inlinedRequestBody({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),extendedProperties:i.extendedProperties,extends:i.extends,properties:i.properties,extraProperties:i.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:n.inlinedTypes})}:{requestBody:F2.reference({contentType:t,docs:this.description,requestBodyType:n.type,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:n.inlinedTypes??{}}}handleMultipartContent({contentType:t}){let r=this.mediaType;if(r==null||r.schema==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,resolveSchema:!0,contentType:t});if(n==null)return;let i=n.schema?.typeDeclaration.shape;if(i?.type==="object")return{requestBody:F2.fileUpload({contentType:t,docs:this.description,name:this.context.casingsGenerator.generateName(this.schemaId),properties:i.properties.map(a=>{let o=r.encoding?.[a.name.wireValue];return this.convertRequestBodyProperty({property:a,contentType:t,encoding:o})}),v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:n.inlinedTypes}),examples:n.examples}}handleBinaryContent({contentType:t}){let r=this.mediaType;if(r==null)return;let n=this.parseMediaTypeObject({mediaTypeObject:r,schemaId:this.schemaId,contentType:t});return{requestBody:F2.bytes({contentType:t,isOptional:this.required===!1,docs:this.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:r,exampleGenerationStrategy:"request"})}),streamRequestBody:void 0,inlinedTypes:n?.inlinedTypes??{}}}convertRequestBodyProperty({property:t,contentType:r,encoding:n}){let{isFile:i,isOptional:a,isArray:o}=this.recursivelyCheckTypeReferenceIsFile({typeReference:t.valueType});return i?o?gie.file(oxe.fileArray({key:t.name,isOptional:a,contentType:r,docs:t.docs})):gie.file(oxe.file({key:t.name,isOptional:a,contentType:r,docs:t.docs})):gie.bodyProperty({...t,contentType:n?.contentType??r,style:uPI({encoding:n}),name:t.name})}handleStreamConditionJsonOrFormContent({contentType:t}){if(this.streamingExtension?.type!=="streamCondition")return;let r=this.mediaType;if(r==null||r.schema==null)return;let n=this.context.resolveMaybeReference({schemaOrReference:r.schema,breadcrumbs:[...this.breadcrumbs,"content",t,"schema"]});if(n==null)return;let i=n.properties?.[this.streamingExtension.streamConditionProperty];if(i==null||this.context.isReferenceObject(i))return;let a=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:i,resolvedMediaTypeSchema:n,isStreaming:!0,contentType:t,mediaTypeObject:r}),o=this.buildStreamConditionInlinedRequestBody({streamConditionProperty:i,resolvedMediaTypeSchema:n,isStreaming:!1,contentType:t,mediaTypeObject:r});if(!(a==null||o==null))return{requestBody:o.requestBody,streamRequestBody:a.requestBody,inlinedTypes:this.context.removeSchemaFromInlinedTypes({id:this.schemaId,inlinedTypes:{...a.inlinedTypes,...o.inlinedTypes}})}}buildStreamConditionInlinedRequestBody({streamConditionProperty:t,resolvedMediaTypeSchema:r,isStreaming:n,contentType:i,mediaTypeObject:a}){if(this.streamingExtension==null||this.streamingExtension.type!=="streamCondition")return;let o={...r,properties:{...r.properties,[this.streamingExtension.streamConditionProperty]:{type:"boolean",const:n,...t}},required:[...r.required??[],this.streamingExtension.streamConditionProperty]},c={...a,schema:o},d=this.parseMediaTypeObject({mediaTypeObject:c,schemaId:this.schemaId,contentType:i});if(d==null)return;let s=d.schema?.typeDeclaration.shape;if(s?.type==="object")return{requestBody:F2.inlinedRequestBody({contentType:i,docs:void 0,name:this.context.casingsGenerator.generateName(n?`${this.schemaId}_streaming`:this.schemaId),extendedProperties:s.extendedProperties,extends:s.extends,properties:s.properties,extraProperties:s.extraProperties,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:c,exampleGenerationStrategy:"request"})}),inlinedTypes:d.inlinedTypes}}recursivelyCheckTypeReferenceIsFile({typeReference:t,isOptional:r,isArray:n}){return this.context.isList(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.list,isOptional:r,isArray:!0}):this.context.isOptional(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.optional,isOptional:!0,isArray:n}):this.context.isNullable(t)?this.recursivelyCheckTypeReferenceIsFile({typeReference:t.container.nullable,isOptional:r,isArray:n}):{isFile:this.context.isFile(t),isOptional:r??!1,isArray:n??!1}}},oPI={"application/json":"json"};function uPI({encoding:e}){if(e){if(e.explode)return"exploded";if(e.style==="form")return"form";if(e.contentType)return oPI[e.contentType]}}var sPI=/{([^}]+)}/g,cPI=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]),too=class extends oO{operation;method;path;inlinedTypes={};constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a}){super({context:t,breadcrumbs:r}),this.operation=n,this.method=i,this.path=a}convertHttpMethod(){switch(this.method){case"get":return c9.Get;case"post":return c9.Post;case"put":return c9.Put;case"delete":return c9.Delete;case"patch":return c9.Patch;case"head":return c9.Head;default:return}}convertParameters({breadcrumbs:t}){let r=[],n=[],i=[];if(!this.operation.parameters)return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:n,headers:i};for(let a of this.operation.parameters){let o=this.context.resolveMaybeReference({schemaOrReference:a,breadcrumbs:t});if(o==null)continue;let d=new H8s({context:this.context,breadcrumbs:t,parameter:o}).convert();if(d!=null)switch(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},d.type){case"path":r.push(d.parameter);break;case"query":n.push(d.parameter);break;case"header":{let s=d.parameter.name.name.originalName,u=d.parameter.name.wireValue,l=!1,m=this.context.authOverrides?.["auth-schemes"];if(m!=null){for(let P of Object.values(m))if(pPI(P)&&P.header.toLowerCase()===u.toLowerCase()){l=!0;break}}let A=this.context.globalHeaderNames;if(A!=null){for(let P of A)if(P.toLowerCase()===u.toLowerCase()){l=!0;break}}!cPI.has(s.toLowerCase())&&!l&&i.push(d.parameter);break}}}return this.checkMissingPathParameters(r),{pathParameters:r,queryParameters:n,headers:i}}checkMissingPathParameters(t){let n=[...this.path.matchAll(sPI)].map(i=>i[1]).filter(i=>!t.some(a=>a.name.originalName===i));for(let i of n){if(i==null)continue;let a=`${i}_example`;t.push({name:this.context.casingsGenerator.generateName(i),valueType:oO.STRING,docs:void 0,location:"ENDPOINT",variable:void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{[a]:this.generateStringParameterExample({example:i})}}})}}convertRequestBody({breadcrumbs:t,group:r,method:n,streamingExtension:i}){if(this.operation.requestBody==null)return;let a=this.context.resolveMaybeReference({schemaOrReference:this.operation.requestBody,breadcrumbs:t});if(a==null)return null;let o=[];for(let[c,d]of Object.entries(a.content)){let u=new G8s({context:this.context,breadcrumbs:t,contentType:c,mediaType:d,description:a.description,required:a.required,group:r??[],method:n,streamingExtension:i}).convert();u!=null&&(this.inlinedTypes={...this.inlinedTypes,...u.inlinedTypes},o.push({requestBody:u.requestBody,streamRequestBody:u.streamRequestBody,examples:u.examples}))}return o}computeGroupNameAndLocationFromExtensions(){let r=new Ube.SdkMethodNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.methodName,i=new Ube.SdkGroupNameExtension({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert()?.groups??[];if(r!=null)return{group:i,method:r}}evaluateMethodNameFromOperation(){let t=this.operation.operationId;return t??(this.operation.summary!=null?MA(this.operation.summary):MA(`${this.method}_${this.path.split("/").join("_")}`))}computeGroupNameFromTagAndOperationId(){let t=this.operation.tags?.[0],r=this.evaluateMethodNameFromOperation();if(t==null)return{method:r};let n=Zdv(t),i=Zdv(r);return Wue(n,i)?{method:t}:this.computeGroupAndMethodFromTokens({tag:t,tagTokens:n,methodName:r,methodNameTokens:i})}computeGroupAndMethodFromTokens({tag:t,tagTokens:r,methodName:n,methodNameTokens:i}){if(r.some((c,d)=>c!==i[d]))return{group:[t],method:n};let o=i.slice(r.length);return{group:[t],method:MA(o.join("_"))}}generateStringParameterExample({example:t}){let r=new Q4.ExampleConverter({breadcrumbs:this.breadcrumbs,context:this.context,schema:{type:"string"},example:t}),{validExample:n}=r.convert();return n}};function Zdv(e){let t=lPI(e)?fPI(e):dPI(e);return t=t.map(r=>r.toLowerCase()),t=hpt(t),t}function lPI(e){return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)}function fPI(e){return e.split(/(?=[A-Z])/)}function dPI(e){return e.split(/[^a-zA-Z0-9]+/)}function pPI(e){return e?.header!=null}var roo=class extends too{constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a}){super({context:t,breadcrumbs:r,operation:n,method:i,path:a})}convert(){if(this.operation.requestBody==null){this.context.errorCollector.collect({message:"Skipping webhook because no request body present",path:this.breadcrumbs});return}let t=this.convertHttpMethod();if(t==null)return;if(t!=="POST"&&t!=="GET"){this.context.errorCollector.collect({message:"Skipping webhook because non-POST or GET method",path:this.breadcrumbs});return}let{group:r,method:n}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),i=[...this.breadcrumbs,"Payload"],{headers:a}=this.convertParameters({breadcrumbs:i}),o=this.convertRequestBody({breadcrumbs:i,group:r,method:n,streamingExtension:void 0});if(o==null)return;let c=o[0]?.requestBody;if(c==null)return;let d;if(c.type==="inlinedRequestBody")d=Abe.inlinedPayload({name:c.name,extends:c.extends,properties:c.properties});else if(c.type==="reference")d=Abe.reference({payloadType:c.requestBodyType,docs:c.docs});else return;return{audiences:this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],group:r,webhook:{id:`${r?.join(".")??""}.${n}`,name:this.context.casingsGenerator.generateName(n),displayName:this.operation.summary,method:t,headers:a,payload:d,examples:[],availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),docs:this.operation.description,v2Examples:{autogeneratedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.autogeneratedExamples??{}),userSpecifiedExamples:this.getWebhookV2ExamplesFromRequestBodyV2Examples(c.v2Examples?.userSpecifiedExamples??{})}},inlinedTypes:this.inlinedTypes}}getWebhookV2ExamplesFromRequestBodyV2Examples(t){return Object.fromEntries(Object.entries(t).map(([r,n])=>[r,{name:r,payload:n}]))}};var c2f=fa(V8s(),1);var kdv=["get","post","put","delete","patch","head"];var J8s=class extends jC{operation;key="x-fern-idempotent";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-idempotent",path:this.breadcrumbs});return}return t}}};var _PI=rl.object({cursor:rl.string(),next_cursor:rl.string(),results:rl.string()}),hPI=rl.object({offset:rl.string(),results:rl.string(),step:rl.string().optional(),"has-next-page":rl.string().optional()}),u2f=rl.union([rl.boolean(),_PI,hPI]);var s2f="$request.",K8s="$response.",$8s=class extends jC{operation;document;key="x-fern-pagination";constructor({breadcrumbs:t,operation:r,document:n,context:i}){super({breadcrumbs:t,context:i}),this.operation=r,this.document=n}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=u2f.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean"){let n=this.getExtensionValue(this.document);if(n==null)return;if(typeof n=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.",path:this.breadcrumbs});return}let i=u2f.safeParse(n);if(!i.success){this.context.errorCollector.collect({message:`Invalid x-fern-pagination extension: ${i.error.message}`,path:this.breadcrumbs});return}if(typeof i.data=="boolean"){this.context.errorCollector.collect({message:"Global pagination extension is a boolean, expected an object.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:i.data})}if(typeof r.data=="boolean"){this.context.errorCollector.collect({message:"Pagination extension is a boolean with no global configuration.",path:this.breadcrumbs});return}return this.convertPaginationConfig({config:r.data})}convertPaginationConfig({config:t}){let r=t;if("cursor"in r)return{type:"cursor",cursor:Tee.maybeTrimPrefix(r.cursor,s2f),nextCursor:Tee.maybeTrimPrefix(r.next_cursor,K8s),results:Tee.maybeTrimPrefix(r.results,K8s)};let n=t;return{type:"offset",offset:Tee.maybeTrimPrefix(n.offset,s2f),results:Tee.maybeTrimPrefix(n.results,K8s),step:n.step!=null?Tee.maybeTrimPrefix(n.step,s2f):void 0,hasNextPage:n["has-next-page"]!=null?Tee.maybeTrimPrefix(n["has-next-page"],K8s):void 0}}};var yPI="$request.",vPI=rl.object({"stream-condition":rl.string().optional(),format:rl.enum(["sse","json"]).optional(),"stream-description":rl.string().optional(),"response-stream":rl.any(),response:rl.any()}),bPI=rl.union([rl.boolean(),vPI]),Y8s=class extends jC{operation;key="x-fern-streaming";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=bPI.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-streaming extension: ${r.error.message}`,path:this.breadcrumbs});return}if(typeof r.data=="boolean")return r.data?{type:"stream",format:"json"}:void 0;if(r.data["stream-condition"]==null&&r.data.format!=null)return{type:"stream",format:r.data.format};if(r.data["stream-condition"]==null){this.context.errorCollector.collect({message:"Missing stream-condition property without specified format.",path:this.breadcrumbs});return}return{type:"streamCondition",format:r.data.format??"json",streamDescription:r.data["stream-description"],streamConditionProperty:Tee.maybeTrimPrefix(r.data["stream-condition"],yPI),responseStream:r.data["response-stream"],response:r.data.response}}};var X8s=class extends jC{operation;key="x-fern-webhook";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-webhook",path:this.breadcrumbs});return}return t}}};var noo={of(e){return e}};var epv={SOURCE:noo.of("source"),SDK_NAMESPACE:noo.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:noo.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:noo.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:noo.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var Z8s=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let n=t[this.key];if(n!=null)return n;if(r!=null)return t[r]}};var k8s=class extends Z8s{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var e5s=class extends jC{operation;key="x-fern-examples";constructor({context:t,breadcrumbs:r,operation:n}){super({breadcrumbs:r,context:t}),this.operation=n}convert(){let t=this.getExtensionValue(this.operation);return t==null?void 0:(Array.isArray(t)?t:[]).filter(i=>{let a=YX.serialization.ExampleEndpointCallSchema.parse(i);return a.ok||this.context.errorCollector.collect({message:`Failed to parse x-fern-example in ${this.breadcrumbs.join(".")}`,path:this.breadcrumbs}),a.ok})}};var Heu=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{responseBody;statusCode;streamingExtension;constructor({context:t,breadcrumbs:r,responseBody:n,group:i,method:a,statusCode:o,streamingExtension:c}){super({context:t,breadcrumbs:r,group:i,method:a}),this.responseBody=n,this.statusCode=o,this.streamingExtension=c}convert(){return this.shouldConvertAsStreaming()?this.convertStreamingResponseBody():this.convertNonStreamingResponseBody()}convertStreamingResponseBody(){if(this.streamingExtension!=null){if(this.streamingExtension.type=="streamCondition"){let t=this.streamingExtension.responseStream,r=this.streamingExtension.response,n=[...this.group,this.method,"Response",this.statusCode].join("_"),i=`${n}_streaming`,a=this.parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:i}),o=this.parseMediaTypeSchemaOrReference({schemaOrReference:r,schemaId:n});return this.convertStreamConditionResponse({convertedStreamingSchema:a,convertedNonStreamingSchema:o})}if(this.streamingExtension.type==="stream"){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{});for(let n of r){let i=this.responseBody.content?.[n];if(i==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:i,schemaId:t,contentType:this.streamingExtension.format});if(a!=null)return this.convertStreamingResponse({mediaTypeObject:i,convertedSchema:a})}}}}convertNonStreamingResponseBody(){let t=[...this.group,this.method,"Response",this.statusCode].join("_"),r=Object.keys(this.responseBody.content??{}).filter(a=>a.includes("json"));for(let a of r){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null&&this.shouldReturnJsonResponse(a))return this.returnJsonResponse({mediaTypeObject:o,convertedSchema:c})}let n=Object.keys(this.responseBody.content??{}).filter(a=>!a.includes("json"));for(let a of n){let o=this.responseBody.content?.[a];if(o==null)continue;let c=this.parseMediaTypeObject({mediaTypeObject:o,schemaId:t,contentType:a});if(c!=null){if(this.isBinarySchema(c))return this.shouldReturnBytesResponse()?this.returnBytesResponse({mediaTypeObject:o}):this.returnFileDownloadResponse({mediaTypeObject:o});if(this.shouldReturnTextResponse(a))return this.returnTextResponse({mediaTypeObject:o})}}let i=parseInt(this.statusCode);if(!isNaN(i)&&i>=200&&i<300){let a={schema:{type:"object",description:"Empty response body"}},o=this.parseMediaTypeObject({mediaTypeObject:a,schemaId:t,contentType:"application/json",resolveSchema:!0});if(o!=null)return this.returnJsonResponse({mediaTypeObject:a,convertedSchema:o})}}convertStreamConditionResponse({convertedStreamingSchema:t,convertedNonStreamingSchema:r}){if(t==null||r==null)return;let n=this.responseBody.description;return this.streamingExtension?.type==="streamCondition"&&this.streamingExtension.streamDescription!=null&&(n=this.streamingExtension.streamDescription),{responseBody:oN.json(dde.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:r.schema?.typeDeclaration.v2Examples})),streamResponseBody:oN.streaming(pde.json({docs:n,payload:t.type,terminator:void 0,v2Examples:t.schema?.typeDeclaration.v2Examples})),inlinedTypes:{...t.inlinedTypes,...r.inlinedTypes}}}convertStreamingResponse({mediaTypeObject:t,convertedSchema:r}){if(this.streamingExtension==null)return;switch(this.streamingExtension.format){case"json":return{responseBody:oN.streaming(pde.json({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};case"sse":return{responseBody:oN.streaming(pde.sse({docs:this.responseBody.description,payload:r.type,terminator:void 0,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples};default:return}}returnJsonResponse({mediaTypeObject:t,convertedSchema:r}){return{responseBody:oN.json(dde.response({responseBodyType:r.type,docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})})),streamResponseBody:void 0,inlinedTypes:r.inlinedTypes,examples:r.examples}}returnBytesResponse({mediaTypeObject:t}){return{responseBody:oN.bytes({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnFileDownloadResponse({mediaTypeObject:t}){return{responseBody:oN.fileDownload({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}returnTextResponse({mediaTypeObject:t}){return{responseBody:oN.text({docs:this.responseBody.description,v2Examples:this.convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:!0,exampleGenerationStrategy:"response"})}),streamResponseBody:void 0,inlinedTypes:{}}}isBinarySchema(t){let r=t.type;switch(r.type){case"container":case"named":case"unknown":return!1;case"primitive":return r.primitive.v2==null?!1:r.primitive.v2.type==="string"&&r.primitive.v2.validation?.format==="binary";default:return!1}}shouldConvertAsStreaming(){return this.streamingExtension!=null}shouldReturnJsonResponse(t){return t.includes("json")}shouldReturnBytesResponse(){return this.context.settings.useBytesForBinaryResponse&&this.streamingExtension==null}shouldReturnTextResponse(t){return z7.parse(t)?.isText()??!1}};var t5s=class extends Q4.AbstractConverters.AbstractMediaTypeObjectConverter{responseError;statusCode;methodName;constructor({context:t,breadcrumbs:r,responseError:n,group:i,method:a,methodName:o,statusCode:c}){super({context:t,breadcrumbs:r,group:i,method:a}),this.responseError=n,this.statusCode=c,this.methodName=o}convert(){if(!this.responseError.content){let n=pXo[this.statusCode];if(n==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}let i=this.getErrorIdFromErrorName(n);return{error:{error:{name:this.context.casingsGenerator.generateName(i),fernFilepath:{allParts:[],packagePath:[],file:void 0},errorId:i},docs:this.responseError.description},errorType:mh.unknown(),displayName:n,statusCode:this.statusCode,inlinedTypes:{},examples:{}}}let t=Object.keys(this.responseError.content).filter(n=>n.includes("json")),r=pXo[this.statusCode];if(r==null){this.context.logger.warn(`No error name found for status code ${this.statusCode}`);return}for(let n of[...t]){let i=this.responseError.content?.[n];if(i==null)continue;let a=this.parseMediaTypeObject({mediaTypeObject:i,schemaId:tpv(`${this.methodName}Request${r}`),contentType:n});if(a==null)continue;let o=this.getErrorIdFromErrorName(r);if(a.schema!=null)return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.schema.typeDeclaration.name.fernFilepath,convertedSchema:a});if(a.type.type==="named")return this.constructErrorConverterOutput({errorName:r,errorId:o,fernFilepath:a.type.fernFilepath,convertedSchema:a})}}constructErrorConverterOutput({errorName:t,errorId:r,fernFilepath:n,convertedSchema:i}){return{error:{error:{name:this.context.casingsGenerator.generateName(r),fernFilepath:n,errorId:r},docs:this.responseError.description},errorType:i.type,displayName:t,statusCode:this.statusCode,inlinedTypes:i.inlinedTypes,examples:i.examples}}getErrorIdFromErrorName(t){return this.context.enableUniqueErrorsPerEndpoint?tpv(`${this.methodName}Request${t}`):t}};function tpv(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var r5s=class e extends too{idempotent;idToAuthScheme;topLevelServers;streamingExtension;static AUTHORIZATION_HEADER="Authorization";constructor({context:t,breadcrumbs:r,operation:n,method:i,path:a,idempotent:o,idToAuthScheme:c,topLevelServers:d,streamingExtension:s}){super({context:t,breadcrumbs:r,operation:n,method:i,path:a}),this.idempotent=o,this.idToAuthScheme=c,this.topLevelServers=d,this.streamingExtension=s}convert(){let t=this.convertHttpMethod();if(t==null)return;let{group:r,method:n}=this.computeGroupNameAndLocationFromExtensions()??this.computeGroupNameFromTagAndOperationId(),i=this.getGroupDisplayName(r),{headers:a,pathParameters:o,queryParameters:c}=this.convertParameters({breadcrumbs:[...this.breadcrumbs,"parameters"]}),d=this.convertRequestBody({breadcrumbs:[...this.breadcrumbs,"requestBody"],group:r,method:n,streamingExtension:this.streamingExtension}),s=d?.[0]?.requestBody,u=d?.[0]?.streamRequestBody,l={requestBodies:d?.map(be=>be.requestBody)},m=this.convertResponseBody({breadcrumbs:[...this.breadcrumbs,"responses"],group:r,method:n,streamingExtension:this.streamingExtension}),A=m?.response,P=m?.streamResponse,C=m!=null?m.errors:[],M={},T=C.map(be=>be.error),z=fZ(this.path),U=this.getEndpointBaseUrl(),R=this.getEndpointBaseUrls(),V=this.convertExamples({httpPath:z,httpMethod:t,baseUrl:U}),$=new Set(this.operation.security?.flatMap(be=>Object.keys(be))??[]),re=this.authSchemeToHeaders(Array.from($));re.length>0&&a.push(...re);for(let be of C){let me=be.error,he=be.errorType,Me=me.error.errorId,Be=be.examples;M[Me]={name:me.error,displayName:be.displayName,discriminantValue:{name:me.error.name,wireValue:Me},type:he,statusCode:be.statusCode,docs:me.docs,examples:[],v2Examples:{userSpecifiedExamples:Be??{},autogeneratedExamples:{}}}}let X=this.context.getAudiences({operation:this.operation,breadcrumbs:this.breadcrumbs})??[],ee={displayName:this.operation.summary,method:t,baseUrl:U,v2BaseUrls:R,path:z,pathParameters:o,queryParameters:c,headers:a.filter((be,me,he)=>me===he.findIndex(Me=>Me.name.wireValue===be.name.wireValue)),sdkRequest:void 0,errors:T,auth:this.operation.security!=null||this.context.spec.security!=null,security:this.operation.security??this.context.spec.security,availability:this.context.getAvailability({node:this.operation,breadcrumbs:this.breadcrumbs}),userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:this.idempotent??!1,basePath:void 0,fullPath:z,allPathParameters:o,pagination:void 0,transport:void 0,source:RPe.openapi(),audiences:X,retries:void 0},ne=this.context.namespace!=null?[this.context.namespace]:[],Oe=r?.map(be=>MA(be));return ne.push(...Oe??[]),{audiences:X,group:r,groupDisplayName:i,errors:M,endpoint:{...ee,id:`endpoint_${ne.join("/")}.${n}`,name:this.context.casingsGenerator.generateName(n),requestBody:s,v2RequestBodies:l,response:A,docs:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:V.examples},v2Responses:{responses:m?.v2Responses}},streamEndpoint:P!=null&&P.body!=null?{...ee,id:`endpoint_${ne.join("/")}.${n}_stream`,name:this.context.casingsGenerator.generateName(`${n}_stream`),requestBody:u,v2RequestBodies:void 0,response:P,docs:this.streamingExtension?.type==="streamCondition"?this.streamingExtension.streamDescription??this.operation.description:this.operation.description,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:V.streamExamples},v2Responses:{responses:[{statusCode:200,body:P.body}]}}:void 0,inlinedTypes:this.inlinedTypes,servers:this.filterOutTopLevelServers(this.operation.servers??[])}}convertResponseBody({breadcrumbs:t,group:r,method:n,streamingExtension:i}){if(this.operation.responses==null)return;let a,o=!1;for(let[c,d]of Object.entries(this.operation.responses)){let s=parseInt(c);if(!(isNaN(s)||s<200||s>=300&&s<400)){if(a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{}}),s>=200&&s<300){let u=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(u==null)continue;let m=new Heu({context:this.context,breadcrumbs:[...t,c],responseBody:u,group:r??[],method:n,statusCode:c,streamingExtension:i}).convert();m!=null&&(this.inlinedTypes={...this.inlinedTypes,...m.inlinedTypes},o||(o=!0,a.response={statusCode:s,body:m.responseBody},a.streamResponse={statusCode:s,body:m.streamResponseBody}),a.v2Responses=[...a.v2Responses??[],{statusCode:s,body:m.responseBody}])}if(s>=400&&s<600){let u=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:[...t,c]});if(u==null)continue;let m=new t5s({context:this.context,breadcrumbs:[...t,c],responseError:u,group:r??[],method:n,methodName:this.evaluateMethodNameFromOperation(),statusCode:s}).convert();m!=null&&(this.inlinedTypes={...this.inlinedTypes,...m.inlinedTypes},a.errors.push(m))}}}if(this.streamingExtension!=null){a==null&&(a={response:void 0,v2Responses:void 0,streamResponse:void 0,errors:[],examples:{}});let d=new Heu({context:this.context,breadcrumbs:[...t,"stream"],responseBody:{description:""},group:r??[],method:n,statusCode:"stream",streamingExtension:i}).convert();d!=null&&(this.inlinedTypes={...this.inlinedTypes,...d.inlinedTypes},a.response={statusCode:200,body:d.responseBody},a.streamResponse={statusCode:200,body:d.streamResponseBody},a.v2Responses=[{statusCode:200,body:d.responseBody}])}return a}authSchemeToHeaders(t){let r=[];for(let n of t){let i=this.idToAuthScheme?.[n];if(i==null)continue;let a={valueType:oO.STRING,availability:void 0,docs:void 0,env:void 0,v2Examples:void 0};switch(i.type){case"bearer":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"basic":r.push({name:{name:this.context.casingsGenerator.generateName(e.AUTHORIZATION_HEADER),wireValue:e.AUTHORIZATION_HEADER},...a});break;case"header":r.push({name:i.name,...a});break}}return r}convertExamples({httpPath:t,httpMethod:r,baseUrl:n}){let a=new e5s({context:this.context,breadcrumbs:this.breadcrumbs,operation:this.operation}).convert();return a==null?{examples:{},streamExamples:{}}:this.streamingExtension?.type==="streamCondition"?this.convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}):{examples:this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}),streamExamples:{}}}convertStreamConditionExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:i}){let a=i.filter(s=>!(s.response!=null&&"stream"in s.response)),o=i.filter(s=>s.response!=null&&"stream"in s.response),c=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:a}),d=this.convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:o});return{examples:c,streamExamples:d}}convertEndpointExamples({httpPath:t,httpMethod:r,baseUrl:n,fernExamples:i}){return Object.fromEntries(i.map((a,o)=>[this.getExampleName({example:a,exampleIndex:o}),{displayName:void 0,request:a.request!=null?{docs:void 0,endpoint:{method:r,path:this.buildExamplePath(t,a["path-parameters"]??{})},baseUrl:void 0,environment:n,auth:void 0,pathParameters:a["path-parameters"]??{},queryParameters:a["query-parameters"]??{},headers:a.headers??{},requestBody:a.request}:void 0,response:a.response!=null?{docs:void 0,statusCode:void 0,body:this.getExampleResponseBody({example:a})}:void 0,codeSamples:a["code-samples"]?.map(c=>{let d=("language"in c?c.language:c.sdk)??void 0;return{name:c.name,docs:void 0,language:d,code:c.code}})}]))}getExampleName({example:t,exampleIndex:r}){return t.name??t["code-samples"]?.[0]?.name??`Example_${r}`}getExampleResponseBody({example:t}){if(t.response!=null){if("stream"in t.response)return Jd.V2HttpEndpointResponseBody.stream(t.response.stream);if("body"in t.response)return Jd.V2HttpEndpointResponseBody.json(t.response.body)}}getEndpointBaseUrl(){let r=new k8s({breadcrumbs:this.breadcrumbs,operation:this.operation,context:this.context}).convert();if(r!=null)return this.context.logger.debug(`[getEndpointBaseUrl] Endpoint ${this.method.toUpperCase()} ${this.path} specifies a server with "${epv.SERVER_NAME_V2}" extension. Returning server type: ${r}`),r;let n=this.operation.servers?.[0];if(n==null)return;let a=this.topLevelServers?.find(o=>o.url===n.url)??n;return Ynt.getServerName({server:a,context:this.context})}getEndpointBaseUrls(){let t=this.operation.servers;return t?.map(n=>{let a=this.topLevelServers?.find(o=>o.url===n.url)??n;return Ynt.getServerName({server:a,context:this.context})})}buildExamplePath(t,r){return t.head+t.parts.map(n=>`${r[n.pathParameter]?.toString()??n.pathParameter}${n.tail}`).join("")}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers?.some(n=>n.url===r.url))}getGroupDisplayName(t){let r=this.operation.tags?.[0];r!=null&&(r=this.context.getDisplayNameForTag(r));let n=t?.[t.length-1];if(n!=null&&r!=null)return r.toLowerCase().replaceAll(" ","")===n?r:void 0}};var n5s=class extends oO{pathItem;path;idToAuthScheme;topLevelServers;constructor({context:t,breadcrumbs:r,pathItem:n,path:i,idToAuthScheme:a,topLevelServers:o}){super({context:t,breadcrumbs:r}),this.pathItem=n,this.path=i,this.idToAuthScheme=a,this.topLevelServers=o}convert(){let t=[],r=[],n={};for(let i of kdv){let a=this.pathItem[i];if(a==null)continue;let o=[...this.breadcrumbs,i],c=this.tryParseAsWebhook({operationBreadcrumbs:o,operation:a,method:i,context:this.context});if(c!=null){r.push(c),Object.assign(n,c.inlinedTypes);continue}let s=new Y8s({breadcrumbs:o,operation:a,context:this.context}).convert(),u=this.tryParseAsHttpEndpoint({operationBreadcrumbs:o,operation:a,method:i,streamingExtension:s});u!=null&&(t.push(u),Object.assign(n,u.inlinedTypes))}return{endpoints:t,webhooks:r,inlinedTypes:n}}tryParseAsWebhook({operation:t,method:r,operationBreadcrumbs:n,context:i}){return new X8s({breadcrumbs:n,operation:t,context:i}).convert()?new roo({context:this.context,breadcrumbs:n,operation:t,method:c2f.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path}).convert():void 0}tryParseAsHttpEndpoint({operation:t,method:r,operationBreadcrumbs:n,streamingExtension:i}){new $8s({breadcrumbs:n,operation:t,document:this.context.spec,context:this.context}).convert()!=null;let d=new J8s({breadcrumbs:n,operation:t,context:this.context}).convert();return new r5s({context:this.context,breadcrumbs:n,operation:t,method:c2f.OpenAPIV3.HttpMethods[r.toUpperCase()],path:this.path,idempotent:d,idToAuthScheme:this.idToAuthScheme,topLevelServers:this.topLevelServers,streamingExtension:i}).convert()}};var i5s=class extends oO{securityScheme;schemeId;constructor({context:t,breadcrumbs:r,securityScheme:n,schemeId:i}){super({context:t,breadcrumbs:r}),this.securityScheme=n,this.schemeId=i}convert(){switch(this.securityScheme.type){case"http":{if(this.securityScheme.scheme==="bearer")return N2.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description});if(this.securityScheme.scheme==="basic")return N2.basic({key:this.schemeId,username:this.context.casingsGenerator.generateName("username"),password:this.context.casingsGenerator.generateName("password"),usernameEnvVar:void 0,passwordEnvVar:void 0,docs:this.securityScheme.description});break}case"apiKey":{if(this.securityScheme.in==="header")return N2.header({key:this.schemeId,name:{name:this.context.casingsGenerator.generateName("apiKey"),wireValue:this.securityScheme.name},valueType:oO.OPTIONAL_STRING,prefix:void 0,headerEnvVar:void 0,docs:this.securityScheme.description});break}case"oauth2":return N2.bearer({key:this.schemeId,token:this.context.casingsGenerator.generateName("token"),tokenEnvVar:void 0,docs:this.securityScheme.description})}}};var Geu=class extends mqr{constructor({breadcrumbs:t,context:r,audiences:n}){super({breadcrumbs:t,context:r,audiences:n})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.context.spec=await this.resolveAllExternalRefs({spec:this.context.spec}),this.convertSecuritySchemes(),this.convertGlobalHeaders(),this.convertSchemas(),this.convertWebhooks();let{endpointLevelServers:t,errors:r}=this.convertPaths();this.addErrorsToIr(r);let{defaultUrl:n}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(n),this.finalizeIr()}convertGlobalHeaders(){this.context.globalHeaderOverrides;let r=new W8s({breadcrumbs:["x-fern-global-headers"],document:this.context.spec,context:this.context}).convert();if(r!=null){let n=Xdv({globalHeaders:r,context:this.context});this.addGlobalHeadersToIr(n),this.context.setGlobalHeaders(n)}}convertSecuritySchemes(){if(this.context.authOverrides){this.addAuthToIR(qIf({rawApiFileSchema:this.context.authOverrides,casingsGenerator:this.context.casingsGenerator}));return}let t=[];for(let[r,n]of Object.entries(this.context.spec.components?.securitySchemes??{})){let i=this.context.resolveMaybeReference({schemaOrReference:n,breadcrumbs:["components","securitySchemes",r]});if(i==null)continue;let o=new i5s({context:this.context,breadcrumbs:["components","securitySchemes",r],securityScheme:i,schemeId:r}).convert();o!=null&&t.push(o)}t.length>0&&this.addAuthToIR({requirement:t.length===1?"ALL":"ANY",schemes:t,docs:void 0})}convertServers({endpointLevelServers:t}){if(this.context.environmentOverrides){let i=sXo({rawApiFileSchema:this.context.environmentOverrides,casingsGenerator:this.context.casingsGenerator});return i!=null&&this.addEnvironmentsToIr({environmentConfig:i.environmentsConfig,audiences:i.audiences}),{defaultUrl:this.context.environmentOverrides["default-url"]}}let n=new Ynt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:n?.value}),{defaultUrl:n?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let i=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();i!=null&&this.addSchemaOutputToIr(t,i)}}convertWebhooks(){for(let[,t]of Object.entries(this.context.spec.webhooks??{})){if(t==null){this.context.errorCollector.collect({message:"Skipping empty webhook",path:this.breadcrumbs});continue}if(!("post"in t)){this.context.errorCollector.collect({message:"Skipping webhook as it is not a POST method",path:this.breadcrumbs});continue}if(t.post?.operationId==null){this.context.errorCollector.collect({message:"Skipping webhook as no operationId is present",path:this.breadcrumbs});continue}let r=t.post.operationId,i=new roo({context:this.context,breadcrumbs:["webhooks",r],operation:t.post,method:rpv.OpenAPIV3.HttpMethods.POST,path:r}).convert();i!=null&&(this.addWebhookToIr({webhook:i.webhook,operationId:r,audiences:i.audiences,group:i.group}),this.addTypesToIr(i.inlinedTypes))}}convertPaths(){let t=[],r={};for(let[n,i]of Object.entries(this.context.spec.paths??{})){if(i==null)continue;let o=new n5s({context:this.context,breadcrumbs:["paths",n],topLevelServers:this.context.spec.servers,pathItem:i,path:n}).convert();if(o!=null){for(let c of o.endpoints){if(c.streamEndpoint!=null&&this.addEndpointToIr({endpoint:c.streamEndpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),this.addEndpointToIr({endpoint:c.endpoint,audiences:c.audiences,endpointGroup:c.group,endpointGroupDisplayName:c.groupDisplayName}),c.servers)for(let d of c.servers)this.shouldAddServerToCollectedServers({server:d,currentServers:t})&&t.push(d);if(c.errors)for(let[d,s]of Object.entries(c.errors))r[d]=s}for(let c of o.webhooks){let d=this.context.getGroup({groupParts:c.group,namespace:this.context.namespace});this.addWebhookToIr({webhook:c.webhook,operationId:d.join("."),group:d,audiences:c.audiences})}this.addTypesToIr(o.inlinedTypes)}}return{endpointLevelServers:t,errors:r}}};var a5s=class extends jC{tag;key="x-displayName";constructor({breadcrumbs:t,tag:r,context:n}){super({breadcrumbs:t,context:n}),this.tag=r}convert(){if(typeof this.tag!="object"||this.tag==null)return;let t=this.tag[this.key];if(t!=null){if(typeof t!="string"){this.context.errorCollector.collect({message:"x-displayName extension must be a string",path:this.breadcrumbs});return}if(t.trim().length!==0)return{displayName:t}}}};var Jeu=class extends Tee{globalHeaderNames;tagToDisplayName={};isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;i==="reference_identifier"?c=n??o.value.title:i==="discriminator_key"?c=o.value.title??n:i==="schema_identifier"&&(c=o.value.title);let d;if(a.includes("/")){let u=new Q4.SchemaConverters.SchemaConverter({context:this,breadcrumbs:r??[],schema:o.value,id:a}).convert();u!=null&&(d={[a]:u.convertedSchema})}return{ok:!0,reference:mh.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,default:void 0,inline:!1,displayName:c}),inlinedTypes:d}}setGlobalHeaders(t){this.globalHeaderNames=t.map(r=>r.name.wireValue)}getDisplayNameForTag(t){if(Object.keys(this.tagToDisplayName).length===0)for(let r of this.spec.tags??[]){let i=new a5s({breadcrumbs:["tags",r.name],tag:r,context:this}).convert()?.displayName??r.name;this.tagToDisplayName[r.name]=i}return this.tagToDisplayName[t]??t}};var gPI=rl.object({description:rl.string().optional(),required:rl.boolean().optional(),deprecated:rl.boolean().optional(),allowEmptyValue:rl.boolean().optional(),style:rl.string().optional(),explode:rl.boolean().optional(),allowReserved:rl.boolean().optional(),schema:rl.any().optional(),example:rl.any().optional(),examples:rl.record(rl.string(),rl.any()).optional(),content:rl.record(rl.string(),rl.any()).optional()}),mPI=gPI.extend({name:rl.string(),in:rl.string()}),OPI=rl.array(mPI),o5s=class extends jC{operation;key="x-fern-parameters";constructor({breadcrumbs:t,operation:r,context:n}){super({breadcrumbs:t,context:n}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null)try{return OPI.parse(t)}catch(r){this.context.errorCollector.collect({message:`Failed to parse x-fern-parameters extension: ${r instanceof Error?r.message:String(r)}`,path:this.breadcrumbs});return}}};var u5s=class extends oO{method;pathParameters;queryParameters;headers;topLevelServers;constructor({context:t,breadcrumbs:r,method:n,pathParameters:i=[],queryParameters:a=[],headers:o=[],topLevelServers:c=[]}){super({context:t,breadcrumbs:r}),this.method=n,this.pathParameters=i,this.queryParameters=a,this.headers=o,this.topLevelServers=c}convert(){let t={},r="";for(let s of this.pathParameters)r+=`/{${s.name.originalName}}`;let n=fZ(r),i=[];for(let[s,u]of this.method.params.entries()){let l;if(this.context.isReferenceObject(u)){let C=this.context.resolveReference({reference:u});if(C.resolved)l=C.value;else continue}else l=u;let m=[this.method.name,"Param",l.name].join("_"),P=new Q4.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"Param",l.name],schemaIdOverride:m,context:this.context,schemaOrReference:l.schema,wrapAsOptional:!l.required}).convert();P!=null&&(i.push({docs:l.description,availability:this.context.getAvailability({node:u,breadcrumbs:[...this.breadcrumbs,"parameters"]}),name:this.context.casingsGenerator.generateNameAndWireValue({name:l.name,wireValue:l.name}),valueType:P.type,v2Examples:P.schema?.typeDeclaration.v2Examples,propertyAccess:void 0}),t={...P.inlinedTypes,...t,...P.schema!=null?{[m]:P.schema}:{}})}let a;if(this.method.result!=null){let s=this.context.resolveMaybeReference({schemaOrReference:this.method.result,breadcrumbs:[...this.breadcrumbs,"result"]});if(s!=null){let u=new Q4.SchemaConverters.SchemaOrReferenceConverter({breadcrumbs:[this.method.name,"result"],context:this.context,schemaOrReference:s.schema}),l=[this.method.name,"Result"].join("_"),m=u.convert();m!=null&&(a={docs:s.description,v2Examples:m.schema?.typeDeclaration.v2Examples,responseBodyType:m.type},t={...m.inlinedTypes,...t,...m.schema!=null?{[l]:m.schema}:{}})}}let o=this.getEndpointBaseUrls(),c=this.context.getAudiences({operation:this.method,breadcrumbs:this.breadcrumbs})??[];return{endpoint:{baseUrl:void 0,v2BaseUrls:o,basePath:void 0,auth:!1,security:void 0,method:"POST",id:this.method.name,docs:this.method.description,name:this.context.casingsGenerator.generateName(this.method.name),headers:this.headers,displayName:this.method.name,pathParameters:this.pathParameters,queryParameters:this.queryParameters,allPathParameters:this.pathParameters,path:n,fullPath:n,requestBody:i.length>0?F2.inlinedRequestBody({name:this.context.casingsGenerator.generateName([this.method.name,"Request"].join("_")),docs:void 0,properties:i,extends:[],extendedProperties:[],contentType:"application/json",extraProperties:!1,v2Examples:void 0}):void 0,v2RequestBodies:void 0,sdkRequest:void 0,response:a!=null?{body:oN.json(dde.response(a)),statusCode:void 0}:void 0,v2Responses:void 0,errors:[],idempotent:!1,pagination:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:this.convertExamples()},transport:void 0,availability:void 0,source:RPe.openrpc(),audiences:c,retries:void 0},audiences:c,inlinedTypes:t,servers:this.filterOutTopLevelServers(this.method.servers??[])}}filterOutTopLevelServers(t){return t.filter(r=>!this.topLevelServers.some(n=>n.url===r.url))}getEndpointBaseUrls(){let t=this.method.servers;return t?.map(n=>{if(this.topLevelServers.find(c=>c.name===n.name&&c.url!==n.url)!=null)return n.url;let o=this.topLevelServers.find(c=>c.url===n.url)??n;return Ynt.getServerName({server:o,context:this.context})})}convertExamples(){let t={},r=0;if(this.method.examples&&this.method.examples.length>0){for(let n of this.method.examples??[]){let i;if(this.context.isReferenceObject(n)){let d=this.context.resolveReference({reference:n});if(d.resolved)i=d.value;else continue}else i=n;let a;if(i.result)if(this.context.isReferenceObject(i.result)){let d=this.context.resolveReference({reference:i.result});d.resolved&&(a=d.value)}else a=i.result;let o=i.name??`Example ${r+1}`,c=[];if(i.params&&Array.isArray(i.params)){c=[];for(let d of i.params)if(this.context.isReferenceObject(d)){let s=this.context.resolveReference({reference:d});if(s.resolved)c.push(s.value);else continue}else c.push(d)}t[o]={displayName:void 0,request:{docs:void 0,endpoint:{method:"POST",path:"/{apiKey}"},baseUrl:void 0,environment:void 0,auth:void 0,pathParameters:{},queryParameters:{},headers:{},requestBody:c.map(d=>d.value)??void 0},response:{docs:void 0,statusCode:void 0,body:a?.value?Jd.V2HttpEndpointResponseBody.json({jsonrpc:"2.0",id:i.examplePairedRequest?.id||"1",result:a.value}):void 0},codeSamples:[]}}++r}return t}};var s5s=class extends Q4.AbstractConverters.AbstractParameterConverter{constructor({context:t,breadcrumbs:r,parameter:n}){super({context:t,breadcrumbs:r,parameter:n})}convert(){let t,r={};if(this.parameter.schema!=null){let i=new Q4.SchemaConverters.SchemaOrReferenceConverter({context:this.context,breadcrumbs:[...this.breadcrumbs,"schema"],schemaOrReference:this.parameter.schema,wrapAsOptional:this.parameter.required==null||!this.parameter.required}).convert();i!=null&&(t=i.type,r=i.inlinedTypes??{})}return this.convertToOutput({schema:this.parameter.schema??{type:"string"},typeReference:t,inlinedTypes:r})}};var Keu=class extends mqr{constructor({context:t,breadcrumbs:r,audiences:n}){super({context:t,breadcrumbs:r,audiences:n})}async convert(){this.context.spec=this.removeXFernIgnores({document:this.context.spec}),this.convertSchemas();let{endpointLevelServers:t}=this.convertMethods(),{defaultUrl:r}=this.convertServers({endpointLevelServers:t});return this.updateEndpointsWithDefaultUrl(r),this.finalizeIr()}convertServers({endpointLevelServers:t}){let n=new Ynt({context:this.context,breadcrumbs:["servers"],servers:this.context.spec.servers,endpointLevelServers:t}).convert();return this.addEnvironmentsToIr({environmentConfig:n?.value}),{defaultUrl:n?.defaultUrl}}convertSchemas(){for(let[t,r]of Object.entries(this.context.spec.components?.schemas??{})){let i=new Q4.SchemaConverters.SchemaConverter({context:this.context,id:t,breadcrumbs:["components","schemas",t],schema:r}).convert();i!=null&&this.addSchemaOutputToIr(t,i)}}convertMethods(){let t=[],n=new o5s({context:this.context,breadcrumbs:["methods"],operation:this.context.spec}).convert(),i=[],a=[],o=[];if(n&&n.length>0)for(let[d,s]of n.entries()){let l=new s5s({context:this.context,breadcrumbs:[...this.breadcrumbs,`x-fern-parameters[${d}]`],parameter:s}).convert();if(l!=null)switch(l.type){case"path":{i.push(l.parameter);break}case"query":{a.push(l.parameter);break}case"header":{o.push(l.parameter);break}}}let c=this.context.getGroup({groupParts:[],namespace:this.context.namespace});for(let d of this.context.spec.methods??[]){let s=this.context.resolveMaybeReference({schemaOrReference:d,breadcrumbs:["methods"]});if(s==null)continue;let l=new u5s({context:this.context,breadcrumbs:["methods"],method:s,pathParameters:i,queryParameters:a,headers:o,topLevelServers:this.context.spec.servers}).convert();if(l!=null&&(this.addEndpointToIr({endpoint:l.endpoint,audiences:l.audiences,endpointGroup:c,serviceName:"service_root"}),this.addTypesToIr(l.inlinedTypes),l.servers))for(let m of l.servers)this.shouldAddServerToCollectedServers({server:m,currentServers:t,specType:"openrpc"})&&t.push(this.maybeDeduplicateServerName(m))}return{endpointLevelServers:t}}maybeDeduplicateServerName(t){return this.context.spec.servers?.find(n=>n.name===t.name&&n.url!==t.url)?{...t,name:t.url}:t}};var $eu=class extends Tee{isReferenceObject(t){return t!=null&&"$ref"in t}convertReferenceToTypeReference({reference:t,breadcrumbs:r,displayNameOverride:n,displayNameOverrideSource:i}){let a=this.getTypeIdFromSchemaReference(t);if(a==null)return{ok:!1};let o=this.resolveReference({reference:t,breadcrumbs:r});if(!o.resolved)return{ok:!1};let c;return i==="reference_identifier"?c=n??o.value.title:(i==="discriminator_key"||i==="schema_identifier")&&(c=o.value.title??n),{ok:!0,reference:mh.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(a),typeId:a,displayName:c,default:void 0,inline:!1})}}};var H_v=require("fs/promises");var npv={[JP.GenerationLanguage.PHP]:new Set(["abstract","and","as","break","callable","case","catch","class","clone","const","continue","declare","default","do","echo","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","extends","final","finally","fn","for","foreach","function","global","goto","list","if","implements","include","include_once","instanceof","insteadof","interface","match","namespace","new","or","parent","Parent","print","private","protected","public","readonly","require","require_once","return","static","switch","throw","trait","try","use","var","while","xor","yield"].flatMap(e=>[e,n9(e)])),[JP.GenerationLanguage.TYPESCRIPT]:new Set(["any","as","boolean","break","case","catch","class","const","constructor","continue","debugger","declare","default","delete","do","else","enum","export","extends","false","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","module","new","null","number","of","package","private","protected","public","require","return","set","static","string","super","switch","symbol","this","throw","true","try","type","typeof","var","void","while","with","yield","Date","Error","File","Object","Record"]),[JP.GenerationLanguage.JAVA]:new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","false","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","try","void","volatile","while"]),[JP.GenerationLanguage.PYTHON]:new Set(["False","None","True","and","as","assert","async","","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","float","int","complex","bool","uuid","list","set","map","long","self","all","kwargs"]),[JP.GenerationLanguage.GO]:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","vendor","any","bool","byte","complex64","complex128","error","float32","float64","int","int8","int16","int32","int64","make","new","rune","string","uint","uint8","uint16","uint32","uint64","uintptr"]),[JP.GenerationLanguage.RUBY]:new Set(["__ENCODING__","__LINE__","__FILE__","alias","and","begin","break","case","class","def","defined","do","else","elsif","end","ensure","false","for","if","in","module","next","nil","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","Object","JSON","Date","DateTime","object_id","hash","eql?","equal?","method","send","respond_to?","respond_to_missing?","instance_of?","kind_of?","is_a?","extend","singleton_class","instance_variables","instance_variable_get","instance_variable_set","instance_variable_defined?","remove_instance_variable","public_methods","private_methods","protected_methods","singleton_methods"]),[JP.GenerationLanguage.CSHARP]:new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while","add","and","alias","ascending","args","async","","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","managed","nameof","nint","not","notnull","nuint","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value","var","when","where","with","yield"]),[JP.GenerationLanguage.RUST]:new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","union","unsafe","use","where","while","abstract","become","box","do","final","macro","override","priv","try","typeof","unsized","virtual","yield","bool","char","f32","f64","i8","i16","i32","i64","i128","isize","str","u8","u16","u32","u64","u128","usize","String","Vec","Option","Result","Box","Rc","Arc","Cell","RefCell","HashMap","HashSet","BTreeMap","BTreeSet"]),[JP.GenerationLanguage.SWIFT]:new Set([])};var API=["go","ruby"];function f5s({generationLanguage:e,keywords:t,smartCasing:r}){let n={generateName:(i,a)=>{let o=l=>({unsafeName:l,safeName:PPI({name:l,keywords:wPI({generationLanguage:e,keywords:t})})}),c=MA(i),d=n9(c),s=baa(i),u=_aa(c);return r&&(!SPI(u)&&(e==null||API.includes(e))&&(c=u.map((l,m)=>{if(m>0){let A=c5s(l);if(A!=null)return A;if(l5s(l))return l.toUpperCase()}return l}).join(""),d=n9(u.map((l,m)=>{let A=c5s(l);return A??(l5s(l)?l.toUpperCase():m===0?n9(l):l)}).join(""))),s=i.split(" ").map(l=>l.split(/(\d+)/).map(baa).join("")).join("_")),{originalName:i,camelCase:o(a?.casingOverrides?.camel??c),snakeCase:o(a?.casingOverrides?.snake??s),screamingSnakeCase:o(a?.casingOverrides?.["screaming-snake"]??s.toUpperCase()),pascalCase:o(a?.casingOverrides?.pascal??d)}},generateNameAndWireValue:({name:i,wireValue:a,opts:o})=>({name:n.generateName(i,o),wireValue:a})};return n}function PPI({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":EPI(e)?"_"+e:e}function wPI({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return npv[e]}var jPI=/^[0-9]/;function EPI(e){return jPI.test(e)}function SPI(e){return e.some((t,r)=>{if(r===0)return!1;let n=e[r-1];if(n==null)return!1;let i=c5s(n)!=null||l5s(n),a=c5s(t)!=null||l5s(t);return i&&a})}function c5s(e){return CPI.get(e.toUpperCase())}function l5s(e){return DPI.has(e.toUpperCase())}var DPI=new Set(["ACL","API","ASCII","CPU","CSS","DNS","EOF","GUID","HTML","HTTP","HTTPS","ID","IP","JSON","LHS","QPS","RAM","RHS","RPC","SAML","SCIM","SLA","SMTP","SQL","SSH","SSO","TCP","TLS","TTL","UDP","UI","UID","UUID","URI","URL","UTF8","VM","XML","XMPP","XSRF","XSS"]),CPI=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var ipv=require("fs/promises");async function l2f({context:e,absoluteFilePath:t,absoluteFilePathToOverrides:r}){let n=(await(0,ipv.readFile)(t)).toString(),i;try{i=JSON.parse(n)}catch{i=Vg.load(n)}return r!=null?await Xao({absoluteFilePathToOverrides:r,context:e,data:i}):i}var B_v=fa(M_v(),1);function M8i(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...o}={}){let c=i.reduce((s,u)=>({...s,[u]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[s,u]of Object.entries(c))d=d.replaceAll(s,u);return e?.debug(`+ ${d}`),(0,B_v.default)(t,r,o)}async function MH(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...o}={}){let c=M8i(e,t,r,{doNotPipeOutput:n,secrets:i,substitutions:a,...o});n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr));let d=await c;return d.stdout==null&&(d.stdout=""),d.stderr==null&&(d.stderr=""),d}function B8i(e,{logger:t,...r}={}){return(n,i)=>MH(t,e,n,{...r,...i})}var bit=require("fs/promises"),L_v=fa(require("path"),1),S2f=fa(OCe(),1);var T_v="buf.gen.yaml",AjI="output",q_v=`${AjI}/ir.json`,R_v="protoc-gen-fern",N_v=`version: v1
|
|
2414
2415
|
`,F_v=`version: v2
|
|
2415
2416
|
`,g5s=e=>{let t=`version: v1
|
|
2416
2417
|
`;if(e.length>0){t+=`deps:
|
|
@@ -3037,7 +3038,7 @@ ${l}`)}async function fMM(e){await MH(void 0,"docker",["pull",e],{all:!0,doNotPi
|
|
|
3037
3038
|
|
|
3038
3039
|
If you believe this is an error, please contact support@buildwithfern.com`),orgNotConfiguredForWhitelabel:()=>a.failAndThrow("Your org is not configured for white-labeling. Please reach out to support@buildwithfern.com."),_other:P=>(a.logger.debug(`Failed to create job: ${JSON.stringify(P)}`),a.failAndThrow("Failed to create job. Please try again or contact support@buildwithfern.com for assistance."))})}async function Z9E({absolutePathToDefinitionDirectory:e,definition:t}){for(let[r,n]of Object.entries(t.namedDefinitionFiles)){let i=Jl(e,ys.of(r));await(0,Ske.mkdir)(Ug(i),{recursive:!0}),await(0,Ske.writeFile)(i,Vg.dump(n.contents))}for(let[r,n]of Object.entries(t.packageMarkers))if(n.contents.export==null){let i=Jl(e,ys.of(r));await(0,Ske.mkdir)(Ug(i),{recursive:!0}),await(0,Ske.writeFile)(i,Vg.dump(n.contents))}for(let[r,n]of Object.entries(t.importedDefinitions))await Z9E({absolutePathToDefinitionDirectory:Jl(e,ys.of(r)),definition:n.definition})}async function RXQ({intermediateRepresentation:e,generatorInvocation:t,job:r,context:n,irVersionOverride:i}){let a=await Zua(t).then(l=>l==null?void 0:"v"+l.toString()),o=i??a,c=o==null?await KFu({intermediateRepresentation:e,context:n,targetGenerator:{name:t.name,version:t.version}}):await uL_({intermediateRepresentation:e,context:n,irVersion:o,targetGenerator:{name:t.name,version:t.version}}),d=new J9E.default,s=await Okl(c,{onWrite:l=>{n.logger.debug("Wrote IR to disk: "+l)}});d.append("file",s);let u=jD(Ucf(),`/api/remote-gen/jobs/${r.jobId}/start`);try{await rZ.post(u,d,{headers:d.getHeaders(),maxBodyLength:1/0})}catch(l){let m=l instanceof Vwy?l.response?.data:l;n.logger.debug(`POST ${u} failed with ${JSON.stringify(l)}`),n.failAndThrow("Failed to start job",m)}}function NXQ(e){if(e?.reason==="status-code"){let t=e.body;switch(t?._error){case"IllegalApiNameError":return oRo.FernFiddle.remoteGen.createJobV3.Error.illegalApiNameError();case"GeneratorsDoNotExistError":return oRo.FernFiddle.remoteGen.createJobV3.Error.generatorsDoNotExistError(t.body);case"CannotPublishToNpmScope":return oRo.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToNpmScope(t.body);case"CannotPublishToMavenScope":return oRo.FernFiddle.remoteGen.createJobV3.Error.cannotPublishToMavenGroup(t.body);case"InsufficientPermissions":return oRo.FernFiddle.remoteGen.createJobV3.Error.insufficientPermissions(t.body)}}return e}function FXQ({outputMode:e,generatorInvocation:t,absolutePathToPreview:r,shouldLogS3Url:n}){return e.type==="downloadFiles"||t.absolutePathToLocalSnippets!=null||r!=null||n}function Q0l({apiName:e,organization:t,generatorInvocation:r}){let n=xXQ(r);return{apiName:e,organization:t,customConfig:r.config,outputConfig:n??ef.GeneratorOutputConfig.local()}}function xXQ(e){let t=e.outputMode;switch(t.type){case"downloadFiles":return ef.GeneratorOutputConfig.local();case"publishV2":return zXQ({publish:t.publishV2,version:e.version});case"githubV2":return QXQ({github:t.githubV2,language:e.language,version:e.version});case"publish":case"github":return;default:tc(t)}}function zXQ({publish:e,version:t}){switch(e.type){case"npmOverride":{let r=e.npmOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.npm({version:t,packageName:r.packageName,repoUrl:void 0}))}case"mavenOverride":{let r=e.mavenOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.maven({version:t,coordinate:r.coordinate,repoUrl:void 0}))}case"pypiOverride":{let r=e.pypiOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.pypi({version:t,packageName:r.coordinate,repoUrl:void 0}))}case"rubyGemsOverride":{let r=e.rubyGemsOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.rubygems({version:t,packageName:r.packageName,repoUrl:void 0}))}case"nugetOverride":{let r=e.nugetOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.nuget({version:t,packageName:r.packageName,repoUrl:void 0}))}case"cratesOverride":{let r=e.cratesOverride;return r==null?void 0:ef.GeneratorOutputConfig.publish(ef.PublishInfo.crates({version:t,packageName:r.packageName,repoUrl:void 0}))}case"postman":return;default:tc(e)}}function QXQ({github:e,version:t,language:r}){let n=LXQ({owner:e.owner,repo:e.repo});if(r===JP.GenerationLanguage.GO)return ef.GeneratorOutputConfig.publish(ef.PublishInfo.go({version:t,repoUrl:n}));let i=e.publishInfo;if(i!=null)switch(i.type){case"maven":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.maven({version:t,coordinate:i.coordinate,repoUrl:n}));case"npm":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.npm({version:t,packageName:i.packageName,repoUrl:n}));case"pypi":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.pypi({version:t,packageName:i.packageName,repoUrl:n}));case"rubygems":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.rubygems({version:t,packageName:i.packageName,repoUrl:n}));case"nuget":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.nuget({version:t,packageName:i.packageName,repoUrl:n}));case"crates":return ef.GeneratorOutputConfig.publish(ef.PublishInfo.crates({version:t,packageName:i.packageName,repoUrl:n}));case"postman":return;default:tc(i)}}function LXQ({owner:e,repo:t}){return`https://github.com/${e}/${t}`}var k9E=oAi();var UXQ=3;function eVE({job:e,taskId:t,taskHandler:r,context:n}){let i=0,a=async()=>{let o=await k9E.remoteGen.getJobStatus(e.jobId);if(o.ok)return o.body[t];n.logger.debug("Failed to get job status.",JSON.stringify(o.error.content))};return new Promise((o,c)=>{d();async function d(){try{let s=await a();if(s==null)i++,i===UXQ&&n.failAndThrow(`Failed to get job status after ${i} attempts.`),setTimeout(d,2e3+1e3*i);else{i=0;let u=await r.processUpdate(s);r.isFinished?o(u):setTimeout(d,2e3)}}catch(s){c(s)}}})}var iVE=fa(_Gs(),1),aVE=require("fs"),V0l=require("fs/promises"),lL_=fa(require("path"),1),oVE=require("stream/promises");var L0l=fa(nVE(),1);function BBi(e,t,{target:r="stdout",...n}={}){return L0l.default[r]?sno.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}BBi.isSupported=L0l.default.stdout;BBi.stderr=(e,t,r={})=>BBi(e,t,{target:"stderr",...r});BBi.stderr.isSupported=L0l.default.stderr;var uVE=fa(OCe(),1),U0l=class{context;generatorInvocation;absolutePathToPreview;lengthOfLastLogs=0;constructor({interactiveTaskContext:t,generatorInvocation:r,absolutePathToPreview:n}){this.context=t,this.generatorInvocation=r,this.absolutePathToPreview=n}async processUpdate(t){t==null&&this.context.failAndThrow("Task is missing on job status");let r=t.packages.map(i=>i.coordinate._visit({npm:a=>`${a.name}@${a.version}`,maven:a=>`${a.group}:${a.artifact}:${a.version}`,pypi:a=>`${a.name} ${a.version}`,ruby:a=>`${a.name}:${a.version}`,nuget:a=>`${a.name} ${a.version}`,crates:a=>`${a.name} ${a.version}`,_other:()=>"<unknown package>"}));this.absolutePathToPreview==null&&this.context.setSubtitle(r.length>0?r.map(i=>`\u25E6 ${i}`).join(`
|
|
3039
3040
|
`):void 0);for(let i of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(GXQ(i.level),i.message);this.lengthOfLastLogs=t.logs.length;let n=i=>{this.context.logger.debug(`Generated files. ${BBi("View here",i,{fallback:(a,o)=>`${a}: ${o}`})}`)};return await t.status._visit({notStarted:Hc,running:Hc,failed:({message:i,s3PreSignedReadUrl:a})=>{a!=null&&n(a),this.context.failAndThrow(i)},finished:async i=>{if(i.s3PreSignedReadUrlV2!=null){n(i.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await WXQ({s3PreSignedReadUrl:i.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);this.#e=!0,this.#t=i.createdSnippets!=null?i.createdSnippets:!1,this.#r=i.snippetsS3PreSignedReadUrl},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),this.#e?{createdSnippets:this.#t,snippetsS3PreSignedReadUrl:this.#r}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?Jl(this.absolutePathToPreview,ys.of(lL_.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}#e=!1;get isFinished(){return this.#e}#t=!1;get createdSnippets(){return this.#t}#r=void 0;get snippetsS3PreSignedReadUrl(){return this.#r}};async function WXQ({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await HXQ({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(od.green(`Downloaded to ${t}`))}catch(n){r.failAndThrow("Failed to download files",n)}}async function HXQ({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await rZ.get(e,{responseType:"stream"}),n=await uVE.default.dir({prefix:"fern",unsafeCleanup:!0}),i=lL_.default.join(n.path,"output.zip");await(0,oVE.pipeline)(r.data,(0,aVE.createWriteStream)(i)),await Tv(t)&&await(0,V0l.rm)(t,{recursive:!0}),await(0,V0l.mkdir)(t,{recursive:!0}),await(0,iVE.default)(i,t)}function GXQ(e){switch(e){case"DEBUG":return K1.Debug;case"INFO":return K1.Info;case"WARN":return K1.Warn;case"ERROR":return K1.Error;default:return K1.Info}}var H0l=require("fs/promises"),sVE=fa(OCe(),1),JXQ="proto.zip",W0l=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(n=>[n.id,n])),this.sourceTypes=new Set(Object.values(this.sources).map(n=>n.type))}async uploadSources(t){for(let[r,n]of Object.entries(t)){let i=this.getSourceOrThrow(r);await this.uploadSource(i,n.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let n=await this.getUploadCommand(t),i=await(0,H0l.readFile)(n.absoluteFilePath),a=await fetch(r,{method:"PUT",body:i,headers:{"Content-Type":"application/octet-stream"}});await n.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,H0l.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await sVE.default.dir(),n=Jl(x_.of(r.path),ys.of(JXQ));return this.context.logger.debug(`Zipping source ${t} into ${n}`),await MH(this.context.logger,"zip",["-r",n,"."],{cwd:t,doNotPipeOutput:!0}),n}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[n,i]of Object.entries(t))switch(this.getSourceOrThrow(n).type){case"protobuf":r.push(sxe.proto({id:n,protoRootUrl:i.downloadUrl}));continue;case"openapi":r.push(sxe.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};async function cVE({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:n,generatorInvocation:i,version:a,audiences:o,shouldLogS3Url:c,token:d,whitelabel:s,irVersionOverride:u,absolutePathToPreview:l,readme:m}){let A=Xua({token:d.value}),P=JP.getPackageName({generatorInvocation:i}),C=l!=null,M=Me=>Yxi(Me,{onError:Be=>n.failAndThrow(Be)},{substituteAsEmpty:C}),T=M(i),z=Q0l({apiName:r.definition.rootApiFile.contents.name,organization:t,generatorInvocation:T}),U=qH({workspace:r,generationLanguage:i.language,keywords:i.keywords,smartCasing:i.smartCasing,exampleGeneration:{disabled:i.disableExamples,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!1},audiences:o,readme:m,packageName:P,version:a??await $XQ({fdr:A,packageName:P,generatorInvocation:i}),context:n,sourceResolver:new BH(n,r),dynamicGeneratorConfig:z}),V=await UCe({token:d.value}).organization.get(nR.OrganizationId(e.organization));V.ok&&V.body.isWhitelabled&&(U.readmeConfig==null&&(U.readmeConfig=XXQ),U.readmeConfig.whiteLabel=!0);let $=r.getSources(),re=DIe({ir:U,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},context:n}),X=await A.api.v1.register.registerApiDefinition({orgId:fL_.FernRegistry.OrgId(t),apiId:fL_.FernRegistry.ApiId(U.apiName.originalName),definition:re,sources:$.length>0?YXQ($):void 0}),ee,ne;X.ok&&(ee=X.body.apiDefinitionId,ne=X.body.sources);let Oe=new W0l(n,$);if(ne==null&&Oe.sourceTypes.has("protobuf")&&(X.ok||n.failAndThrow(`Failed to register API definition: ${JSON.stringify(X.error.content)}`),n.failAndThrow("Did not successfully upload Protobuf source files.")),ne!=null){n.logger.debug("Uploading source files ...");let Me=await Oe.uploadSources(ne);n.logger.debug("Setting IR source configuration ..."),U.sourceConfig=Me}let be=await X9E({projectConfig:e,workspace:r,organization:t,generatorInvocation:T,context:n,version:a,intermediateRepresentation:{...U,fdrApiDefinitionId:ee,publishConfig:KXQ({generatorInvocation:T})},shouldLogS3Url:c,token:d,whitelabel:s!=null?M(s):void 0,irVersionOverride:u,absolutePathToPreview:l});n.logger.debug(`Job ID: ${be.jobId}`);let me=be.taskIds[0];if(me==null){n.failAndThrow("Did not receive a task ID.");return}n.logger.debug(`Task ID: ${me}`);let he=new U0l({job:be,taskId:me,generatorInvocation:i,interactiveTaskContext:n,absolutePathToPreview:l});return await eVE({job:be,taskHandler:he,taskId:me,context:n})}function KXQ({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},cratesOverride:()=>{},postman:r=>{let n;return e.raw?.output?.location==="postman"&&(n=e.raw.output?.["collection-id"]),Jd.PublishingConfig.direct({target:Jd.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:n})})},_other:()=>{}}),_other:()=>{}})}async function $XQ({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let n;switch(r.language){case"csharp":n="Csharp";break;case"go":n="Go";break;case"java":n="Java";break;case"python":n="Python";break;case"ruby":n="Ruby";break;case"typescript":n="TypeScript";break;case"php":n="Php";break;case"swift":n="Swift";break;default:return}if(t==null)return;let i=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:n,package:t});if(i.ok)return i.body.version}function YXQ(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}var XXQ={defaultEndpoint:void 0,bannerLink:void 0,introduction:void 0,apiReferenceLink:void 0,apiName:void 0,disabledFeatures:void 0,whiteLabel:void 0,customSections:void 0,features:void 0,exampleStyle:void 0};async function dL_({projectConfig:e,organization:t,workspace:r,context:n,generatorGroup:i,version:a,shouldLogS3Url:o,token:c,whitelabel:d,absolutePathToPreview:s,mode:u}){if(i.generators.length===0)return n.logger.warn("No generators specified."),null;let l=[],m=[];return l.push(...i.generators.map(P=>n.runInteractiveTask({name:P.name},async C=>{let M=rao(P),T=await r.toFernWorkspace({context:n},M),z=await cVE({projectConfig:e,organization:t,workspace:T,interactiveTaskContext:C,generatorInvocation:{...P,outputMode:P.outputMode._visit({downloadFiles:()=>P.outputMode,github:U=>G0l.FernFiddle.OutputMode.github({...U,makePr:u==="pull-request"}),githubV2:U=>u==="pull-request"?G0l.FernFiddle.OutputMode.githubV2(G0l.FernFiddle.GithubOutputModeV2.pullRequest(U)):P.outputMode,publish:()=>P.outputMode,publishV2:()=>P.outputMode,_other:()=>P.outputMode})},version:a,audiences:i.audiences,shouldLogS3Url:o,token:c,whitelabel:d,readme:P.readme,irVersionOverride:P.irVersionOverride,absolutePathToPreview:s});z!=null&&z.createdSnippets&&(m.push(P),P.absolutePathToLocalSnippets!=null&&z.snippetsS3PreSignedReadUrl!=null&&await G9E({snippetsS3PreSignedReadUrl:z.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:P.absolutePathToLocalSnippets,context:C}))}))),(await Promise.all(l)).some(P=>!P)&&n.failAndThrow(),{snippetsProducedBy:m}}var zyi=fa(ynt(),1);var AWE=require("fs/promises");var VL_=fa(wYa(),1);var sRo=(e,t,r)=>JSON.stringify(e,t,r);function YFu(e,t){return JSON.parse(e,t)}var zp=class e extends Error{constructor({message:t,statusCode:r,body:n,rawResponse:i}){super(ZXQ({message:t,statusCode:r,body:n})),Object.setPrototypeOf(this,e.prototype),this.statusCode=r,this.body=n,this.rawResponse=i}};function ZXQ({message:e,statusCode:t,body:r}){let n=[];return e!=null&&n.push(e),t!=null&&n.push(`Status code: ${t.toString()}`),r!=null&&n.push(`Body: ${sRo(r,void 0,2)}`),n.join(`
|
|
3040
|
-
`)}var tw=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};var iE=class e extends zp{constructor(t,r){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:r}),Object.setPrototypeOf(this,e.prototype)}};var kXQ={arrayFormat:"indices",encode:!0};function lVE(e,t){if(e===void 0||e===null)return"";let r=String(e);return t?encodeURIComponent(r):r}function pL_(e,t="",r){let n=[];for(let[i,a]of Object.entries(e)){let o=t?`${t}[${i}]`:i;if(a!==void 0)if(Array.isArray(a)){if(a.length===0)continue;for(let c=0;c<a.length;c++){let d=a[c];if(d!==void 0)if(typeof d=="object"&&!Array.isArray(d)&&d!==null){let s=r.arrayFormat==="indices"?`${o}[${c}]`:o;n.push(...pL_(d,s,r))}else{let s=r.arrayFormat==="indices"?`${o}[${c}]`:o,u=r.encode?encodeURIComponent(s):s;n.push(`${u}=${lVE(d,r.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;n.push(...pL_(a,o,r))}else{let c=r.encode?encodeURIComponent(o):o;n.push(`${c}=${lVE(a,r.encode)}`)}}return n}function J0l(e,t){return e==null||typeof e!="object"?"":pL_(e,"",Object.assign(Object.assign({},kXQ),t)).join("&")}function fVE(e,t){let r=J0l(t,{arrayFormat:"repeat"});return r?`${e}?${r}`:e}function dVE(e){let t={get bodyUsed(){return e.bodyUsed},stream:()=>e.body,arrayBuffer:e.arrayBuffer.bind(e),blob:e.blob.bind(e)};return"bytes"in e&&typeof e.bytes=="function"&&(t.bytes=e.bytes.bind(e)),t}function pVE(e){return e.body!=null}var eZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function K0l(e,t){return eZQ(this,void 0,void 0,function*(){if(!pVE(e))return;switch(t){case"binary-response":return dVE(e);case"blob":return yield e.blob();case"arrayBuffer":return yield e.arrayBuffer();case"sse":return e.body;case"streaming":return e.body;case"text":return yield e.text()}let r=yield e.text();if(r.length>0)try{return YFu(r)}catch{return{ok:!1,error:{reason:"non-json",statusCode:e.status,rawBody:r}}}})}var tZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function _VE(e){return tZQ(this,void 0,void 0,function*(){var t,r,n;let i=(t=e.headers.get("Content-Type"))===null||t===void 0?void 0:t.toLowerCase();if(i==null||i.length===0)return K0l(e);switch(i.indexOf(";")!==-1&&(i=(n=(r=i.split(";")[0])===null||r===void 0?void 0:r.trim())!==null&&n!==void 0?n:""),i){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":let a=yield e.text();return a.length>0?YFu(a):void 0;default:if(i.startsWith("application/vnd.")&&i.endsWith("+json")){let o=yield e.text();return o.length>0?YFu(o):void 0}return yield e.text()}})}var rZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function hVE(){return rZQ(this,void 0,void 0,function*(){return fetch})}var nZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function yVE(e){return nZQ(this,arguments,void 0,function*({body:t,type:r}){return r.includes("json")?sRo(t):t})}var iZQ="timeout";function vVE(e){let t=new AbortController,r=setTimeout(()=>t.abort(iZQ),e);return{signal:t.signal,abortId:r}}function bVE(...e){let t=e.length===1&&Array.isArray(e[0])?e[0]:e,r=new AbortController;for(let n of t){if(n.aborted){r.abort(n?.reason);break}n.addEventListener("abort",()=>r.abort(n?.reason),{signal:r.signal})}return r.signal}var aZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},gVE=(e,t,r,n,i,a,o,c,d)=>aZQ(void 0,void 0,void 0,function*(){let s=[],u;if(a!=null){let{signal:A,abortId:P}=vVE(a);u=P,s.push(A)}o!=null&&s.push(o);let l=bVE(s),m=yield e(t,{method:r,headers:n,body:i,signal:l,credentials:c?"include":void 0,duplex:d});return u!=null&&clearTimeout(u),m});var XFu;typeof globalThis.Headers<"u"?XFu=globalThis.Headers:XFu=class mVE{constructor(t){if(this.headers=new Map,t)if(t instanceof mVE)t.forEach((r,n)=>this.append(n,r));else if(Array.isArray(t))for(let[r,n]of t)if(typeof r=="string"&&typeof n=="string")this.append(r,n);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[r,n]of Object.entries(t))if(typeof n=="string")this.append(r,n);else throw new TypeError("Header values must be strings")}append(t,r){let n=t.toLowerCase(),i=this.headers.get(n)||[];this.headers.set(n,[...i,r])}delete(t){let r=t.toLowerCase();this.headers.delete(r)}get(t){let r=t.toLowerCase(),n=this.headers.get(r);return n?n.join(", "):null}has(t){let r=t.toLowerCase();return this.headers.has(r)}set(t,r){let n=t.toLowerCase();this.headers.set(n,[r])}forEach(t,r){let n=r?t.bind(r):t;this.headers.forEach((i,a)=>n(i.join(", "),a,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,r]of this.headers.entries())yield[t,r.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let t of this.headers.values())yield t.join(", ")}[Symbol.iterator](){return this.entries()}};var _L_={headers:new XFu,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},hL_={headers:new XFu,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function yL_(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}var oZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function uZQ(e){let t=1+(Math.random()*2-1)*.2;return e*t}function OVE(e){return oZQ(this,arguments,void 0,function*(t,r=2){let n=yield t();for(let i=0;i<r&&([408,429].includes(n.status)||n.status>=500);++i){let a=Math.min(1e3*Math.pow(2,i),6e4),o=uZQ(a);yield new Promise(c=>setTimeout(c,o)),n=yield t()}return n})}var sZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},cy={get:e=>sZQ(void 0,void 0,void 0,function*(){return typeof e=="function"?e():e})};var vL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function cZQ(e){return vL_(this,void 0,void 0,function*(){let t={};if(e.body!==void 0&&e.contentType!=null&&(t["Content-Type"]=e.contentType),e.headers==null)return t;for(let[r,n]of Object.entries(e.headers)){let i=yield cy.get(n);if(typeof i=="string"){t[r]=i;continue}i!=null&&(t[r]=`${i}`)}return t})}function lZQ(e){return vL_(this,void 0,void 0,function*(){let t=fVE(e.url,e.queryParameters),r=yield yVE({body:e.body,type:e.requestType==="json"?"json":"other"}),n=yield hVE();try{let i=yield OVE(()=>vL_(this,void 0,void 0,function*(){return gVE(n,t,e.method,yield cZQ(e),r,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex)}),e.maxRetries);return i.status>=200&&i.status<400?{ok:!0,body:yield K0l(i,e.responseType),headers:i.headers,rawResponse:yL_(i)}:{ok:!1,error:{reason:"status-code",statusCode:i.status,body:yield _VE(i)},rawResponse:yL_(i)}}catch(i){return e.abortSignal!=null&&e.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:_L_}:i instanceof Error&&i.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:_L_}:i instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:i.message},rawResponse:hL_}:{ok:!1,error:{reason:"unknown",errorMessage:sRo(i)},rawResponse:hL_}}})}var Gw=lZQ;var fZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},rw=class e extends Promise{constructor(t){super(r=>{r(void 0)}),this.innerPromise=t}static fromFunction(t,...r){return new e(t(...r))}static interceptFunction(t){return(...r)=>e.fromPromise(t(...r))}static fromPromise(t){return new e(t)}static fromExecutor(t){let r=new Promise(t);return new e(r)}static fromResult(t){let r=Promise.resolve(t);return new e(r)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,r){return this.unwrap().then(t,r)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}withRawResponse(){return fZQ(this,void 0,void 0,function*(){return yield this.innerPromise})}};var $0l=dZQ();function dZQ(){var e,t,r,n,i;return typeof window<"u"&&typeof window.document<"u"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis<"u"&&((e=globalThis?.navigator)===null||e===void 0?void 0:e.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof self?.importScripts=="function"&&(((t=self.constructor)===null||t===void 0?void 0:t.name)==="DedicatedWorkerGlobalScope"||((r=self.constructor)===null||r===void 0?void 0:r.name)==="ServiceWorkerGlobalScope"||((n=self.constructor)===null||n===void 0?void 0:n.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u"?{type:"deno",version:Deno.version.deno}:typeof Bun<"u"&&typeof Bun.version<"u"?{type:"bun",version:Bun.version}:typeof process<"u"&&"version"in process&&!!process.version&&"versions"in process&&!!(!((i=process.versions)===null||i===void 0)&&i.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator<"u"&&navigator?.product==="ReactNative"?{type:"react-native"}:{type:"unknown"}}var Ew={};ff(Ew,{join:()=>PVE,toQueryString:()=>J0l});function PVE(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let r;try{r=new URL(e)}catch{return AVE(e,...t)}let n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=jVE(a);o&&(r.pathname=wVE(r.pathname,o))}return i&&!r.pathname.endsWith("/")&&(r.pathname+="/"),r.toString()}return AVE(e,...t)}function AVE(e,...t){if(t.length===0)return e;let r=e,n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=jVE(a);o&&(r=wVE(r,o))}return i&&!r.endsWith("/")&&(r+="/"),r}function wVE(e,t){return e.endsWith("/")?e+t:e+"/"+t}function jVE(e){if(!e)return e;let t=0,r=e.length;return e.startsWith("/")&&(t=1),e.endsWith("/")&&(r=e.length-1),t===0&&r===e.length?e:e.slice(t,r)}function Sw(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null?t[r]=n:r in t&&delete t[r];return t}function oj(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null&&(t[r]=n);return t}var uj={Production:"https://fai.buildwithfern.com",Development:"https://fai-dev.buildwithfern.com",Local:"http://localhost:8080"};var cRo=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},Y0l=class{constructor(t={}){this._options=t}getAnalyticsHistogram(t,r={},n){return rw.fromPromise(this.__getAnalyticsHistogram(t,r,n))}__getAnalyticsHistogram(t){return cRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:d,end_date:s,group_by:u}=n,l={};d!=null&&(l.start_date=d),s!=null&&(l.end_date=s),u!=null&&(l.group_by=u);let m=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),A=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`analytics/histogram/${encodeURIComponent(r)}`),method:"GET",headers:m,queryParameters:Object.assign(Object.assign({},l),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(A.ok)return{data:A.body,rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 422:throw new iE(A.error.body,A.rawResponse);default:throw new zp({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}switch(A.error.reason){case"non-json":throw new zp({statusCode:A.error.statusCode,body:A.error.rawBody,rawResponse:A.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/histogram/{domain}.");case"unknown":throw new zp({message:A.error.errorMessage,rawResponse:A.rawResponse})}})}getAnalyticsInsights(t,r={},n){return rw.fromPromise(this.__getAnalyticsInsights(t,r,n))}__getAnalyticsInsights(t){return cRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:d,end_date:s}=n,u={};d!=null&&(u.start_date=d),s!=null&&(u.end_date=s);let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`analytics/insights/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/insights/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}generateAllInsights(t={},r){return rw.fromPromise(this.__generateAllInsights(t,r))}__generateAllInsights(){return cRo(this,arguments,void 0,function*(t={},r){var n,i,a;let{start_date:o,end_date:c}=t,d={};o!=null&&(d.start_date=o),c!=null&&(d.end_date=c);let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"analytics/insights/generate_all"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /analytics/insights/generate_all.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}triggerScheduledInsightsGeneration(t){return rw.fromPromise(this.__triggerScheduledInsightsGeneration(t))}__triggerScheduledInsightsGeneration(t){return cRo(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"analytics/insights/trigger_scheduled"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /analytics/insights/trigger_scheduled.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}getSchedulerStatus(t){return rw.fromPromise(this.__getSchedulerStatus(t))}__getSchedulerStatus(t){return cRo(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"analytics/scheduler/status"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/scheduler/status.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return cRo(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var EVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},X0l=class{constructor(t={}){this._options=t}postChatCompletion(t,r,n){return rw.fromPromise(this.__postChatCompletion(t,r,n))}__postChatCompletion(t,r,n){return EVE(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`chat/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /chat/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return EVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var SVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},Z0l=class{constructor(t={}){this._options=t}getConversationById(t,r,n){return rw.fromPromise(this.__getConversationById(t,r,n))}__getConversationById(t,r,n){return SVE(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`conversation/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /conversation/{domain}/{conversation_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return SVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var bL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},k0l=class{constructor(t={}){this._options=t}createDiscordIntegration(t,r){return rw.fromPromise(this.__createDiscordIntegration(t,r))}__createDiscordIntegration(t,r){return bL_(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"discord/install"),method:"POST",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /discord/install.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}handleDiscordInstallCallback(t){return rw.fromPromise(this.__handleDiscordInstallCallback(t))}__handleDiscordInstallCallback(t){return bL_(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"discord/install/callback"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /discord/install/callback.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return bL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var TBi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},eml=class{constructor(t={}){this._options=t}createDocument(t,r,n){return rw.fromPromise(this.__createDocument(t,r,n))}__createDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /document/{domain}/create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}batchCreateDocument(t,r,n){return rw.fromPromise(this.__batchCreateDocument(t,r,n))}__batchCreateDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/batch-create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /document/{domain}/batch-create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getDocumentById(t,r,n){return rw.fromPromise(this.__getDocumentById(t,r,n))}__getDocumentById(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /document/{domain}/{document_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}updateDocument(t,r,n={},i){return rw.fromPromise(this.__updateDocument(t,r,n,i))}__updateDocument(t,r){return TBi(this,arguments,void 0,function*(n,i,a={},o){var c,d,s;let u=Sw((c=this._options)===null||c===void 0?void 0:c.headers,oj({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield Gw({url:Ew.join((s=(d=yield cy.get(this._options.baseUrl))!==null&&d!==void 0?d:yield cy.get(this._options.environment))!==null&&s!==void 0?s:uj.Production,`document/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling PATCH /document/{domain}/{document_id}.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}deleteDocumentById(t,r,n){return rw.fromPromise(this.__deleteDocumentById(t,r,n))}__deleteDocumentById(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/delete.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}batchDeleteDocument(t,r,n){return rw.fromPromise(this.__batchDeleteDocument(t,r,n))}__batchDeleteDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/batch-delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/batch-delete.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getDocuments(t,r={},n){return rw.fromPromise(this.__getDocuments(t,r,n))}__getDocuments(t){return TBi(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s}=n,u={};d!=null&&(u.page=d.toString()),s!=null&&(u.limit=s.toString());let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`document/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /document/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}deleteAllDocuments(t,r){return rw.fromPromise(this.__deleteAllDocuments(t,r))}__deleteAllDocuments(t,r){return TBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`document/${encodeURIComponent(t)}/delete-all`),method:"DELETE",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/delete-all.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return TBi(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var gL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},tml=class{constructor(t={}){this._options=t}createFeedback(t,r,n){return rw.fromPromise(this.__createFeedback(t,r,n))}__createFeedback(t,r,n){return gL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`feedback/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /feedback/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getFeedbackById(t,r,n){return rw.fromPromise(this.__getFeedbackById(t,r,n))}__getFeedbackById(t,r,n){return gL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`feedback/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /feedback/{domain}/{conversation_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return gL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var mL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},rml=class{constructor(t={}){this._options=t}indexReferenceMd(t,r,n){return rw.fromPromise(this.__indexReferenceMd(t,r,n))}__indexReferenceMd(t,r,n){return mL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`github/${encodeURIComponent(t)}/reference-md/index`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /github/{domain}/reference-md/index.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}checkCodeIndexStatus(t,r){return rw.fromPromise(this.__checkCodeIndexStatus(t,r))}__checkCodeIndexStatus(t,r){return mL_(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`github/${encodeURIComponent(t)}/indexed`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /github/{domain}/indexed.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return mL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var lRo=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},nml=class{constructor(t={}){this._options=t}createGuidance(t,r,n){return rw.fromPromise(this.__createGuidance(t,r,n))}__createGuidance(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /guidance/{domain}/create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getGuidanceById(t,r,n){return rw.fromPromise(this.__getGuidanceById(t,r,n))}__getGuidanceById(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}deleteGuidanceById(t,r,n){return rw.fromPromise(this.__deleteGuidanceById(t,r,n))}__deleteGuidanceById(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"DELETE",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}update(t,r,n={},i){return rw.fromPromise(this.__update(t,r,n,i))}__update(t,r){return lRo(this,arguments,void 0,function*(n,i,a={},o){var c,d,s;let u=Sw((c=this._options)===null||c===void 0?void 0:c.headers,oj({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield Gw({url:Ew.join((s=(d=yield cy.get(this._options.baseUrl))!==null&&d!==void 0?d:yield cy.get(this._options.environment))!==null&&s!==void 0?s:uj.Production,`guidance/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling PATCH /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}getGuidances(t,r={},n){return rw.fromPromise(this.__getGuidances(t,r,n))}__getGuidances(t){return lRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s}=n,u={};d!=null&&(u.page=d.toString()),s!=null&&(u.limit=s.toString());let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`guidance/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /guidance/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}_getAuthorizationHeader(){return lRo(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var DVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},iml=class{constructor(t={}){this._options=t}check(t){return rw.fromPromise(this.__check(t))}__check(t){return DVE(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"health"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /health.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return DVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var aml=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},oml=class{constructor(t={}){this._options=t}reconstructQueryIndex(t,r){return rw.fromPromise(this.__reconstructQueryIndex(t,r))}__reconstructQueryIndex(t,r){return aml(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`index/${encodeURIComponent(t)}/reconstruct`),method:"POST",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /index/{domain}/reconstruct.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}syncIndexToQueryIndex(t,r,n){return rw.fromPromise(this.__syncIndexToQueryIndex(t,r,n))}__syncIndexToQueryIndex(t,r,n){return aml(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`index/${encodeURIComponent(t)}/sync`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /index/{domain}/sync.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getJobStatus(t,r){return rw.fromPromise(this.__getJobStatus(t,r))}__getJobStatus(t,r){return aml(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`jobs/${encodeURIComponent(t)}/status`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /jobs/{job_id}/status.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return aml(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var OL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},uml=class{constructor(t={}){this._options=t}getMcpSemanticQuery(t,r,n){return rw.fromPromise(this.__getMcpSemanticQuery(t,r,n))}__getMcpSemanticQuery(t,r,n){return OL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`mcp/semantic/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /mcp/semantic/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getMcpBmfQuery(t,r,n){return rw.fromPromise(this.__getMcpBmfQuery(t,r,n))}__getMcpBmfQuery(t,r,n){return OL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`mcp/bmf/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /mcp/bmf/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return OL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var AL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},sml=class{constructor(t={}){this._options=t}createQuery(t,r){return rw.fromPromise(this.__createQuery(t,r))}__createQuery(t,r){return AL_(this,void 0,void 0,function*(){var n,i,a;let{domain:o,body:c}=t,d={};d.domain=o;let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"queries"),method:"POST",headers:s,contentType:"application/json",queryParameters:Object.assign(Object.assign({},d),r?.queryParams),requestType:"json",body:c,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /queries.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getRecentQueries(t,r={},n){return rw.fromPromise(this.__getRecentQueries(t,r,n))}__getRecentQueries(t){return AL_(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s,cutoff_time:u,include_assistant:l,start_date:m,end_date:A}=n,P={};d!=null&&(P.page=d.toString()),s!=null&&(P.limit=s.toString()),u!=null&&(P.cutoff_time=u),l!=null&&(P.include_assistant=l.toString()),m!=null&&(P.start_date=m),A!=null&&(P.end_date=A);let C=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),M=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`queries/${encodeURIComponent(r)}`),method:"GET",headers:C,queryParameters:Object.assign(Object.assign({},P),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(M.ok)return{data:M.body,rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 422:throw new iE(M.error.body,M.rawResponse);default:throw new zp({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}switch(M.error.reason){case"non-json":throw new zp({statusCode:M.error.statusCode,body:M.error.rawBody,rawResponse:M.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /queries/{domain}.");case"unknown":throw new zp({message:M.error.errorMessage,rawResponse:M.rawResponse})}})}_getAuthorizationHeader(){return AL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var q8a=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},cml=class{constructor(t={}){this._options=t}getSettings(t,r){return rw.fromPromise(this.__getSettings(t,r))}__getSettings(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getDocsSettings(t,r){return rw.fromPromise(this.__getDocsSettings(t,r))}__getDocsSettings(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/docs"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai/docs.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}toggleAskAi(t,r){return rw.fromPromise(this.__toggleAskAi(t,r))}__toggleAskAi(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c,preview:d}=t,s={};s.domain=o,s.org_name=c,d!=null&&(s.preview=d.toString());let u=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),l=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/toggle"),method:"POST",headers:u,queryParameters:Object.assign(Object.assign({},s),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/ask-ai/toggle.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}reindexAskAi(t,r){return rw.fromPromise(this.__reindexAskAi(t,r))}__reindexAskAi(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c}=t,d={};d.domain=o,d.org_name=c;let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/reindex"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/ask-ai/reindex.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getToggleStatus(t,r){return rw.fromPromise(this.__getToggleStatus(t,r))}__getToggleStatus(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/toggle/status"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai/toggle/status.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}reindexPreviewCallback(t,r){return rw.fromPromise(this.__reindexPreviewCallback(t,r))}__reindexPreviewCallback(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/reindex-preview-callback"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/reindex-preview-callback.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return q8a(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var qBi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},lml=class{constructor(t={}){this._options=t}createSlackIntegration(t,r){return rw.fromPromise(this.__createSlackIntegration(t,r))}__createSlackIntegration(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/integrations"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/integrations.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}handleSlackEvents(t){return rw.fromPromise(this.__handleSlackEvents(t))}__handleSlackEvents(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/events"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/events.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackSlashCommands(t){return rw.fromPromise(this.__handleSlackSlashCommands(t))}__handleSlackSlashCommands(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/slash-commands"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/slash-commands.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackInteractions(t){return rw.fromPromise(this.__handleSlackInteractions(t))}__handleSlackInteractions(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/interactions"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/interactions.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackOauthCallback(t,r){return rw.fromPromise(this.__handleSlackOauthCallback(t,r))}__handleSlackOauthCallback(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let{code:o,state:c}=t,d={};d.code=o,c!=null&&(d.state=c);let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/oauth/callback"),method:"GET",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/oauth/callback.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getSlackInstallLink(t,r){return rw.fromPromise(this.__getSlackInstallLink(t,r))}__getSlackInstallLink(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/get-install"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/get-install.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}listSlackIntegrations(t,r){return rw.fromPromise(this.__listSlackIntegrations(t,r))}__listSlackIntegrations(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`slack/integrations/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/integrations/{domain}.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}getSlackInstallLinkById(t,r){return rw.fromPromise(this.__getSlackInstallLinkById(t,r))}__getSlackInstallLinkById(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`slack/get-install/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/get-install/{integration_id}.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return qBi(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var ZFu=class{constructor(t={}){this._options=Object.assign(Object.assign({},t),{headers:Sw({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@fern-api/fai-sdk","X-Fern-SDK-Version":"0.0.2-9f9be72b3","X-Fern-Runtime":$0l.type,"X-Fern-Runtime-Version":$0l.version},t?.headers)})}get analytics(){var t;return(t=this._analytics)!==null&&t!==void 0?t:this._analytics=new Y0l(this._options)}get chat(){var t;return(t=this._chat)!==null&&t!==void 0?t:this._chat=new X0l(this._options)}get conversation(){var t;return(t=this._conversation)!==null&&t!==void 0?t:this._conversation=new Z0l(this._options)}get discord(){var t;return(t=this._discord)!==null&&t!==void 0?t:this._discord=new k0l(this._options)}get document(){var t;return(t=this._document)!==null&&t!==void 0?t:this._document=new eml(this._options)}get feedback(){var t;return(t=this._feedback)!==null&&t!==void 0?t:this._feedback=new tml(this._options)}get github(){var t;return(t=this._github)!==null&&t!==void 0?t:this._github=new rml(this._options)}get guidance(){var t;return(t=this._guidance)!==null&&t!==void 0?t:this._guidance=new nml(this._options)}get health(){var t;return(t=this._health)!==null&&t!==void 0?t:this._health=new iml(this._options)}get index(){var t;return(t=this._index)!==null&&t!==void 0?t:this._index=new oml(this._options)}get mcp(){var t;return(t=this._mcp)!==null&&t!==void 0?t:this._mcp=new uml(this._options)}get query(){var t;return(t=this._query)!==null&&t!==void 0?t:this._query=new sml(this._options)}get settings(){var t;return(t=this._settings)!==null&&t!==void 0?t:this._settings=new cml(this._options)}get slack(){var t;return(t=this._slack)!==null&&t!==void 0?t:this._slack=new lml(this._options)}};function CVE({token:e}){return new ZFu({baseUrl:"https://fai.buildwithfern.com",token:e})}var hWE=fa(_WE(),1);var yWE=require("util"),kkQ=(0,yWE.promisify)(hWE.default);async function vWE(e,t,r){let n=u9o(e,t),i=[];for(let a of n){let o=await Promise.all(a.map(async c=>{try{let d=await kkQ(c);return d==null||d.height==null||d.width==null?void 0:{filePath:c,width:d.width,height:d.height,blurDataUrl:void 0}}catch(d){r.logger.error(`Failed to measure image size for ${c}. ${d?.message}`);return}}));i.push(...o.filter(kw))}return new Map(i.map(a=>[a.filePath,a]))}var eeL=10,bWE=10;async function PWE({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,apiWorkspaces:a,ossWorkspaces:o,context:c,preview:d,editThisPage:s,isPrivate:u=!1,disableTemplates:l=!1,skipUpload:m=!1}){let A=Xua({token:e.value}),P=u?{type:"private",authType:"sso"}:{type:"public"},C,M=i[0]??n,T=teL(n),z=r.config.experimental?.dynamicSnippets,U=d||z,V=await new TRr(n,r,o,a,c,s,async re=>{let X=new Map(re.map(he=>[he.absoluteFilePath,he])),ne=re.map(he=>({...he,mediaType:VL_.lookup(he.absoluteFilePath)})).filter(he=>he.mediaType!==!1).filter(he=>z7.parse(he.mediaType)?.isImage()??!1).map(he=>he.absoluteFilePath),Oe=await vWE(ne,eeL,c),be=[];[...Oe.values()].forEach(he=>{let Me=X.get(he.filePath);if(Me==null)return;let Be={filePath:zyi.FernRegistry.docs.v1.write.FilePath(tos(Me.relativeFilePath)),width:he.width,height:he.height,blurDataUrl:he.blurDataUrl,alt:void 0};be.push(Be)});let me=re.filter(({absoluteFilePath:he})=>!Oe.has(he)).map(({relativeFilePath:he})=>tos(he));if(d){let he=await A.docs.v2.write.startDocsPreviewRegister({orgId:zyi.FernRegistry.OrgId(t),authConfig:u?{type:"private",authType:"sso"}:{type:"public"},filepaths:me.map(Me=>zyi.FernRegistry.docs.v1.write.FilePath(Me)),images:be,basePath:T});return he.ok?(M=he.body.previewUrl,C=he.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs preview"):await gWE(he.body.uploadUrls,r.absoluteFilePath,c,bWE),mWE(he.body.uploadUrls,r.absoluteFilePath)):await OWE(he.error,c)}else{let he=await A.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:P,apiId:zyi.FernRegistry.ApiId(""),orgId:zyi.FernRegistry.OrgId(t),filepaths:me.map(Me=>zyi.FernRegistry.docs.v1.write.FilePath(Me)),images:be});return he.ok?(C=he.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs"):await gWE(he.body.uploadUrls,r.absoluteFilePath,c,bWE),mWE(he.body.uploadUrls,r.absoluteFilePath)):OWE(he.error,c)}},async({ir:re,snippetsConfig:X,playgroundConfig:ee,apiName:ne,workspace:Oe})=>{let be=DIe({ir:re,snippetsConfig:X,playgroundConfig:ee,context:c}),me;z&&(me=await reL({workspace:Oe,organization:t,context:c,snippetsConfig:X}));let he=await A.api.v1.register.registerApiDefinition({orgId:zyi.FernRegistry.OrgId(t),apiId:zyi.FernRegistry.ApiId(re.apiName.originalName),definition:be,definitionV2:void 0,dynamicIRs:me});if(he.ok)return c.logger.debug(`Registered API Definition ${he.body.apiDefinitionId}`),he.body.dynamicIRs&&me&&(m?c.logger.debug("Skip-upload mode: skipping dynamic IR uploads"):await neL({dynamicIRs:me,dynamicIRUploadUrls:he.body.dynamicIRs,context:c,apiId:he.body.apiDefinitionId})),he.body.apiDefinitionId;switch(he.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return ne!=null?c.failAndThrow(`Failed to publish docs because API definition (${ne}) could not be uploaded. Please contact support@buildwithfern.com
|
|
3041
|
+
`)}var tw=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};var iE=class e extends zp{constructor(t,r){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:r}),Object.setPrototypeOf(this,e.prototype)}};var kXQ={arrayFormat:"indices",encode:!0};function lVE(e,t){if(e===void 0||e===null)return"";let r=String(e);return t?encodeURIComponent(r):r}function pL_(e,t="",r){let n=[];for(let[i,a]of Object.entries(e)){let o=t?`${t}[${i}]`:i;if(a!==void 0)if(Array.isArray(a)){if(a.length===0)continue;for(let c=0;c<a.length;c++){let d=a[c];if(d!==void 0)if(typeof d=="object"&&!Array.isArray(d)&&d!==null){let s=r.arrayFormat==="indices"?`${o}[${c}]`:o;n.push(...pL_(d,s,r))}else{let s=r.arrayFormat==="indices"?`${o}[${c}]`:o,u=r.encode?encodeURIComponent(s):s;n.push(`${u}=${lVE(d,r.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;n.push(...pL_(a,o,r))}else{let c=r.encode?encodeURIComponent(o):o;n.push(`${c}=${lVE(a,r.encode)}`)}}return n}function J0l(e,t){return e==null||typeof e!="object"?"":pL_(e,"",Object.assign(Object.assign({},kXQ),t)).join("&")}function fVE(e,t){let r=J0l(t,{arrayFormat:"repeat"});return r?`${e}?${r}`:e}function dVE(e){let t={get bodyUsed(){return e.bodyUsed},stream:()=>e.body,arrayBuffer:e.arrayBuffer.bind(e),blob:e.blob.bind(e)};return"bytes"in e&&typeof e.bytes=="function"&&(t.bytes=e.bytes.bind(e)),t}function pVE(e){return e.body!=null}var eZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function K0l(e,t){return eZQ(this,void 0,void 0,function*(){if(!pVE(e))return;switch(t){case"binary-response":return dVE(e);case"blob":return yield e.blob();case"arrayBuffer":return yield e.arrayBuffer();case"sse":return e.body;case"streaming":return e.body;case"text":return yield e.text()}let r=yield e.text();if(r.length>0)try{return YFu(r)}catch{return{ok:!1,error:{reason:"non-json",statusCode:e.status,rawBody:r}}}})}var tZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function _VE(e){return tZQ(this,void 0,void 0,function*(){var t,r,n;let i=(t=e.headers.get("Content-Type"))===null||t===void 0?void 0:t.toLowerCase();if(i==null||i.length===0)return K0l(e);switch(i.indexOf(";")!==-1&&(i=(n=(r=i.split(";")[0])===null||r===void 0?void 0:r.trim())!==null&&n!==void 0?n:""),i){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":let a=yield e.text();return a.length>0?YFu(a):void 0;default:if(i.startsWith("application/vnd.")&&i.endsWith("+json")){let o=yield e.text();return o.length>0?YFu(o):void 0}return yield e.text()}})}var rZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function hVE(){return rZQ(this,void 0,void 0,function*(){return fetch})}var nZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function yVE(e){return nZQ(this,arguments,void 0,function*({body:t,type:r}){return r.includes("json")?sRo(t):t})}var iZQ="timeout";function vVE(e){let t=new AbortController,r=setTimeout(()=>t.abort(iZQ),e);return{signal:t.signal,abortId:r}}function bVE(...e){let t=e.length===1&&Array.isArray(e[0])?e[0]:e,r=new AbortController;for(let n of t){if(n.aborted){r.abort(n?.reason);break}n.addEventListener("abort",()=>r.abort(n?.reason),{signal:r.signal})}return r.signal}var aZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},gVE=(e,t,r,n,i,a,o,c,d)=>aZQ(void 0,void 0,void 0,function*(){let s=[],u;if(a!=null){let{signal:A,abortId:P}=vVE(a);u=P,s.push(A)}o!=null&&s.push(o);let l=bVE(s),m=yield e(t,{method:r,headers:n,body:i,signal:l,credentials:c?"include":void 0,duplex:d});return u!=null&&clearTimeout(u),m});var XFu;typeof globalThis.Headers<"u"?XFu=globalThis.Headers:XFu=class mVE{constructor(t){if(this.headers=new Map,t)if(t instanceof mVE)t.forEach((r,n)=>this.append(n,r));else if(Array.isArray(t))for(let[r,n]of t)if(typeof r=="string"&&typeof n=="string")this.append(r,n);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[r,n]of Object.entries(t))if(typeof n=="string")this.append(r,n);else throw new TypeError("Header values must be strings")}append(t,r){let n=t.toLowerCase(),i=this.headers.get(n)||[];this.headers.set(n,[...i,r])}delete(t){let r=t.toLowerCase();this.headers.delete(r)}get(t){let r=t.toLowerCase(),n=this.headers.get(r);return n?n.join(", "):null}has(t){let r=t.toLowerCase();return this.headers.has(r)}set(t,r){let n=t.toLowerCase();this.headers.set(n,[r])}forEach(t,r){let n=r?t.bind(r):t;this.headers.forEach((i,a)=>n(i.join(", "),a,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,r]of this.headers.entries())yield[t,r.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let t of this.headers.values())yield t.join(", ")}[Symbol.iterator](){return this.entries()}};var _L_={headers:new XFu,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},hL_={headers:new XFu,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function yL_(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}var oZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function uZQ(e){let t=1+(Math.random()*2-1)*.2;return e*t}function OVE(e){return oZQ(this,arguments,void 0,function*(t,r=2){let n=yield t();for(let i=0;i<r&&([408,429].includes(n.status)||n.status>=500);++i){let a=Math.min(1e3*Math.pow(2,i),6e4),o=uZQ(a);yield new Promise(c=>setTimeout(c,o)),n=yield t()}return n})}var sZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},cy={get:e=>sZQ(void 0,void 0,void 0,function*(){return typeof e=="function"?e():e})};var vL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})};function cZQ(e){return vL_(this,void 0,void 0,function*(){let t={};if(e.body!==void 0&&e.contentType!=null&&(t["Content-Type"]=e.contentType),e.headers==null)return t;for(let[r,n]of Object.entries(e.headers)){let i=yield cy.get(n);if(typeof i=="string"){t[r]=i;continue}i!=null&&(t[r]=`${i}`)}return t})}function lZQ(e){return vL_(this,void 0,void 0,function*(){let t=fVE(e.url,e.queryParameters),r=yield yVE({body:e.body,type:e.requestType==="json"?"json":"other"}),n=yield hVE();try{let i=yield OVE(()=>vL_(this,void 0,void 0,function*(){return gVE(n,t,e.method,yield cZQ(e),r,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex)}),e.maxRetries);return i.status>=200&&i.status<400?{ok:!0,body:yield K0l(i,e.responseType),headers:i.headers,rawResponse:yL_(i)}:{ok:!1,error:{reason:"status-code",statusCode:i.status,body:yield _VE(i)},rawResponse:yL_(i)}}catch(i){return e.abortSignal!=null&&e.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:_L_}:i instanceof Error&&i.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:_L_}:i instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:i.message},rawResponse:hL_}:{ok:!1,error:{reason:"unknown",errorMessage:sRo(i)},rawResponse:hL_}}})}var Gw=lZQ;var fZQ=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},rw=class e extends Promise{constructor(t){super(r=>{r(void 0)}),this.innerPromise=t}static fromFunction(t,...r){return new e(t(...r))}static interceptFunction(t){return(...r)=>e.fromPromise(t(...r))}static fromPromise(t){return new e(t)}static fromExecutor(t){let r=new Promise(t);return new e(r)}static fromResult(t){let r=Promise.resolve(t);return new e(r)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,r){return this.unwrap().then(t,r)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}withRawResponse(){return fZQ(this,void 0,void 0,function*(){return yield this.innerPromise})}};var $0l=dZQ();function dZQ(){var e,t,r,n,i;return typeof window<"u"&&typeof window.document<"u"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis<"u"&&((e=globalThis?.navigator)===null||e===void 0?void 0:e.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof self?.importScripts=="function"&&(((t=self.constructor)===null||t===void 0?void 0:t.name)==="DedicatedWorkerGlobalScope"||((r=self.constructor)===null||r===void 0?void 0:r.name)==="ServiceWorkerGlobalScope"||((n=self.constructor)===null||n===void 0?void 0:n.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u"?{type:"deno",version:Deno.version.deno}:typeof Bun<"u"&&typeof Bun.version<"u"?{type:"bun",version:Bun.version}:typeof process<"u"&&"version"in process&&!!process.version&&"versions"in process&&!!(!((i=process.versions)===null||i===void 0)&&i.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator<"u"&&navigator?.product==="ReactNative"?{type:"react-native"}:{type:"unknown"}}var Ew={};ff(Ew,{join:()=>PVE,toQueryString:()=>J0l});function PVE(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let r;try{r=new URL(e)}catch{return AVE(e,...t)}let n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=jVE(a);o&&(r.pathname=wVE(r.pathname,o))}return i&&!r.pathname.endsWith("/")&&(r.pathname+="/"),r.toString()}return AVE(e,...t)}function AVE(e,...t){if(t.length===0)return e;let r=e,n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=jVE(a);o&&(r=wVE(r,o))}return i&&!r.endsWith("/")&&(r+="/"),r}function wVE(e,t){return e.endsWith("/")?e+t:e+"/"+t}function jVE(e){if(!e)return e;let t=0,r=e.length;return e.startsWith("/")&&(t=1),e.endsWith("/")&&(r=e.length-1),t===0&&r===e.length?e:e.slice(t,r)}function Sw(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null?t[r]=n:r in t&&delete t[r];return t}function oj(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null&&(t[r]=n);return t}var uj={Production:"https://fai.buildwithfern.com",Development:"https://fai-dev.buildwithfern.com",Local:"http://localhost:8080"};var cRo=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},Y0l=class{constructor(t={}){this._options=t}getAnalyticsHistogram(t,r={},n){return rw.fromPromise(this.__getAnalyticsHistogram(t,r,n))}__getAnalyticsHistogram(t){return cRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:d,end_date:s,group_by:u}=n,l={};d!=null&&(l.start_date=d),s!=null&&(l.end_date=s),u!=null&&(l.group_by=u);let m=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),A=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`analytics/histogram/${encodeURIComponent(r)}`),method:"GET",headers:m,queryParameters:Object.assign(Object.assign({},l),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(A.ok)return{data:A.body,rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 422:throw new iE(A.error.body,A.rawResponse);default:throw new zp({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}switch(A.error.reason){case"non-json":throw new zp({statusCode:A.error.statusCode,body:A.error.rawBody,rawResponse:A.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/histogram/{domain}.");case"unknown":throw new zp({message:A.error.errorMessage,rawResponse:A.rawResponse})}})}getAnalyticsInsights(t,r={},n){return rw.fromPromise(this.__getAnalyticsInsights(t,r,n))}__getAnalyticsInsights(t){return cRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:d,end_date:s}=n,u={};d!=null&&(u.start_date=d),s!=null&&(u.end_date=s);let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`analytics/insights/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/insights/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}generateAllInsights(t={},r){return rw.fromPromise(this.__generateAllInsights(t,r))}__generateAllInsights(){return cRo(this,arguments,void 0,function*(t={},r){var n,i,a;let{start_date:o,end_date:c}=t,d={};o!=null&&(d.start_date=o),c!=null&&(d.end_date=c);let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"analytics/insights/generate_all"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /analytics/insights/generate_all.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}triggerScheduledInsightsGeneration(t){return rw.fromPromise(this.__triggerScheduledInsightsGeneration(t))}__triggerScheduledInsightsGeneration(t){return cRo(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"analytics/insights/trigger_scheduled"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /analytics/insights/trigger_scheduled.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}getSchedulerStatus(t){return rw.fromPromise(this.__getSchedulerStatus(t))}__getSchedulerStatus(t){return cRo(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"analytics/scheduler/status"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /analytics/scheduler/status.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return cRo(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var EVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},X0l=class{constructor(t={}){this._options=t}postChatCompletion(t,r,n){return rw.fromPromise(this.__postChatCompletion(t,r,n))}__postChatCompletion(t,r,n){return EVE(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`chat/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /chat/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return EVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var SVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},Z0l=class{constructor(t={}){this._options=t}getConversationById(t,r,n){return rw.fromPromise(this.__getConversationById(t,r,n))}__getConversationById(t,r,n){return SVE(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`conversation/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /conversation/{domain}/{conversation_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return SVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var bL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},k0l=class{constructor(t={}){this._options=t}createDiscordIntegration(t,r){return rw.fromPromise(this.__createDiscordIntegration(t,r))}__createDiscordIntegration(t,r){return bL_(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"discord/install"),method:"POST",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /discord/install.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}handleDiscordInstallCallback(t){return rw.fromPromise(this.__handleDiscordInstallCallback(t))}__handleDiscordInstallCallback(t){return bL_(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"discord/install/callback"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /discord/install/callback.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return bL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var TBi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},eml=class{constructor(t={}){this._options=t}createDocument(t,r,n){return rw.fromPromise(this.__createDocument(t,r,n))}__createDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /document/{domain}/create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}batchCreateDocument(t,r,n){return rw.fromPromise(this.__batchCreateDocument(t,r,n))}__batchCreateDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/batch-create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /document/{domain}/batch-create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getDocumentById(t,r,n){return rw.fromPromise(this.__getDocumentById(t,r,n))}__getDocumentById(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /document/{domain}/{document_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}updateDocument(t,r,n={},i){return rw.fromPromise(this.__updateDocument(t,r,n,i))}__updateDocument(t,r){return TBi(this,arguments,void 0,function*(n,i,a={},o){var c,d,s;let u=Sw((c=this._options)===null||c===void 0?void 0:c.headers,oj({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield Gw({url:Ew.join((s=(d=yield cy.get(this._options.baseUrl))!==null&&d!==void 0?d:yield cy.get(this._options.environment))!==null&&s!==void 0?s:uj.Production,`document/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling PATCH /document/{domain}/{document_id}.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}deleteDocumentById(t,r,n){return rw.fromPromise(this.__deleteDocumentById(t,r,n))}__deleteDocumentById(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/delete.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}batchDeleteDocument(t,r,n){return rw.fromPromise(this.__batchDeleteDocument(t,r,n))}__batchDeleteDocument(t,r,n){return TBi(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`document/${encodeURIComponent(t)}/batch-delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/batch-delete.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getDocuments(t,r={},n){return rw.fromPromise(this.__getDocuments(t,r,n))}__getDocuments(t){return TBi(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s}=n,u={};d!=null&&(u.page=d.toString()),s!=null&&(u.limit=s.toString());let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`document/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /document/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}deleteAllDocuments(t,r){return rw.fromPromise(this.__deleteAllDocuments(t,r))}__deleteAllDocuments(t,r){return TBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`document/${encodeURIComponent(t)}/delete-all`),method:"DELETE",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /document/{domain}/delete-all.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return TBi(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var gL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},tml=class{constructor(t={}){this._options=t}createFeedback(t,r,n){return rw.fromPromise(this.__createFeedback(t,r,n))}__createFeedback(t,r,n){return gL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`feedback/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /feedback/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getFeedbackById(t,r,n){return rw.fromPromise(this.__getFeedbackById(t,r,n))}__getFeedbackById(t,r,n){return gL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`feedback/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /feedback/{domain}/{conversation_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return gL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var mL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},rml=class{constructor(t={}){this._options=t}indexReferenceMd(t,r,n){return rw.fromPromise(this.__indexReferenceMd(t,r,n))}__indexReferenceMd(t,r,n){return mL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`github/${encodeURIComponent(t)}/reference-md/index`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /github/{domain}/reference-md/index.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}checkCodeIndexStatus(t,r){return rw.fromPromise(this.__checkCodeIndexStatus(t,r))}__checkCodeIndexStatus(t,r){return mL_(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`github/${encodeURIComponent(t)}/indexed`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /github/{domain}/indexed.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return mL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var lRo=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},nml=class{constructor(t={}){this._options=t}createGuidance(t,r,n){return rw.fromPromise(this.__createGuidance(t,r,n))}__createGuidance(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /guidance/{domain}/create.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getGuidanceById(t,r,n){return rw.fromPromise(this.__getGuidanceById(t,r,n))}__getGuidanceById(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}deleteGuidanceById(t,r,n){return rw.fromPromise(this.__deleteGuidanceById(t,r,n))}__deleteGuidanceById(t,r,n){return lRo(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"DELETE",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling DELETE /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}update(t,r,n={},i){return rw.fromPromise(this.__update(t,r,n,i))}__update(t,r){return lRo(this,arguments,void 0,function*(n,i,a={},o){var c,d,s;let u=Sw((c=this._options)===null||c===void 0?void 0:c.headers,oj({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield Gw({url:Ew.join((s=(d=yield cy.get(this._options.baseUrl))!==null&&d!==void 0?d:yield cy.get(this._options.environment))!==null&&s!==void 0?s:uj.Production,`guidance/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling PATCH /guidance/{domain}/{guidance_id}.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}getGuidances(t,r={},n){return rw.fromPromise(this.__getGuidances(t,r,n))}__getGuidances(t){return lRo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s}=n,u={};d!=null&&(u.page=d.toString()),s!=null&&(u.limit=s.toString());let l=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`guidance/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},u),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new iE(m.error.body,m.rawResponse);default:throw new zp({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new zp({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /guidance/{domain}.");case"unknown":throw new zp({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}_getAuthorizationHeader(){return lRo(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var DVE=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},iml=class{constructor(t={}){this._options=t}check(t){return rw.fromPromise(this.__check(t))}__check(t){return DVE(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"health"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /health.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return DVE(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var aml=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},oml=class{constructor(t={}){this._options=t}reconstructQueryIndex(t,r){return rw.fromPromise(this.__reconstructQueryIndex(t,r))}__reconstructQueryIndex(t,r){return aml(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`index/${encodeURIComponent(t)}/reconstruct`),method:"POST",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /index/{domain}/reconstruct.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}syncIndexToQueryIndex(t,r,n){return rw.fromPromise(this.__syncIndexToQueryIndex(t,r,n))}__syncIndexToQueryIndex(t,r,n){return aml(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`index/${encodeURIComponent(t)}/sync`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /index/{domain}/sync.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getJobStatus(t,r){return rw.fromPromise(this.__getJobStatus(t,r))}__getJobStatus(t,r){return aml(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`jobs/${encodeURIComponent(t)}/status`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /jobs/{job_id}/status.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return aml(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var OL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},uml=class{constructor(t={}){this._options=t}getMcpSemanticQuery(t,r,n){return rw.fromPromise(this.__getMcpSemanticQuery(t,r,n))}__getMcpSemanticQuery(t,r,n){return OL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`mcp/semantic/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /mcp/semantic/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}getMcpBmfQuery(t,r,n){return rw.fromPromise(this.__getMcpBmfQuery(t,r,n))}__getMcpBmfQuery(t,r,n){return OL_(this,void 0,void 0,function*(){var i,a,o;let c=Sw((i=this._options)===null||i===void 0?void 0:i.headers,oj({Authorization:yield this._getAuthorizationHeader()}),n?.headers),d=yield Gw({url:Ew.join((o=(a=yield cy.get(this._options.baseUrl))!==null&&a!==void 0?a:yield cy.get(this._options.environment))!==null&&o!==void 0?o:uj.Production,`mcp/bmf/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 422:throw new iE(d.error.body,d.rawResponse);default:throw new zp({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new zp({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /mcp/bmf/{domain}.");case"unknown":throw new zp({message:d.error.errorMessage,rawResponse:d.rawResponse})}})}_getAuthorizationHeader(){return OL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var AL_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},sml=class{constructor(t={}){this._options=t}createQuery(t,r){return rw.fromPromise(this.__createQuery(t,r))}__createQuery(t,r){return AL_(this,void 0,void 0,function*(){var n,i,a;let{domain:o,body:c}=t,d={};d.domain=o;let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"queries"),method:"POST",headers:s,contentType:"application/json",queryParameters:Object.assign(Object.assign({},d),r?.queryParams),requestType:"json",body:c,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /queries.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getRecentQueries(t,r={},n){return rw.fromPromise(this.__getRecentQueries(t,r,n))}__getRecentQueries(t){return AL_(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:d,limit:s,cutoff_time:u,include_assistant:l,start_date:m,end_date:A}=n,P={};d!=null&&(P.page=d.toString()),s!=null&&(P.limit=s.toString()),u!=null&&(P.cutoff_time=u),l!=null&&(P.include_assistant=l.toString()),m!=null&&(P.start_date=m),A!=null&&(P.end_date=A);let C=Sw((a=this._options)===null||a===void 0?void 0:a.headers,oj({Authorization:yield this._getAuthorizationHeader()}),i?.headers),M=yield Gw({url:Ew.join((c=(o=yield cy.get(this._options.baseUrl))!==null&&o!==void 0?o:yield cy.get(this._options.environment))!==null&&c!==void 0?c:uj.Production,`queries/${encodeURIComponent(r)}`),method:"GET",headers:C,queryParameters:Object.assign(Object.assign({},P),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(M.ok)return{data:M.body,rawResponse:M.rawResponse};if(M.error.reason==="status-code")switch(M.error.statusCode){case 422:throw new iE(M.error.body,M.rawResponse);default:throw new zp({statusCode:M.error.statusCode,body:M.error.body,rawResponse:M.rawResponse})}switch(M.error.reason){case"non-json":throw new zp({statusCode:M.error.statusCode,body:M.error.rawBody,rawResponse:M.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /queries/{domain}.");case"unknown":throw new zp({message:M.error.errorMessage,rawResponse:M.rawResponse})}})}_getAuthorizationHeader(){return AL_(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var q8a=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},cml=class{constructor(t={}){this._options=t}getSettings(t,r){return rw.fromPromise(this.__getSettings(t,r))}__getSettings(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getDocsSettings(t,r){return rw.fromPromise(this.__getDocsSettings(t,r))}__getDocsSettings(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/docs"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai/docs.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}toggleAskAi(t,r){return rw.fromPromise(this.__toggleAskAi(t,r))}__toggleAskAi(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c,preview:d}=t,s={};s.domain=o,s.org_name=c,d!=null&&(s.preview=d.toString());let u=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),l=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/toggle"),method:"POST",headers:u,queryParameters:Object.assign(Object.assign({},s),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new iE(l.error.body,l.rawResponse);default:throw new zp({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new zp({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/ask-ai/toggle.");case"unknown":throw new zp({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}reindexAskAi(t,r){return rw.fromPromise(this.__reindexAskAi(t,r))}__reindexAskAi(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c}=t,d={};d.domain=o,d.org_name=c;let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/reindex"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/ask-ai/reindex.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getToggleStatus(t,r){return rw.fromPromise(this.__getToggleStatus(t,r))}__getToggleStatus(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/ask-ai/toggle/status"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /settings/ask-ai/toggle/status.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}reindexPreviewCallback(t,r){return rw.fromPromise(this.__reindexPreviewCallback(t,r))}__reindexPreviewCallback(t,r){return q8a(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"settings/reindex-preview-callback"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /settings/reindex-preview-callback.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return q8a(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var qBi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(n.next(u))}catch(l){o(l)}}function d(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,d)}s((n=n.apply(e,t||[])).next())})},lml=class{constructor(t={}){this._options=t}createSlackIntegration(t,r){return rw.fromPromise(this.__createSlackIntegration(t,r))}__createSlackIntegration(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/integrations"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/integrations.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}handleSlackEvents(t){return rw.fromPromise(this.__handleSlackEvents(t))}__handleSlackEvents(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/events"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/events.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackSlashCommands(t){return rw.fromPromise(this.__handleSlackSlashCommands(t))}__handleSlackSlashCommands(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/slash-commands"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/slash-commands.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackInteractions(t){return rw.fromPromise(this.__handleSlackInteractions(t))}__handleSlackInteractions(t){return qBi(this,void 0,void 0,function*(){var r,n,i;let a=Sw((r=this._options)===null||r===void 0?void 0:r.headers,oj({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield Gw({url:Ew.join((i=(n=yield cy.get(this._options.baseUrl))!==null&&n!==void 0?n:yield cy.get(this._options.environment))!==null&&i!==void 0?i:uj.Production,"slack/interactions"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new zp({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new zp({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling POST /slack/interactions.");case"unknown":throw new zp({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackOauthCallback(t,r){return rw.fromPromise(this.__handleSlackOauthCallback(t,r))}__handleSlackOauthCallback(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let{code:o,state:c}=t,d={};d.code=o,c!=null&&(d.state=c);let s=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/oauth/callback"),method:"GET",headers:s,queryParameters:Object.assign(Object.assign({},d),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new iE(u.error.body,u.rawResponse);default:throw new zp({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new zp({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/oauth/callback.");case"unknown":throw new zp({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getSlackInstallLink(t,r){return rw.fromPromise(this.__getSlackInstallLink(t,r))}__getSlackInstallLink(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let d=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,"slack/get-install"),method:"GET",headers:d,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new iE(s.error.body,s.rawResponse);default:throw new zp({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new zp({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/get-install.");case"unknown":throw new zp({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}listSlackIntegrations(t,r){return rw.fromPromise(this.__listSlackIntegrations(t,r))}__listSlackIntegrations(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`slack/integrations/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/integrations/{domain}.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}getSlackInstallLinkById(t,r){return rw.fromPromise(this.__getSlackInstallLinkById(t,r))}__getSlackInstallLinkById(t,r){return qBi(this,void 0,void 0,function*(){var n,i,a;let o=Sw((n=this._options)===null||n===void 0?void 0:n.headers,oj({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield Gw({url:Ew.join((a=(i=yield cy.get(this._options.baseUrl))!==null&&i!==void 0?i:yield cy.get(this._options.environment))!==null&&a!==void 0?a:uj.Production,`slack/get-install/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new iE(c.error.body,c.rawResponse);default:throw new zp({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new zp({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new tw("Timeout exceeded when calling GET /slack/get-install/{integration_id}.");case"unknown":throw new zp({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return qBi(this,void 0,void 0,function*(){let t=yield cy.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var ZFu=class{constructor(t={}){this._options=Object.assign(Object.assign({},t),{headers:Sw({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@fern-api/fai-sdk","X-Fern-SDK-Version":"0.0.2-9f9be72b3","X-Fern-Runtime":$0l.type,"X-Fern-Runtime-Version":$0l.version},t?.headers)})}get analytics(){var t;return(t=this._analytics)!==null&&t!==void 0?t:this._analytics=new Y0l(this._options)}get chat(){var t;return(t=this._chat)!==null&&t!==void 0?t:this._chat=new X0l(this._options)}get conversation(){var t;return(t=this._conversation)!==null&&t!==void 0?t:this._conversation=new Z0l(this._options)}get discord(){var t;return(t=this._discord)!==null&&t!==void 0?t:this._discord=new k0l(this._options)}get document(){var t;return(t=this._document)!==null&&t!==void 0?t:this._document=new eml(this._options)}get feedback(){var t;return(t=this._feedback)!==null&&t!==void 0?t:this._feedback=new tml(this._options)}get github(){var t;return(t=this._github)!==null&&t!==void 0?t:this._github=new rml(this._options)}get guidance(){var t;return(t=this._guidance)!==null&&t!==void 0?t:this._guidance=new nml(this._options)}get health(){var t;return(t=this._health)!==null&&t!==void 0?t:this._health=new iml(this._options)}get index(){var t;return(t=this._index)!==null&&t!==void 0?t:this._index=new oml(this._options)}get mcp(){var t;return(t=this._mcp)!==null&&t!==void 0?t:this._mcp=new uml(this._options)}get query(){var t;return(t=this._query)!==null&&t!==void 0?t:this._query=new sml(this._options)}get settings(){var t;return(t=this._settings)!==null&&t!==void 0?t:this._settings=new cml(this._options)}get slack(){var t;return(t=this._slack)!==null&&t!==void 0?t:this._slack=new lml(this._options)}};function CVE({token:e}){return new ZFu({baseUrl:"https://fai.buildwithfern.com",token:e})}var hWE=fa(_WE(),1);var yWE=require("util"),kkQ=(0,yWE.promisify)(hWE.default);async function vWE(e,t,r){let n=u9o(e,t),i=[];for(let a of n){let o=await Promise.all(a.map(async c=>{try{let d=await kkQ(c);return d==null||d.height==null||d.width==null?void 0:{filePath:c,width:d.width,height:d.height,blurDataUrl:void 0}}catch(d){r.logger.error(`Failed to measure image size for ${c}. ${d?.message}`);return}}));i.push(...o.filter(kw))}return new Map(i.map(a=>[a.filePath,a]))}var eeL=10,bWE=10;async function PWE({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,apiWorkspaces:a,ossWorkspaces:o,context:c,preview:d,editThisPage:s,isPrivate:u=!1,disableTemplates:l=!1,skipUpload:m=!1}){let A=Xua({token:e.value}),P=u?{type:"private",authType:"sso"}:{type:"public"},C,M=i[0]??n,T=teL(n),z=r.config.experimental?.dynamicSnippets,U=d||z,V=await new TRr(n,r,o,a,c,s,async re=>{let X=new Map(re.map(he=>[he.absoluteFilePath,he])),ne=re.map(he=>({...he,mediaType:VL_.lookup(he.absoluteFilePath)})).filter(he=>he.mediaType!==!1).filter(he=>z7.parse(he.mediaType)?.isImage()??!1).map(he=>he.absoluteFilePath),Oe=await vWE(ne,eeL,c),be=[];[...Oe.values()].forEach(he=>{let Me=X.get(he.filePath);if(Me==null)return;let Be={filePath:zyi.FernRegistry.docs.v1.write.FilePath(tos(Me.relativeFilePath)),width:he.width,height:he.height,blurDataUrl:he.blurDataUrl,alt:void 0};be.push(Be)});let me=re.filter(({absoluteFilePath:he})=>!Oe.has(he)).map(({relativeFilePath:he})=>tos(he));if(d){let he=await A.docs.v2.write.startDocsPreviewRegister({orgId:zyi.FernRegistry.OrgId(t),authConfig:u?{type:"private",authType:"sso"}:{type:"public"},filepaths:me.map(Me=>zyi.FernRegistry.docs.v1.write.FilePath(Me)),images:be,basePath:T});return he.ok?(M=he.body.previewUrl,C=he.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs preview"):await gWE(he.body.uploadUrls,r.absoluteFilePath,c,bWE),mWE(he.body.uploadUrls,r.absoluteFilePath)):await OWE(he.error,c)}else{let he=await A.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:P,apiId:zyi.FernRegistry.ApiId(""),orgId:zyi.FernRegistry.OrgId(t),filepaths:me.map(Me=>zyi.FernRegistry.docs.v1.write.FilePath(Me)),images:be});return he.ok?(C=he.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs"):await gWE(he.body.uploadUrls,r.absoluteFilePath,c,bWE),mWE(he.body.uploadUrls,r.absoluteFilePath)):OWE(he.error,c)}},async({ir:re,snippetsConfig:X,playgroundConfig:ee,apiName:ne,workspace:Oe})=>{let be=DIe({ir:re,snippetsConfig:X,playgroundConfig:ee,context:c}),me;z&&(me=await reL({workspace:Oe,organization:t,context:c,snippetsConfig:X}));let he=await A.api.v1.register.registerApiDefinition({orgId:zyi.FernRegistry.OrgId(t),apiId:zyi.FernRegistry.ApiId(re.apiName.originalName),definition:be,definitionV2:void 0,dynamicIRs:me});if(he.ok)return c.logger.debug(`Registered API Definition ${ne}: ${he.body.apiDefinitionId}`),he.body.dynamicIRs&&me&&(m?c.logger.debug("Skip-upload mode: skipping dynamic IR uploads"):await neL({dynamicIRs:me,dynamicIRUploadUrls:he.body.dynamicIRs,context:c,apiId:he.body.apiDefinitionId})),he.body.apiDefinitionId;switch(he.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return ne!=null?c.failAndThrow(`Failed to publish docs because API definition (${ne}) could not be uploaded. Please contact support@buildwithfern.com
|
|
3041
3042
|
${JSON.stringify(he.error)}`):c.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com
|
|
3042
3043
|
${JSON.stringify(he.error)}`)}}).resolve();if(C==null)return c.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");c.logger.debug("Publishing docs...");let $=await A.docs.v2.write.finishDocsRegister(zyi.FernRegistry.docs.v1.write.DocsRegistrationId(C),{docsDefinition:V});if($.ok){let re=Gwe(M);await ieL({docsDefinition:V,organization:t,token:e,url:re.replace("https://",""),context:c,fdr:A,preview:d});let X=BBi(re,re);c.logger.info(od.green(`Published docs to ${X}`))}else switch($.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return c.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${C} does not exist.`);default:return c.failAndThrow("Failed to publish docs to "+n,$.error)}}async function gWE(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let o=u9o(Object.entries(e),n),c=0;for(let s of o){await Promise.all(s.map(async([l,{uploadUrl:m}])=>{let A=ys.of(l),P=A1(t,A);try{let C=VL_.lookup(P);await rZ.put(m,await(0,AWE.readFile)(P),{headers:{"Content-Type":C===!1?"application/octet-stream":C,"Cache-Control":"public, max-age=31536000, immutable"}})}catch(C){r.failAndThrow(`Failed to upload ${P}`,C)}}));let u=Date.now();c+=s.length,r.logger.debug(`Uploaded ${c}/${a} files in ${u-i}ms`)}let d=Date.now();r.logger.debug(`Finished uploading ${a} files in ${d-i}ms`)}function mWE(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=ys.of(n),o=A1(t,a);r.push({relativeFilePath:a,absoluteFilePath:o,fileId:i.fileId})}return r}async function OWE(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function teL(e){try{return new URL(Gwe(e)).pathname}catch{return}}async function reL({workspace:e,organization:t,context:r,snippetsConfig:n}){let i={};if(!e)return;Object.keys(n).length===0&&(r.logger.warn(`WARNING: No snippets defined for ${e.workspaceName}.`),r.logger.warn("Did you add snippets to your docs configuration?"),r.logger.warn("For more info: https://buildwithfern.com/learn/docs/api-references/sdk-snippets"));let a={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo,csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:n.rustSdk?.package};if(e.generatorsConfiguration?.groups)for(let o of e.generatorsConfiguration.groups)for(let c of o.generators){let d=Q0l({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),s="";if(d?.outputConfig.type==="publish")switch(d.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":s=d.outputConfig.value.packageName;break;case"maven":s=d.outputConfig.value.coordinate;break;case"go":s=d.outputConfig.value.repoUrl;break;case"crates":s=d.outputConfig.value.packageName;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(s=c.config.packageName??""),!!c.language&&c.language&&a[c.language]===s){let u=qH({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:s,version:void 0,context:r,sourceResolver:new BH(r,e),dynamicGeneratorConfig:d}),l=aiu({ir:u,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:d});l?i[c.language]={dynamicIR:l}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}for(let[o,c]of Object.entries(a))o&&c&&!Object.keys(i).includes(o)&&(r.logger.warn(),r.logger.warn(`Failed to upload ${o} SDK snippets because of unknown package \`${c}\`.`),r.logger.warn(`Please make sure your ${e.workspaceName?`${e.workspaceName}/`:""}generators.yml has a generator that publishes a ${c} package.`),r.logger.warn());if(Object.keys(i).length>0)return i}async function neL({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,a]of Object.entries(t)){let o=e[i]?.dynamicIR;o?(await fetch(a.uploadUrl,{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/octet-stream","Content-Length":JSON.stringify(o).length.toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`):r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function ieL({docsDefinition:e,organization:t,token:r,url:n,context:i,fdr:a,preview:o}){if(e.config.aiChatConfig==null)return;i.logger.debug("Processing AI Chat configuration from docs.yml");let c=new URL(Gwe(n)).hostname;if(e.config.aiChatConfig.location!=null){for(let d of e.config.aiChatConfig.location)if(d==="docs"){let s=CVE({token:r.value}),u=await s.settings.getDocsSettings({domain:c});if(u.job_id)continue;i.logger.debug(`Starting Ask Fern docs content ${u.ask_ai_enabled?"reindexing":"indexing"}...`),(await a.docs.v2.write.addAlgoliaPreviewWhitelistEntry({domain:c})).ok?(u.ask_ai_enabled?await s.settings.reindexAskAi({domain:c,org_name:t}):await s.settings.toggleAskAi({domain:c,org_name:t,preview:o})).success&&i.logger.info(od.green("Note: it may take a few minutes after publishing for Ask Fern answers to reflect new content.")):i.logger.warn(`Failed to add domain ${c} to Algolia whitelist. Please try regenerating to test AI chat in preview.`)}}}async function WL_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:o,preview:c,disableTemplates:d,skipUpload:s}){let u=n.config.instances;if(n.config=Yxi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),u.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(u.length>1&&o==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${u[0]?.url})`);return}let l=u.find(A=>A.url===o)??u[0];if(l==null){i.failAndThrow(`No docs instance with url ${o}. Failed to register.`);return}let m=[];l.customDomain!=null&&(typeof l.customDomain=="string"?m.push(l.customDomain):Array.isArray(l.customDomain)&&m.push(...l.customDomain)),await i.runInteractiveTask({name:l.url},async()=>{await PWE({docsWorkspace:n,customDomains:m,domain:l.url,token:a,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:c,editThisPage:l.editThisPage,isPrivate:l.private,disableTemplates:d,skipUpload:s})})}var wHE=fa(D6i(),1);var Rhe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function oL(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function aDr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(Zq(e))for(let n of Object.values(e))aDr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)aDr({example:n,visitor:t,nodePath:r})}function Jzr(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function wWE({service:e,visitor:t,nodePath:r}){t.httpService?.(e,r),rN(e,{url:n=>{t.serviceBaseUrl?.(n,[...r,"url"])},"base-path":Hc,"display-name":Hc,availability:Hc,headers:n=>{jWE({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Hc,auth:Hc,"path-parameters":n=>{txu({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let o=[...r,"endpoints",i];aeL({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:o})}},idempotent:Hc,transport:Hc,source:Hc})}function aeL({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=Jzr(n);n.httpEndpoint?.({endpointId:e,endpoint:t,service:r},i),rN(t,{docs:oL(n,i),"display-name":Hc,availability:Hc,"base-path":Hc,path:Hc,idempotent:Hc,url:o=>{n.endpointBaseUrl?.({baseUrl:o,service:r},[...i,"url"])},"path-parameters":o=>{txu({pathParameters:o,visitor:n,nodePath:[...i,"path-parameters"]})},request:o=>{if(o==null)return;let c=[...i,"request"];if(typeof o=="string"){a(o,c,{location:"requestReference"});return}rN(o,{name:Hc,docs:oL(n,c),"path-parameters":d=>{txu({pathParameters:d,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":d=>{if(d!=null)for(let[s,u]of Object.entries(d)){let l=[...c,"query-parameters",s];n.queryParameter?.({queryParameterKey:s,queryParameter:u},l),typeof u=="string"?a(u,l):rN(u,{name:Hc,docs:oL(n,l),availability:Hc,type:m=>{a(m,[...l,"type"],{_default:u.default,validation:u.validation})},"allow-multiple":Hc,audiences:Hc,encoding:Hc,default:Hc,validation:Hc})}},"content-type":Hc,headers:d=>{jWE({headers:d,visitor:n,nodePath:[...c,"headers"]})},body:d=>{if(d==null)return;let s=[...c,"body"];typeof d=="string"?a(d,s,{location:"requestReference"}):s9(d)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:d},s),rN(d,{extends:u=>{if(u==null)return;let l=typeof u=="string"?[u]:u;for(let m of l){let A=[...s,"extends",m];n.extension?.(m,A),a(m,A)}},properties:u=>{if(u!=null)for(let[l,m]of Object.entries(u)){let A=[...s,"properties",l];typeof m=="string"?a(m,A,{location:Rhe.InlinedRequestProperty}):rN(m,{name:Hc,docs:oL(n,A),availability:Hc,type:P=>{a(P,[...A,"type"],{location:Rhe.InlinedRequestProperty,_default:m.default,validation:m.validation})},style:Hc,"content-type":Hc,audiences:Hc,encoding:Hc,default:Hc,validation:Hc})}},"extra-properties":Hc})):(oL(n,s)(d.docs),a(d.type,s))}})},audiences:Hc,method:Hc,auth:Hc,"stream-condition":o=>{n.streamCondition?.({streamCondition:o,endpoint:t},[...i,"stream-condition"])},"response-stream":o=>{o!=null&&(typeof o=="string"?a(o,[...i,"response-stream"],{location:Rhe.StreamingResponse}):a(o.type,[...i,"response-stream"],{location:Rhe.StreamingResponse}))},response:o=>{if(o==null)return;let c=[...i,"response"];typeof o=="string"?a(o,c,{location:Rhe.Response}):rN(o,{docs:oL(n,c),type:d=>{d!=null&&a(d,[...c,"type"],{location:Rhe.Response})},property:Hc,"status-code":Hc})},errors:o=>{if(o!=null)for(let c of o){let d=[...i,"errors",typeof c=="string"?c:c.error];typeof c=="string"?n.errorReference?.(c,d):rN(c,{docs:oL(n,d),error:s=>{n.errorReference?.(s,[...d,"error"])}})}},examples:o=>{if(o!=null)for(let[c,d]of o.entries())oeL({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:d})},pagination:Hc,source:Hc,transport:Hc,retries:Hc})}function oeL({nodePathForExample:e,visitor:t,service:r,endpoint:n,example:i}){if(i.headers==null&&i["path-parameters"]==null&&i["query-parameters"]==null&&i.request==null&&i.response==null&&i["code-samples"]!=null)return;t.exampleHttpEndpointCall?.({service:r,endpoint:n,example:i},e);let a=[...e,"headers"];if(t.exampleHeaders?.({service:r,endpoint:n,examples:i.headers},a),i.headers!=null)for(let u of Object.values(i.headers))aDr({example:u,visitor:t,nodePath:a});let o=[...e,"path-parameters"];if(t.examplePathParameters?.({service:r,endpoint:n,examples:i["path-parameters"]},o),i["path-parameters"]!=null)for(let u of Object.values(i["path-parameters"]))aDr({example:u,visitor:t,nodePath:o});let c=[...e,"query-parameters"];if(t.exampleQueryParameters?.({service:r,endpoint:n,examples:i["query-parameters"]},c),i["query-parameters"]!=null)for(let u of Object.values(i["query-parameters"]))aDr({example:u,visitor:t,nodePath:c});let d=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},d),i.request!=null&&aDr({example:i.request,visitor:t,nodePath:d});let s=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},s),i.response!=null&&Aua(n,i.response,{body:u=>{u.body!=null&&aDr({example:u.body,visitor:t,nodePath:s}),u.error!=null&&t.errorReference?.(u.error,[...s,"error"])},stream:u=>{for(let l of u.stream)aDr({example:l,visitor:t,nodePath:s})},events:u=>{for(let{data:l}of u.stream)aDr({example:l,visitor:t,nodePath:s})}}),i["code-samples"]!=null)for(let[u,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:u}])}function txu({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=Jzr(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},o),bYa(a)?typeof a=="string"?t.variableReference?.(a,o):rN(a,{docs:oL(t,o),variable:c=>t.variableReference?.(c,[...o,"variable"]),availability:Hc}):typeof a=="string"?n(a,o):rN(a,{docs:oL(t,o),type:c=>{n(c,[...o,"type"],{_default:a.default,validation:a.validation})},availability:Hc,encoding:Hc,default:Hc,validation:Hc,name:Hc,audiences:Hc})}}function jWE({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=Jzr(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):rN(a,{name:Hc,availability:Hc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:oL(t,o),audiences:Hc,encoding:Hc,env:Hc,default:Hc,validation:Hc})}}function EWE({typeDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.typeName?.(n,a),HL_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function HL_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=Jzr(r);r.typeDeclaration?.({typeName:{isInlined:!1,name:e},declaration:t,nodePath:n},n);let a=o=>{if(o!=null)for(let[c,d]of o.entries()){let s=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:d},s),aDr({example:d.value,nodePath:s,visitor:r})}};Oee(t,{alias:o=>{typeof o=="string"?i(o,n):rN(o,{type:c=>{i(c,[...n,"type"])},docs:oL(r,n),availability:Hc,audiences:Hc,examples:a,validation:Hc,encoding:Hc,source:Hc,inline:Hc})},object:o=>{rN(o,{docs:oL(r,n),extends:c=>{if(c==null)return;let d=typeof c=="string"?[c]:c;for(let s of d){let u=[...n,"extends",s];r.extension?.(s,u),i(s,u)}},properties:c=>{if(c!=null)for(let[d,s]of Object.entries(c)){let u=[...n,"properties",d];typeof s=="string"?i(s,u):rN(s,{name:Hc,docs:oL(r,u),availability:Hc,type:l=>{i(l,[...u,"type"],{_default:s.default,validation:s.validation})},audiences:Hc,encoding:Hc,default:Hc,validation:Hc,access:Hc})}},"extra-properties":Hc,availability:Hc,audiences:Hc,encoding:Hc,source:Hc,examples:a,inline:Hc})},discriminatedUnion:o=>{rN(o,{docs:oL(r,n),discriminant:Hc,extends:c=>{if(c==null)return;let d=typeof c=="string"?[c]:c;for(let s of d){let u=[...n,"extends",s];r.extension?.(s,u),i(s,u)}},union:c=>{for(let[d,s]of Object.entries(c)){let u=[...n,"union",d];typeof s=="string"?i(s,u):rN(s,{docs:oL(r,u),name:Hc,key:Hc,type:l=>{typeof l=="string"&&i(l,[...n,"type"])},"display-name":Hc,availability:Hc})}},"base-properties":Hc,availability:Hc,audiences:Hc,encoding:Hc,source:Hc,examples:a,inline:Hc})},undiscriminatedUnion:o=>{rN(o,{docs:oL(r,n),discriminated:Hc,union:c=>{for(let[d,s]of c.entries()){let u=[...n,`union[${d}]`];typeof s!="string"&&rN(s,{docs:oL(r,u),type:l=>{i(l,[...n,"type"])},"display-name":Hc,validation:Hc})}},availability:Hc,audiences:Hc,encoding:Hc,source:Hc,examples:a,inline:Hc})},enum:o=>{rN(o,{docs:oL(r,n),enum:c=>{for(let d of c){let s=[...n,typeof d=="string"?d:d.name??d.value];typeof d!="string"&&rN(d,{docs:oL(r,s),name:Hc,value:Hc,casing:Hc})}},availability:Hc,audiences:Hc,default:Hc,encoding:Hc,source:Hc,examples:a,inline:Hc})}})}function SWE({errorDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.errorDeclaration?.({errorName:n,declaration:i},a),ueL({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function ueL({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=Jzr(r);typeof t=="string"?i(t,n):rN(t,{docs:oL(r,n),"status-code":Hc,type:a=>{if(a==null)return;let o=[...n,"type"];typeof a=="string"?i(a,o):HL_({typeName:e,declaration:a,visitor:r,nodePathForType:o})},examples:a=>{if(a!=null)for(let o of a){let c=[...n,"type"];r.exampleError?.({errorName:e,declaration:t,example:o},c)}}})}function DWE({imports:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e))t.import?.({importPath:i,importedAs:n},[...r,n])}function CWE({webhook:e,visitor:t,nodePathForWebhook:r}){let n=Jzr(t);rN(e,{"display-name":Hc,method:Hc,examples:Hc,headers:i=>{seL({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(ceL(i)){n(i.type,[...a,"type"],{location:"requestReference"});return}let o=[...a];t.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:i},o),rN(i,{name:Hc,extends:c=>{if(c==null)return;let d=typeof c=="string"?[c]:c;for(let s of d){let u=[...o,"extends",s];t.extension?.(s,u),n(s,u)}},properties:c=>{if(c!=null)for(let[d,s]of Object.entries(c)){let u=[...o,"properties",d];typeof s=="string"?n(s,u,{location:Rhe.InlinedRequestProperty}):rN(s,{name:Hc,docs:oL(t,u),availability:Hc,type:l=>{n(l,[...u,"type"],{_default:s.default,validation:s.validation,location:Rhe.InlinedRequestProperty})},audiences:Hc,encoding:Hc,default:Hc,validation:Hc,access:Hc})}}})},audiences:Hc,availability:Hc,docs:oL(t,r)})}function seL({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=Jzr(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):rN(a,{name:Hc,availability:Hc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:oL(t,o),audiences:Hc,encoding:Hc,env:Hc,default:Hc,validation:Hc})}}function ceL(e){return e.type!=null}function Eme(e,t){rN(e,{docs:oL(t,[]),imports:r=>{DWE({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{EWE({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&wWE({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))CWE({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Hc,errors:r=>{SWE({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function GL_(e,t){rN(e,{docs:Hc,imports:Hc,types:Hc,service:Hc,webhooks:Hc,errors:Hc,channel:Hc,export:r=>{t.export?.(typeof r=="string"?r:r?.dependency,["export"])},navigation:r=>{t.navigation?.(r,["navigation"])}})}function JL_(e,t){t.file?.(e,[]),rN(e,{version:Hc,product:Hc,name:Hc,"default-url":Hc,"display-name":Hc,imports:Hc,auth:Hc,"idempotency-headers":Hc,"auth-schemes":r=>Object.entries(r??{}).map(([n,i])=>{lof(i)&&t.oauth?.({name:n,oauth:i},["auth-scheme",n])}),pagination:Hc,"default-environment":r=>{t.defaultEnvironment?.(r,["default-environment"])},docs:Hc,headers:Hc,environments:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.environment?.({environmentId:n,environment:i},["environments",n])},"error-discrimination":r=>{t.errorDiscrimination?.(r,["error-discrimination"])},audiences:Hc,errors:r=>{if(r!=null)for(let n of r)t.errorReference?.(n,["errors",n])},"base-path":Hc,"path-parameters":r=>{txu({pathParameters:r,visitor:t,nodePath:["path-parameters"]})},variables:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.variableDeclaration?.({variableId:n,variable:i},["variables",n])}})}var Lml=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function IWE({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,d)=>{for(let s of r){let u=s.definitionFile?.[a];if(u!=null){let l=u(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:d,message:m.message})))}}};return{[a]:o}}return{...i("docs"),...i("import"),...i("typeReference"),...i("typeDeclaration"),...i("typeName"),...i("httpService"),...i("httpEndpoint"),...i("pathParameter"),...i("queryParameter"),...i("streamCondition"),...i("header"),...i("errorDeclaration"),...i("errorReference"),...i("exampleType"),...i("exampleTypeReference"),...i("exampleHttpEndpointCall"),...i("exampleCodeSample"),...i("exampleHeaders"),...i("examplePathParameters"),...i("exampleQueryParameters"),...i("exampleRequest"),...i("exampleResponse"),...i("variableReference"),...i("extension"),...i("serviceBaseUrl"),...i("endpointBaseUrl"),...i("exampleError")}}function MWE({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,d)=>{for(let s of r){let u=s.packageMarker?.[a];if(u!=null){let l=u(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:d,message:m.message})))}}};return{[a]:o}}return{...i("export"),...i("navigation")}}function BWE({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,d)=>{for(let s of r){let u=s.rootApiFile?.[a];if(u!=null){let l=u(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:d,message:m.message})))}}};return{[a]:o}}return{...i("file"),...i("oauth"),...i("defaultEnvironment"),...i("environment"),...i("errorDiscrimination"),...i("errorReference"),...i("variableDeclaration"),...i("variableReference"),...i("pathParameter")}}var KL_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(Oua(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&s9(e.request.body)){let r=[];for(let[n,i]of Object.entries(e.request.body.properties??{}))typeof i!="string"&&i["content-type"]!=null&&r.push({severity:"fatal",message:`${n} has content-type, but the request is not multipart`});return r}return[]}}})};var Wx=cIe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var $L_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new OF(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:n,contents:i})=>{if(r.request==null||typeof r.request=="string"||r.request?.body==null||typeof r.request.body=="string")return[];if(!leL(r.request.body))return[];let a=[];for(let[o,c]of Object.entries(r.request.body.properties??{})){if(typeof c=="string"||c.style!=="exploded")continue;let d=YS({relativeFilepath:n,definitionFile:i,casingsGenerator:Wx,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:c.type,file:d});if(s==null)return[];TWE(s)||a.push({message:`${o} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function TWE(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?TWE(e.container.itemType):!1}function leL(e){return e?.properties!=null}var YL_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(VPi(e.definition)),r=new Set;return t.forEach(n=>{let i=Jl(e.definition.absoluteFilePath,ys.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let o=[],c=Jl(e.definition.absoluteFilePath,Ug(a),ys.of(i));return r.has(c)||o.push({severity:"fatal",message:`Import ${od.bold(n)} points to non-existent path ${od.bold(i)}.`}),o}}}}};function Uml(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(Pnt(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var XL_={name:"matching-environment-urls",create:({workspace:e})=>{let t=Uml(e);return t.length===0?{}:{rootApiFile:{environment:({environmentId:r,environment:n})=>{let i=[],a=o=>{i.push({severity:"fatal",message:`Environment ${r} is missing URL for ${od.bold(o)}`})};return qLr(n,{singleBaseUrl:()=>{for(let o of t)a(o)},multipleBaseUrls:o=>{for(let c of t)o.urls[c]==null&&a(c)}}),i}}}}};var ZL_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=feL(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=o5i({referencedIn:n,importPath:ys.of(r)});return i.filter(({chainWithoutStartingFilepath:c})=>c.length===0||c[0]===a).map(c=>({severity:"fatal",message:c.chainWithoutStartingFilepath.length===0?"A file cannot import itself":`Circular import detected: ${[c.startingFilepath,...c.chainWithoutStartingFilepath,c.startingFilepath].join(" -> ")}`}))}}}}};function feL(e){let t={};for(let r of JBr(e))t[r]=qWE(r,[r],e);return t}function qWE(e,t,r){let n=[],i=r[e];if(i==null)return[];if(i.contents.imports!=null)for(let a of Object.values(i.contents.imports)){let o=o5i({referencedIn:e,importPath:ys.of(a)});t.includes(o)?t[0]===o&&t[0]===deL(t)&&n.push({startingFilepath:o,chainWithoutStartingFilepath:t.slice(1)}):n.push(...qWE(o,[...t,o],r))}return n}function deL(e){return e.reduce((t,r)=>r<t?r:t)}var Vml=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new OF(t)}isTypeComplex(t,r){let n=YS({relativeFilepath:r.relativeFilepath,definitionFile:r.contents,casingsGenerator:Wx,rootApiFile:this.workspace.definition.rootApiFile.contents}),i=this.typeResolver.resolveType({type:t,file:n});if(i==null)return;let a=new Set;return this.isResolvedReferenceComplex({type:i,file:n,visited:a})}isResolvedReferenceComplex({type:t,file:r,visited:n}){switch(t._type){case"container":return this.isResolvedContainerComplex({type:t.container,file:r,visited:n});case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":return!1;case"unknown":return!0;default:tc(t)}}isResolvedContainerComplex({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return(this.isResolvedReferenceComplex({type:t.keyType,file:r,visited:n})||this.isResolvedReferenceComplex({type:t.valueType,file:r,visited:n}))&&!(t.keyType._type==="primitive"&&t.keyType.primitive.v1==="STRING"&&t.valueType._type==="unknown");case"optional":case"nullable":case"list":case"set":return this.isResolvedReferenceComplex({type:t.itemType,file:r,visited:n});default:tc(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),o6i(t.declaration))return!0;if(BTr(t.declaration))return!1;if(mx(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(gYa(t.declaration)){for(let i of t.declaration.union){let a=typeof i=="string"?i:i.type,o=this.isTypeComplex(a,{contents:r.definitionFile,relativeFilepath:r.relativeFilepath});if(o!=null&&o)return!0}return!1}tc(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return MRr({typeName:t,objectDeclaration:r,typeResolver:this.typeResolver,definitionFile:n.definitionFile,workspace:this.workspace,filepathOfDeclaration:n.relativeFilepath,smartCasing:!1}).some(o=>this.isComplex({type:o.resolvedPropertyType,file:n,visited:i}))}isComplex({type:t,file:r,visited:n}){switch(t._type){case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":case"unknown":return!1;case"container":return this.isComplexContainer({type:t.container,file:r,visited:n});default:tc(t)}}isComplexContainer({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return this.isComplex({type:t.keyType,file:r,visited:n})||this.isComplex({type:t.valueType,file:r,visited:n});case"optional":case"nullable":case"list":case"set":return this.isComplex({type:t.itemType,file:r,visited:n});default:tc(t)}}};var kL_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new Vml(e);return{definitionFile:{queryParameter:({queryParameter:r},n)=>{let i=typeof r=="string"?r:r.type,a=t.isTypeComplex(i,n);return a!=null&&a?[{severity:"fatal",message:`${i} is not a valid type for a query parameter`}]:[]}}}}};var eU_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===pVs?[{severity:"fatal",message:`Path parameter ${od.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function rxu({service:e,endpoint:t}){return e["base-path"]+t.path}var Wml=class{root=new tU_;registerEndpoint(t){this.root.insert(this.getPathPartsForEndpoint(t),t)}getConflictingEndpoints(t){return this.root.getMatchingEndpoints(this.getPathPartsForEndpoint(t)).filter(r=>!(r.relativeFilepath===t.relativeFilepath&&r.endpointId===t.endpointId)&&r.endpoint.method===t.endpoint.method)}getPathPartsForEndpoint(t){return rxu({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},tU_=class e{childPaths={};childPathParam;endpointsThatEndWithThisNode=[];insert(t,r){let[n,...i]=t;if(n==null){this.endpointsThatEndWithThisNode.push(r);return}(this.isPathParam(n)?this.childPathParam??=new e:this.childPaths[n]??=new e).insert(i,r)}getMatchingEndpoints(t){let[r,...n]=t;if(r==null)return this.endpointsThatEndWithThisNode;let i=[];if(this.isPathParam(r))i.push(...Object.values(this.childPaths).flatMap(a=>a.getMatchingEndpoints(n)));else{let a=this.childPaths[r];a!=null&&i.push(...a.getMatchingEndpoints(n))}return this.childPathParam!=null&&i.push(...this.childPathParam.getMatchingEndpoints(n)),i}isPathParam(t){return t.startsWith("{")&&t.endsWith("}")}};var rU_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new Wml;return Lee(e,(r,n)=>{Eme(n,{httpEndpoint:({service:i,endpointId:a,endpoint:o})=>{t.registerEndpoint({service:i,endpointId:a,endpoint:o,relativeFilepath:r})}})}),{definitionFile:{httpEndpoint:({service:r,endpoint:n,endpointId:i},{relativeFilepath:a})=>{let o=t.getConflictingEndpoints({service:r,endpointId:i,endpoint:n,relativeFilepath:a});return o.length===0?[]:[{severity:"warning",message:[`Endpoint path ${rxu({service:r,endpoint:n})} conflicts with other endpoints:`,...o.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${od.dim(rxu({service:c.service,endpoint:c.endpoint}))}`)].join(`
|
|
3043
3044
|
`)}]}}}}};var nU_={name:"no-conflicting-request-wrapper-properties",create:({workspace:e})=>({definitionFile:{httpEndpoint:({endpoint:t,service:r},{contents:n,relativeFilepath:i})=>{let a=peL({endpoint:t,service:r,relativeFilepath:i,definitionFile:n,workspace:e}),o=[];for(let[c,d]of Object.entries(a))d.length<=1||o.push({severity:"fatal",message:`Multiple request properties have the name ${od.bold(c)}. This is not suitable for code generation. Use the "name" property to deconflict.
|