fern-api 3.0.1 → 3.0.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.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1153,7 +1153,7 @@ ${o4p.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&U9s(th
1153
1153
  `+KHi.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?KHi.default.cyan(h4p(t,this.opt.mask)):KHi.default.italic(KHi.default.dim("[hidden]")):this.opt.mask?h4p(t,this.opt.mask):KHi.default.italic(KHi.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 m0o=ae(v1(),1);var h3p=ae(AGs(),1),O0o=require("child_process"),cTn=require("fs"),g0o=ae(require("path"),1),y3p=ae(require("os"),1),b3p=require("crypto"),a7s=ae(p3p(),1);var y0o=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var nOa=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var b0o=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var v0o=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function A0o(e="",t,r){let i=new o7s(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function _3p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function cOS(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var o7s=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=cOS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??y3p.default.tmpdir(),r=(0,b3p.randomUUID)(),i=_3p(this.fileOptions.prefix),n=_3p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=g0o.default.resolve(t,a),c=g0o.default.resolve(t)+g0o.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,cTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new y0o(t)}}readTemporaryFile(){try{let t=(0,cTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,h3p.detect)(t)??"utf8";a7s.default.encodingExists(r)||(r="utf8"),this.text=a7s.default.decode(t,r)}}catch(t){throw new b0o(t)}}removeTemporaryFile(){try{(0,cTn.unlinkSync)(this.tempFile)}catch(t){throw new v0o(t)}}launchEditor(){try{let t=(0,O0o.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new nOa(t)}}launchEditorAsync(t){try{(0,O0o.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new nOa(r)}}};var v3p=ae(ehe(),1);var aOa=class extends g1{_run(t){this.done=t,this.editorResult=new v3p.Subject;let r=TQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?m0o.default.dim("Received"):m0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=m0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),A0o(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 P3p=require("stream");var A3p=ae(require("readline"),1),m3p=ae(O3p(),1),XHi=class{constructor(t){this.rl||=A3p.default.createInterface(fOS(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 fOS(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new m3p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var oOa=class extends XHi{constructor(t={}){super(t),this.log=new P3p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Wga(this.rl,this.bottomBar.split(`
1154
1154
  `).length),this}updateBottomBar(t){return Wga(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+`
1155
1155
  `}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&&xmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var pO=ae(ehe(),1),E3p=ae(lga(),1);var P0o=ae(ehe(),1),j3p=ae(lga(),1),j0o=function(e,t,r){return typeof e[t]!="function"?(0,P0o.of)(e):(0,P0o.from)((0,j3p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var w3p={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},lTn=class extends XHi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,pO.from)(t):(0,pO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,pO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,pO.from)([t]),this.process=i.pipe((0,pO.concatMap)(this.processQuestion.bind(this)),(0,pO.publish)()),this.process.connect(),this.process.pipe((0,pO.reduce)((n,a)=>(w3p.set(n,a.name,a.answer),n),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,pO.defer)(()=>(0,pO.of)(t).pipe((0,pO.concatMap)(this.setDefaultType.bind(this)),(0,pO.concatMap)(this.filterIfRunnable.bind(this)),(0,pO.concatMap)(()=>j0o(t,"message",this.answers)),(0,pO.concatMap)(()=>j0o(t,"default",this.answers)),(0,pO.concatMap)(()=>j0o(t,"choices",this.answers)),(0,pO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,pO.defer)(()=>(0,pO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,pO.defer)(()=>(0,pO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&w3p.get(this.answers,t.name)!==void 0)return pO.EMPTY;if(t.when===!1)return pO.EMPTY;if(typeof t.when!="function")return(0,pO.of)(t);let{answers:r}=this;return(0,pO.defer)(()=>(0,pO.from)((0,E3p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,pO.filter)(i=>i!=null)))}};function S3p(e){let t=function(r,i){let n;try{n=new lTn(t.prompts,e)}catch(o){return Promise.reject(o)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Gga),this.registerPrompt("input",HHi),this.registerPrompt("number",Hga),this.registerPrompt("confirm",Kga),this.registerPrompt("rawlist",Jga),this.registerPrompt("expand",$ga),this.registerPrompt("checkbox",Yga),this.registerPrompt("password",Xga),this.registerPrompt("editor",aOa)},t.restoreDefaultPrompts(),t}var s7s=S3p();function pOS(e,t){s7s.registerPrompt(e,t)}function _OS(){s7s.restoreDefaultPrompts()}var hOS={prompt:s7s,ui:{BottomBar:oOa,Prompt:lTn},createPromptModule:S3p,registerPrompt:pOS,restoreDefaultPrompts:_OS,Separator:S6},w0o=hOS;var PTn=require("path"),o8p=require("fs"),u8p=require("readline"),ILp="posthog-node";function VmS(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[G0o.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(_=>({..._,stacktrace:_.stacktrace?{..._.stacktrace,type:"raw",frames:(_.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),p={$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&&(p.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:p}),a}}var G0o=class{constructor(t,r,i,n){this.name=ILp,this.name=ILp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(VmS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};G0o.POSTHOG_ID_TAG="posthog_distinct_id";var U0o="0123456789abcdef",H0o=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,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>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|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,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 i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=U0o.charAt(this.bytes[r]>>>4),t+=U0o.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+=U0o.charAt(this.bytes[r]>>>4),t+=U0o.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 i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},H7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??WmS()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}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 H0o.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,H0o.ofInner(t)}},WmS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),CLp,K7s=()=>xmS().toString(),xmS=()=>(CLp||(CLp=new H7s)).generate();function GmS(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function HmS(e,t){global.process.on("uncaughtException",GmS(e,t))}function KmS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var L0o,qLp,V0o;function JmS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return V0o&&r.length===qLp||(qLp=r.length,V0o=r.reduce((i,n)=>{L0o||(L0o={});let a=L0o[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,L0o[n]=[s,u];break}}}return i},{})),V0o}function $mS(e){return typeof Event<"u"&&s8p(e,Event)}function YmS(e){return c8p(e,"Object")}function tHs(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return s8p(e,Error)}}function s8p(e,t){try{return e instanceof t}catch{return!1}}function XmS(e){return c8p(e,"ErrorEvent")}function c8p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function ZmS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=l8p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await a0S(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function l8p(e,t,r){let i=kmS(e,t,r);return i.cause?[i,...l8p(e,i.cause,r)]:[i]}function kmS(e,t,r){if(tHs(t))return t;if(e.synthetic=!0,YmS(t)){let n=e0S(t);if(n)return n;let a=t0S(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function e0S(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(tHs(r))return r}}function t0S(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=i0S(e);if(XmS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=r0S(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function r0S(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function i0S(e,t=40){let r=Object.keys(n0S(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return TLp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:TLp(a,t)}return""}function TLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function n0S(e){return tHs(e)?{message:e.message,name:e.name,stack:e.stack,...RLp(e)}:$mS(e)?{type:e.type,target:zLp(e.target),currentTarget:zLp(e.currentTarget),...RLp(e)}:e}function RLp(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 zLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function a0S(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=o0S(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function o0S(e,t){return u0S(e(t.stack||"",1),e)}function u0S(e,t){let r=JmS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var s0S=2e3,OTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await ZmS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||K7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(HmS(this.onException.bind(this),this.onFatalError.bind(this)),KmS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(s0S)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function c0S(e=process.argv[1]?(0,PTn.dirname)(process.argv[1]):process.cwd(),t=PTn.sep==="\\"){let r=t?NLp(e):e;return i=>{if(!i)return;let n=t?NLp(i):i,{dir:a,base:o,ext:c}=PTn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function NLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var K0o=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)}}},x0o=new K0o(25),f8p=new K0o(20),rHs=7,l0S=1e3,f0S=1e4;async function d0S(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||y0S(o)||b0S(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(f8p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=g0S(a);if(o.every(f=>v0S(n,f)))continue;let c=O0S(x0o,n,{});i.push(p0S(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&_0S(e,x0o),x0o.reduce(),e}function p0S(e,t,r){return new Promise(i=>{let n=(0,o8p.createReadStream)(e),a=(0,u8p.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function p(){f8p.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=A0S(_,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let h=t[f];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function _0S(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;h0S(r.lineno,r,i)}}function h0S(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=d8p(e);n<e;n++){let a=r[n];if(a===void 0){FLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){FLp(t);return}t.context_line=r[e];let i=p8p(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function FLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function y0S(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function b0S(e){return e.lineno!==void 0&&e.lineno>f0S||e.colno!==void 0&&e.colno>l0S}function v0S(e,t){let r=x0o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function g0S(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=QLp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+rHs:(n.push(i),i=QLp(a)),t++}return n}function QLp(e){return[d8p(e),p8p(e)]}function d8p(e){return Math.max(1,e-rHs)}function p8p(e){return e+rHs}function O0S(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function A0S(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var m0S="4.18.0",C6;(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"})(C6||(C6={}));var ULp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(ULp||(ULp={}));var LLp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(LLp||(LLp={}));var VLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(VLp||(VLp={}));var WLp;(function(e){e.Html="html",e.Text="text"})(WLp||(WLp={}));var xLp;(function(e){e.Number="number",e.Emoji="emoji"})(xLp||(xLp={}));var GLp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(GLp||(GLp={}));var HLp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(HLp||(HLp={}));var KLp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(KLp||(KLp={}));var JLp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(JLp||(JLp={}));var P0S=e=>{if("flags"in e){let t=w0S(e.flags),r=E0S(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,_8p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,j0S(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function j0S(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 w0S=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,iHs(r)]).filter(([,t])=>t!==void 0)),E0S=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?_8p(i):void 0]}))},iHs=e=>e===void 0?void 0:e.variant??e.enabled,_8p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},S0S=1,M0S=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"]),D0S="utf8";function B0S(e,t){if(!e||typeof e!="string"||I0S(e))throw new Error(t)}function I0S(e){return e.trim().length===0}function C0S(e){return e?.replace(/\/+$/,"")}async function q0S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function $Lp(){return new Date().getTime()}function x7s(){return new Date().toISOString()}function J0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function T0S(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function R0S(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 z0S(e,t=0,r){let i=R0S(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function YLp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var yOa=String.fromCharCode,XLp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",W0o={};function N0S(e,t){if(!W0o[e]){W0o[e]={};for(let r=0;r<e.length;r++)W0o[e][e.charAt(r)]=r}return W0o[e][t]}var vTn={compressToBase64:function(e){if(e==null)return"";let t=vTn._compress(e,6,function(r){return XLp.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:vTn._decompress(e.length,32,function(t){return N0S(XLp,e.charAt(t))})},compress:function(e){return vTn._compress(e,16,function(t){return yOa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],o,c,f="",s="",u="",l=2,p=3,_=2,h=0,y=0,b;for(b=0;b<e.length;b+=1)if(f=e.charAt(b),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=p++,n[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(i,s))u=s;else{if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++),i[s]=p++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++)}for(c=2,o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;for(;;)if(h=h<<1,y==t-1){a.push(r(h));break}else y++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:vTn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,s="",u,l,p,_,h,y,b;for(u=0;u<3;u+=1)i[u]=u;for(p=0,h=Math.pow(2,2),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=yOa(p);break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=yOa(p);break;case 2:return""}for(i[3]=b,l=b,n.push(b);;){if(a.index>e)return"";for(p=0,h=Math.pow(2,f),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(b=p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=yOa(p),b=c-1,o--;break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=yOa(p),b=c-1,o--;break;case 2:return n.join("")}if(o==0&&(o=Math.pow(2,f),f++),i[b])s=i[b];else if(b===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},J7s=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(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},ATn=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()}},bOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function ZLp(e){if(e instanceof ATn){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 G7s(e){return typeof e=="object"&&(e instanceof ATn||e instanceof bOa)}function kLp(e){return typeof e=="object"&&e instanceof ATn&&e.status===413}var $7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})($7s||($7s={}));var Y7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new J7s,this._isInitialized=!1,B0S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=C0S(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:G7s},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(C6.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(C6.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(C6.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));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=K7s();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}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`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=z0S(this.apiKey,S0S,M0S)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>P0S(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=iHs(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,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={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,i,n,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes($7s.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(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 n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(C6.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(C6.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(C6.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(C6.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(C6.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=J0o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){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 n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:x7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$Lp()}&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(vTn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:x7s(),uuid:i?.uuid?i.uuid:K7s()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await ZLp(t)})}async flush(){let t=YLp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),YLp([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(C6.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(C6.Queue)||[]).slice(n.length);this.setPersistedProperty(C6.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:x7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${$Lp()}&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(vTn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>kLp(p)?!1:G7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(kLp(p)&&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 p instanceof bOa||o(),this._events.emit("error",p),p}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){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,D0S)}catch{c=new TextEncoder().encode(o).length}return await q0S(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new bOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new ATn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(C6.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!G7s(n))throw n;await ZLp(n)}};return Promise.race([new Promise((n,a)=>{J0o(()=>{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)}),i()])}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}},X7s=T0S();if(!X7s){let e=BLp();X7s=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var h8p=X7s,$0o=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()}},y8p=new $0o(async()=>{try{return await import("crypto")}catch{return}});async function F0S(){return await y8p.getValue()}var Q0S=new $0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await y8p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function U0S(){return await Q0S.getValue()}async function L0S(e){let t=await F0S();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await U0S();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).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 V0S=60*1e3,W0S=1152921504606847e3,x0S=["is_not"],gTn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},O1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Z7s=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,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=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||h8p,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,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof O1?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let s=await this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof O1||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new O1("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new O1("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return await this.matchFeatureFlagProperties(t,i[f],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],o=!1,c,f=[...a].sort((s,u)=>{let l=!!s.variant,p=!!u.variant;return l&&p?0:l?-1:p?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,i)){let u=s.variant,l=n.multivariate?.variants||[];u&&l.some(p=>p.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof O1)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new O1("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let f=c.type,s=!1;if(f==="cohort"?s=v8p(c,n,this.cohorts,this.debugMode):s=b8p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await e8p(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await e8p(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),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(V0S,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 gTn(`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 gTn(`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 gTn(`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((i,n)=>(i[n.key]=n,i),{}),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 gTn&&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(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=J0o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=J0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function e8p(e,t,r=""){let i=await L0S(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/W0S}function b8p(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new O1("Operator is_not_set is not supported")}else throw new O1(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!x0S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return t8p(String(n))&&String(o).match(String(n))!==null;case"not_regex":return t8p(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&o!=null?typeof o=="string"?f(o,String(n),a):f(o,s,a):f(String(o),String(n),a)}case"is_date_after":case"is_date_before":{let s=G0S(String(n));if(s==null&&(s=r8p(n)),s==null)throw new O1(`Invalid date: ${n}`);let u=r8p(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new O1(`Unknown operator: ${a}`)}}function v8p(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new O1("can't match cohort without a given cohort property value");let a=r[n];return g8p(a,t,r,i)}function g8p(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=g8p(c,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof O1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new O1("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=v8p(c,t,r,i):f=b8p(c,t);let s=c.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof O1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new O1("can't match cohort without a given cohort property value");return n==="AND"}}function t8p(e){try{return new RegExp(e),!0}catch{return!1}}function r8p(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 O1(`${e} is in an invalid date format`)}else throw new O1(`The date provided ${e} must be a string, number, or date object`)}function G0S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var k7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},H0S=100,i8p=30*1e3,K0S=50*1e3,eHs=class extends Y7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new k7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,H0S):i8p,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 Z7s({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new OTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||K0S}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):h8p(t,r)}getLibraryVersion(){return m0S}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:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>{super.captureStateless(r,i,_,{timestamp:c,disableGeoip:f,uuid:s})},l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags,p=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})});this.addPendingPromise(p)}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:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>super.captureStatelessImmediate(r,i,_,{timestamp:c,disableGeoip:f,uuid:s}),l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}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=i8p){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),p=l!==void 0,_,h;if(!p&&!o){let b=await super.getFeatureFlagDetailStateless(t,r,n,f,s,a);if(b===void 0)return;h=b.response,l=iHs(h),_=b?.requestId}let y=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(y))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(y):this.distinctIdHasSentFlagCalls[r]=[y],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:h?.metadata?.id,$feature_flag_version:h?.metadata?.version,$feature_flag_reason:h?.reason?.description??h?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let p;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(p=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(p!==void 0)&&!c&&(p=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),p}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,o,c),u={},l={},p=!0;if(s&&(u=s.response,l=s.payloads,p=s.fallbackToDecide),p&&!a){let _=await super.getFeatureFlagsAndPayloadsStateless(t,i,o,c,n);u={...u,..._.flags||{}},l={...l,..._.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");OTn.captureException(this,t,{syntheticException:n},r,i)}},n8p=/\(error: (.*)\)/,O8p=50,A8p="?";function J0S(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,o,c,f,s;if(n[1]){c=n[1];let p=c.lastIndexOf(".");if(c[p-1]==="."&&p--,p>0){a=c.slice(0,p),o=c.slice(p+1);let _=a.indexOf(".Module");_>0&&(c=c.slice(_+1),a=a.slice(0,_))}f=void 0}o&&(f=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||A8p,c=f?`${f}.${s}`:s);let u=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&n[5]&&!l&&(u=n[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:a8p(n[3]),colno:a8p(n[4]),in_app:$0S(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function $0S(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 a8p(e){return parseInt(e||"",10)||void 0}function Y0S(e){return[90,J0S(e)]}function X0S(e){let r=[Y0S(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
1156
- `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=n8p.test(f)?f.replace(n8p,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=O8p)break}}return Z0S(a)}}function Z0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,O8p).map(r=>({...r,filename:r.filename||k0S(t).filename,function:r.function||A8p}))}function k0S(e){return e[e.length-1]||{}}OTn.stackParser=X0S(c0S());OTn.frameModifiers=[d0S];var mTn=class extends eHs{getLibraryId(){return"posthog-node"}};var Y0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new mTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.0.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var vOa=class{async sendEvent(){}async identify(){}async flush(){}};var jTn=require("fs/promises"),w8p=require("os"),E8p=require("path");var m8p=ae(require("crypto")),Z0o=new Uint8Array(256),X0o=Z0o.length;function nHs(){return X0o>Z0o.length-16&&(m8p.default.randomFillSync(Z0o),X0o=0),Z0o.slice(X0o,X0o+=16)}var zQ=[];for(let e=0;e<256;++e)zQ.push((e+256).toString(16).slice(1));function P8p(e,t=0){return zQ[e[t+0]]+zQ[e[t+1]]+zQ[e[t+2]]+zQ[e[t+3]]+"-"+zQ[e[t+4]]+zQ[e[t+5]]+"-"+zQ[e[t+6]]+zQ[e[t+7]]+"-"+zQ[e[t+8]]+zQ[e[t+9]]+"-"+zQ[e[t+10]]+zQ[e[t+11]]+zQ[e[t+12]]+zQ[e[t+13]]+zQ[e[t+14]]+zQ[e[t+15]]}var j8p=ae(require("crypto")),aHs={randomUUID:j8p.default.randomUUID};function ePS(e,t,r){if(aHs.randomUUID&&!t&&!e)return aHs.randomUUID();e=e||{};let i=e.random||(e.rng||nHs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return P8p(i)}var rhe=ePS;var tPS="id",rPS=".fern",gOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new mTn(r),this.userId=t==null?void 0:E8s(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:"3.0.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,w8p.homedir)()),Ye.of(rPS),Ye.of(tPS));await Ri(t)||(await(0,jTn.mkdir)((0,E8p.dirname)(t),{recursive:!0}),await(0,jTn.writeFile)(t,rhe())),this.persistedDistinctId=(await(0,jTn.readFile)(t)).toString()}return this.persistedDistinctId}};var oHs;async function wTn(){return oHs==null&&(oHs=await iPS()),oHs}async function iPS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new vOa;let r=await hbo();return r!=null?new gOa({token:r,posthogApiKey:e}):await Mqn()!=null?new Y0o({posthogApiKey:e}):new gOa({token:void 0,posthogApiKey:e})}catch{return new vOa}}function OOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:nPS}=Object.prototype,{getPrototypeOf:sHs}=Object,{iterator:ePo,toStringTag:M8p}=Symbol,tPo=(e=>t=>{let r=nPS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),UNt=e=>(e=e.toLowerCase(),t=>tPo(t)===e),rPo=e=>t=>typeof t===e,{isArray:STn}=Array,ETn=rPo("undefined");function AOa(e){return e!==null&&!ETn(e)&&e.constructor!==null&&!ETn(e.constructor)&&q6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var D8p=UNt("ArrayBuffer");function aPS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&D8p(e.buffer),t}var oPS=rPo("string"),q6=rPo("function"),B8p=rPo("number"),mOa=e=>e!==null&&typeof e=="object",uPS=e=>e===!0||e===!1,k0o=e=>{if(tPo(e)!=="object")return!1;let t=sHs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(M8p in e)&&!(ePo in e)},sPS=e=>{if(!mOa(e)||AOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},cPS=UNt("Date"),lPS=UNt("File"),fPS=UNt("Blob"),dPS=UNt("FileList"),pPS=e=>mOa(e)&&q6(e.pipe),_PS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||q6(e.append)&&((t=tPo(e))==="formdata"||t==="object"&&q6(e.toString)&&e.toString()==="[object FormData]"))},hPS=UNt("URLSearchParams"),[yPS,bPS,vPS,gPS]=["ReadableStream","Request","Response","Headers"].map(UNt),OPS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function POa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),STn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(AOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function I8p(e,t){if(AOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var i6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,C8p=e=>!ETn(e)&&e!==i6i;function uHs(){let{caseless:e,skipUndefined:t}=C8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&I8p(r,a)||a;k0o(r[o])&&k0o(n)?r[o]=uHs(r[o],n):k0o(n)?r[o]=uHs({},n):STn(n)?r[o]=n.slice():(!t||!ETn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&POa(arguments[n],i);return r}var APS=(e,t,r,{allOwnKeys:i}={})=>(POa(t,(n,a)=>{r&&q6(n)?e[a]=OOa(n,r):e[a]=n},{allOwnKeys:i}),e),mPS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),PPS=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},jPS=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&sHs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},wPS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},EPS=e=>{if(!e)return null;if(STn(e))return e;let t=e.length;if(!B8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},SPS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&sHs(Uint8Array)),MPS=(e,t)=>{let i=(e&&e[ePo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},DPS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},BPS=UNt("HTMLFormElement"),IPS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),S8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),CPS=UNt("RegExp"),q8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};POa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},qPS=e=>{q8p(e,(t,r)=>{if(q6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(q6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},TPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return STn(e)?i(e):i(String(e).split(t)),r},RPS=()=>{},zPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function NPS(e){return!!(e&&q6(e.append)&&e[M8p]==="FormData"&&e[ePo])}var FPS=e=>{let t=new Array(10),r=(i,n)=>{if(mOa(i)){if(t.indexOf(i)>=0)return;if(AOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=STn(i)?[]:{};return POa(i,(o,c)=>{let f=r(o,n+1);!ETn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},QPS=UNt("AsyncFunction"),UPS=e=>e&&(mOa(e)||q6(e))&&q6(e.then)&&q6(e.catch),T8p=((e,t)=>e?setImmediate:t?((r,i)=>(i6i.addEventListener("message",({source:n,data:a})=>{n===i6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),i6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",q6(i6i.postMessage)),LPS=typeof queueMicrotask<"u"?queueMicrotask.bind(i6i):typeof process<"u"&&process.nextTick||T8p,VPS=e=>e!=null&&q6(e[ePo]),kt={isArray:STn,isArrayBuffer:D8p,isBuffer:AOa,isFormData:_PS,isArrayBufferView:aPS,isString:oPS,isNumber:B8p,isBoolean:uPS,isObject:mOa,isPlainObject:k0o,isEmptyObject:sPS,isReadableStream:yPS,isRequest:bPS,isResponse:vPS,isHeaders:gPS,isUndefined:ETn,isDate:cPS,isFile:lPS,isBlob:fPS,isRegExp:CPS,isFunction:q6,isStream:pPS,isURLSearchParams:hPS,isTypedArray:SPS,isFileList:dPS,forEach:POa,merge:uHs,extend:APS,trim:OPS,stripBOM:mPS,inherits:PPS,toFlatObject:jPS,kindOf:tPo,kindOfTest:UNt,endsWith:wPS,toArray:EPS,forEachEntry:MPS,matchAll:DPS,isHTMLForm:BPS,hasOwnProperty:S8p,hasOwnProp:S8p,reduceDescriptors:q8p,freezeMethods:qPS,toObjectSet:TPS,toCamelCase:IPS,noop:RPS,toFiniteNumber:zPS,findKey:I8p,global:i6i,isContextDefined:C8p,isSpecCompliantForm:NPS,toJSONObject:FPS,isAsyncFn:QPS,isThenable:UPS,setImmediate:T8p,asap:LPS,isIterable:VPS};function MTn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(MTn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var R8p=MTn.prototype,z8p={};["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=>{z8p[e]={value:e}});Object.defineProperties(MTn,z8p);Object.defineProperty(R8p,"isAxiosError",{value:!0});MTn.from=(e,t,r,i,n,a)=>{let o=Object.create(R8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return MTn.call(o,c,f,r,i,n),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 ya=MTn;var N8p=ae(Pqn(),1),iPo=N8p.default;function cHs(e){return kt.isPlainObject(e)||kt.isArray(e)}function Q8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function F8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Q8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function WPS(e){return kt.isArray(e)&&!e.some(cHs)}var xPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function GPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(iPo||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&WPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=Q8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?F8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return cHs(h)?!0:(t.append(F8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(xPS,{defaultVisitor:u,convertValue:s,isVisitable:cHs});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var UBi=GPS;function U8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function L8p(e,t){this._pairs=[],e&&UBi(e,this,t)}var V8p=L8p.prototype;V8p.append=function(t,r){this._pairs.push([t,r])};V8p.toString=function(t){let r=t?function(i){return t.call(this,i,U8p)}:U8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var W8p=L8p;function HPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function n6i(e,t,r){if(!t)return e;let i=r&&r.encode||HPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new W8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var lHs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},fHs=lHs;var DTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var K8p=ae(require("crypto"),1);var x8p=ae(require("url"),1),G8p=x8p.default.URLSearchParams;var dHs="abcdefghijklmnopqrstuvwxyz",H8p="0123456789",J8p={DIGIT:H8p,ALPHA:dHs,ALPHA_DIGIT:dHs+dHs.toUpperCase()+H8p},KPS=(e=16,t=J8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);K8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},$8p={isNode:!0,classes:{URLSearchParams:G8p,FormData:iPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:J8p,generateString:KPS,protocols:["http","https","file","data"]};var hHs={};Kt(hHs,{hasBrowserEnv:()=>_Hs,hasStandardBrowserEnv:()=>JPS,hasStandardBrowserWebWorkerEnv:()=>$PS,navigator:()=>pHs,origin:()=>YPS});var _Hs=typeof window<"u"&&typeof document<"u",pHs=typeof navigator=="object"&&navigator||void 0,JPS=_Hs&&(!pHs||["ReactNative","NativeScript","NS"].indexOf(pHs.product)<0),$PS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",YPS=_Hs&&window.location.href||"http://localhost";var AA={...hHs,...$8p};function yHs(e,t){return UBi(e,new AA.classes.URLSearchParams,{visitor:function(r,i,n,a){return AA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function XPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ZPS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function kPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=ZPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(XPS(i),n,r,0)}),r}return null}var nPo=kPS;function ejS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var bHs={transitional:DTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(nPo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return yHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return UBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),ejS(t)):t}],transformResponse:[function(t){let r=this.transitional||bHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:AA.classes.FormData,Blob:AA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{bHs.headers[e]={}});var BTn=bHs;var tjS=kt.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"]),Y8p=e=>{let t={},r,i,n;return e&&e.split(`
1156
+ `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=n8p.test(f)?f.replace(n8p,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=O8p)break}}return Z0S(a)}}function Z0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,O8p).map(r=>({...r,filename:r.filename||k0S(t).filename,function:r.function||A8p}))}function k0S(e){return e[e.length-1]||{}}OTn.stackParser=X0S(c0S());OTn.frameModifiers=[d0S];var mTn=class extends eHs{getLibraryId(){return"posthog-node"}};var Y0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new mTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.0.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var vOa=class{async sendEvent(){}async identify(){}async flush(){}};var jTn=require("fs/promises"),w8p=require("os"),E8p=require("path");var m8p=ae(require("crypto")),Z0o=new Uint8Array(256),X0o=Z0o.length;function nHs(){return X0o>Z0o.length-16&&(m8p.default.randomFillSync(Z0o),X0o=0),Z0o.slice(X0o,X0o+=16)}var zQ=[];for(let e=0;e<256;++e)zQ.push((e+256).toString(16).slice(1));function P8p(e,t=0){return zQ[e[t+0]]+zQ[e[t+1]]+zQ[e[t+2]]+zQ[e[t+3]]+"-"+zQ[e[t+4]]+zQ[e[t+5]]+"-"+zQ[e[t+6]]+zQ[e[t+7]]+"-"+zQ[e[t+8]]+zQ[e[t+9]]+"-"+zQ[e[t+10]]+zQ[e[t+11]]+zQ[e[t+12]]+zQ[e[t+13]]+zQ[e[t+14]]+zQ[e[t+15]]}var j8p=ae(require("crypto")),aHs={randomUUID:j8p.default.randomUUID};function ePS(e,t,r){if(aHs.randomUUID&&!t&&!e)return aHs.randomUUID();e=e||{};let i=e.random||(e.rng||nHs)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return P8p(i)}var rhe=ePS;var tPS="id",rPS=".fern",gOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new mTn(r),this.userId=t==null?void 0:E8s(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:"3.0.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,w8p.homedir)()),Ye.of(rPS),Ye.of(tPS));await Ri(t)||(await(0,jTn.mkdir)((0,E8p.dirname)(t),{recursive:!0}),await(0,jTn.writeFile)(t,rhe())),this.persistedDistinctId=(await(0,jTn.readFile)(t)).toString()}return this.persistedDistinctId}};var oHs;async function wTn(){return oHs==null&&(oHs=await iPS()),oHs}async function iPS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new vOa;let r=await hbo();return r!=null?new gOa({token:r,posthogApiKey:e}):await Mqn()!=null?new Y0o({posthogApiKey:e}):new gOa({token:void 0,posthogApiKey:e})}catch{return new vOa}}function OOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:nPS}=Object.prototype,{getPrototypeOf:sHs}=Object,{iterator:ePo,toStringTag:M8p}=Symbol,tPo=(e=>t=>{let r=nPS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),UNt=e=>(e=e.toLowerCase(),t=>tPo(t)===e),rPo=e=>t=>typeof t===e,{isArray:STn}=Array,ETn=rPo("undefined");function AOa(e){return e!==null&&!ETn(e)&&e.constructor!==null&&!ETn(e.constructor)&&q6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var D8p=UNt("ArrayBuffer");function aPS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&D8p(e.buffer),t}var oPS=rPo("string"),q6=rPo("function"),B8p=rPo("number"),mOa=e=>e!==null&&typeof e=="object",uPS=e=>e===!0||e===!1,k0o=e=>{if(tPo(e)!=="object")return!1;let t=sHs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(M8p in e)&&!(ePo in e)},sPS=e=>{if(!mOa(e)||AOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},cPS=UNt("Date"),lPS=UNt("File"),fPS=UNt("Blob"),dPS=UNt("FileList"),pPS=e=>mOa(e)&&q6(e.pipe),_PS=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||q6(e.append)&&((t=tPo(e))==="formdata"||t==="object"&&q6(e.toString)&&e.toString()==="[object FormData]"))},hPS=UNt("URLSearchParams"),[yPS,bPS,vPS,gPS]=["ReadableStream","Request","Response","Headers"].map(UNt),OPS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function POa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),STn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(AOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function I8p(e,t){if(AOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var i6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,C8p=e=>!ETn(e)&&e!==i6i;function uHs(){let{caseless:e,skipUndefined:t}=C8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&I8p(r,a)||a;k0o(r[o])&&k0o(n)?r[o]=uHs(r[o],n):k0o(n)?r[o]=uHs({},n):STn(n)?r[o]=n.slice():(!t||!ETn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&POa(arguments[n],i);return r}var APS=(e,t,r,{allOwnKeys:i}={})=>(POa(t,(n,a)=>{r&&q6(n)?e[a]=OOa(n,r):e[a]=n},{allOwnKeys:i}),e),mPS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),PPS=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},jPS=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&sHs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},wPS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},EPS=e=>{if(!e)return null;if(STn(e))return e;let t=e.length;if(!B8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},SPS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&sHs(Uint8Array)),MPS=(e,t)=>{let i=(e&&e[ePo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},DPS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},BPS=UNt("HTMLFormElement"),IPS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),S8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),CPS=UNt("RegExp"),q8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};POa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},qPS=e=>{q8p(e,(t,r)=>{if(q6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(q6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},TPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return STn(e)?i(e):i(String(e).split(t)),r},RPS=()=>{},zPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function NPS(e){return!!(e&&q6(e.append)&&e[M8p]==="FormData"&&e[ePo])}var FPS=e=>{let t=new Array(10),r=(i,n)=>{if(mOa(i)){if(t.indexOf(i)>=0)return;if(AOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=STn(i)?[]:{};return POa(i,(o,c)=>{let f=r(o,n+1);!ETn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},QPS=UNt("AsyncFunction"),UPS=e=>e&&(mOa(e)||q6(e))&&q6(e.then)&&q6(e.catch),T8p=((e,t)=>e?setImmediate:t?((r,i)=>(i6i.addEventListener("message",({source:n,data:a})=>{n===i6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),i6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",q6(i6i.postMessage)),LPS=typeof queueMicrotask<"u"?queueMicrotask.bind(i6i):typeof process<"u"&&process.nextTick||T8p,VPS=e=>e!=null&&q6(e[ePo]),kt={isArray:STn,isArrayBuffer:D8p,isBuffer:AOa,isFormData:_PS,isArrayBufferView:aPS,isString:oPS,isNumber:B8p,isBoolean:uPS,isObject:mOa,isPlainObject:k0o,isEmptyObject:sPS,isReadableStream:yPS,isRequest:bPS,isResponse:vPS,isHeaders:gPS,isUndefined:ETn,isDate:cPS,isFile:lPS,isBlob:fPS,isRegExp:CPS,isFunction:q6,isStream:pPS,isURLSearchParams:hPS,isTypedArray:SPS,isFileList:dPS,forEach:POa,merge:uHs,extend:APS,trim:OPS,stripBOM:mPS,inherits:PPS,toFlatObject:jPS,kindOf:tPo,kindOfTest:UNt,endsWith:wPS,toArray:EPS,forEachEntry:MPS,matchAll:DPS,isHTMLForm:BPS,hasOwnProperty:S8p,hasOwnProp:S8p,reduceDescriptors:q8p,freezeMethods:qPS,toObjectSet:TPS,toCamelCase:IPS,noop:RPS,toFiniteNumber:zPS,findKey:I8p,global:i6i,isContextDefined:C8p,isSpecCompliantForm:NPS,toJSONObject:FPS,isAsyncFn:QPS,isThenable:UPS,setImmediate:T8p,asap:LPS,isIterable:VPS};function MTn(e,t,r,i,n){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),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(MTn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var R8p=MTn.prototype,z8p={};["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=>{z8p[e]={value:e}});Object.defineProperties(MTn,z8p);Object.defineProperty(R8p,"isAxiosError",{value:!0});MTn.from=(e,t,r,i,n,a)=>{let o=Object.create(R8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return MTn.call(o,c,f,r,i,n),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 ya=MTn;var N8p=ae(Pqn(),1),iPo=N8p.default;function cHs(e){return kt.isPlainObject(e)||kt.isArray(e)}function Q8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function F8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=Q8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function WPS(e){return kt.isArray(e)&&!e.some(cHs)}var xPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function GPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(iPo||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&WPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=Q8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?F8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return cHs(h)?!0:(t.append(F8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(xPS,{defaultVisitor:u,convertValue:s,isVisitable:cHs});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var UBi=GPS;function U8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function L8p(e,t){this._pairs=[],e&&UBi(e,this,t)}var V8p=L8p.prototype;V8p.append=function(t,r){this._pairs.push([t,r])};V8p.toString=function(t){let r=t?function(i){return t.call(this,i,U8p)}:U8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var W8p=L8p;function HPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function n6i(e,t,r){if(!t)return e;let i=r&&r.encode||HPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new W8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var lHs=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},fHs=lHs;var DTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var K8p=ae(require("crypto"),1);var x8p=ae(require("url"),1),G8p=x8p.default.URLSearchParams;var dHs="abcdefghijklmnopqrstuvwxyz",H8p="0123456789",J8p={DIGIT:H8p,ALPHA:dHs,ALPHA_DIGIT:dHs+dHs.toUpperCase()+H8p},KPS=(e=16,t=J8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);K8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},$8p={isNode:!0,classes:{URLSearchParams:G8p,FormData:iPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:J8p,generateString:KPS,protocols:["http","https","file","data"]};var hHs={};Kt(hHs,{hasBrowserEnv:()=>_Hs,hasStandardBrowserEnv:()=>JPS,hasStandardBrowserWebWorkerEnv:()=>$PS,navigator:()=>pHs,origin:()=>YPS});var _Hs=typeof window<"u"&&typeof document<"u",pHs=typeof navigator=="object"&&navigator||void 0,JPS=_Hs&&(!pHs||["ReactNative","NativeScript","NS"].indexOf(pHs.product)<0),$PS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",YPS=_Hs&&window.location.href||"http://localhost";var AA={...hHs,...$8p};function yHs(e,t){return UBi(e,new AA.classes.URLSearchParams,{visitor:function(r,i,n,a){return AA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function XPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ZPS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function kPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=ZPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(XPS(i),n,r,0)}),r}return null}var nPo=kPS;function ejS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var bHs={transitional:DTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(nPo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return yHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return UBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),ejS(t)):t}],transformResponse:[function(t){let r=this.transitional||bHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:AA.classes.FormData,Blob:AA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{bHs.headers[e]={}});var BTn=bHs;var tjS=kt.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"]),Y8p=e=>{let t={},r,i,n;return e&&e.split(`
1157
1157
  `).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&tjS[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var X8p=Symbol("internals");function jOa(e){return e&&String(e).trim().toLowerCase()}function aPo(e){return e===!1||e==null?e:kt.isArray(e)?e.map(aPo):String(e)}function rjS(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var ijS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vHs(e,t,r,i,n){if(kt.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!kt.isString(t)){if(kt.isString(i))return t.indexOf(i)!==-1;if(kt.isRegExp(i))return i.test(t)}}function njS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function ajS(e,t){let r=kt.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var ITn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=jOa(f);if(!u)throw new Error("header name must be a non-empty string");let l=kt.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=aPo(c))}let o=(c,f)=>kt.forEach(c,(s,u)=>a(s,u,f));if(kt.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(kt.isString(t)&&(t=t.trim())&&!ijS(t))o(Y8p(t),r);else if(kt.isObject(t)&&kt.isIterable(t)){let c={},f,s;for(let u of t){if(!kt.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?kt.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=jOa(t),t){let i=kt.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return rjS(n);if(kt.isFunction(r))return r.call(this,n,i);if(kt.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=jOa(t),t){let i=kt.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||vHs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=jOa(o),o){let c=kt.findKey(i,o);c&&(!r||vHs(i,i[c],c,r))&&(delete i[c],n=!0)}}return kt.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||vHs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return kt.forEach(this,(n,a)=>{let o=kt.findKey(i,a);if(o){r[o]=aPo(n),delete r[a];return}let c=t?njS(a):String(a).trim();c!==a&&delete r[a],r[c]=aPo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return kt.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&kt.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1158
1158
  `)}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 i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[X8p]=this[X8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=jOa(o);i[c]||(ajS(n,o),i[c]=!0)}return kt.isArray(t)?t.forEach(a):a(t),this}};ITn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);kt.reduceDescriptors(ITn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});kt.freezeMethods(ITn);var LS=ITn;function wOa(e,t){let r=this||BTn,i=t||r,n=LS.from(i.headers),a=i.data;return kt.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function EOa(e){return!!(e&&e.__CANCEL__)}function Z8p(e,t,r){ya.call(this,e??"canceled",ya.ERR_CANCELED,t,r),this.name="CanceledError"}kt.inherits(Z8p,ya,{__CANCEL__:!0});var ihe=Z8p;function c9t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ya("Request failed with status code "+r.status,[ya.ERR_BAD_REQUEST,ya.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function gHs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function OHs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function a6i(e,t,r){let i=!gHs(t);return e&&(i||r==!1)?OHs(e,t):t}var _Vp=ae(E0o(),1),hVp=ae(require("http"),1),yVp=ae(require("https"),1),bVp=ae(require("util"),1),vVp=ae(A7s(),1),Jbi=ae(require("zlib"),1);var o6i="1.12.2";function SOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var ojS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function AHs(e,t,r){let i=r&&r.Blob||AA.classes.Blob,n=SOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=ojS.exec(e);if(!a)throw new ya("Invalid URL",ya.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ya("Blob is not supported",ya.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ya("Unsupported protocol "+n,ya.ERR_NOT_SUPPORT)}var s6i=ae(require("stream"),1);var k8p=ae(require("stream"),1);var mHs=Symbol("internals"),PHs=class extends k8p.default.Transform{constructor(t){t=kt.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!kt.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[mHs]={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",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[mHs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[mHs],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,f=1e3/c,s=a/f,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},jHs=PHs;var gVp=require("events");var tVp=ae(require("util"),1),rVp=require("stream");var{asyncIterator:eVp}=Symbol,ujS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[eVp]?yield*e[eVp]():yield e},oPo=ujS;var sjS=AA.ALPHABET.ALPHA_DIGIT+"-_",MOa=typeof TextEncoder=="function"?new TextEncoder:new tVp.default.TextEncoder,u6i=`\r
1159
1159
  `,cjS=MOa.encode(u6i),ljS=2,wHs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=kt.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${u6i}`;n?r=MOa.encode(String(r).replace(/\r?\n|\r\n?/g,u6i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${u6i}`,this.headers=MOa.encode(a+u6i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+ljS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;kt.isTypedArray(t)?yield t:yield*oPo(t),yield cjS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},fjS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+AA.generateString(n,sjS)}=r||{};if(!kt.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=MOa.encode("--"+a+u6i),c=MOa.encode("--"+a+"--"+u6i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new wHs(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=kt.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),rVp.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},iVp=fjS;var nVp=ae(require("stream"),1),EHs=class extends nVp.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},aVp=EHs;var djS=(e,t)=>kt.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,oVp=djS;function pjS(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),u=i[a];o||(o=s),r[n]=f,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var uVp=pjS;function _jS(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var sVp=_jS;var Kbi=(e,t,r=3)=>{let i=0,n=uVp(50,250);return sVp(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-i,s=n(f),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},CTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},qTn=e=>(...t)=>kt.asap(()=>e(...t));function SHs(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),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,f=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);f>=0&&(i.charCodeAt(f)===61?(c++,f--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(i.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var cVp={flush:Jbi.default.constants.Z_SYNC_FLUSH,finishFlush:Jbi.default.constants.Z_SYNC_FLUSH},hjS={flush:Jbi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Jbi.default.constants.BROTLI_OPERATION_FLUSH},lVp=kt.isFunction(Jbi.default.createBrotliDecompress),{http:yjS,https:bjS}=vVp.default,vjS=/https:?/,fVp=AA.protocols.map(e=>e+":"),dVp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function gjS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function OVp(e,t,r){let i=t;if(!i&&i!==!1){let n=_Vp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){OVp(a,t,a.href)}}var OjS=typeof process<"u"&&kt.kindOf(process)==="process",AjS=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>i=f).catch(c)}),mjS=({address:e,family:t})=>{if(!kt.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},pVp=(e,t)=>mjS(kt.isObject(e)?e:{address:e,family:t}),AVp=OjS&&function(t){return AjS(async function(i,n,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let H=oVp(c,oe=>kt.isArray(oe)?oe:[oe]);c=(oe,se,x)=>{H(oe,se,(G,Pe,ne)=>{if(G)return x(G);let Ee=kt.isArray(Pe)?Pe.map(Qe=>pVp(Qe)):[pVp(Pe,ne)];se.all?x(G,Ee):x(G,Ee[0].address,Ee[0].family)})}}let y=new gVp.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((H,oe)=>{p=!0,oe&&(_=!0,b())});function v(H){y.emit("abort",!H||H.type?new ihe(null,t,h):H)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=a6i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,AA.hasBrowserEnv?AA.origin:void 0),g=A.protocol||fVp[0];if(g==="data:"){if(t.maxContentLength>-1){let oe=String(t.url||O||"");if(SHs(oe)>t.maxContentLength)return n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t))}let H;if(l!=="GET")return c9t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{H=AHs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(oe){throw ya.from(oe,ya.ERR_BAD_REQUEST,t)}return s==="text"?(H=H.toString(u),(!u||u==="utf8")&&(H=kt.stripBOM(H))):s==="stream"&&(H=s6i.default.Readable.from(H)),c9t(i,n,{data:H,status:200,statusText:"OK",headers:new LS,config:t})}if(fVp.indexOf(g)===-1)return n(new ya("Unsupported protocol "+g,ya.ERR_BAD_REQUEST,t));let m=LS.from(t.headers).normalize();m.set("User-Agent","axios/"+o6i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(kt.isSpecCompliantForm(o)){let H=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=iVp(o,oe=>{m.set(oe)},{tag:`axios-${o6i}-boundary`,boundary:H&&H[1]||void 0})}else if(kt.isFormData(o)&&kt.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let H=await bVp.default.promisify(o.getLength).call(o);Number.isFinite(H)&&H>=0&&m.setContentLength(H)}catch{}}else if(kt.isBlob(o)||kt.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=s6i.default.Readable.from(oPo(o));else if(o&&!kt.isStream(o)){if(!Buffer.isBuffer(o))if(kt.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(kt.isString(o))o=Buffer.from(o,"utf-8");else return n(new ya("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ya.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ya("Request body larger than maxBodyLength limit",ya.ERR_BAD_REQUEST,t))}let F=kt.toFiniteNumber(m.getContentLength());kt.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(kt.isStream(o)||(o=s6i.default.Readable.from(o,{objectMode:!1})),o=s6i.default.pipeline([o,new jHs({maxRate:kt.toFiniteNumber(D)})],kt.noop),j&&o.on("progress",dVp(o,CTn(F,Kbi(qTn(j),!1,3)))));let N;if(t.auth){let H=t.auth.username||"",oe=t.auth.password||"";N=H+":"+oe}if(!N&&A.username){let H=A.username,oe=A.password;N=H+":"+oe}N&&m.delete("authorization");let T;try{T=n6i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(H){let oe=new Error(H.message);return oe.config=t,oe.url=t.url,oe.exists=!0,n(oe)}m.set("Accept-Encoding","gzip, compress, deflate"+(lVp?", br":""),!1);let R={path:T,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:f,beforeRedirect:gjS,beforeRedirects:{}};!kt.isUndefined(c)&&(R.lookup=c),t.socketPath?R.socketPath=t.socketPath:(R.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,R.port=A.port,OVp(R,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+R.path));let Q,U=vjS.test(R.protocol);if(R.agent=U?t.httpsAgent:t.httpAgent,t.transport?Q=t.transport:t.maxRedirects===0?Q=U?yVp.default:hVp.default:(t.maxRedirects&&(R.maxRedirects=t.maxRedirects),t.beforeRedirect&&(R.beforeRedirects.config=t.beforeRedirect),Q=U?bjS:yjS),t.maxBodyLength>-1?R.maxBodyLength=t.maxBodyLength:R.maxBodyLength=1/0,t.insecureHTTPParser&&(R.insecureHTTPParser=t.insecureHTTPParser),h=Q.request(R,function(oe){if(h.destroyed)return;let se=[oe],x=+oe.headers["content-length"];if(M||B){let Qe=new jHs({maxRate:kt.toFiniteNumber(B)});M&&Qe.on("progress",dVp(Qe,CTn(x,Kbi(qTn(M),!0,3)))),se.push(Qe)}let G=oe,Pe=oe.req||h;if(t.decompress!==!1&&oe.headers["content-encoding"])switch((l==="HEAD"||oe.statusCode===204)&&delete oe.headers["content-encoding"],(oe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":se.push(Jbi.default.createUnzip(cVp)),delete oe.headers["content-encoding"];break;case"deflate":se.push(new aVp),se.push(Jbi.default.createUnzip(cVp)),delete oe.headers["content-encoding"];break;case"br":lVp&&(se.push(Jbi.default.createBrotliDecompress(hjS)),delete oe.headers["content-encoding"])}G=se.length>1?s6i.default.pipeline(se,kt.noop):se[0];let ne=s6i.default.finished(G,()=>{ne(),b()}),Ee={status:oe.statusCode,statusText:oe.statusMessage,headers:new LS(oe.headers),config:t,request:Pe};if(s==="stream")Ee.data=G,c9t(i,n,Ee);else{let Qe=[],re=0;G.on("data",function(Ve){Qe.push(Ve),re+=Ve.length,t.maxContentLength>-1&&re>t.maxContentLength&&(_=!0,G.destroy(),n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t,Pe)))}),G.on("aborted",function(){if(_)return;let Ve=new ya("stream has been aborted",ya.ERR_BAD_RESPONSE,t,Pe);G.destroy(Ve),n(Ve)}),G.on("error",function(Ve){h.destroyed||n(ya.from(Ve,null,t,Pe))}),G.on("end",function(){try{let Ve=Qe.length===1?Qe[0]:Buffer.concat(Qe);s!=="arraybuffer"&&(Ve=Ve.toString(u),(!u||u==="utf8")&&(Ve=kt.stripBOM(Ve))),Ee.data=Ve}catch(Ve){return n(ya.from(Ve,null,t,Ee.request,Ee))}c9t(i,n,Ee)})}y.once("abort",Qe=>{G.destroyed||(G.emit("error",Qe),G.destroy())})}),y.once("abort",H=>{n(H),h.destroy(H)}),h.on("error",function(oe){n(ya.from(oe,null,t,h))}),h.on("socket",function(oe){oe.setKeepAlive(!0,1e3*60)}),t.timeout){let H=parseInt(t.timeout,10);if(Number.isNaN(H)){n(new ya("error trying to parse `config.timeout` to int",ya.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(H,function(){if(p)return;let se=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",x=t.transitional||DTn;t.timeoutErrorMessage&&(se=t.timeoutErrorMessage),n(new ya(se,x.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,t,h)),v()})}if(kt.isStream(o)){let H=!1,oe=!1;o.on("end",()=>{H=!0}),o.once("error",se=>{oe=!0,h.destroy(se)}),o.on("close",()=>{!H&&!oe&&v(new ihe("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var mVp=AA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,AA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(AA.origin),AA.navigator&&/(msie|trident)/i.test(AA.navigator.userAgent)):()=>!0;var PVp=AA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];kt.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),kt.isString(i)&&o.push("path="+i),kt.isString(n)&&o.push("domain="+n),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 jVp=e=>e instanceof LS?{...e}:e;function LNt(e,t){t=t||{};let r={};function i(s,u,l,p){return kt.isPlainObject(s)&&kt.isPlainObject(u)?kt.merge.call({caseless:p},s,u):kt.isPlainObject(u)?kt.merge({},u):kt.isArray(u)?u.slice():u}function n(s,u,l,p){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!kt.isUndefined(u))return i(void 0,u)}function o(s,u){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(jVp(s),jVp(u),l,!0)};return kt.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);kt.isUndefined(p)&&l!==c||(r[u]=p)}),r}var uPo=e=>{let t=LNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=LS.from(o),t.url=n6i(a6i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),kt.isFormData(r)){if(AA.hasStandardBrowserEnv||AA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(kt.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(AA.hasStandardBrowserEnv&&(i&&kt.isFunction(i)&&(i=i(t)),i||i!==!1&&mVp(t.url))){let f=n&&a&&PVp.read(a);f&&o.set(n,f)}return t};var PjS=typeof XMLHttpRequest<"u",wVp=PjS&&function(e){return new Promise(function(r,i){let n=uPo(e),a=n.data,o=LS.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=LS.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};c9t(function(M){r(M),y()},function(M){i(M),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ya("Request aborted",ya.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ya(m,ya.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||DTn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ya(g,m.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&kt.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),kt.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Kbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Kbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new ihe(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=SOa(n.url);if(O&&AA.protocols.indexOf(O)===-1){i(new ya("Unsupported protocol "+O+":",ya.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var jjS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ya?u:new ihe(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ya(`timeout ${t} of ms exceeded`,ya.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>kt.asap(c),f}},EVp=jjS;var wjS=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},EjS=async function*(e,t){for await(let r of SjS(e))yield*wjS(r,t)},SjS=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},MHs=(e,t,r,i)=>{let n=EjS(e,t),a=0,o,c=f=>{o||(o=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await n.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),n.return()}},{highWaterMark:2})};var SVp=64*1024,{isFunction:sPo}=kt,MjS=(({Request:e,Response:t})=>({Request:e,Response:t}))(kt.global),{ReadableStream:MVp,TextEncoder:DVp}=kt.global,BVp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},DjS=e=>{e=kt.merge.call({skipUndefined:!0},MjS,e);let{fetch:t,Request:r,Response:i}=e,n=t?sPo(t):typeof fetch=="function",a=sPo(r),o=sPo(i);if(!n)return!1;let c=n&&sPo(MVp),f=n&&(typeof DVp=="function"?(h=>y=>h.encode(y))(new DVp):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&BVp(()=>{let h=!1,y=new r(AA.origin,{body:new MVp,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&BVp(()=>kt.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new ya(`Response type '${h}' is not supported`,ya.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(kt.isBlob(h))return h.size;if(kt.isSpecCompliantForm(h))return(await new r(AA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(kt.isArrayBufferView(h)||kt.isArrayBuffer(h))return h.byteLength;if(kt.isURLSearchParams(h)&&(h=h+""),kt.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=kt.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:M,headers:E,withCredentials:D="same-origin",fetchOptions:B}=uPo(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=EVp([O,A&&A.toAbortSignal()],g),T=null,R=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),Q;try{if(j&&s&&b!=="get"&&b!=="head"&&(Q=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Pe;if(kt.isFormData(v)&&(Pe=G.headers.get("content-type"))&&E.setContentType(Pe),G.body){let[ne,Ee]=CTn(Q,Kbi(qTn(j)));v=MHs(G.body,SVp,ne,Ee)}}kt.isString(D)||(D=D?"include":"omit");let U=a&&"credentials"in r.prototype,H={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:U?D:void 0};T=a&&new r(y,H);let oe=await(a?F(T,B):F(y,H)),se=u&&(M==="stream"||M==="response");if(u&&(m||se&&R)){let G={};["status","statusText","headers"].forEach(Qe=>{G[Qe]=oe[Qe]});let Pe=kt.toFiniteNumber(oe.headers.get("content-length")),[ne,Ee]=m&&CTn(Pe,Kbi(qTn(m),!0))||[];oe=new i(MHs(oe.body,SVp,ne,()=>{Ee&&Ee(),R&&R()}),G)}M=M||"text";let x=await l[kt.findKey(l,M)||"text"](oe,h);return!se&&R&&R(),await new Promise((G,Pe)=>{c9t(G,Pe,{data:x,headers:LS.from(oe.headers),status:oe.status,statusText:oe.statusText,config:h,request:T})})}catch(U){throw R&&R(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new ya("Network Error",ya.ERR_NETWORK,h,T),{cause:U.cause||U}):ya.from(U,U&&U.code,h,T)}}},BjS=new Map,DHs=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,f,s,u=BjS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:DjS(t)),u=s;return s},Ug5=DHs();var BHs={http:AVp,xhr:wVp,fetch:{get:DHs}};kt.forEach(BHs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var IVp=e=>`- ${e}`,CjS=e=>kt.isFunction(e)||e===null||e===!1,cPo={getAdapter:(e,t)=>{e=kt.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!CjS(i)&&(n=BHs[(c=String(i)).toLowerCase()],n===void 0))throw new ya(`Unknown adapter '${c}'`);if(n&&(kt.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -1355,7 +1355,7 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
1355
1355
  `)),super.launch(t)}async computeLaunchArguments(t={}){let{ignoreDefaultArgs:r=!1,args:i=[],pipe:n=!1,debuggingPort:a,channel:o,executablePath:c}=t,f=[];r?Array.isArray(r)?f.push(...this.defaultArgs(t).filter(_=>!r.includes(_))):f.push(...i):f.push(...this.defaultArgs(t)),f.some(_=>_.startsWith("--remote-debugging-"))||(n?(Ei(!a,"Browser should be launched with either pipe or debugging port - not both."),f.push("--remote-debugging-pipe")):f.push(`--remote-debugging-port=${a||0}`));let s=!1,u=f.findIndex(_=>_.startsWith("--user-data-dir"));u<0&&(s=!0,f.push(`--user-data-dir=${await(0,Ri_.mkdtemp)(this.getProfilePath())}`),u=f.length-1);let l=f[u].split("=",2)[1];Ei(typeof l=="string","`--user-data-dir` is malformed");let p=c;return p||(Ei(o||!this.puppeteer._isPuppeteerCore,"An `executablePath` or `channel` must be specified for `puppeteer-core`"),p=o?this.executablePath(o):this.resolveExecutablePath(t.headless??!0)),{executablePath:p,args:f,isTempUserDataDir:s,userDataDir:l}}async cleanUserDataDir(t,r){if(r.isTemp)try{await kBo(t)}catch(i){throw zi(i),i}}defaultArgs(t={}){let r=qi_("--disable-features",t.args);t.args&&r.length>0&&Ti_(t.args,"--disable-features");let n=["Translate","AcceptCHFrame","MediaRouter","OptimizationHints","RenderDocument",...process.env.PUPPETEER_TEST_EXPERIMENTAL_CHROME_FEATURES==="true"?[]:["ProcessPerSiteUpToMainFrameThreshold","IsolateSandboxedIframes"],...r].filter(_=>_!==""),a=qi_("--enable-features",t.args);t.args&&a.length>0&&Ti_(t.args,"--enable-features");let o=["PdfOopif",...a].filter(_=>_!==""),c=["--allow-pre-commit-input","--disable-background-networking","--disable-background-timer-throttling","--disable-backgrounding-occluded-windows","--disable-breakpad","--disable-client-side-phishing-detection","--disable-component-extensions-with-background-pages","--disable-crash-reporter","--disable-default-apps","--disable-dev-shm-usage","--disable-hang-monitor","--disable-infobars","--disable-ipc-flooding-protection","--disable-popup-blocking","--disable-prompt-on-repost","--disable-renderer-backgrounding","--disable-search-engine-choice-screen","--disable-sync","--enable-automation","--export-tagged-pdf","--force-color-profile=srgb","--generate-pdf-document-outline","--metrics-recording-only","--no-first-run","--password-store=basic","--use-mock-keychain",`--disable-features=${n.join(",")}`,`--enable-features=${o.join(",")}`].filter(_=>_!==""),{devtools:f=!1,headless:s=!f,args:u=[],userDataDir:l,enableExtensions:p=!1}=t;return l&&c.push(`--user-data-dir=${Ni_.default.resolve(l)}`),f&&c.push("--auto-open-devtools-for-tabs"),s&&c.push(s==="shell"?"--headless":"--headless=new","--hide-scrollbars","--mute-audio"),c.push(p?"--enable-unsafe-extension-debugging":"--disable-extensions"),u.every(_=>_.startsWith("-"))&&c.push("about:blank"),c.push(...u),c}executablePath(t,r=!0){return t?$Bo({browser:pc.CHROME,channel:HHS(t)}):this.resolveExecutablePath(void 0,r)}};function HHS(e){switch(e){case"chrome":return qv.STABLE;case"chrome-dev":return qv.DEV;case"chrome-beta":return qv.BETA;case"chrome-canary":return qv.CANARY}}function qi_(e,t=[]){return t.filter(r=>r.startsWith(e.endsWith("=")?e:`${e}=`)).map(r=>r.split(new RegExp(`${e}=\\s*`))[1]?.trim()).filter(r=>r)}function Ti_(e,t){let r=new RegExp(`^${t}=.*`),i=0;for(;i<e.length;)r.test(e[i])?e.splice(i,1):i++;return e}var Fi_=ae(require("fs"),1),ENn=require("fs/promises"),Qi_=ae(require("os"),1),qrc=ae(require("path"),1);Xf();kA();var tIo=class e extends wNn{constructor(t){super(t,"firefox")}static getPreferences(t){return{...t,"fission.webContentIsolationStrategy":0}}async computeLaunchArguments(t={}){let{ignoreDefaultArgs:r=!1,args:i=[],executablePath:n,pipe:a=!1,extraPrefsFirefox:o={},debuggingPort:c=null}=t,f=[];r?Array.isArray(r)?f.push(...this.defaultArgs(t).filter(_=>!r.includes(_))):f.push(...i):f.push(...this.defaultArgs(t)),f.some(_=>_.startsWith("--remote-debugging-"))||(a&&Ei(c===null,"Browser should be launched with either pipe or debugging port - not both."),f.push(`--remote-debugging-port=${c||0}`));let s,u=!0,l=f.findIndex(_=>["-profile","--profile"].includes(_));if(l!==-1){if(s=f[l+1],!s)throw new Error("Missing value for profile command line argument");u=!1}else s=await(0,ENn.mkdtemp)(this.getProfilePath()),f.push("--profile"),f.push(s);await mrc(pc.FIREFOX,{path:s,preferences:e.getPreferences(o)});let p;return this.puppeteer._isPuppeteerCore||n?(Ei(n,"An `executablePath` must be specified for `puppeteer-core`"),p=n):p=this.executablePath(void 0),{isTempUserDataDir:u,userDataDir:s,args:f,executablePath:p}}async cleanUserDataDir(t,r){if(r.isTemp)try{await kBo(t)}catch(i){throw zi(i),i}else try{let i=".puppeteer",n=["prefs.js","user.js"],a=await Promise.allSettled(n.map(async o=>{let c=qrc.default.join(t,o+i);if(Fi_.default.existsSync(c)){let f=qrc.default.join(t,o);await(0,ENn.unlink)(f),await(0,ENn.rename)(c,f)}}));for(let o of a)if(o.status==="rejected")throw o.reason}catch(i){zi(i)}}executablePath(t,r=!0){return this.resolveExecutablePath(void 0,r)}defaultArgs(t={}){let{devtools:r=!1,headless:i=!r,args:n=[],userDataDir:a=null}=t,o=[];switch(Qi_.default.platform()){case"darwin":o.push("--foreground");break;case"win32":o.push("--wait-for-browser");break}return a&&(o.push("--profile"),o.push(a)),i&&o.push("--headless"),r&&o.push("--devtools"),n.every(c=>c.startsWith("-"))&&o.push("about:blank"),o.push(...n),o}};var SNn=class extends ZMo{#e;#t;defaultBrowserRevision;configuration={};constructor(t){let{configuration:r,...i}=t;switch(super(i),r&&(this.configuration=r),this.configuration.defaultBrowser){case"firefox":this.defaultBrowserRevision=zzn.firefox;break;default:this.configuration.defaultBrowser="chrome",this.defaultBrowserRevision=zzn.chrome;break}this.connect=this.connect.bind(this),this.launch=this.launch.bind(this),this.executablePath=this.executablePath.bind(this),this.defaultArgs=this.defaultArgs.bind(this),this.trimCache=this.trimCache.bind(this)}connect(t){return super.connect(t)}launch(t={}){let{browser:r=this.defaultBrowser}=t;switch(this.#t=r,r){case"chrome":this.defaultBrowserRevision=zzn.chrome;break;case"firefox":this.defaultBrowserRevision=zzn.firefox;break;default:throw new Error(`Unknown product: ${r}`)}return this.#e=this.#r(r),this.#e.launch(t)}#r(t){if(this.#e&&this.#e.browser===t)return this.#e;switch(t){case"chrome":return new eIo(this);case"firefox":return new tIo(this);default:throw new Error(`Unknown product: ${t}`)}}executablePath(t){return t===void 0?this.#r(this.lastLaunchedBrowser).executablePath(void 0,!1):typeof t=="string"?this.#r("chrome").executablePath(t,!1):this.#r(t.browser??this.lastLaunchedBrowser).resolveExecutablePath(t.headless,!1)}get browserVersion(){return this.configuration?.[this.lastLaunchedBrowser]?.version??this.defaultBrowserRevision}get defaultDownloadPath(){return this.configuration.cacheDirectory}get lastLaunchedBrowser(){return this.#t??this.defaultBrowser}get defaultBrowser(){return this.configuration.defaultBrowser??"chrome"}get product(){return this.lastLaunchedBrowser}defaultArgs(t={}){return this.#r(t.browser??this.lastLaunchedBrowser).defaultArgs(t)}async trimCache(){let t=rFt();if(!t)throw new Error("The current platform is not supported.");let r=this.configuration.cacheDirectory,i=await Crc({cacheDir:r}),n=[{product:"chrome",browser:pc.CHROME,currentBuildId:""},{product:"firefox",browser:pc.FIREFOX,currentBuildId:""}];for(let c of n){let f=this.configuration?.[c.product]?.version??zzn[c.product];c.currentBuildId=await WBo(c.browser,t,f)}let a=new Set(n.map(c=>`${c.browser}_${c.currentBuildId}`)),o=new Set(n.map(c=>c.browser));for(let c of i)o.has(c.browser)&&(a.has(`${c.browser}_${c.buildId}`)||await Irc({browser:c.browser,platform:t,cacheDir:r,buildId:c.buildId}))}};var rIo=require("child_process"),Vi_=ae(require("fs"),1),Wi_=ae(require("os"),1),xi_=require("path"),Gi_=require("stream"),Hi_=ae(FS(),1);i0e();L6();Xf();OB();ZA();var KHS=function(e,t,r){for(var i=arguments.length>2,n=0;n<t.length;n++)r=i?t[n].call(e,r):t[n].call(e);return i?r:void 0},Ui_=function(e,t,r,i,n,a){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var c=i.kind,f=c==="getter"?"get":c==="setter"?"set":"value",s=!t&&e?i.static?e:e.prototype:null,u=t||(s?Object.getOwnPropertyDescriptor(s,i.name):{}),l,p=!1,_=r.length-1;_>=0;_--){var h={};for(var y in i)h[y]=y==="access"?{}:i[y];for(var y in i.access)h.access[y]=i.access[y];h.addInitializer=function(v){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(o(v||null))};var b=(0,r[_])(c==="accessor"?{get:u.get,set:u.set}:u[f],h);if(c==="accessor"){if(b===void 0)continue;if(b===null||typeof b!="object")throw new TypeError("Object expected");(l=o(b.get))&&(u.get=l),(l=o(b.set))&&(u.set=l),(l=o(b.init))&&n.unshift(l)}else(l=o(b))&&(c==="field"?n.unshift(l):u[f]=l)}s&&Object.defineProperty(s,i.name,u),p=!0},JHS=function(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})},$HS=30,Li_=30,YHS=(0,Hi_.default)("puppeteer:ffmpeg"),Ki_=(()=>{let e=Gi_.PassThrough,t=[],r,i,n;return class extends e{static{let o=typeof Symbol=="function"&&Symbol.metadata?Object.create(e[Symbol.metadata]??null):void 0;Ui_(this,i={value:JHS(async function(c){let f=await new Promise(s=>{this.#t.stdin.write(c,s)});f&&console.log(`ffmpeg failed to write: ${f.message}.`)},"#writeFrame")},r,{kind:"method",name:"#writeFrame",static:!1,private:!0,access:{has:c=>#o in c,get:c=>c.#o},metadata:o},null,t),Ui_(this,null,n,{kind:"method",name:"stop",static:!1,private:!1,access:{has:c=>"stop"in c,get:c=>c.stop},metadata:o},null,t),o&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}#e=KHS(this,t);#t;#r=new AbortController;#i;#n;constructor(o,c,f,{ffmpegPath:s,speed:u,scale:l,crop:p,format:_,fps:h,loop:y,delay:b,quality:v,colors:O,path:A,overwrite:g}={}){super({allowHalfOpen:!1}),s??="ffmpeg",_??="webm",h??=Li_,y||=-1,b??=-1,v??=$HS,O??=256,g??=!0,this.#n=h;let{error:m}=(0,rIo.spawnSync)(s);if(m)throw m;let j=[`crop='min(${c},iw):min(${f},ih):0:0'`,`pad=${c}:${f}:0:0`];u&&j.push(`setpts=${1/u}*PTS`),p&&j.push(`crop=${p.width}:${p.height}:${p.x}:${p.y}`),l&&j.push(`scale=iw*${l}:-1:flags=lanczos`);let M=this.#a(_,h,y,b,v,O),E=M.indexOf("-vf");E!==-1&&j.push(M.splice(E,2).at(-1)??""),A&&Vi_.default.mkdirSync((0,xi_.dirname)(A),{recursive:g}),this.#t=(0,rIo.spawn)(s,[["-loglevel","error"],["-avioflags","direct"],["-fpsprobesize","0","-probesize","32","-analyzeduration","0","-fflags","nobuffer"],["-f","image2pipe","-vcodec","png","-i","pipe:0"],["-an"],["-threads","1"],["-framerate",`${h}`],["-b:v","0"],M,["-vf",j.join()],[g?"-y":"-n"],"pipe:1"].flat(),{stdio:["pipe","pipe","pipe"]}),this.#t.stdout.pipe(this),this.#t.stderr.on("data",B=>{YHS(B.toString("utf8"))}),this.#e=o;let{client:D}=this.#e.mainFrame();D.once(nv.Disconnected,()=>{this.stop().catch(zi)}),this.#i=LJp(Iv(D,"Page.screencastFrame").pipe(x6i(B=>{D.send("Page.screencastFrameAck",{sessionId:B.sessionId})}),she(B=>B.metadata.timestamp!==void 0),XA(B=>({buffer:Buffer.from(B.data,"base64"),timestamp:B.metadata.timestamp})),HJp(2,1),KJp(([{timestamp:B,buffer:F},{timestamp:N}])=>td(Array(Math.round(h*Math.max(N-B,0))).fill(F))),XA(B=>(this.#o(B),[B,performance.now()])),xwo(mRn(this.#r.signal,"abort"))),{defaultValue:[Buffer.from([]),performance.now()]})}#a(o,c,f,s,u,l){let p=[["-vcodec","vp9"],["-crf",`${u}`],["-deadline","realtime","-cpu-used",`${Math.min(Wi_.default.cpus().length/2,8)}`]];switch(o){case"webm":return[...p,["-f","webm"]].flat();case"gif":return c=Li_===c?20:"source_fps",f===1/0&&(f=0),s!==-1&&(s/=10),[["-vf",`fps=${c},split[s0][s1];[s0]palettegen=stats_mode=diff:max_colors=${l}[p];[s1][p]paletteuse=dither=bayer`],["-loop",`${f}`],["-final_delay",`${s}`],["-f","gif"]].flat();case"mp4":return[...p,["-movflags","hybrid_fragmented"],["-f","mp4"]].flat()}}get#o(){return i.value}async stop(){if(this.#r.signal.aborted)return;await this.#e._stopScreencast().catch(zi),this.#r.abort();let[o,c]=await this.#i;await Promise.all(Array(Math.max(1,Math.round(this.#n*(performance.now()-c)/1e3))).fill(o).map(this.#o.bind(this))),this.#t.stdin.end(),await new Promise(f=>{this.#t.once("close",f)})}async[(r=[pma()],n=[pma()],vB)](){await this.stop()}}})();var Ji_=ae(require("fs"),1),$i_=ae(require("path"),1);hvi();ox.value={fs:Ji_.default,path:$i_.default,ScreenRecorder:Ki_};var ZHS=new SNn({isPuppeteerCore:!0}),{connect:yZ5,defaultArgs:bZ5,executablePath:vZ5,launch:gZ5}=ZHS;var So_=require("os"),Mo_=require("path"),Do_=ae(Eo_(),1);function Qic(e){let t=process.env[e];if(t!==void 0)switch(t.toLowerCase()){case"":case"0":case"false":case"off":return!1;default:return!0}}function D$S(e){switch(e){case"chrome":case"firefox":return!0;default:return!1}}function B$S(e){if(e&&!D$S(e))throw new Error(`Unsupported browser ${e}`);switch(e){case"firefox":return"firefox";default:return"chrome"}}function I$S(e){switch(e){case"silent":return"silent";case"error":return"error";default:return"warn"}}function Fic(e,t,r={}){if(t.skipDownload)return{skipDownload:!0};let i={},n=e.replaceAll("-","_").toUpperCase();return i.version=process.env[`PUPPETEER_${n}_VERSION`]??t[e]?.version??r.version,i.downloadBaseUrl=process.env[`PUPPETEER_${n}_DOWNLOAD_BASE_URL`]??t[e]?.downloadBaseUrl??r.downloadBaseUrl,i.skipDownload=Qic(`PUPPETEER_${n}_SKIP_DOWNLOAD`)??Qic(`PUPPETEER_SKIP_${n}_DOWNLOAD`)??t[e]?.skipDownload??r.skipDownload,i}var Bo_=()=>{let e=(0,Do_.cosmiconfigSync)("puppeteer",{searchStrategy:"global"}).search(),t=e?e.config:{};return t.logLevel=I$S(process.env.PUPPETEER_LOGLEVEL??t.logLevel),t.defaultBrowser=B$S(process.env.PUPPETEER_BROWSER??t.defaultBrowser),t.executablePath=process.env.PUPPETEER_EXECUTABLE_PATH??t.executablePath,t.executablePath&&(t.skipDownload=!0),t.skipDownload=Qic("PUPPETEER_SKIP_DOWNLOAD")??t.skipDownload,t.chrome=Fic("chrome",t),t["chrome-headless-shell"]=Fic("chrome-headless-shell",t),t.firefox=Fic("firefox",t,{skipDownload:!0}),t.cacheDirectory=process.env.PUPPETEER_CACHE_DIR??t.cacheDirectory??(0,Mo_.join)((0,So_.homedir)(),".cache","puppeteer"),t.temporaryDirectory=process.env.PUPPETEER_TMP_DIR??t.temporaryDirectory,t.experiments??={},t};var C$S=Bo_(),q$S=new SNn({isPuppeteerCore:!1,configuration:C$S}),{connect:O25,defaultArgs:A25,executablePath:m25,launch:Io_,trimCache:P25}=q$S;var T$S="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",R$S={"Accept-Language":"en-US,en;q=0.9",Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36","Accept-Encoding":"gzip, deflate, br, zstd",Connection:"keep-alive"};async function J0a(e,t=3,r=1e3,i=2){try{return await e()}catch(n){if(t>0)return await new Promise(a=>setTimeout(a,r)),J0a(e,t-1,r*i,i);throw n}}async function Co_(){try{return await Io_({headless:!0,args:["--ignore-certificate-errors"]})}catch{throw new Error("Could not create a Puppeteer instance")}}async function z$S(e,t){try{let r=await e.newPage();await r.setViewport({width:3072,height:2048,deviceScaleFactor:2,isMobile:!1,hasTouch:!1,isLandscape:!0}),await r.setExtraHTTPHeaders(R$S),await r.setUserAgent(T$S),await r.setJavaScriptEnabled(!0),await J0a(()=>r.goto(t.toString(),{waitUntil:"networkidle2",timeout:3e4}));let i=await J0a(()=>r.content());return await r.close(),i}catch{throw new Error("Failed to download page from Puppeteer")}}async function N$S(e){try{let t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return await t.text()}catch{throw new Error("Failed to fetch page from source")}}async function Uic({url:e,browser:t}){try{let r;if(t?r=await z$S(t,e):r=await J0a(()=>N$S(e)),r)return r;throw new Error("An unknown error occurred.")}catch{throw new Error(`Error retrieving HTML for ${e.toString()}`)}}async function qo_(e){try{let t=await J0a(()=>fetch(e));if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);let r=await t.arrayBuffer();return new Uint8Array(r)}catch{throw new Error(`Failed to retrieve image from source url ${e}`)}}var F$S=["png","jpeg","jpg","webp","avif","svg","ico","jfif","pjpeg","pjp","svgz","bmp"];async function To_(e){if(!e)return{success:!1,data:void 0};if(e.startsWith("data:image/"))return{success:!0,data:[e,e]};let t=(0,FNn.join)(process.cwd(),"fern");try{let r=await Q$S(e,(0,FNn.join)(t,"images"));return r=r.replace(t,""),{success:!0,data:[e,r]}}catch{return{success:!1,data:void 0}}}async function Q$S(e,t){let r=L$S(e),i=(0,FNn.join)(t,r);if(!U$S(r))throw new Error(`${r} - file extension not supported`);if((0,OIo.existsSync)(i))return i;try{(0,OIo.mkdirSync)((0,FNn.dirname)(i),{recursive:!0})}catch{throw new Error(`${i} - failed to create directory`)}try{let n=await qo_(e);return k6p(i,n),i}catch{throw new Error(`${i}: failed to download file from source`)}}function U$S(e){if(!e)return!1;let t=e.lastIndexOf(".")+1,r=e.substring(t);if(e===r)return!1;let i=r.toLowerCase();return!(i&&!F$S.includes(i))}function L$S(e){e.startsWith("http")&&(e=new URL(e).pathname);let t=e.split("#");if(t.length===0)return"image";let r=t[0];if(!r)return"image";let i=r.split("?");if(i.length===0)return"image";let n=i[0];return n&&decodeURIComponent(n.replace(/[/]{2,}/g,"/")).replace(/(?:_{2,}|[\s%#&{}\\<>*?$!'":@+`|=])/g,"-")||"image"}function V$S(e){let t=[];return Fi(e,"element",r=>{r.tagName==="img"&&Array.isArray(r.properties.className)&&r.properties.className.includes("rm-Logo-img")&&t.push(r)}),t.length>0?t:void 0}async function Ro_(e,t){let r=ORn(e),i=V$S(r);if(i!=null){let n=await Promise.all(i.map(async a=>{let o=await To_(a.properties.src);return o.success&&o.data?o.data[1]:""}));t.push(...n)}for(let n=t.length-1;n>=0;n--)t[n]||t.splice(n,1)}var zo_=28;async function No_(e,t){e=new URL(e);let r=[];if(t){let n=[];try{let a=await t.newPage();await a.goto(e.toString(),{waitUntil:"networkidle2"}),n.push(await a.content()),await a.click(".rm-ThemeToggle"),n.push(await a.content())}catch{}await Promise.all(n.map(async a=>await Ro_(a,r)))}let i=[...new Set(r).values()];if(i.length!==0){if(i.length===1&&i[0]!=null){let n=Ye.of(z3(i[0]));return{light:n,dark:n,height:zo_}}if(i[0]!=null&&i[1]!=null){let n=Ye.of(z3(i[0])),a=Ye.of(z3(i[1]));return{light:n,dark:a,height:zo_}}}}var AIo=class extends h6i{url;logger;absolutePathToFernDirectory;constructor(t){super({context:t.context}),this.url=typeof t.url=="string"?new URL(t.url):t.url,this.logger=t.context.logger,this.absolutePathToFernDirectory=t.absolutePathToFernDirectory}async import({args:t,builder:r}){r.setLayout({layout:dAa});let i=await this.getHastForUrl(this.url),n=fJp(i)??[];if(n.length===0)this.logger.debug("No tabs found on the page");else{this.logger.debug(`Found ${n.length} tabs:`);for(let u of n)this.logger.debug(` - Tab: ${u.name} (${u.url})`)}for(let u of n){let l=await this.scrapeTab({name:u.name,url:u.url});if(!l)continue;let p=r.getNavigationBuilder({tabId:this.kebabCaseWithoutEmojis(u.name),tabConfig:{slug:u.url,displayName:u.name}}),_=Ft(this.absolutePathToFernDirectory,Ye.of(this.kebabCaseWithoutEmojis(u.name)));await this.downloadMarkdownPages({absolutePathToOutputDirectory:_,sections:l});let h=await this.getNavigationItems({absolutePathToOutputDirectory:_,sections:l});for(let y of h)p.addItem({item:y})}let a=await Co_(),o=await No_(this.url,a);o!=null&&r.setLogo({logo:o});let c=await U9p(i);r.setTitle({title:c});let f=await z9p(i);if(f!=null){let u=await this.getAndCreateAssetsDirectory(),l=await fetch(f);if(l.ok){let p=Buffer.from(await l.arrayBuffer()),_=Ft(u,Ye.of("favicon"));await(0,ZIi.writeFile)(_,new Uint8Array(p)),r.setFavicon({favicon:jH(this.absolutePathToFernDirectory,_)})}}let s=await pJp(i);r.setColors({colors:s}),a&&await a.close(),r.build({outputDirectory:this.absolutePathToFernDirectory})}async getAndCreateAssetsDirectory(){let t=Ft(this.absolutePathToFernDirectory,Ye.of("assets"));return await(0,ZIi.mkdir)(t,{recursive:!0}),t}async scrapeTab({name:t,url:r}){try{this.logger.debug(`Scraping tab: ${t} (${r})`);let i=new URL(r,this.url),n=await this.getHastForUrl(i),a=sJp(n);if(!a){this.logger.debug(`No sidebar element found for tab: ${t} (${r})`);return}let o=cJp(a);return this.logger.debug(`Successfully scraped tab: ${t}`),o}catch(i){this.logger.error(`Failed to scrape tab ${t}: ${i instanceof Error?i.message:String(i)}`),i instanceof Error&&i.stack&&this.logger.error(`Stack trace: ${i.stack}`)}}async getHastForUrl(t){let r=await Uic({url:t});return ORn(r)}async downloadMarkdownPages({absolutePathToOutputDirectory:t,sections:r}){for(let i of r){this.logger.debug(`Processing section: ${i.group}`);let n=this.getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:i});await(0,ZIi.mkdir)(n,{recursive:!0}),await Promise.all(i.pages.filter(a=>a.type==="page").map(async a=>{let o=new URL(a.slug.toString(),this.url);this.logger.debug(`Fetching page: ${o.toString()}`);let c=await Uic({url:o}),f=await uJp({logger:this.logger,html:c,url:o});if(f.success&&f.data){let s=this.getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:n,page:a.slug});await(0,ZIi.writeFile)(s,f.data.mdx),f.data.images.imageURLs.length>0&&(this.logger.debug(`Found ${f.data.images.imageURLs.length} images to download for ${o.toString()}`),await Promise.all(Object.entries(f.data.images.imageURLToFilename).map(async([u,l])=>{try{let p=await fetch(u);if(!p.ok){this.logger.warn(`Failed to download image ${u}, status: ${p.status}`);return}let _=Buffer.from(await p.arrayBuffer()),h=Ft(n,Ye.of(l)),y=hn(h);await(0,ZIi.mkdir)(y,{recursive:!0}),await(0,ZIi.writeFile)(h,new Uint8Array(_)),this.logger.debug(`Saved image to ${h}`)}catch(p){this.logger.warn(`Error downloading image ${u}: ${p}`)}})))}else this.logger.warn(`Failed to parse page ${o.toString()}, skipping`)})),await Promise.all(i.pages.filter(a=>a.type==="group").map(async a=>{this.logger.debug(`Processing nested group: ${a.group}`),await this.downloadMarkdownPages({absolutePathToOutputDirectory:n,sections:[{type:"group",group:a.group,pages:a.pages}]})}))}}async getNavigationItems({absolutePathToOutputDirectory:t,sections:r}){let i=[];for(let n of r){let a=this.getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:n}),o={section:n.group,contents:[],slug:this.kebabCaseWithoutEmojis(n.group)};for(let c of n.pages)if(c.type==="page")o.contents.push({page:c.page,path:jH(this.absolutePathToFernDirectory,this.getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:a,page:c.slug}))});else{let f=await this.getNavigationItems({absolutePathToOutputDirectory:a,sections:[c]});o.contents.push(...f)}i.push(o)}return i}getAbsolutePathToOutputFileForPage({absolutePathToOutputDirectoryForSection:t,page:r}){return Ft(t,Ye.of(`${this.kebabCaseWithoutEmojis(r.split("/").pop()||r)}.mdx`))}getAbsolutePathToOutputDirectoryForSection({absolutePathToOutputDirectory:t,section:r}){return Ft(t,Ye.of(this.kebabCaseWithoutEmojis(r.group)))}kebabCaseWithoutEmojis(t){return t.replace(/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu,"").toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_]+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}};var Fo_=require("fs/promises");async function Lic({readmeUrl:e,outputPath:t,taskContext:r,versionOfCli:i,organization:n}){let a=new y6i;a.setInstance({companyName:n}),await new AIo({url:e,context:r,builder:a,absolutePathToFernDirectory:Ft(Lr.of(process.cwd()),Ye.of("fern"))}).import({args:{},builder:a}),await a.build({outputDirectory:t}),await(0,Fo_.writeFile)(Ft(Lr.of(t),Ye.of(n1),Ye.of(ZF)),JSON.stringify({version:i,organization:n},void 0,4))}var Vic=async({readmeUrl:e,organization:t,taskContext:r,versionOfCli:i})=>{if(!e||!P9i(e)){r.failAndThrow("Provide a URL to a readme-generated site");return}let n=Lr.of(Q0());await Lic({readmeUrl:e,outputPath:n,taskContext:r,versionOfCli:i,organization:t})};var Qo_="0.0.0";var Uo_={[wn.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,UP(e)])),[wn.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"]),[wn.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"]),[wn.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"]),[wn.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"]),[wn.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"]),[wn.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"]),[wn.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"]),[wn.GenerationLanguage.SWIFT]:new Set([])};var x$S=["go","ruby"];function _x({generationLanguage:e,keywords:t,smartCasing:r}){let i={generateName:(n,a)=>{let o=l=>({unsafeName:l,safeName:G$S({name:l,keywords:H$S({generationLanguage:e,keywords:t})})}),c=No(n),f=UP(c),s=Nxi(n),u=qxi(c);return r&&(!$$S(u)&&(e==null||x$S.includes(e))&&(c=u.map((l,p)=>{if(p>0){let _=mIo(l);if(_!=null)return _;if(PIo(l))return l.toUpperCase()}return l}).join(""),f=UP(u.map((l,p)=>{let _=mIo(l);return _??(PIo(l)?l.toUpperCase():p===0?UP(l):l)}).join(""))),s=n.split(" ").map(l=>l.split(/(\d+)/).map(Nxi).join("")).join("_")),{originalName:n,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??f)}},generateNameAndWireValue:({name:n,wireValue:a,opts:o})=>({name:i.generateName(n,o),wireValue:a})};return i}function G$S({name:e,keywords:t}){return t==null?e:t.has(e)?e+"_":J$S(e)?"_"+e:e}function H$S({generationLanguage:e,keywords:t}){if(t!=null)return new Set(t);if(e!=null)return Uo_[e]}var K$S=/^[0-9]/;function J$S(e){return K$S.test(e)}function $$S(e){return e.some((t,r)=>{if(r===0)return!1;let i=e[r-1];if(i==null)return!1;let n=mIo(i)!=null||PIo(i),a=mIo(t)!=null||PIo(t);return n&&a})}function mIo(e){return X$S.get(e.toUpperCase())}function PIo(e){return Y$S.has(e.toUpperCase())}var Y$S=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"]),X$S=new Map([["ACLS","ACLs"],["APIS","APIs"],["CPUS","CPUs"],["GUIDS","GUIDs"],["IDS","IDs"],["UIDS","UIDs"],["UUIDS","UUIDs"],["URIS","URIs"],["URLS","URLs"]]);var br={};Kt(br,{ApiDefinitionSource:()=>k6,ApiVersionScheme:()=>rCi,AuthScheme:()=>EA,AuthSchemesRequirement:()=>CL,AvailabilityStatus:()=>IC,ContainerType:()=>es,Environments:()=>YE,ErrorDeclarationDiscriminantValue:()=>tCi,ErrorDiscriminationStrategy:()=>vhe,ExampleCodeSample:()=>yhe,ExampleContainer:()=>op,ExampleEndpointSuccessResponse:()=>$P,ExamplePrimitive:()=>Dn,ExampleQueryParameterShape:()=>B1,ExampleRequestBody:()=>RL,ExampleResponse:()=>K0,ExampleSingleUnionTypeProperties:()=>jB,ExampleStyle:()=>SIo,ExampleTypeReferenceShape:()=>lu,ExampleTypeShape:()=>Ih,ExampleWebSocketMessageBody:()=>ghe,FileProperty:()=>X6,FileUploadBodyPropertyEncoding:()=>$0a,FileUploadRequestProperty:()=>qC,HttpEndpointSource:()=>qL,HttpMethod:()=>JP,HttpRequestBody:()=>VO,HttpResponseBody:()=>ly,JsonResponse:()=>nz,Literal:()=>uz,NamedTypeDefault:()=>QNn,NonStreamHttpResponseBody:()=>LQ,OAuthConfiguration:()=>kIi,ObjectPropertyAccess:()=>Y9t,Pagination:()=>TL,PathParameterLocation:()=>j0e,PrimitiveTypeV1:()=>Su,PrimitiveTypeV2:()=>Pn,ProtobufMethodType:()=>nFt,ProtobufType:()=>Bh,PublishTarget:()=>PB,PublishingConfig:()=>$9t,RequestPropertyValue:()=>Z6,ResolvedTypeReference:()=>VQ,SdkRequestBodyType:()=>iFt,SdkRequestShape:()=>w0e,ShapeType:()=>aFt,SingleUnionTypeProperties:()=>oz,Source:()=>Qvi,StreamingResponse:()=>az,SupportedSdkLanguage:()=>bhe,Transport:()=>P0e,Type:()=>Zc,TypeReference:()=>ni,V2AuthValues:()=>m0e,V2EndpointLocationHttpMethod:()=>J9t,V2HttpEndpointResponseBody:()=>CC,WebSocketMessageBody:()=>sz,WebSocketMessageOrigin:()=>DIo,WebhookHttpMethod:()=>MIo,WebhookPayload:()=>WQ,WellKnownProtobufType:()=>ln,audience:()=>Lo_,auth:()=>Wic,commons:()=>xic,constants:()=>Vo_,dynamic:()=>Gt,environment:()=>Zic,errors:()=>kic,examples:()=>enc,generatorExec:()=>Lc,http:()=>rnc,ir:()=>inc,proto:()=>nnc,publish:()=>anc,types:()=>onc,variables:()=>fu_,webhooks:()=>unc,websocket:()=>snc});var Lo_={};var Wic={};Kt(Wic,{AuthScheme:()=>EA,AuthSchemesRequirement:()=>CL,OAuthConfiguration:()=>kIi});var CL={All:"ALL",Any:"ANY",_visit:(e,t)=>{switch(e){case CL.All:return t.all();case CL.Any:return t.any();default:return t._other()}}};var EA={bearer:e=>({...e,type:"bearer",_visit:function(t){return EA._visit(this,t)}}),basic:e=>({...e,type:"basic",_visit:function(t){return EA._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return EA._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return EA._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return EA._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bearer":return t.bearer(e);case"basic":return t.basic(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var kIi={clientCredentials:e=>({...e,type:"clientCredentials",_visit:function(t){return kIi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"clientCredentials":return t.clientCredentials(e);default:return t._other(e)}}};var xic={};Kt(xic,{AvailabilityStatus:()=>IC});var IC={InDevelopment:"IN_DEVELOPMENT",PreRelease:"PRE_RELEASE",GeneralAvailability:"GENERAL_AVAILABILITY",Deprecated:"DEPRECATED",_visit:(e,t)=>{switch(e){case IC.InDevelopment:return t.inDevelopment();case IC.PreRelease:return t.preRelease();case IC.GeneralAvailability:return t.generalAvailability();case IC.Deprecated:return t.deprecated();default:return t._other()}}};var Vo_={};var Gt={};Kt(Gt,{Auth:()=>Wo_,AuthValues:()=>xo_,Environments:()=>Zo_,ErrorSeverity:()=>jIo,FileUploadRequestBodyProperty:()=>Xo_,GeneratorOutputConfig:()=>ko_,HttpMethod:()=>eCi,InlinedRequestBody:()=>$o_,LiteralType:()=>nu_,NamedType:()=>tu_,ObjectPropertyAccess:()=>wIo,PrimitiveTypeV1:()=>hx,PublishInfo:()=>eu_,ReferencedRequestBodyType:()=>Yo_,Request:()=>Ko_,Response:()=>Jo_,SingleDiscriminatedUnionType:()=>iu_,TypeReference:()=>ru_,auth:()=>Gic,commons:()=>Go_,declaration:()=>Ho_,endpoints:()=>Hic,environment:()=>Kic,http:()=>Jic,ir:()=>$ic,snippets:()=>Yic,types:()=>Xic,variables:()=>au_});var Gic={};Kt(Gic,{Auth:()=>Wo_,AuthValues:()=>xo_});var Wo_={basic:e=>({...e,type:"basic",_visit:function(t){return Gt.Auth._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Gt.Auth._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Gt.Auth._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Gt.Auth._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return Gt.Auth._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"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var xo_={basic:e=>({...e,type:"basic",_visit:function(t){return Gt.AuthValues._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Gt.AuthValues._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Gt.AuthValues._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Gt.AuthValues._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return Gt.AuthValues._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"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var Go_={};var Ho_={};var Hic={};Kt(Hic,{FileUploadRequestBodyProperty:()=>Xo_,InlinedRequestBody:()=>$o_,ReferencedRequestBodyType:()=>Yo_,Request:()=>Ko_,Response:()=>Jo_});var Ko_={body:e=>({...e,type:"body",_visit:function(t){return Gt.Request._visit(this,t)}}),inlined:e=>({...e,type:"inlined",_visit:function(t){return Gt.Request._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e);case"inlined":return t.inlined(e);default:return t._other(e)}}};var Jo_={json:()=>({type:"json",_visit:function(e){return Gt.Response._visit(this,e)}}),streaming:()=>({type:"streaming",_visit:function(e){return Gt.Response._visit(this,e)}}),streamParameter:()=>({type:"streamParameter",_visit:function(e){return Gt.Response._visit(this,e)}}),fileDownload:()=>({type:"fileDownload",_visit:function(e){return Gt.Response._visit(this,e)}}),text:()=>({type:"text",_visit:function(e){return Gt.Response._visit(this,e)}}),bytes:()=>({type:"bytes",_visit:function(e){return Gt.Response._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json();case"streaming":return t.streaming();case"streamParameter":return t.streamParameter();case"fileDownload":return t.fileDownload();case"text":return t.text();case"bytes":return t.bytes();default:return t._other(e)}}};var $o_={properties:e=>({value:e,type:"properties",_visit:function(t){return Gt.InlinedRequestBody._visit(this,t)}}),referenced:e=>({...e,type:"referenced",_visit:function(t){return Gt.InlinedRequestBody._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return Gt.InlinedRequestBody._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"properties":return t.properties(e.value);case"referenced":return t.referenced(e);case"fileUpload":return t.fileUpload(e);default:return t._other(e)}}};var Yo_={bytes:()=>({type:"bytes",_visit:function(e){return Gt.ReferencedRequestBodyType._visit(this,e)}}),typeReference:e=>({value:e,type:"typeReference",_visit:function(t){return Gt.ReferencedRequestBodyType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bytes":return t.bytes();case"typeReference":return t.typeReference(e.value);default:return t._other(e)}}};var Xo_={file:e=>({...e,type:"file",_visit:function(t){return Gt.FileUploadRequestBodyProperty._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return Gt.FileUploadRequestBodyProperty._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return Gt.FileUploadRequestBodyProperty._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var Kic={};Kt(Kic,{Environments:()=>Zo_});var Zo_={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return Gt.Environments._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return Gt.Environments._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var Jic={};Kt(Jic,{HttpMethod:()=>eCi});var eCi={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case eCi.Get:return t.get();case eCi.Post:return t.post();case eCi.Put:return t.put();case eCi.Patch:return t.patch();case eCi.Delete:return t.delete();case eCi.Head:return t.head();default:return t._other()}}};var $ic={};Kt($ic,{GeneratorOutputConfig:()=>ko_,PublishInfo:()=>eu_});var ko_={publish:e=>({value:e,type:"publish",_visit:function(t){return Gt.GeneratorOutputConfig._visit(this,t)}}),local:()=>({type:"local",_visit:function(e){return Gt.GeneratorOutputConfig._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e.value);case"local":return t.local();default:return t._other(e)}}};var eu_={go:e=>({...e,type:"go",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),swift:e=>({...e,type:"swift",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Gt.PublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"go":return t.go(e);case"swift":return t.swift(e);case"maven":return t.maven(e);case"npm":return t.npm(e);case"nuget":return t.nuget(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Yic={};Kt(Yic,{ErrorSeverity:()=>jIo});var jIo={Critical:"CRITICAL",Warning:"WARNING",_visit:(e,t)=>{switch(e){case jIo.Critical:return t.critical();case jIo.Warning:return t.warning();default:return t._other()}}};var Xic={};Kt(Xic,{LiteralType:()=>nu_,NamedType:()=>tu_,ObjectPropertyAccess:()=>wIo,PrimitiveTypeV1:()=>hx,SingleDiscriminatedUnionType:()=>iu_,TypeReference:()=>ru_});var tu_={alias:e=>({...e,type:"alias",_visit:function(t){return Gt.NamedType._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Gt.NamedType._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Gt.NamedType._visit(this,t)}}),discriminatedUnion:e=>({...e,type:"discriminatedUnion",_visit:function(t){return Gt.NamedType._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Gt.NamedType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"discriminatedUnion":return t.discriminatedUnion(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var ru_={list:e=>({value:e,type:"list",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),named:e=>({value:e,type:"named",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),nullable:e=>({value:e,type:"nullable",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),optional:e=>({value:e,type:"optional",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),primitive:e=>({value:e,type:"primitive",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),set:e=>({value:e,type:"set",_visit:function(t){return Gt.TypeReference._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return Gt.TypeReference._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.value);case"literal":return t.literal(e.value);case"map":return t.map(e);case"named":return t.named(e.value);case"nullable":return t.nullable(e.value);case"optional":return t.optional(e.value);case"primitive":return t.primitive(e.value);case"set":return t.set(e.value);case"unknown":return t.unknown();default:return t._other(e)}}};var iu_={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return Gt.SingleDiscriminatedUnionType._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return Gt.SingleDiscriminatedUnionType._visit(this,t)}}),noProperties:e=>({...e,type:"noProperties",_visit:function(t){return Gt.SingleDiscriminatedUnionType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties(e);default:return t._other(e)}}};var nu_={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Gt.LiteralType._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Gt.LiteralType._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 wIo={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY",_visit:(e,t)=>{switch(e){case wIo.ReadOnly:return t.readOnly();case wIo.WriteOnly:return t.writeOnly();default:return t._other()}}};var hx={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER",_visit:(e,t)=>{switch(e){case hx.Integer:return t.integer();case hx.Long:return t.long();case hx.Uint:return t.uint();case hx.Uint64:return t.uint64();case hx.Float:return t.float();case hx.Double:return t.double();case hx.Boolean:return t.boolean();case hx.String:return t.string();case hx.Date:return t.date();case hx.DateTime:return t.dateTime();case hx.Uuid:return t.uuid();case hx.Base64:return t.base64();case hx.BigInteger:return t.bigInteger();default:return t._other()}}};var au_={};var Zic={};Kt(Zic,{Environments:()=>YE});var YE={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return YE._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return YE._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var kic={};Kt(kic,{ErrorDeclarationDiscriminantValue:()=>tCi});var tCi={property:e=>({...e,type:"property",_visit:function(t){return tCi._visit(this,t)}}),statusCode:()=>({type:"statusCode",_visit:function(e){return tCi._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"property":return t.property(e);case"statusCode":return t.statusCode();default:return t._other(e)}}};var enc={};Kt(enc,{V2AuthValues:()=>m0e,V2EndpointLocationHttpMethod:()=>J9t,V2HttpEndpointResponseBody:()=>CC});var CC={error:e=>({value:e,type:"error",_visit:function(t){return CC._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return CC._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return CC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"error":return t.error(e.value);case"json":return t.json(e.value);case"stream":return t.stream(e.value);default:return t._other(e)}}};var J9t={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case J9t.Get:return t.get();case J9t.Post:return t.post();case J9t.Put:return t.put();case J9t.Patch:return t.patch();case J9t.Delete:return t.delete();case J9t.Head:return t.head();default:return t._other()}}};var m0e={basic:e=>({...e,type:"basic",_visit:function(t){return m0e._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return m0e._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return m0e._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return m0e._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"oauth":return t.oauth(e);default:return t._other(e)}}};var Lc={};Kt(Lc,{GeneratorEnvironment:()=>lu_,GeneratorPublishTarget:()=>cu_,GithubPublishInfo:()=>su_,LicenseConfig:()=>ou_,LicenseId:()=>EIo,OutputMode:()=>uu_,config:()=>tnc});var tnc={};Kt(tnc,{GeneratorEnvironment:()=>lu_,GeneratorPublishTarget:()=>cu_,GithubPublishInfo:()=>su_,LicenseConfig:()=>ou_,LicenseId:()=>EIo,OutputMode:()=>uu_});var ou_={basic:e=>({...e,type:"basic",_visit:function(t){return Lc.LicenseConfig._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Lc.LicenseConfig._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"custom":return t.custom(e);default:return t._other(e)}}};var EIo={Mit:"MIT",Apache2:"Apache-2.0",_visit:(e,t)=>{switch(e){case EIo.Mit:return t.mit();case EIo.Apache2:return t.apache2();default:return t._other()}}};var uu_={publish:e=>({...e,type:"publish",_visit:function(t){return Lc.OutputMode._visit(this,t)}}),downloadFiles:()=>({type:"downloadFiles",_visit:function(e){return Lc.OutputMode._visit(this,e)}}),github:e=>({...e,type:"github",_visit:function(t){return Lc.OutputMode._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e);case"downloadFiles":return t.downloadFiles();case"github":return t.github(e);default:return t._other(e)}}};var su_={npm:e=>({...e,type:"npm",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Lc.GithubPublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"npm":return t.npm(e);case"maven":return t.maven(e);case"postman":return t.postman(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var cu_={maven:e=>({...e,type:"maven",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Lc.GeneratorPublishTarget._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"maven":return t.maven(e);case"npm":return t.npm(e);case"pypi":return t.pypi(e);case"postman":return t.postman(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var lu_={local:()=>({type:"local",_visit:function(e){return Lc.GeneratorEnvironment._visit(this,e)}}),remote:e=>({...e,type:"remote",_visit:function(t){return Lc.GeneratorEnvironment._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"local":return t.local();case"remote":return t.remote(e);default:return t._other(e)}}};var rnc={};Kt(rnc,{ExampleCodeSample:()=>yhe,ExampleEndpointSuccessResponse:()=>$P,ExampleQueryParameterShape:()=>B1,ExampleRequestBody:()=>RL,ExampleResponse:()=>K0,FileProperty:()=>X6,FileUploadBodyPropertyEncoding:()=>$0a,FileUploadRequestProperty:()=>qC,HttpEndpointSource:()=>qL,HttpMethod:()=>JP,HttpRequestBody:()=>VO,HttpResponseBody:()=>ly,JsonResponse:()=>nz,NonStreamHttpResponseBody:()=>LQ,Pagination:()=>TL,PathParameterLocation:()=>j0e,RequestPropertyValue:()=>Z6,SdkRequestBodyType:()=>iFt,SdkRequestShape:()=>w0e,StreamingResponse:()=>az,SupportedSdkLanguage:()=>bhe,Transport:()=>P0e});var P0e={http:()=>({type:"http",_visit:function(e){return P0e._visit(this,e)}}),grpc:e=>({...e,type:"grpc",_visit:function(t){return P0e._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"http":return t.http();case"grpc":return t.grpc(e);default:return t._other(e)}}};var qL={proto:e=>({...e,type:"proto",_visit:function(t){return qL._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return qL._visit(this,e)}}),openrpc:()=>({type:"openrpc",_visit:function(e){return qL._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();case"openrpc":return t.openrpc();default:return t._other(e)}}};var JP={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",_visit:(e,t)=>{switch(e){case JP.Get:return t.get();case JP.Post:return t.post();case JP.Put:return t.put();case JP.Patch:return t.patch();case JP.Delete:return t.delete();case JP.Head:return t.head();default:return t._other()}}};var j0e={Root:"ROOT",Service:"SERVICE",Endpoint:"ENDPOINT",_visit:(e,t)=>{switch(e){case j0e.Root:return t.root();case j0e.Service:return t.service();case j0e.Endpoint:return t.endpoint();default:return t._other()}}};var VO={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return VO._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return VO._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return VO._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return VO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);case"fileUpload":return t.fileUpload(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var qC={file:e=>({value:e,type:"file",_visit:function(t){return qC._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return qC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e.value);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var $0a={Exploded:"exploded",Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case $0a.Exploded:return t.exploded();case $0a.Json:return t.json();case $0a.Form:return t.form();default:return t._other()}}};var X6={file:e=>({...e,type:"file",_visit:function(t){return X6._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return X6._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);default:return t._other(e)}}};var iFt={typeReference:e=>({...e,type:"typeReference",_visit:function(t){return iFt._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return iFt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"typeReference":return t.typeReference(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var w0e={justRequestBody:e=>({value:e,type:"justRequestBody",_visit:function(t){return w0e._visit(this,t)}}),wrapper:e=>({...e,type:"wrapper",_visit:function(t){return w0e._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"justRequestBody":return t.justRequestBody(e.value);case"wrapper":return t.wrapper(e);default:return t._other(e)}}};var LQ={json:e=>({value:e,type:"json",_visit:function(t){return LQ._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return LQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return LQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return LQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var ly={json:e=>({value:e,type:"json",_visit:function(t){return ly._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return ly._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return ly._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return ly._visit(this,t)}}),streaming:e=>({value:e,type:"streaming",_visit:function(t){return ly._visit(this,t)}}),streamParameter:e=>({...e,type:"streamParameter",_visit:function(t){return ly._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streaming":return t.streaming(e.value);case"streamParameter":return t.streamParameter(e);default:return t._other(e)}}};var nz={response:e=>({...e,type:"response",_visit:function(t){return nz._visit(this,t)}}),nestedPropertyAsResponse:e=>({...e,type:"nestedPropertyAsResponse",_visit:function(t){return nz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"response":return t.response(e);case"nestedPropertyAsResponse":return t.nestedPropertyAsResponse(e);default:return t._other(e)}}};var az={json:e=>({...e,type:"json",_visit:function(t){return az._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return az._visit(this,t)}}),sse:e=>({...e,type:"sse",_visit:function(t){return az._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e);case"text":return t.text(e);case"sse":return t.sse(e);default:return t._other(e)}}};var TL={cursor:e=>({...e,type:"cursor",_visit:function(t){return TL._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return TL._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return TL._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 Z6={query:e=>({...e,type:"query",_visit:function(t){return Z6._visit(this,t)}}),body:e=>({...e,type:"body",_visit:function(t){return Z6._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"query":return t.query(e);case"body":return t.body(e);default:return t._other(e)}}};var yhe={language:e=>({...e,type:"language",_visit:function(t){return yhe._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return yhe._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 bhe={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Php:"php",Rust:"rust",Swift:"swift",_visit:(e,t)=>{switch(e){case bhe.Curl:return t.curl();case bhe.Python:return t.python();case bhe.Javascript:return t.javascript();case bhe.Typescript:return t.typescript();case bhe.Go:return t.go();case bhe.Ruby:return t.ruby();case bhe.Csharp:return t.csharp();case bhe.Java:return t.java();case bhe.Php:return t.php();case bhe.Rust:return t.rust();case bhe.Swift:return t.swift();default:return t._other()}}};var B1={single:()=>({type:"single",_visit:function(e){return B1._visit(this,e)}}),exploded:()=>({type:"exploded",_visit:function(e){return B1._visit(this,e)}}),commaSeparated:()=>({type:"commaSeparated",_visit:function(e){return B1._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"single":return t.single();case"exploded":return t.exploded();case"commaSeparated":return t.commaSeparated();default:return t._other(e)}}};var RL={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return RL._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return RL._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var K0={ok:e=>({value:e,type:"ok",_visit:function(t){return K0._visit(this,t)}}),error:e=>({...e,type:"error",_visit:function(t){return K0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"ok":return t.ok(e.value);case"error":return t.error(e);default:return t._other(e)}}};var $P={body:e=>({value:e,type:"body",_visit:function(t){return $P._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return $P._visit(this,t)}}),sse:e=>({value:e,type:"sse",_visit:function(t){return $P._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e.value);case"stream":return t.stream(e.value);case"sse":return t.sse(e.value);default:return t._other(e)}}};var inc={};Kt(inc,{ApiDefinitionSource:()=>k6,ApiVersionScheme:()=>rCi,ErrorDiscriminationStrategy:()=>vhe,ExampleStyle:()=>SIo});var SIo={Minimal:"minimal",Comprehensive:"comprehensive",_visit:(e,t)=>{switch(e){case SIo.Minimal:return t.minimal();case SIo.Comprehensive:return t.comprehensive();default:return t._other()}}};var k6={proto:e=>({...e,type:"proto",_visit:function(t){return k6._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return k6._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();default:return t._other(e)}}};var rCi={header:e=>({...e,type:"header",_visit:function(t){return rCi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"header":return t.header(e);default:return t._other(e)}}};var vhe={statusCode:()=>({type:"statusCode",_visit:function(e){return vhe._visit(this,e)}}),property:e=>({...e,type:"property",_visit:function(t){return vhe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"statusCode":return t.statusCode();case"property":return t.property(e);default:return t._other(e)}}};var nnc={};Kt(nnc,{ProtobufMethodType:()=>nFt,ProtobufType:()=>Bh,WellKnownProtobufType:()=>ln});var Bh={wellKnown:e=>({value:e,type:"wellKnown",_visit:function(t){return Bh._visit(this,t)}}),userDefined:e=>({...e,type:"userDefined",_visit:function(t){return Bh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"wellKnown":return t.wellKnown(e.value);case"userDefined":return t.userDefined(e);default:return t._other(e)}}};var ln={any:()=>({type:"any",_visit:function(e){return ln._visit(this,e)}}),api:()=>({type:"api",_visit:function(e){return ln._visit(this,e)}}),boolValue:()=>({type:"boolValue",_visit:function(e){return ln._visit(this,e)}}),bytesValue:()=>({type:"bytesValue",_visit:function(e){return ln._visit(this,e)}}),doubleValue:()=>({type:"doubleValue",_visit:function(e){return ln._visit(this,e)}}),duration:()=>({type:"duration",_visit:function(e){return ln._visit(this,e)}}),empty:()=>({type:"empty",_visit:function(e){return ln._visit(this,e)}}),enum:()=>({type:"enum",_visit:function(e){return ln._visit(this,e)}}),enumValue:()=>({type:"enumValue",_visit:function(e){return ln._visit(this,e)}}),field:()=>({type:"field",_visit:function(e){return ln._visit(this,e)}}),fieldCardinality:()=>({type:"fieldCardinality",_visit:function(e){return ln._visit(this,e)}}),fieldKind:()=>({type:"fieldKind",_visit:function(e){return ln._visit(this,e)}}),fieldMask:()=>({type:"fieldMask",_visit:function(e){return ln._visit(this,e)}}),floatValue:()=>({type:"floatValue",_visit:function(e){return ln._visit(this,e)}}),int32Value:()=>({type:"int32Value",_visit:function(e){return ln._visit(this,e)}}),int64Value:()=>({type:"int64Value",_visit:function(e){return ln._visit(this,e)}}),listValue:()=>({type:"listValue",_visit:function(e){return ln._visit(this,e)}}),method:()=>({type:"method",_visit:function(e){return ln._visit(this,e)}}),mixin:()=>({type:"mixin",_visit:function(e){return ln._visit(this,e)}}),nullValue:()=>({type:"nullValue",_visit:function(e){return ln._visit(this,e)}}),option:()=>({type:"option",_visit:function(e){return ln._visit(this,e)}}),sourceContext:()=>({type:"sourceContext",_visit:function(e){return ln._visit(this,e)}}),stringValue:()=>({type:"stringValue",_visit:function(e){return ln._visit(this,e)}}),struct:()=>({type:"struct",_visit:function(e){return ln._visit(this,e)}}),syntax:()=>({type:"syntax",_visit:function(e){return ln._visit(this,e)}}),timestamp:()=>({type:"timestamp",_visit:function(e){return ln._visit(this,e)}}),type:()=>({type:"type",_visit:function(e){return ln._visit(this,e)}}),uint32Value:()=>({type:"uint32Value",_visit:function(e){return ln._visit(this,e)}}),uint64Value:()=>({type:"uint64Value",_visit:function(e){return ln._visit(this,e)}}),value:()=>({type:"value",_visit:function(e){return ln._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"any":return t.any();case"api":return t.api();case"boolValue":return t.boolValue();case"bytesValue":return t.bytesValue();case"doubleValue":return t.doubleValue();case"duration":return t.duration();case"empty":return t.empty();case"enum":return t.enum();case"enumValue":return t.enumValue();case"field":return t.field();case"fieldCardinality":return t.fieldCardinality();case"fieldKind":return t.fieldKind();case"fieldMask":return t.fieldMask();case"floatValue":return t.floatValue();case"int32Value":return t.int32Value();case"int64Value":return t.int64Value();case"listValue":return t.listValue();case"method":return t.method();case"mixin":return t.mixin();case"nullValue":return t.nullValue();case"option":return t.option();case"sourceContext":return t.sourceContext();case"stringValue":return t.stringValue();case"struct":return t.struct();case"syntax":return t.syntax();case"timestamp":return t.timestamp();case"type":return t.type();case"uint32Value":return t.uint32Value();case"uint64Value":return t.uint64Value();case"value":return t.value();default:return t._other(e)}}};var nFt={Unary:"UNARY",ClientStream:"CLIENT_STREAM",ServerStream:"SERVER_STREAM",BidirectionalStream:"BIDIRECTIONAL_STREAM",_visit:(e,t)=>{switch(e){case nFt.Unary:return t.unary();case nFt.ClientStream:return t.clientStream();case nFt.ServerStream:return t.serverStream();case nFt.BidirectionalStream:return t.bidirectionalStream();default:return t._other()}}};var anc={};Kt(anc,{PublishTarget:()=>PB,PublishingConfig:()=>$9t});var $9t={github:e=>({...e,type:"github",_visit:function(t){return $9t._visit(this,t)}}),direct:e=>({...e,type:"direct",_visit:function(t){return $9t._visit(this,t)}}),filesystem:e=>({...e,type:"filesystem",_visit:function(t){return $9t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"github":return t.github(e);case"direct":return t.direct(e);case"filesystem":return t.filesystem(e);default:return t._other(e)}}};var PB={postman:e=>({...e,type:"postman",_visit:function(t){return PB._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return PB._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return PB._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return PB._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return PB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"postman":return t.postman(e);case"npm":return t.npm(e);case"maven":return t.maven(e);case"pypi":return t.pypi(e);case"crates":return t.crates(e);default:return t._other(e)}}};var onc={};Kt(onc,{ContainerType:()=>es,ExampleContainer:()=>op,ExamplePrimitive:()=>Dn,ExampleSingleUnionTypeProperties:()=>jB,ExampleTypeReferenceShape:()=>lu,ExampleTypeShape:()=>Ih,Literal:()=>uz,NamedTypeDefault:()=>QNn,ObjectPropertyAccess:()=>Y9t,PrimitiveTypeV1:()=>Su,PrimitiveTypeV2:()=>Pn,ResolvedTypeReference:()=>VQ,ShapeType:()=>aFt,SingleUnionTypeProperties:()=>oz,Source:()=>Qvi,Type:()=>Zc,TypeReference:()=>ni});var Qvi={proto:e=>({value:e,type:"proto",_visit:function(t){return Qvi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e.value);default:return t._other(e)}}};var Zc={alias:e=>({...e,type:"alias",_visit:function(t){return Zc._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Zc._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Zc._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Zc._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Zc._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var VQ={container:e=>({container:e,type:"container",_visit:function(t){return VQ._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return VQ._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return VQ._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return VQ._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var aFt={Enum:"ENUM",Object:"OBJECT",Union:"UNION",UndiscriminatedUnion:"UNDISCRIMINATED_UNION",_visit:(e,t)=>{switch(e){case aFt.Enum:return t.enum();case aFt.Object:return t.object();case aFt.Union:return t.union();case aFt.UndiscriminatedUnion:return t.undiscriminatedUnion();default:return t._other()}}};var Y9t={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY",_visit:(e,t)=>{switch(e){case Y9t.ReadOnly:return t.readOnly();case Y9t.WriteOnly:return t.writeOnly();default:return t._other()}}};var oz={samePropertiesAsObject:e=>({...e,propertiesType:"samePropertiesAsObject",_visit:function(t){return oz._visit(this,t)}}),singleProperty:e=>({...e,propertiesType:"singleProperty",_visit:function(t){return oz._visit(this,t)}}),noProperties:()=>({propertiesType:"noProperties",_visit:function(e){return oz._visit(this,e)}}),_visit:(e,t)=>{switch(e.propertiesType){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var ni={container:e=>({container:e,type:"container",_visit:function(t){return ni._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return ni._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return ni._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return ni._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var QNn={enum:e=>({...e,type:"enum",_visit:function(t){return QNn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"enum":return t.enum(e);default:return t._other(e)}}};var es={list:e=>({list:e,type:"list",_visit:function(t){return es._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return es._visit(this,t)}}),nullable:e=>({nullable:e,type:"nullable",_visit:function(t){return es._visit(this,t)}}),optional:e=>({optional:e,type:"optional",_visit:function(t){return es._visit(this,t)}}),set:e=>({set:e,type:"set",_visit:function(t){return es._visit(this,t)}}),literal:e=>({literal:e,type:"literal",_visit:function(t){return es._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.list);case"map":return t.map(e);case"nullable":return t.nullable(e.nullable);case"optional":return t.optional(e.optional);case"set":return t.set(e.set);case"literal":return t.literal(e.literal);default:return t._other(e)}}};var Su={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER",_visit:(e,t)=>{switch(e){case Su.Integer:return t.integer();case Su.Long:return t.long();case Su.Uint:return t.uint();case Su.Uint64:return t.uint64();case Su.Float:return t.float();case Su.Double:return t.double();case Su.Boolean:return t.boolean();case Su.String:return t.string();case Su.Date:return t.date();case Su.DateTime:return t.dateTime();case Su.Uuid:return t.uuid();case Su.Base64:return t.base64();case Su.BigInteger:return t.bigInteger();default:return t._other()}}};var Pn={integer:e=>({...e,type:"integer",_visit:function(t){return Pn._visit(this,t)}}),long:e=>({...e,type:"long",_visit:function(t){return Pn._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Pn._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Pn._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Pn._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Pn._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Pn._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Pn._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Pn._visit(this,t)}}),dateTime:e=>({...e,type:"dateTime",_visit:function(t){return Pn._visit(this,t)}}),uuid:e=>({...e,type:"uuid",_visit:function(t){return Pn._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Pn._visit(this,t)}}),bigInteger:e=>({...e,type:"bigInteger",_visit:function(t){return Pn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e);case"long":return t.long(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"boolean":return t.boolean(e);case"string":return t.string(e);case"date":return t.date(e);case"dateTime":return t.dateTime(e);case"uuid":return t.uuid(e);case"base64":return t.base64(e);case"bigInteger":return t.bigInteger(e);default:return t._other(e)}}};var uz={string:e=>({string:e,type:"string",_visit:function(t){return uz._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return uz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"string":return t.string(e.string);case"boolean":return t.boolean(e.boolean);default:return t._other(e)}}};var Ih={alias:e=>({...e,type:"alias",_visit:function(t){return Ih._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Ih._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Ih._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Ih._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Ih._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var jB={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return jB._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return jB._visit(this,t)}}),noProperties:()=>({type:"noProperties",_visit:function(e){return jB._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var lu={primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return lu._visit(this,t)}}),container:e=>({container:e,type:"container",_visit:function(t){return lu._visit(this,t)}}),unknown:e=>({unknown:e,type:"unknown",_visit:function(t){return lu._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return lu._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.primitive);case"container":return t.container(e.container);case"unknown":return t.unknown(e.unknown);case"named":return t.named(e);default:return t._other(e)}}};var op={list:e=>({...e,type:"list",_visit:function(t){return op._visit(this,t)}}),set:e=>({...e,type:"set",_visit:function(t){return op._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return op._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return op._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return op._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return op._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e);case"set":return t.set(e);case"optional":return t.optional(e);case"nullable":return t.nullable(e);case"map":return t.map(e);case"literal":return t.literal(e);default:return t._other(e)}}};var Dn={integer:e=>({integer:e,type:"integer",_visit:function(t){return Dn._visit(this,t)}}),long:e=>({long:e,type:"long",_visit:function(t){return Dn._visit(this,t)}}),uint:e=>({uint:e,type:"uint",_visit:function(t){return Dn._visit(this,t)}}),uint64:e=>({uint64:e,type:"uint64",_visit:function(t){return Dn._visit(this,t)}}),float:e=>({float:e,type:"float",_visit:function(t){return Dn._visit(this,t)}}),double:e=>({double:e,type:"double",_visit:function(t){return Dn._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return Dn._visit(this,t)}}),string:e=>({string:e,type:"string",_visit:function(t){return Dn._visit(this,t)}}),date:e=>({date:e,type:"date",_visit:function(t){return Dn._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Dn._visit(this,t)}}),uuid:e=>({uuid:e,type:"uuid",_visit:function(t){return Dn._visit(this,t)}}),base64:e=>({base64:e,type:"base64",_visit:function(t){return Dn._visit(this,t)}}),bigInteger:e=>({bigInteger:e,type:"bigInteger",_visit:function(t){return Dn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e.integer);case"long":return t.long(e.long);case"uint":return t.uint(e.uint);case"uint64":return t.uint64(e.uint64);case"float":return t.float(e.float);case"double":return t.double(e.double);case"boolean":return t.boolean(e.boolean);case"string":return t.string(e.string);case"date":return t.date(e.date);case"datetime":return t.datetime(e);case"uuid":return t.uuid(e.uuid);case"base64":return t.base64(e.base64);case"bigInteger":return t.bigInteger(e.bigInteger);default:return t._other(e)}}};var fu_={};var unc={};Kt(unc,{WebhookHttpMethod:()=>MIo,WebhookPayload:()=>WQ});var WQ={inlinedPayload:e=>({...e,type:"inlinedPayload",_visit:function(t){return WQ._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return WQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedPayload":return t.inlinedPayload(e);case"reference":return t.reference(e);default:return t._other(e)}}};var MIo={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case MIo.Get:return t.get();case MIo.Post:return t.post();default:return t._other()}}};var snc={};Kt(snc,{ExampleWebSocketMessageBody:()=>ghe,WebSocketMessageBody:()=>sz,WebSocketMessageOrigin:()=>DIo});var DIo={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case DIo.Client:return t.client();case DIo.Server:return t.server();default:return t._other()}}};var sz={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return sz._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return sz._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var ghe={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return ghe._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ghe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var zn={};Kt(zn,{AliasTypeDeclaration:()=>UTo,ApiAuth:()=>kIo,ApiDefinitionSource:()=>TRo,ApiDefinitionSourceId:()=>CRo,ApiVersionScheme:()=>vTo,AudienceDefinition:()=>TIo,AudienceReference:()=>WNn,AuthScheme:()=>ZIo,AuthSchemeKey:()=>xNn,AuthSchemesRequirement:()=>zIo,AuthScope:()=>RIo,AutogeneratedEndpointExample:()=>iTo,Availability:()=>k9t,AvailabilityStatus:()=>UIo,Base64Type:()=>zTo,BaseAuthScheme:()=>S0e,BasicAuthScheme:()=>FIo,BasicAuthValues:()=>wqo,BearerAuthScheme:()=>NIo,BearerAuthValues:()=>Eqo,BigIntegerType:()=>NTo,BooleanType:()=>BTo,BytesRequest:()=>pFn,BytesResponse:()=>vFn,Constants:()=>rCo,ContainerType:()=>BFn,CratesPublishTarget:()=>URo,CsharpProtobufFileOptions:()=>nTo,CursorPagination:()=>L1o,CustomPagination:()=>W1o,DateTimeType:()=>TTo,DateType:()=>qTo,Declaration:()=>TC,DeclaredErrorName:()=>hCi,DeclaredServiceName:()=>f1o,DeclaredTypeName:()=>Nj,DirectPublish:()=>VRo,DisplayName:()=>cCi,DoubleType:()=>DTo,DoubleValidationRules:()=>MTo,Encoding:()=>SFn,EndpointId:()=>Uvi,EndpointName:()=>p1o,EndpointReference:()=>aCi,EnumTypeDeclaration:()=>MFn,EnumTypeReference:()=>Gu_,EnumValue:()=>Lvi,EnvironmentBaseUrlId:()=>Ohe,EnvironmentBaseUrlWithId:()=>hqo,EnvironmentId:()=>rGt,EnvironmentUrl:()=>_Ci,EnvironmentVariable:()=>E0e,Environments:()=>vqo,EnvironmentsConfig:()=>gqo,ErrorDeclaration:()=>Aqo,ErrorDeclarationDiscriminantValue:()=>Vu_,ErrorDiscriminationByPropertyStrategy:()=>mRo,ErrorDiscriminationStrategy:()=>PRo,ErrorId:()=>lCi,EscapedString:()=>eCo,ExampleAliasType:()=>XRo,ExampleCodeSample:()=>K1o,ExampleCodeSampleLanguage:()=>G1o,ExampleCodeSampleSdk:()=>H1o,ExampleContainer:()=>uzo,ExampleDatetime:()=>ozo,ExampleEndpointCall:()=>jFn,ExampleEndpointErrorResponse:()=>eTo,ExampleEndpointSuccessResponse:()=>k1o,ExampleEnumType:()=>YRo,ExampleError:()=>Oqo,ExampleExtraObjectProperty:()=>ezo,ExampleHeader:()=>QKi,ExampleInlinedRequestBody:()=>PFn,ExampleInlinedRequestBodyExtraProperty:()=>Y1o,ExampleInlinedRequestBodyProperty:()=>$1o,ExampleKeyValuePair:()=>hzo,ExampleListContainer:()=>lzo,ExampleLiteralContainer:()=>czo,ExampleMapContainer:()=>_zo,ExampleNamedType:()=>szo,ExampleNullableContainer:()=>pzo,ExampleObjectProperty:()=>RFn,ExampleObjectType:()=>TFn,ExampleObjectTypeWithTypeId:()=>nzo,ExampleOptionalContainer:()=>dzo,ExamplePathParameter:()=>yCi,ExamplePrimitive:()=>zFn,ExampleQueryParameter:()=>mFn,ExampleQueryParameterShape:()=>J1o,ExampleRequestBody:()=>X1o,ExampleResponse:()=>tTo,ExampleServerSideEvent:()=>Z1o,ExampleSetContainer:()=>fzo,ExampleSingleUnionType:()=>rzo,ExampleSingleUnionTypeProperties:()=>izo,ExampleStyle:()=>BRo,ExampleType:()=>nPa,ExampleTypeReference:()=>xl,ExampleTypeReferenceShape:()=>azo,ExampleTypeShape:()=>IFn,ExampleUndiscriminatedUnionType:()=>kRo,ExampleUnionBaseProperty:()=>tzo,ExampleUnionType:()=>ZRo,ExampleWebSocketMessage:()=>bRo,ExampleWebSocketMessageBody:()=>yRo,ExampleWebSocketSession:()=>vRo,ExampleWebhookCall:()=>oRo,FeatureId:()=>ePa,FernFilepath:()=>M0e,FileDownloadResponse:()=>yFn,FileProperty:()=>g1o,FilePropertyArray:()=>v1o,FilePropertySingle:()=>b1o,FileUploadBodyProperty:()=>A1o,FileUploadBodyPropertyEncoding:()=>O1o,FileUploadRequest:()=>P1o,FileUploadRequestProperty:()=>m1o,Filesystem:()=>WRo,FloatType:()=>STo,GenerationMetadata:()=>GRo,GithubPublish:()=>LRo,GrpcTransport:()=>uTo,HeaderApiVersionScheme:()=>bTo,HeaderAuthScheme:()=>QIo,HeaderAuthValues:()=>Sqo,HttpEndpoint:()=>pTo,HttpEndpointSecurityItem:()=>U1o,HttpEndpointSource:()=>lTo,HttpHeader:()=>bx,HttpMethod:()=>_1o,HttpPath:()=>B0e,HttpPathPart:()=>d1o,HttpRequestBody:()=>_Fn,HttpRequestBodyReference:()=>dFn,HttpResponse:()=>OFn,HttpResponseBody:()=>z1o,HttpService:()=>yTo,InferredAuthScheme:()=>XIo,InferredAuthSchemeTokenEndpoint:()=>YIo,InferredAuthenticatedRequestHeader:()=>$Io,InlinedRequestBody:()=>y1o,InlinedRequestBodyProperty:()=>fFn,InlinedWebSocketMessageBody:()=>dRo,InlinedWebSocketMessageBodyProperty:()=>fRo,InlinedWebhookPayload:()=>iRo,InlinedWebhookPayloadProperty:()=>rRo,IntegerType:()=>PTo,IntegerValidationRules:()=>mTo,IntermediateRepresentation:()=>xu_,JsonEncoding:()=>_To,JsonResponse:()=>hFn,JsonResponseBody:()=>D1o,JsonResponseBodyWithProperty:()=>B1o,JsonStreamChunk:()=>I1o,Literal:()=>JRo,LongType:()=>jTo,MapType:()=>$Ro,MavenPublishTarget:()=>FRo,MultipleBaseUrlsEnvironment:()=>yqo,MultipleBaseUrlsEnvironments:()=>bqo,MultipleEnvironmentUrlValues:()=>jqo,Name:()=>Oa,NameAndWireValue:()=>Ec,NamedType:()=>KRo,NamedTypeDefault:()=>HRo,NonStreamHttpResponseBody:()=>T1o,NpmPublishTarget:()=>NRo,OAuthAccessTokenRequestProperties:()=>VIo,OAuthAccessTokenResponseProperties:()=>HNn,OAuthClientCredentials:()=>HIo,OAuthConfiguration:()=>KIo,OAuthRefreshEndpoint:()=>GIo,OAuthRefreshTokenRequestProperties:()=>xIo,OAuthScheme:()=>JIo,OAuthTokenEndpoint:()=>WIo,OAuthValues:()=>Mqo,ObjectProperty:()=>yx,ObjectPropertyAccess:()=>uCi,ObjectTypeDeclaration:()=>LTo,OffsetPagination:()=>V1o,Package:()=>qFn,PackageNavigationConfig:()=>ORo,Pagination:()=>x1o,PathParameter:()=>uFt,PathParameterLocation:()=>h1o,PlatformHeaders:()=>wRo,PostmanPublishTarget:()=>zRo,PrimitiveType:()=>DFn,PrimitiveTypeV1:()=>ATo,PrimitiveTypeV2:()=>FTo,PropertyPathItem:()=>GNn,ProtoEncoding:()=>hTo,ProtoSource:()=>qRo,ProtoSourceInfo:()=>cTo,ProtobufFile:()=>wFn,ProtobufFileOptions:()=>aTo,ProtobufMethodType:()=>sTo,ProtobufService:()=>oTo,ProtobufType:()=>XTo,PublishTarget:()=>bCi,PublishingConfig:()=>xRo,PypiPublishTarget:()=>QRo,QueryParameter:()=>oCi,ReadmeConfig:()=>IRo,ReadmeCustomSection:()=>DRo,RequestProperty:()=>NL,RequestPropertyValue:()=>LIo,ResolvedNamedType:()=>OTo,ResolvedTypeReference:()=>QTo,ResponseError:()=>F1o,ResponseErrors:()=>Q1o,ResponseProperty:()=>fz,RetriesConfiguration:()=>dTo,RetriesDisabledSchema:()=>fTo,SafeAndUnsafeString:()=>NKi,SdkConfig:()=>ERo,SdkRequest:()=>M1o,SdkRequestBodyType:()=>w1o,SdkRequestShape:()=>S1o,SdkRequestWrapper:()=>E1o,ServiceId:()=>X9t,ServiceTypeReferenceInfo:()=>MRo,ShapeType:()=>gTo,SingleBaseUrlEnvironment:()=>pqo,SingleBaseUrlEnvironments:()=>_qo,SingleUnionType:()=>xTo,SingleUnionTypeProperties:()=>WTo,SingleUnionTypeProperty:()=>VTo,Source:()=>ZTo,SourceConfig:()=>RRo,SseStreamChunk:()=>q1o,StreamParameterResponse:()=>R1o,StreamingResponse:()=>gFn,StringType:()=>CTo,StringValidationRules:()=>ITo,Subpackage:()=>ARo,SubpackageId:()=>Z9t,SupportedSdkLanguage:()=>AFn,TextResponse:()=>bFn,TextStreamChunk:()=>C1o,Transport:()=>EFn,Type:()=>JTo,TypeDeclaration:()=>kTo,TypeId:()=>xQ,TypeReference:()=>ts,Uint64Type:()=>ETo,UintType:()=>wTo,UndiscriminatedUnionMember:()=>HTo,UndiscriminatedUnionTypeDeclaration:()=>KTo,UnionTypeDeclaration:()=>GTo,UserAgent:()=>jRo,UserDefinedProtobufType:()=>YTo,UserSpecifiedEndpointExample:()=>rTo,UuidType:()=>RTo,V2AuthValues:()=>eFn,V2EndpointLocation:()=>Pqo,V2EndpointLocationHttpMethod:()=>mqo,V2EnvironmentValues:()=>kNn,V2HttpEndpointCodeSample:()=>Cqo,V2HttpEndpointExample:()=>tPa,V2HttpEndpointExamples:()=>qqo,V2HttpEndpointRequest:()=>Dqo,V2HttpEndpointResponse:()=>Iqo,V2HttpEndpointResponseBody:()=>Bqo,V2HttpRequestBodies:()=>j1o,V2HttpResponses:()=>N1o,V2SchemaExample:()=>k0a,V2SchemaExamples:()=>lz,V2ValueExamples:()=>iGt,V2WebSocketEndpointLocation:()=>Tqo,V2WebSocketMessageExample:()=>Rqo,V2WebSocketSessionExample:()=>rPa,V2WebSocketSessionExamples:()=>zqo,V2WebhookExample:()=>iPa,V2WebhookExamples:()=>Nqo,VariableDeclaration:()=>SRo,VariableId:()=>lFn,WebSocketChannel:()=>gRo,WebSocketChannelId:()=>JNn,WebSocketMessage:()=>hRo,WebSocketMessageBody:()=>_Ro,WebSocketMessageBodyReference:()=>pRo,WebSocketMessageId:()=>CFn,WebSocketMessageOrigin:()=>lRo,WebSocketName:()=>cRo,Webhook:()=>uRo,WebhookGroup:()=>sRo,WebhookGroupId:()=>KNn,WebhookHttpMethod:()=>tRo,WebhookId:()=>tCo,WebhookName:()=>eRo,WebhookPayload:()=>aRo,WebhookPayloadReference:()=>nRo,WellKnownProtobufType:()=>$To,WithContentType:()=>D0e,WithDocs:()=>Un,WithDocsAndAvailability:()=>sCi,WithJsonExample:()=>eGt,WithV2Examples:()=>zj,audience:()=>pnc,auth:()=>_nc,commons:()=>hnc,constants:()=>ync,dynamic:()=>XE,environment:()=>Snc,errors:()=>Mnc,examples:()=>Dnc,generatorExec:()=>Inc,http:()=>Cnc,ir:()=>qnc,proto:()=>Tnc,publish:()=>Rnc,types:()=>znc,variables:()=>Nnc,webhooks:()=>Fnc,websocket:()=>Qnc});var pnc={};Kt(pnc,{AudienceDefinition:()=>TIo,AudienceReference:()=>WNn});var S={};Kt(S,{JsonError:()=>UNn,ParseError:()=>LNn,any:()=>Eu_,bigint:()=>pu_,boolean:()=>Su_,booleanLiteral:()=>wu_,date:()=>_u_,discriminant:()=>zu_,enum_:()=>IIo,getObjectLikeUtils:()=>oFt,getObjectUtils:()=>zKi,getSchemaUtils:()=>$m,isProperty:()=>nCi,lazy:()=>hu_,lazyObject:()=>mu_,list:()=>qIo,number:()=>Mu_,object:()=>CIo,objectWithoutOptionalProperties:()=>Au_,optional:()=>cnc,property:()=>bu_,record:()=>Cu_,set:()=>qu_,string:()=>Du_,stringLiteral:()=>ju_,transform:()=>lnc,undiscriminatedUnion:()=>Ru_,union:()=>Fu_,unknown:()=>Bu_,withParsedProperties:()=>dnc});var ih={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 SA(e,t){return`Expected ${t}. Received ${Z$S(e)}.`}function Z$S(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 cz(e){return{...e,json:du_(e.json),parse:du_(e.parse)}}function du_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1356
1356
  `)),{ok:!0,value:t}):i}}function BIo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var UNn=class e extends Error{errors;constructor(t){super(t.map(BIo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var LNn=class e extends Error{errors;constructor(t){super(t.map(BIo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function $m(e){return{optional:()=>cnc(e),transform:t=>lnc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new LNn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new UNn(i.errors)}}}function cnc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>ih.OPTIONAL};return{...t,...$m(t)}}function lnc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...$m(r)}}function pu_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:SA(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:SA(t,"bigint")}]},getType:()=>ih.BIGINT};return{...cz(e),...$m(e)}}var k$S=/^([+-]?\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 _u_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:SA(t,"string")}]}:k$S.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:SA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:SA(t,"Date object")}]},getType:()=>ih.DATE};return{...cz(e),...$m(e)}}function zL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...cz(r),...$m(r)}}}function IIo(e){let t=new Set(e);return zL(ih.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:SA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:SA(i,"enum")}]}:{ok:!0,value:i})()}function hu_(e){let t=fnc(e);return{...t,...$m(t)}}function fnc(e){return{parse:(t,r)=>VNn(e).parse(t,r),json:(t,r)=>VNn(e).json(t,r),getType:()=>VNn(e).getType()}}function VNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Y0a(e){return Object.entries(e)}function X0a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function iCi(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 Z0a(e){return Object.keys(e)}function yu_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function oFt(e){return{withParsedProperties:t=>dnc(e,t)}}function dnc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!iCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:SA(i,"object")}]};let a=new Set(Object.keys(t)),o=X0a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...$m(r),...oFt(r)}}function bu_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function nCi(e){return e.isProperty}function CIo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>nCi(i)?i.rawKey:r),_getParsedProperties:()=>Z0a(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of Y0a(e)){let f=nCi(c)?c.rawKey:o,s=nCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Ou_(s)&&a.push(f)}return vu_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of Y0a(e)){let c=nCi(o)?o.valueSchema:o;Ou_(c)&&n.push(a)}return vu_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return nCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>ih.OBJECT};return{...cz(t),...$m(t),...oFt(t),...zKi(t)}}function vu_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!iCi(e))return{ok:!1,errors:[{path:a,message:SA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function zKi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>gu_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>gu_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>ih.OBJECT};return{...r,...$m(r),...oFt(r),...zKi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>ih.OBJECT};return{...t,...$m(t),...oFt(t),...zKi(t)}}}}function gu_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=yu_(Z0a(t),s=>n.has(s)),c=r(X0a(t,o)),f=i(X0a(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function Ou_(e){return!eYS(e)}function eYS(e){switch(e.getType()){case ih.ANY:case ih.UNKNOWN:case ih.OPTIONAL:return!0;default:return!1}}function Au_(e){return CIo(e)}function mu_(e){let t={...fnc(e),_getRawProperties:()=>VNn(e)._getRawProperties(),_getParsedProperties:()=>VNn(e)._getParsedProperties()};return{...t,...$m(t),...oFt(t),...zKi(t)}}function qIo(e){let t={parse:(r,i)=>Pu_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Pu_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ih.LIST};return{...cz(t),...$m(t)}}function Pu_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:SA(e,"list"),path:[]}]}}function ju_(e){return zL(ih.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:SA(r,`"${e}"`)}]})()}function wu_(e){return zL(ih.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:SA(r,`${e.toString()}`)}]})()}var Eu_=zL(ih.ANY,e=>({ok:!0,value:e}));var Su_=zL(ih.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"boolean")}]});var Mu_=zL(ih.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"number")}]});var Du_=zL(ih.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:SA(e,"string")}]});var Bu_=zL(ih.UNKNOWN,e=>({ok:!0,value:e}));function Cu_(e,t){let r={parse:(i,n)=>Iu_({value:i,isKeyNumeric:e.getType()===ih.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Iu_({value:i,isKeyNumeric:e.getType()===ih.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>ih.RECORD};return{...cz(r),...$m(r)}}function Iu_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return iCi(e)?Y0a(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:SA(e,"object")}]}}function qu_(e){let t=qIo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:SA(i,"Set")}]},getType:()=>ih.SET};return{...cz(r),...$m(r)}}function Ru_(e){let t={parse:(r,i)=>Tu_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Tu_((n,a)=>n.json(r,a),e,i),getType:()=>ih.UNDISCRIMINATED_UNION};return{...cz(t),...$m(t)}}function Tu_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function zu_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fu_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=IIo(Z0a(t)),a={parse:(o,c)=>Nu_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>Nu_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>ih.UNION};return{...cz(a),...$m(a),...oFt(a)}}function Nu_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!iCi(e))return{ok:!1,errors:[{path:c,message:SA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(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 p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var TIo=S.string();var WNn=S.string();var _nc={};Kt(_nc,{ApiAuth:()=>kIo,AuthScheme:()=>ZIo,AuthSchemeKey:()=>xNn,AuthSchemesRequirement:()=>zIo,AuthScope:()=>RIo,BaseAuthScheme:()=>S0e,BasicAuthScheme:()=>FIo,BearerAuthScheme:()=>NIo,EnvironmentVariable:()=>E0e,HeaderAuthScheme:()=>QIo,InferredAuthScheme:()=>XIo,InferredAuthSchemeTokenEndpoint:()=>YIo,InferredAuthenticatedRequestHeader:()=>$Io,OAuthAccessTokenRequestProperties:()=>VIo,OAuthAccessTokenResponseProperties:()=>HNn,OAuthClientCredentials:()=>HIo,OAuthConfiguration:()=>KIo,OAuthRefreshEndpoint:()=>GIo,OAuthRefreshTokenRequestProperties:()=>xIo,OAuthScheme:()=>JIo,OAuthTokenEndpoint:()=>WIo});var E0e=S.string();var xNn=S.string();var RIo=S.string();var zIo=S.enum_(["ALL","ANY"]);var NKi=S.objectWithoutOptionalProperties({unsafeName:S.string(),safeName:S.string()});var Oa=S.objectWithoutOptionalProperties({originalName:S.string(),camelCase:NKi,pascalCase:NKi,snakeCase:NKi,screamingSnakeCase:NKi});var Un=S.objectWithoutOptionalProperties({docs:S.string().optional()});var S0e=S.objectWithoutOptionalProperties({key:xNn}).extend(Un);var NIo=S.objectWithoutOptionalProperties({token:Oa,tokenEnvVar:E0e.optional()}).extend(S0e);var FIo=S.objectWithoutOptionalProperties({username:Oa,usernameEnvVar:E0e.optional(),password:Oa,passwordEnvVar:E0e.optional()}).extend(S0e);var Ec=S.objectWithoutOptionalProperties({wireValue:S.string(),name:Oa});var QIo=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts),prefix:S.string().optional(),headerEnvVar:E0e.optional()}).extend(S0e);var Uvi=S.string();var X9t=S.string();var Z9t=S.string();var aCi=S.objectWithoutOptionalProperties({endpointId:Uvi,serviceId:X9t,subpackageId:Z9t.optional()});var GNn=S.objectWithoutOptionalProperties({name:Oa,type:S.lazy(()=>ts)});var k0a=S.unknown();var lz=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),k0a),autogeneratedExamples:S.record(S.string(),k0a)});var UIo=S.enum_(["IN_DEVELOPMENT","PRE_RELEASE","GENERAL_AVAILABILITY","DEPRECATED"]);var k9t=S.objectWithoutOptionalProperties({status:UIo,message:S.string().optional()});var TC=S.objectWithoutOptionalProperties({availability:k9t.optional()}).extend(Un);var oCi=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts),allowMultiple:S.boolean(),v2Examples:lz.optional()}).extend(TC);var uCi=S.enum_(["READ_ONLY","WRITE_ONLY"]);var yx=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts),propertyAccess:uCi.optional(),v2Examples:lz.optional()}).extend(TC);var LIo=S.union("type",{query:oCi,body:yx}).transform({transform:e=>{switch(e.type){case"query":return Z6.query(e);case"body":return Z6.body(e);default:return e}},untransform:({_visit:e,...t})=>t});var NL=S.objectWithoutOptionalProperties({propertyPath:S.list(GNn).optional(),property:LIo});var VIo=S.objectWithoutOptionalProperties({clientId:NL,clientSecret:NL,scopes:NL.optional(),customProperties:S.list(NL).optional()});var fz=S.objectWithoutOptionalProperties({propertyPath:S.list(GNn).optional(),property:yx});var HNn=S.objectWithoutOptionalProperties({accessToken:fz,expiresIn:fz.optional(),refreshToken:fz.optional()});var WIo=S.objectWithoutOptionalProperties({endpointReference:aCi,requestProperties:VIo,responseProperties:HNn});var xIo=S.objectWithoutOptionalProperties({refreshToken:NL});var GIo=S.objectWithoutOptionalProperties({endpointReference:aCi,requestProperties:xIo,responseProperties:HNn});var HIo=S.objectWithoutOptionalProperties({clientIdEnvVar:E0e.optional(),clientSecretEnvVar:E0e.optional(),tokenPrefix:S.string().optional(),tokenHeader:S.string().optional(),scopes:S.list(S.string()).optional(),tokenEndpoint:WIo,refreshEndpoint:GIo.optional()});var KIo=S.union("type",{clientCredentials:HIo}).transform({transform:e=>{switch(e.type){case"clientCredentials":return kIi.clientCredentials(e);default:return e}},untransform:({_visit:e,...t})=>t});var JIo=S.objectWithoutOptionalProperties({configuration:KIo}).extend(S0e);var $Io=S.objectWithoutOptionalProperties({responseProperty:fz,headerName:S.string(),valuePrefix:S.string().optional()});var YIo=S.objectWithoutOptionalProperties({endpoint:aCi,expiryProperty:fz.optional(),authenticatedRequestHeaders:S.list($Io)});var XIo=S.objectWithoutOptionalProperties({tokenEndpoint:YIo}).extend(S0e);var ZIo=S.union(S.discriminant("type","_type"),{bearer:NIo,basic:FIo,header:QIo,oauth:JIo,inferred:XIo}).transform({transform:e=>{switch(e.type){case"bearer":return EA.bearer(e);case"basic":return EA.basic(e);case"header":return EA.header(e);case"oauth":return EA.oauth(e);case"inferred":return EA.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var kIo=S.objectWithoutOptionalProperties({requirement:zIo,schemes:S.list(ZIo)}).extend(Un);var hnc={};Kt(hnc,{Availability:()=>k9t,AvailabilityStatus:()=>UIo,Declaration:()=>TC,DisplayName:()=>cCi,EndpointId:()=>Uvi,EndpointReference:()=>aCi,ErrorId:()=>lCi,EscapedString:()=>eCo,FeatureId:()=>ePa,FernFilepath:()=>M0e,Name:()=>Oa,NameAndWireValue:()=>Ec,SafeAndUnsafeString:()=>NKi,ServiceId:()=>X9t,SubpackageId:()=>Z9t,TypeId:()=>xQ,WebSocketChannelId:()=>JNn,WebhookGroupId:()=>KNn,WebhookId:()=>tCo,WithContentType:()=>D0e,WithDocs:()=>Un,WithDocsAndAvailability:()=>sCi,WithJsonExample:()=>eGt});var sCi=S.objectWithoutOptionalProperties({availability:k9t.optional()}).extend(Un);var M0e=S.objectWithoutOptionalProperties({allParts:S.list(Oa),packagePath:S.list(Oa),file:Oa.optional()});var cCi=S.string();var eCo=S.objectWithoutOptionalProperties({original:S.string()});var eGt=S.objectWithoutOptionalProperties({jsonExample:S.unknown()});var D0e=S.objectWithoutOptionalProperties({contentType:S.string().optional()});var xQ=S.string();var lCi=S.string();var KNn=S.string();var tCo=S.string();var JNn=S.string();var ePa=S.string();var ync={};Kt(ync,{Constants:()=>rCo});var rCo=S.objectWithoutOptionalProperties({errorInstanceIdKey:Ec});var XE={};Kt(XE,{AliasType:()=>UCo,Auth:()=>cCo,AuthValues:()=>hCo,BasicAuth:()=>iCo,BasicAuthValues:()=>lCo,BearerAuth:()=>nCo,BearerAuthValues:()=>fCo,BodyRequest:()=>gCo,CratesPublishInfo:()=>nqo,Declaration:()=>FL,DiscriminatedUnionType:()=>KCo,DynamicIntermediateRepresentation:()=>sqo,Endpoint:()=>CCo,EndpointExample:()=>ICo,EndpointId:()=>bCo,EndpointLocation:()=>YNn,EndpointSnippetRequest:()=>BCo,EndpointSnippetResponse:()=>Qu_,EnumType:()=>LCo,EnvironmentBaseUrlId:()=>dCi,EnvironmentBaseUrlWithId:()=>RCo,EnvironmentId:()=>tGt,EnvironmentUrl:()=>pCi,EnvironmentValues:()=>DCo,Environments:()=>FCo,EnvironmentsConfig:()=>QCo,ErrorSeverity:()=>cqo,Error_:()=>lqo,FernFilepath:()=>yCo,FileUploadRequestBody:()=>mCo,FileUploadRequestBodyProperty:()=>ACo,GeneratorConfig:()=>uqo,GeneratorOutputConfig:()=>oqo,GoPublishInfo:()=>XCo,HeaderAuth:()=>oCo,HeaderAuthValues:()=>dCo,HttpMethod:()=>vCo,InferredAuth:()=>sCo,InferredAuthValues:()=>_Co,InlinedRequest:()=>wCo,InlinedRequestBody:()=>PCo,InlinedRequestMetadata:()=>jCo,LiteralType:()=>fqo,MapType:()=>Lu_,MavenPublishInfo:()=>kCo,MultipleBaseUrlsEnvironment:()=>zCo,MultipleBaseUrlsEnvironments:()=>NCo,MultipleEnvironmentUrlValues:()=>MCo,Name:()=>Rj,NameAndWireValue:()=>GQ,NamedParameter:()=>Zw,NamedType:()=>$Co,NpmPublishInfo:()=>eqo,NugetPublishInfo:()=>tqo,OAuth:()=>uCo,OAuthValues:()=>pCo,ObjectPropertyAccess:()=>aCo,ObjectType:()=>VCo,PrimitiveTypeV1:()=>dqo,PublishInfo:()=>aqo,PypiPublishInfo:()=>rqo,ReferencedRequestBody:()=>OCo,ReferencedRequestBodyType:()=>XNn,Request:()=>ECo,Response:()=>SCo,RubyGemsPublishInfo:()=>iqo,SafeAndUnsafeString:()=>FKi,SingleBaseUrlEnvironment:()=>qCo,SingleBaseUrlEnvironments:()=>TCo,SingleDiscriminatedUnionType:()=>HCo,SingleDiscriminatedUnionTypeNoProperties:()=>GCo,SingleDiscriminatedUnionTypeObject:()=>WCo,SingleDiscriminatedUnionTypeSingleProperty:()=>xCo,SwiftPublishInfo:()=>ZCo,TypeId:()=>fCi,TypeReference:()=>Uu_,UndiscriminatedUnionType:()=>JCo,Values:()=>ZNn,VariableDeclaration:()=>YCo,WithDocs:()=>$Nn,auth:()=>bnc,commons:()=>vnc,declaration:()=>gnc,endpoints:()=>Onc,environment:()=>Anc,http:()=>mnc,ir:()=>Pnc,snippets:()=>jnc,types:()=>wnc,variables:()=>Enc});var bnc={};Kt(bnc,{Auth:()=>cCo,AuthValues:()=>hCo,BasicAuth:()=>iCo,BasicAuthValues:()=>lCo,BearerAuth:()=>nCo,BearerAuthValues:()=>fCo,HeaderAuth:()=>oCo,HeaderAuthValues:()=>dCo,InferredAuth:()=>sCo,InferredAuthValues:()=>_Co,OAuth:()=>uCo,OAuthValues:()=>pCo});var FKi=S.objectWithoutOptionalProperties({unsafeName:S.string(),safeName:S.string()});var Rj=S.objectWithoutOptionalProperties({originalName:S.string(),camelCase:FKi,pascalCase:FKi,snakeCase:FKi,screamingSnakeCase:FKi});var iCo=S.objectWithoutOptionalProperties({username:Rj,password:Rj});var nCo=S.objectWithoutOptionalProperties({token:Rj});var GQ=S.objectWithoutOptionalProperties({wireValue:S.string(),name:Rj});var aCo=S.enum_(["READ_ONLY","WRITE_ONLY"]);var Zw=S.objectWithoutOptionalProperties({name:GQ,typeReference:S.lazy(()=>XE.TypeReference),propertyAccess:aCo.optional(),variable:S.string().optional()});var oCo=S.objectWithoutOptionalProperties({header:Zw});var uCo=S.objectWithoutOptionalProperties({clientId:Rj,clientSecret:Rj});var sCo=S.objectWithoutOptionalProperties({});var cCo=S.union("type",{basic:iCo,bearer:nCo,header:oCo,oauth:uCo,inferred:sCo}).transform({transform:e=>{switch(e.type){case"basic":return Gt.Auth.basic(e);case"bearer":return Gt.Auth.bearer(e);case"header":return Gt.Auth.header(e);case"oauth":return Gt.Auth.oauth(e);case"inferred":return Gt.Auth.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var lCo=S.objectWithoutOptionalProperties({username:S.string(),password:S.string()});var fCo=S.objectWithoutOptionalProperties({token:S.string()});var dCo=S.objectWithoutOptionalProperties({value:S.unknown()});var pCo=S.objectWithoutOptionalProperties({clientId:S.string(),clientSecret:S.string()});var _Co=S.objectWithoutOptionalProperties({});var hCo=S.union("type",{basic:lCo,bearer:fCo,header:dCo,oauth:pCo,inferred:_Co}).transform({transform:e=>{switch(e.type){case"basic":return Gt.AuthValues.basic(e);case"bearer":return Gt.AuthValues.bearer(e);case"header":return Gt.AuthValues.header(e);case"oauth":return Gt.AuthValues.oauth(e);case"inferred":return Gt.AuthValues.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var vnc={};Kt(vnc,{EndpointId:()=>bCo,FernFilepath:()=>yCo,Name:()=>Rj,NameAndWireValue:()=>GQ,SafeAndUnsafeString:()=>FKi,TypeId:()=>fCi,WithDocs:()=>$Nn});var $Nn=S.objectWithoutOptionalProperties({docs:S.string().optional()});var yCo=S.objectWithoutOptionalProperties({allParts:S.list(Rj),packagePath:S.list(Rj),file:Rj.optional()});var bCo=S.string();var fCi=S.string();var gnc={};Kt(gnc,{Declaration:()=>FL});var FL=S.objectWithoutOptionalProperties({fernFilepath:yCo,name:Rj});var Onc={};Kt(Onc,{BodyRequest:()=>gCo,Endpoint:()=>CCo,EndpointExample:()=>ICo,EndpointLocation:()=>YNn,FileUploadRequestBody:()=>mCo,FileUploadRequestBodyProperty:()=>ACo,InlinedRequest:()=>wCo,InlinedRequestBody:()=>PCo,InlinedRequestMetadata:()=>jCo,ReferencedRequestBody:()=>OCo,ReferencedRequestBodyType:()=>XNn,Request:()=>ECo,Response:()=>SCo});var vCo=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var YNn=S.objectWithoutOptionalProperties({method:vCo,path:S.string()});var XNn=S.union("type",{bytes:S.object({}),typeReference:S.object({value:S.lazy(()=>XE.TypeReference)})}).transform({transform:e=>{switch(e.type){case"bytes":return Gt.ReferencedRequestBodyType.bytes();case"typeReference":return Gt.ReferencedRequestBodyType.typeReference(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var gCo=S.objectWithoutOptionalProperties({pathParameters:S.list(Zw).optional(),body:XNn.optional()});var OCo=S.objectWithoutOptionalProperties({bodyKey:Rj,bodyType:XNn});var ACo=S.union("type",{file:GQ,fileArray:GQ,bodyProperty:Zw}).transform({transform:e=>{switch(e.type){case"file":return Gt.FileUploadRequestBodyProperty.file(e);case"fileArray":return Gt.FileUploadRequestBodyProperty.fileArray(e);case"bodyProperty":return Gt.FileUploadRequestBodyProperty.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var mCo=S.objectWithoutOptionalProperties({properties:S.list(ACo)});var PCo=S.union("type",{properties:S.object({value:S.list(Zw)}),referenced:OCo,fileUpload:mCo}).transform({transform:e=>{switch(e.type){case"properties":return Gt.InlinedRequestBody.properties(e.value);case"referenced":return Gt.InlinedRequestBody.referenced(e);case"fileUpload":return Gt.InlinedRequestBody.fileUpload(e);default:return e}},untransform:({_visit:e,...t})=>t});var jCo=S.objectWithoutOptionalProperties({includePathParameters:S.boolean(),onlyPathParameters:S.boolean()});var wCo=S.objectWithoutOptionalProperties({declaration:FL,pathParameters:S.list(Zw).optional(),queryParameters:S.list(Zw).optional(),headers:S.list(Zw).optional(),body:PCo.optional(),metadata:jCo.optional()});var ECo=S.union("type",{body:gCo,inlined:wCo}).transform({transform:e=>{switch(e.type){case"body":return Gt.Request.body(e);case"inlined":return Gt.Request.inlined(e);default:return e}},untransform:({_visit:e,...t})=>t});var SCo=S.union("type",{json:S.object({}),streaming:S.object({}),streamParameter:S.object({}),fileDownload:S.object({}),text:S.object({}),bytes:S.object({})}).transform({transform:e=>{switch(e.type){case"json":return Gt.Response.json();case"streaming":return Gt.Response.streaming();case"streamParameter":return Gt.Response.streamParameter();case"fileDownload":return Gt.Response.fileDownload();case"text":return Gt.Response.text();case"bytes":return Gt.Response.bytes();default:return e}},untransform:({_visit:e,...t})=>t});var tGt=S.string();var dCi=S.string();var pCi=S.string();var MCo=S.record(dCi,pCi);var DCo=S.undiscriminatedUnion([tGt,MCo]);var ZNn=S.record(S.string(),S.unknown());var BCo=S.objectWithoutOptionalProperties({endpoint:YNn,baseUrl:S.property("baseURL",S.string().optional()),environment:DCo.optional(),auth:hCo.optional(),pathParameters:ZNn.optional(),queryParameters:ZNn.optional(),headers:ZNn.optional(),requestBody:S.unknown().optional()});var ICo=S.objectWithoutOptionalProperties({id:S.string(),name:S.string().optional()}).extend(BCo);var CCo=S.objectWithoutOptionalProperties({auth:cCo.optional(),declaration:FL,location:YNn,request:ECo,response:SCo,examples:S.list(ICo).optional()});var Anc={};Kt(Anc,{EnvironmentBaseUrlId:()=>dCi,EnvironmentBaseUrlWithId:()=>RCo,EnvironmentId:()=>tGt,EnvironmentUrl:()=>pCi,EnvironmentValues:()=>DCo,Environments:()=>FCo,EnvironmentsConfig:()=>QCo,MultipleBaseUrlsEnvironment:()=>zCo,MultipleBaseUrlsEnvironments:()=>NCo,MultipleEnvironmentUrlValues:()=>MCo,SingleBaseUrlEnvironment:()=>qCo,SingleBaseUrlEnvironments:()=>TCo});var qCo=S.objectWithoutOptionalProperties({id:tGt,name:Rj,url:pCi}).extend($Nn);var TCo=S.objectWithoutOptionalProperties({environments:S.list(qCo)});var RCo=S.objectWithoutOptionalProperties({id:dCi,name:Rj});var zCo=S.objectWithoutOptionalProperties({id:tGt,name:Rj,urls:S.record(dCi,pCi)}).extend($Nn);var NCo=S.objectWithoutOptionalProperties({baseUrls:S.list(RCo),environments:S.list(zCo)});var FCo=S.union("type",{singleBaseUrl:TCo,multipleBaseUrls:NCo}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return Gt.Environments.singleBaseUrl(e);case"multipleBaseUrls":return Gt.Environments.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var QCo=S.objectWithoutOptionalProperties({defaultEnvironment:tGt.optional(),environments:FCo});var mnc={};Kt(mnc,{HttpMethod:()=>vCo});var Pnc={};Kt(Pnc,{CratesPublishInfo:()=>nqo,DynamicIntermediateRepresentation:()=>sqo,GeneratorConfig:()=>uqo,GeneratorOutputConfig:()=>oqo,GoPublishInfo:()=>XCo,MavenPublishInfo:()=>kCo,NpmPublishInfo:()=>eqo,NugetPublishInfo:()=>tqo,PublishInfo:()=>aqo,PypiPublishInfo:()=>rqo,RubyGemsPublishInfo:()=>iqo,SwiftPublishInfo:()=>ZCo});var UCo=S.objectWithoutOptionalProperties({declaration:FL,typeReference:S.lazy(()=>XE.TypeReference)});var LCo=S.objectWithoutOptionalProperties({declaration:FL,values:S.list(GQ)});var VCo=S.objectWithoutOptionalProperties({declaration:FL,properties:S.list(Zw),additionalProperties:S.boolean().optional()});var WCo=S.objectWithoutOptionalProperties({typeId:fCi,discriminantValue:GQ,properties:S.list(Zw)});var xCo=S.objectWithoutOptionalProperties({typeReference:S.lazy(()=>XE.TypeReference),discriminantValue:GQ,properties:S.list(Zw).optional()});var GCo=S.objectWithoutOptionalProperties({discriminantValue:GQ,properties:S.list(Zw).optional()});var HCo=S.union("type",{samePropertiesAsObject:WCo,singleProperty:xCo,noProperties:GCo}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return Gt.SingleDiscriminatedUnionType.samePropertiesAsObject(e);case"singleProperty":return Gt.SingleDiscriminatedUnionType.singleProperty(e);case"noProperties":return Gt.SingleDiscriminatedUnionType.noProperties(e);default:return e}},untransform:({_visit:e,...t})=>t});var KCo=S.objectWithoutOptionalProperties({declaration:FL,discriminant:GQ,types:S.record(S.string(),HCo)});var JCo=S.objectWithoutOptionalProperties({declaration:FL,types:S.list(S.lazy(()=>XE.TypeReference))});var $Co=S.union("type",{alias:UCo,enum:LCo,object:VCo,discriminatedUnion:KCo,undiscriminatedUnion:JCo}).transform({transform:e=>{switch(e.type){case"alias":return Gt.NamedType.alias(e);case"enum":return Gt.NamedType.enum(e);case"object":return Gt.NamedType.object(e);case"discriminatedUnion":return Gt.NamedType.discriminatedUnion(e);case"undiscriminatedUnion":return Gt.NamedType.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var YCo=S.objectWithoutOptionalProperties({id:S.string(),name:Oa,typeReference:S.lazy(()=>XE.TypeReference)});var XCo=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string()});var ZCo=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string()});var kCo=S.objectWithoutOptionalProperties({version:S.string(),coordinate:S.string(),repoUrl:S.string().optional()});var eqo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var tqo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var rqo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var iqo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var nqo=S.objectWithoutOptionalProperties({version:S.string(),packageName:S.string(),repoUrl:S.string().optional()});var aqo=S.union("type",{go:XCo,swift:ZCo,maven:kCo,npm:eqo,nuget:tqo,pypi:rqo,rubygems:iqo,crates:nqo}).transform({transform:e=>{switch(e.type){case"go":return Gt.PublishInfo.go(e);case"swift":return Gt.PublishInfo.swift(e);case"maven":return Gt.PublishInfo.maven(e);case"npm":return Gt.PublishInfo.npm(e);case"nuget":return Gt.PublishInfo.nuget(e);case"pypi":return Gt.PublishInfo.pypi(e);case"rubygems":return Gt.PublishInfo.rubygems(e);case"crates":return Gt.PublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var oqo=S.union("type",{publish:S.object({value:aqo}),local:S.object({})}).transform({transform:e=>{switch(e.type){case"publish":return Gt.GeneratorOutputConfig.publish(e.value);case"local":return Gt.GeneratorOutputConfig.local();default:return e}},untransform:({_visit:e,...t})=>t});var uqo=S.objectWithoutOptionalProperties({apiName:S.string(),organization:S.string(),customConfig:S.unknown(),outputConfig:oqo});var sqo=S.objectWithoutOptionalProperties({version:S.stringLiteral("1.0.0"),types:S.record(fCi,$Co),endpoints:S.record(bCo,CCo),environments:QCo.optional(),headers:S.list(Zw).optional(),pathParameters:S.list(Zw).optional(),variables:S.list(YCo).optional(),generatorConfig:uqo.optional()});var jnc={};Kt(jnc,{EndpointSnippetRequest:()=>BCo,EndpointSnippetResponse:()=>Qu_,ErrorSeverity:()=>cqo,Error_:()=>lqo,Values:()=>ZNn});var cqo=S.enum_(["CRITICAL","WARNING"]);var lqo=S.objectWithoutOptionalProperties({severity:cqo,message:S.string()});var Qu_=S.objectWithoutOptionalProperties({snippet:S.string(),errors:S.list(lqo).optional()});var wnc={};Kt(wnc,{AliasType:()=>UCo,DiscriminatedUnionType:()=>KCo,EnumType:()=>LCo,LiteralType:()=>fqo,MapType:()=>Lu_,NamedParameter:()=>Zw,NamedType:()=>$Co,ObjectPropertyAccess:()=>aCo,ObjectType:()=>VCo,PrimitiveTypeV1:()=>dqo,SingleDiscriminatedUnionType:()=>HCo,SingleDiscriminatedUnionTypeNoProperties:()=>GCo,SingleDiscriminatedUnionTypeObject:()=>WCo,SingleDiscriminatedUnionTypeSingleProperty:()=>xCo,TypeReference:()=>Uu_,UndiscriminatedUnionType:()=>JCo});var fqo=S.union("type",{boolean:S.object({value:S.boolean()}),string:S.object({value:S.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Gt.LiteralType.boolean(e.value);case"string":return Gt.LiteralType.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var dqo=S.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var Uu_=S.union("type",{list:S.object({value:S.lazy(()=>XE.TypeReference)}),literal:S.object({value:fqo}),map:S.lazyObject(()=>XE.MapType),named:S.object({value:fCi}),nullable:S.object({value:S.lazy(()=>XE.TypeReference)}),optional:S.object({value:S.lazy(()=>XE.TypeReference)}),primitive:S.object({value:dqo}),set:S.object({value:S.lazy(()=>XE.TypeReference)}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"list":return Gt.TypeReference.list(e.value);case"literal":return Gt.TypeReference.literal(e.value);case"map":return Gt.TypeReference.map(e);case"named":return Gt.TypeReference.named(e.value);case"nullable":return Gt.TypeReference.nullable(e.value);case"optional":return Gt.TypeReference.optional(e.value);case"primitive":return Gt.TypeReference.primitive(e.value);case"set":return Gt.TypeReference.set(e.value);case"unknown":return Gt.TypeReference.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Lu_=S.objectWithoutOptionalProperties({key:S.lazy(()=>XE.TypeReference),value:S.lazy(()=>XE.TypeReference)});var Enc={};Kt(Enc,{VariableDeclaration:()=>YCo});var Snc={};Kt(Snc,{EnvironmentBaseUrlId:()=>Ohe,EnvironmentBaseUrlWithId:()=>hqo,EnvironmentId:()=>rGt,EnvironmentUrl:()=>_Ci,Environments:()=>vqo,EnvironmentsConfig:()=>gqo,MultipleBaseUrlsEnvironment:()=>yqo,MultipleBaseUrlsEnvironments:()=>bqo,SingleBaseUrlEnvironment:()=>pqo,SingleBaseUrlEnvironments:()=>_qo});var rGt=S.string();var Ohe=S.string();var _Ci=S.string();var pqo=S.objectWithoutOptionalProperties({id:rGt,name:Oa,url:_Ci}).extend(Un);var _qo=S.objectWithoutOptionalProperties({environments:S.list(pqo)});var hqo=S.objectWithoutOptionalProperties({id:Ohe,name:Oa});var yqo=S.objectWithoutOptionalProperties({id:rGt,name:Oa,urls:S.record(Ohe,_Ci)}).extend(Un);var bqo=S.objectWithoutOptionalProperties({baseUrls:S.list(hqo),environments:S.list(yqo)});var vqo=S.union("type",{singleBaseUrl:_qo,multipleBaseUrls:bqo}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return YE.singleBaseUrl(e);case"multipleBaseUrls":return YE.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var gqo=S.objectWithoutOptionalProperties({defaultEnvironment:rGt.optional(),environments:vqo});var Mnc={};Kt(Mnc,{DeclaredErrorName:()=>hCi,ErrorDeclaration:()=>Aqo,ErrorDeclarationDiscriminantValue:()=>Vu_,ExampleError:()=>Oqo});var hCi=S.objectWithoutOptionalProperties({errorId:lCi,fernFilepath:M0e,name:Oa});var Oqo=S.objectWithoutOptionalProperties({name:Oa.optional(),shape:S.lazyObject(()=>xl)}).extend(eGt).extend(Un);var Aqo=S.objectWithoutOptionalProperties({name:hCi,displayName:S.string().optional(),discriminantValue:Ec,type:S.lazy(()=>ts).optional(),statusCode:S.number(),isWildcardStatusCode:S.boolean().optional(),examples:S.list(Oqo),v2Examples:lz.optional()}).extend(Un);var Vu_=S.union("type",{property:Ec,statusCode:S.object({})}).transform({transform:e=>{switch(e.type){case"property":return tCi.property(e);case"statusCode":return tCi.statusCode();default:return e}},untransform:({_visit:e,...t})=>t});var Dnc={};Kt(Dnc,{BasicAuthValues:()=>wqo,BearerAuthValues:()=>Eqo,HeaderAuthValues:()=>Sqo,MultipleEnvironmentUrlValues:()=>jqo,OAuthValues:()=>Mqo,V2AuthValues:()=>eFn,V2EndpointLocation:()=>Pqo,V2EndpointLocationHttpMethod:()=>mqo,V2EnvironmentValues:()=>kNn,V2HttpEndpointCodeSample:()=>Cqo,V2HttpEndpointExample:()=>tPa,V2HttpEndpointExamples:()=>qqo,V2HttpEndpointRequest:()=>Dqo,V2HttpEndpointResponse:()=>Iqo,V2HttpEndpointResponseBody:()=>Bqo,V2SchemaExample:()=>k0a,V2SchemaExamples:()=>lz,V2ValueExamples:()=>iGt,V2WebSocketEndpointLocation:()=>Tqo,V2WebSocketMessageExample:()=>Rqo,V2WebSocketSessionExample:()=>rPa,V2WebSocketSessionExamples:()=>zqo,V2WebhookExample:()=>iPa,V2WebhookExamples:()=>Nqo,WithV2Examples:()=>zj});var zj=S.objectWithoutOptionalProperties({v2Examples:lz.optional()});var mqo=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var Pqo=S.objectWithoutOptionalProperties({method:mqo,path:S.string()});var jqo=S.record(Ohe,_Ci);var kNn=S.undiscriminatedUnion([rGt,jqo]);var wqo=S.objectWithoutOptionalProperties({username:S.string(),password:S.string()});var Eqo=S.objectWithoutOptionalProperties({token:S.string()});var Sqo=S.objectWithoutOptionalProperties({value:S.unknown()});var Mqo=S.objectWithoutOptionalProperties({clientId:S.string(),clientSecret:S.string()});var eFn=S.union("type",{basic:wqo,bearer:Eqo,header:Sqo,oauth:Mqo}).transform({transform:e=>{switch(e.type){case"basic":return m0e.basic(e);case"bearer":return m0e.bearer(e);case"header":return m0e.header(e);case"oauth":return m0e.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var iGt=S.record(S.string(),S.unknown());var Dqo=S.objectWithoutOptionalProperties({endpoint:Pqo,baseUrl:S.property("baseURL",S.string().optional()),environment:kNn.optional(),auth:eFn.optional(),pathParameters:iGt.optional(),queryParameters:iGt.optional(),headers:iGt.optional(),requestBody:S.unknown().optional()}).extend(Un);var Bqo=S.union("type",{error:S.object({value:S.unknown()}),json:S.object({value:S.unknown()}),stream:S.object({value:S.list(S.unknown())})}).transform({transform:e=>{switch(e.type){case"error":return CC.error(e.value);case"json":return CC.json(e.value);case"stream":return CC.stream(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Iqo=S.objectWithoutOptionalProperties({statusCode:S.number().optional(),body:Bqo.optional()}).extend(Un);var Cqo=S.objectWithoutOptionalProperties({name:S.string().optional(),language:S.string(),code:S.string()}).extend(Un);var tPa=S.objectWithoutOptionalProperties({displayName:S.string().optional(),request:Dqo.optional(),response:Iqo.optional(),codeSamples:S.list(Cqo).optional()});var qqo=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),tPa),autogeneratedExamples:S.record(S.string(),tPa)});var Tqo=S.objectWithoutOptionalProperties({path:S.string()});var Rqo=S.objectWithoutOptionalProperties({type:S.string(),body:S.unknown()});var rPa=S.objectWithoutOptionalProperties({channel:Tqo,baseUrl:S.property("baseURL",S.string().optional()),environment:kNn.optional(),auth:eFn.optional(),pathParameters:iGt.optional(),queryParameters:iGt.optional(),headers:iGt.optional(),messages:S.list(Rqo).optional()});var zqo=S.objectWithoutOptionalProperties({autogeneratedExamples:S.record(S.string(),rPa),userSpecifiedExamples:S.record(S.string(),rPa)});var iPa=S.objectWithoutOptionalProperties({name:S.string().optional(),payload:S.unknown()});var Nqo=S.objectWithoutOptionalProperties({userSpecifiedExamples:S.record(S.string(),iPa),autogeneratedExamples:S.record(S.string(),iPa)});var Inc={};Kt(Inc,{BasicLicense:()=>Qqo,CratesGithubPublishInfo:()=>n1o,CratesRegistryConfig:()=>sFn,CustomLicense:()=>Uqo,EnvironmentVariable:()=>GS,GeneratorConfig:()=>Wu_,GeneratorEnvironment:()=>l1o,GeneratorOutputConfig:()=>s1o,GeneratorPublishConfig:()=>cFn,GeneratorPublishTarget:()=>Yqo,GeneratorRegistriesConfig:()=>Gqo,GeneratorRegistriesConfigV2:()=>Jqo,GithubOutputMode:()=>o1o,GithubPublishInfo:()=>a1o,LicenseConfig:()=>Lqo,LicenseId:()=>Fqo,MavenCentralSignature:()=>tFn,MavenCentralSignatureGithubInfo:()=>Zqo,MavenGithubPublishInfo:()=>kqo,MavenRegistryConfig:()=>Wqo,MavenRegistryConfigV2:()=>rFn,NpmGithubPublishInfo:()=>Xqo,NpmRegistryConfig:()=>xqo,NpmRegistryConfigV2:()=>iFn,NugetGithubPublishInfo:()=>i1o,NugetRegistryConfig:()=>uFn,OutputMetadata:()=>Kqo,OutputMetadataAuthor:()=>Hqo,OutputMode:()=>u1o,PostmanConfig:()=>$qo,PostmanGithubPublishInfo:()=>e1o,PublishingMetadata:()=>Vqo,PypiGithubPublishInfo:()=>t1o,PypiMetadata:()=>nFn,PypiRegistryConfig:()=>aFn,RemoteGeneratorEnvironment:()=>c1o,RubyGemsGithubPublishInfo:()=>r1o,RubyGemsRegistryConfig:()=>oFn,config:()=>Bnc});var Bnc={};Kt(Bnc,{BasicLicense:()=>Qqo,CratesGithubPublishInfo:()=>n1o,CratesRegistryConfig:()=>sFn,CustomLicense:()=>Uqo,EnvironmentVariable:()=>GS,GeneratorConfig:()=>Wu_,GeneratorEnvironment:()=>l1o,GeneratorOutputConfig:()=>s1o,GeneratorPublishConfig:()=>cFn,GeneratorPublishTarget:()=>Yqo,GeneratorRegistriesConfig:()=>Gqo,GeneratorRegistriesConfigV2:()=>Jqo,GithubOutputMode:()=>o1o,GithubPublishInfo:()=>a1o,LicenseConfig:()=>Lqo,LicenseId:()=>Fqo,MavenCentralSignature:()=>tFn,MavenCentralSignatureGithubInfo:()=>Zqo,MavenGithubPublishInfo:()=>kqo,MavenRegistryConfig:()=>Wqo,MavenRegistryConfigV2:()=>rFn,NpmGithubPublishInfo:()=>Xqo,NpmRegistryConfig:()=>xqo,NpmRegistryConfigV2:()=>iFn,NugetGithubPublishInfo:()=>i1o,NugetRegistryConfig:()=>uFn,OutputMetadata:()=>Kqo,OutputMetadataAuthor:()=>Hqo,OutputMode:()=>u1o,PostmanConfig:()=>$qo,PostmanGithubPublishInfo:()=>e1o,PublishingMetadata:()=>Vqo,PypiGithubPublishInfo:()=>t1o,PypiMetadata:()=>nFn,PypiRegistryConfig:()=>aFn,RemoteGeneratorEnvironment:()=>c1o,RubyGemsGithubPublishInfo:()=>r1o,RubyGemsRegistryConfig:()=>oFn});var Fqo=S.enum_(["MIT","Apache-2.0"]);var Qqo=S.objectWithoutOptionalProperties({id:Fqo});var Uqo=S.objectWithoutOptionalProperties({filename:S.string()});var Lqo=S.union("type",{basic:Qqo,custom:Uqo}).transform({transform:e=>{switch(e.type){case"basic":return Lc.LicenseConfig.basic(e);case"custom":return Lc.LicenseConfig.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Vqo=S.objectWithoutOptionalProperties({packageDescription:S.property("package_description",S.string().optional()),publisherEmail:S.property("publisher_email",S.string().optional()),referenceUrl:S.property("reference_url",S.string().optional()),publisherName:S.property("publisher_name",S.string().optional())});var tFn=S.objectWithoutOptionalProperties({keyId:S.string(),password:S.string(),secretKey:S.string()});var Wqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),group:S.string(),signature:tFn.optional()});var xqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),scope:S.string()});var Gqo=S.objectWithoutOptionalProperties({maven:Wqo,npm:xqo});var rFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),coordinate:S.string(),signature:tFn.optional()});var iFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),packageName:S.string()});var Hqo=S.objectWithoutOptionalProperties({name:S.string(),email:S.string()});var Kqo=S.objectWithoutOptionalProperties({description:S.string().optional(),authors:S.list(Hqo).optional()});var nFn=S.objectWithoutOptionalProperties({keywords:S.list(S.string()).optional(),documentationLink:S.string().optional(),homepageLink:S.string().optional()}).extend(Kqo);var aFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),username:S.string(),password:S.string(),packageName:S.string(),pypiMetadata:nFn.optional()});var oFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),apiKey:S.string(),packageName:S.string()});var uFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),apiKey:S.string(),packageName:S.string()});var sFn=S.objectWithoutOptionalProperties({registryUrl:S.string(),token:S.string(),packageName:S.string()});var Jqo=S.objectWithoutOptionalProperties({maven:rFn,npm:iFn,pypi:aFn,rubygems:oFn,nuget:uFn,crates:sFn});var $qo=S.objectWithoutOptionalProperties({apiKey:S.string(),workspaceId:S.string()});var Yqo=S.union("type",{maven:rFn,npm:iFn,pypi:aFn,postman:$qo,rubygems:oFn,nuget:uFn,crates:sFn}).transform({transform:e=>{switch(e.type){case"maven":return Lc.GeneratorPublishTarget.maven(e);case"npm":return Lc.GeneratorPublishTarget.npm(e);case"pypi":return Lc.GeneratorPublishTarget.pypi(e);case"postman":return Lc.GeneratorPublishTarget.postman(e);case"rubygems":return Lc.GeneratorPublishTarget.rubygems(e);case"nuget":return Lc.GeneratorPublishTarget.nuget(e);case"crates":return Lc.GeneratorPublishTarget.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var cFn=S.objectWithoutOptionalProperties({registries:Gqo,registriesV2:Jqo,publishTarget:Yqo.optional(),version:S.string()});var GS=S.string();var Xqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),tokenEnvironmentVariable:GS,shouldGeneratePublishWorkflow:S.boolean().optional()});var Zqo=S.objectWithoutOptionalProperties({keyIdEnvironmentVariable:GS,passwordEnvironmentVariable:GS,secretKeyEnvironmentVariable:GS});var kqo=S.objectWithoutOptionalProperties({registryUrl:S.string(),coordinate:S.string(),usernameEnvironmentVariable:GS,passwordEnvironmentVariable:GS,signature:Zqo.optional(),shouldGeneratePublishWorkflow:S.boolean().optional()});var e1o=S.objectWithoutOptionalProperties({apiKeyEnvironmentVariable:GS,workspaceIdEnvironmentVariable:GS});var t1o=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),usernameEnvironmentVariable:GS,passwordEnvironmentVariable:GS,pypiMetadata:nFn.optional(),shouldGeneratePublishWorkflow:S.boolean().optional()});var r1o=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),apiKeyEnvironmentVariable:GS,shouldGeneratePublishWorkflow:S.boolean().optional()});var i1o=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),apiKeyEnvironmentVariable:GS,shouldGeneratePublishWorkflow:S.boolean().optional()});var n1o=S.objectWithoutOptionalProperties({registryUrl:S.string(),packageName:S.string(),tokenEnvironmentVariable:GS,shouldGeneratePublishWorkflow:S.boolean().optional()});var a1o=S.union("type",{npm:Xqo,maven:kqo,postman:e1o,pypi:t1o,rubygems:r1o,nuget:i1o,crates:n1o}).transform({transform:e=>{switch(e.type){case"npm":return Lc.GithubPublishInfo.npm(e);case"maven":return Lc.GithubPublishInfo.maven(e);case"postman":return Lc.GithubPublishInfo.postman(e);case"pypi":return Lc.GithubPublishInfo.pypi(e);case"rubygems":return Lc.GithubPublishInfo.rubygems(e);case"nuget":return Lc.GithubPublishInfo.nuget(e);case"crates":return Lc.GithubPublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var o1o=S.objectWithoutOptionalProperties({version:S.string(),repoUrl:S.string(),installationToken:S.string().optional(),branch:S.string().optional(),publishInfo:a1o.optional()});var u1o=S.union("type",{publish:cFn,downloadFiles:S.object({}),github:o1o}).transform({transform:e=>{switch(e.type){case"publish":return Lc.OutputMode.publish(e);case"downloadFiles":return Lc.OutputMode.downloadFiles();case"github":return Lc.OutputMode.github(e);default:return e}},untransform:({_visit:e,...t})=>t});var s1o=S.objectWithoutOptionalProperties({path:S.string(),snippetFilepath:S.string().optional(),snippetTemplateFilepath:S.string().optional(),publishingMetadata:Vqo.optional(),mode:u1o});var c1o=S.objectWithoutOptionalProperties({coordinatorUrl:S.string(),coordinatorUrlV2:S.string(),id:S.string()});var l1o=S.union(S.discriminant("type","_type"),{local:S.object({}),remote:c1o}).transform({transform:e=>{switch(e.type){case"local":return Lc.GeneratorEnvironment.local();case"remote":return Lc.GeneratorEnvironment.remote(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wu_=S.objectWithoutOptionalProperties({dryRun:S.boolean(),irFilepath:S.string(),originalReadmeFilepath:S.string().optional(),license:Lqo.optional(),output:s1o,publish:cFn.optional(),workspaceName:S.string(),organization:S.string(),customConfig:S.unknown(),environment:l1o,whitelabel:S.boolean(),writeUnitTests:S.boolean(),generatePaginatedClients:S.boolean().optional(),generateOauthClients:S.boolean()});var Cnc={};Kt(Cnc,{AutogeneratedEndpointExample:()=>iTo,BytesRequest:()=>pFn,BytesResponse:()=>vFn,CursorPagination:()=>L1o,CustomPagination:()=>W1o,DeclaredServiceName:()=>f1o,EndpointName:()=>p1o,ExampleCodeSample:()=>K1o,ExampleCodeSampleLanguage:()=>G1o,ExampleCodeSampleSdk:()=>H1o,ExampleEndpointCall:()=>jFn,ExampleEndpointErrorResponse:()=>eTo,ExampleEndpointSuccessResponse:()=>k1o,ExampleHeader:()=>QKi,ExampleInlinedRequestBody:()=>PFn,ExampleInlinedRequestBodyExtraProperty:()=>Y1o,ExampleInlinedRequestBodyProperty:()=>$1o,ExamplePathParameter:()=>yCi,ExampleQueryParameter:()=>mFn,ExampleQueryParameterShape:()=>J1o,ExampleRequestBody:()=>X1o,ExampleResponse:()=>tTo,ExampleServerSideEvent:()=>Z1o,FileDownloadResponse:()=>yFn,FileProperty:()=>g1o,FilePropertyArray:()=>v1o,FilePropertySingle:()=>b1o,FileUploadBodyProperty:()=>A1o,FileUploadBodyPropertyEncoding:()=>O1o,FileUploadRequest:()=>P1o,FileUploadRequestProperty:()=>m1o,GrpcTransport:()=>uTo,HttpEndpoint:()=>pTo,HttpEndpointSecurityItem:()=>U1o,HttpEndpointSource:()=>lTo,HttpHeader:()=>bx,HttpMethod:()=>_1o,HttpPath:()=>B0e,HttpPathPart:()=>d1o,HttpRequestBody:()=>_Fn,HttpRequestBodyReference:()=>dFn,HttpResponse:()=>OFn,HttpResponseBody:()=>z1o,HttpService:()=>yTo,InlinedRequestBody:()=>y1o,InlinedRequestBodyProperty:()=>fFn,JsonResponse:()=>hFn,JsonResponseBody:()=>D1o,JsonResponseBodyWithProperty:()=>B1o,JsonStreamChunk:()=>I1o,NonStreamHttpResponseBody:()=>T1o,OffsetPagination:()=>V1o,Pagination:()=>x1o,PathParameter:()=>uFt,PathParameterLocation:()=>h1o,PropertyPathItem:()=>GNn,ProtoSourceInfo:()=>cTo,QueryParameter:()=>oCi,RequestProperty:()=>NL,RequestPropertyValue:()=>LIo,ResponseError:()=>F1o,ResponseErrors:()=>Q1o,ResponseProperty:()=>fz,RetriesConfiguration:()=>dTo,RetriesDisabledSchema:()=>fTo,SdkRequest:()=>M1o,SdkRequestBodyType:()=>w1o,SdkRequestShape:()=>S1o,SdkRequestWrapper:()=>E1o,SseStreamChunk:()=>q1o,StreamParameterResponse:()=>R1o,StreamingResponse:()=>gFn,SupportedSdkLanguage:()=>AFn,TextResponse:()=>bFn,TextStreamChunk:()=>C1o,Transport:()=>EFn,UserSpecifiedEndpointExample:()=>rTo,V2HttpRequestBodies:()=>j1o,V2HttpResponses:()=>N1o});var f1o=S.objectWithoutOptionalProperties({fernFilepath:M0e});var d1o=S.objectWithoutOptionalProperties({pathParameter:S.string(),tail:S.string()});var B0e=S.objectWithoutOptionalProperties({head:S.string(),parts:S.list(d1o)});var p1o=Oa;var _1o=S.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var bx=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts),env:S.string().optional(),v2Examples:lz.optional()}).extend(TC);var h1o=S.enum_(["ROOT","SERVICE","ENDPOINT"]);var lFn=S.string();var uFt=S.objectWithoutOptionalProperties({name:Oa,valueType:S.lazy(()=>ts),location:h1o,variable:lFn.optional(),v2Examples:lz.optional()}).extend(Un);var Nj=S.objectWithoutOptionalProperties({typeId:xQ,fernFilepath:M0e,name:Oa,displayName:cCi.optional()});var fFn=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts),v2Examples:lz.optional(),propertyAccess:uCi.optional()}).extend(sCi);var y1o=S.objectWithoutOptionalProperties({name:Oa,extends:S.list(Nj),properties:S.list(fFn),extendedProperties:S.list(yx).optional(),extraProperties:S.property("extra-properties",S.boolean())}).extend(Un).extend(zj).extend(D0e);var dFn=S.objectWithoutOptionalProperties({requestBodyType:S.lazy(()=>ts)}).extend(Un).extend(D0e).extend(zj);var b1o=S.objectWithoutOptionalProperties({key:Ec,isOptional:S.boolean(),contentType:S.string().optional()}).extend(Un);var v1o=S.objectWithoutOptionalProperties({key:Ec,isOptional:S.boolean(),contentType:S.string().optional()}).extend(Un);var g1o=S.union("type",{file:b1o,fileArray:v1o}).transform({transform:e=>{switch(e.type){case"file":return X6.file(e);case"fileArray":return X6.fileArray(e);default:return e}},untransform:({_visit:e,...t})=>t});var O1o=S.enum_(["exploded","json","form"]);var A1o=S.objectWithoutOptionalProperties({style:O1o.optional()}).extend(fFn).extend(D0e);var m1o=S.union("type",{file:S.object({value:g1o}),bodyProperty:A1o}).transform({transform:e=>{switch(e.type){case"file":return qC.file(e.value);case"bodyProperty":return qC.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var P1o=S.objectWithoutOptionalProperties({name:Oa,properties:S.list(m1o)}).extend(Un).extend(zj).extend(D0e);var pFn=S.objectWithoutOptionalProperties({isOptional:S.boolean()}).extend(Un).extend(zj).extend(D0e);var _Fn=S.union("type",{inlinedRequestBody:y1o,reference:dFn,fileUpload:P1o,bytes:pFn}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return VO.inlinedRequestBody(e);case"reference":return VO.reference(e);case"fileUpload":return VO.fileUpload(e);case"bytes":return VO.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var j1o=S.objectWithoutOptionalProperties({requestBodies:S.list(_Fn).optional()});var w1o=S.union("type",{typeReference:dFn,bytes:pFn}).transform({transform:e=>{switch(e.type){case"typeReference":return iFt.typeReference(e);case"bytes":return iFt.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var E1o=S.objectWithoutOptionalProperties({wrapperName:Oa,bodyKey:Oa,includePathParameters:S.boolean().optional(),onlyPathParameters:S.boolean().optional()});var S1o=S.union("type",{justRequestBody:S.object({value:w1o}),wrapper:E1o}).transform({transform:e=>{switch(e.type){case"justRequestBody":return w0e.justRequestBody(e.value);case"wrapper":return w0e.wrapper(e);default:return e}},untransform:({_visit:e,...t})=>t});var M1o=S.objectWithoutOptionalProperties({streamParameter:NL.optional(),requestParameterName:Oa,shape:S1o});var D1o=S.objectWithoutOptionalProperties({responseBodyType:S.lazy(()=>ts)}).extend(Un).extend(zj);var B1o=S.objectWithoutOptionalProperties({responseBodyType:S.lazy(()=>ts),responseProperty:yx.optional()}).extend(Un).extend(zj);var hFn=S.union("type",{response:D1o,nestedPropertyAsResponse:B1o}).transform({transform:e=>{switch(e.type){case"response":return nz.response(e);case"nestedPropertyAsResponse":return nz.nestedPropertyAsResponse(e);default:return e}},untransform:({_visit:e,...t})=>t});var yFn=S.objectWithoutOptionalProperties({}).extend(Un).extend(zj);var bFn=S.objectWithoutOptionalProperties({}).extend(Un).extend(zj);var vFn=S.objectWithoutOptionalProperties({}).extend(Un).extend(zj);var I1o=S.objectWithoutOptionalProperties({payload:S.lazy(()=>ts),terminator:S.string().optional()}).extend(Un).extend(zj);var C1o=S.objectWithoutOptionalProperties({}).extend(Un).extend(zj);var q1o=S.objectWithoutOptionalProperties({payload:S.lazy(()=>ts),terminator:S.string().optional()}).extend(Un).extend(zj);var gFn=S.union("type",{json:I1o,text:C1o,sse:q1o}).transform({transform:e=>{switch(e.type){case"json":return az.json(e);case"text":return az.text(e);case"sse":return az.sse(e);default:return e}},untransform:({_visit:e,...t})=>t});var T1o=S.union("type",{json:S.object({value:hFn}),fileDownload:yFn,text:bFn,bytes:vFn}).transform({transform:e=>{switch(e.type){case"json":return LQ.json(e.value);case"fileDownload":return LQ.fileDownload(e);case"text":return LQ.text(e);case"bytes":return LQ.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var R1o=S.objectWithoutOptionalProperties({nonStreamResponse:T1o,streamResponse:gFn});var z1o=S.union("type",{json:S.object({value:hFn}),fileDownload:yFn,text:bFn,bytes:vFn,streaming:S.object({value:gFn}),streamParameter:R1o}).transform({transform:e=>{switch(e.type){case"json":return ly.json(e.value);case"fileDownload":return ly.fileDownload(e);case"text":return ly.text(e);case"bytes":return ly.bytes(e);case"streaming":return ly.streaming(e.value);case"streamParameter":return ly.streamParameter(e);default:return e}},untransform:({_visit:e,...t})=>t});var OFn=S.objectWithoutOptionalProperties({statusCode:S.property("status-code",S.number().optional()),isWildcardStatusCode:S.boolean().optional(),body:z1o.optional()});var N1o=S.objectWithoutOptionalProperties({responses:S.list(OFn).optional()});var F1o=S.objectWithoutOptionalProperties({error:hCi}).extend(Un);var Q1o=S.list(F1o);var U1o=S.record(xNn,S.list(RIo));var L1o=S.objectWithoutOptionalProperties({page:NL,next:fz,results:fz});var V1o=S.objectWithoutOptionalProperties({page:NL,results:fz,hasNextPage:fz.optional(),step:NL.optional()});var W1o=S.objectWithoutOptionalProperties({results:fz});var x1o=S.union("type",{cursor:L1o,offset:V1o,custom:W1o}).transform({transform:e=>{switch(e.type){case"cursor":return TL.cursor(e);case"offset":return TL.offset(e);case"custom":return TL.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var G1o=S.objectWithoutOptionalProperties({name:Oa.optional(),language:S.string(),code:S.string(),install:S.string().optional()}).extend(Un);var AFn=S.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","php","rust","swift"]);var H1o=S.objectWithoutOptionalProperties({name:Oa.optional(),sdk:AFn,code:S.string()}).extend(Un);var K1o=S.union("type",{language:G1o,sdk:H1o}).transform({transform:e=>{switch(e.type){case"language":return yhe.language(e);case"sdk":return yhe.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var yCi=S.objectWithoutOptionalProperties({name:Oa,value:S.lazyObject(()=>xl)});var QKi=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl)});var J1o=S.union("type",{single:S.object({}),exploded:S.object({}),commaSeparated:S.object({})}).transform({transform:e=>{switch(e.type){case"single":return B1.single();case"exploded":return B1.exploded();case"commaSeparated":return B1.commaSeparated();default:return e}},untransform:({_visit:e,...t})=>t});var mFn=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl),shape:J1o.optional()});var $1o=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl),originalTypeDeclaration:Nj.optional()});var Y1o=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl)});var PFn=S.objectWithoutOptionalProperties({properties:S.list($1o),extraProperties:S.list(Y1o).optional()}).extend(eGt);var X1o=S.union("type",{inlinedRequestBody:PFn,reference:S.lazyObject(()=>xl)}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return RL.inlinedRequestBody(e);case"reference":return RL.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var Z1o=S.objectWithoutOptionalProperties({event:S.string(),data:S.lazyObject(()=>xl)});var k1o=S.union("type",{body:S.object({value:S.lazyObject(()=>xl).optional()}),stream:S.object({value:S.list(S.lazyObject(()=>xl))}),sse:S.object({value:S.list(Z1o)})}).transform({transform:e=>{switch(e.type){case"body":return $P.body(e.value);case"stream":return $P.stream(e.value);case"sse":return $P.sse(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var eTo=S.objectWithoutOptionalProperties({error:hCi,body:S.lazyObject(()=>xl).optional()});var tTo=S.union("type",{ok:S.object({value:k1o}),error:eTo}).transform({transform:e=>{switch(e.type){case"ok":return K0.ok(e.value);case"error":return K0.error(e);default:return e}},untransform:({_visit:e,...t})=>t});var jFn=S.objectWithoutOptionalProperties({id:S.string().optional(),name:Oa.optional(),url:S.string(),rootPathParameters:S.list(yCi),servicePathParameters:S.list(yCi),endpointPathParameters:S.list(yCi),serviceHeaders:S.list(QKi),endpointHeaders:S.list(QKi),queryParameters:S.list(mFn),request:X1o.optional(),response:tTo}).extend(Un);var rTo=S.objectWithoutOptionalProperties({codeSamples:S.list(K1o).optional(),example:jFn.optional()});var iTo=S.objectWithoutOptionalProperties({example:jFn});var nTo=S.objectWithoutOptionalProperties({namespace:S.string()});var aTo=S.objectWithoutOptionalProperties({csharp:nTo.optional()});var wFn=S.objectWithoutOptionalProperties({filepath:S.string(),packageName:S.string().optional(),options:aTo.optional()});var oTo=S.objectWithoutOptionalProperties({file:wFn,name:Oa});var uTo=S.objectWithoutOptionalProperties({service:oTo});var EFn=S.union("type",{http:S.object({}),grpc:uTo}).transform({transform:e=>{switch(e.type){case"http":return P0e.http();case"grpc":return P0e.grpc(e);default:return e}},untransform:({_visit:e,...t})=>t});var sTo=S.enum_(["UNARY","CLIENT_STREAM","SERVER_STREAM","BIDIRECTIONAL_STREAM"]);var cTo=S.objectWithoutOptionalProperties({methodType:sTo.optional()});var lTo=S.union("type",{proto:cTo,openapi:S.object({}),openrpc:S.object({})}).transform({transform:e=>{switch(e.type){case"proto":return qL.proto(e);case"openapi":return qL.openapi();case"openrpc":return qL.openrpc();default:return e}},untransform:({_visit:e,...t})=>t});var fTo=S.objectWithoutOptionalProperties({disabled:S.boolean().optional()});var dTo=S.undiscriminatedUnion([fTo]);var pTo=S.objectWithoutOptionalProperties({id:Uvi,name:p1o,displayName:S.string().optional(),method:_1o,headers:S.list(bx),baseUrl:Ohe.optional(),v2BaseUrls:S.list(Ohe).optional(),basePath:B0e.optional(),path:B0e,fullPath:B0e,pathParameters:S.list(uFt),allPathParameters:S.list(uFt),queryParameters:S.list(oCi),requestBody:_Fn.optional(),v2RequestBodies:j1o.optional(),sdkRequest:M1o.optional(),response:OFn.optional(),v2Responses:N1o.optional(),errors:Q1o,auth:S.boolean(),security:S.list(U1o).optional(),idempotent:S.boolean(),pagination:x1o.optional(),userSpecifiedExamples:S.list(rTo),autogeneratedExamples:S.list(iTo),v2Examples:qqo.optional(),transport:EFn.optional(),source:lTo.optional(),audiences:S.list(WNn).optional(),retries:dTo.optional(),apiPlayground:S.boolean().optional()}).extend(TC);var _To=S.objectWithoutOptionalProperties({});var hTo=S.objectWithoutOptionalProperties({});var SFn=S.objectWithoutOptionalProperties({json:_To.optional(),proto:hTo.optional()});var yTo=S.objectWithoutOptionalProperties({availability:k9t.optional(),name:f1o,displayName:S.string().optional(),basePath:B0e,endpoints:S.list(pTo),headers:S.list(bx),pathParameters:S.list(uFt),encoding:SFn.optional(),transport:EFn.optional(),audiences:S.list(WNn).optional()});var qnc={};Kt(qnc,{ApiDefinitionSource:()=>TRo,ApiDefinitionSourceId:()=>CRo,ApiVersionScheme:()=>vTo,ErrorDiscriminationByPropertyStrategy:()=>mRo,ErrorDiscriminationStrategy:()=>PRo,ExampleStyle:()=>BRo,GenerationMetadata:()=>GRo,HeaderApiVersionScheme:()=>bTo,IntermediateRepresentation:()=>xu_,Package:()=>qFn,PackageNavigationConfig:()=>ORo,PlatformHeaders:()=>wRo,ProtoSource:()=>qRo,ReadmeConfig:()=>IRo,ReadmeCustomSection:()=>DRo,SdkConfig:()=>ERo,ServiceTypeReferenceInfo:()=>MRo,SourceConfig:()=>RRo,Subpackage:()=>ARo,UserAgent:()=>jRo});var Lvi=S.objectWithoutOptionalProperties({name:Ec}).extend(TC);var MFn=S.objectWithoutOptionalProperties({default:Lvi.optional(),values:S.list(Lvi)});var bTo=S.objectWithoutOptionalProperties({header:bx,value:MFn});var vTo=S.union("type",{header:bTo}).transform({transform:e=>{switch(e.type){case"header":return rCi.header(e);default:return e}},untransform:({_visit:e,...t})=>t});var gTo=S.enum_(["ENUM","OBJECT","UNION","UNDISCRIMINATED_UNION"]);var OTo=S.objectWithoutOptionalProperties({name:Nj,shape:gTo});var ATo=S.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var mTo=S.objectWithoutOptionalProperties({min:S.number().optional(),max:S.number().optional(),exclusiveMin:S.boolean().optional(),exclusiveMax:S.boolean().optional(),multipleOf:S.number().optional()});var PTo=S.objectWithoutOptionalProperties({default:S.number().optional(),validation:mTo.optional()});var jTo=S.objectWithoutOptionalProperties({default:S.number().optional()});var wTo=S.objectWithoutOptionalProperties({});var ETo=S.objectWithoutOptionalProperties({});var STo=S.objectWithoutOptionalProperties({});var MTo=S.objectWithoutOptionalProperties({min:S.number().optional(),max:S.number().optional(),exclusiveMin:S.boolean().optional(),exclusiveMax:S.boolean().optional(),multipleOf:S.number().optional()});var DTo=S.objectWithoutOptionalProperties({default:S.number().optional(),validation:MTo.optional()});var BTo=S.objectWithoutOptionalProperties({default:S.boolean().optional()});var ITo=S.objectWithoutOptionalProperties({format:S.string().optional(),pattern:S.string().optional(),minLength:S.number().optional(),maxLength:S.number().optional()});var CTo=S.objectWithoutOptionalProperties({default:S.string().optional(),validation:ITo.optional()});var qTo=S.objectWithoutOptionalProperties({});var TTo=S.objectWithoutOptionalProperties({});var RTo=S.objectWithoutOptionalProperties({});var zTo=S.objectWithoutOptionalProperties({});var NTo=S.objectWithoutOptionalProperties({default:S.string().optional()});var FTo=S.union("type",{integer:PTo,long:jTo,uint:wTo,uint64:ETo,float:STo,double:DTo,boolean:BTo,string:CTo,date:qTo,dateTime:TTo,uuid:RTo,base64:zTo,bigInteger:NTo}).transform({transform:e=>{switch(e.type){case"integer":return Pn.integer(e);case"long":return Pn.long(e);case"uint":return Pn.uint(e);case"uint64":return Pn.uint64(e);case"float":return Pn.float(e);case"double":return Pn.double(e);case"boolean":return Pn.boolean(e);case"string":return Pn.string(e);case"date":return Pn.date(e);case"dateTime":return Pn.dateTime(e);case"uuid":return Pn.uuid(e);case"base64":return Pn.base64(e);case"bigInteger":return Pn.bigInteger(e);default:return e}},untransform:({_visit:e,...t})=>t});var DFn=S.objectWithoutOptionalProperties({v1:ATo,v2:FTo.optional()});var QTo=S.union(S.discriminant("type","_type"),{container:S.object({container:S.lazy(()=>BFn)}),named:OTo,primitive:S.object({primitive:DFn}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"container":return VQ.container(e.container);case"named":return VQ.named(e);case"primitive":return VQ.primitive(e.primitive);case"unknown":return VQ.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var UTo=S.objectWithoutOptionalProperties({aliasOf:S.lazy(()=>ts),resolvedType:QTo});var LTo=S.objectWithoutOptionalProperties({extends:S.list(Nj),properties:S.list(yx),extendedProperties:S.list(yx).optional(),extraProperties:S.property("extra-properties",S.boolean())});var VTo=S.objectWithoutOptionalProperties({name:Ec,type:S.lazy(()=>ts)});var WTo=S.union(S.discriminant("propertiesType","_type"),{samePropertiesAsObject:Nj,singleProperty:VTo,noProperties:S.object({})}).transform({transform:e=>{switch(e.propertiesType){case"samePropertiesAsObject":return oz.samePropertiesAsObject(e);case"singleProperty":return oz.singleProperty(e);case"noProperties":return oz.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var xTo=S.objectWithoutOptionalProperties({discriminantValue:Ec,shape:WTo,displayName:S.string().optional(),availability:k9t.optional()}).extend(Un);var GTo=S.objectWithoutOptionalProperties({discriminant:Ec,extends:S.list(Nj),types:S.list(xTo),baseProperties:S.list(yx)});var HTo=S.objectWithoutOptionalProperties({type:S.lazy(()=>ts)}).extend(Un);var KTo=S.objectWithoutOptionalProperties({members:S.list(HTo)});var JTo=S.union(S.discriminant("type","_type"),{alias:UTo,enum:MFn,object:LTo,union:GTo,undiscriminatedUnion:KTo}).transform({transform:e=>{switch(e.type){case"alias":return Zc.alias(e);case"enum":return Zc.enum(e);case"object":return Zc.object(e);case"union":return Zc.union(e);case"undiscriminatedUnion":return Zc.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var nPa=S.objectWithoutOptionalProperties({name:Oa.optional(),shape:S.lazy(()=>IFn)}).extend(eGt).extend(Un);var $To=S.union("type",{any:S.object({}),api:S.object({}),boolValue:S.object({}),bytesValue:S.object({}),doubleValue:S.object({}),duration:S.object({}),empty:S.object({}),enum:S.object({}),enumValue:S.object({}),field:S.object({}),fieldCardinality:S.object({}),fieldKind:S.object({}),fieldMask:S.object({}),floatValue:S.object({}),int32Value:S.object({}),int64Value:S.object({}),listValue:S.object({}),method:S.object({}),mixin:S.object({}),nullValue:S.object({}),option:S.object({}),sourceContext:S.object({}),stringValue:S.object({}),struct:S.object({}),syntax:S.object({}),timestamp:S.object({}),type:S.object({}),uint32Value:S.object({}),uint64Value:S.object({}),value:S.object({})}).transform({transform:e=>{switch(e.type){case"any":return ln.any();case"api":return ln.api();case"boolValue":return ln.boolValue();case"bytesValue":return ln.bytesValue();case"doubleValue":return ln.doubleValue();case"duration":return ln.duration();case"empty":return ln.empty();case"enum":return ln.enum();case"enumValue":return ln.enumValue();case"field":return ln.field();case"fieldCardinality":return ln.fieldCardinality();case"fieldKind":return ln.fieldKind();case"fieldMask":return ln.fieldMask();case"floatValue":return ln.floatValue();case"int32Value":return ln.int32Value();case"int64Value":return ln.int64Value();case"listValue":return ln.listValue();case"method":return ln.method();case"mixin":return ln.mixin();case"nullValue":return ln.nullValue();case"option":return ln.option();case"sourceContext":return ln.sourceContext();case"stringValue":return ln.stringValue();case"struct":return ln.struct();case"syntax":return ln.syntax();case"timestamp":return ln.timestamp();case"type":return ln.type();case"uint32Value":return ln.uint32Value();case"uint64Value":return ln.uint64Value();case"value":return ln.value();default:return e}},untransform:({_visit:e,...t})=>t});var YTo=S.objectWithoutOptionalProperties({file:wFn,name:Oa});var XTo=S.union("type",{wellKnown:S.object({value:$To}),userDefined:YTo}).transform({transform:e=>{switch(e.type){case"wellKnown":return Bh.wellKnown(e.value);case"userDefined":return Bh.userDefined(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZTo=S.union("type",{proto:S.object({value:XTo})}).transform({transform:e=>{switch(e.type){case"proto":return Qvi.proto(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var kTo=S.objectWithoutOptionalProperties({name:Nj,shape:JTo,autogeneratedExamples:S.list(nPa),userProvidedExamples:S.list(nPa),v2Examples:lz.optional(),referencedTypes:S.set(xQ),encoding:SFn.optional(),source:ZTo.optional(),inline:S.boolean().optional()}).extend(TC);var eRo=Oa;var tRo=S.enum_(["GET","POST"]);var rRo=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts)}).extend(sCi);var iRo=S.objectWithoutOptionalProperties({name:Oa,extends:S.list(Nj),properties:S.list(rRo)});var nRo=S.objectWithoutOptionalProperties({payloadType:S.lazy(()=>ts)}).extend(Un);var aRo=S.union("type",{inlinedPayload:iRo,reference:nRo}).transform({transform:e=>{switch(e.type){case"inlinedPayload":return WQ.inlinedPayload(e);case"reference":return WQ.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var oRo=S.objectWithoutOptionalProperties({name:Oa.optional(),payload:S.lazyObject(()=>xl)}).extend(Un);var uRo=S.objectWithoutOptionalProperties({id:tCo,name:eRo,displayName:S.string().optional(),method:tRo,headers:S.list(bx),payload:aRo,examples:S.list(oRo).optional(),v2Examples:Nqo.optional()}).extend(TC);var sRo=S.list(uRo);var cRo=Oa;var CFn=S.string();var lRo=S.enum_(["client","server"]);var fRo=S.objectWithoutOptionalProperties({name:Ec,valueType:S.lazy(()=>ts)}).extend(sCi);var dRo=S.objectWithoutOptionalProperties({name:Oa,extends:S.list(Nj),properties:S.list(fRo)});var pRo=S.objectWithoutOptionalProperties({bodyType:S.lazy(()=>ts)}).extend(Un);var _Ro=S.union("type",{inlinedBody:dRo,reference:pRo}).transform({transform:e=>{switch(e.type){case"inlinedBody":return sz.inlinedBody(e);case"reference":return sz.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var hRo=S.objectWithoutOptionalProperties({type:CFn,displayName:S.string().optional(),origin:lRo,body:_Ro}).extend(TC);var yRo=S.union("type",{inlinedBody:PFn,reference:S.lazyObject(()=>xl)}).transform({transform:e=>{switch(e.type){case"inlinedBody":return ghe.inlinedBody(e);case"reference":return ghe.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var bRo=S.objectWithoutOptionalProperties({type:CFn,body:yRo});var vRo=S.objectWithoutOptionalProperties({name:Oa.optional(),url:S.string(),pathParameters:S.list(yCi),headers:S.list(QKi),queryParameters:S.list(mFn),messages:S.list(bRo)}).extend(Un);var gRo=S.objectWithoutOptionalProperties({name:cRo,displayName:S.string().optional(),baseUrl:Ohe.optional(),path:B0e,auth:S.boolean(),headers:S.list(bx),queryParameters:S.list(oCi),pathParameters:S.list(uFt),messages:S.list(hRo),examples:S.list(vRo),v2Examples:zqo.optional()}).extend(TC);var ORo=S.objectWithoutOptionalProperties({pointsTo:Z9t});var qFn=S.objectWithoutOptionalProperties({fernFilepath:M0e,service:X9t.optional(),types:S.list(xQ),errors:S.list(lCi),webhooks:KNn.optional(),websocket:JNn.optional(),subpackages:S.list(Z9t),hasEndpointsInTree:S.boolean(),navigationConfig:ORo.optional()}).extend(Un);var ARo=S.objectWithoutOptionalProperties({name:Oa,displayName:cCi.optional()}).extend(qFn);var mRo=S.objectWithoutOptionalProperties({discriminant:Ec,contentProperty:Ec});var PRo=S.union("type",{statusCode:S.object({}),property:mRo}).transform({transform:e=>{switch(e.type){case"statusCode":return vhe.statusCode();case"property":return vhe.property(e);default:return e}},untransform:({_visit:e,...t})=>t});var jRo=S.objectWithoutOptionalProperties({header:S.stringLiteral("User-Agent"),value:S.string()});var wRo=S.objectWithoutOptionalProperties({language:S.string(),sdkName:S.string(),sdkVersion:S.string(),userAgent:jRo.optional()});var ERo=S.objectWithoutOptionalProperties({isAuthMandatory:S.boolean(),hasStreamingEndpoints:S.boolean(),hasPaginatedEndpoints:S.boolean(),hasFileDownloadEndpoints:S.boolean(),platformHeaders:wRo});var SRo=S.objectWithoutOptionalProperties({id:lFn,name:Oa,type:S.lazy(()=>ts)}).extend(Un);var MRo=S.objectWithoutOptionalProperties({typesReferencedOnlyByService:S.record(X9t,S.list(xQ)),sharedTypes:S.list(xQ)});var DRo=S.objectWithoutOptionalProperties({title:S.string(),language:AFn,content:S.string()});var BRo=S.enum_(["minimal","comprehensive"]);var IRo=S.objectWithoutOptionalProperties({defaultEndpoint:Uvi.optional(),bannerLink:S.string().optional(),introduction:S.string().optional(),apiReferenceLink:S.string().optional(),apiName:S.string().optional(),disabledFeatures:S.list(ePa).optional(),whiteLabel:S.boolean().optional(),features:S.record(ePa,S.list(Uvi)).optional(),customSections:S.list(DRo).optional(),exampleStyle:BRo.optional()});var CRo=S.string();var qRo=S.objectWithoutOptionalProperties({id:CRo,protoRootUrl:S.string()});var TRo=S.union("type",{proto:qRo,openapi:S.object({})}).transform({transform:e=>{switch(e.type){case"proto":return k6.proto(e);case"openapi":return k6.openapi();default:return e}},untransform:({_visit:e,...t})=>t});var RRo=S.objectWithoutOptionalProperties({sources:S.list(TRo)});var zRo=S.objectWithoutOptionalProperties({apiKey:S.string(),workspaceId:S.string(),collectionId:S.string().optional()});var NRo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional(),tokenEnvironmentVariable:S.string()});var FRo=S.objectWithoutOptionalProperties({coordinate:S.string().optional(),version:S.string().optional(),usernameEnvironmentVariable:S.string(),passwordEnvironmentVariable:S.string(),mavenUrlEnvironmentVariable:S.string()});var QRo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional()});var URo=S.objectWithoutOptionalProperties({version:S.string().optional(),packageName:S.string().optional()});var bCi=S.union("type",{postman:zRo,npm:NRo,maven:FRo,pypi:QRo,crates:URo}).transform({transform:e=>{switch(e.type){case"postman":return PB.postman(e);case"npm":return PB.npm(e);case"maven":return PB.maven(e);case"pypi":return PB.pypi(e);case"crates":return PB.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var LRo=S.objectWithoutOptionalProperties({owner:S.string(),repo:S.string(),uri:S.string().optional(),token:S.string().optional(),mode:S.stringLiteral("pull-request").optional(),branch:S.string().optional(),target:bCi});var VRo=S.objectWithoutOptionalProperties({target:bCi});var WRo=S.objectWithoutOptionalProperties({generateFullProject:S.boolean(),publishTarget:bCi.optional()});var xRo=S.union("type",{github:LRo,direct:VRo,filesystem:WRo}).transform({transform:e=>{switch(e.type){case"github":return $9t.github(e);case"direct":return $9t.direct(e);case"filesystem":return $9t.filesystem(e);default:return e}},untransform:({_visit:e,...t})=>t});var GRo=S.objectWithoutOptionalProperties({cliVersion:S.string(),generatorName:S.string(),generatorVersion:S.string(),generatorConfig:S.unknown().optional()});var xu_=S.objectWithoutOptionalProperties({fdrApiDefinitionId:S.string().optional(),apiVersion:vTo.optional(),apiName:Oa,apiDisplayName:S.string().optional(),apiDocs:S.string().optional(),auth:kIo,headers:S.list(bx),idempotencyHeaders:S.list(bx),types:S.record(xQ,kTo),services:S.record(X9t,yTo),webhookGroups:S.record(KNn,sRo),websocketChannels:S.record(JNn,gRo).optional(),errors:S.record(lCi,Aqo),subpackages:S.record(Z9t,ARo),rootPackage:qFn,constants:rCo,environments:gqo.optional(),basePath:B0e.optional(),pathParameters:S.list(uFt),errorDiscriminationStrategy:PRo,sdkConfig:ERo,variables:S.list(SRo),serviceTypeReferenceInfo:MRo,readmeConfig:IRo.optional(),sourceConfig:RRo.optional(),publishConfig:xRo.optional(),dynamic:sqo.optional(),selfHosted:S.boolean().optional(),audiences:S.list(TIo).optional(),generationMetadata:GRo.optional(),apiPlayground:S.boolean().optional()});var Tnc={};Kt(Tnc,{CsharpProtobufFileOptions:()=>nTo,ProtobufFile:()=>wFn,ProtobufFileOptions:()=>aTo,ProtobufMethodType:()=>sTo,ProtobufService:()=>oTo,ProtobufType:()=>XTo,UserDefinedProtobufType:()=>YTo,WellKnownProtobufType:()=>$To});var Rnc={};Kt(Rnc,{CratesPublishTarget:()=>URo,DirectPublish:()=>VRo,Filesystem:()=>WRo,GithubPublish:()=>LRo,MavenPublishTarget:()=>FRo,NpmPublishTarget:()=>NRo,PostmanPublishTarget:()=>zRo,PublishTarget:()=>bCi,PublishingConfig:()=>xRo,PypiPublishTarget:()=>QRo});var znc={};Kt(znc,{AliasTypeDeclaration:()=>UTo,Base64Type:()=>zTo,BigIntegerType:()=>NTo,BooleanType:()=>BTo,ContainerType:()=>BFn,DateTimeType:()=>TTo,DateType:()=>qTo,DeclaredTypeName:()=>Nj,DoubleType:()=>DTo,DoubleValidationRules:()=>MTo,Encoding:()=>SFn,EnumTypeDeclaration:()=>MFn,EnumTypeReference:()=>Gu_,EnumValue:()=>Lvi,ExampleAliasType:()=>XRo,ExampleContainer:()=>uzo,ExampleDatetime:()=>ozo,ExampleEnumType:()=>YRo,ExampleExtraObjectProperty:()=>ezo,ExampleKeyValuePair:()=>hzo,ExampleListContainer:()=>lzo,ExampleLiteralContainer:()=>czo,ExampleMapContainer:()=>_zo,ExampleNamedType:()=>szo,ExampleNullableContainer:()=>pzo,ExampleObjectProperty:()=>RFn,ExampleObjectType:()=>TFn,ExampleObjectTypeWithTypeId:()=>nzo,ExampleOptionalContainer:()=>dzo,ExamplePrimitive:()=>zFn,ExampleSetContainer:()=>fzo,ExampleSingleUnionType:()=>rzo,ExampleSingleUnionTypeProperties:()=>izo,ExampleType:()=>nPa,ExampleTypeReference:()=>xl,ExampleTypeReferenceShape:()=>azo,ExampleTypeShape:()=>IFn,ExampleUndiscriminatedUnionType:()=>kRo,ExampleUnionBaseProperty:()=>tzo,ExampleUnionType:()=>ZRo,FloatType:()=>STo,IntegerType:()=>PTo,IntegerValidationRules:()=>mTo,JsonEncoding:()=>_To,Literal:()=>JRo,LongType:()=>jTo,MapType:()=>$Ro,NamedType:()=>KRo,NamedTypeDefault:()=>HRo,ObjectProperty:()=>yx,ObjectPropertyAccess:()=>uCi,ObjectTypeDeclaration:()=>LTo,PrimitiveType:()=>DFn,PrimitiveTypeV1:()=>ATo,PrimitiveTypeV2:()=>FTo,ProtoEncoding:()=>hTo,ResolvedNamedType:()=>OTo,ResolvedTypeReference:()=>QTo,ShapeType:()=>gTo,SingleUnionType:()=>xTo,SingleUnionTypeProperties:()=>WTo,SingleUnionTypeProperty:()=>VTo,Source:()=>ZTo,StringType:()=>CTo,StringValidationRules:()=>ITo,Type:()=>JTo,TypeDeclaration:()=>kTo,TypeReference:()=>ts,Uint64Type:()=>ETo,UintType:()=>wTo,UndiscriminatedUnionMember:()=>HTo,UndiscriminatedUnionTypeDeclaration:()=>KTo,UnionTypeDeclaration:()=>GTo,UuidType:()=>RTo});var HRo=S.union("type",{enum:Lvi}).transform({transform:e=>{switch(e.type){case"enum":return QNn.enum(e);default:return e}},untransform:({_visit:e,...t})=>t});var KRo=S.objectWithoutOptionalProperties({typeId:xQ,fernFilepath:M0e,name:Oa,displayName:cCi.optional(),default:HRo.optional(),inline:S.boolean().optional()});var ts=S.union(S.discriminant("type","_type"),{container:S.object({container:S.lazy(()=>BFn)}),named:KRo,primitive:S.object({primitive:DFn}),unknown:S.object({})}).transform({transform:e=>{switch(e.type){case"container":return ni.container(e.container);case"named":return ni.named(e);case"primitive":return ni.primitive(e.primitive);case"unknown":return ni.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Gu_=S.objectWithoutOptionalProperties({default:Lvi.optional(),name:Nj});var JRo=S.union("type",{string:S.object({string:S.string()}),boolean:S.object({boolean:S.boolean()})}).transform({transform:e=>{switch(e.type){case"string":return uz.string(e.string);case"boolean":return uz.boolean(e.boolean);default:return e}},untransform:({_visit:e,...t})=>t});var BFn=S.union(S.discriminant("type","_type"),{list:S.object({list:S.lazy(()=>ts)}),map:S.lazyObject(()=>$Ro),nullable:S.object({nullable:S.lazy(()=>ts)}),optional:S.object({optional:S.lazy(()=>ts)}),set:S.object({set:S.lazy(()=>ts)}),literal:S.object({literal:JRo})}).transform({transform:e=>{switch(e.type){case"list":return es.list(e.list);case"map":return es.map(e);case"nullable":return es.nullable(e.nullable);case"optional":return es.optional(e.optional);case"set":return es.set(e.set);case"literal":return es.literal(e.literal);default:return e}},untransform:({_visit:e,...t})=>t});var $Ro=S.objectWithoutOptionalProperties({keyType:S.lazy(()=>ts),valueType:S.lazy(()=>ts)});var YRo=S.objectWithoutOptionalProperties({value:Ec});var IFn=S.union("type",{alias:S.lazyObject(()=>XRo),enum:YRo,object:S.lazyObject(()=>TFn),union:S.lazyObject(()=>ZRo),undiscriminatedUnion:S.lazyObject(()=>kRo)}).transform({transform:e=>{switch(e.type){case"alias":return Ih.alias(e);case"enum":return Ih.enum(e);case"object":return Ih.object(e);case"union":return Ih.union(e);case"undiscriminatedUnion":return Ih.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var XRo=S.objectWithoutOptionalProperties({value:S.lazyObject(()=>xl)});var TFn=S.objectWithoutOptionalProperties({properties:S.list(S.lazyObject(()=>RFn)),extraProperties:S.list(S.lazyObject(()=>ezo)).optional()});var RFn=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl),propertyAccess:uCi.optional(),originalTypeDeclaration:Nj});var ezo=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl)});var ZRo=S.objectWithoutOptionalProperties({discriminant:Ec,singleUnionType:S.lazyObject(()=>rzo),extendProperties:S.list(S.lazyObject(()=>RFn)).optional(),baseProperties:S.list(S.lazyObject(()=>tzo)).optional()});var tzo=S.objectWithoutOptionalProperties({name:Ec,value:S.lazyObject(()=>xl)});var kRo=S.objectWithoutOptionalProperties({index:S.number(),singleUnionType:S.lazyObject(()=>xl)});var rzo=S.objectWithoutOptionalProperties({wireDiscriminantValue:Ec,shape:S.lazy(()=>izo)});var izo=S.union("type",{samePropertiesAsObject:S.lazyObject(()=>nzo),singleProperty:S.lazyObject(()=>xl),noProperties:S.object({})}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return jB.samePropertiesAsObject(e);case"singleProperty":return jB.singleProperty(e);case"noProperties":return jB.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var xl=S.objectWithoutOptionalProperties({shape:S.lazy(()=>azo)}).extend(eGt);var ozo=S.objectWithoutOptionalProperties({datetime:S.date(),raw:S.string().optional()});var zFn=S.union("type",{integer:S.object({integer:S.number()}),long:S.object({long:S.number()}),uint:S.object({uint:S.number()}),uint64:S.object({uint64:S.number()}),float:S.object({float:S.number()}),double:S.object({double:S.number()}),boolean:S.object({boolean:S.boolean()}),string:S.object({string:eCo}),date:S.object({date:S.string()}),datetime:ozo,uuid:S.object({uuid:S.string()}),base64:S.object({base64:S.string()}),bigInteger:S.object({bigInteger:S.string()})}).transform({transform:e=>{switch(e.type){case"integer":return Dn.integer(e.integer);case"long":return Dn.long(e.long);case"uint":return Dn.uint(e.uint);case"uint64":return Dn.uint64(e.uint64);case"float":return Dn.float(e.float);case"double":return Dn.double(e.double);case"boolean":return Dn.boolean(e.boolean);case"string":return Dn.string(e.string);case"date":return Dn.date(e.date);case"datetime":return Dn.datetime(e);case"uuid":return Dn.uuid(e.uuid);case"base64":return Dn.base64(e.base64);case"bigInteger":return Dn.bigInteger(e.bigInteger);default:return e}},untransform:({_visit:e,...t})=>t});var azo=S.union("type",{primitive:S.object({primitive:zFn}),container:S.object({container:S.lazy(()=>uzo)}),unknown:S.object({unknown:S.unknown()}),named:S.lazyObject(()=>szo)}).transform({transform:e=>{switch(e.type){case"primitive":return lu.primitive(e.primitive);case"container":return lu.container(e.container);case"unknown":return lu.unknown(e.unknown);case"named":return lu.named(e);default:return e}},untransform:({_visit:e,...t})=>t});var czo=S.objectWithoutOptionalProperties({literal:zFn});var uzo=S.union("type",{list:S.lazyObject(()=>lzo),set:S.lazyObject(()=>fzo),optional:S.lazyObject(()=>dzo),nullable:S.lazyObject(()=>pzo),map:S.lazyObject(()=>_zo),literal:czo}).transform({transform:e=>{switch(e.type){case"list":return op.list(e);case"set":return op.set(e);case"optional":return op.optional(e);case"nullable":return op.nullable(e);case"map":return op.map(e);case"literal":return op.literal(e);default:return e}},untransform:({_visit:e,...t})=>t});var lzo=S.objectWithoutOptionalProperties({list:S.list(S.lazyObject(()=>xl)),itemType:S.lazy(()=>ts)});var fzo=S.objectWithoutOptionalProperties({set:S.list(S.lazyObject(()=>xl)),itemType:S.lazy(()=>ts)});var dzo=S.objectWithoutOptionalProperties({optional:S.lazyObject(()=>xl).optional(),valueType:S.lazy(()=>ts)});var pzo=S.objectWithoutOptionalProperties({nullable:S.lazyObject(()=>xl).optional(),valueType:S.lazy(()=>ts)});var _zo=S.objectWithoutOptionalProperties({map:S.list(S.lazyObject(()=>hzo)),keyType:S.lazy(()=>ts),valueType:S.lazy(()=>ts)});var hzo=S.objectWithoutOptionalProperties({key:S.lazyObject(()=>xl),value:S.lazyObject(()=>xl)});var szo=S.objectWithoutOptionalProperties({typeName:Nj,shape:S.lazy(()=>IFn)});var nzo=S.objectWithoutOptionalProperties({typeId:xQ,object:S.lazyObject(()=>TFn)});var Nnc={};Kt(Nnc,{VariableDeclaration:()=>SRo,VariableId:()=>lFn});var Fnc={};Kt(Fnc,{ExampleWebhookCall:()=>oRo,InlinedWebhookPayload:()=>iRo,InlinedWebhookPayloadProperty:()=>rRo,Webhook:()=>uRo,WebhookGroup:()=>sRo,WebhookHttpMethod:()=>tRo,WebhookName:()=>eRo,WebhookPayload:()=>aRo,WebhookPayloadReference:()=>nRo});var Qnc={};Kt(Qnc,{ExampleWebSocketMessage:()=>bRo,ExampleWebSocketMessageBody:()=>yRo,ExampleWebSocketSession:()=>vRo,InlinedWebSocketMessageBody:()=>dRo,InlinedWebSocketMessageBodyProperty:()=>fRo,WebSocketChannel:()=>gRo,WebSocketMessage:()=>hRo,WebSocketMessageBody:()=>_Ro,WebSocketMessageBodyReference:()=>pRo,WebSocketMessageId:()=>CFn,WebSocketMessageOrigin:()=>lRo,WebSocketName:()=>cRo});var PD={};Kt(PD,{AvailabilityStatusSchema:()=>Ku_,FernDefinitionError:()=>sPa,FernDefinitionTimeoutError:()=>cPa,FormDataBodyEncodingStyle:()=>is_,HttpMethodSchema:()=>rs_,ObjectPropertyAccess:()=>os_,StreamFormat:()=>ns_,SupportedSdkLanguageSchema:()=>Zu_,WebSocketOrigin:()=>fs_,WebhookMethodSchema:()=>ls_,auth:()=>Hu_,availability:()=>Lnc,commons:()=>Ju_,encoding:()=>$u_,environments:()=>Yu_,errors:()=>Xu_,examples:()=>Vnc,file:()=>ku_,pagination:()=>es_,products:()=>ts_,serialization:()=>hac,service:()=>Wnc,source:()=>as_,types:()=>xnc,validation:()=>us_,variables:()=>ss_,versioning:()=>cs_,webhooks:()=>Gnc,websocket:()=>Hnc});var Hu_={};var Lnc={};Kt(Lnc,{AvailabilityStatusSchema:()=>Ku_});var Ku_={InDevelopment:"in-development",PreRelease:"pre-release",Deprecated:"deprecated",GenerallyAvailable:"generally-available"};var Ju_={};var $u_={};var Yu_={};var Xu_={};var Vnc={};Kt(Vnc,{SupportedSdkLanguageSchema:()=>Zu_});var Zu_={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",Csharp2:"c#"};var ku_={};var es_={};var ts_={};var Wnc={};Kt(Wnc,{FormDataBodyEncodingStyle:()=>is_,HttpMethodSchema:()=>rs_,StreamFormat:()=>ns_});var rs_={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"};var is_={Json:"json",Exploded:"exploded",Form:"form"};var ns_={Sse:"sse",Json:"json"};var as_={};var xnc={};Kt(xnc,{ObjectPropertyAccess:()=>os_});var os_={ReadOnly:"read-only",WriteOnly:"write-only"};var us_={};var ss_={};var cs_={};var Gnc={};Kt(Gnc,{WebhookMethodSchema:()=>ls_});var ls_={Post:"POST",Get:"GET"};var Hnc={};Kt(Hnc,{WebSocketOrigin:()=>fs_});var fs_={Client:"client",Server:"server"};var hac={};Kt(hac,{AliasSchema:()=>INo,AnyAuthItem:()=>Ozo,AnyAuthSchemesSchema:()=>Azo,ApiAuthSchema:()=>mzo,AuthSchemeDeclarationSchema:()=>Fzo,AuthSchemeKey:()=>UFn,AuthSchemeReferenceSchema:()=>VFn,AuthScope:()=>LFn,AuthVariable:()=>LKi,AvailabilitySchema:()=>Uzo,AvailabilityStatusSchema:()=>xFn,AvailabilityUnionSchema:()=>Lzo,BaseTypeDeclarationSchema:()=>q0e,BaseTypeReferenceSchema:()=>JFn,BasicAuthSchemeSchema:()=>Izo,BearerAuthSchemeSchema:()=>Nzo,CasingOverridesSchema:()=>yNo,CursorPaginationSchema:()=>nFo,CustomPaginationSchema:()=>oFo,DeclarationSchema:()=>nGt,DeclarationWithNameSchema:()=>Qs_,DeclarationWithoutDocsSchema:()=>Gzo,DefinitionFileSchema:()=>PFo,DiscriminatedUnionSchema:()=>SNo,EncodingSchema:()=>GFn,EnumSchema:()=>gNo,EnumValue:()=>vNo,EnumValueSchema:()=>bNo,EnvironmentSchema:()=>$zo,ErrorDeclarationSchema:()=>Zzo,ErrorDiscriminationSchema:()=>BFo,ExampleBodyResponseSchema:()=>tNo,ExampleCodeSampleSchema:()=>cNo,ExampleCodeSampleSchemaLanguage:()=>sNo,ExampleCodeSampleSchemaSdk:()=>uNo,ExampleEndpointCallArraySchema:()=>Us_,ExampleEndpointCallSchema:()=>KFn,ExampleResponseSchema:()=>aNo,ExampleSseEventSchema:()=>iNo,ExampleSseResponseSchema:()=>nNo,ExampleStreamResponseSchema:()=>rNo,ExampleTypeReferenceSchema:()=>I1,ExampleTypeSchema:()=>HFn,ExampleTypeValueSchema:()=>Xzo,ExampleWebSocketMessage:()=>kzo,ExampleWebSocketSession:()=>eNo,ExampleWebhookCallSchema:()=>lNo,Export:()=>EFo,ExportDetailed:()=>wFo,FormDataBodyEncodingStyle:()=>WNo,GrpcTransport:()=>qNo,HeaderAuthSchemeSchema:()=>Bzo,HttpEndpointAuth:()=>FNo,HttpEndpointSchema:()=>lFo,HttpEndpointSecurity:()=>NNo,HttpEndpointSecurityItem:()=>zNo,HttpHeaderSchema:()=>T0e,HttpInlineFileRequestBodyPropertySchema:()=>xNo,HttpInlineRequestBodyPropertySchema:()=>GNo,HttpInlineRequestBodySchema:()=>HNo,HttpMethodSchema:()=>TNo,HttpPathParameterSchema:()=>aGt,HttpQueryParameterSchema:()=>YFn,HttpReferencedRequestBodySchema:()=>VNo,HttpRequest:()=>$No,HttpRequestBodySchema:()=>KNo,HttpRequestSchema:()=>JNo,HttpResponseSchema:()=>XNo,HttpResponseSchemaDetailed:()=>YNo,HttpResponseStreamSchema:()=>eFo,HttpResponseStreamSchemaDetailed:()=>kNo,HttpServiceSchema:()=>fFo,InferredAuthenticatedRequestHeader:()=>qzo,InferredBearerAuthSchema:()=>zzo,InferredGetTokenEndpointSchema:()=>Rzo,InferredGetTokenEndpointSchemaObject:()=>Tzo,MultipleBaseUrlsEnvironmentSchema:()=>Jzo,Navigation:()=>jFo,NumberValidationSchema:()=>Wzo,OAuthAccessTokenRequestPropertiesSchema:()=>Pzo,OAuthAccessTokenResponsePropertiesSchema:()=>jzo,OAuthGetTokenEndpointSchema:()=>wzo,OAuthRefreshTokenEndpointSchema:()=>Mzo,OAuthRefreshTokenRequestPropertiesSchema:()=>Ezo,OAuthRefreshTokenResponsePropertiesSchema:()=>Szo,OAuthSchemeSchema:()=>Dzo,ObjectExtendsSchema:()=>I0e,ObjectPropertyAccess:()=>fNo,ObjectPropertySchema:()=>ACi,ObjectPropertyWithAccessSchema:()=>dNo,ObjectSchema:()=>hNo,OffsetPaginationSchema:()=>aFo,OpenApiSourceSchema:()=>pNo,PackageMarkerFileSchema:()=>Ls_,Pagination:()=>uFo,PaginationSchema:()=>XFn,ProductDeclarationHeaderObjectSchema:()=>QFo,ProductDeclarationHeaderSchema:()=>UFo,ProductDeclarationSchema:()=>LFo,ProductValue:()=>FFo,ProductValueDetailed:()=>NFo,PropertyBasedErrorDiscrimination:()=>MFo,ProtobufSourceSchema:()=>_No,ProtobufTypeSchema:()=>Hzo,QueryParameterTypeReferenceDetailed:()=>QNo,ResponseError:()=>rFo,ResponseErrorWithDocsSchema:()=>tFo,ResponseErrorsSchema:()=>iFo,RetriesConfiguration:()=>cFo,RetriesDisabledSchema:()=>sFo,RootApiFileSchema:()=>Vs_,ServiceTransport:()=>$Fn,SingleBaseUrlEnvironmentSchema:()=>Kzo,SingleUndiscriminatedUnionTypeDetailedSchema:()=>MNo,SingleUndiscriminatedUnionTypeSchema:()=>DNo,SingleUnionTypeDetailedSchema:()=>wNo,SingleUnionTypeKey:()=>jNo,SingleUnionTypeKeySchema:()=>PNo,SingleUnionTypeSchema:()=>ENo,SourceSchema:()=>mCi,StatusCodeBasedErrorDiscrimination:()=>DFo,StreamFormat:()=>ZNo,StringValidationSchema:()=>Vzo,SupportedSdkLanguageSchema:()=>oNo,TokenBearerAuthSchema:()=>Czo,TypeDeclarationSchema:()=>CNo,TypeReferenceDeclarationWithEnvOverride:()=>LNo,TypeReferenceDeclarationWithEnvOverrideSchema:()=>UNo,TypeReferenceDeclarationWithName:()=>C0e,TypeReferenceDeclarationWithNameSchema:()=>Ws_,TypeReferenceDetailedSchema:()=>mNo,TypeReferenceSchema:()=>Vvi,UndiscriminatedUnionSchema:()=>BNo,UnionDiscriminant:()=>ANo,UnionDiscriminantSchema:()=>ONo,ValidationSchema:()=>OCi,VariableDeclarationDetailed:()=>IFo,VariableDeclarationSchema:()=>CFo,VariableReferenceSchema:()=>RNo,VersionDeclarationHeaderObjectSchema:()=>RFo,VersionDeclarationHeaderSchema:()=>zFo,VersionDeclarationSchema:()=>ZFn,VersionValue:()=>TFo,VersionValueDetailed:()=>qFo,WebSocketChannelInlinedMessageSchema:()=>gFo,WebSocketChannelMessageBodySchema:()=>OFo,WebSocketChannelMessageSchema:()=>AFo,WebSocketChannelReferencedMessageSchema:()=>vFo,WebSocketChannelSchema:()=>mFo,WebSocketOrigin:()=>bFo,WebhookInlinedPayloadSchema:()=>_Fo,WebhookMethodSchema:()=>dFo,WebhookPayloadSchema:()=>hFo,WebhookReferencedPayloadSchema:()=>pFo,WebhookSchema:()=>yFo,WithAudiences:()=>_z,WithAuthSchema:()=>Qzo,WithAvailability:()=>UL,WithDisplayName:()=>pz,WithDocsSchema:()=>Ta,WithEnvironmentVariable:()=>WFn,WithEnvironmentsSchema:()=>Yzo,WithHeadersSchema:()=>SFo,WithName:()=>db,WithValidation:()=>xzo,auth:()=>Xnc,availability:()=>Znc,commons:()=>knc,encoding:()=>eac,environments:()=>tac,errors:()=>rac,examples:()=>iac,file:()=>nac,pagination:()=>aac,products:()=>oac,service:()=>uac,source:()=>sac,types:()=>cac,validation:()=>lac,variables:()=>fac,versioning:()=>dac,webhooks:()=>pac,websocket:()=>_ac});var Xnc={};Kt(Xnc,{AnyAuthItem:()=>Ozo,AnyAuthSchemesSchema:()=>Azo,ApiAuthSchema:()=>mzo,AuthSchemeDeclarationSchema:()=>Fzo,AuthSchemeKey:()=>UFn,AuthSchemeReferenceSchema:()=>VFn,AuthScope:()=>LFn,AuthVariable:()=>LKi,BasicAuthSchemeSchema:()=>Izo,BearerAuthSchemeSchema:()=>Nzo,HeaderAuthSchemeSchema:()=>Bzo,InferredAuthenticatedRequestHeader:()=>qzo,InferredBearerAuthSchema:()=>zzo,InferredGetTokenEndpointSchema:()=>Rzo,InferredGetTokenEndpointSchemaObject:()=>Tzo,OAuthAccessTokenRequestPropertiesSchema:()=>Pzo,OAuthAccessTokenResponsePropertiesSchema:()=>jzo,OAuthGetTokenEndpointSchema:()=>wzo,OAuthRefreshTokenEndpointSchema:()=>Mzo,OAuthRefreshTokenRequestPropertiesSchema:()=>Ezo,OAuthRefreshTokenResponsePropertiesSchema:()=>Szo,OAuthSchemeSchema:()=>Dzo,TokenBearerAuthSchema:()=>Czo,WithAuthSchema:()=>Qzo,WithEnvironmentVariable:()=>WFn});var X={};Kt(X,{JsonError:()=>NFn,ParseError:()=>FFn,any:()=>Es_,bigint:()=>ps_,boolean:()=>Ss_,booleanLiteral:()=>ws_,date:()=>_s_,discriminant:()=>zs_,enum_:()=>bzo,getObjectLikeUtils:()=>sFt,getObjectUtils:()=>UKi,getSchemaUtils:()=>Ym,isProperty:()=>gCi,lazy:()=>hs_,lazyObject:()=>ms_,list:()=>gzo,number:()=>Ms_,object:()=>vzo,objectWithoutOptionalProperties:()=>As_,optional:()=>Knc,property:()=>bs_,record:()=>Cs_,set:()=>qs_,string:()=>Ds_,stringLiteral:()=>js_,transform:()=>Jnc,undiscriminatedUnion:()=>Rs_,union:()=>Fs_,unknown:()=>Bs_,withParsedProperties:()=>Ync});var nh={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 MA(e,t){return`Expected ${t}. Received ${tYS(e)}.`}function tYS(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 dz(e){return{...e,json:ds_(e.json),parse:ds_(e.parse)}}function ds_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1357
1357
  `)),{ok:!0,value:t}):i}}function yzo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var NFn=class e extends Error{errors;constructor(t){super(t.map(yzo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var FFn=class e extends Error{errors;constructor(t){super(t.map(yzo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Ym(e){return{optional:()=>Knc(e),transform:t=>Jnc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new FFn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new NFn(i.errors)}}}function Knc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>nh.OPTIONAL};return{...t,...Ym(t)}}function Jnc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Ym(r)}}function ps_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(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:MA(t,"bigint")}]},getType:()=>nh.BIGINT};return{...dz(e),...Ym(e)}}var rYS=/^([+-]?\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 _s_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:MA(t,"string")}]}:rYS.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:MA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:MA(t,"Date object")}]},getType:()=>nh.DATE};return{...dz(e),...Ym(e)}}function QL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...dz(r),...Ym(r)}}}function bzo(e){let t=new Set(e);return QL(nh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:MA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:MA(i,"enum")}]}:{ok:!0,value:i})()}function hs_(e){let t=$nc(e);return{...t,...Ym(t)}}function $nc(e){return{parse:(t,r)=>QFn(e).parse(t,r),json:(t,r)=>QFn(e).json(t,r),getType:()=>QFn(e).getType()}}function QFn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function aPa(e){return Object.entries(e)}function oPa(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function vCi(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 uPa(e){return Object.keys(e)}function ys_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function sFt(e){return{withParsedProperties:t=>Ync(e,t)}}function Ync(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!vCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:MA(i,"object")}]};let a=new Set(Object.keys(t)),o=oPa(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Ym(r),...sFt(r)}}function bs_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function gCi(e){return e.isProperty}function vzo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>gCi(i)?i.rawKey:r),_getParsedProperties:()=>uPa(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of aPa(e)){let f=gCi(c)?c.rawKey:o,s=gCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,Os_(s)&&a.push(f)}return vs_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of aPa(e)){let c=gCi(o)?o.valueSchema:o;Os_(c)&&n.push(a)}return vs_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return gCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>nh.OBJECT};return{...dz(t),...Ym(t),...sFt(t),...UKi(t)}}function vs_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!vCi(e))return{ok:!1,errors:[{path:a,message:MA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function UKi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>gs_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>gs_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>nh.OBJECT};return{...r,...Ym(r),...sFt(r),...UKi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>nh.OBJECT};return{...t,...Ym(t),...sFt(t),...UKi(t)}}}}function gs_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=ys_(uPa(t),s=>n.has(s)),c=r(oPa(t,o)),f=i(oPa(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function Os_(e){return!iYS(e)}function iYS(e){switch(e.getType()){case nh.ANY:case nh.UNKNOWN:case nh.OPTIONAL:return!0;default:return!1}}function As_(e){return vzo(e)}function ms_(e){let t={...$nc(e),_getRawProperties:()=>QFn(e)._getRawProperties(),_getParsedProperties:()=>QFn(e)._getParsedProperties()};return{...t,...Ym(t),...sFt(t),...UKi(t)}}function gzo(e){let t={parse:(r,i)=>Ps_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Ps_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>nh.LIST};return{...dz(t),...Ym(t)}}function Ps_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:MA(e,"list"),path:[]}]}}function js_(e){return QL(nh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`"${e}"`)}]})()}function ws_(e){return QL(nh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:MA(r,`${e.toString()}`)}]})()}var Es_=QL(nh.ANY,e=>({ok:!0,value:e}));var Ss_=QL(nh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"boolean")}]});var Ms_=QL(nh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"number")}]});var Ds_=QL(nh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:MA(e,"string")}]});var Bs_=QL(nh.UNKNOWN,e=>({ok:!0,value:e}));function Cs_(e,t){let r={parse:(i,n)=>Is_({value:i,isKeyNumeric:e.getType()===nh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Is_({value:i,isKeyNumeric:e.getType()===nh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>nh.RECORD};return{...dz(r),...Ym(r)}}function Is_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return vCi(e)?aPa(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:MA(e,"object")}]}}function qs_(e){let t=gzo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:MA(i,"Set")}]},getType:()=>nh.SET};return{...dz(r),...Ym(r)}}function Rs_(e){let t={parse:(r,i)=>Ts_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Ts_((n,a)=>n.json(r,a),e,i),getType:()=>nh.UNDISCRIMINATED_UNION};return{...dz(t),...Ym(t)}}function Ts_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function zs_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Fs_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=bzo(uPa(t)),a={parse:(o,c)=>Ns_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>Ns_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>nh.UNION};return{...dz(a),...Ym(a),...sFt(a)}}function Ns_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!vCi(e))return{ok:!1,errors:[{path:c,message:MA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(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 p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var UFn=X.string();var LFn=X.string();var Ta=X.object({docs:X.string().optional()});var VFn=X.object({scheme:X.string()}).extend(Ta);var Ozo=X.undiscriminatedUnion([X.string(),VFn]);var Azo=X.object({any:X.list(Ozo)}).extend(Ta);var mzo=X.undiscriminatedUnion([X.string(),VFn,Azo]);var Pzo=X.object({"client-id":X.string().optional(),"client-secret":X.string().optional(),scopes:X.string().optional()});var jzo=X.object({"access-token":X.string().optional(),"expires-in":X.string().optional(),"refresh-token":X.string().optional()});var wzo=X.object({endpoint:X.string(),"request-properties":Pzo.optional(),"response-properties":jzo.optional()});var Ezo=X.object({"refresh-token":X.string()});var Szo=X.object({"access-token":X.string().optional(),"expires-in":X.string().optional(),"refresh-token":X.string().optional()});var Mzo=X.object({endpoint:X.string(),"request-properties":Ezo.optional(),"response-properties":Szo.optional()});var Dzo=X.object({scheme:X.stringLiteral("oauth"),type:X.stringLiteral("client-credentials"),scopes:X.list(LFn).optional(),"client-id-env":X.string().optional(),"client-secret-env":X.string().optional(),"token-prefix":X.string().optional(),"token-header":X.string().optional(),"get-token":wzo,"refresh-token":Mzo.optional()}).extend(Ta);var WFn=X.object({env:X.string().optional()});var db=X.object({name:X.string().optional()});var Bzo=X.object({header:X.string(),type:X.string().optional(),prefix:X.string().optional()}).extend(WFn).extend(db).extend(Ta);var LKi=X.object({}).extend(WFn).extend(db);var Izo=X.object({scheme:X.stringLiteral("basic"),username:LKi.optional(),password:LKi.optional()}).extend(Ta);var Czo=X.object({scheme:X.stringLiteral("bearer"),token:LKi.optional()}).extend(Ta);var qzo=X.object({"response-property":X.string(),"header-name":X.string(),"value-prefix":X.string().optional()});var Tzo=X.object({endpoint:X.string(),"expiry-response-property":X.string().optional(),"authenticated-request-headers":X.list(qzo).optional()});var Rzo=X.undiscriminatedUnion([X.string(),Tzo]);var zzo=X.object({scheme:X.stringLiteral("bearer"),"get-token":Rzo}).extend(Ta);var Nzo=X.undiscriminatedUnion([Czo,zzo]);var Fzo=X.undiscriminatedUnion([Dzo,Bzo,Izo,Nzo]);var Qzo=X.object({auth:mzo.optional(),"auth-schemes":X.record(UFn,Fzo).optional()});var Znc={};Kt(Znc,{AvailabilitySchema:()=>Uzo,AvailabilityStatusSchema:()=>xFn,AvailabilityUnionSchema:()=>Lzo});var xFn=X.enum_(["in-development","pre-release","deprecated","generally-available"]);var Uzo=X.object({status:xFn,message:X.string().optional()});var Lzo=X.undiscriminatedUnion([xFn,Uzo]);var knc={};Kt(knc,{DeclarationSchema:()=>nGt,DeclarationWithNameSchema:()=>Qs_,DeclarationWithoutDocsSchema:()=>Gzo,WithAudiences:()=>_z,WithAvailability:()=>UL,WithDisplayName:()=>pz,WithDocsSchema:()=>Ta,WithName:()=>db,WithValidation:()=>xzo});var UL=X.object({availability:Lzo.optional()});var pz=X.object({"display-name":X.string().optional()});var Vzo=X.object({minLength:X.number().optional(),maxLength:X.number().optional(),pattern:X.string().optional(),format:X.string().optional()});var Wzo=X.object({min:X.number().optional(),max:X.number().optional(),exclusiveMin:X.boolean().optional(),exclusiveMax:X.boolean().optional(),multipleOf:X.number().optional()});var OCi=X.undiscriminatedUnion([Vzo,Wzo]);var xzo=X.object({validation:OCi.optional()});var _z=X.object({audiences:X.list(X.string()).optional()});var nGt=X.object({}).extend(Ta).extend(UL).extend(_z);var Gzo=X.object({}).extend(UL).extend(_z);var Qs_=X.object({}).extend(nGt).extend(db);var eac={};Kt(eac,{EncodingSchema:()=>GFn,ProtobufTypeSchema:()=>Hzo});var Hzo=X.object({type:X.string()});var GFn=X.object({proto:Hzo.optional()});var tac={};Kt(tac,{EnvironmentSchema:()=>$zo,MultipleBaseUrlsEnvironmentSchema:()=>Jzo,SingleBaseUrlEnvironmentSchema:()=>Kzo,WithEnvironmentsSchema:()=>Yzo});var Kzo=X.object({url:X.string()}).extend(_z).extend(Ta);var Jzo=X.object({urls:X.record(X.string(),X.string())}).extend(_z).extend(Ta);var $zo=X.undiscriminatedUnion([X.string(),Kzo,Jzo]);var Yzo=X.object({"default-url":X.string().optional(),"default-environment":X.string().optional(),environments:X.record(X.string(),$zo).optional()});var rac={};Kt(rac,{ErrorDeclarationSchema:()=>Zzo});var Xzo=X.unknown();var HFn=X.object({value:Xzo}).extend(db).extend(Ta);var Zzo=X.object({"status-code":X.number(),type:X.string().optional(),examples:X.list(HFn).optional()}).extend(Ta);var iac={};Kt(iac,{ExampleBodyResponseSchema:()=>tNo,ExampleCodeSampleSchema:()=>cNo,ExampleCodeSampleSchemaLanguage:()=>sNo,ExampleCodeSampleSchemaSdk:()=>uNo,ExampleEndpointCallArraySchema:()=>Us_,ExampleEndpointCallSchema:()=>KFn,ExampleResponseSchema:()=>aNo,ExampleSseEventSchema:()=>iNo,ExampleSseResponseSchema:()=>nNo,ExampleStreamResponseSchema:()=>rNo,ExampleTypeReferenceSchema:()=>I1,ExampleTypeSchema:()=>HFn,ExampleTypeValueSchema:()=>Xzo,ExampleWebSocketMessage:()=>kzo,ExampleWebSocketSession:()=>eNo,ExampleWebhookCallSchema:()=>lNo,SupportedSdkLanguageSchema:()=>oNo});var I1=X.unknown();var kzo=X.object({type:X.string(),body:X.unknown()});var eNo=X.object({"path-parameters":X.record(X.string(),I1).optional(),"query-parameters":X.record(X.string(),I1).optional(),headers:X.record(X.string(),I1).optional(),messages:X.list(kzo)}).extend(db).extend(Ta);var tNo=X.object({error:X.string().optional(),body:I1.optional()});var rNo=X.object({stream:X.list(I1)});var iNo=X.object({event:X.string(),data:I1.optional()});var nNo=X.object({stream:X.list(iNo)});var aNo=X.undiscriminatedUnion([tNo,rNo,nNo]);var oNo=X.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]);var uNo=X.object({sdk:oNo,code:X.string()}).extend(Ta).extend(db);var sNo=X.object({language:X.string(),code:X.string(),install:X.string().optional()}).extend(Ta).extend(db);var cNo=X.undiscriminatedUnion([uNo,sNo]);var KFn=X.object({id:X.string().optional(),"path-parameters":X.record(X.string(),I1).optional(),"query-parameters":X.record(X.string(),I1).optional(),headers:X.record(X.string(),I1).optional(),request:I1.optional(),response:aNo.optional(),"code-samples":X.list(cNo).optional()}).extend(db).extend(Ta);var Us_=X.list(KFn);var lNo=X.object({id:X.string().optional(),payload:I1}).extend(db).extend(Ta);var nac={};Kt(nac,{DefinitionFileSchema:()=>PFo,ErrorDiscriminationSchema:()=>BFo,Export:()=>EFo,ExportDetailed:()=>wFo,Navigation:()=>jFo,PackageMarkerFileSchema:()=>Ls_,PropertyBasedErrorDiscrimination:()=>MFo,RootApiFileSchema:()=>Vs_,StatusCodeBasedErrorDiscrimination:()=>DFo,WithHeadersSchema:()=>SFo});var I0e=X.undiscriminatedUnion([X.string(),X.list(X.string())]);var fNo=X.enum_(["read-only","write-only"]);var JFn=X.object({default:X.unknown().optional(),encoding:GFn.optional(),validation:OCi.optional()}).extend(Ta).extend(UL);var C0e=X.object({type:X.string()}).extend(JFn).extend(db).extend(_z);var dNo=X.object({access:fNo.optional()}).extend(C0e);var ACi=X.undiscriminatedUnion([X.string(),dNo]);var pNo=X.object({openapi:X.string()});var _No=X.object({proto:X.string()});var mCi=X.undiscriminatedUnion([pNo,_No]);var q0e=X.object({examples:X.list(HFn).optional(),encoding:GFn.optional(),source:mCi.optional(),inline:X.boolean().optional()}).extend(Ta).extend(UL).extend(_z);var hNo=X.object({extends:I0e.optional(),properties:X.record(X.string(),ACi).optional(),"extra-properties":X.boolean().optional()}).extend(q0e);var yNo=X.object({camel:X.string().optional(),snake:X.string().optional(),pascal:X.string().optional(),"screaming-snake":X.string().optional()});var bNo=X.object({value:X.string(),casing:yNo.optional()}).extend(Ta).extend(db);var vNo=X.undiscriminatedUnion([X.string(),bNo]);var gNo=X.object({default:X.string().optional(),enum:X.list(vNo)}).extend(q0e);var ONo=X.object({value:X.string()}).extend(db);var ANo=X.undiscriminatedUnion([X.string(),ONo]);var mNo=X.object({type:X.string()}).extend(JFn).extend(db).extend(_z);var Vvi=X.undiscriminatedUnion([X.string(),mNo]);var PNo=X.object({value:X.string()}).extend(db);var jNo=X.undiscriminatedUnion([X.string(),PNo]);var wNo=X.object({type:X.string().optional(),key:jNo.optional()}).extend(Ta).extend(db).extend(UL).extend(pz);var ENo=X.undiscriminatedUnion([X.string(),wNo]);var SNo=X.object({discriminant:ANo.optional(),extends:I0e.optional(),"base-properties":X.record(X.string(),Vvi).optional(),union:X.record(X.string(),ENo)}).extend(q0e);var MNo=X.object({type:X.string()}).extend(Ta).extend(pz).extend(xzo);var DNo=X.undiscriminatedUnion([X.string(),MNo]);var BNo=X.object({discriminated:X.booleanLiteral(!1),union:X.list(DNo)}).extend(q0e);var INo=X.object({type:X.string(),validation:OCi.optional()}).extend(q0e);var CNo=X.undiscriminatedUnion([X.string(),hNo,gNo,SNo,BNo,INo]);var qNo=X.object({"service-name":X.string()});var $Fn=X.object({grpc:qNo.optional()});var TNo=X.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var RNo=X.object({variable:X.string()}).extend(UL).extend(Ta);var aGt=X.undiscriminatedUnion([Vvi,RNo]);var zNo=X.record(UFn,X.list(LFn));var NNo=X.list(zNo);var FNo=X.undiscriminatedUnion([X.boolean(),NNo]);var QNo=X.object({"allow-multiple":X.boolean().optional()}).extend(C0e);var YFn=X.undiscriminatedUnion([X.string(),QNo]);var UNo=X.object({env:X.string().optional()}).extend(C0e);var LNo=X.undiscriminatedUnion([X.string(),UNo]);var T0e=LNo;var VNo=X.object({type:X.string()}).extend(Ta);var WNo=X.enum_(["json","exploded","form"]);var xNo=X.object({style:WNo.optional(),"content-type":X.string().optional()}).extend(C0e);var GNo=X.undiscriminatedUnion([X.string(),xNo]);var HNo=X.object({extends:I0e.optional(),"extra-properties":X.boolean().optional(),properties:X.record(X.string(),GNo).optional()});var KNo=X.undiscriminatedUnion([X.string(),VNo,HNo]);var JNo=X.object({"content-type":X.string().optional(),"path-parameters":X.record(X.string(),aGt).optional(),"query-parameters":X.record(X.string(),YFn).optional(),headers:X.record(X.string(),T0e).optional(),body:KNo.optional()}).extend(db).extend(Ta);var $No=X.undiscriminatedUnion([X.string(),JNo]);var YNo=X.object({type:X.string().optional(),property:X.string().optional(),"status-code":X.number().optional()}).extend(Ta);var XNo=X.undiscriminatedUnion([X.string(),YNo]);var ZNo=X.enum_(["sse","json"]);var kNo=X.object({type:X.string(),format:ZNo.optional(),terminator:X.string().optional()}).extend(Ta);var eFo=X.undiscriminatedUnion([X.string(),kNo]);var tFo=X.object({error:X.string()}).extend(Ta);var rFo=X.undiscriminatedUnion([X.string(),tFo]);var iFo=X.list(rFo);var nFo=X.object({cursor:X.string(),next_cursor:X.string(),results:X.string()});var aFo=X.object({offset:X.string(),results:X.string(),step:X.string().optional(),"has-next-page":X.string().optional()});var oFo=X.object({type:X.stringLiteral("custom"),results:X.string()});var XFn=X.undiscriminatedUnion([nFo,aFo,oFo]);var uFo=X.undiscriminatedUnion([XFn,X.boolean()]);var sFo=X.object({disabled:X.boolean().optional()});var cFo=X.undiscriminatedUnion([sFo]);var lFo=X.object({method:TNo.optional(),"base-path":X.string().optional(),path:X.string(),url:X.string().optional(),"path-parameters":X.record(X.string(),aGt).optional(),auth:FNo.optional(),idempotent:X.boolean().optional(),"stream-condition":X.string().optional(),request:$No.optional(),response:XNo.optional(),"response-stream":eFo.optional(),errors:iFo.optional(),examples:X.list(KFn).optional(),pagination:uFo.optional(),transport:$Fn.optional(),source:mCi.optional(),retries:cFo.optional()}).extend(pz).extend(nGt);var fFo=X.object({auth:X.boolean(),url:X.string().optional(),"base-path":X.string(),"path-parameters":X.record(X.string(),Vvi).optional(),idempotent:X.boolean().optional(),headers:X.record(X.string(),Vvi).optional(),transport:$Fn.optional(),source:mCi.optional(),endpoints:X.record(X.string(),lFo)}).extend(Gzo).extend(pz);var dFo=X.enum_(["POST","GET"]);var pFo=X.object({type:X.string()}).extend(Ta);var _Fo=X.object({name:X.string(),extends:I0e.optional(),properties:X.record(X.string(),ACi).optional()});var hFo=X.undiscriminatedUnion([X.string(),pFo,_Fo]);var yFo=X.object({method:dFo,headers:X.record(X.string(),T0e).optional(),payload:hFo,examples:X.list(lNo).optional()}).extend(UL).extend(_z).extend(Ta).extend(pz);var bFo=X.enum_(["client","server"]);var vFo=X.object({type:X.string()}).extend(Ta);var gFo=X.object({name:X.string(),extends:I0e.optional(),properties:X.record(X.string(),ACi).optional()});var OFo=X.undiscriminatedUnion([X.string(),vFo,gFo]);var AFo=X.object({origin:bFo,body:OFo}).extend(nGt).extend(pz);var mFo=X.object({auth:X.boolean(),url:X.string().optional(),path:X.string(),headers:X.record(X.string(),T0e).optional(),"path-parameters":X.record(X.string(),aGt).optional(),"query-parameters":X.record(X.string(),YFn).optional(),messages:X.record(X.string(),AFo).optional(),examples:X.list(eNo).optional()}).extend(nGt).extend(pz);var PFo=X.object({imports:X.record(X.string(),X.string()).optional(),types:X.record(X.string(),CNo).optional(),service:fFo.optional(),errors:X.record(X.string(),Zzo).optional(),webhooks:X.record(X.string(),yFo).optional(),channel:mFo.optional()}).extend(Ta);var jFo=X.undiscriminatedUnion([X.string(),X.list(X.string())]);var wFo=X.object({dependency:X.string(),url:X.string().optional()});var EFo=X.undiscriminatedUnion([X.string(),wFo]);var Ls_=X.object({navigation:jFo.optional(),export:EFo.optional()}).extend(PFo);var SFo=X.object({headers:X.record(X.string(),T0e).optional()});var MFo=X.object({strategy:X.stringLiteral("property"),"property-name":X.string()});var DFo=X.object({strategy:X.stringLiteral("status-code")});var BFo=X.undiscriminatedUnion([MFo,DFo]);var IFo=X.object({type:X.string()}).extend(Ta);var CFo=X.undiscriminatedUnion([X.string(),IFo]);var qFo=X.object({value:X.string()}).extend(Ta).extend(db);var TFo=X.undiscriminatedUnion([X.string(),qFo]);var RFo=X.object({name:X.string().optional(),env:X.string().optional(),value:X.string()});var zFo=X.undiscriminatedUnion([X.string(),RFo]);var ZFn=X.object({default:X.string().optional(),values:X.list(TFo),header:zFo});var NFo=X.object({value:X.string(),versions:ZFn.optional()}).extend(Ta).extend(db);var FFo=X.undiscriminatedUnion([X.string(),NFo]);var QFo=X.object({name:X.string().optional(),env:X.string().optional(),value:X.string()});var UFo=X.undiscriminatedUnion([X.string(),QFo]);var LFo=X.object({default:X.string().optional(),values:X.list(FFo),header:UFo});var Vs_=X.object({name:X.string(),imports:X.record(X.string(),X.string()).optional(),"error-discrimination":BFo.optional(),audiences:X.list(X.string()).optional(),errors:X.list(X.string()).optional(),"base-path":X.string().optional(),"path-parameters":X.record(X.string(),aGt).optional(),"idempotency-headers":X.record(X.string(),T0e).optional(),variables:X.record(X.string(),CFo).optional(),pagination:XFn.optional(),product:LFo.optional(),version:ZFn.optional()}).extend(Ta).extend(pz).extend(Yzo).extend(Qzo).extend(SFo);var aac={};Kt(aac,{CursorPaginationSchema:()=>nFo,CustomPaginationSchema:()=>oFo,OffsetPaginationSchema:()=>aFo,PaginationSchema:()=>XFn});var oac={};Kt(oac,{ProductDeclarationHeaderObjectSchema:()=>QFo,ProductDeclarationHeaderSchema:()=>UFo,ProductDeclarationSchema:()=>LFo,ProductValue:()=>FFo,ProductValueDetailed:()=>NFo});var uac={};Kt(uac,{FormDataBodyEncodingStyle:()=>WNo,GrpcTransport:()=>qNo,HttpEndpointAuth:()=>FNo,HttpEndpointSchema:()=>lFo,HttpEndpointSecurity:()=>NNo,HttpEndpointSecurityItem:()=>zNo,HttpHeaderSchema:()=>T0e,HttpInlineFileRequestBodyPropertySchema:()=>xNo,HttpInlineRequestBodyPropertySchema:()=>GNo,HttpInlineRequestBodySchema:()=>HNo,HttpMethodSchema:()=>TNo,HttpPathParameterSchema:()=>aGt,HttpQueryParameterSchema:()=>YFn,HttpReferencedRequestBodySchema:()=>VNo,HttpRequest:()=>$No,HttpRequestBodySchema:()=>KNo,HttpRequestSchema:()=>JNo,HttpResponseSchema:()=>XNo,HttpResponseSchemaDetailed:()=>YNo,HttpResponseStreamSchema:()=>eFo,HttpResponseStreamSchemaDetailed:()=>kNo,HttpServiceSchema:()=>fFo,Pagination:()=>uFo,QueryParameterTypeReferenceDetailed:()=>QNo,ResponseError:()=>rFo,ResponseErrorWithDocsSchema:()=>tFo,ResponseErrorsSchema:()=>iFo,RetriesConfiguration:()=>cFo,RetriesDisabledSchema:()=>sFo,ServiceTransport:()=>$Fn,StreamFormat:()=>ZNo,TypeReferenceDeclarationWithEnvOverride:()=>LNo,TypeReferenceDeclarationWithEnvOverrideSchema:()=>UNo});var sac={};Kt(sac,{OpenApiSourceSchema:()=>pNo,ProtobufSourceSchema:()=>_No,SourceSchema:()=>mCi});var cac={};Kt(cac,{AliasSchema:()=>INo,BaseTypeDeclarationSchema:()=>q0e,BaseTypeReferenceSchema:()=>JFn,CasingOverridesSchema:()=>yNo,DiscriminatedUnionSchema:()=>SNo,EnumSchema:()=>gNo,EnumValue:()=>vNo,EnumValueSchema:()=>bNo,ObjectExtendsSchema:()=>I0e,ObjectPropertyAccess:()=>fNo,ObjectPropertySchema:()=>ACi,ObjectPropertyWithAccessSchema:()=>dNo,ObjectSchema:()=>hNo,SingleUndiscriminatedUnionTypeDetailedSchema:()=>MNo,SingleUndiscriminatedUnionTypeSchema:()=>DNo,SingleUnionTypeDetailedSchema:()=>wNo,SingleUnionTypeKey:()=>jNo,SingleUnionTypeKeySchema:()=>PNo,SingleUnionTypeSchema:()=>ENo,TypeDeclarationSchema:()=>CNo,TypeReferenceDeclarationWithName:()=>C0e,TypeReferenceDeclarationWithNameSchema:()=>Ws_,TypeReferenceDetailedSchema:()=>mNo,TypeReferenceSchema:()=>Vvi,UndiscriminatedUnionSchema:()=>BNo,UnionDiscriminant:()=>ANo,UnionDiscriminantSchema:()=>ONo});var Ws_=X.undiscriminatedUnion([X.string(),C0e]);var lac={};Kt(lac,{NumberValidationSchema:()=>Wzo,StringValidationSchema:()=>Vzo,ValidationSchema:()=>OCi});var fac={};Kt(fac,{VariableDeclarationDetailed:()=>IFo,VariableDeclarationSchema:()=>CFo,VariableReferenceSchema:()=>RNo});var dac={};Kt(dac,{VersionDeclarationHeaderObjectSchema:()=>RFo,VersionDeclarationHeaderSchema:()=>zFo,VersionDeclarationSchema:()=>ZFn,VersionValue:()=>TFo,VersionValueDetailed:()=>qFo});var pac={};Kt(pac,{WebhookInlinedPayloadSchema:()=>_Fo,WebhookMethodSchema:()=>dFo,WebhookPayloadSchema:()=>hFo,WebhookReferencedPayloadSchema:()=>pFo,WebhookSchema:()=>yFo});var _ac={};Kt(_ac,{WebSocketChannelInlinedMessageSchema:()=>gFo,WebSocketChannelMessageBodySchema:()=>OFo,WebSocketChannelMessageSchema:()=>AFo,WebSocketChannelReferencedMessageSchema:()=>vFo,WebSocketChannelSchema:()=>mFo,WebSocketOrigin:()=>bFo});var sPa=class e extends Error{statusCode;body;constructor({message:t,statusCode:r,body:i}){super(nYS({message:t,statusCode:r,body:i})),Object.setPrototypeOf(this,e.prototype),r!=null&&(this.statusCode=r),i!==void 0&&(this.body=i)}};function nYS({message:e,statusCode:t,body:r}){let i=[];return e!=null&&i.push(e),t!=null&&i.push(`Status code: ${t.toString()}`),r!=null&&i.push(`Body: ${JSON.stringify(r,void 0,2)}`),i.join(`
1358
- `)}var cPa=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function yac(e){return e.scheme==="oauth"}var aYS={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},xs_=new Set(Object.values(aYS));function HS(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!xs_.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function R0e(e){return HS(e)!=null}function bac(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}function vac(e){if(e.response!=null)return typeof e.response=="string"?e.response:e.response.type}var VKi=class{REFERENCE_REGEX=/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};function YP(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function oGt(e){return e?e.proto!=null:!1}var oYS="text";function kFn(e){return e===oYS}var vx={integer:"integer",long:"long",uint:"uint",uint64:"uint64",float:"float",double:"double",boolean:"boolean",string:"string",datetime:"datetime",base64:"base64",uuid:"uuid",date:"date",bigint:"bigint",unknown:"unknown"};var eK={MAP:/^map<\s*([^,]*)\s*,\s*(.*)\s*>$/,LIST:/^list<\s*(.*)\s*>$/,SET:/^set<\s*(.*)\s*>$/,OPTIONAL:/^optional<\s*(.*)\s*>$/,NULLABLE:/^nullable<\s*(.*)\s*>$/,LITERAL:/^literal<\s*(?:"(.*)"|(true|false))\s*>$/};function WKi({type:e,_default:t,validation:r,visitor:i}){switch(e){case vx.integer:{let u=r??void 0;return i.primitive({v1:Su.Integer,v2:Pn.integer({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case vx.double:{let u=r??void 0;return i.primitive({v1:Su.Double,v2:Pn.double({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case vx.string:{let u=r??void 0;return i.primitive({v1:Su.String,v2:Pn.string({default:t??void 0,validation:u!=null?{format:u.format,pattern:u.pattern,minLength:u.minLength,maxLength:u.maxLength}:void 0})})}case vx.float:return i.primitive({v1:Su.Float,v2:void 0});case vx.long:return i.primitive({v1:Su.Long,v2:Pn.long({default:t??void 0})});case vx.boolean:return i.primitive({v1:Su.Boolean,v2:Pn.boolean({default:t??void 0})});case vx.datetime:return i.primitive({v1:Su.DateTime,v2:void 0});case vx.date:return i.primitive({v1:Su.Date,v2:void 0});case vx.uuid:return i.primitive({v1:Su.Uuid,v2:void 0});case vx.base64:return i.primitive({v1:Su.Base64,v2:void 0});case vx.bigint:return i.primitive({v1:Su.BigInteger,v2:Pn.bigInteger({default:t??void 0})});case vx.uint:return i.primitive({v1:Su.Uint,v2:void 0});case vx.uint64:return i.primitive({v1:Su.Uint64,v2:void 0});case vx.unknown:return i.unknown()}let n=e.match(eK.MAP);if(n?.[1]!=null&&n[2]!=null)return i.map({keyType:n[1],valueType:n[2]});let a=e.match(eK.LIST);if(a?.[1]!=null)return i.list(a[1]);let o=e.match(eK.SET);if(o?.[1]!=null)return i.set(o[1]);let c=e.match(eK.OPTIONAL);if(c?.[1]!=null)return i.optional(c[1]);let f=e.match(eK.NULLABLE);if(f?.[1]!=null)return i.nullable(f[1]);let s=e.match(eK.LITERAL);if(s?.[1]!=null)return i.literal(uz.string(s[1]));if(s?.[2]!=null){let u=s[2];switch(u){case"false":return i.literal(uz.boolean(!1));case"true":return i.literal(uz.boolean(!0));default:throw new Error(`Unsupported literal value: ${u}`)}}return i.named(e)}var Gs_="bytes";function uGt(e){if(e===Gs_)return{isOptional:!1};if(e.match(eK.OPTIONAL)?.[1]===Gs_)return{isOptional:!0}}function lPa(e){let t=typeof e=="string"?e:typeof e.body=="string"?e.body:void 0;if(t!=null)return uGt(t)}function gac({input:e,typeName:t}){for(let r of e.arguments)if(typeof r=="string"){if(r===t)return!0}else if(gac({input:r,typeName:t}))return!0;return!1}function Hs_(e){return gac({input:e,typeName:"file"})}function Ks_(e){let t=0,r=0;function i(){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return;let a="";for(;t<e.length&&e[t]!=="<"&&e[t]!==","&&e[t]!==">";)a+=e[t++];if(a.trim()){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t<e.length&&e[t]==="<"){if(t++,r++,r>128)throw new Error("Internal error; Exceeded maximum recursion depth while parsing generics.");let o={name:a.trim(),arguments:[]};for(;t<e.length&&e[t]!==">";){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t<e.length&&e[t]!==">"){let c=i();c&&o.arguments.push(c)}}if(t<e.length&&e[t]===">")t++,r--;else throw new Error("Malformed input: missing closing '>' for generic arguments.");return o}else return a.trim()}}let n=i();if(typeof n=="object")return n}var Oac="file";function Js_(e){return e.match(eK.LIST)?.[1]===Oac}function z0e(e){if(e===Oac)return{isOptional:!1,isArray:!1};let t=e.match(eK.OPTIONAL);if(t?.[1]!==void 0){if(t[1]===Oac)return{isOptional:!0,isArray:!1};if(Js_(t[1]))return{isOptional:!0,isArray:!0}}if(Js_(e))return{isOptional:!1,isArray:!0}}function uYS(e){return typeof e=="string"?!1:WA.parse(e["content-type"])?.isMultiPartFormData()??!1?!0:e.body==null?!1:!!(YP(e.body)&&Object.values(e.body.properties??[]).some(cYS))}function xKi(e){if(!(!uYS(e)||e.body==null)&&e.name!=null&&e.body!=null&&YP(e.body))return sYS(e.name,e.body)}function sYS(e,t){let r=Object.entries(t.properties??[]).reduce((i,[n,a])=>{let o=typeof a!="string"?a.docs:void 0,c=typeof a!="string"?a["content-type"]:void 0,f=typeof a!="string"?a.style:void 0,s=z0e(typeof a=="string"?a:a.type);return s!=null?i.push({isFile:!0,key:n,docs:o,isOptional:s.isOptional,isArray:s.isArray,contentType:c,style:f}):i.push({isFile:!1,key:n,propertyType:a,docs:o,contentType:c,style:f}),i},[]);return t["extra-properties"],{name:e,extends:t.extends,properties:r}}function cYS(e){let t=typeof e=="string"?e:e.type;if(t==="file")return!0;if(!t.includes("file"))return!1;let r=Ks_(t);return r==null?!1:Hs_(r)}var $s_="text";function fPa(e){if(e===$s_)return{isOptional:!1};if(e.match(eK.OPTIONAL)?.[1]===$s_)return{isOptional:!0}}function wB({type:e,_default:t,validation:r,visitor:i}){return WKi({type:e,_default:t,validation:r,visitor:{primitive:i.primitive,map:({keyType:n,valueType:a})=>i.map({keyType:wB({type:n,_default:void 0,validation:void 0,visitor:i}),valueType:wB({type:a,_default:void 0,validation:void 0,visitor:i})}),list:n=>i.list(wB({type:n,_default:void 0,validation:void 0,visitor:i})),set:n=>i.set(wB({type:n,_default:void 0,validation:void 0,visitor:i})),optional:n=>i.optional(wB({type:n,_default:t,validation:r,visitor:i})),nullable:n=>i.nullable(wB({type:n,_default:t,validation:r,visitor:i})),literal:i.literal,named:i.named,unknown:i.unknown}})}function Aac(e,t){if(lYS(e))return t.sdk(e);if(fYS(e))return t.language(e);vt(e)}function lYS(e){return e.sdk!=null}function fYS(e){return e.language!=null}function Ys_(e){return e["response-stream"]!=null&&(typeof e["response-stream"]=="string"||e["response-stream"].format==null||e["response-stream"].format==="json")}function Xs_(e){return e["response-stream"]!=null&&typeof e["response-stream"]!="string"&&e["response-stream"].format==="sse"}function GKi(e,t,r){return dYS(e,t)?r.stream(t):pYS(e,t)?r.events(t):r.body(t)}function dYS(e,t){return t.stream!==void 0&&Ys_(e)}function pYS(e,t){return t.stream!==void 0&&Xs_(e)}function HKi(e,t){if(Zs_(e))return t.single(e);if(ks_(e))return t.any(e);vt(e)}function Zs_(e){return typeof e=="string"||e.scheme!=null}function ks_(e){let[t,...r]=Object.keys(e);return t==="any"&&r.length===0}function dPa(e,t){if(ec_(e))return t.header(e);switch(e.scheme){case"basic":return t.basic(e);case"bearer":return"get-token"in e?t.inferredBearer(e):t.tokenBearer(e);case"oauth":return t.oauth(e);default:vt(e)}}function ec_(e){return e.header!=null}function sGt(e,t){if(tc_(e))return t.singleBaseUrl(e);if(Ahe(e))return t.multipleBaseUrls(e);vt(e)}function tc_(e){return typeof e=="string"||"url"in e}function Ahe(e){return typeof e!="string"&&"urls"in e}function eQn(e){return typeof e=="string"?e.startsWith("$"):"variable"in e}function EB(e,t){if(PCi(e))return t.alias(e);if(jCi(e))return t.discriminatedUnion(e);if(pb(e))return t.object(e);if(tQn(e))return t.undiscriminatedUnion(e);if(cFt(e))return t.enum(e);vt(e)}function PCi(e){return typeof e=="string"||e.type!=null}function pb(e){return e.extends!=null||e.properties!=null}function jCi(e){return e.union!=null&&e.discriminated==null}function tQn(e){let t=e;return t.union!=null&&t.discriminated!=null}function cFt(e){return e.enum!=null}function mac({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:CL.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return HKi(e.auth,{single:i=>{let n=rc_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:CL.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:CL.Any,schemes:i.map(n=>rc_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function rc_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,o)=>{let c=t?.[a];if(c==null)throw new Error("Unknown auth scheme: "+a);return dPa(c,{header:f=>EA.header({key:a,docs:o,name:r.generateNameAndWireValue({name:f.name??a,wireValue:f.header}),valueType:ni.primitive({v1:Su.String,v2:Pn.string({default:void 0,validation:void 0})}),prefix:f.prefix,headerEnvVar:f.env}),basic:f=>ic_({key:a,casingsGenerator:r,docs:o,rawScheme:f}),tokenBearer:f=>VFo({key:a,casingsGenerator:r,docs:o,rawScheme:f}),inferredBearer(f){return VFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})},oauth:f=>VFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return VFo({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return ic_({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function VFo({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return EA.bearer({key:e,docs:r,token:t.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function ic_({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return EA.basic({key:e,docs:r,username:t.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function jD(e){let t=hYS(e),{value:r,done:i}=Pac(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[..._YS(t)]}}function*_YS(e){let t;do{let{value:r}=Pac(e,"}"),i=Pac(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*hYS(e){for(let t of e)yield t}function Pac(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function pPa({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:sGt(i,{singleBaseUrl:()=>YE.singleBaseUrl(yYS({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>YE.multipleBaseUrls(bYS({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,sGt(a,{singleBaseUrl:o=>[...typeof o=="string"?[]:o.audiences??[]],multipleBaseUrls:o=>[...o.audiences??[]]})]))}}}function yYS({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>sGt(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:nc_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function bYS({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>sGt(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:bn(a.urls,o=>nc_(o))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function nc_(e){return e.endsWith("/")?e.slice(0,-1):e}function wCi(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let o=0;o<n.length;o++)o>0&&i(","),r(n[o],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((c,f)=>{f>0&&i(","),i(c),i(":"),r(n[c],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let o=n.charCodeAt(a);t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function cGt({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function ac_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return lGt({containerType:t});switch(t.type){case"list":{let o=DA({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.list({list:[o.example,o.example],itemType:t.list}),jsonExample:[o.jsonExample,o.jsonExample]}}case"literal":return{type:"success",example:op.literal({literal:t.literal._visit({boolean:o=>Dn.boolean(o),string:o=>Dn.string({original:o}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:o=>o,string:o=>o,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return lGt({containerType:t});let o=DA({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.optional({optional:o.example,valueType:t.optional}),jsonExample:o.jsonExample}}case"nullable":{if(a)return lGt({containerType:t});let o=DA({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.nullable({nullable:o.example,valueType:t.nullable}),jsonExample:o.jsonExample}}case"set":{let o=DA({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.set({set:[o.example],itemType:t.set}),jsonExample:[o.jsonExample]}}case"map":{let o=DA({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),c=DA({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"||c.type==="failure"?lGt({containerType:t}):{type:"success",example:op.map({map:[{key:o.example,value:c.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[o.jsonExample]:c.jsonExample}}}default:vt(t)}}function lGt({containerType:e}){switch(e.type){case"list":return{type:"success",example:op.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:op.literal({literal:e.literal._visit({boolean:t=>Dn.boolean(t),string:t=>Dn.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:op.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:op.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:op.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:op.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:vt(e)}}function uc_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return mYS({fieldName:e,default_:vYS(t.v2),validation:gYS(t.v2)});case"BASE_64":return{type:"success",example:Dn.base64(cu.BASE64),jsonExample:cu.BASE64};case"BOOLEAN":return{type:"success",example:Dn.boolean(cu.BOOLEAN),jsonExample:cu.BOOLEAN};case"DATE":return{type:"success",example:Dn.date(cu.DATE),jsonExample:cu.DATE};case"DATE_TIME":return{type:"success",example:Dn.datetime({datetime:new Date(cu.DATE_TIME),raw:cu.DATE_TIME}),jsonExample:cu.DATE_TIME};case"DOUBLE":return PYS({fieldName:e,validation:OYS(t.v2)});case"FLOAT":return{type:"success",example:Dn.float(cu.FLOAT),jsonExample:cu.FLOAT};case"INTEGER":return jYS({fieldName:e,validation:AYS(t.v2)});case"UINT_64":return{type:"success",example:Dn.uint64(cu.INT64),jsonExample:cu.INT64};case"UINT":return{type:"success",example:Dn.uint(cu.UINT),jsonExample:cu.UINT};case"BIG_INTEGER":return{type:"success",example:Dn.bigInteger(cu.INT64.toString()),jsonExample:`${cu.INT64}`};case"LONG":return{type:"success",example:Dn.long(cu.INT64),jsonExample:cu.INT64};case"UUID":return{type:"success",example:Dn.uuid(cu.UUID),jsonExample:cu.UUID};default:vt(t.v1)}}function vYS(e){if(e?.type==="string")return e.default}function gYS(e){if(e?.type==="string")return e.validation}function OYS(e){if(e?.type==="double")return e.validation}function AYS(e){if(e?.type==="integer")return e.validation}function oc_(e){if(e<=cu.SAMPLE_STRINGS.length){let t=cu.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return cu.SAMPLE_STRINGS[cu.SAMPLE_STRINGS.length-1]+".".repeat(e-cu.SAMPLE_STRINGS.length)}function mYS({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Dn.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let o=oc_(n);return{type:"success",example:Dn.string({original:o}),jsonExample:o}}else if(a!=null&&a<10){let o=oc_(a);return{type:"success",example:Dn.string({original:o}),jsonExample:o}}}let i=e??cu.STRING;return{type:"success",example:Dn.string({original:i}),jsonExample:i}}function PYS({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Dn.double(r),jsonExample:r};if(i)return{type:"success",example:Dn.double(i),jsonExample:i}}return{type:"success",example:Dn.double(cu.DOUBLE),jsonExample:cu.DOUBLE}}function jYS({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Dn.integer(r),jsonExample:r};if(i)return{type:"success",example:Dn.integer(i),jsonExample:i}}return{type:"success",example:Dn.integer(cu.INT),jsonExample:cu.INT}}function wYS(e,t){if(e.type==="primitive"||e.type==="container"&&e.container.type==="literal")return!0;if(e.type==="named"){let r=t[e.typeId];if(r!=null&&r.shape.type==="enum")return!0}return!1}function KKi({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let o=DA({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure")return o;let{example:c,jsonExample:f}=o;return{type:"success",example:Ih.alias({value:c}),jsonExample:f}}case"enum":{let o=r.shape.values[0];return o==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Ih.enum({value:o.name}),jsonExample:o.name.wireValue}}case"object":{let o={},c=[];if((r.shape.extendedProperties==null||r.shape.extendedProperties.length===0)&&r.shape.extends!=null)for(let l of r.shape.extends){let p=t[l.typeId];if(p==null)continue;let _=KKi({fieldName:e,typeDeclaration:p,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});_!=null&&_.type==="success"&&_.example.type==="object"&&(Object.assign(o,_.jsonExample),c.push(..._.example.properties))}let f=EYS({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(f.type==="failure")return f;let{example:s,jsonExample:u}=f;return{type:"success",example:Ih.object({properties:[...c,...s.properties],extraProperties:s.extraProperties}),jsonExample:Object.assign({},o,u)}}case"undiscriminatedUnion":{let o=r.shape.members;if(o.every(s=>wYS(s.type,t))){let s=o.findIndex(u=>{if(u.type.type==="container"&&u.type.container.type==="literal")return!0;if(u.type.type==="named"){let l=t[u.type.typeId];if(l!=null&&l.shape.type==="enum")return l.shape.values.length>0}return!1});if(s!==-1){let u=o[s];if(u!=null){let l=DA({fieldName:e,typeReference:u.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="success"){let{example:p,jsonExample:_}=l;return{type:"success",example:Ih.undiscriminatedUnion({index:s,singleUnionType:p}),jsonExample:_}}}}}let f=0;for(let s of o){let u=DA({fieldName:e,typeReference:s.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(u.type==="failure"){++f;continue}let{example:l,jsonExample:p}=u;return{type:"success",example:Ih.undiscriminatedUnion({index:f,singleUnionType:l}),jsonExample:p}}break}case"union":{let o=r.shape.discriminant,c={};if(r.shape.baseProperties!=null)for(let u of r.shape.baseProperties){let l=DA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});l.type==="success"&&(c[u.name.wireValue]=l.jsonExample)}let f=r.shape.baseProperties.map(u=>{let l=DA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="failure")throw new Error(`Failed to generate example for union base property ${u.name.wireValue}`);let{example:p}=l;return{name:u.name,value:p}}),s=r.shape.extends.flatMap(u=>{let l=t[u.typeId];if(l==null)throw new Error(`Failed to find extended type declaration with id ${u.typeId}`);let p=KKi({fieldName:e,typeDeclaration:l,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(p==null||p.type==="failure")throw new Error(`Failed to generate example for extended type declaration ${l.name.typeId}`);if(p.example.type!=="object")throw new Error(`Extended type declaration ${l.name.typeId} is not an object`);return p.example.properties});for(let u of r.shape.types){let l=u.shape._visit({noProperties:()=>({type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.noProperties()},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...c}}),samePropertiesAsObject:p=>{let _=t[p.typeId];if(_==null)return{type:"failure",message:`Failed to find type declaration with id ${p.typeId}`};let h=KKi({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:_,typeDeclarations:t,skipOptionalProperties:a});if(h==null)return{type:"failure",message:"Failed to generate example for type reference"};if(h.type==="failure")return h;let{example:y,jsonExample:b}=h;return{type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.samePropertiesAsObject({typeId:_.name.typeId,object:y.type==="object"?y:{properties:[],extraProperties:void 0}})},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...typeof b=="object"?b:{},...c}}},singleProperty:p=>{let _=DA({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:p.type,typeDeclarations:t,skipOptionalProperties:a});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;return{type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.singleProperty(h)},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,[p.name.wireValue]:y,...c}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(l.type!=="failure")return l}}}return{type:"failure",message:"Failed to generate example for type reference"}}function EYS({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:o}){let c={},f=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let u=DA({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:o});if(u.type==="failure"&&!cGt({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${u.message}`};if(u.type==="failure")continue;let{example:l,jsonExample:p}=u;f.push({name:s.name,originalTypeDeclaration:t.name,value:l,propertyAccess:s.propertyAccess}),c[s.name.wireValue]=p}return{type:"success",example:Ih.object({properties:f,extraProperties:void 0}),jsonExample:c}}function DA({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:`Exceeded max depth of ${i}`};switch(t.type){case"named":{let o=r[t.typeId];if(o==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let c=KKi({fieldName:e,typeDeclaration:o,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(c==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(c.type==="failure")return c;let{example:f,jsonExample:s}=c;return{type:"success",example:{jsonExample:s,shape:lu.named({shape:f,typeName:o.name})},jsonExample:s}}case"container":{let o=ac_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure"){let{example:s,jsonExample:u}=lGt({containerType:t.container});return{type:"success",example:{jsonExample:u,shape:lu.container(s)},jsonExample:u}}let{example:c,jsonExample:f}=o;return{type:"success",example:{jsonExample:f,shape:lu.container(c)},jsonExample:f}}case"primitive":{let{jsonExample:o,example:c}=uc_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:o,shape:lu.primitive(c)},jsonExample:o}}case"unknown":{let o={key:"value"};return{type:"success",example:{jsonExample:o,shape:lu.unknown(o)},jsonExample:o}}}}function JKi(e,t){let r=[];for(let i of e){let n=DA({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function rQn(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&cGt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=DA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function WFo(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&cGt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=DA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?B1.exploded():B1.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var jac=ni.primitive({v1:Su.String,v2:Pn.string({default:void 0,validation:void 0})});function iQn({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let o={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:K0.ok($P.body(void 0)),docs:void 0},c=JKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;o.endpointPathParameters=c.example;let f=JKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(f.type==="failure")return f;o.servicePathParameters=f.example;let s=JKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;o.rootPathParameters=s.example;let u=WFo(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(u.type==="failure")return u;o.queryParameters=u.example;let l=rQn(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;o.endpointHeaders=l.example;let p=rQn(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(p.type==="failure")return p;if(o.serviceHeaders=p.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let _={},h=[];if(t.requestBody.extends!=null)for(let y of t.requestBody.extends){let b=i[y.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${y.typeId}`);let v=KKi({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});v!=null&&v.type==="success"&&Object.assign(_,v.jsonExample)}for(let y of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=DA({fieldName:y.name.wireValue,typeReference:y.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!cGt({typeDeclarations:i,typeReference:y.valueType}))return{type:"failure",message:`Failed to generate required property ${y.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:v,jsonExample:O}=b;h.push({name:y.name,originalTypeDeclaration:void 0,value:v}),_[y.name.wireValue]=O}o.request=RL.inlinedRequestBody({jsonExample:_,properties:h,extraProperties:void 0});break}case"reference":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.request=RL.reference(h);break}default:vt(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"streamParameter":{let _;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1});break;default:vt(t.response.body.nonStreamResponse)}if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"streaming":{let _;switch(t.response.body.value.type){case"sse":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.sse([{data:{...h,jsonExample:y},event:""}]));break}case"json":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.stream([{...h,jsonExample:y}]));break}case"text":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.stream([{...h,jsonExample:y}]));break}default:vt(t.response.body.value)}break}case"text":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:vt(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)o.response=K0.error({body:void 0,error:a.declaration.name});else{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.response=K0.error({body:h,error:a.declaration.name})}try{return{type:"success",example:{id:wCi(o),url:SYS(t,o),...o},jsonExample:void 0}}catch(_){return{type:"failure",message:`Parse failure with exceptions ${_}`}}}function SYS(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.fullPath.head+e.fullPath.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function wac({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=JKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let o=JKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(o.type==="failure")return o;n.pathParameters.push(...o.example);let c=WFo(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(c.type==="failure")return c;n.queryParameters=c.example;let f=rQn(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(f.type==="failure")return f;n.headers.push(...f.example);let s=rQn(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let l=t.messages.filter(h=>h.origin==="client")[0];if(l!=null){let h=sc_({message:l,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:l.type,body:h})}let _=t.messages.filter(h=>h.origin==="server")[0];if(_!=null){let h=sc_({message:_,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:_.type,body:h})}return{type:"success",example:{...n,url:MYS(t,n)},jsonExample:void 0}}function sc_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=DA({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return ghe.reference(i.example)}function MYS(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.path.head+e.path.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function nQn(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function ECi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function cc_({ir:e,endpoint:t,skipOptionalRequestProperties:r}){let i=e.types,n={pathParameters:{},queryParameters:{},headers:{}};for(let o of t.pathParameters){let{userExample:c,autoExample:f}=nQn(o.v2Examples);c!==void 0?n.pathParameters[o.name.originalName]=c:f!==void 0&&(n.pathParameters[o.name.originalName]=f)}for(let o of t.queryParameters){let{userExample:c,autoExample:f}=nQn(o.v2Examples);if(c!==void 0)n.queryParameters[o.name.name.originalName]=c;else if(f!==void 0){if(r&&cGt({typeReference:o.valueType,typeDeclarations:i}))continue;n.queryParameters[o.name.name.originalName]=f}}let a=[...t.headers,...e.headers,...e.idempotencyHeaders];for(let o of a){let{userExample:c,autoExample:f}=nQn(o.v2Examples);if(c!==void 0)n.headers[o.name.wireValue]=c;else if(f!==void 0){if(r&&cGt({typeReference:o.valueType,typeDeclarations:i}))continue;n.headers[o.name.wireValue]=f}}return n}function lc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let{pathParameters:i,queryParameters:n,headers:a}=cc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),o={},c={},f={endpoint:{method:e.method,path:DYS(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:i,queryParameters:n,headers:a,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"inlinedRequestBody":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"reference":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}default:vt(e.requestBody)}return{userRequestExamples:o,autoRequestExamples:c,baseExample:f}}function DYS(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=nQn(i.v2Examples),o=n??a,c;o==null?c=i.name.originalName:c=typeof o=="string"?o:JSON.stringify(o),t[i.name.originalName]=c});let r=e.fullPath.head+e.fullPath.parts.map(i=>encodeURIComponent(`${t[i.pathParameter]}`)+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function xFo({endpoint:e,responseObject:t}){let r=t!==void 0?t:e.response,i={},n={},a={statusCode:r?.statusCode,body:void 0,docs:void 0};if(r==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:a};if(r.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...a,body:CC.json(_Pa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:a};switch(r.body.type){case"bytes":break;case"fileDownload":break;case"text":{let o=r.body,{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?_Pa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?_Pa(u):u;n[s]={...a,body:CC.json(l)}}break}case"json":{let o=r.body.value;if(o.type==="response"){let{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?_Pa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?_Pa(u):u;n[s]={...a,body:CC.json(l)}}}break}case"streaming":{let o=r.body.value;if(o.type==="json"){let{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c))i[s]={...a,body:CC.stream([u])};for(let[s,u]of Object.entries(f))n[s]={...a,body:CC.stream([u])}}break}case"streamParameter":break;default:vt(r.body)}return{userResponseExamples:i,autoResponseExamples:n,baseExample:a}}function _Pa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}var aQn=(e,t,r)=>{let i;return e===t?i=`${e}`:i=`${e}_${t}`,r&&(i=`${i}_${r}`),i},BYS=({exampleStore:e,key:t,example:r})=>e.has(t)?!1:(e.set(t,r),!0);function GFo({key:e,displayName:t,request:r,response:i,exampleStore:n,userOrAutoStore:a}){if(!n.has(e)){let o={displayName:t,request:r,response:i,codeSamples:void 0};return a[e]=o,BYS({exampleStore:n,key:e,example:o}),!0}return!1}function fc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let i={},n={},a=new Map,{userRequestExamples:o,autoRequestExamples:c,baseExample:f}=lc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),s=Object.keys(o)[0],u=Object.values(o)[0],l=Object.keys(c)[0],p=Object.values(c)[0],_=IYS({endpoint:e,userRequestExamples:o,baseRequestExample:f,firstUserRequestName:s,firstUserRequestExample:u,firstAutoRequestName:l,firstAutoRequestExample:p,userResults:i,autoResults:n,exampleStore:a});if(CYS({endpoint:e,userRequestExamples:o,requestExamplesUsed:_,userResults:i,exampleStore:a}),Object.keys(i).length===0&&Object.keys(n).length===0){let{baseExample:h}=xFo({endpoint:e}),y=aQn(l??"base","base",void 0);GFo({key:y,displayName:l??"base",request:p??f,response:h,exampleStore:a,userOrAutoStore:n})}return{userFullExamples:i,autoFullExamples:n}}function IYS({endpoint:e,userRequestExamples:t,baseRequestExample:r,firstUserRequestName:i,firstUserRequestExample:n,firstAutoRequestName:a,firstAutoRequestExample:o,userResults:c,autoResults:f,exampleStore:s}){let u=e.v2Responses?.responses??[e.response],l=new Set;for(let p of u){let _=!1,{userResponseExamples:h,autoResponseExamples:y,baseExample:b}=xFo({endpoint:e,responseObject:p}),v=Object.keys(y)[0],O=Object.values(y)[0];for(let[A,g]of Object.entries(h)){let m,j;t[A]?(j=t[A],l.add(A),m=aQn(A,A,p?.statusCode)):o&&a?(j=o,m=aQn(a,A,p?.statusCode)):(j=r,m=aQn("base",A,p?.statusCode)),GFo({key:m,displayName:A,request:j,response:g,exampleStore:s,userOrAutoStore:c})&&(_=!0)}if(!_){let A=No(`${e.name.originalName}_example`);i&&n&&l.add(i);let g=aQn(i??a??"base",v??"base",p?.statusCode);GFo({key:g,displayName:i??a??A,request:n??o??r,response:O??b,exampleStore:s,userOrAutoStore:f})&&(_=!0)}}return l}function CYS({endpoint:e,userRequestExamples:t,requestExamplesUsed:r,userResults:i,exampleStore:n}){let{userResponseExamples:a,autoResponseExamples:o,baseExample:c}=xFo({endpoint:e}),f=Object.values(a)[0],s=Object.keys(a)[0],u=Object.keys(o)[0],l=Object.values(o)[0],p=Object.entries(t).filter(([_])=>!r.has(_));for(let[_,h]of p){let y=aQn(_,s??u??"base",f?f.statusCode:l?l.statusCode:c.statusCode);GFo({key:y,displayName:_,request:h,response:f??l??c,exampleStore:n,userOrAutoStore:i})}}function hPa({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){let o=[];if(a.userSpecifiedExamples.length===0||r.skipAutogenerationIfManualExamplesExist===!1){let c=iQn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});c.type==="success"&&o.push({example:c.example})}if(a.userSpecifiedExamples.filter(c=>c.example?.response.type==="error").length===0||r.skipErrorAutogenerationIfManualErrorExamplesExist===!1)for(let c of a.errors){let f=e.errors[c.error.errorId];if(!f)continue;let s=iQn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"error",declaration:f}});s.type==="success"&&o.push({example:s.example})}a.autogeneratedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=wac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function Eac({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){a.v2Examples==null&&(a.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:o,autoFullExamples:c}=fc_({endpoint:a,ir:e,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(Object.keys(a.v2Examples.userSpecifiedExamples).length>0){if(Object.values(a.v2Examples.userSpecifiedExamples).some(s=>s.request!=null||s.response!=null))continue;let f=Object.values(a.v2Examples.userSpecifiedExamples).filter(s=>s!=null).flatMap(s=>s.codeSamples??[]);for(let[s,u]of Object.entries(c))c[s]={...u,codeSamples:f};for(let[s,u]of Object.entries(o))o[s]={...u,codeSamples:f}}a.v2Examples.autogeneratedExamples=c,a.v2Examples.userSpecifiedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=wac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function pc_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{...r.object,properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:KS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?jB.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=KS({filteredIr:e,exampleTypeReference:r});return i!==void 0?jB.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function KS({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:lu.container(op.list({...i,list:i.list.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:lu.container(op.set({...i,set:i.set.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?KS({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:lu.container(op.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?KS({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:lu.container(op.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:lu.container(op.map({...i,map:i.map.map(n=>{let a=KS({filteredIr:e,exampleTypeReference:n.key}),o=KS({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&o!==void 0?{key:a,value:o}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=KS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:lu.named({...r,shape:Ih.enum(i)})}),object:i=>({...t,shape:lu.named({...r,shape:Ih.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:KS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=pc_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=KS({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function Sac({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function qYS({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function dc_({filteredIr:e,headers:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function TYS({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=KS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=KS({filteredIr:e,exampleTypeReference:r});return i!==void 0?RL.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function RYS({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>K0.ok($P.body(i!=null?KS({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>K0.ok($P.stream(i.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(ps))),sse:i=>K0.ok($P.sse(i.map(({event:n,data:a})=>{let o=KS({filteredIr:e,exampleTypeReference:a});return o!==void 0?{event:n,data:o}:void 0}).filter(ps))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>K0.error({error:r,body:i!=null?KS({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function Mac({filteredIr:e,example:t}){return{...t,rootPathParameters:Sac({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:Sac({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:Sac({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:dc_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:dc_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:qYS({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?TYS({filteredIr:e,requestBody:t.request}):void 0,response:RYS({filteredIr:e,response:t.response})}}function _c_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Ih.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Ih.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:KS({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=pc_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Ih.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=KS({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Ih.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function Dac(e,t){if(t==null)return e;let r=zxi(e.types,c=>t.hasType(c)),i=Object.fromEntries(Object.entries(r).map(([c,f])=>{let s=[];if(f.userProvidedExamples=f.userProvidedExamples.map(u=>_c_({filteredIr:t,exampleType:u})).filter(u=>u!==void 0),f.shape.type==="object"){for(let u of f.shape.properties)t.hasProperty(c,u.name.wireValue)&&s.push(u);return[c,{...f,shape:Zc.object({...f.shape,properties:s})}]}return[c,f]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([c,f])=>{let s=f.filter(u=>t.hasWebhook(u)).map(u=>{let l=u.id;return u.payload.type==="inlinedPayload"&&l!=null&&(u.payload={...u.payload,properties:u.payload.properties.filter(p=>t.hasWebhookPayloadProperty(l,p.name.wireValue))}),u});return[c,s]})),a=e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).filter(([c])=>t.hasChannel(c)).map(([c,f])=>[c,{...f}])):{},o=e.environments;if(o){switch(o.environments.type){case"singleBaseUrl":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}case"multipleBaseUrls":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}}o.defaultEnvironment&&(t.hasEnvironmentId(o.defaultEnvironment)||(o.defaultEnvironment=void 0))}return{...e,environments:o,types:i,errors:zxi(e.errors,c=>t.hasError(c)),services:bn(zxi(e.services,c=>t.hasService(c)),c=>({...c,endpoints:c.endpoints.filter(f=>t.hasEndpoint(f)).map(f=>(f.autogeneratedExamples=f.autogeneratedExamples.map(s=>({...s,example:Mac({filteredIr:t,example:s.example})})),f.userSpecifiedExamples=f.userSpecifiedExamples.map(s=>({...s,example:s.example!=null?Mac({filteredIr:t,example:s.example}):void 0})),f.queryParameters.length>0&&(f.queryParameters=f.queryParameters.filter(s=>t.hasQueryParameter(f.id,s.name.wireValue))),f.requestBody?.type==="inlinedRequestBody"?{...f,requestBody:{...f.requestBody,properties:f.requestBody.properties.filter(s=>t.hasRequestProperty(f.id,s.name.wireValue))}}:f))})),websocketChannels:a,webhookGroups:n,serviceTypeReferenceInfo:zYS(e.serviceTypeReferenceInfo,t)}}function zYS(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}function $Ki(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}function mhe(e){return e.allParts.map(t=>t.originalName).join("/")}var up={generateTypeId:e=>`type_${mhe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${mhe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${mhe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${mhe(e)}`,generateSubpackageId:e=>`subpackage_${mhe(e)}`,generateEndpointId:(e,t)=>{let r=mhe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${mhe(e)}`,generateWebhookId:(e,t)=>`webhooks_${mhe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${mhe(e)}`};function oQn(e){return e.type!=null}var HFo=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:o,webhooks:c,subpackages:f,queryParameters:s,requestProperties:u,webhookPayloadProperties:l,channels:p}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=o,this.webhooks=c,this.webhookPayloadProperties=l,this.subpackages=f,this.requestProperties=u,this.queryParameters=s,this.channels=p}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=up.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=up.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=up.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t?this.channels.has(t):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};var YKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=NYS(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let o=up.generateTypeId(t),c={typeId:o,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[o]=c,this.typesReferencedByService[o]==null&&(this.typesReferencedByService[o]=new Set),this.properties[o]={typeId:o,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=up.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=up.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&ZE(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=up.generateServiceId(t.name),a=r.id,o=new Set,c=new Set,f=new Set;for(let s of[...t.headers,...r.headers])ZE(s.valueType,o,f);for(let s of[...t.pathParameters,...r.pathParameters])ZE(s.valueType,o,f);for(let s of r.queryParameters)ZE(s.valueType,o,f);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=$Ki(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&VO._visit(r.requestBody,{inlinedRequestBody:s=>{for(let u of s.extends)KFo(u,o,f);for(let u of s.properties)ZE(u.valueType,o,f);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&YP(i.request.body)){let u=$Ki(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:u}}},reference:({requestBodyType:s})=>{ZE(s,o,f)},fileUpload:({properties:s})=>{for(let u of s)qC._visit(u,{file:Et,bodyProperty:({valueType:l})=>{ZE(l,o,f)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+u.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&ly._visit(r.response.body,{fileDownload:Et,json:s=>{ZE(s.responseBodyType,o,f)},streaming:s=>{s._visit({sse:u=>ZE(u.payload,o,f),json:u=>ZE(u.payload,o,f),text:Et,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:u=>ZE(u.payload,o,f),json:u=>ZE(u.payload,o,f),text:Et,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&ZE(s.nonStreamResponse.value.responseBodyType,o,f)},text:Et,bytes:Et,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{c.add(up.generateErrorId(s.error)),f.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:o,referencedErrors:c,referencedSubpackages:f}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=up.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let o=a.id;this.endpointsNeededForAudience.add(o),this.endpoints[o]?.referencedSubpackages.forEach(c=>{this.addSubpackages(c)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,o=new Set;r.payload!=null&&WQ._visit(r.payload,{inlinedPayload:c=>{for(let f of c.extends)KFo(f,a,o);for(let f of c.properties)ZE(f.valueType,a,o);if(i?.payload!=null&&typeof i.payload=="object"&&!oQn(i.payload)){let f=$Ki(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:f}}},reference:({payloadType:c})=>{ZE(c,a,o)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),o.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:o}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,o=new Set;for(let c of i.messages)sz._visit(c.body,{reference:({bodyType:f})=>{ZE(f,a,o)},inlinedBody:f=>{for(let s of f.extends)KFo(s,a,o);for(let s of f.properties)ZE(s.valueType,a,o)},_other:()=>{}});for(let c of i.queryParameters)ZE(c.valueType,a,o);o.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:o}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let c of this.endpointsNeededForAudience.keys()){let f=this.getEndpointNode(c);for(let s of f.referencedErrors){if(r.has(s))continue;r.add(s);let u=this.getErrorNode(s);this.addReferencedTypes(t,u.referencedTypes)}this.addReferencedTypes(t,f.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let c of this.webhooksNeededForAudience.keys()){let f=this.getWebhookNode(c);this.addReferencedTypes(t,f.referencedTypes)}for(let c of this.channelsNeededForAudience.keys()){let f=this.getChannelNode(c);this.addReferencedTypes(t,f.referencedTypes)}let i={},n={},a={},o={};if(this.audiences.type==="filtered"){for(let[c,f]of Object.entries(this.properties)){if(!t.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}s.size>0&&(i[c]=s),i[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}n[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.parametersByAudience[u];l?.forEach(p=>{s.add(p)})}a[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}o[c]=s.size>0?s:void 0}}return new HFo({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:o,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let o=n.descendantsByAudience[a];if(o!=null)o.forEach(c=>{t.add(c)});else{n.allDescendants.forEach(c=>{t.add(c)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:vt(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(up.generateSubpackageId(i))}}};function NYS(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:vt(e)}}function ZE(e,t,r){ni._visit(e,{container:i=>{FYS(i,t,r)},named:i=>{KFo(i,t,r)},primitive:Et,unknown:Et,_other:Et})}function KFo(e,t,r){t.add(up.generateTypeId(e)),r.add(e.fernFilepath)}function FYS(e,t,r){es._visit(e,{list:i=>{ZE(i,t,r)},map:i=>{ZE(i.keyType,t,r),ZE(i.valueType,t,r)},optional:i=>{ZE(i,t,r)},nullable:i=>{ZE(i,t,r)},set:i=>{ZE(i,t,r)},literal:Et,_other:Et})}var QYS=[br.AvailabilityStatus.GeneralAvailability];function Wvi(e){return e!==void 0&&!QYS.includes(e.status)}var Bac=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},yPa=class{errors;constructor(){this.errors=new Bac}async check({from:t,to:r}){let i=this.toInternalIr(t),n=this.toInternalIr(r),a=wCi(i),o=wCi(n);if(a===o)return{bump:"no_change",isBreaking:!1,errors:[]};let c=this.checkBreaking({from:i,to:n});return{bump:c.isBreaking?"major":"minor",isBreaking:c.isBreaking,errors:c.errors}}toInternalIr(t){return{types:t.types,errors:t.errors,services:t.services}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(Wvi(n.availability))continue;let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}if(Wvi(a.availability)){this.errors.add(`Type "${i}" was moved from stable to unstable availability status.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(o=>o.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(Wvi(n.availability)||(n.endpoints?.every(o=>Wvi(o.availability))??!1))continue;let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}if(Wvi(a.availability)){this.errors.add(`Service "${i}" was moved from stable to unstable availability status.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(o=>[o.id,o])),a=Object.fromEntries(i.endpoints.map(o=>[o.id,o]));for(let[o,c]of Object.entries(n)){if(Wvi(c.availability))continue;let f=a[o];if(!f){this.errors.add(`Endpoint "${o}" was removed.`);continue}if(Wvi(f.availability)){this.errors.add(`Endpoint "${o}" was moved from stable to unstable availability status.`);continue}this.checkEndpointBreakingChanges({id:o,from:c,to:f})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.originalName,o])),a=Object.fromEntries(i.map(o=>[o.name.originalName,o]));for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Path parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Path parameter "${o}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Query parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Query parameter "${o}" type changed in endpoint "${t}".`),c.allowMultiple!==f.allowMultiple&&this.errors.add(`Query parameter "${o}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Header "${o}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Header "${o}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:vt(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,o])=>{let c=n[a];return c?this.areTypeReferencesCompatible({from:o,to:c}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,o]of Object.entries(i)){let c=n[a];if(!c)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(o==="file"&&c!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o==="fileArray"&&c!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o!=="file"&&o!=="fileArray"&&c!=="file"&&c!=="fileArray"&&!this.areTypeReferencesCompatible({from:o,to:c}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:vt(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:vt(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return Wvi(t.availability)?!0:this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:vt(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areNameAndWireValuesCompatible({from:a.name,to:o.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,o])=>[a,o.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,o])=>[a,o.valueType]))}),Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areObjectPropertiesCompatible({from:a,to:o}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),o=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let u=o[s.name.wireValue];if(!u)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:u}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,u])=>[s,u.valueType])),to:Object.fromEntries(Object.entries(o).map(([s,u])=>[s,u.valueType]))});let c=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),f=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(c).every(s=>{let u=f[s.discriminantValue.wireValue];return u?this.areSingleUnionTypesCompatible({from:s.shape,to:u.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:vt(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:vt(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:vt(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:vt(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:vt(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function XKi(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=LYS(e.environments,t.environments,r),{services:o,websocketChannels:c}=VYS(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:{requirement:e.auth?.requirement??t.auth?.requirement,schemes:t.auth?.schemes?.length!=null&&t.auth.schemes.length>(e.auth?.schemes?.length??0)?t.auth.schemes:e.auth?.schemes??[],docs:e.auth?.docs??t.auth?.docs},headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:o,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:UYS(e.subpackages,t.subpackages),websocketChannels:c,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(f=>!e.rootPackage.subpackages?.includes(f))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig,audiences:[...e.audiences??[],...t.audiences??[]],generationMetadata:e.generationMetadata??t.generationMetadata,apiPlayground:e.apiPlayground??t.apiPlayground}}function UYS(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,displayName:n.displayName,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function LYS(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=hc_(e),n=hc_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:YE.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,o=e.environments,c=t.environments;if(o.type==="singleBaseUrl"&&c.type==="singleBaseUrl"){let f=i?c:o,s=i?o:c,u={},{deconflictedEnvironments2:l,changedBaseUrlIds2:p}=WYS(f,s,r);if(f.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let _="Base",h=r.generateName("Base");return f.environments.forEach(y=>{u[y.id]=_}),{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[{id:_,name:h},...l.environments.map(y=>({id:y.id,name:y.name}))],environments:f.environments.map(y=>({id:y.id,name:y.name,urls:{[_]:y.url,...Object.fromEntries(l.environments.map(b=>[b.id,b.url]))},docs:void 0}))})},changedBaseUrlIds1:i?p:u,changedBaseUrlIds2:i?u:p}}if(o.type==="multipleBaseUrls"&&c.type==="singleBaseUrl"||o.type==="singleBaseUrl"&&c.type==="multipleBaseUrls"){let f=o.type==="singleBaseUrl"?o:c,s=o.type==="multipleBaseUrls"?o:c,{deconflictedEnvironments1:u,changedBaseUrlIds1:l}=xYS(f,s,r);return{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[...s.baseUrls,...u.environments.map(p=>({id:p.id,name:p.name}))],environments:s.environments.map(p=>({...p,urls:{...p.urls,...Object.fromEntries(u.environments.map(_=>[_.id,_.url]))}}))})},changedBaseUrlIds1:o.type==="singleBaseUrl"?l:void 0,changedBaseUrlIds2:o.type==="singleBaseUrl"?void 0:l}}if(o.type==="multipleBaseUrls"&&c.type==="multipleBaseUrls"){let{deconflictedEnvironments:f,changedBaseUrlIds:s}=GYS(o,c,r);return{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[...o.baseUrls,...f.baseUrls],environments:o.environments.flatMap(u=>f.environments.map(l=>({...u,urls:{...u.urls,...l.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function VYS(e,t,r,i){if(r!=null)for(let[o,c]of Object.entries(r)){for(let f of Object.values(e.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(e.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}if(i!=null)for(let[o,c]of Object.entries(i)){for(let f of Object.values(t.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(t.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}let n=e.services;for(let[o,c]of Object.entries(t.services))n[o]==null?n[o]=c:n[o]={availability:c.availability,name:c.name,displayName:c.displayName,basePath:c.basePath,endpoints:[...n[o].endpoints??[],...c.endpoints],pathParameters:[...n[o].pathParameters??[],...c.pathParameters??[]],headers:[...n[o].headers??[],...c.headers??[]],encoding:c.encoding,transport:c.transport,audiences:[...n[o].audiences??[],...c.audiences??[]]};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function WYS(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),o=new Map(e.environments.map(s=>[s.url,s.id])),c=t.environments.filter(s=>{let u=o.get(s.url);return u!=null?(i[s.id]=u,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let u=Iac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s});return{deconflictedEnvironments2:YE.singleBaseUrl({environments:c}),changedBaseUrlIds2:i}}function xYS(e,t,r){let i={},n=new Set(t.baseUrls.map(f=>f.id)),a=new Set(t.baseUrls.map(f=>f.name)),o=e.environments.map(f=>{if(n.has(f.id)||a.has(f.name)){let s=Iac(f.id,n);return i[f.id]=s,{...f,id:s,name:r.generateName(s)}}return f});return{deconflictedEnvironments1:YE.singleBaseUrl({environments:o}),changedBaseUrlIds1:i}}function GYS(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),o=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let u=Iac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s}),c=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([u,l])=>[i[u]??u,l]))}));return{deconflictedEnvironments:YE.multipleBaseUrls({baseUrls:o,environments:c}),changedBaseUrlIds:i}}function hc_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function Iac(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var Ra=class e{breadcrumbs=[];context;static STRING=br.TypeReference.primitive({v1:"STRING",v2:br.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=br.TypeReference.container(br.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var bc_=require("fs/promises");var Cac=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:o,position:c,lineStart:f}=r;this._path.length===0?this._map["."+i]={line:o,position:c,lineStart:f}:this._fragments.push({path:this._path.join(".")+"."+i,line:o,position:c,lineStart:f})}else if(n==="mapping"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=0;this.iterFragments(a,f=>{c++,!((!f.children||f.children.length===0)&&c%2===1)&&(this._path.length===1?this.resolveNode(f,f.path):(o.children.push({...f,path:f.path.slice(a.length+1)}),o.line=f.line,o.position=f.position,o.lineStart=f.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else if(n==="sequence"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=new Set,f=i.length;this.iterFragments(a,s=>{c.has(s.position)||(f--,c.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${f}`):(o.children.push({...s,path:f.toString()}),o.line=s.line,o.position=s.position,o.lineStart=s.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},yc_=Cac;var N0e;(function(e){e.WARNING="warning",e.ERROR="error"})(N0e||(N0e={}));var SCi=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new qac({logger:t,relativePathToFile:Ye.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",o=`${n.message}|${n.level||N0e.WARNING}|${a}`;r.has(o)?i++:(r.add(o),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===N0e.ERROR?t++:(i.level===N0e.WARNING||i.level===void 0)&&r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors){let i=r.level??N0e.WARNING;if(!(i===N0e.WARNING&&!t))switch(i){case N0e.ERROR:if(this.logger.log($s.Debug,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Debug,` - at location (${a})`)}break;case N0e.WARNING:if(this.logger.log($s.Warn,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Warn,` - at location (${a})`)}r.resolution&&this.logger.log($s.Warn,` - resolution: ${r.resolution}`);break}}}},qac=class{logger;relativePathToFile;map=new yc_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,bc_.readFile)(this.relativePathToFile,"utf-8");Ni.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log($s.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var SB=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;generateV1Examples;documentBaseDir;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=_x({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint,this.generateV1Examples=t.generateV1Examples,this.documentBaseDir=t.documentBaseDir}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=No(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(o=>o.replace(/~1/g,"/"));for(let o of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:N0e.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[o]}return n==null?(i||this.errorCollector.collect({level:N0e.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,o;if(this.isExternalReference(t.$ref)){n=!0;let s=t.$ref.split("#"),u=s[0];if(i=s[1],!u)return{resolved:!1};o=u;let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let p=await l.text();try{a=JSON.parse(p),r=a}catch{a=Ni.load(p),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let c=i??t.$ref;if(c==null||typeof c!="string")return{resolved:!1};let f=c.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(s=>s.replace(/~1/g,"/"));for(let s of f){if(typeof r!="object"||r==null)return{resolved:!1};r=r[s]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let s=new Set;s.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,s,o)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let o=[];for(let c of t)o.push(await this.resolveNestedExternalReferences(c,r,i,n));return o}if(this.isReferenceObject(t)){let o=t.$ref;if(this.isExternalReference(o)){if(i.has(o))return t;i.add(o);let c=await this.resolveMaybeExternalReference({$ref:o});if(i.delete(o),c.resolved)return c.value}else{let c=`${n}${o}`;if(i.has(c))return t;i.add(c);let f=r,s=o.substring(2).split("/").map(u=>u.replace(/~1/g,"/").replace(/~0/g,"~"));for(let u of s){if(typeof f!="object"||f===null)return t;f=f[u]}if(f!=null){let u=await this.resolveNestedExternalReferences(f,r,i,n);return i.delete(o),u}i.delete(o)}return t}let a={};for(let[o,c]of Object.entries(t))typeof c=="object"&&c!==null?a[o]=await this.resolveNestedExternalReferences(c,r,i,n):a[o]=c;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let a=this.resolveReference({reference:r});if(!a.resolved)return;r=a.value}let{readOnly:i,writeOnly:n}=this.getReadOnlyWriteOnlyFromSchema(r);if(!(i&&n)){if(i)return Y9t.ReadOnly;if(n)return Y9t.WriteOnly}}getReadOnlyWriteOnlyFromSchema(t){if(t.allOf&&t.allOf.length>0){let r=!0,i=!0;for(let n of t.allOf){let a=n;if(this.isReferenceObject(n)){let c=this.resolveReference({reference:n});if(!c.resolved)continue;a=c.value}let o=this.getReadOnlyWriteOnlyFromSchema(a);r=r&&o.readOnly,i=i&&o.writeOnly}return{readOnly:r,writeOnly:i}}else return{readOnly:!!t.readOnly,writeOnly:!!t.writeOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new C1.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new C1.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:IC.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return ni.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://"))}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t||"summary"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var kc=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};var C1={};Kt(C1,{AudienceExtension:()=>JFo,FernAvailabilityExtension:()=>$Fo,FernEnumExtension:()=>YFo,FernIgnoreExtension:()=>ZKi,FernOptionalExtension:()=>XFo,FernTypeExtension:()=>tQo,FernTypeNameExtension:()=>rQo,SdkGroupNameExtension:()=>ZFo,SdkMethodNameExtension:()=>kFo,ServerFromOperationNameExtension:()=>eQo});var JFo=class extends kc{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var $Fo=class extends kc{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return IC.InDevelopment;case"PRE_RELEASE":case"BETA":return IC.PreRelease;case"GENERAL_AVAILABILITY":case"GA":return IC.GeneralAvailability;case"DEPRECATED":return IC.Deprecated;default:return}}};var HYS=Tt.object({snake:Tt.string().optional(),camel:Tt.string().optional(),screamingSnake:Tt.string().optional(),pascal:Tt.string().optional()}),KYS=Tt.object({description:Tt.string().optional(),name:Tt.string().optional(),casing:HYS.optional()}),vc_=Tt.record(KYS);var YFo=class extends kc{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=vc_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var ZKi=class extends kc{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),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-ignore",path:this.breadcrumbs});return}return t}}};var XFo=class extends kc{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var ZFo=class extends kc{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var kFo=class extends kc{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var eQo=class extends kc{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var tQo=class extends kc{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var rQo=class extends kc{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var lFt=class extends Ra{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new YKi(i),this.ir={auth:{docs:void 0,requirement:br.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:br.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}},audiences:void 0,generationMetadata:void 0,apiPlayground:void 0}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new ZKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new ZKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0};this.irGraph.hasNoAudiences()||(t=this.filterIrForAudiences(t));let r=this.context.exampleGenerationArgs,i=Eac({ir:t,exampleGeneration:r});if(this.context.generateV1Examples){let n=hPa({ir:t,exampleGeneration:r});return{...t,...n,...i}}return{...t,...i}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let o=[];for(let c of a.endpoints)r.has(c.id)&&o.push(c);a.endpoints=o}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference(i);if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r,specType:i="openapi"}){return i==="openapi"?!r.some(n=>n.url===t.url&&"x-fern-server-name"in n&&"x-fern-server-name"in t&&n["x-fern-server-name"]===t["x-fern-server-name"]):!r.some(n=>n.url===t.url&&"name"in n&&"name"in t&&n.name===t.name)}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>No(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,o=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),o.webhooks=a;let c=this.context.createFernFilepath();this.irGraph.addWebhook(c,t),i!=null&&this.irGraph.markWebhookForAudiences(c,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=No(n?.join(".")),o=No(r),c=this.context.namespace?`${No(this.context.namespace)}/`:"",f=a?`channel_${c}${a}`:`channel_${c}${o}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[o]});this.ir.websocketChannels={...this.ir.websocketChannels,[f]:t},f!==""?s.websocket==null&&(s.websocket=f):this.ir.rootPackage.websocket="";let u=this.context.createFernFilepath();this.irGraph.addChannel(u,f,t),i!=null&&this.irGraph.markChannelForAudiences(u,f,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addGlobalHeadersToIr(t){this.ir.headers=t}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addSchemaOutputToIr(t,r){let{convertedSchema:i,inlinedTypes:n}=r,o=Object.keys(n).some(c=>c===t)?`${t}Wrapper`:t;this.addTypeToPackage(o),this.addTypesToIr({...n,[o]:i})}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r,endpointGroupDisplayName:i}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:i,basePath:jD(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0,audiences:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>No(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:void 0,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}};var WO={};Kt(WO,{AbstractConverters:()=>Rac,ExampleConverter:()=>F0e,SchemaConverters:()=>Tac,ServersConverter:()=>Phe});var Rac={};Kt(Rac,{AbstractMediaTypeObjectConverter:()=>aQo,AbstractParameterConverter:()=>oQo});var JYS=/^literal<\s*(?:"(.*)"|(true|false))\s*>$/;function $YS(e){return e.type==="array"||e.properties||e.oneOf||e.anyOf||e.allOf||e.additionalProperties?!1:!!(e.type==="string"||e.type==="number"||e.type==="integer"||e.type==="boolean"||e.const!==void 0||Array.isArray(e.enum)&&e.enum.length>0)}function gc_(e){if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0]}var F0e=class e extends Ra{MAX_DEPTH=12;EXAMPLE_STRING=cu.STRING;EXAMPLE_NUMBER=cu.DOUBLE;EXAMPLE_BOOLEAN=cu.BOOLEAN;EXAMPLE_INTEGER=cu.INT;EXAMPLE_DATE=cu.DATE;EXAMPLE_DATE_TIME=cu.DATE_TIME;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;seenRefs;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:o,generateOptionalProperties:c=!1,seenRefs:f=new Set}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=o,this.generateOptionalProperties=c,this.seenRefs=f}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:typeof this.example<"u"?this.example:{},errors:[]};if(this.context.isReferenceObject(this.schema)){let i=this.schema.$ref;if(this.seenRefs.has(i))return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}}let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(t==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]};if(typeof t!="object")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]};if("nullable"in t&&t.nullable===!0&&this.example===null)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.maybeConvertLiteralFernType(t);return r??(Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]})}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.default:this.schema.default,i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.const:this.schema.const;return typeof r=="boolean"||typeof i=="boolean"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i??r,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,usedProvidedExample:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.default;return typeof i=="number"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.adjustNumberToConstraints(this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,r),errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}adjustNumberToConstraints(t,r){if(r==null)return this.context.logger.debug("[ExampleConverter.adjustNumberToConstraints] Schema object is null, returning original number","number:",t.toString()),t;let{minimum:i,maximum:n,exclusiveMinimum:a,exclusiveMaximum:o}=r,c;a!=null?typeof a=="boolean"?c=i!=null?i+Math.max(Number.EPSILON,Math.abs(i)*1e-10):void 0:c=a+Math.max(Number.EPSILON,Math.abs(a)*1e-10):i!=null&&(c=i);let f;return o!=null?typeof o=="boolean"?f=n!=null?n-Math.max(Number.EPSILON,Math.abs(n)*Number.EPSILON):void 0:f=o-Math.max(Number.EPSILON,Math.abs(o)*Number.EPSILON):n!=null&&(f=n),c!==void 0&&f!==void 0?(t<c||t>f)&&(t=c+(f-c)/2):c!==void 0&&t<c?t=c+Math.abs(c*.1):f!==void 0&&t>f&&(t=f-Math.abs(f*.1)),Number(Number(t).toPrecision(3))}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;if(typeof t=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.format==="date"?this.EXAMPLE_DATE:r?.format==="date-time"?this.EXAMPLE_DATE_TIME:this.EXAMPLE_STRING;return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??i,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(f=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:f,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),o=a.every(f=>f?.isValid??!1)&&!r,c=!r&&a.some(f=>f.usedProvidedExample);return{isValid:o,coerced:!1,usedProvidedExample:c,validExample:a.map(f=>f.validExample),errors:o?[]:a.flatMap(f=>f.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([s,u])=>{if(typeof u!="object")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(u)&&!this.isRequiredProperty({key:s,resolvedSchema:t}))return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in u&&u.readOnly===!0&&"writeOnly"in u&&u.writeOnly===!0)return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in u&&u.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("writeOnly"in u&&u.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};let l=!(s in r)||!("nullable"in u)&&r[s]==null||"nullable"in u&&u.nullable===!0&&r[s]===void 0,p=!t.required?.includes(s);if(l&&p){if(this.example===void 0&&this.generateOptionalProperties){let _=this.maybeResolveSchemaExample(u),h=new e({breadcrumbs:[...this.breadcrumbs,s],context:this.context,schema:u,example:_,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()});return{key:s,result:h.convert()}}return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}}}else{let h=r[s]??this.maybeResolveSchemaExample(u),b=new e({breadcrumbs:[...this.breadcrumbs,s],context:this.context,schema:u,example:h,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();return{key:s,result:b}}}),n=(t.allOf??[]).map((s,u)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${u}]`],context:this.context,schema:{...t,...s,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),a=i.every(s=>s.result.isValid)&&n.every(s=>s.isValid),o=this.example!==void 0&&(i.some(({result:s})=>s.usedProvidedExample)||n.some(s=>s.usedProvidedExample)),c=Object.fromEntries(i.map(({key:s,result:u})=>[s,u.validExample]).filter(([s,u])=>u!==void 0));for(let s of n)if(typeof s.validExample=="object"&&s.validExample!==null){let u=s.validExample;c={...c,...Object.fromEntries(Object.entries(u).filter(([l,p])=>p!==void 0))}}let f=[];if(t.additionalProperties!==!1){let s=typeof t.additionalProperties=="object"?t.additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object"},{type:"array"}]},u=new Set(Object.keys(c??{}));Object.keys(r).filter(p=>!u.has(p)).forEach(p=>{let h=new e({breadcrumbs:[...this.breadcrumbs,p],context:this.context,schema:s,example:r[p],depth:this.depth+1,generateOptionalProperties:!1,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();f.push({key:p,result:h})})}for(let{key:s,result:u}of f)u.validExample!==void 0&&c[s]===void 0&&(c[s]=u.validExample);if(Object.keys(c).length===0){let s=n.find(u=>u.validExample!==void 0&&(typeof u.validExample!="object"||u.validExample===null));s&&(c=s.validExample)}return{isValid:a,coerced:!1,usedProvidedExample:o,validExample:c,errors:[...i.flatMap(({result:s})=>s.errors),...n.flatMap(s=>s.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();let r=t.type.map((c,f)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${f}]`],context:this.context,schema:{...t,type:c},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),i=r.some(c=>c?.isValid??!1),a=r.find(c=>c.isValid)?.validExample??r[0]?.validExample??null,o=r.some(c=>c.usedProvidedExample);return{isValid:i,coerced:!1,usedProvidedExample:o,validExample:a,errors:i?[]:r.flatMap(c=>c?.errors??[])}}convertUnion({resolvedSchema:t,unionType:r}){let i=r==="oneOf"?t.oneOf:t.anyOf;if(!(r in t)||i==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};let n=this.example??this.maybeResolveSchemaExample(t);if(this.example===void 0){let p=[];for(let h of i){if(!h)continue;let y=this.context.resolveMaybeReference({schemaOrReference:h,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});y&&p.push(y)}if(p.length>0&&p.every(h=>$YS(h))){let h=p.findIndex(y=>gc_(y)!==void 0);if(h!==-1){let y=i[h],b=p[h];if(y&&b){let v=gc_(b),A=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${h}]`],context:this.context,schema:r==="oneOf"?{...t,...y,oneOf:void 0}:y,example:v,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(A.isValid)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:A.validExample,errors:[]}}}}}let a=[],o=null,c=null;for(let p=0;p<i.length;p++){let _=i[p];if(!_)continue;let h=r==="oneOf"?{...t,..._,oneOf:void 0}:_,y=n??this.maybeResolveSchemaExample(h),v=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${p}]`],context:this.context,schema:h,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(v.isValid&&!v.coerced&&v.usedProvidedExample)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:v.validExample,errors:[]};if(v.isValid&&!v.coerced)return{isValid:!0,coerced:!1,usedProvidedExample:v.usedProvidedExample,validExample:v.validExample,errors:[]};a.push(v),v.isValid&&v.usedProvidedExample&&c===null&&(c=v),v.isValid&&o===null&&(o=v)}let f=c??o,s=f!==null,u=f?.validExample??a[0]?.validExample,l=f?.usedProvidedExample??!1;return{isValid:s,coerced:!1,usedProvidedExample:l,validExample:u,errors:s?[]:a.flatMap(p=>p.errors)}}convertOneOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"oneOf"})}convertAnyOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"anyOf"})}getMaybeUpdatedSeenRefs(){let t=new Set(this.seenRefs);return this.context.isReferenceObject(this.schema)&&t.add(this.schema.$ref),t}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r){let i=r.examples;return Array.isArray(i)&&i.length>0?i[0]:Object.values(i??{})[0]}}}maybeConvertLiteralFernType(t){let r=t["x-fern-type"];if(typeof r!="string")return;let i=r.match(JYS);if(i!=null){if(i[1]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[1],errors:[]};if(i[2]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[2]==="true",errors:[]}}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var Tac={};Kt(Tac,{ArraySchemaConverter:()=>fQn,EnumSchemaConverter:()=>uQn,ObjectSchemaConverter:()=>sQn,OneOfSchemaConverter:()=>cQn,PrimitiveSchemaConverter:()=>lQn,SchemaConverter:()=>MCi,SchemaOrReferenceConverter:()=>LL});function Oc_(e){return wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return ni.primitive({v1:"BASE_64",v2:Pn.base64({})});case"BOOLEAN":return ni.primitive({v1:"BOOLEAN",v2:Pn.boolean({default:void 0})});case"DATE":return ni.primitive({v1:"DATE",v2:Pn.date({})});case"DATE_TIME":return ni.primitive({v1:"DATE_TIME",v2:Pn.dateTime({})});case"FLOAT":return ni.primitive({v1:"FLOAT",v2:Pn.float({})});case"DOUBLE":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:void 0,validation:void 0})});case"UINT":return ni.primitive({v1:"UINT",v2:Pn.uint({})});case"UINT_64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({})});case"INTEGER":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:void 0,validation:void 0})});case"LONG":return ni.primitive({v1:"LONG",v2:Pn.long({default:void 0})});case"STRING":return ni.primitive({v1:"STRING",v2:Pn.string({default:void 0,validation:void 0})});case"UUID":return ni.primitive({v1:"UUID",v2:Pn.uuid({})});case"BIG_INTEGER":return ni.primitive({v1:"BIG_INTEGER",v2:Pn.bigInteger({default:void 0})});default:return}},unknown:()=>ni.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return ni.container(es.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return ni.container(es.list(t))},optional:t=>{if(t!=null)return ni.container(es.optional(t))},nullable:t=>{if(t!=null)return ni.container(es.nullable(t))},set:t=>{if(t!=null)return ni.container(es.set(t))},literal:t=>ni.container(es.literal(t._visit({string:r=>uz.string(r),boolean:r=>uz.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var uQn=class extends Ra{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),o=this.maybeFernEnum?.[a],c=o?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:c,wireValue:a}),docs:o?.description,availability:void 0,casing:o?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:Zc.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var iQo=class extends Ra{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=ni.container(es.map({keyType:Ra.STRING,valueType:ni.unknown()}));return{type:Zc.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new LL({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=ni.container(es.map({keyType:Ra.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:Zc.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function bPa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],o={},c={},f=new Set;for(let[s,u]of Object.entries(e??{})){let l=[...r,"properties",s];if(typeof u!="object"){n.collect({message:`Schema property ${s} should be an object`,path:l});continue}let p=YYS(r,u,i)??i.convertBreadcrumbsToName(l),_="nullable"in u?u.nullable:!1,y=new LL({context:i,breadcrumbs:l,schemaOrReference:u,schemaIdOverride:p,wrapAsOptional:!t.includes(s),wrapAsNullable:_}).convert();if(y!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:y.type,docs:u.description,availability:y.availability,propertyAccess:i.getPropertyAccess(u),v2Examples:y.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),o={...o,...y.inlinedTypes},y.schema?.typeDeclaration.referencedTypes!=null&&y.schema.typeDeclaration.referencedTypes.forEach(b=>{f.add(b)});for(let b of y.schema?.audiences??[])c[b]==null&&(c[b]=new Set),c[b].add(s)}}for(let s of Object.keys(o))f.add(s);return{convertedProperties:a,propertiesByAudience:c,inlinedTypesFromProperties:o,referencedTypes:f}}function YYS(e,t,r){return r.isReferenceObject(t)?void 0:new C1.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var sQn=class extends Ra{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:Zc.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=bPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),o=[],c=n,f=this.schema.required!=null&&this.schema.required.length>0,s=i,u=a;for(let[l,p]of(this.schema.allOf??[]).entries()){let _=[...this.breadcrumbs,"allOf",l.toString()],h;if(this.context.isReferenceObject(p)){let A=this.context.resolveMaybeReference({schemaOrReference:p,breadcrumbs:_});if(A==null){this.context.logger.debug?.(`[ObjectSchemaConverter] allOf[${l}] reference could not be resolved. Skipping: ${JSON.stringify(p)}`);continue}if(h=A,typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0),!f||Object.keys(h.properties??{}).every(g=>!this.schema.required?.includes(g))){this.addTypeReferenceToExtends({reference:p,breadcrumbs:_,extends_:o,referencedTypes:c});continue}}else h=p;typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0);let{convertedProperties:y,inlinedTypesFromProperties:b,referencedTypes:v,propertiesByAudience:O}=bPa({properties:h.properties??{},required:[...this.schema.required??[],...h.required??[]],breadcrumbs:_,context:this.context,errorCollector:this.context.errorCollector});r.push(...y),s={...s,...b},u={...u,...O},v.forEach(A=>{c.add(A)})}for(let l of Object.keys(s))c.add(l);return{type:Zc.object({properties:r,extends:o.map(l=>this.context.typeReferenceToDeclaredTypeName(l)).filter(ps),extendedProperties:[],extraProperties:t}),propertiesByAudience:u,referencedTypes:c,inlinedTypes:s}}addTypeReferenceToExtends({reference:t,breadcrumbs:r,extends_:i,referencedTypes:n}){let a=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:r});a.ok&&i.push(a.reference);let o=this.context.getTypeIdFromSchemaReference(t);o!=null&&n.add(o)}};var nQo=class extends kc{node;key="x-fern-discriminated";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t!=null&&typeof t=="boolean")return t}};var cQn=class extends Ra{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():new nQo({context:this.context,breadcrumbs:this.breadcrumbs,node:this.schema}).convert()===!1?this.convertAsUndiscriminatedUnion():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[f,s]of Object.entries(this.schema.discriminator.mapping??{})){let u=new LL({context:this.context,schemaOrReference:{$ref:s},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",f]}),l=this.context.getTypeIdFromSchemaReference({$ref:s});l!=null&&r.add(l);let p=u.convert();if(p?.type!=null&&l!=null){for(let h of Object.keys(p?.inlinedTypes??{}))r.add(h);for(let h of p.schema?.typeDeclaration.referencedTypes??[])r.add(h);let _=this.context.casingsGenerator.generateNameAndWireValue({name:f,wireValue:f});t.push({docs:void 0,discriminantValue:_,availability:p.availability,displayName:f,shape:oz.samePropertiesAsObject({typeId:l,name:this.context.casingsGenerator.generateName(l),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:f})}),i={...i,...p.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:o}=bPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);let c=[];for(let[f,s]of(this.schema.allOf??[]).entries()){let u=[...this.breadcrumbs,"allOf",f.toString()];if(this.context.isReferenceObject(s)){let l=this.context.convertReferenceToTypeReference({reference:s,breadcrumbs:u});if(l.ok){let _=this.context.typeReferenceToDeclaredTypeName(l.reference);_!=null&&c.push(_)}let p=this.context.getTypeIdFromSchemaReference(s);p!=null&&r.add(p);continue}}for(let f of Object.keys({...i,...o}))r.add(f);return{type:Zc.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:c,types:t}),referencedTypes:r,inlinedTypes:{...i,...o}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={},n=[...this.schema.oneOf??[],...this.schema.anyOf??[]].filter(a=>!this.context.isReferenceObject(a));for(let[a,o]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(o)){let p;if(this.context.isReferenceObjectWithIdentifier(o))p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.summary??o.title??o.name??o.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(o)!=null){let h=this.getDiscriminatorKeyForRef(o);p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:h,displayNameOverrideSource:"discriminator_key"})}else p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.$ref.split("/").pop(),displayNameOverrideSource:"schema_identifier"});p.ok&&t.push({type:p.reference,docs:o.description});let _=this.context.getTypeIdFromSchemaReference(o);_!=null&&r.add(_);continue}let c=this.extendSubSchema(o),f=this.context.convertBreadcrumbsToName([`${this.id}_${a}`]),s=o.title,l=new MCi({context:this.context,id:f,nameOverride:s,breadcrumbs:[...this.breadcrumbs,`oneOf[${a}]`],schema:c??o}).convert();if(l!=null){let p=l.convertedSchema.typeDeclaration.shape;p.type==="alias"&&this.typeReferenceIsWrappedPrimitive(p.aliasOf)?t.push({type:p.aliasOf,docs:o.description}):p.type==="object"&&p.properties.length===0?t.push({type:ni.container(es.map({keyType:Ra.STRING,valueType:ni.unknown()})),docs:o.description}):(t.push({type:this.context.createNamedTypeReference(f,s),docs:o.description}),i={...i,...l.inlinedTypes,[f]:l.convertedSchema}),l.convertedSchema.typeDeclaration.referencedTypes.forEach(_=>{r.add(_)})}}return{type:Zc.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new LL({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:Zc.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return ni.container(es.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var lQn=class extends Ra{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);if(t!=null)return ni.container(es.literal(uz.string(t)));if(this.context.settings.typeDatesAsStrings===!1){if(this.schema.format==="date")return ni.primitive({v1:Su.Date,v2:Pn.date({})});if(this.schema.format==="date-time")return ni.primitive({v1:Su.DateTime,v2:Pn.dateTime({})})}return ni.primitive({v1:"STRING",v2:Pn.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ni.primitive({v1:"FLOAT",v2:Pn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ni.primitive({v1:"LONG",v2:Pn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ni.primitive({v1:"UINT",v2:Pn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ni.primitive({v1:"FLOAT",v2:Pn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ni.primitive({v1:"LONG",v2:Pn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ni.primitive({v1:"UINT",v2:Pn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?ni.container(es.literal(uz.boolean(t))):ni.primitive({v1:"BOOLEAN",v2:Pn.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var XYS=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],MCi=class e extends Ra{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:o}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=o,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let o=this.tryConvertTypeArraySchema();if(o!=null)return o;let c=this.tryConvertOneOfAnyOfSchema();if(c!=null)return c;let f=this.tryConvertMapSchema();if(f!=null)return f;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let u=this.tryConvertUntypedSchema();if(u!=null)return u;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new C1.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new uQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let r=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(r!=null){let n=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:r,id:this.id,inlined:!0}).convert();if(n?.convertedSchema.typeDeclaration?.shape.type!=="object")return n}}if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&Array.isArray(this.schema.allOf)&&this.schema.allOf.length>=1){let r={};for(let n of this.schema.allOf??[]){if(this.context.isReferenceObject(n))return;r=NMn(r,n,(a,o)=>{if(o===n)return a;if(Array.isArray(a)&&Array.isArray(o))return[...a,...o]})}return new e({context:this.context,breadcrumbs:this.breadcrumbs,schema:r,id:this.id,inlined:!0}).convert()}}tryConvertPrimitiveSchema(){let r=new lQn({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new fQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new cQn({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){if(typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties===!1)return;let r=new iQo({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new sQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:ni.unknown(),resolvedType:ni.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new C1.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=Oc_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...XYS,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),o=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=o}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(o=>{this.context.errorCollector.collect({message:o.message,path:o.path})}),n}};var LL=class extends Ra{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:o=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=o}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:r.inlinedTypes??{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new MCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let o=a.convertedSchema.typeDeclaration.shape;return o.type==="alias"?{type:this.wrapTypeReference(o.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return ni.container(es.optional(t))}wrapInNullable(t){return ni.container(es.nullable(t))}};var fQn=class e extends Ra{static LIST_UNKNOWN=ni.container(es.list(ni.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:ni.container(es.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var aQo=class extends Ra{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let f=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(f==null)return;t.schema=f}let o=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(o==null)return;let c=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([f,s])=>{if(this.context.isReferenceObject(s)){let u=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return u.resolved?[f,u.value.value??u.value]:null}return[f,s.value??s]}).filter(f=>f!=null)):void 0;return{...o,examples:c}}parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:r}){let n=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs],schemaOrReference:t,schemaIdOverride:r}).convert();if(n!=null)return{...n,examples:void 0}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,o=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[c,f]of o){let s=this.context.resolveExampleWithValue(f),u=this.context.isExampleWithSummary(f)?f.summary:c;s!=null&&(a!=null?n.userSpecifiedExamples[u]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[u]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let c=No(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[c]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let o=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(o==null)return;let c=this.context.getExamplesFromSchema({schema:o,breadcrumbs:this.breadcrumbs}),f=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:o,example:r??c[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:u}=f.convert();return i||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),s}};var oQo=class extends Ra{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),o=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Ra.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Ra.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??Ra.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:o??t})},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,o]of Object.entries(n??{})){let c=this.context.resolveExampleWithValue(o);c!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:c}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:o}=n.convert();return r||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};var uQo=class extends kc{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var Ac_="Base",Phe=class e extends Ra{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(c=>{let f=e.getServerName({server:c,context:this.context});return{id:f,name:this.context.casingsGenerator.generateName(f)}}).filter((c,f,s)=>s.findIndex(u=>u.id===c.id)===f),a=[i,...n],o=this.servers.map(c=>{let f=e.getServerName({server:c,context:this.context}),s=this.endpointLevelServers?.map(u=>[e.getServerName({server:u,context:this.context}),this.getServerUrl(u)]);return{id:f,name:this.context.casingsGenerator.generateName(f),urls:{[r]:this.getServerUrl(c),...Object.fromEntries(s??[])},docs:c.description}});return{value:{defaultEnvironment:o[0]?.id,environments:YE.multipleBaseUrls({baseUrls:a,environments:o})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.maybeRemoveTrailingSlashIfNotEmpty(this.getServerUrl(r)),docs:r.description}}).filter(ps);return{value:{defaultEnvironment:t[0]?.id,environments:YE.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new uQo({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return t.name!=null?t.name:e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,encodeURIComponent(n.default)));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([c,f])=>f.enum!=null&&f.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,o]=n;return o.enum==null?[r]:o.enum.map(c=>{let f=r.url.replace(`{${a}}`,encodeURIComponent(c)),s={};for(let[l,p]of Object.entries(r.variables??{}))l!==a&&(s[l]=p);let u={...r,url:f,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${c}`:`${c}`,description:r.description};return this.withExplodedServers([u])[0]})}).filter(ps)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?Ac_:e.getServerExtensionName({server:this.servers[0],context:this.context})??Ac_}maybeRemoveTrailingSlashIfNotEmpty(t){return t.endsWith("/")&&t!=="/"?t.slice(0,-1):t}};var sQo={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"},ZYS=new Set(Object.values(sQo));var dQn=class{enabled=!0;write(t,...r){this.enabled&&process.stderr.write(`[${t}] ${r.join(" ")}
1358
+ `)}var cPa=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function yac(e){return e.scheme==="oauth"}var aYS={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},xs_=new Set(Object.values(aYS));function HS(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!xs_.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function R0e(e){return HS(e)!=null}function bac(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}function vac(e){if(e.response!=null)return typeof e.response=="string"?e.response:e.response.type}var VKi=class{REFERENCE_REGEX=/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};function YP(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function oGt(e){return e?e.proto!=null:!1}var oYS="text";function kFn(e){return e===oYS}var vx={integer:"integer",long:"long",uint:"uint",uint64:"uint64",float:"float",double:"double",boolean:"boolean",string:"string",datetime:"datetime",base64:"base64",uuid:"uuid",date:"date",bigint:"bigint",unknown:"unknown"};var eK={MAP:/^map<\s*([^,]*)\s*,\s*(.*)\s*>$/,LIST:/^list<\s*(.*)\s*>$/,SET:/^set<\s*(.*)\s*>$/,OPTIONAL:/^optional<\s*(.*)\s*>$/,NULLABLE:/^nullable<\s*(.*)\s*>$/,LITERAL:/^literal<\s*(?:"(.*)"|(true|false))\s*>$/};function WKi({type:e,_default:t,validation:r,visitor:i}){switch(e){case vx.integer:{let u=r??void 0;return i.primitive({v1:Su.Integer,v2:Pn.integer({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case vx.double:{let u=r??void 0;return i.primitive({v1:Su.Double,v2:Pn.double({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case vx.string:{let u=r??void 0;return i.primitive({v1:Su.String,v2:Pn.string({default:t??void 0,validation:u!=null?{format:u.format,pattern:u.pattern,minLength:u.minLength,maxLength:u.maxLength}:void 0})})}case vx.float:return i.primitive({v1:Su.Float,v2:void 0});case vx.long:return i.primitive({v1:Su.Long,v2:Pn.long({default:t??void 0})});case vx.boolean:return i.primitive({v1:Su.Boolean,v2:Pn.boolean({default:t??void 0})});case vx.datetime:return i.primitive({v1:Su.DateTime,v2:void 0});case vx.date:return i.primitive({v1:Su.Date,v2:void 0});case vx.uuid:return i.primitive({v1:Su.Uuid,v2:void 0});case vx.base64:return i.primitive({v1:Su.Base64,v2:void 0});case vx.bigint:return i.primitive({v1:Su.BigInteger,v2:Pn.bigInteger({default:t??void 0})});case vx.uint:return i.primitive({v1:Su.Uint,v2:void 0});case vx.uint64:return i.primitive({v1:Su.Uint64,v2:void 0});case vx.unknown:return i.unknown()}let n=e.match(eK.MAP);if(n?.[1]!=null&&n[2]!=null)return i.map({keyType:n[1],valueType:n[2]});let a=e.match(eK.LIST);if(a?.[1]!=null)return i.list(a[1]);let o=e.match(eK.SET);if(o?.[1]!=null)return i.set(o[1]);let c=e.match(eK.OPTIONAL);if(c?.[1]!=null)return i.optional(c[1]);let f=e.match(eK.NULLABLE);if(f?.[1]!=null)return i.nullable(f[1]);let s=e.match(eK.LITERAL);if(s?.[1]!=null)return i.literal(uz.string(s[1]));if(s?.[2]!=null){let u=s[2];switch(u){case"false":return i.literal(uz.boolean(!1));case"true":return i.literal(uz.boolean(!0));default:throw new Error(`Unsupported literal value: ${u}`)}}return i.named(e)}var Gs_="bytes";function uGt(e){if(e===Gs_)return{isOptional:!1};if(e.match(eK.OPTIONAL)?.[1]===Gs_)return{isOptional:!0}}function lPa(e){let t=typeof e=="string"?e:typeof e.body=="string"?e.body:void 0;if(t!=null)return uGt(t)}function gac({input:e,typeName:t}){for(let r of e.arguments)if(typeof r=="string"){if(r===t)return!0}else if(gac({input:r,typeName:t}))return!0;return!1}function Hs_(e){return gac({input:e,typeName:"file"})}function Ks_(e){let t=0,r=0;function i(){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return;let a="";for(;t<e.length&&e[t]!=="<"&&e[t]!==","&&e[t]!==">";)a+=e[t++];if(a.trim()){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t<e.length&&e[t]==="<"){if(t++,r++,r>128)throw new Error("Internal error; Exceeded maximum recursion depth while parsing generics.");let o={name:a.trim(),arguments:[]};for(;t<e.length&&e[t]!==">";){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t<e.length&&e[t]!==">"){let c=i();c&&o.arguments.push(c)}}if(t<e.length&&e[t]===">")t++,r--;else throw new Error("Malformed input: missing closing '>' for generic arguments.");return o}else return a.trim()}}let n=i();if(typeof n=="object")return n}var Oac="file";function Js_(e){return e.match(eK.LIST)?.[1]===Oac}function z0e(e){if(e===Oac)return{isOptional:!1,isArray:!1};let t=e.match(eK.OPTIONAL);if(t?.[1]!==void 0){if(t[1]===Oac)return{isOptional:!0,isArray:!1};if(Js_(t[1]))return{isOptional:!0,isArray:!0}}if(Js_(e))return{isOptional:!1,isArray:!0}}function uYS(e){return typeof e=="string"?!1:WA.parse(e["content-type"])?.isMultiPartFormData()??!1?!0:e.body==null?!1:!!(YP(e.body)&&Object.values(e.body.properties??[]).some(cYS))}function xKi(e){if(!(!uYS(e)||e.body==null)&&e.name!=null&&e.body!=null&&YP(e.body))return sYS(e.name,e.body)}function sYS(e,t){let r=Object.entries(t.properties??[]).reduce((i,[n,a])=>{let o=typeof a!="string"?a.docs:void 0,c=typeof a!="string"?a["content-type"]:void 0,f=typeof a!="string"?a.style:void 0,s=z0e(typeof a=="string"?a:a.type);return s!=null?i.push({isFile:!0,key:n,docs:o,isOptional:s.isOptional,isArray:s.isArray,contentType:c,style:f}):i.push({isFile:!1,key:n,propertyType:a,docs:o,contentType:c,style:f}),i},[]);return t["extra-properties"],{name:e,extends:t.extends,properties:r}}function cYS(e){let t=typeof e=="string"?e:e.type;if(t==="file")return!0;if(!t.includes("file"))return!1;let r=Ks_(t);return r==null?!1:Hs_(r)}var $s_="text";function fPa(e){if(e===$s_)return{isOptional:!1};if(e.match(eK.OPTIONAL)?.[1]===$s_)return{isOptional:!0}}function wB({type:e,_default:t,validation:r,visitor:i}){return WKi({type:e,_default:t,validation:r,visitor:{primitive:i.primitive,map:({keyType:n,valueType:a})=>i.map({keyType:wB({type:n,_default:void 0,validation:void 0,visitor:i}),valueType:wB({type:a,_default:void 0,validation:void 0,visitor:i})}),list:n=>i.list(wB({type:n,_default:void 0,validation:void 0,visitor:i})),set:n=>i.set(wB({type:n,_default:void 0,validation:void 0,visitor:i})),optional:n=>i.optional(wB({type:n,_default:t,validation:r,visitor:i})),nullable:n=>i.nullable(wB({type:n,_default:t,validation:r,visitor:i})),literal:i.literal,named:i.named,unknown:i.unknown}})}function Aac(e,t){if(lYS(e))return t.sdk(e);if(fYS(e))return t.language(e);vt(e)}function lYS(e){return e.sdk!=null}function fYS(e){return e.language!=null}function Ys_(e){return e["response-stream"]!=null&&(typeof e["response-stream"]=="string"||e["response-stream"].format==null||e["response-stream"].format==="json")}function Xs_(e){return e["response-stream"]!=null&&typeof e["response-stream"]!="string"&&e["response-stream"].format==="sse"}function GKi(e,t,r){return dYS(e,t)?r.stream(t):pYS(e,t)?r.events(t):r.body(t)}function dYS(e,t){return t.stream!==void 0&&Ys_(e)}function pYS(e,t){return t.stream!==void 0&&Xs_(e)}function HKi(e,t){if(Zs_(e))return t.single(e);if(ks_(e))return t.any(e);vt(e)}function Zs_(e){return typeof e=="string"||e.scheme!=null}function ks_(e){let[t,...r]=Object.keys(e);return t==="any"&&r.length===0}function dPa(e,t){if(ec_(e))return t.header(e);switch(e.scheme){case"basic":return t.basic(e);case"bearer":return"get-token"in e?t.inferredBearer(e):t.tokenBearer(e);case"oauth":return t.oauth(e);default:vt(e)}}function ec_(e){return e.header!=null}function sGt(e,t){if(tc_(e))return t.singleBaseUrl(e);if(Ahe(e))return t.multipleBaseUrls(e);vt(e)}function tc_(e){return typeof e=="string"||"url"in e}function Ahe(e){return typeof e!="string"&&"urls"in e}function eQn(e){return typeof e=="string"?e.startsWith("$"):"variable"in e}function EB(e,t){if(PCi(e))return t.alias(e);if(jCi(e))return t.discriminatedUnion(e);if(pb(e))return t.object(e);if(tQn(e))return t.undiscriminatedUnion(e);if(cFt(e))return t.enum(e);vt(e)}function PCi(e){return typeof e=="string"||e.type!=null}function pb(e){return e.extends!=null||e.properties!=null}function jCi(e){return e.union!=null&&e.discriminated==null}function tQn(e){let t=e;return t.union!=null&&t.discriminated!=null}function cFt(e){return e.enum!=null}function mac({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:CL.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return HKi(e.auth,{single:i=>{let n=rc_({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:CL.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:CL.Any,schemes:i.map(n=>rc_({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))})})}function rc_({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,o)=>{let c=t?.[a];if(c==null)throw new Error("Unknown auth scheme: "+a);return dPa(c,{header:f=>EA.header({key:a,docs:o,name:r.generateNameAndWireValue({name:f.name??a,wireValue:f.header}),valueType:ni.primitive({v1:Su.String,v2:Pn.string({default:void 0,validation:void 0})}),prefix:f.prefix,headerEnvVar:f.env}),basic:f=>ic_({key:a,casingsGenerator:r,docs:o,rawScheme:f}),tokenBearer:f=>VFo({key:a,casingsGenerator:r,docs:o,rawScheme:f}),inferredBearer(f){return VFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})},oauth:f=>VFo({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return VFo({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return ic_({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function VFo({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return EA.bearer({key:e,docs:r,token:t.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function ic_({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return EA.basic({key:e,docs:r,username:t.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function jD(e){let t=hYS(e),{value:r,done:i}=Pac(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[..._YS(t)]}}function*_YS(e){let t;do{let{value:r}=Pac(e,"}"),i=Pac(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*hYS(e){for(let t of e)yield t}function Pac(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function pPa({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:sGt(i,{singleBaseUrl:()=>YE.singleBaseUrl(yYS({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>YE.multipleBaseUrls(bYS({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,sGt(a,{singleBaseUrl:o=>[...typeof o=="string"?[]:o.audiences??[]],multipleBaseUrls:o=>[...o.audiences??[]]})]))}}}function yYS({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>sGt(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:nc_(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function bYS({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>sGt(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:bn(a.urls,o=>nc_(o))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function nc_(e){return e.endsWith("/")?e.slice(0,-1):e}function wCi(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let o=0;o<n.length;o++)o>0&&i(","),r(n[o],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((c,f)=>{f>0&&i(","),i(c),i(":"),r(n[c],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let o=n.charCodeAt(a);t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function cGt({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function ac_({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return lGt({containerType:t});switch(t.type){case"list":{let o=DA({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.list({list:[o.example,o.example],itemType:t.list}),jsonExample:[o.jsonExample,o.jsonExample]}}case"literal":return{type:"success",example:op.literal({literal:t.literal._visit({boolean:o=>Dn.boolean(o),string:o=>Dn.string({original:o}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:o=>o,string:o=>o,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return lGt({containerType:t});let o=DA({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.optional({optional:o.example,valueType:t.optional}),jsonExample:o.jsonExample}}case"nullable":{if(a)return lGt({containerType:t});let o=DA({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.nullable({nullable:o.example,valueType:t.nullable}),jsonExample:o.jsonExample}}case"set":{let o=DA({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?lGt({containerType:t}):{type:"success",example:op.set({set:[o.example],itemType:t.set}),jsonExample:[o.jsonExample]}}case"map":{let o=DA({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),c=DA({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"||c.type==="failure"?lGt({containerType:t}):{type:"success",example:op.map({map:[{key:o.example,value:c.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[o.jsonExample]:c.jsonExample}}}default:vt(t)}}function lGt({containerType:e}){switch(e.type){case"list":return{type:"success",example:op.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:op.literal({literal:e.literal._visit({boolean:t=>Dn.boolean(t),string:t=>Dn.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:op.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:op.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:op.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:op.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:vt(e)}}function uc_({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return mYS({fieldName:e,default_:vYS(t.v2),validation:gYS(t.v2)});case"BASE_64":return{type:"success",example:Dn.base64(cu.BASE64),jsonExample:cu.BASE64};case"BOOLEAN":return{type:"success",example:Dn.boolean(cu.BOOLEAN),jsonExample:cu.BOOLEAN};case"DATE":return{type:"success",example:Dn.date(cu.DATE),jsonExample:cu.DATE};case"DATE_TIME":return{type:"success",example:Dn.datetime({datetime:new Date(cu.DATE_TIME),raw:cu.DATE_TIME}),jsonExample:cu.DATE_TIME};case"DOUBLE":return PYS({fieldName:e,validation:OYS(t.v2)});case"FLOAT":return{type:"success",example:Dn.float(cu.FLOAT),jsonExample:cu.FLOAT};case"INTEGER":return jYS({fieldName:e,validation:AYS(t.v2)});case"UINT_64":return{type:"success",example:Dn.uint64(cu.INT64),jsonExample:cu.INT64};case"UINT":return{type:"success",example:Dn.uint(cu.UINT),jsonExample:cu.UINT};case"BIG_INTEGER":return{type:"success",example:Dn.bigInteger(cu.INT64.toString()),jsonExample:`${cu.INT64}`};case"LONG":return{type:"success",example:Dn.long(cu.INT64),jsonExample:cu.INT64};case"UUID":return{type:"success",example:Dn.uuid(cu.UUID),jsonExample:cu.UUID};default:vt(t.v1)}}function vYS(e){if(e?.type==="string")return e.default}function gYS(e){if(e?.type==="string")return e.validation}function OYS(e){if(e?.type==="double")return e.validation}function AYS(e){if(e?.type==="integer")return e.validation}function oc_(e){if(e<=cu.SAMPLE_STRINGS.length){let t=cu.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return cu.SAMPLE_STRINGS[cu.SAMPLE_STRINGS.length-1]+".".repeat(e-cu.SAMPLE_STRINGS.length)}function mYS({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Dn.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let o=oc_(n);return{type:"success",example:Dn.string({original:o}),jsonExample:o}}else if(a!=null&&a<10){let o=oc_(a);return{type:"success",example:Dn.string({original:o}),jsonExample:o}}}let i=e??cu.STRING;return{type:"success",example:Dn.string({original:i}),jsonExample:i}}function PYS({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Dn.double(r),jsonExample:r};if(i)return{type:"success",example:Dn.double(i),jsonExample:i}}return{type:"success",example:Dn.double(cu.DOUBLE),jsonExample:cu.DOUBLE}}function jYS({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Dn.integer(r),jsonExample:r};if(i)return{type:"success",example:Dn.integer(i),jsonExample:i}}return{type:"success",example:Dn.integer(cu.INT),jsonExample:cu.INT}}function wYS(e,t){if(e.type==="primitive"||e.type==="container"&&e.container.type==="literal")return!0;if(e.type==="named"){let r=t[e.typeId];if(r!=null&&r.shape.type==="enum")return!0}return!1}function KKi({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let o=DA({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure")return o;let{example:c,jsonExample:f}=o;return{type:"success",example:Ih.alias({value:c}),jsonExample:f}}case"enum":{let o=r.shape.values[0];return o==null?{type:"failure",message:"No enum values present"}:{type:"success",example:Ih.enum({value:o.name}),jsonExample:o.name.wireValue}}case"object":{let o={},c=[];if((r.shape.extendedProperties==null||r.shape.extendedProperties.length===0)&&r.shape.extends!=null)for(let l of r.shape.extends){let p=t[l.typeId];if(p==null)continue;let _=KKi({fieldName:e,typeDeclaration:p,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});_!=null&&_.type==="success"&&_.example.type==="object"&&(Object.assign(o,_.jsonExample),c.push(..._.example.properties))}let f=EYS({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(f.type==="failure")return f;let{example:s,jsonExample:u}=f;return{type:"success",example:Ih.object({properties:[...c,...s.properties],extraProperties:s.extraProperties}),jsonExample:Object.assign({},o,u)}}case"undiscriminatedUnion":{let o=r.shape.members;if(o.every(s=>wYS(s.type,t))){let s=o.findIndex(u=>{if(u.type.type==="container"&&u.type.container.type==="literal")return!0;if(u.type.type==="named"){let l=t[u.type.typeId];if(l!=null&&l.shape.type==="enum")return l.shape.values.length>0}return!1});if(s!==-1){let u=o[s];if(u!=null){let l=DA({fieldName:e,typeReference:u.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="success"){let{example:p,jsonExample:_}=l;return{type:"success",example:Ih.undiscriminatedUnion({index:s,singleUnionType:p}),jsonExample:_}}}}}let f=0;for(let s of o){let u=DA({fieldName:e,typeReference:s.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(u.type==="failure"){++f;continue}let{example:l,jsonExample:p}=u;return{type:"success",example:Ih.undiscriminatedUnion({index:f,singleUnionType:l}),jsonExample:p}}break}case"union":{let o=r.shape.discriminant,c={};if(r.shape.baseProperties!=null)for(let u of r.shape.baseProperties){let l=DA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});l.type==="success"&&(c[u.name.wireValue]=l.jsonExample)}let f=r.shape.baseProperties.map(u=>{let l=DA({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(l.type==="failure")throw new Error(`Failed to generate example for union base property ${u.name.wireValue}`);let{example:p}=l;return{name:u.name,value:p}}),s=r.shape.extends.flatMap(u=>{let l=t[u.typeId];if(l==null)throw new Error(`Failed to find extended type declaration with id ${u.typeId}`);let p=KKi({fieldName:e,typeDeclaration:l,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(p==null||p.type==="failure")throw new Error(`Failed to generate example for extended type declaration ${l.name.typeId}`);if(p.example.type!=="object")throw new Error(`Extended type declaration ${l.name.typeId} is not an object`);return p.example.properties});for(let u of r.shape.types){let l=u.shape._visit({noProperties:()=>({type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.noProperties()},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...c}}),samePropertiesAsObject:p=>{let _=t[p.typeId];if(_==null)return{type:"failure",message:`Failed to find type declaration with id ${p.typeId}`};let h=KKi({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:_,typeDeclarations:t,skipOptionalProperties:a});if(h==null)return{type:"failure",message:"Failed to generate example for type reference"};if(h.type==="failure")return h;let{example:y,jsonExample:b}=h;return{type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.samePropertiesAsObject({typeId:_.name.typeId,object:y.type==="object"?y:{properties:[],extraProperties:void 0}})},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...typeof b=="object"?b:{},...c}}},singleProperty:p=>{let _=DA({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:p.type,typeDeclarations:t,skipOptionalProperties:a});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;return{type:"success",example:Ih.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:jB.singleProperty(h)},baseProperties:f,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,[p.name.wireValue]:y,...c}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(l.type!=="failure")return l}}}return{type:"failure",message:"Failed to generate example for type reference"}}function EYS({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:o}){let c={},f=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let u=DA({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:o});if(u.type==="failure"&&!cGt({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${u.message}`};if(u.type==="failure")continue;let{example:l,jsonExample:p}=u;f.push({name:s.name,originalTypeDeclaration:t.name,value:l,propertyAccess:s.propertyAccess}),c[s.name.wireValue]=p}return{type:"success",example:Ih.object({properties:f,extraProperties:void 0}),jsonExample:c}}function DA({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:`Exceeded max depth of ${i}`};switch(t.type){case"named":{let o=r[t.typeId];if(o==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let c=KKi({fieldName:e,typeDeclaration:o,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(c==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(c.type==="failure")return c;let{example:f,jsonExample:s}=c;return{type:"success",example:{jsonExample:s,shape:lu.named({shape:f,typeName:o.name})},jsonExample:s}}case"container":{let o=ac_({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure"){let{example:s,jsonExample:u}=lGt({containerType:t.container});return{type:"success",example:{jsonExample:u,shape:lu.container(s)},jsonExample:u}}let{example:c,jsonExample:f}=o;return{type:"success",example:{jsonExample:f,shape:lu.container(c)},jsonExample:f}}case"primitive":{let{jsonExample:o,example:c}=uc_({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:o,shape:lu.primitive(c)},jsonExample:o}}case"unknown":{let o={key:"value"};return{type:"success",example:{jsonExample:o,shape:lu.unknown(o)},jsonExample:o}}}}function JKi(e,t){let r=[];for(let i of e){let n=DA({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function rQn(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&cGt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=DA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function WFo(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&cGt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=DA({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?B1.exploded():B1.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var jac=ni.primitive({v1:Su.String,v2:Pn.string({default:void 0,validation:void 0})});function iQn({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let o={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:K0.ok($P.body(void 0)),docs:void 0},c=JKi(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;o.endpointPathParameters=c.example;let f=JKi(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(f.type==="failure")return f;o.servicePathParameters=f.example;let s=JKi(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;o.rootPathParameters=s.example;let u=WFo(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(u.type==="failure")return u;o.queryParameters=u.example;let l=rQn(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(l.type==="failure")return l;o.endpointHeaders=l.example;let p=rQn(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(p.type==="failure")return p;if(o.serviceHeaders=p.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let _={},h=[];if(t.requestBody.extends!=null)for(let y of t.requestBody.extends){let b=i[y.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${y.typeId}`);let v=KKi({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});v!=null&&v.type==="success"&&Object.assign(_,v.jsonExample)}for(let y of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=DA({fieldName:y.name.wireValue,typeReference:y.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!cGt({typeDeclarations:i,typeReference:y.valueType}))return{type:"failure",message:`Failed to generate required property ${y.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:v,jsonExample:O}=b;h.push({name:y.name,originalTypeDeclaration:void 0,value:v}),_[y.name.wireValue]=O}o.request=RL.inlinedRequestBody({jsonExample:_,properties:h,extraProperties:void 0});break}case"reference":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.request=RL.reference(h);break}default:vt(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"streamParameter":{let _;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1});break;default:vt(t.response.body.nonStreamResponse)}if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"streaming":{let _;switch(t.response.body.value.type){case"sse":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.sse([{data:{...h,jsonExample:y},event:""}]));break}case"json":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.stream([{...h,jsonExample:y}]));break}case"text":{if(_=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.stream([{...h,jsonExample:y}]));break}default:vt(t.response.body.value)}break}case"text":{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:jac,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=K0.ok($P.body({...h,jsonExample:y}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:vt(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)o.response=K0.error({body:void 0,error:a.declaration.name});else{let _=DA({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.response=K0.error({body:h,error:a.declaration.name})}try{return{type:"success",example:{id:wCi(o),url:SYS(t,o),...o},jsonExample:void 0}}catch(_){return{type:"failure",message:`Parse failure with exceptions ${_}`}}}function SYS(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.fullPath.head+e.fullPath.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function wac({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=JKi(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let o=JKi(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(o.type==="failure")return o;n.pathParameters.push(...o.example);let c=WFo(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(c.type==="failure")return c;n.queryParameters=c.example;let f=rQn(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(f.type==="failure")return f;n.headers.push(...f.example);let s=rQn(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let l=t.messages.filter(h=>h.origin==="client")[0];if(l!=null){let h=sc_({message:l,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:l.type,body:h})}let _=t.messages.filter(h=>h.origin==="server")[0];if(_!=null){let h=sc_({message:_,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:_.type,body:h})}return{type:"success",example:{...n,url:MYS(t,n)},jsonExample:void 0}}function sc_({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=DA({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return ghe.reference(i.example)}function MYS(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.path.head+e.path.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function nQn(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function ECi(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function cc_({ir:e,endpoint:t,skipOptionalRequestProperties:r}){let i=e.types,n={pathParameters:{},queryParameters:{},headers:{}};for(let o of t.pathParameters){let{userExample:c,autoExample:f}=nQn(o.v2Examples);c!==void 0?n.pathParameters[o.name.originalName]=c:f!==void 0&&(n.pathParameters[o.name.originalName]=f)}for(let o of t.queryParameters){let{userExample:c,autoExample:f}=nQn(o.v2Examples);if(c!==void 0)n.queryParameters[o.name.name.originalName]=c;else if(f!==void 0){if(r&&cGt({typeReference:o.valueType,typeDeclarations:i}))continue;n.queryParameters[o.name.name.originalName]=f}}let a=[...t.headers,...e.headers,...e.idempotencyHeaders];for(let o of a){let{userExample:c,autoExample:f}=nQn(o.v2Examples);if(c!==void 0)n.headers[o.name.wireValue]=c;else if(f!==void 0){if(r&&cGt({typeReference:o.valueType,typeDeclarations:i}))continue;n.headers[o.name.wireValue]=f}}return n}function lc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let{pathParameters:i,queryParameters:n,headers:a}=cc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),o={},c={},f={endpoint:{method:e.method,path:DYS(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:i,queryParameters:n,headers:a,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"inlinedRequestBody":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}case"reference":{let{userExamples:s,autoExamples:u}=ECi(e.requestBody.v2Examples);for(let[l,p]of Object.entries(s))o[l]={...f,requestBody:p};for(let[l,p]of Object.entries(u))c[l]={...f,requestBody:p};break}default:vt(e.requestBody)}return{userRequestExamples:o,autoRequestExamples:c,baseExample:f}}function DYS(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=nQn(i.v2Examples),o=n??a,c;o==null?c=i.name.originalName:c=typeof o=="string"?o:JSON.stringify(o),t[i.name.originalName]=c});let r=e.fullPath.head+e.fullPath.parts.map(i=>encodeURIComponent(`${t[i.pathParameter]}`)+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function xFo({endpoint:e,responseObject:t}){let r=t!==void 0?t:e.response,i={},n={},a={statusCode:r?.statusCode,body:void 0,docs:void 0};if(r==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:a};if(r.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...a,body:CC.json(_Pa(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:a};switch(r.body.type){case"bytes":break;case"fileDownload":break;case"text":{let o=r.body,{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?_Pa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?_Pa(u):u;n[s]={...a,body:CC.json(l)}}break}case"json":{let o=r.body.value;if(o.type==="response"){let{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c)){let l=e.source?.type==="openrpc"?_Pa(u):u;i[s]={...a,body:CC.json(l)}}for(let[s,u]of Object.entries(f)){let l=e.source?.type==="openrpc"?_Pa(u):u;n[s]={...a,body:CC.json(l)}}}break}case"streaming":{let o=r.body.value;if(o.type==="json"){let{userExamples:c,autoExamples:f}=ECi(o.v2Examples);for(let[s,u]of Object.entries(c))i[s]={...a,body:CC.stream([u])};for(let[s,u]of Object.entries(f))n[s]={...a,body:CC.stream([u])}}break}case"streamParameter":break;default:vt(r.body)}return{userResponseExamples:i,autoResponseExamples:n,baseExample:a}}function _Pa(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}var aQn=(e,t,r)=>{let i;return e===t?i=`${e}`:i=`${e}_${t}`,r&&(i=`${i}_${r}`),i},BYS=({exampleStore:e,key:t,example:r})=>e.has(t)?!1:(e.set(t,r),!0);function GFo({key:e,displayName:t,request:r,response:i,exampleStore:n,userOrAutoStore:a}){if(!n.has(e)){let o={displayName:t,request:r,response:i,codeSamples:void 0};return a[e]=o,BYS({exampleStore:n,key:e,example:o}),!0}return!1}function fc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let i={},n={},a=new Map,{userRequestExamples:o,autoRequestExamples:c,baseExample:f}=lc_({endpoint:e,ir:t,skipOptionalRequestProperties:r}),s=Object.keys(o)[0],u=Object.values(o)[0],l=Object.keys(c)[0],p=Object.values(c)[0],_=IYS({endpoint:e,userRequestExamples:o,baseRequestExample:f,firstUserRequestName:s,firstUserRequestExample:u,firstAutoRequestName:l,firstAutoRequestExample:p,userResults:i,autoResults:n,exampleStore:a});if(CYS({endpoint:e,userRequestExamples:o,requestExamplesUsed:_,userResults:i,exampleStore:a}),Object.keys(i).length===0&&Object.keys(n).length===0){let{baseExample:h}=xFo({endpoint:e}),y=aQn(l??"base","base",void 0);GFo({key:y,displayName:l??"base",request:p??f,response:h,exampleStore:a,userOrAutoStore:n})}return{userFullExamples:i,autoFullExamples:n}}function IYS({endpoint:e,userRequestExamples:t,baseRequestExample:r,firstUserRequestName:i,firstUserRequestExample:n,firstAutoRequestName:a,firstAutoRequestExample:o,userResults:c,autoResults:f,exampleStore:s}){let u=e.v2Responses?.responses??[e.response],l=new Set;for(let p of u){let _=!1,{userResponseExamples:h,autoResponseExamples:y,baseExample:b}=xFo({endpoint:e,responseObject:p}),v=Object.keys(y)[0],O=Object.values(y)[0];for(let[A,g]of Object.entries(h)){let m,j;t[A]?(j=t[A],l.add(A),m=aQn(A,A,p?.statusCode)):o&&a?(j=o,m=aQn(a,A,p?.statusCode)):(j=r,m=aQn("base",A,p?.statusCode)),GFo({key:m,displayName:A,request:j,response:g,exampleStore:s,userOrAutoStore:c})&&(_=!0)}if(!_){let A=No(`${e.name.originalName}_example`);i&&n&&l.add(i);let g=aQn(i??a??"base",v??"base",p?.statusCode);GFo({key:g,displayName:i??a??A,request:n??o??r,response:O??b,exampleStore:s,userOrAutoStore:f})&&(_=!0)}}return l}function CYS({endpoint:e,userRequestExamples:t,requestExamplesUsed:r,userResults:i,exampleStore:n}){let{userResponseExamples:a,autoResponseExamples:o,baseExample:c}=xFo({endpoint:e}),f=Object.values(a)[0],s=Object.keys(a)[0],u=Object.keys(o)[0],l=Object.values(o)[0],p=Object.entries(t).filter(([_])=>!r.has(_));for(let[_,h]of p){let y=aQn(_,s??u??"base",f?f.statusCode:l?l.statusCode:c.statusCode);GFo({key:y,displayName:_,request:h,response:f??l??c,exampleStore:n,userOrAutoStore:i})}}function hPa({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){let o=[];if(a.userSpecifiedExamples.length===0||r.skipAutogenerationIfManualExamplesExist===!1){let c=iQn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});c.type==="success"&&o.push({example:c.example})}if(a.userSpecifiedExamples.filter(c=>c.example?.response.type==="error").length===0||r.skipErrorAutogenerationIfManualErrorExamplesExist===!1)for(let c of a.errors){let f=e.errors[c.error.errorId];if(!f)continue;let s=iQn({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"error",declaration:f}});s.type==="success"&&o.push({example:s.example})}a.autogeneratedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=wac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function Eac({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){a.v2Examples==null&&(a.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:o,autoFullExamples:c}=fc_({endpoint:a,ir:e,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(Object.keys(a.v2Examples.userSpecifiedExamples).length>0){if(Object.values(a.v2Examples.userSpecifiedExamples).some(s=>s.request!=null||s.response!=null))continue;let f=Object.values(a.v2Examples.userSpecifiedExamples).filter(s=>s!=null).flatMap(s=>s.codeSamples??[]);for(let[s,u]of Object.entries(c))c[s]={...u,codeSamples:f};for(let[s,u]of Object.entries(o))o[s]={...u,codeSamples:f}}a.v2Examples.autogeneratedExamples=c,a.v2Examples.userSpecifiedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=wac({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function pc_({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{...r.object,properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:KS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?jB.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=KS({filteredIr:e,exampleTypeReference:r});return i!==void 0?jB.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function KS({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:lu.container(op.list({...i,list:i.list.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:lu.container(op.set({...i,set:i.set.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?KS({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:lu.container(op.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?KS({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:lu.container(op.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:lu.container(op.map({...i,map:i.map.map(n=>{let a=KS({filteredIr:e,exampleTypeReference:n.key}),o=KS({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&o!==void 0?{key:a,value:o}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=KS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:lu.named({...r,shape:Ih.enum(i)})}),object:i=>({...t,shape:lu.named({...r,shape:Ih.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:KS({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=pc_({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=KS({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:lu.named({...r,shape:Ih.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function Sac({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function qYS({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function dc_({filteredIr:e,headers:t}){return t.map(r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function TYS({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=KS({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=KS({filteredIr:e,exampleTypeReference:r});return i!==void 0?RL.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function RYS({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>K0.ok($P.body(i!=null?KS({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>K0.ok($P.stream(i.map(n=>KS({filteredIr:e,exampleTypeReference:n})).filter(ps))),sse:i=>K0.ok($P.sse(i.map(({event:n,data:a})=>{let o=KS({filteredIr:e,exampleTypeReference:a});return o!==void 0?{event:n,data:o}:void 0}).filter(ps))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>K0.error({error:r,body:i!=null?KS({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function Mac({filteredIr:e,example:t}){return{...t,rootPathParameters:Sac({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:Sac({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:Sac({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:dc_({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:dc_({filteredIr:e,headers:t.endpointHeaders}),queryParameters:qYS({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?TYS({filteredIr:e,requestBody:t.request}):void 0,response:RYS({filteredIr:e,response:t.response})}}function _c_({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=KS({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:Ih.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:Ih.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:KS({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=pc_({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:Ih.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=KS({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:Ih.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function Dac(e,t){if(t==null)return e;let r=zxi(e.types,c=>t.hasType(c)),i=Object.fromEntries(Object.entries(r).map(([c,f])=>{let s=[];if(f.userProvidedExamples=f.userProvidedExamples.map(u=>_c_({filteredIr:t,exampleType:u})).filter(u=>u!==void 0),f.shape.type==="object"){for(let u of f.shape.properties)t.hasProperty(c,u.name.wireValue)&&s.push(u);return[c,{...f,shape:Zc.object({...f.shape,properties:s})}]}return[c,f]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([c,f])=>{let s=f.filter(u=>t.hasWebhook(u)).map(u=>{let l=u.id;return u.payload.type==="inlinedPayload"&&l!=null&&(u.payload={...u.payload,properties:u.payload.properties.filter(p=>t.hasWebhookPayloadProperty(l,p.name.wireValue))}),u});return[c,s]})),a=e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).filter(([c])=>t.hasChannel(c)).map(([c,f])=>[c,{...f}])):{},o=e.environments;if(o){switch(o.environments.type){case"singleBaseUrl":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}case"multipleBaseUrls":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}}o.defaultEnvironment&&(t.hasEnvironmentId(o.defaultEnvironment)||(o.defaultEnvironment=void 0))}return{...e,environments:o,types:i,errors:zxi(e.errors,c=>t.hasError(c)),services:bn(zxi(e.services,c=>t.hasService(c)),c=>({...c,endpoints:c.endpoints.filter(f=>t.hasEndpoint(f)).map(f=>(f.autogeneratedExamples=f.autogeneratedExamples.map(s=>({...s,example:Mac({filteredIr:t,example:s.example})})),f.userSpecifiedExamples=f.userSpecifiedExamples.map(s=>({...s,example:s.example!=null?Mac({filteredIr:t,example:s.example}):void 0})),f.queryParameters.length>0&&(f.queryParameters=f.queryParameters.filter(s=>t.hasQueryParameter(f.id,s.name.wireValue))),f.requestBody?.type==="inlinedRequestBody"?{...f,requestBody:{...f.requestBody,properties:f.requestBody.properties.filter(s=>t.hasRequestProperty(f.id,s.name.wireValue))}}:f))})),websocketChannels:a,webhookGroups:n,serviceTypeReferenceInfo:zYS(e.serviceTypeReferenceInfo,t)}}function zYS(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}function $Ki(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}function mhe(e){return e.allParts.map(t=>t.originalName).join("/")}var up={generateTypeId:e=>`type_${mhe(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${mhe(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${mhe(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${mhe(e)}`,generateSubpackageId:e=>`subpackage_${mhe(e)}`,generateEndpointId:(e,t)=>{let r=mhe(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${mhe(e)}`,generateWebhookId:(e,t)=>`webhooks_${mhe(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${mhe(e)}`};function oQn(e){return e.type!=null}var HFo=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:o,webhooks:c,subpackages:f,queryParameters:s,requestProperties:u,webhookPayloadProperties:l,channels:p}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=o,this.webhooks=c,this.webhookPayloadProperties=l,this.subpackages=f,this.requestProperties=u,this.queryParameters=s,this.channels=p}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=up.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=up.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=up.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t?this.channels.has(t):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};var YKi=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=NYS(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let o=up.generateTypeId(t),c={typeId:o,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[o]=c,this.typesReferencedByService[o]==null&&(this.typesReferencedByService[o]=new Set),this.properties[o]={typeId:o,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=up.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=up.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&ZE(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=up.generateServiceId(t.name),a=r.id,o=new Set,c=new Set,f=new Set;for(let s of[...t.headers,...r.headers])ZE(s.valueType,o,f);for(let s of[...t.pathParameters,...r.pathParameters])ZE(s.valueType,o,f);for(let s of r.queryParameters)ZE(s.valueType,o,f);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=$Ki(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&VO._visit(r.requestBody,{inlinedRequestBody:s=>{for(let u of s.extends)KFo(u,o,f);for(let u of s.properties)ZE(u.valueType,o,f);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&YP(i.request.body)){let u=$Ki(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:u}}},reference:({requestBodyType:s})=>{ZE(s,o,f)},fileUpload:({properties:s})=>{for(let u of s)qC._visit(u,{file:Et,bodyProperty:({valueType:l})=>{ZE(l,o,f)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+u.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&ly._visit(r.response.body,{fileDownload:Et,json:s=>{ZE(s.responseBodyType,o,f)},streaming:s=>{s._visit({sse:u=>ZE(u.payload,o,f),json:u=>ZE(u.payload,o,f),text:Et,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:u=>ZE(u.payload,o,f),json:u=>ZE(u.payload,o,f),text:Et,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&ZE(s.nonStreamResponse.value.responseBodyType,o,f)},text:Et,bytes:Et,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{c.add(up.generateErrorId(s.error)),f.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:o,referencedErrors:c,referencedSubpackages:f}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=up.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let o=a.id;this.endpointsNeededForAudience.add(o),this.endpoints[o]?.referencedSubpackages.forEach(c=>{this.addSubpackages(c)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,o=new Set;r.payload!=null&&WQ._visit(r.payload,{inlinedPayload:c=>{for(let f of c.extends)KFo(f,a,o);for(let f of c.properties)ZE(f.valueType,a,o);if(i?.payload!=null&&typeof i.payload=="object"&&!oQn(i.payload)){let f=$Ki(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:f}}},reference:({payloadType:c})=>{ZE(c,a,o)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),o.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:o}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,o=new Set;for(let c of i.messages)sz._visit(c.body,{reference:({bodyType:f})=>{ZE(f,a,o)},inlinedBody:f=>{for(let s of f.extends)KFo(s,a,o);for(let s of f.properties)ZE(s.valueType,a,o)},_other:()=>{}});for(let c of i.queryParameters)ZE(c.valueType,a,o);o.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:o}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let c of this.endpointsNeededForAudience.keys()){let f=this.getEndpointNode(c);for(let s of f.referencedErrors){if(r.has(s))continue;r.add(s);let u=this.getErrorNode(s);this.addReferencedTypes(t,u.referencedTypes)}this.addReferencedTypes(t,f.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let c of this.webhooksNeededForAudience.keys()){let f=this.getWebhookNode(c);this.addReferencedTypes(t,f.referencedTypes)}for(let c of this.channelsNeededForAudience.keys()){let f=this.getChannelNode(c);this.addReferencedTypes(t,f.referencedTypes)}let i={},n={},a={},o={};if(this.audiences.type==="filtered"){for(let[c,f]of Object.entries(this.properties)){if(!t.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}s.size>0&&(i[c]=s),i[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}n[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.parametersByAudience[u];l?.forEach(p=>{s.add(p)})}a[c]=s.size>0?s:void 0}for(let[c,f]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let l=f.propertiesByAudience[u];l?.forEach(p=>{s.add(p)})}o[c]=s.size>0?s:void 0}}return new HFo({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:o,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let o=n.descendantsByAudience[a];if(o!=null)o.forEach(c=>{t.add(c)});else{n.allDescendants.forEach(c=>{t.add(c)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:vt(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(up.generateSubpackageId(i))}}};function NYS(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:vt(e)}}function ZE(e,t,r){ni._visit(e,{container:i=>{FYS(i,t,r)},named:i=>{KFo(i,t,r)},primitive:Et,unknown:Et,_other:Et})}function KFo(e,t,r){t.add(up.generateTypeId(e)),r.add(e.fernFilepath)}function FYS(e,t,r){es._visit(e,{list:i=>{ZE(i,t,r)},map:i=>{ZE(i.keyType,t,r),ZE(i.valueType,t,r)},optional:i=>{ZE(i,t,r)},nullable:i=>{ZE(i,t,r)},set:i=>{ZE(i,t,r)},literal:Et,_other:Et})}var QYS=[br.AvailabilityStatus.GeneralAvailability];function Wvi(e){return e!==void 0&&!QYS.includes(e.status)}var Bac=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},yPa=class{errors;constructor(){this.errors=new Bac}async check({from:t,to:r}){let i=this.toInternalIr(t),n=this.toInternalIr(r),a=wCi(i),o=wCi(n);if(a===o)return{bump:"no_change",isBreaking:!1,errors:[]};let c=this.checkBreaking({from:i,to:n});return{bump:c.isBreaking?"major":"minor",isBreaking:c.isBreaking,errors:c.errors}}toInternalIr(t){return{types:t.types,errors:t.errors,services:t.services}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(Wvi(n.availability))continue;let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}if(Wvi(a.availability)){this.errors.add(`Type "${i}" was moved from stable to unstable availability status.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(o=>o.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(Wvi(n.availability)||(n.endpoints?.every(o=>Wvi(o.availability))??!1))continue;let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}if(Wvi(a.availability)){this.errors.add(`Service "${i}" was moved from stable to unstable availability status.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(o=>[o.id,o])),a=Object.fromEntries(i.endpoints.map(o=>[o.id,o]));for(let[o,c]of Object.entries(n)){if(Wvi(c.availability))continue;let f=a[o];if(!f){this.errors.add(`Endpoint "${o}" was removed.`);continue}if(Wvi(f.availability)){this.errors.add(`Endpoint "${o}" was moved from stable to unstable availability status.`);continue}this.checkEndpointBreakingChanges({id:o,from:c,to:f})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.originalName,o])),a=Object.fromEntries(i.map(o=>[o.name.originalName,o]));for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Path parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Path parameter "${o}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Query parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Query parameter "${o}" type changed in endpoint "${t}".`),c.allowMultiple!==f.allowMultiple&&this.errors.add(`Query parameter "${o}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let f=a[o];if(!f){this.errors.add(`Header "${o}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:f.valueType})||this.errors.add(`Header "${o}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:vt(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,o])=>{let c=n[a];return c?this.areTypeReferencesCompatible({from:o,to:c}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,o]of Object.entries(i)){let c=n[a];if(!c)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(o==="file"&&c!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o==="fileArray"&&c!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o!=="file"&&o!=="fileArray"&&c!=="file"&&c!=="fileArray"&&!this.areTypeReferencesCompatible({from:o,to:c}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:vt(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:vt(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return Wvi(t.availability)?!0:this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:vt(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areNameAndWireValuesCompatible({from:a.name,to:o.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,o])=>[a,o.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,o])=>[a,o.valueType]))}),Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areObjectPropertiesCompatible({from:a,to:o}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),o=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let u=o[s.name.wireValue];if(!u)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:u}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,u])=>[s,u.valueType])),to:Object.fromEntries(Object.entries(o).map(([s,u])=>[s,u.valueType]))});let c=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),f=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(c).every(s=>{let u=f[s.discriminantValue.wireValue];return u?this.areSingleUnionTypesCompatible({from:s.shape,to:u.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:vt(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:vt(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:vt(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:vt(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:vt(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function XKi(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=LYS(e.environments,t.environments,r),{services:o,websocketChannels:c}=VYS(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:{requirement:e.auth?.requirement??t.auth?.requirement,schemes:t.auth?.schemes?.length!=null&&t.auth.schemes.length>(e.auth?.schemes?.length??0)?t.auth.schemes:e.auth?.schemes??[],docs:e.auth?.docs??t.auth?.docs},headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:o,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:UYS(e.subpackages,t.subpackages),websocketChannels:c,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(f=>!e.rootPackage.subpackages?.includes(f))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig,audiences:[...e.audiences??[],...t.audiences??[]],generationMetadata:e.generationMetadata??t.generationMetadata,apiPlayground:e.apiPlayground??t.apiPlayground}}function UYS(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,displayName:n.displayName,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function LYS(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=hc_(e),n=hc_(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:YE.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,o=e.environments,c=t.environments;if(o.type==="singleBaseUrl"&&c.type==="singleBaseUrl"){let f=i?c:o,s=i?o:c,u={},{deconflictedEnvironments2:l,changedBaseUrlIds2:p}=WYS(f,s,r);if(f.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let _="Base",h=r.generateName("Base");return f.environments.forEach(y=>{u[y.id]=_}),{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[{id:_,name:h},...l.environments.map(y=>({id:y.id,name:y.name}))],environments:f.environments.map(y=>({id:y.id,name:y.name,urls:{[_]:y.url,...Object.fromEntries(l.environments.map(b=>[b.id,b.url]))},docs:void 0}))})},changedBaseUrlIds1:i?p:u,changedBaseUrlIds2:i?u:p}}if(o.type==="multipleBaseUrls"&&c.type==="singleBaseUrl"||o.type==="singleBaseUrl"&&c.type==="multipleBaseUrls"){let f=o.type==="singleBaseUrl"?o:c,s=o.type==="multipleBaseUrls"?o:c,{deconflictedEnvironments1:u,changedBaseUrlIds1:l}=xYS(f,s,r);return{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[...s.baseUrls,...u.environments.map(p=>({id:p.id,name:p.name}))],environments:s.environments.map(p=>({...p,urls:{...p.urls,...Object.fromEntries(u.environments.map(_=>[_.id,_.url]))}}))})},changedBaseUrlIds1:o.type==="singleBaseUrl"?l:void 0,changedBaseUrlIds2:o.type==="singleBaseUrl"?void 0:l}}if(o.type==="multipleBaseUrls"&&c.type==="multipleBaseUrls"){let{deconflictedEnvironments:f,changedBaseUrlIds:s}=GYS(o,c,r);return{environments:{defaultEnvironment:a,environments:YE.multipleBaseUrls({baseUrls:[...o.baseUrls,...f.baseUrls],environments:o.environments.flatMap(u=>f.environments.map(l=>({...u,urls:{...u.urls,...l.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function VYS(e,t,r,i){if(r!=null)for(let[o,c]of Object.entries(r)){for(let f of Object.values(e.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(e.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}if(i!=null)for(let[o,c]of Object.entries(i)){for(let f of Object.values(t.services))for(let s of Object.values(f.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let f of Object.values(t.websocketChannels??{}))f.baseUrl==o&&(f.baseUrl=c)}let n=e.services;for(let[o,c]of Object.entries(t.services))n[o]==null?n[o]=c:n[o]={availability:c.availability,name:c.name,displayName:c.displayName,basePath:c.basePath,endpoints:[...n[o].endpoints??[],...c.endpoints],pathParameters:[...n[o].pathParameters??[],...c.pathParameters??[]],headers:[...n[o].headers??[],...c.headers??[]],encoding:c.encoding,transport:c.transport,audiences:[...n[o].audiences??[],...c.audiences??[]]};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function WYS(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),o=new Map(e.environments.map(s=>[s.url,s.id])),c=t.environments.filter(s=>{let u=o.get(s.url);return u!=null?(i[s.id]=u,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let u=Iac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s});return{deconflictedEnvironments2:YE.singleBaseUrl({environments:c}),changedBaseUrlIds2:i}}function xYS(e,t,r){let i={},n=new Set(t.baseUrls.map(f=>f.id)),a=new Set(t.baseUrls.map(f=>f.name)),o=e.environments.map(f=>{if(n.has(f.id)||a.has(f.name)){let s=Iac(f.id,n);return i[f.id]=s,{...f,id:s,name:r.generateName(s)}}return f});return{deconflictedEnvironments1:YE.singleBaseUrl({environments:o}),changedBaseUrlIds1:i}}function GYS(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),o=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let u=Iac(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s}),c=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([u,l])=>[i[u]??u,l]))}));return{deconflictedEnvironments:YE.multipleBaseUrls({baseUrls:o,environments:c}),changedBaseUrlIds:i}}function hc_(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function Iac(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}var Ra=class e{breadcrumbs=[];context;static STRING=br.TypeReference.primitive({v1:"STRING",v2:br.PrimitiveTypeV2.string({default:void 0,validation:void 0})});static OPTIONAL_STRING=br.TypeReference.container(br.ContainerType.optional(e.STRING));constructor({breadcrumbs:t=[],context:r}){this.breadcrumbs=t,this.context=r}};var bc_=require("fs/promises");var Cac=class{_map;_path;_lastScalar;_fragments;_count;constructor(){this._map={},this._path=[],this._lastScalar="",this._fragments=[],this._count=0}get map(){return this._map}resolveNode(t,r){if(t.path==="."&&(r="."),!this._map[r]){let{line:i,position:n,lineStart:a}=t;this._map[r]={line:i,position:n,lineStart:a}}t.children&&t.children.length>0&&t.children.forEach(i=>{this.resolveNode(i,(r==="."?"":r)+"."+i.path)})}iterFragments(t,r){for(let i=this._fragments.length-1;i>=0;i--){if(!this._fragments[i].path.startsWith(t)||this._fragments[i].path===t)continue;let n=this._fragments.pop();r(n)}}handleState(t,r){if(t==="close"){let i=r.result,n=r.kind,a=this._path.join(".");if(n==="scalar"){this._path.pop(),this._lastScalar=`${i}`;let{line:o,position:c,lineStart:f}=r;this._path.length===0?this._map["."+i]={line:o,position:c,lineStart:f}:this._fragments.push({path:this._path.join(".")+"."+i,line:o,position:c,lineStart:f})}else if(n==="mapping"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=0;this.iterFragments(a,f=>{c++,!((!f.children||f.children.length===0)&&c%2===1)&&(this._path.length===1?this.resolveNode(f,f.path):(o.children.push({...f,path:f.path.slice(a.length+1)}),o.line=f.line,o.position=f.position,o.lineStart=f.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else if(n==="sequence"){let o={path:a,children:[],line:0,position:0,lineStart:0},c=new Set,f=i.length;this.iterFragments(a,s=>{c.has(s.position)||(f--,c.add(s.position),this._path.length===1?this.resolveNode(s,`${a}.${f}`):(o.children.push({...s,path:f.toString()}),o.line=s.line,o.position=s.position,o.lineStart=s.lineStart))}),o.children&&o.children.length>0&&this._fragments.push(o),this._path.pop()}else this._path.pop()}if(t==="open"){if(this._count===0){let{line:i,position:n,lineStart:a}=r;this._map["."]={line:i,position:n,lineStart:a}}this._path.push(this._lastScalar),this._count++}}listen(){return this.handleState.bind(this)}lookup(t){let r=t instanceof Array?t.map(n=>`${n}`).join("."):`${t}`;r.startsWith(".")||(r="."+r),r.startsWith("..")&&(r=r.slice(1)),r=r.replace(/\[/g,".").replace(/\]/g,"");let i=this._map[r];if(i)return{line:i.line+1,column:i.position-i.lineStart+1,position:i.position}}},yc_=Cac;var N0e;(function(e){e.WARNING="warning",e.ERROR="error"})(N0e||(N0e={}));var SCi=class{errors=[];logger;breadcrumbToLineNumberMapper;relativeFilepathToSpec;constructor({logger:t,relativeFilepathToSpec:r}){this.logger=t,this.relativeFilepathToSpec=r,r&&(this.breadcrumbToLineNumberMapper=new qac({logger:t,relativePathToFile:Ye.of(r)}))}collect(t){this.errors.push(t)}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}dedupe(){let t=[],r=new Set,i=0;for(let n of this.errors){let a=n.path?n.path.join("->"):"",o=`${n.message}|${n.level||N0e.WARNING}|${a}`;r.has(o)?i++:(r.add(o),t.push(n))}return this.errors=t,i}getErrorStats(){this.dedupe();let t=0,r=0;for(let i of this.errors)i.level===N0e.ERROR?t++:(i.level===N0e.WARNING||i.level===void 0)&&r++;return{numErrors:t,numWarnings:r}}async logErrors({logWarnings:t}){this.dedupe();for(let r of this.errors){let i=r.level??N0e.WARNING;if(!(i===N0e.WARNING&&!t))switch(i){case N0e.ERROR:if(this.logger.log($s.Debug,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Debug,` - at location (${a})`)}break;case N0e.WARNING:if(this.logger.log($s.Warn,r.message),r.path&&r.path.length>0){let n=await this.breadcrumbToLineNumberMapper?.getSourceLocation(r.path),a=n?`${this.relativeFilepathToSpec}:${n.line}:${n.column}`:r.path.join(" -> ");this.logger.log($s.Warn,` - at location (${a})`)}r.resolution&&this.logger.log($s.Warn,` - resolution: ${r.resolution}`);break}}}},qac=class{logger;relativePathToFile;map=new yc_;initialized=!1;constructor({relativePathToFile:t,logger:r}){this.relativePathToFile=t,this.logger=r}async initialize(){if(!this.initialized)try{let t=await(0,bc_.readFile)(this.relativePathToFile,"utf-8");Ni.load(t,{listener:this.map.listen()}),this.initialized=!0}catch(t){this.logger.log($s.Warn,`Failed to initialize line number mapping for ${this.relativePathToFile}: ${JSON.stringify(t)}`)}}async getSourceLocation(t){return this.initialized||await this.initialize(),this.map.lookup(t)}};var SB=class e{args;spec;settings;errorCollector;logger;generationLanguage;smartCasing;casingsGenerator;namespace;exampleGenerationArgs;authOverrides;environmentOverrides;globalHeaderOverrides;enableUniqueErrorsPerEndpoint;generateV1Examples;documentBaseDir;constructor(t){this.args=t,this.spec=t.spec,this.settings=t.settings,this.errorCollector=t.errorCollector,this.logger=t.logger,this.generationLanguage=t.generationLanguage,this.smartCasing=t.smartCasing,this.namespace=t.namespace,this.casingsGenerator=_x({generationLanguage:t.generationLanguage,keywords:void 0,smartCasing:t.smartCasing}),this.exampleGenerationArgs=t.exampleGenerationArgs,this.authOverrides=t.authOverrides,this.environmentOverrides=t.environmentOverrides,this.globalHeaderOverrides=t.globalHeaderOverrides,this.enableUniqueErrorsPerEndpoint=t.enableUniqueErrorsPerEndpoint,this.generateV1Examples=t.generateV1Examples,this.documentBaseDir=t.documentBaseDir}static BREADCRUMBS_TO_IGNORE=["properties","allOf","anyOf"];convertBreadcrumbsToName(t){let r=t.filter((n,a)=>!(/^\d+$/.test(n)||e.BREADCRUMBS_TO_IGNORE.includes(n)||a===0&&n==="components"||a===1&&n==="schemas"||t[0]==="paths"&&(a===0||a===1&&["get","post","put","delete","patch"].includes(n)||a===2&&t[1]!=null&&["get","post","put","delete","patch"].includes(t[1])&&n==="parameters"))),i=No(r.join("_"));return i.charAt(0).toUpperCase()+i.slice(1)}createFernFilepath(t={}){let r=this.namespace!=null?[this.casingsGenerator.generateName(this.namespace)]:[],i=t.name!=null?this.casingsGenerator.generateName(t.name):void 0;return{allParts:i?[...r,i]:r,packagePath:r,file:i}}resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i}){let n=this.spec,a=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(o=>o.replace(/~1/g,"/"));for(let o of a){if(typeof n!="object"||n==null)return i||this.errorCollector.collect({level:N0e.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1};n=n[o]}return n==null?(i||this.errorCollector.collect({level:N0e.ERROR,message:this.getErrorMessageForMissingRef({reference:t}),path:r}),{resolved:!1}):{resolved:!0,value:n}}getErrorMessageForMissingRef({reference:t}){let r=t.$ref.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/");return r.length>=3&&r[0]==="components"&&r[1]==="schemas"?`Schema ${r[2]} does not exist`:`${t.$ref} does not exist`}async resolveMaybeExternalReference(t){let r=this.spec,i,n=!1,a=null,o;if(this.isExternalReference(t.$ref)){n=!0;let s=t.$ref.split("#"),u=s[0];if(i=s[1],!u)return{resolved:!1};o=u;let l=await fetch(u);if(!l.ok)return{resolved:!1};try{let p=await l.text();try{a=JSON.parse(p),r=a}catch{a=Ni.load(p),r=a}if(r==null)return{resolved:!1}}catch{return{resolved:!1}}if(!i)return{resolved:!0,value:r}}let c=i??t.$ref;if(c==null||typeof c!="string")return{resolved:!1};let f=c.replace(/^(?:(?:https?:\/\/)?|#?\/?)?/,"").split("/").map(s=>s.replace(/~1/g,"/"));for(let s of f){if(typeof r!="object"||r==null)return{resolved:!1};r=r[s]}if(r==null)return{resolved:!1};if(n&&typeof r=="object"&&r!==null){let s=new Set;s.add(t.$ref),r=await this.resolveNestedExternalReferences(r,a,s,o)}return{resolved:!0,value:r}}async resolveNestedExternalReferences(t,r,i,n){if(t===null||typeof t!="object")return t;if(Array.isArray(t)){let o=[];for(let c of t)o.push(await this.resolveNestedExternalReferences(c,r,i,n));return o}if(this.isReferenceObject(t)){let o=t.$ref;if(this.isExternalReference(o)){if(i.has(o))return t;i.add(o);let c=await this.resolveMaybeExternalReference({$ref:o});if(i.delete(o),c.resolved)return c.value}else{let c=`${n}${o}`;if(i.has(c))return t;i.add(c);let f=r,s=o.substring(2).split("/").map(u=>u.replace(/~1/g,"/").replace(/~0/g,"~"));for(let u of s){if(typeof f!="object"||f===null)return t;f=f[u]}if(f!=null){let u=await this.resolveNestedExternalReferences(f,r,i,n);return i.delete(o),u}i.delete(o)}return t}let a={};for(let[o,c]of Object.entries(t))typeof c=="object"&&c!==null?a[o]=await this.resolveNestedExternalReferences(c,r,i,n):a[o]=c;return a}getExamplesFromSchema({schema:t,breadcrumbs:r}){if(t==null)return[];let i=t.example!=null?[t.example]:[];return t.examples!=null&&(Array.isArray(t.examples)?i.push(...t.examples):this.errorCollector.collect({message:"Received non-array schema examples",path:r})),i}getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:r,defaultExampleName:i}){if(t==null)return[];let n=[];if(t.example!=null){let a=this.generateUniqueName({prefix:i??`${r.join("_")}_example`,existingNames:[]});n.push([a,t.example])}return t.examples!=null&&n.push(...Object.entries(t.examples)),n}resolveMaybeReference({schemaOrReference:t,breadcrumbs:r,skipErrorCollector:i}){if(this.isReferenceObject(t)){let n=this.resolveReference({reference:t,breadcrumbs:r,skipErrorCollector:i});return n.resolved?n.value:void 0}return t}resolveExample(t){if(!this.isReferenceObject(t))return t;let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}resolveExampleWithValue(t){if(!this.isReferenceObject(t))return this.returnExampleValue(t);let r=this.resolveReference({reference:t});return r.resolved?this.returnExampleValue(r.value):void 0}returnExampleValue(t){return this.isExampleWithValue(t)?t.value:t}getPropertyAccess(t){let r=t;for(;this.isReferenceObject(r);){let a=this.resolveReference({reference:r});if(!a.resolved)return;r=a.value}let{readOnly:i,writeOnly:n}=this.getReadOnlyWriteOnlyFromSchema(r);if(!(i&&n)){if(i)return Y9t.ReadOnly;if(n)return Y9t.WriteOnly}}getReadOnlyWriteOnlyFromSchema(t){if(t.allOf&&t.allOf.length>0){let r=!0,i=!0;for(let n of t.allOf){let a=n;if(this.isReferenceObject(n)){let c=this.resolveReference({reference:n});if(!c.resolved)continue;a=c.value}let o=this.getReadOnlyWriteOnlyFromSchema(a);r=r&&o.readOnly,i=i&&o.writeOnly}return{readOnly:r,writeOnly:i}}else return{readOnly:!!t.readOnly,writeOnly:!!t.writeOnly}}getAudiences({operation:t,breadcrumbs:r}){let n=new C1.AudienceExtension({operation:t,breadcrumbs:r,context:this}).convert();if(n!=null)return n.audiences}getAvailability({node:t,breadcrumbs:r}){for(;this.isReferenceObject(t);){let a=this.resolveReference({reference:t});if(!a.resolved)return;t=a.value}let n=new C1.FernAvailabilityExtension({node:t,breadcrumbs:r,context:this}).convert();if(n!=null)return{status:n,message:void 0};if(t.deprecated===!0)return{status:IC.Deprecated,message:void 0}}getTypeIdFromSchemaReference(t){let r=t.$ref.match(/\/schemas\/(.+)$/);if(!(!r||!r[1]))return r[1]}createNamedTypeReference(t,r){return ni.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(t),typeId:t,displayName:r,default:void 0,inline:!1})}typeReferenceToDeclaredTypeName(t){if(t.type!=="named")return;let r=t.typeId;return{typeId:r,fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(r),displayName:t.displayName}}removeSchemaFromInlinedTypes({id:t,inlinedTypes:r}){return Object.fromEntries(Object.entries(r).filter(([i])=>i!==t))}static maybeTrimPrefix(t,r){return t.startsWith(r)?t.slice(r.length):t}generateUniqueName({prefix:t,existingNames:r}){if(!r.includes(t))return t;let i=0;for(;r.includes(`${t}_${i}`);)i++;return`${t}_${i}`}isReferenceObject(t){return typeof t=="object"&&t!==null&&"$ref"in t}isExternalReference(t){return typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://"))}isReferenceObjectWithIdentifier(t){return this.isReferenceObject(t)&&("title"in t||"name"in t||"messageId"in t||"summary"in t)}isExampleWithSummary(t){return typeof t=="object"&&t!=null&&"summary"in t}isExampleWithValue(t){return typeof t=="object"&&t!=null&&"value"in t}isOptional(t){return t.type==="container"&&t.container.type==="optional"}isNullable(t){return t.type==="container"&&t.container.type==="nullable"}isList(t){return t.type==="container"&&t.container.type==="list"}isFile(t){return t.type==="primitive"&&t.primitive.v2?.type==="string"&&t.primitive.v2.validation?.format==="binary"}getAsString(t){if(typeof t=="string")return t}getAsInteger(t){if(typeof t=="number"&&Number.isInteger(t))return t}getAsNumber(t){if(typeof t=="number")return t}getAsBoolean(t){if(typeof t=="boolean")return t}getAsArray(t){if(Array.isArray(t))return t}getAsObject(t){if(typeof t=="object"&&t!==null&&!Array.isArray(t))return t}getGroup({groupParts:t,namespace:r}){let i=[];return r!=null&&i.push(r),i.push(...t??[]),i}isObjectSchemaType(t){return t.type==="object"||t.properties!=null}};var kc=class{breadcrumbs;context;constructor(t){this.breadcrumbs=t.breadcrumbs,this.context=t.context}getExtensionValue(t,r){if(typeof t!="object"||t==null)return;let i=t[this.key];if(i!=null)return i;if(r!=null)return t[r]}};var C1={};Kt(C1,{AudienceExtension:()=>JFo,FernAvailabilityExtension:()=>$Fo,FernEnumExtension:()=>YFo,FernIgnoreExtension:()=>ZKi,FernOptionalExtension:()=>XFo,FernTypeExtension:()=>tQo,FernTypeNameExtension:()=>rQo,SdkGroupNameExtension:()=>ZFo,SdkMethodNameExtension:()=>kFo,ServerFromOperationNameExtension:()=>eQo});var JFo=class extends kc{operation;key="x-fern-audiences";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{audiences:r}}};var $Fo=class extends kc{node;key="x-fern-availability";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t==null||typeof t!="string")return;switch(t.toUpperCase().replace(/[-_\s]/g,"_")){case"IN_DEVELOPMENT":return IC.InDevelopment;case"PRE_RELEASE":case"BETA":return IC.PreRelease;case"GENERAL_AVAILABILITY":case"GA":return IC.GeneralAvailability;case"DEPRECATED":return IC.Deprecated;default:return}}};var HYS=Tt.object({snake:Tt.string().optional(),camel:Tt.string().optional(),screamingSnake:Tt.string().optional(),pascal:Tt.string().optional()}),KYS=Tt.object({description:Tt.string().optional(),name:Tt.string().optional(),casing:HYS.optional()}),vc_=Tt.record(KYS);var YFo=class extends kc{schema;key="x-fern-enum";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t==null)return;let r=vc_.safeParse(t);if(!r.success){this.context.errorCollector.collect({message:`Invalid x-fern-enum extension: ${r.error.message}`,path:this.breadcrumbs});return}return r.data}};var ZKi=class extends kc{operation;key="x-fern-ignore";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),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-ignore",path:this.breadcrumbs});return}return t}}};var XFo=class extends kc{parameter;key="x-fern-optional";constructor({breadcrumbs:t,parameter:r,context:i}){super({breadcrumbs:t,context:i}),this.parameter=r}convert(){let t=this.getExtensionValue(this.parameter);if(t!=null){if(typeof t!="boolean"){this.context.errorCollector.collect({message:"Received unexpected non-boolean value for x-fern-optional",path:this.breadcrumbs});return}return t}}};var ZFo=class extends kc{operation;key="x-fern-sdk-group-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t==null)return;let r=Array.isArray(t)?t.filter(i=>typeof i=="string"):typeof t=="string"?[t]:[];if(r.length!==0)return{groups:r}}};var kFo=class extends kc{operation;key="x-fern-sdk-method-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation);if(t!=null&&typeof t=="string")return{methodName:t}}};var eQo=class extends kc{operation;key="x-fern-server-name";constructor({breadcrumbs:t,operation:r,context:i}){super({breadcrumbs:t,context:i}),this.operation=r}convert(){let t=this.getExtensionValue(this.operation,"x-name");if(!(t==null||typeof t!="string"))return t}};var tQo=class extends kc{schema;key="x-fern-type";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(t!=null&&typeof t=="string")return t}};var rQo=class extends kc{schema;key="x-fern-type-name";constructor({breadcrumbs:t,schema:r,context:i}){super({breadcrumbs:t,context:i}),this.schema=r}convert(){let t=this.getExtensionValue(this.schema);if(typeof t=="string")return t}};var lFt=class extends Ra{ir;audiences;irGraph;constructor({breadcrumbs:t=[],context:r,audiences:i}){super({breadcrumbs:t,context:r}),this.audiences=i,this.irGraph=new YKi(i),this.ir={auth:{docs:void 0,requirement:br.AuthSchemesRequirement.All,schemes:[]},selfHosted:!1,types:{},services:{},errors:{},webhookGroups:{},websocketChannels:void 0,headers:[],idempotencyHeaders:[],apiVersion:void 0,apiDisplayName:void 0,apiDocs:void 0,basePath:void 0,pathParameters:[],errorDiscriminationStrategy:br.ErrorDiscriminationStrategy.statusCode(),variables:[],serviceTypeReferenceInfo:{sharedTypes:[],typesReferencedOnlyByService:{}},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,environments:void 0,fdrApiDefinitionId:void 0,rootPackage:this.createPackage(),subpackages:{},sdkConfig:{hasFileDownloadEndpoints:!1,hasPaginatedEndpoints:!1,hasStreamingEndpoints:!1,isAuthMandatory:!0,platformHeaders:{language:"",sdkName:"",sdkVersion:"",userAgent:void 0}},audiences:void 0,generationMetadata:void 0,apiPlayground:void 0}}removeXFernIgnores({document:t,breadcrumbs:r=[]}){return Array.isArray(t)?t.filter((i,n)=>!new ZKi({breadcrumbs:[...r,String(n)],operation:i,context:this.context}).convert()).map((i,n)=>this.removeXFernIgnores({document:i,breadcrumbs:[...r,String(n)]})):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([i,n])=>!new ZKi({breadcrumbs:[...r,i],operation:n,context:this.context}).convert()).map(([i,n])=>[i,this.removeXFernIgnores({document:n,breadcrumbs:[...r,i]})])):t}finalizeIr(){let t={...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0};this.irGraph.hasNoAudiences()||(t=this.filterIrForAudiences(t));let r=this.context.exampleGenerationArgs,i=Eac({ir:t,exampleGeneration:r});if(this.context.generateV1Examples){let n=hPa({ir:t,exampleGeneration:r});return{...t,...n,...i}}return{...t,...i}}filterIrForAudiences(t){let r=this.irGraph.getFilteredEndpoints(),i=this.irGraph.getFilteredChannels(),n=this.irGraph.getFilteredWebhooks();for(let a of Object.values(t.services)){let o=[];for(let c of a.endpoints)r.has(c.id)&&o.push(c);a.endpoints=o}return t.websocketChannels=Object.fromEntries(Object.entries(t.websocketChannels??{}).filter(([a])=>i.has(a))),t.webhookGroups=Object.fromEntries(Object.entries(t.webhookGroups).filter(([a])=>n.has(a))),t}async resolveAllExternalRefs({spec:t}){let r=[t];for(;r.length>0;){let i=r.shift();i!=null&&(Array.isArray(i)?await this.resolveExternalRefsInArray(i,r):typeof i=="object"&&await this.resolveExternalRefsInObject(i,r))}return t}async resolveExternalRefsInArray(t,r){for(let i=0;i<t.length;i++)t[i]=await this.resolveReferenceChain(t[i],r)}async resolveExternalRefsInObject(t,r){for(let[i,n]of Object.entries(t))t[i]=await this.resolveReferenceChain(n,r)}async resolveReferenceChain(t,r){let i=t;if(!this.context.isReferenceObject(i))return r.push(i),t;for(;this.context.isReferenceObject(i);){let n=this.context.isExternalReference(i.$ref),a=await this.context.resolveMaybeExternalReference(i);if(a.resolved){if(i=a.value,n)return i}else return t}return t}shouldAddServerToCollectedServers({server:t,currentServers:r,specType:i="openapi"}){return i==="openapi"?!r.some(n=>n.url===t.url&&"x-fern-server-name"in n&&"x-fern-server-name"in t&&n["x-fern-server-name"]===t["x-fern-server-name"]):!r.some(n=>n.url===t.url&&"name"in n&&"name"in t&&n.name===t.name)}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>No(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}addWebhookToIr({webhook:t,operationId:r,audiences:i,group:n}){let a=n?.join(".")??r,o=this.getOrCreatePackage({group:n});this.ir.webhookGroups[a]==null&&(this.ir.webhookGroups[a]=[]),this.ir.webhookGroups[a].push(t),o.webhooks=a;let c=this.context.createFernFilepath();this.irGraph.addWebhook(c,t),i!=null&&this.irGraph.markWebhookForAudiences(c,t,i)}addWebsocketChannelToIr({websocketChannel:t,channelPath:r,audiences:i,websocketGroup:n}){let a=No(n?.join(".")),o=No(r),c=this.context.namespace?`${No(this.context.namespace)}/`:"",f=a?`channel_${c}${a}`:`channel_${c}${o}`,s=n?this.getOrCreatePackage({group:n}):this.getOrCreatePackage({group:[o]});this.ir.websocketChannels={...this.ir.websocketChannels,[f]:t},f!==""?s.websocket==null&&(s.websocket=f):this.ir.rootPackage.websocket="";let u=this.context.createFernFilepath();this.irGraph.addChannel(u,f,t),i!=null&&this.irGraph.markChannelForAudiences(u,f,i)}addAuthToIR(t){this.ir.auth=t}addErrorsToIr(t){this.ir.errors=t;for(let r of Object.values(t))this.irGraph.addError(r)}addGlobalHeadersToIr(t){this.ir.headers=t}addEnvironmentsToIr({environmentConfig:t,audiences:r}){if(this.ir.environments=t,r!=null)for(let[i,n]of Object.entries(t??{}))r[i]!=null&&this.irGraph.markEnvironmentForAudiences(n,r[i])}addTypeToRootPackage(t){this.ir.rootPackage.types.push(t)}addSchemaOutputToIr(t,r){let{convertedSchema:i,inlinedTypes:n}=r,o=Object.keys(n).some(c=>c===t)?`${t}Wrapper`:t;this.addTypeToPackage(o),this.addTypesToIr({...n,[o]:i})}addTypeToPackage(t){let r=this.context.getGroup({groupParts:[],namespace:this.context.namespace});this.getOrCreatePackage({group:r}).types.push(t)}addTypesToIr(t){Object.assign(this.ir.types,Object.fromEntries(Object.entries(t).map(([r,i])=>[r,i.typeDeclaration])));for(let r of Object.values(t))this.irGraph.addType({declaredTypeName:r.typeDeclaration.name,descendantTypeIds:r.typeDeclaration.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:r.propertiesByAudience,descendantFilepaths:new Set}),this.irGraph.markTypeForAudiences(r.typeDeclaration.name,r.audiences)}updateEndpointsWithDefaultUrl(t){if(t!=null)for(let r of Object.values(this.ir.services))for(let i of r.endpoints)i.baseUrl==null&&(i.baseUrl=t)}createNewService({allParts:t,finalpart:r,endpointGroupDisplayName:i}){return{name:{fernFilepath:{allParts:t,packagePath:t.slice(0,-1),file:r}},displayName:i,basePath:jD(""),headers:[],pathParameters:[],availability:void 0,endpoints:[],transport:void 0,encoding:void 0,audiences:void 0}}createPackage(t={}){return{fernFilepath:this.context.createFernFilepath(t),service:void 0,types:[],errors:[],subpackages:[],docs:void 0,webhooks:void 0,websocket:void 0,hasEndpointsInTree:!1,navigationConfig:void 0}}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...(t??[]).map(n=>No(n))),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:void 0,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}};var WO={};Kt(WO,{AbstractConverters:()=>Rac,ExampleConverter:()=>F0e,SchemaConverters:()=>Tac,ServersConverter:()=>Phe});var Rac={};Kt(Rac,{AbstractMediaTypeObjectConverter:()=>aQo,AbstractParameterConverter:()=>oQo});var JYS=/^literal<\s*(?:"(.*)"|(true|false))\s*>$/;function $YS(e){return e.type==="array"||e.properties||e.oneOf||e.anyOf||e.allOf||e.additionalProperties?!1:!!(e.type==="string"||e.type==="number"||e.type==="integer"||e.type==="boolean"||e.const!==void 0||Array.isArray(e.enum)&&e.enum.length>0)}function gc_(e){if(e.const!==void 0)return e.const;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0]}var F0e=class e extends Ra{MAX_DEPTH=12;EXAMPLE_STRING=cu.STRING;EXAMPLE_NUMBER=cu.DOUBLE;EXAMPLE_BOOLEAN=cu.BOOLEAN;EXAMPLE_INTEGER=cu.INT;EXAMPLE_DATE=cu.DATE;EXAMPLE_DATE_TIME=cu.DATE_TIME;schema;example;depth;exampleGenerationStrategy;generateOptionalProperties;seenRefs;constructor({breadcrumbs:t,context:r,schema:i,example:n,depth:a=0,exampleGenerationStrategy:o,generateOptionalProperties:c=!1,seenRefs:f=new Set}){super({breadcrumbs:t,context:r}),this.example=n,this.schema=i,this.depth=a,this.exampleGenerationStrategy=o,this.generateOptionalProperties=c,this.seenRefs=f}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:typeof this.example<"u"?this.example:{},errors:[]};if(this.context.isReferenceObject(this.schema)){let i=this.schema.$ref;if(this.seenRefs.has(i))return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}}let t=this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(t==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:"Schema is not resolvable",path:this.breadcrumbs}]};if(typeof t!="object")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Schema should be an object: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]};if("nullable"in t&&t.nullable===!0&&this.example===null)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.maybeConvertLiteralFernType(t);return r??(Array.isArray(t.type)?this.convertSchemaTypeArray({resolvedSchema:t}):t.type=="null"?this.convertNull():t.type=="boolean"?this.convertBoolean():t.enum!=null?this.convertEnum(t):t.type=="number"?this.convertNumber():t.type=="string"?this.convertString():t.type=="integer"?this.convertInteger():t.type=="array"?this.convertArray({resolvedSchema:t}):"oneOf"in t&&t.oneOf!=null?this.convertOneOf({resolvedSchema:t}):"anyOf"in t&&t.anyOf!=null?this.convertAnyOf({resolvedSchema:t}):t.type=="object"||t.properties!=null||t.allOf!=null?this.convertObject({resolvedSchema:t}):typeof t=="object"&&Object.keys(t).length===0?{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Unsupported schema type: ${JSON.stringify(t,null,2)}`,path:this.breadcrumbs}]})}convertNull(){let t=this.example===null;return t?{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[{message:`Example is not null: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertBoolean(){let t=typeof this.example=="boolean";if(t)return{isValid:t,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.default:this.schema.default,i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs})?.const:this.schema.const;return typeof r=="boolean"||typeof i=="boolean"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i??r,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_BOOLEAN,errors:[{message:`Example is not a boolean: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertEnum(t){let r=t.enum?.includes(this.example)??!1;if(r)return{isValid:r,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let i=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return i!==void 0&&t.enum?.includes(i)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:r,coerced:!1,usedProvidedExample:!1,validExample:t.enum?.[0],errors:[{message:`Example is not one of the allowed enum values: ${JSON.stringify(t.enum,null,2)}`,path:this.breadcrumbs}]}}convertNumber(){if(typeof this.example=="number")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};let t=Number(this.example);if(!isNaN(t))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.default;return typeof i=="number"?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.adjustNumberToConstraints(this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_NUMBER,r),errors:[{message:`Example is not a number: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}adjustNumberToConstraints(t,r){if(r==null)return this.context.logger.debug("[ExampleConverter.adjustNumberToConstraints] Schema object is null, returning original number","number:",t.toString()),t;let{minimum:i,maximum:n,exclusiveMinimum:a,exclusiveMaximum:o}=r,c;a!=null?typeof a=="boolean"?c=i!=null?i+Math.max(Number.EPSILON,Math.abs(i)*1e-10):void 0:c=a+Math.max(Number.EPSILON,Math.abs(a)*1e-10):i!=null&&(c=i);let f;return o!=null?typeof o=="boolean"?f=n!=null?n-Math.max(Number.EPSILON,Math.abs(n)*Number.EPSILON):void 0:f=o-Math.max(Number.EPSILON,Math.abs(o)*Number.EPSILON):n!=null&&(f=n),c!==void 0&&f!==void 0?(t<c||t>f)&&(t=c+(f-c)/2):c!==void 0&&t<c?t=c+Math.abs(c*.1):f!==void 0&&t>f&&(t=f-Math.abs(f*.1)),Number(Number(t).toPrecision(3))}convertString(){if(typeof this.example=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example!="object"&&!Array.isArray(this.example)&&this.example!=null)return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:String(this.example),errors:[]};let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;if(typeof t=="string")return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]};let r=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0}):this.schema,i=r?.format==="date"?this.EXAMPLE_DATE:r?.format==="date-time"?this.EXAMPLE_DATE_TIME:this.EXAMPLE_STRING;return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??i,errors:[{message:`Example cannot be converted to string: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertInteger(){if(typeof this.example=="number"&&Number.isInteger(this.example))return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:this.example,errors:[]};if(typeof this.example=="string"){let r=Number(this.example);if(!isNaN(r)&&Number.isInteger(r))return{isValid:!0,coerced:!0,usedProvidedExample:!0,validExample:r,errors:[]}}let t=this.context.isReferenceObject(this.schema)?this.context.resolveMaybeReference({schemaOrReference:this.schema,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0})?.default:this.schema.default;return typeof t=="number"&&Number.isInteger(t)?{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:t,errors:[]}:{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:this.maybeResolveSchemaExample(this.schema)??this.EXAMPLE_INTEGER,errors:[{message:`Example is not an integer: ${JSON.stringify(this.example,null,2)}`,path:this.breadcrumbs}]}}convertArray({resolvedSchema:t}){if(t.type!="array")return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};t.items==null&&(t.items={type:"string"});let r=this.example==null,i=this.example??t.example,a=(Array.isArray(i)?i:[i]).map(f=>new e({breadcrumbs:[...this.breadcrumbs,"items"],context:this.context,schema:t.items,example:f,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),o=a.every(f=>f?.isValid??!1)&&!r,c=!r&&a.some(f=>f.usedProvidedExample);return{isValid:o,coerced:!1,usedProvidedExample:c,validExample:a.map(f=>f.validExample),errors:o?[]:a.flatMap(f=>f.errors)}}convertObject({resolvedSchema:t}){if(t.type=="object"&&t.properties==null&&t.allOf==null)return{isValid:!0,coerced:!1,usedProvidedExample:this.example!==void 0,validExample:this.example??{},errors:[]};let r=typeof this.example!="object"||this.example==null?{}:this.example,i=Object.entries(t.properties??{}).map(([s,u])=>{if(typeof u!="object")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if(this.isDeprecatedProperty(u)&&!this.isRequiredProperty({key:s,resolvedSchema:t}))return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in u&&u.readOnly===!0&&"writeOnly"in u&&u.writeOnly===!0)return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("readOnly"in u&&u.readOnly===!0&&this.exampleGenerationStrategy==="request")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};if("writeOnly"in u&&u.writeOnly===!0&&this.exampleGenerationStrategy==="response")return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}};let l=!(s in r)||!("nullable"in u)&&r[s]==null||"nullable"in u&&u.nullable===!0&&r[s]===void 0,p=!t.required?.includes(s);if(l&&p){if(this.example===void 0&&this.generateOptionalProperties){let _=this.maybeResolveSchemaExample(u),h=new e({breadcrumbs:[...this.breadcrumbs,s],context:this.context,schema:u,example:_,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()});return{key:s,result:h.convert()}}return{key:s,result:{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:void 0,errors:[]}}}else{let h=r[s]??this.maybeResolveSchemaExample(u),b=new e({breadcrumbs:[...this.breadcrumbs,s],context:this.context,schema:u,example:h,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();return{key:s,result:b}}}),n=(t.allOf??[]).map((s,u)=>new e({breadcrumbs:[...this.breadcrumbs,`allOf[${u}]`],context:this.context,schema:{...t,...s,allOf:void 0},example:this.example,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),a=i.every(s=>s.result.isValid)&&n.every(s=>s.isValid),o=this.example!==void 0&&(i.some(({result:s})=>s.usedProvidedExample)||n.some(s=>s.usedProvidedExample)),c=Object.fromEntries(i.map(({key:s,result:u})=>[s,u.validExample]).filter(([s,u])=>u!==void 0));for(let s of n)if(typeof s.validExample=="object"&&s.validExample!==null){let u=s.validExample;c={...c,...Object.fromEntries(Object.entries(u).filter(([l,p])=>p!==void 0))}}let f=[];if(t.additionalProperties!==!1){let s=typeof t.additionalProperties=="object"?t.additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object"},{type:"array"}]},u=new Set(Object.keys(c??{}));Object.keys(r).filter(p=>!u.has(p)).forEach(p=>{let h=new e({breadcrumbs:[...this.breadcrumbs,p],context:this.context,schema:s,example:r[p],depth:this.depth+1,generateOptionalProperties:!1,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();f.push({key:p,result:h})})}for(let{key:s,result:u}of f)u.validExample!==void 0&&c[s]===void 0&&(c[s]=u.validExample);if(Object.keys(c).length===0){let s=n.find(u=>u.validExample!==void 0&&(typeof u.validExample!="object"||u.validExample===null));s&&(c=s.validExample)}return{isValid:a,coerced:!1,usedProvidedExample:o,validExample:c,errors:[...i.flatMap(({result:s})=>s.errors),...n.flatMap(s=>s.errors)]}}convertSchemaTypeArray({resolvedSchema:t}){if(!Array.isArray(t.type))return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};if(t.type.length===1)return new e({breadcrumbs:this.breadcrumbs,context:this.context,schema:{...t,type:t.type[0]},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();let r=t.type.map((c,f)=>new e({breadcrumbs:[...this.breadcrumbs,`type[${f}]`],context:this.context,schema:{...t,type:c},example:this.example,depth:this.depth,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert()),i=r.some(c=>c?.isValid??!1),a=r.find(c=>c.isValid)?.validExample??r[0]?.validExample??null,o=r.some(c=>c.usedProvidedExample);return{isValid:i,coerced:!1,usedProvidedExample:o,validExample:a,errors:i?[]:r.flatMap(c=>c?.errors??[])}}convertUnion({resolvedSchema:t,unionType:r}){let i=r==="oneOf"?t.oneOf:t.anyOf;if(!(r in t)||i==null)return{isValid:!1,coerced:!1,usedProvidedExample:!1,validExample:null,errors:[]};let n=this.example??this.maybeResolveSchemaExample(t);if(this.example===void 0){let p=[];for(let h of i){if(!h)continue;let y=this.context.resolveMaybeReference({schemaOrReference:h,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});y&&p.push(y)}if(p.length>0&&p.every(h=>$YS(h))){let h=p.findIndex(y=>gc_(y)!==void 0);if(h!==-1){let y=i[h],b=p[h];if(y&&b){let v=gc_(b),A=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${h}]`],context:this.context,schema:r==="oneOf"?{...t,...y,oneOf:void 0}:y,example:v,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(A.isValid)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:A.validExample,errors:[]}}}}}let a=[],o=null,c=null;for(let p=0;p<i.length;p++){let _=i[p];if(!_)continue;let h=r==="oneOf"?{...t,..._,oneOf:void 0}:_,y=n??this.maybeResolveSchemaExample(h),v=new e({breadcrumbs:[...this.breadcrumbs,`${r}[${p}]`],context:this.context,schema:h,example:y,depth:this.depth+1,generateOptionalProperties:this.generateOptionalProperties,exampleGenerationStrategy:this.exampleGenerationStrategy,seenRefs:this.getMaybeUpdatedSeenRefs()}).convert();if(v.isValid&&!v.coerced&&v.usedProvidedExample)return{isValid:!0,coerced:!1,usedProvidedExample:!0,validExample:v.validExample,errors:[]};if(v.isValid&&!v.coerced)return{isValid:!0,coerced:!1,usedProvidedExample:v.usedProvidedExample,validExample:v.validExample,errors:[]};a.push(v),v.isValid&&v.usedProvidedExample&&c===null&&(c=v),v.isValid&&o===null&&(o=v)}let f=c??o,s=f!==null,u=f?.validExample??a[0]?.validExample,l=f?.usedProvidedExample??!1;return{isValid:s,coerced:!1,usedProvidedExample:l,validExample:u,errors:s?[]:a.flatMap(p=>p.errors)}}convertOneOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"oneOf"})}convertAnyOf({resolvedSchema:t}){return this.convertUnion({resolvedSchema:t,unionType:"anyOf"})}getMaybeUpdatedSeenRefs(){let t=new Set(this.seenRefs);return this.context.isReferenceObject(this.schema)&&t.add(this.schema.$ref),t}maybeResolveSchemaExample(t){let r=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(r!=null){if("example"in r)return r.example;if("examples"in r){let i=r.examples;return Array.isArray(i)&&i.length>0?i[0]:Object.values(i??{})[0]}}}maybeConvertLiteralFernType(t){let r=t["x-fern-type"];if(typeof r!="string")return;let i=r.match(JYS);if(i!=null){if(i[1]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[1],errors:[]};if(i[2]!=null)return{isValid:!0,coerced:!1,usedProvidedExample:!1,validExample:i[2]==="true",errors:[]}}}isDeprecatedProperty(t){return t!=null&&"availability"in t&&t.availability==="deprecated"}isRequiredProperty({key:t,resolvedSchema:r}){return r.required?.includes(t)??!1}};var Tac={};Kt(Tac,{ArraySchemaConverter:()=>fQn,EnumSchemaConverter:()=>uQn,ObjectSchemaConverter:()=>sQn,OneOfSchemaConverter:()=>cQn,PrimitiveSchemaConverter:()=>lQn,SchemaConverter:()=>MCi,SchemaOrReferenceConverter:()=>LL});function Oc_(e){return wB({type:e,_default:void 0,validation:void 0,visitor:{primitive:t=>{switch(t.v1){case"BASE_64":return ni.primitive({v1:"BASE_64",v2:Pn.base64({})});case"BOOLEAN":return ni.primitive({v1:"BOOLEAN",v2:Pn.boolean({default:void 0})});case"DATE":return ni.primitive({v1:"DATE",v2:Pn.date({})});case"DATE_TIME":return ni.primitive({v1:"DATE_TIME",v2:Pn.dateTime({})});case"FLOAT":return ni.primitive({v1:"FLOAT",v2:Pn.float({})});case"DOUBLE":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:void 0,validation:void 0})});case"UINT":return ni.primitive({v1:"UINT",v2:Pn.uint({})});case"UINT_64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({})});case"INTEGER":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:void 0,validation:void 0})});case"LONG":return ni.primitive({v1:"LONG",v2:Pn.long({default:void 0})});case"STRING":return ni.primitive({v1:"STRING",v2:Pn.string({default:void 0,validation:void 0})});case"UUID":return ni.primitive({v1:"UUID",v2:Pn.uuid({})});case"BIG_INTEGER":return ni.primitive({v1:"BIG_INTEGER",v2:Pn.bigInteger({default:void 0})});default:return}},unknown:()=>ni.unknown(),map:({keyType:t,valueType:r})=>{if(!(t==null||r==null))return ni.container(es.map({keyType:t,valueType:r}))},list:t=>{if(t!=null)return ni.container(es.list(t))},optional:t=>{if(t!=null)return ni.container(es.optional(t))},nullable:t=>{if(t!=null)return ni.container(es.nullable(t))},set:t=>{if(t!=null)return ni.container(es.set(t))},literal:t=>ni.container(es.literal(t._visit({string:r=>uz.string(r),boolean:r=>uz.boolean(r),_other:()=>{throw new Error("Unexpected literal type")}}))),named:()=>{}}})}var uQn=class extends Ra{schema;maybeFernEnum;constructor({context:t,breadcrumbs:r,schema:i,maybeFernEnum:n}){super({context:t,breadcrumbs:r}),this.schema=i,this.maybeFernEnum=n}convert(){if(!this.schema.enum)return;let r=this.schema.enum.filter(n=>typeof n=="string"||typeof n=="number").map(n=>{let a=n.toString(),o=this.maybeFernEnum?.[a],c=o?.name??a;return{name:this.context.casingsGenerator.generateNameAndWireValue({name:c,wireValue:a}),docs:o?.description,availability:void 0,casing:o?.casing}});if(r.length===0){this.context.errorCollector.collect({message:`Received enum schema with no valid values: ${JSON.stringify(this.schema)}`,path:this.breadcrumbs});return}let i=this.context.getAsString(this.schema.default);return{type:Zc.enum({default:i!=null?r.find(n=>n.name.wireValue===i):void 0,values:r})}}};var iQo=class extends Ra{schemaOrReferenceOrBoolean;constructor({context:t,breadcrumbs:r,schemaOrReferenceOrBoolean:i}){super({context:t,breadcrumbs:r}),this.schemaOrReferenceOrBoolean=i}convert(){let t=this.tryConvertUnknownMap();if(t!=null)return t;let r=this.tryConvertTypedMap();if(r!=null)return r}tryConvertUnknownMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean"){let t=ni.container(es.map({keyType:Ra.STRING,valueType:ni.unknown()}));return{type:Zc.alias({aliasOf:t,resolvedType:t}),referencedTypes:new Set,inlinedTypes:{}}}}tryConvertTypedMap(){if(typeof this.schemaOrReferenceOrBoolean=="boolean")return;let r=new LL({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:this.schemaOrReferenceOrBoolean}).convert();if(r!=null){let i=ni.container(es.map({keyType:Ra.STRING,valueType:r.type})),n=new Set;for(let a of r.schema?.typeDeclaration.referencedTypes??[])n.add(a);for(let a of Object.keys(r.inlinedTypes))n.add(a);return{type:Zc.alias({aliasOf:i,resolvedType:i}),referencedTypes:n,inlinedTypes:r.inlinedTypes}}}};function bPa({properties:e,required:t,breadcrumbs:r,context:i,errorCollector:n}){let a=[],o={},c={},f=new Set;for(let[s,u]of Object.entries(e??{})){let l=[...r,"properties",s];if(typeof u!="object"){n.collect({message:`Schema property ${s} should be an object`,path:l});continue}let p=YYS(r,u,i)??i.convertBreadcrumbsToName(l),_="nullable"in u?u.nullable:!1,y=new LL({context:i,breadcrumbs:l,schemaOrReference:u,schemaIdOverride:p,wrapAsOptional:!t.includes(s),wrapAsNullable:_}).convert();if(y!=null){a.push({name:i.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),valueType:y.type,docs:u.description,availability:y.availability,propertyAccess:i.getPropertyAccess(u),v2Examples:y.schema?.typeDeclaration?.v2Examples??{userSpecifiedExamples:{},autogeneratedExamples:{}}}),o={...o,...y.inlinedTypes},y.schema?.typeDeclaration.referencedTypes!=null&&y.schema.typeDeclaration.referencedTypes.forEach(b=>{f.add(b)});for(let b of y.schema?.audiences??[])c[b]==null&&(c[b]=new Set),c[b].add(s)}}for(let s of Object.keys(o))f.add(s);return{convertedProperties:a,propertiesByAudience:c,inlinedTypesFromProperties:o,referencedTypes:f}}function YYS(e,t,r){return r.isReferenceObject(t)?void 0:new C1.FernTypeNameExtension({breadcrumbs:e,schema:t,context:r}).convert()}var sQn=class extends Ra{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){let t=typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties;if(!this.schema.properties&&!this.schema.allOf)return{type:Zc.object({properties:[],extends:[],extendedProperties:[],extraProperties:t}),propertiesByAudience:{},inlinedTypes:{},referencedTypes:new Set};let{convertedProperties:r,inlinedTypesFromProperties:i,referencedTypes:n,propertiesByAudience:a}=bPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector}),o=[],c=n,f=this.schema.required!=null&&this.schema.required.length>0,s=i,u=a;for(let[l,p]of(this.schema.allOf??[]).entries()){let _=[...this.breadcrumbs,"allOf",l.toString()],h;if(this.context.isReferenceObject(p)){let A=this.context.resolveMaybeReference({schemaOrReference:p,breadcrumbs:_});if(A==null){this.context.logger.debug?.(`[ObjectSchemaConverter] allOf[${l}] reference could not be resolved. Skipping: ${JSON.stringify(p)}`);continue}if(h=A,typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0),!f||Object.keys(h.properties??{}).every(g=>!this.schema.required?.includes(g))){this.addTypeReferenceToExtends({reference:p,breadcrumbs:_,extends_:o,referencedTypes:c});continue}}else h=p;typeof h.additionalProperties=="boolean"&&h.additionalProperties&&(t=!0);let{convertedProperties:y,inlinedTypesFromProperties:b,referencedTypes:v,propertiesByAudience:O}=bPa({properties:h.properties??{},required:[...this.schema.required??[],...h.required??[]],breadcrumbs:_,context:this.context,errorCollector:this.context.errorCollector});r.push(...y),s={...s,...b},u={...u,...O},v.forEach(A=>{c.add(A)})}for(let l of Object.keys(s))c.add(l);return{type:Zc.object({properties:r,extends:o.map(l=>this.context.typeReferenceToDeclaredTypeName(l)).filter(ps),extendedProperties:[],extraProperties:t}),propertiesByAudience:u,referencedTypes:c,inlinedTypes:s}}addTypeReferenceToExtends({reference:t,breadcrumbs:r,extends_:i,referencedTypes:n}){let a=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:r});a.ok&&i.push(a.reference);let o=this.context.getTypeIdFromSchemaReference(t);o!=null&&n.add(o)}};var nQo=class extends kc{node;key="x-fern-discriminated";constructor({breadcrumbs:t,node:r,context:i}){super({breadcrumbs:t,context:i}),this.node=r}convert(){let t=this.getExtensionValue(this.node);if(t!=null&&typeof t=="boolean")return t}};var cQn=class extends Ra{schema;id;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlinedTypes:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n}convert(){return this.shouldConvertAsNullableSchemaOrReference()?this.convertAsNullableSchemaOrReference():new nQo({context:this.context,breadcrumbs:this.breadcrumbs,node:this.schema}).convert()===!1?this.convertAsUndiscriminatedUnion():this.schema.discriminator!=null&&!this.unionVariantsContainLiteral({discriminantProperty:this.schema.discriminator.propertyName})?this.convertAsDiscriminatedUnion():this.convertAsUndiscriminatedUnion()}unionVariantsContainLiteral({discriminantProperty:t}){for(let[r,i]of Object.entries(this.schema.discriminator?.mapping??{})){let n=this.context.resolveReference({reference:{$ref:i},breadcrumbs:this.breadcrumbs});if(n.resolved&&!Object.keys(n.value.properties??{}).includes(t))return!1}return!0}convertAsDiscriminatedUnion(){if(this.schema.discriminator==null)return;let t=[],r=new Set,i={};for(let[f,s]of Object.entries(this.schema.discriminator.mapping??{})){let u=new LL({context:this.context,schemaOrReference:{$ref:s},breadcrumbs:[...this.breadcrumbs,"discriminator","mapping",f]}),l=this.context.getTypeIdFromSchemaReference({$ref:s});l!=null&&r.add(l);let p=u.convert();if(p?.type!=null&&l!=null){for(let h of Object.keys(p?.inlinedTypes??{}))r.add(h);for(let h of p.schema?.typeDeclaration.referencedTypes??[])r.add(h);let _=this.context.casingsGenerator.generateNameAndWireValue({name:f,wireValue:f});t.push({docs:void 0,discriminantValue:_,availability:p.availability,displayName:f,shape:oz.samePropertiesAsObject({typeId:l,name:this.context.casingsGenerator.generateName(l),fernFilepath:{allParts:[],packagePath:[],file:void 0},displayName:f})}),i={...i,...p.inlinedTypes}}}let{convertedProperties:n,referencedTypes:a,inlinedTypesFromProperties:o}=bPa({properties:this.schema.properties??{},required:this.schema.required??[],breadcrumbs:this.breadcrumbs,context:this.context,errorCollector:this.context.errorCollector});r=new Set([...r,...a]);let c=[];for(let[f,s]of(this.schema.allOf??[]).entries()){let u=[...this.breadcrumbs,"allOf",f.toString()];if(this.context.isReferenceObject(s)){let l=this.context.convertReferenceToTypeReference({reference:s,breadcrumbs:u});if(l.ok){let _=this.context.typeReferenceToDeclaredTypeName(l.reference);_!=null&&c.push(_)}let p=this.context.getTypeIdFromSchemaReference(s);p!=null&&r.add(p);continue}}for(let f of Object.keys({...i,...o}))r.add(f);return{type:Zc.union({baseProperties:n,discriminant:this.context.casingsGenerator.generateNameAndWireValue({name:this.schema.discriminator.propertyName,wireValue:this.schema.discriminator.propertyName}),extends:c,types:t}),referencedTypes:r,inlinedTypes:{...i,...o}}}convertAsUndiscriminatedUnion(){if(!this.schema.oneOf&&!this.schema.anyOf||this.schema.anyOf?.length===0&&this.schema.oneOf?.length===0)return;let t=[],r=new Set,i={},n=[...this.schema.oneOf??[],...this.schema.anyOf??[]].filter(a=>!this.context.isReferenceObject(a));for(let[a,o]of[...(this.schema.oneOf??[]).entries(),...(this.schema.anyOf??[]).entries()]){if(this.context.isReferenceObject(o)){let p;if(this.context.isReferenceObjectWithIdentifier(o))p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.summary??o.title??o.name??o.messageId,displayNameOverrideSource:"reference_identifier"});else if(this.getDiscriminatorKeyForRef(o)!=null){let h=this.getDiscriminatorKeyForRef(o);p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:h,displayNameOverrideSource:"discriminator_key"})}else p=this.context.convertReferenceToTypeReference({reference:o,displayNameOverride:o.$ref.split("/").pop(),displayNameOverrideSource:"schema_identifier"});p.ok&&t.push({type:p.reference,docs:o.description});let _=this.context.getTypeIdFromSchemaReference(o);_!=null&&r.add(_);continue}let c=this.extendSubSchema(o),f=this.context.convertBreadcrumbsToName([`${this.id}_${a}`]),s=o.title,l=new MCi({context:this.context,id:f,nameOverride:s,breadcrumbs:[...this.breadcrumbs,`oneOf[${a}]`],schema:c??o}).convert();if(l!=null){let p=l.convertedSchema.typeDeclaration.shape;p.type==="alias"&&this.typeReferenceIsWrappedPrimitive(p.aliasOf)?t.push({type:p.aliasOf,docs:o.description}):p.type==="object"&&p.properties.length===0&&p.extends.length===0?t.push({type:ni.container(es.map({keyType:Ra.STRING,valueType:ni.unknown()})),docs:o.description}):(t.push({type:this.context.createNamedTypeReference(f,s),docs:o.description}),i={...i,...l.inlinedTypes,[f]:l.convertedSchema}),l.convertedSchema.typeDeclaration.referencedTypes.forEach(_=>{r.add(_)})}}return{type:Zc.undiscriminatedUnion({members:t}),referencedTypes:r,inlinedTypes:i}}shouldConvertAsNullableSchemaOrReference(){return this.schema.oneOf!=null?this.schema.oneOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):this.schema.anyOf!=null?this.schema.anyOf.some(t=>t&&typeof t=="object"&&"type"in t&&t.type==="null"):!1}removeNullFromOneOfOrAnyOf(){let t=this.schema.oneOf??this.schema.anyOf,r=this.schema.oneOf!=null?"oneOf":"anyOf";if(t==null)return;let i=t.filter(n=>!("type"in n&&n.type==="null"));if(i.length===0){this.context.errorCollector.collect({message:`Received ${r} schema with no valid non-null types`,path:this.breadcrumbs});return}return i.length===1?{...this.schema,[r]:void 0,...i[0]}:{...this.schema,[r]:i}}convertAsNullableSchemaOrReference(){let t=this.removeNullFromOneOfOrAnyOf();if(t==null)return;let i=new LL({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReference:t}).convert();if(i==null)return;let n=this.wrapInNullable(i.type);return{type:Zc.alias({aliasOf:n,resolvedType:n}),referencedTypes:i.schema?.typeDeclaration.referencedTypes??new Set,inlinedTypes:i.inlinedTypes}}typeReferenceIsWrappedPrimitive(t){switch(t.type){case"container":return this.containerTypeIsWrappedPrimitive(t.container);case"named":return!1;case"primitive":return!0;case"unknown":return!0;default:return!1}}containerTypeIsWrappedPrimitive(t){switch(t.type){case"list":return this.typeReferenceIsWrappedPrimitive(t.list);case"map":return this.typeReferenceIsWrappedPrimitive(t.keyType)&&this.typeReferenceIsWrappedPrimitive(t.valueType);case"nullable":return this.typeReferenceIsWrappedPrimitive(t.nullable);case"optional":return this.typeReferenceIsWrappedPrimitive(t.optional);case"set":return this.typeReferenceIsWrappedPrimitive(t.set);case"literal":return!0;default:return!1}}wrapInNullable(t){return ni.container(es.nullable(t))}mergeIntoObjectSchema(t,r){return{...t,properties:{...r,...t.properties??{}}}}extendSubSchema(t){if(Object.entries(this.schema.properties??{}).length===0)return t;if(t.type==="object")return this.mergeIntoObjectSchema(t,this.schema.properties??{});this.context.isObjectSchemaType(t)||this.context.errorCollector.collect({message:"Received additional object properties for oneOf/anyOf that are not objects",path:this.breadcrumbs})}getDiscriminatorKeyForRef(t){return Object.entries(this.schema.discriminator?.mapping??{}).find(([r,i])=>i===t.$ref)?.[0]}};var lQn=class extends Ra{schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){switch(this.schema.type){case"string":{let t=this.context.getAsString(this.schema.const);if(t!=null)return ni.container(es.literal(uz.string(t)));if(this.context.settings.typeDatesAsStrings===!1){if(this.schema.format==="date")return ni.primitive({v1:Su.Date,v2:Pn.date({})});if(this.schema.format==="date-time")return ni.primitive({v1:Su.DateTime,v2:Pn.dateTime({})})}return ni.primitive({v1:"STRING",v2:Pn.string({default:this.context.getAsString(this.schema.default),validation:this.getStringValidation(this.schema)})})}case"number":switch(this.schema.format){case"double":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ni.primitive({v1:"FLOAT",v2:Pn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ni.primitive({v1:"LONG",v2:Pn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ni.primitive({v1:"UINT",v2:Pn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"integer":switch(this.schema.format){case"double":return ni.primitive({v1:"DOUBLE",v2:Pn.double({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"float":return ni.primitive({v1:"FLOAT",v2:Pn.float({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int32":return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"int64":return ni.primitive({v1:"LONG",v2:Pn.long({default:this.context.getAsNumber(this.schema.default)})});case"uint32":return ni.primitive({v1:"UINT",v2:Pn.uint({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});case"uint64":return ni.primitive({v1:"UINT_64",v2:Pn.uint64({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})});default:return ni.primitive({v1:"INTEGER",v2:Pn.integer({default:this.context.getAsNumber(this.schema.default),validation:this.getNumberValidation(this.schema)})})}case"boolean":{let t=this.context.getAsBoolean(this.schema.const);return t!=null?ni.container(es.literal(uz.boolean(t))):ni.primitive({v1:"BOOLEAN",v2:Pn.boolean({default:this.schema.default})})}default:return}}getNumberValidation(t){return{max:t.maximum,min:t.minimum,exclusiveMax:typeof t.exclusiveMaximum=="boolean"?t.exclusiveMaximum:void 0,exclusiveMin:typeof t.exclusiveMinimum=="boolean"?t.exclusiveMinimum:void 0,multipleOf:t.multipleOf}}getStringValidation(t){return{minLength:t.minLength,maxLength:t.maxLength,pattern:t.pattern,format:t.format}}};var XYS=["description","example","title","default","deprecated","readOnly","writeOnly","xml","externalDocs","extensions"],MCi=class e extends Ra{schema;id;inlined;audiences;nameOverride;constructor({context:t,breadcrumbs:r,schema:i,id:n,inlined:a=!1,nameOverride:o}){super({context:t,breadcrumbs:r}),this.schema=i,this.id=n,this.inlined=a,this.nameOverride=o,this.audiences=this.context.getAudiences({operation:this.schema,breadcrumbs:this.breadcrumbs})??[]}convert(){let t=this.tryConvertFernTypeDeclaration();if(t!=null)return t;let r=this.tryConvertEnumSchema();if(r!=null)return r;let i=this.tryConvertSingularAllOfSchema();if(i!=null)return i;let n=this.tryConvertPrimitiveSchema();if(n!=null)return n;let a=this.tryConvertArraySchema();if(a!=null)return a;let o=this.tryConvertTypeArraySchema();if(o!=null)return o;let c=this.tryConvertOneOfAnyOfSchema();if(c!=null)return c;let f=this.tryConvertMapSchema();if(f!=null)return f;let s=this.tryConvertObjectAllOfSchema();if(s!=null)return s;let u=this.tryConvertUntypedSchema();if(u!=null)return u;this.context.errorCollector.collect({message:`Failed to convert schema object: ${JSON.stringify(this.schema,null,2)}`,path:this.breadcrumbs})}tryConvertEnumSchema(){if(!this.schema.enum?.length)return;let r=new C1.FernEnumExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert(),n=new uQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,maybeFernEnum:r}).convert();if(n!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:n.type,referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertSingularAllOfSchema(){if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&this.schema.allOf?.length===1&&this.schema.allOf[0]!=null){let r=this.context.resolveMaybeReference({schemaOrReference:this.schema.allOf[0],breadcrumbs:this.breadcrumbs});if(r!=null){let n=new e({context:this.context,breadcrumbs:[...this.breadcrumbs,"allOf","0"],schema:r,id:this.id,inlined:!0}).convert();if(n?.convertedSchema.typeDeclaration?.shape.type!=="object")return n}}if(this.schemaOnlyHasAllowedKeys(["allOf","type","title"])&&Array.isArray(this.schema.allOf)&&this.schema.allOf.length>=1){let r={};for(let n of this.schema.allOf??[]){if(this.context.isReferenceObject(n))return;r=NMn(r,n,(a,o)=>{if(o===n)return a;if(Array.isArray(a)&&Array.isArray(o))return[...a,...o]})}return new e({context:this.context,breadcrumbs:this.breadcrumbs,schema:r,id:this.id,inlined:!0}).convert()}}tryConvertPrimitiveSchema(){let r=new lQn({context:this.context,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:r,resolvedType:r}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertArraySchema(){if(this.schema.type==="array"){let r=new fQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:r.typeReference,resolvedType:r.typeReference}),referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertTypeArraySchema(){if(Array.isArray(this.schema.type)&&this.schema.type.length>0)return this.schema.type.length===1?this.schema.type=this.schema.type[0]:(this.schema.oneOf=this.schema.type.map(t=>({type:t})),this.schema.type=void 0),this.convert()}tryConvertOneOfAnyOfSchema(){if(this.schema.oneOf!=null||this.schema.anyOf!=null){let r=new cQn({id:this.id,context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema,inlinedTypes:{}}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertMapSchema(){if((typeof this.schema.additionalProperties=="object"||typeof this.schema.additionalProperties=="boolean")&&this.schema.additionalProperties!=null&&!this.schema.properties&&!this.schema.allOf){if(typeof this.schema.additionalProperties=="boolean"&&this.schema.additionalProperties===!1)return;let r=new iQo({context:this.context,breadcrumbs:this.breadcrumbs,schemaOrReferenceOrBoolean:this.schema.additionalProperties}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:r.inlinedTypes}}}tryConvertObjectAllOfSchema(){if(this.schema.type==="object"||this.schema.properties!=null||this.schema.allOf!=null){let r=new sQn({context:this.context,breadcrumbs:this.breadcrumbs,schema:this.schema}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:r.referencedTypes}),audiences:this.audiences,propertiesByAudience:r.propertiesByAudience},inlinedTypes:r.inlinedTypes}}}tryConvertUntypedSchema(){if(this.isUntypedSchema())return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:ni.unknown(),resolvedType:ni.unknown()}),referencedTypes:new Set}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}tryConvertFernTypeDeclaration(){let r=new C1.FernTypeExtension({breadcrumbs:this.breadcrumbs,schema:this.schema,context:this.context}).convert();if(r==null)return;let i=Oc_(r);if(i!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.alias({aliasOf:i,resolvedType:i}),referencedTypes:new Set,omitV2Examples:!0}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}createTypeDeclaration({shape:t,referencedTypes:r,omitV2Examples:i}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:this.context.getAvailability({node:this.schema,breadcrumbs:this.breadcrumbs}),docs:this.schema.description,referencedTypes:r,source:void 0,inline:this.inlined,v2Examples:i?void 0:this.convertSchemaExamples()}}convertDeclaredTypeName(){return{typeId:this.id,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(this.id),displayName:this.nameOverride}}schemaOnlyHasAllowedKeys(t){let r=[...XYS,...t];return Object.keys(this.schema).every(n=>r.includes(n))}isUntypedSchema(){return!!(this.schema&&typeof this.schema=="object"&&!("oneOf"in this.schema)&&!("anyOf"in this.schema)&&!("allOf"in this.schema)&&!("items"in this.schema)&&!("properties"in this.schema))}convertSchemaExamples(){let t={userSpecifiedExamples:{},autogeneratedExamples:{}},r=this.context.getExamplesFromSchema({schema:this.schema,breadcrumbs:this.breadcrumbs});if(r.length===0){let i=this.generateOrValidateExample({example:void 0,ignoreErrors:!0});return t.autogeneratedExamples={[`${this.id}_example_autogenerated`]:i},t}return t.userSpecifiedExamples=this.convertUserSpecifiedExamples(r),t}convertUserSpecifiedExamples(t){let r={};for(let[i,n]of t.entries()){let a=this.context.resolveExample(n),o=this.generateOrValidateExample({example:a});r[`${this.id}_example_${i}`]=o}return r}generateOrValidateExample({example:t,ignoreErrors:r}){let i=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:this.schema,example:t}),{validExample:n,errors:a}=i.convert();return r||a.forEach(o=>{this.context.errorCollector.collect({message:o.message,path:o.path})}),n}};var LL=class extends Ra{schemaOrReference;schemaIdOverride;wrapAsOptional;wrapAsNullable;constructor({context:t,breadcrumbs:r,schemaOrReference:i,schemaIdOverride:n,wrapAsOptional:a=!1,wrapAsNullable:o=!1}){super({context:t,breadcrumbs:r}),this.schemaOrReference=i,this.schemaIdOverride=n,this.wrapAsOptional=a,this.wrapAsNullable=o}convert(){let t=this.maybeConvertReferenceObject({schemaOrReference:this.schemaOrReference});if(t!=null)return t;let r=this.maybeConvertSingularAllOfReferenceObject();return r??this.convertSchemaObject({schema:this.schemaOrReference})}maybeConvertReferenceObject({schemaOrReference:t}){if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:r.inlinedTypes??{}}}}maybeConvertSingularAllOfReferenceObject(){if(this.context.isReferenceObject(this.schemaOrReference)||this.schemaOrReference.allOf==null||this.schemaOrReference.allOf.length!==1)return;let t=this.schemaOrReference.allOf[0];if(this.context.isReferenceObject(t)){let r=this.context.convertReferenceToTypeReference({reference:t,breadcrumbs:this.breadcrumbs});if(r.ok)return{type:this.wrapTypeReference(r.reference),inlinedTypes:{}}}}convertSchemaObject({schema:t}){let r=this.schemaIdOverride??this.context.convertBreadcrumbsToName(this.breadcrumbs),i=new MCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:t,id:r}),n=this.context.getAvailability({node:t,breadcrumbs:this.breadcrumbs}),a=i.convert();if(a!=null){let o=a.convertedSchema.typeDeclaration.shape;return o.type==="alias"?{type:this.wrapTypeReference(o.aliasOf),schema:a.convertedSchema,inlinedTypes:a.inlinedTypes,availability:n}:{type:this.wrapTypeReference(this.context.createNamedTypeReference(r)),schema:a.convertedSchema,inlinedTypes:{...a.inlinedTypes,[r]:a.convertedSchema},availability:n}}}wrapTypeReference(t){return this.wrapAsOptional&&this.wrapAsNullable?this.wrapInOptional(this.wrapInNullable(t)):this.wrapAsOptional?this.wrapInOptional(t):this.wrapAsNullable?this.wrapInNullable(t):t}wrapInOptional(t){return ni.container(es.optional(t))}wrapInNullable(t){return ni.container(es.nullable(t))}};var fQn=class e extends Ra{static LIST_UNKNOWN=ni.container(es.list(ni.unknown()));schema;constructor({context:t,breadcrumbs:r,schema:i}){super({context:t,breadcrumbs:r}),this.schema=i}convert(){if(this.schema.items!=null){Array.isArray(this.schema.items)&&(this.schema.items={oneOf:this.schema.items});let r=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs,"items"],schemaOrReference:this.schema.items}).convert();if(r!=null){let i=new Set;for(let n of r.schema?.typeDeclaration.referencedTypes??[])i.add(n);return r.inlinedTypes!=null&&Object.values(r.inlinedTypes).forEach(n=>{n.typeDeclaration.referencedTypes.forEach(a=>{i.add(a)})}),{typeReference:ni.container(es.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var aQo=class extends Ra{group;method;constructor({context:t,breadcrumbs:r,group:i,method:n}){super({context:t,breadcrumbs:r}),this.group=i,this.method=n}parseMediaTypeObject({mediaTypeObject:t,resolveSchema:r,contentType:i,schemaId:n}){if(t.schema==null)return;if(r){let f=this.context.resolveMaybeReference({schemaOrReference:t.schema,breadcrumbs:[...this.breadcrumbs,"content",i]});if(f==null)return;t.schema=f}let o=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs,"content",i,"schema"],schemaOrReference:t.schema,schemaIdOverride:n}).convert();if(o==null)return;let c=t.examples!=null?Object.fromEntries(Object.entries(t.examples).map(([f,s])=>{if(this.context.isReferenceObject(s)){let u=this.context.resolveReference({reference:s,breadcrumbs:[...this.breadcrumbs,"content",i,"examples"],skipErrorCollector:!0});return u.resolved?[f,u.value.value??u.value]:null}return[f,s.value??s]}).filter(f=>f!=null)):void 0;return{...o,examples:c}}parseMediaTypeSchemaOrReference({schemaOrReference:t,schemaId:r}){let n=new LL({context:this.context,breadcrumbs:[...this.breadcrumbs],schemaOrReference:t,schemaIdOverride:r}).convert();if(n!=null)return{...n,examples:void 0}}convertMediaTypeObjectExamples({mediaTypeObject:t,generateOptionalProperties:r,exampleGenerationStrategy:i}){let n={userSpecifiedExamples:{},autogeneratedExamples:{}},a=t?.schema,o=this.context.getNamedExamplesFromMediaTypeObject({mediaTypeObject:t,breadcrumbs:this.breadcrumbs,defaultExampleName:`${[...this.group,this.method].join("_")}_example`});for(let[c,f]of o){let s=this.context.resolveExampleWithValue(f),u=this.context.isExampleWithSummary(f)?f.summary:c;s!=null&&(a!=null?n.userSpecifiedExamples[u]=this.generateOrValidateExample({schema:a,example:s,exampleGenerationStrategy:i}):n.userSpecifiedExamples[u]=s)}if(Object.keys(n.userSpecifiedExamples).length===0&&a!=null){let c=No(`${[...this.group,this.method].join("_")}_example`);n.autogeneratedExamples[c]=this.generateOrValidateExample({schema:a,example:void 0,ignoreErrors:!0,generateOptionalProperties:r,exampleGenerationStrategy:i})}return n}generateOrValidateExample({schema:t,example:r,ignoreErrors:i,generateOptionalProperties:n,exampleGenerationStrategy:a}){let o=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs,skipErrorCollector:!0});if(o==null)return;let c=this.context.getExamplesFromSchema({schema:o,breadcrumbs:this.breadcrumbs}),f=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:o,example:r??c[0],generateOptionalProperties:n??!1,exampleGenerationStrategy:a}),{validExample:s,errors:u}=f.convert();return i||u.forEach(l=>{this.context.errorCollector.collect({message:l.message,path:l.path})}),s}};var oQo=class extends Ra{parameter;constructor({context:t,breadcrumbs:r,parameter:i}){super({context:t,breadcrumbs:r}),this.parameter=i}convertToOutput({schema:t,typeReference:r,inlinedTypes:i}){let n=this.context.getAvailability({node:this.parameter,breadcrumbs:this.breadcrumbs}),a=this.context.resolveMaybeReference({schemaOrReference:t,breadcrumbs:this.breadcrumbs}),o=this.getParameterSchemaWithExampleOverride({schema:a});switch(this.parameter.in){case"query":return{type:"query",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Ra.OPTIONAL_STRING,allowMultiple:this.parameter.explode??!1,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"header":return{type:"header",parameter:{name:this.context.casingsGenerator.generateNameAndWireValue({name:this.parameter.name,wireValue:this.parameter.name}),docs:this.parameter.description,valueType:r??Ra.OPTIONAL_STRING,env:void 0,v2Examples:this.convertParameterExamples({schema:o??t}),availability:n},inlinedTypes:i};case"path":return{type:"path",parameter:{name:this.context.casingsGenerator.generateName(this.parameter.name),docs:this.parameter.description,valueType:r??Ra.STRING,location:"ENDPOINT",variable:void 0,v2Examples:this.convertParameterExamples({schema:o??t})},inlinedTypes:i};default:return}}getParameterSchemaWithExampleOverride({schema:t}){if(t!=null)return t.type==="string"&&t.example==null?{...t,example:this.parameter.name}:t}convertParameterExamples({schema:t}){let r={userSpecifiedExamples:{},autogeneratedExamples:{}},i=this.parameter.example,n=this.parameter.examples;for(let[a,o]of Object.entries(n??{})){let c=this.context.resolveExampleWithValue(o);c!=null&&(r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:c}))}if(i!=null){let a=this.context.generateUniqueName({prefix:`${this.parameter.name}_example`,existingNames:Object.keys(r.userSpecifiedExamples)});r.userSpecifiedExamples[a]=this.generateOrValidateExample({schema:t,example:i})}if(Object.keys(r.userSpecifiedExamples).length===0){let a=`${this.parameter.name}_example`;r.autogeneratedExamples[a]=this.generateOrValidateExample({schema:t,example:void 0,ignoreErrors:!0})}return r}generateOrValidateExample({schema:t,ignoreErrors:r,example:i}){let n=new F0e({breadcrumbs:this.breadcrumbs,context:this.context,schema:t,example:i}),{validExample:a,errors:o}=n.convert();return r||o.forEach(c=>{this.context.errorCollector.collect({message:c.message,path:c.path})}),a}};var uQo=class extends kc{server;key="x-fern-server-name";constructor({breadcrumbs:t,server:r,context:i}){super({breadcrumbs:t,context:i}),this.server=r}convert(){let t=this.getExtensionValue(this.server,"x-name");if(!(t==null||typeof t!="string"))return t}};var Ac_="Base",Phe=class e extends Ra{servers;endpointLevelServers;constructor({breadcrumbs:t,context:r,servers:i,endpointLevelServers:n}){super({breadcrumbs:t,context:r}),this.servers=i,this.endpointLevelServers=n}convert(){if(this.servers==null||this.servers.length===0||this.servers[0]==null)return;if(this.endpointLevelServers!=null&&this.endpointLevelServers.length>0){let r=this.getDefaultBaseUrlName(),i={id:r,name:this.context.casingsGenerator.generateName(r)},n=this.endpointLevelServers.map(c=>{let f=e.getServerName({server:c,context:this.context});return{id:f,name:this.context.casingsGenerator.generateName(f)}}).filter((c,f,s)=>s.findIndex(u=>u.id===c.id)===f),a=[i,...n],o=this.servers.map(c=>{let f=e.getServerName({server:c,context:this.context}),s=this.endpointLevelServers?.map(u=>[e.getServerName({server:u,context:this.context}),this.getServerUrl(u)]);return{id:f,name:this.context.casingsGenerator.generateName(f),urls:{[r]:this.getServerUrl(c),...Object.fromEntries(s??[])},docs:c.description}});return{value:{defaultEnvironment:o[0]?.id,environments:YE.multipleBaseUrls({baseUrls:a,environments:o})},defaultUrl:i.id}}let t=this.withExplodedServers(this.servers).map(r=>{let i=e.getServerName({server:r,context:this.context});return{id:i,name:this.context.casingsGenerator.generateName(i),url:this.maybeRemoveTrailingSlashIfNotEmpty(this.getServerUrl(r)),docs:r.description}}).filter(ps);return{value:{defaultEnvironment:t[0]?.id,environments:YE.singleBaseUrl({environments:t})},defaultUrl:t[0]?.id}}static getServerExtensionName({server:t,context:r}){return new uQo({breadcrumbs:[],server:t,context:r}).convert()}static getServerName({server:t,context:r}){return t.name!=null?t.name:e.getServerExtensionName({server:t,context:r})??t.description??t.url}getServerUrl(t){if(t.variables==null)return t.url;let r=t.url;for(let[i,n]of Object.entries(t.variables))n.default!=null&&(r=r.replace(`{${i}}`,encodeURIComponent(n.default)));return r}withExplodedServers(t){return t.flatMap(r=>{if(r.variables==null)return[r];let i=Object.entries(r.variables).filter(([c,f])=>f.enum!=null&&f.enum.length>0);if(i.length===0)return[r];let n=i[0];if(n==null)return[r];let[a,o]=n;return o.enum==null?[r]:o.enum.map(c=>{let f=r.url.replace(`{${a}}`,encodeURIComponent(c)),s={};for(let[l,p]of Object.entries(r.variables??{}))l!==a&&(s[l]=p);let u={...r,url:f,variables:Object.keys(s).length>0?s:void 0,"x-fern-server-name":r.description?`${r.description}_${c}`:`${c}`,description:r.description};return this.withExplodedServers([u])[0]})}).filter(ps)}getDefaultBaseUrlName(){return this.servers==null||this.servers.length===0||this.servers[0]==null?Ac_:e.getServerExtensionName({server:this.servers[0],context:this.context})??Ac_}maybeRemoveTrailingSlashIfNotEmpty(t){return t.endsWith("/")&&t!=="/"?t.slice(0,-1):t}};var sQo={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"},ZYS=new Set(Object.values(sQo));var dQn=class{enabled=!0;write(t,...r){this.enabled&&process.stderr.write(`[${t}] ${r.join(" ")}
1359
1359
  `)}disable(){this.enabled=!1}enable(){this.enabled=!0}trace(...t){this.write($s.Trace,...t)}debug(...t){this.write($s.Debug,...t)}info(...t){this.write($s.Info,...t)}warn(...t){this.write($s.Warn,...t)}error(...t){this.write($s.Error,...t)}log(t,...r){this.write(t,...r)}};function fGt(e){if(e?.deprecated)return{status:IC.Deprecated,message:"DEPRECATED"}}var fFt={FILE:{NAME:1,PACKAGE:2,DEPENDENCY:3,MESSAGE_TYPE:4,ENUM_TYPE:5,SERVICE:6,EXTENSION:7,OPTIONS:8,SOURCE_CODE_INFO:9,PUBLIC_DEPENDENCY:10,WEAK_DEPENDENCY:11,SYNTAX:12},MESSAGE:{NAME:1,FIELD:2,NESTED_TYPE:3,ENUM_TYPE:4,EXTENSION_RANGE:5,EXTENSION:6,OPTIONS:7,ONEOF_DECL:8,RESERVED_RANGE:9,RESERVED_NAME:10},ENUM:{NAME:1,VALUE:2,OPTIONS:3,RESERVED_RANGE:4,RESERVED_NAME:5},SERVICE:{NAME:1,METHOD:2,OPTIONS:3},METHOD:{NAME:1,INPUT_TYPE:2,OUTPUT_TYPE:3,OPTIONS:4,CLIENT_STREAMING:5,SERVER_STREAMING:6}},cQo={MESSAGE:4,ENUM:5,SERVICE:6};var lQo=class extends Ra{enum;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,enum:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.enum=i,this.sourceCodeInfoPath=n}convert(){let t=this.enum.value.map((r,i)=>{let n=r.name;return{name:{name:this.context.casingsGenerator.generateName(n),wireValue:n},docs:this.context.getCommentForPath([...this.sourceCodeInfoPath,fFt.ENUM.VALUE,i]),availability:void 0}});return{type:Zc.enum({default:void 0,values:t})}}};function mc_(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var Pc_=new Set([vf.DOUBLE,vf.FLOAT,vf.INT64,vf.UINT64,vf.INT32,vf.FIXED64,vf.FIXED32,vf.BOOL,vf.STRING,vf.BYTES,vf.UINT32,vf.SFIXED32,vf.SFIXED64,vf.SINT32,vf.SINT64]);var fQo=class e extends Ra{static LIST_UNKNOWN=ni.container(es.list(ni.unknown()));field;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.field=i,this.sourceCodeInfoPath=n}convert(){if(this.field.label===3){let r=new DCi({context:this.context,breadcrumbs:this.breadcrumbs,field:{...this.field,label:hMn.OPTIONAL},sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null){let i=new Set;return{typeReference:ni.container(es.list(r.type)),referencedTypes:i,inlinedTypes:r.inlinedTypes}}}return{typeReference:e.LIST_UNKNOWN,referencedTypes:new Set,inlinedTypes:{}}}};var dQo=class extends Ra{field;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.field=i,this.sourceCodeInfoPath=n}convert(){switch(this.field.type){case vf.STRING:return ni.primitive({v1:Su.String,v2:Pn.string({default:void 0,validation:void 0})});case vf.DOUBLE:return ni.primitive({v1:Su.Double,v2:Pn.double({default:void 0,validation:void 0})});case vf.FLOAT:return ni.primitive({v1:Su.Float,v2:Pn.float({})});case vf.INT32:return ni.primitive({v1:Su.Integer,v2:Pn.integer({default:void 0,validation:void 0})});case vf.INT64:return ni.primitive({v1:Su.Long,v2:Pn.long({default:void 0})});case vf.UINT32:return ni.primitive({v1:Su.Uint,v2:Pn.uint({default:void 0})});case vf.UINT64:return ni.primitive({v1:Su.Uint64,v2:Pn.uint64({default:void 0})});case vf.BOOL:return ni.primitive({v1:Su.Boolean,v2:Pn.boolean({default:void 0})});default:return ni.unknown()}}};var DCi=class extends Ra{field;wrapAsOptional;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,field:i,wrapAsOptional:n,sourceCodeInfoPath:a}){super({context:t,breadcrumbs:r}),this.field=i,this.wrapAsOptional=n??!0,this.sourceCodeInfoPath=a}convert(){if(this.field.label===3){let i=new fQo({context:this.context,breadcrumbs:this.breadcrumbs,field:this.field,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(i!=null)return{type:this.wrapAsOptional?this.wrapInOptional(i.typeReference):i.typeReference,inlinedTypes:i.inlinedTypes,availability:fGt(this.field.options)}}if(Pc_.has(this.field.type)){let i=new dQo({context:this.context,breadcrumbs:this.breadcrumbs,field:this.field,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(i!=null)return{type:this.wrapAsOptional?this.wrapInOptional(i):i,inlinedTypes:{},availability:fGt(this.field.options)}}if((this.field.type===vf.MESSAGE||this.field.type===vf.ENUM)&&this.field.typeName!=null){let r=this.context.convertGrpcReferenceToTypeReference({typeName:this.field.typeName,displayNameOverride:this.field.name});if(r.ok)return{type:this.wrapAsOptional?this.wrapInOptional(r.reference):r.reference,inlinedTypes:{},availability:fGt(this.field.options)}}}wrapInOptional(t){return ni.container(es.optional(t))}};function jc_({fields:e,breadcrumbs:t,context:r,sourceCodeInfoPath:i}){let n=[],a={},o=new Set,c={};for(let[f,s]of e.entries()){let l=new DCi({context:r,breadcrumbs:[...t,"fields",s.name],field:s,sourceCodeInfoPath:[...i,fFt.MESSAGE.FIELD,f]}).convert();if(l!=null){let p={name:r.casingsGenerator.generateNameAndWireValue({name:s.name,wireValue:s.name}),valueType:l.type,docs:r.getCommentForPath([...i,fFt.MESSAGE.FIELD,f]),availability:l.availability,propertyAccess:void 0,v2Examples:void 0};if(Object.hasOwn(s,"oneofIndex")&&s.oneofIndex!=null){c[s.oneofIndex]==null&&(c[s.oneofIndex]=[]),c[s.oneofIndex].push(s);continue}n.push(p)}}return{convertedFields:n,referencedTypes:o,propertiesByAudience:a,oneOfFields:c}}var pQo=class extends Ra{oneOfFields;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,oneOfFields:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.oneOfFields=i,this.sourceCodeInfoPath=n}convert(){let t=[];for(let r of this.oneOfFields){let n=new DCi({context:this.context,breadcrumbs:this.breadcrumbs,field:r,wrapAsOptional:!1,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();n!=null&&t.push({type:n.type,docs:void 0})}return{type:Zc.undiscriminatedUnion({members:t}),referencedTypes:new Set,inlinedTypes:{},availability:fGt(this.getProtoAvailabilityOptions())}}getProtoAvailabilityOptions(){return{deprecated:this.oneOfFields.every(t=>t.options?.deprecated)}}};var _Qo=class extends Ra{message;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,message:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.message=i,this.sourceCodeInfoPath=n}convert(){let t={},r=new Set,{convertedFields:i,referencedTypes:n,propertiesByAudience:a,oneOfFields:o}=jc_({fields:this.message.field,breadcrumbs:this.breadcrumbs,context:this.context,sourceCodeInfoPath:this.sourceCodeInfoPath});for(let c of n)r.add(c);for(let[c,f]of this.message.nestedType.entries()){let u=new BCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:f,sourceCodeInfoPath:[...this.sourceCodeInfoPath,fFt.MESSAGE.NESTED_TYPE,c],schemaIndex:c}).convert();if(u!=null){for(let l of u.convertedSchema.typeDeclaration.referencedTypes)r.add(l);t={...t,...Object.fromEntries(Object.entries(u.inlinedTypes).map(([l,p])=>[this.prependDelimitedParentMessageName(l),this.context.updateTypeId(p,this.prependDelimitedParentMessageName(l))])),[this.prependDelimitedParentMessageName(f.name)]:this.context.updateTypeId(u.convertedSchema,this.prependDelimitedParentMessageName(f.name))}}}for(let[c,f]of this.message.enumType.entries()){let u=new BCi({context:this.context,breadcrumbs:this.breadcrumbs,schema:f,sourceCodeInfoPath:[...this.sourceCodeInfoPath,fFt.MESSAGE.ENUM_TYPE,c],schemaIndex:c}).convert();if(u!=null){for(let l of u.convertedSchema.typeDeclaration.referencedTypes)r.add(l);t={...t,...Object.fromEntries(Object.entries(u.inlinedTypes).map(([l,p])=>[this.prependDelimitedParentMessageName(l),this.context.updateTypeId(p,this.prependDelimitedParentMessageName(l))])),[this.prependDelimitedParentMessageName(f.name)]:this.context.updateTypeId(u.convertedSchema,this.prependDelimitedParentMessageName(f.name))}}}for(let[c,f]of this.message.oneofDecl.entries()){let u=new pQo({context:this.context,breadcrumbs:this.breadcrumbs,oneOfFields:o[c]??[],sourceCodeInfoPath:[...this.sourceCodeInfoPath,fFt.MESSAGE.ONEOF_DECL,c]}).convert();if(u!=null){for(let _ of u.referencedTypes)r.add(_);let l={typeDeclaration:this.createTypeDeclaration({shape:u.type,referencedTypes:u.referencedTypes,typeName:this.prependParentMessageName(mc_(f.name))}),audiences:[],propertiesByAudience:{}},p=this.context.convertGrpcReferenceToTypeReference({typeName:this.context.maybePrependPackageName(l.typeDeclaration.name.typeId)});p.ok===!0&&(i.push({name:this.context.casingsGenerator.generateNameAndWireValue({name:f.name,wireValue:f.name}),valueType:p.reference,docs:void 0,availability:u.availability,propertyAccess:void 0,v2Examples:void 0}),t={...t,[l.typeDeclaration.name.typeId]:l})}}return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:Zc.object({properties:i,extends:[],extendedProperties:[],extraProperties:!1}),referencedTypes:r,typeName:this.message.name,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),availability:fGt(this.message.options)}),audiences:[],propertiesByAudience:a},inlinedTypes:t}}createTypeDeclaration({shape:t,referencedTypes:r,typeName:i,docs:n,availability:a}){return{name:this.convertDeclaredTypeName(i),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:a,docs:n,referencedTypes:r,source:void 0,inline:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}convertDeclaredTypeName(t){let r=this.context.maybePrependPackageName(t);return{typeId:r,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(r),displayName:t}}prependDelimitedParentMessageName(t,r="."){return`${this.message.name}${r}${t}`}prependParentMessageName(t){return`${this.message.name}${t}`}};var BCi=class extends Ra{schema;audiences;sourceCodeInfoPath;schemaIndex;constructor({context:t,breadcrumbs:r,schema:i,sourceCodeInfoPath:n,schemaIndex:a}){super({context:t,breadcrumbs:r}),this.schema=i,this.sourceCodeInfoPath=n,this.schemaIndex=a,this.audiences=[]}convert(){let t=this.tryConvertGrpcEnum();if(t!=null)return t;let r=this.tryConvertGrpcMessage();if(r!=null)return r}tryConvertGrpcEnum(){if(this.schema.$typeName==="google.protobuf.EnumDescriptorProto"){let r=new lQo({context:this.context,breadcrumbs:[...this.breadcrumbs,this.schema.name],enum:this.schema,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null)return{convertedSchema:{typeDeclaration:this.createTypeDeclaration({shape:r.type,referencedTypes:new Set,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),availability:fGt(this.schema.options)}),audiences:this.audiences,propertiesByAudience:{}},inlinedTypes:{}}}}tryConvertGrpcMessage(){if(this.schema.$typeName==="google.protobuf.DescriptorProto"){let r=new _Qo({context:this.context,breadcrumbs:[...this.breadcrumbs,this.schema.name],message:this.schema,sourceCodeInfoPath:this.sourceCodeInfoPath}).convert();if(r!=null)return{convertedSchema:r.convertedSchema,inlinedTypes:r.inlinedTypes}}}createTypeDeclaration({shape:t,referencedTypes:r,docs:i,availability:n}){return{name:this.convertDeclaredTypeName(),shape:t,autogeneratedExamples:[],userProvidedExamples:[],encoding:void 0,availability:n,docs:i,referencedTypes:r,source:void 0,inline:void 0,v2Examples:void 0}}convertDeclaredTypeName(){let t=this.context.maybePrependPackageName(this.schema.name);return{typeId:t,fernFilepath:this.context.createFernFilepath(),name:this.context.casingsGenerator.generateName(t),displayName:this.schema.name}}};var pQn=class extends SB{comments;codeGeneratorRequest;constructor({comments:t,codeGeneratorRequest:r,...i}){super(i),this.comments=t,this.codeGeneratorRequest=r}resolveTypeIdToProtoFile(t){if(t.startsWith(this.spec.package)){for(let r of this.spec.messageType)if(`${this.spec.package}.${r.name}`===this.maybeRemoveLeadingPeriod(t))return{ok:!0,message:r,protoFileName:this.spec.name}}for(let r of this.codeGeneratorRequest.protoFile.filter(i=>i.name!==this.spec.name))if(t.startsWith(r.package)){for(let i of r.messageType)if(`${r.package}.${i.name}`===this.maybeRemoveLeadingPeriod(t))return{ok:!0,message:i,protoFileName:r.name}}return{ok:!1}}getCodeGeneratorRequest(){return this.codeGeneratorRequest}maybePrependPackageName(t){return this.maybeRemoveLeadingPeriod(t).startsWith(this.spec.package)?t:this.spec.package+"."+t}convertReferenceToTypeReference({reference:t}){return{ok:!1}}convertGrpcReferenceToTypeReference({typeName:t,displayNameOverride:r}){return{ok:!0,reference:ni.named({fernFilepath:{allParts:[],packagePath:[],file:void 0},name:this.casingsGenerator.generateName(this.maybeRemoveLeadingPeriod(t)),typeId:this.maybeRemoveLeadingPeriod(t),default:void 0,inline:!1,displayName:r})}}maybeRemoveLeadingPeriod(t){return t.startsWith(".")?t.slice(1):t}maybeRemoveGrpcPackagePrefix(t){let r=t.split(".").filter(n=>n!==""),i=this.spec.package.split(".").filter(n=>n!=="");for(;r.length>0&&i.length>0;){if(r[0]!==i[0])return t;r.shift(),i.shift()}return r.length===0?t:r.join(".")}updateTypeId(t,r){return{...t,typeDeclaration:{...t.typeDeclaration,name:{...t.typeDeclaration.name,typeId:r}}}}getCommentForPath(t){if(!t||t.length===0)return;let r=t[0];if(!(r in this.comments))return;let i=this.comments[r];for(let n=1;n<t.length;n++){let a=t[n];if(a===void 0||!i)return;i=i[a]}return i?._comment}};function zac(){return{4:{},5:{},6:{}}}function wc_(e){let t=zac();return e.package?.startsWith("google.protobuf")||e.sourceCodeInfo?.location.forEach(r=>{let i=r.path;if(!i||i.length===0)return;let n=i[0];if(!(n in t))return;let a=r.leadingComments||r.trailingComments||"";if(!a)return;let o=t[n];for(let c=1;c<i.length;c++){let f=i[c];f!=null&&(f in o||(o[f]={}),o=o[f])}o._comment=a.trim()}),t}var vPa=class e extends Ra{MAX_DEPTH=12;EXAMPLE_STRING="example";EXAMPLE_NUMBER=42;EXAMPLE_BOOL=!0;EXAMPLE_BYTES="bytes";message;type;depth;seenMessages;constructor({breadcrumbs:t,context:r,message:i,type:n,depth:a=0,seenMessages:o=new Set}){super({context:r,breadcrumbs:t}),this.message=i,this.type=n,this.depth=a,this.seenMessages=o}convert(){if(this.depth>this.MAX_DEPTH)return{isValid:!0,coerced:!1,validExample:{},errors:[]};let t=this.getFullyQualifiedMessageName(this.message);if(this.seenMessages.has(t))return{isValid:!0,coerced:!1,validExample:{},errors:[]};let r=new Set(this.seenMessages);r.add(t);try{return this.convertMessage(r)}catch(i){return{isValid:!1,coerced:!1,validExample:{},errors:[`Failed to convert message ${t}: ${i}`]}}}getFullyQualifiedMessageName(t){let r=this.context.spec.package||"",i=t.name||"";return r?`${r}.${i}`:i}convertMessage(t){let r=new Map,i=new Map,n=new Map;this.message.oneofDecl&&this.message.oneofDecl.forEach((u,l)=>{u.name&&n.set(l,u.name)});for(let u of this.message.field)Object.hasOwn(u,"oneofIndex")&&u.oneofIndex!=null&&(i.has(u.oneofIndex)||i.set(u.oneofIndex,u));for(let u of this.message.field){let l=u.name??"";if(!(!l||Object.hasOwn(u,"oneofIndex")&&u.oneofIndex!=null&&i.get(u.oneofIndex)!==u))try{let _=this.convertField({field:u,seenMessages:t,fieldName:l});r.set(l,{field:u,result:_})}catch(_){r.set(l,{field:u,result:{isValid:!1,coerced:!1,validExample:null,errors:[`Error converting field ${l}: ${_}`]}})}}let a=Array.from(r.values()),o=a.every(({result:u})=>u.isValid),c=a.flatMap(({result:u})=>u.errors),f={},s=new Map;for(let[u,{field:l,result:p}]of r.entries()){if(!p.isValid||p.validExample===null||p.validExample===void 0)continue;if(Object.hasOwn(l,"oneofIndex")&&l.oneofIndex!=null&&n.has(l.oneofIndex)){let h=n.get(l.oneofIndex)??void 0;h!=null&&s.set(h,{fieldName:u,value:p.validExample})}else f[u]=p.validExample}for(let[u,{fieldName:l,value:p}]of s.entries())f[u]={[l]:p};return{isValid:o,coerced:!1,validExample:f,errors:c}}convertField({field:t,seenMessages:r,fieldName:i}){return t.label===hMn.REPEATED?this.convertRepeatedField({field:t,seenMessages:r,fieldName:i}):this.convertSingleField({field:t,seenMessages:r,fieldName:i})}convertRepeatedField({field:t,seenMessages:r,fieldName:i}){let n=this.convertSingleField({field:t,seenMessages:r,fieldName:i});return{isValid:n.isValid,coerced:!1,validExample:n.isValid?[n.validExample]:[],errors:n.errors}}convertSingleField({field:t,seenMessages:r,fieldName:i}){switch(t.type){case vf.DOUBLE:case vf.FLOAT:case vf.INT64:case vf.UINT64:case vf.INT32:case vf.FIXED64:case vf.FIXED32:case vf.UINT32:case vf.SFIXED32:case vf.SFIXED64:case vf.SINT32:case vf.SINT64:return this.convertNumber();case vf.BOOL:return this.convertBoolean();case vf.STRING:return this.convertString(this.EXAMPLE_STRING);case vf.BYTES:return this.convertBytes();case vf.ENUM:return this.convertEnum(t);case vf.MESSAGE:return this.convertMessage_Field(t,r,i);default:return{isValid:!1,coerced:!1,validExample:null,errors:[`Unsupported field type: ${t.type}`]}}}convertNumber(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_NUMBER,errors:[]}}convertBoolean(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_BOOL,errors:[]}}convertString(t){return{isValid:!0,coerced:!1,validExample:t,errors:[]}}convertBytes(){return{isValid:!0,coerced:!1,validExample:this.EXAMPLE_BYTES,errors:[]}}convertEnum(t){let r=t.typeName??"",i=this.context.maybeRemoveLeadingPeriod(r),n=this.findEnumType(i);return n?n.value.length===0?{isValid:!0,coerced:!1,validExample:0,errors:[]}:{isValid:!0,coerced:!1,validExample:n.value[0]?.number??0,errors:[]}:{isValid:!1,coerced:!1,validExample:0,errors:[`Enum type ${t.typeName} not found`]}}convertMessage_Field(t,r,i){let n=t.typeName;if(!n)return{isValid:!1,coerced:!1,validExample:null,errors:[`Missing type name for message field ${i}`]};let a=this.context.maybeRemoveLeadingPeriod(n),o,c;if(this.context.getCodeGeneratorRequest())for(let s of this.context.getCodeGeneratorRequest().protoFile){let u=this.context.resolveTypeIdToProtoFile(a);if(u.ok){o=u.message,u.protoFileName!==this.context.spec.name?c=new pQn({...this.context,comments:zac(),codeGeneratorRequest:this.context.getCodeGeneratorRequest(),spec:s,logger:new dQn}):c=this.context;break}}return!o||!c?{isValid:!0,coerced:!1,validExample:null,errors:[`Could not find message type ${a}`]}:new e({context:c,breadcrumbs:[...this.breadcrumbs,i],message:o,type:this.type,depth:this.depth+1,seenMessages:r}).convert()}findEnumType(t){let r=this.findEnumInFile(t,this.context.spec);if(!r&&this.context.getCodeGeneratorRequest()){for(let i of this.context.getCodeGeneratorRequest().protoFile)if(r=this.findEnumInFile(t,i),r!=null)break}return r}findEnumInFile(t,r){let i=r.package||"";for(let n of r.enumType)if((i?`${i}.${n.name}`:n.name||"")===t||n.name===t)return n;for(let n of r.messageType){let a=this.findEnumInMessage(t,n,i);if(a!=null)return a}}findEnumInMessage(t,r,i){let n=i?`${i}.${r.name}`:r.name||"";for(let a of r.enumType)if(`${n}.${a.name}`===t||a.name===t)return a;for(let a of r.nestedType){let o=this.findEnumInMessage(t,a,n);if(o!=null)return o}}};var hQo=class extends Ra{operation;serviceName;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,operation:i,serviceName:n,sourceCodeInfoPath:a}){super({context:t,breadcrumbs:r}),this.operation=i,this.serviceName=n,this.sourceCodeInfoPath=a}convert(){let t=this.context.spec.package,r=this.convertRequestBody(),i=this.convertResponseBody();return{group:[t,this.serviceName],endpoint:{id:this.operation.name,docs:this.context.getCommentForPath(this.sourceCodeInfoPath),name:this.context.casingsGenerator.generateName(this.context.maybePrependPackageName(this.operation.name)),requestBody:r?.requestBody,v2RequestBodies:void 0,response:i?.responseBody,v2Responses:void 0,displayName:this.context.maybeRemoveGrpcPackagePrefix(this.operation.name),method:JP.Post,baseUrl:void 0,v2BaseUrls:void 0,v2Examples:{autogeneratedExamples:{},userSpecifiedExamples:{}},path:{head:this.operation.name,parts:[]},pathParameters:[],queryParameters:[],headers:[],sdkRequest:void 0,errors:[],auth:!1,security:void 0,availability:void 0,userSpecifiedExamples:[],autogeneratedExamples:[],idempotent:!1,basePath:void 0,fullPath:{head:this.operation.name,parts:[]},allPathParameters:[],pagination:void 0,transport:void 0,source:qL.proto({methodType:this.getGrpcMethodType()}),audiences:[],retries:void 0,apiPlayground:void 0}}}getGrpcMethodType(){return this.operation.clientStreaming&&this.operation.serverStreaming?nFt.BidirectionalStream:this.operation.clientStreaming?nFt.ClientStream:this.operation.serverStreaming?nFt.ServerStream:nFt.Unary}convertRequestBody(){let t=this.context.convertGrpcReferenceToTypeReference({typeName:this.operation.inputType,displayNameOverride:this.context.maybeRemoveGrpcPackagePrefix(this.operation.inputType)});return t.ok?{requestBody:VO.reference({contentType:"application/proto",docs:void 0,requestBodyType:t.reference,v2Examples:void 0}),requestExample:void 0}:{requestBody:void 0,requestExample:void 0}}convertResponseBody(){let t=this.context.convertGrpcReferenceToTypeReference({typeName:this.operation.outputType,displayNameOverride:this.context.maybeRemoveGrpcPackagePrefix(this.operation.outputType)});return t.ok?{responseBody:{body:ly.json(nz.response({responseBodyType:t.reference,docs:void 0,v2Examples:void 0})),statusCode:void 0,isWildcardStatusCode:void 0},responseExample:void 0}:{responseBody:void 0,responseExample:void 0}}};var yQo=class extends Ra{service;sourceCodeInfoPath;constructor({context:t,breadcrumbs:r,service:i,sourceCodeInfoPath:n}){super({context:t,breadcrumbs:r}),this.service=i,this.sourceCodeInfoPath=n}convert(){let t=[];for(let[r,i]of this.service.method.entries()){let a=new hQo({context:this.context,breadcrumbs:this.breadcrumbs,operation:i,serviceName:this.service.name,sourceCodeInfoPath:[...this.sourceCodeInfoPath,fFt.SERVICE.METHOD,r]}).convert();a!=null&&t.push(a)}return{endpoints:t,serviceName:this.context.maybePrependPackageName(this.service.name),serviceDisplayName:this.service.name,inlinedTypes:{}}}};function Ec_(){return{displayName:void 0,request:{endpoint:{method:J9t.Post,path:""},baseUrl:void 0,environment:void 0,auth:void 0,headers:void 0,docs:void 0,pathParameters:void 0,queryParameters:void 0,requestBody:void 0},response:{statusCode:200,body:br.V2HttpEndpointResponseBody.json({}),docs:void 0},codeSamples:[]}}var bQo=class extends lFt{constructor({breadcrumbs:t,context:r,audiences:i}){super({breadcrumbs:t,context:r,audiences:i})}convert(){return this.convertOptions(),this.convertEnumsAndMessages(),this.convertServices(),this.generateExamplesForServices(),this.finalizeIr()}convertOptions(){}convertEnumsAndMessages(){for(let[t,r]of this.context.spec.enumType.entries()){let n=new BCi({context:this.context,breadcrumbs:[...this.breadcrumbs,this.context.spec.package],schema:r,sourceCodeInfoPath:[cQo.ENUM,t],schemaIndex:t}).convert();n!=null&&this.addTypesToIr({...Sc_(n.inlinedTypes,this.context.maybePrependPackageName.bind(this.context)),[this.context.maybePrependPackageName(r.name)]:n.convertedSchema})}for(let[t,r]of this.context.spec.messageType.entries()){let n=new BCi({context:this.context,breadcrumbs:[...this.breadcrumbs,this.context.spec.package],schema:r,sourceCodeInfoPath:[cQo.MESSAGE,t],schemaIndex:t}).convert();n!=null&&this.addTypesToIr({...Sc_(n.inlinedTypes,this.context.maybePrependPackageName.bind(this.context)),[this.context.maybePrependPackageName(r.name)]:n.convertedSchema})}}convertServices(){for(let[t,r]of this.context.spec.service.entries()){let n=new yQo({context:this.context,breadcrumbs:this.breadcrumbs,service:r,sourceCodeInfoPath:[cQo.SERVICE,t]}).convert();if(n!=null)for(let a of n.endpoints)this.addEndpointToIr({endpointGroup:a.group,endpoint:a.endpoint,audiences:[],serviceName:n.serviceName,endpointGroupDisplayName:n.serviceDisplayName})}}generateExamplesForServices(){for(let[t,r]of Object.entries(this.ir.services))for(let[i,n]of Object.entries(r.endpoints)){let a=Ec_(),o=this.constructRequestBodyExample(n),c=this.constructResponseBodyExample(n);o!=null&&a.request!=null&&(a.request.requestBody=o),c!=null&&a.response!=null&&(a.response.body=CC.json(c)),n.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{[i]:a}}}}constructRequestBodyExample(t){let r=t.requestBody.requestBodyType.typeId,i=this.context.resolveTypeIdToProtoFile(r);if(i.ok)return new vPa({context:this.context,breadcrumbs:this.breadcrumbs,message:i.message,type:"request"}).convert().validExample}constructResponseBodyExample(t){let r=(t.response?.body).value.responseBodyType.typeId,i=this.context.resolveTypeIdToProtoFile(r);if(i.ok)return new vPa({context:this.context,breadcrumbs:this.breadcrumbs,message:i.message,type:"response"}).convert().validExample}addEndpointToIr({endpoint:t,audiences:r,endpointGroup:i,endpointGroupDisplayName:n,serviceName:a}){let o=this.context.getGroup({groupParts:i,namespace:this.context.namespace}),c=this.getOrCreatePackage({group:i}),f=[...o].map(l=>this.context.casingsGenerator.generateName(l)),s=f[f.length-1];c.service==null&&(c.service=a??`service_${o.map(l=>No(l)).join("/")}`),this.ir.services[c.service]==null&&(this.ir.services[c.service]=this.createNewService({allParts:f,finalpart:s,endpointGroupDisplayName:n})),this.ir.services[c.service]?.endpoints.push(t);let u=this.ir.services[c.service];u!=null&&(this.irGraph.addEndpoint(u,t),this.irGraph.markEndpointForAudience(u.name,[t],r))}getOrCreatePackage({group:t}){let r=[];if(this.context.namespace!=null&&r.push(this.context.namespace),r.push(...t??[]),r.length==0)return this.ir.rootPackage;let i=this.ir.rootPackage;for(let n=0;n<r.length;n++){let a=r[n]??"",c=`subpackage_${r.slice(0,n+1).join("/")}`;this.ir.subpackages[c]==null&&(this.ir.subpackages[c]={name:this.context.casingsGenerator.generateName(a),displayName:a,...this.createPackage({name:a})});let f=this.ir.subpackages[c];i.subpackages.includes(c)||i.subpackages.push(c),i=f}return i}finalizeIr(){return{...this.ir,apiName:this.context.casingsGenerator.generateName(this.ir.apiDisplayName??""),constants:{errorInstanceIdKey:this.context.casingsGenerator.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})},audiences:this.audiences.type==="select"?this.audiences.audiences:void 0}}};function Sc_(e,t){return Object.fromEntries(Object.entries(e).map(([r,i])=>[t(r),i]))}function Mc_({req:e,options:t}){let r,i=_x({generationLanguage:void 0,keywords:void 0,smartCasing:!1});for(let a of e.protoFile){let c=new bQo({context:new pQn({codeGeneratorRequest:e,spec:a,settings:{},errorCollector:new SCi({logger:{log:(f,...s)=>{}},relativeFilepathToSpec:void 0}),logger:new dQn,generationLanguage:void 0,smartCasing:!1,exampleGenerationArgs:{disabled:!0},enableUniqueErrorsPerEndpoint:!1,generateV1Examples:!1,comments:wc_(a)}),breadcrumbs:[],audiences:{type:"all"}}).convert();c!=null&&(r=r===void 0?c:XKi(r,c,i))}let n=zn.IntermediateRepresentation.json(r,{allowUnrecognizedEnumValues:!0,skipValidation:!0});return n.ok?{name:"ir.json",content:JSON.stringify(n.value,null,2)}:{name:"ir.json",content:JSON.stringify(n.errors,null,2)}}function Dc_(e){return{}}var Nac=kYS({name:"protoc-gen-fern",version:`v${String(Qo_)}`,run:Mc_});function kYS({name:e,version:t,run:r}){return{name:e,version:t,run(i){let n=Dc_(i.parameter),a=r({req:i,options:n});return eXS([a],O0d,A0d)}}}function eXS(e,t,r){return Ufa(lro,{supportedFeatures:F0.parse(Kfa.PROTO3_OPTIONAL|Kfa.SUPPORTS_EDITIONS),minimumEdition:t,maximumEdition:r,file:e})}var Cc_=ae(require("net"),1),qc_=ae(require("os"),1),vQo=class extends Error{constructor(t){super(`${t} is locked`)}},_Qn={old:new Set,young:new Set},tXS=1e3*15;var gPa,rXS=()=>{let e=qc_.default.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let i of r)t.add(i.address);return t},Bc_=e=>new Promise((t,r)=>{let i=Cc_.default.createServer();i.unref(),i.on("error",r),i.listen(e,()=>{let{port:n}=i.address();i.close(()=>{t(n)})})}),Ic_=async(e,t)=>{if(e.host||e.port===0)return Bc_(e);for(let r of t)try{await Bc_({port:e.port,host:r})}catch(i){if(!["EADDRNOTAVAIL","EINVAL"].includes(i.code))throw i}return e.port},iXS=function*(e){e&&(yield*e),yield 0};async function hQn(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let a of n){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}gPa===void 0&&(gPa=setTimeout(()=>{gPa=void 0,_Qn.old=_Qn.young,_Qn.young=new Set},tXS),gPa.unref&&gPa.unref());let i=rXS();for(let n of iXS(t))try{if(r.has(n))continue;let a=await Ic_({...e,port:n},i);for(;_Qn.old.has(a)||_Qn.young.has(a);){if(n!==0)throw new vQo(n);a=await Ic_({...e,port:n},i)}return _Qn.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof vQo))throw a}throw new Error("No available ports found")}hl_();var jf_=ae(Pf_(),1),{applyExtends:_ZS,cjsPlatformShim:hZS,Parser:yZS,processArgv:bZS,Yargs:VQo}=jf_.default;VQo.applyExtends=(e,t,r)=>_ZS(e,t,r,hZS);VQo.hideBin=bZS.hideBin;VQo.Parser=yZS;var wf_=VQo;var Ef_=require("fs/promises");var Sf_=require("path"),Mf_=ae(BW(),1);async function Df_({url:e,logger:t}){try{let r=await vZS({url:e,logger:t}),i=await Mf_.default.dir(),n=(0,Sf_.join)(i.path,e.endsWith(".json")?"openapi.json":"openapi.yaml");return t.debug("tmpDir",i.path),t.debug("filePath",n),await(0,Ef_.writeFile)(n,r),{status:"success",filePath:n}}catch(r){return t.debug(`Encountered an error while loading OpenAPI spec: ${JSON.stringify(r)}`),{status:"failure",errorMessage:`Failed to load OpenAPI spec from ${e}`}}}async function vZS({url:e,logger:t}){let r=await hB.get(e),i=r.headers["content-type"]??"";return i.includes("json")||e.endsWith(".json")?typeof r.data=="string"?r.data:JSON.stringify(r.data,null,2):i.includes("yaml")||e.endsWith(".yml")||e.endsWith(".yaml")?typeof r.data=="string"?r.data:M9i(r.data):(t.warn(`Unrecognized Content-Type "${i}" from endpoint ${e}. Please ensure you're pointing to a URL that returns JSON or YAML and not HTML (e.g. Swagger UI webpage)`),M9i(r.data))}var IPa=ae(P_e(),1);function qoc(e,t){if(e=IPa.default.parse(e),t=IPa.default.parse(t),!(IPa.default.compareBuild(e,t)>=0))return IPa.default.diff(e,t)||"build"}var gZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9])+$/,OZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-rc[.-]?([0-9]+)-([0-9]+)-([a-z0-9])+$/,AZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-rc[.-]?([0-9]+)$/,mZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)$/,PZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-alpha[.-]?([0-9]+)$/,jZS=/^([0-9]+)\.([0-9]+)\.([0-9]+)-beta[.-]?([0-9]+)$/;function fJi(e){let t=e.match(PZS);if(t!=null){let[c,f,s,u,l]=t,p=kE(f),_=kE(s),h=kE(u),y=kE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse alpha version: "+e);return{type:"alpha",major:p,minor:_,patch:h,index:y}}let r=e.match(jZS);if(r!=null){let[c,f,s,u,l]=r,p=kE(f),_=kE(s),h=kE(u),y=kE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse beta version: "+e);return{type:"beta",major:p,minor:_,patch:h,index:y}}let i=e.match(gZS);if(i!=null){let[c,f,s,u,l]=i,p=kE(f),_=kE(s),h=kE(u),y=kE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse post-release commit version: "+e);return{type:"post-release-commit",major:p,minor:_,patch:h,commitIndex:y}}let n=e.match(AZS);if(n!=null){let[c,f,s,u,l]=n,p=kE(f),_=kE(s),h=kE(u),y=kE(l);if(p==null||_==null||h==null||y==null)throw new Error("Cannot parse RC version: "+e);return{type:"rc",major:p,minor:_,patch:h,releaseCandidateIndex:y}}let a=e.match(OZS);if(a!=null){let[c,f,s,u,l,p]=a,_=kE(f),h=kE(s),y=kE(u),b=kE(l),v=kE(p);if(_==null||h==null||y==null||b==null||v==null)throw new Error("Cannot parse post-RC version: "+e);return{type:"post-rc-commit",major:_,minor:h,patch:y,releaseCandidateIndex:b,commitIndex:v}}let o=e.match(mZS);if(o!=null){let[c,f,s,u]=o,l=kE(f),p=kE(s),_=kE(u);if(l==null||p==null||_==null)throw new Error("Cannot parse release version: "+e);return{type:"release",major:l,minor:p,patch:_}}throw new Error("Failed to parse version: "+e)}function kE(e){if(e==null||e.length===0)return;let t=Number(e);if(!isNaN(t))return t}function tK(e,t){if(e===t)return!1;let r=fJi(e),i=fJi(t);if(r.major!==i.major||r.minor!==i.minor||r.patch!==i.patch)return qoc(Bf_(r),Bf_(i))==null;if(r.type==="post-release-commit")return i.type!=="post-release-commit"||r.commitIndex>i.commitIndex;if(r.type==="release")return i.type!=="post-release-commit";if(r.type==="rc"){switch(i.type){case"release":case"post-release-commit":return!1;case"alpha":case"beta":return!0}return r.releaseCandidateIndex!==i.releaseCandidateIndex&&r.releaseCandidateIndex>i.releaseCandidateIndex}if(r.type==="post-rc-commit"){switch(i.type){case"release":case"post-release-commit":return!1;case"alpha":case"beta":return!0}if(i.type==="post-rc-commit")return r.releaseCandidateIndex!==i.releaseCandidateIndex?r.releaseCandidateIndex>i.releaseCandidateIndex:r.commitIndex>i.commitIndex}if(r.type==="beta"){switch(i.type){case"release":case"post-release-commit":case"rc":case"post-rc-commit":return!1;case"alpha":return!0}return r.index>i.index}if(r.type==="alpha"){switch(i.type){case"release":case"post-release-commit":case"rc":case"post-rc-commit":return!1}return r.index>i.index}return!tK(t,e)}function Bf_(e){return`${e.major}.${e.minor}.${e.patch}`}var HQ=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",rK=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n",Toc=e=>e.name==="space",dJi=e=>e.name==="backspace",Hvi=e=>e.name==="tab",CPa=e=>"1234567890".includes(e.name),BB=e=>e.name==="enter"||e.name==="return";var WQo=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(t){super(),this.cause=t?.cause}},xQo=class extends Error{name="CancelPromptError";message="Prompt was canceled"},qPa=class extends Error{name="ExitPromptError"},GQo=class extends Error{name="HookError"},_Gt=class extends Error{name="ValidationError"};var Tf_=require("async_hooks");var HQo=require("async_hooks");var If_=new HQo.AsyncLocalStorage;function wZS(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Cf_(e,t){let r=wZS(e);return If_.run(r,()=>{function i(n){r.handleChange=()=>{r.index=0,n()},r.handleChange()}return t(i)})}function pJi(){let e=If_.getStore();if(!e)throw new GQo("[Inquirer] Hook functions can only be called from within a prompt");return e}function Roc(){return pJi().rl}function zoc(e){let t=(...r)=>{let i=pJi(),n=!1,a=i.handleChange;i.handleChange=()=>{n=!0};let o=e(...r);return n&&a(),i.handleChange=a,o};return HQo.AsyncResource.bind(t)}function jQn(e){let t=pJi(),{index:r}=t,i={get(){return t.hooks[r]},set(a){t.hooks[r]=a},initialized:r in t.hooks},n=e(i);return t.index++,n}function qf_(){pJi().handleChange()}var _Ji={queue(e){let t=pJi(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let i=e(Roc());if(i!=null&&typeof i!="function")throw new _Gt("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=i})},run(){let e=pJi();zoc(()=>{e.hooksEffect.forEach(t=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=pJi();e.hooksCleanup.forEach(t=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function Ll(e){return jQn(t=>{let r=Tf_.AsyncResource.bind(function(a){t.get()!==a&&(t.set(a),qf_())});if(t.initialized)return[t.get(),r];let i=typeof e=="function"?e():e;return t.set(i),[i,r]})}function Dhe(e,t){jQn(r=>{let i=r.get();(!Array.isArray(i)||t.some((a,o)=>!Object.is(a,i[o])))&&_Ji.queue(e),r.set(t)})}var x0e=ae(v1(),1);var Rf_={prefix:{idle:x0e.default.blue("?"),done:x0e.default.green(bC.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(e=>x0e.default.yellow(e))},style:{answer:x0e.default.cyan,message:x0e.default.bold,error:e=>x0e.default.red(`> ${e}`),defaultAnswer:e=>x0e.default.dim(`(${e})`),help:x0e.default.dim,highlight:x0e.default.cyan,key:e=>x0e.default.cyan(x0e.default.bold(`<${e}>`))}};function zf_(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Nf_(...e){let t={};for(let r of e)for(let[i,n]of Object.entries(r)){let a=t[i];t[i]=zf_(a)&&zf_(n)?Nf_(a,n):n}return t}function JS(...e){let t=[Rf_,...e.filter(r=>r!=null)];return Nf_(...t)}function IB({status:e="idle",theme:t}){let[r,i]=Ll(!1),[n,a]=Ll(0),{prefix:o,spinner:c}=JS(t);return Dhe(()=>{if(e==="loading"){let s,u=-1,l=setTimeout(()=>{i(!0),s=setInterval(()=>{u=u+1,a(u%c.frames.length)},c.interval)},300);return()=>{clearTimeout(l),clearInterval(s)}}else i(!1)},[e]),r?c.frames[n]:typeof o=="string"?o:o[e==="loading"?"idle":e]??o.idle}function iK(e,t){return jQn(r=>{let i=r.get();if(!i||i.dependencies.length!==t.length||i.dependencies.some((n,a)=>n!==t[a])){let n=e();return r.set({value:n,dependencies:t}),n}return i.value})}function G0e(e){return Ll({current:e})[0]}function CB(e){let t=G0e(e);t.current=e,Dhe(r=>{let i=!1,n=zoc((a,o)=>{i||t.current(o,r)});return r.input.on("keypress",n),()=>{i=!0,r.input.removeListener("keypress",n)}},[])}var Ff_=ae(Txs(),1),Qf_=ae(Vxs(),1);function TPa(e,t){return e.split(`
1360
1360
  `).flatMap(r=>(0,Qf_.default)(r,t,{trim:!1,hard:!0}).split(`
1361
1361
  `).map(i=>i.trimEnd())).join(`
@@ -1397,7 +1397,7 @@ ${g}${O}${m}${wQn}`});function kQo({message:e,error:t,logger:r,logLevel:i=$s.Err
1397
1397
  Run ${Ut.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1398
1398
  Run ${Ut.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),WBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function duc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!Pd_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)n+=`
1399
1399
  ${await y2S(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Ut.dim(c.currentVersion)+Ut.reset(" \u2192 ")+Ut.green(c.latestVersion);return n+=`
1400
- `,i?WBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function y2S(e){let r=await new md_.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 b2S({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=UMi(u.name,l),_=await hNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=UMi(s.name,u),p=await hNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await X_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function Ed_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=tK(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function iUo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await b2S({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...Ed_(s,f,t.logger));else o.push(...Ed_(c.versions,void 0,t.logger))}return o}var VPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${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=i}};var DQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var puc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),Sd_=typeof globalThis.AbortController=="function",Md_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Dd_=typeof globalThis.ReadableStream=="function",Bd_=typeof globalThis.FormData=="function",nUo=["get","post","put","patch","head","delete"],v2S=()=>{};v2S();var Id_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},aUo=2147483647,Cd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oUo=Symbol("stop"),qd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Td_={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 g2S=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Cd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.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},Rd_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},zd_=(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(Rd_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Nd_=(e,t,r)=>{if(!e.body)return e;let i=g2S(r??e.body);return new Request(e,{duplex:"half",body:Rd_(e.body,i,t)})};var BQn=e=>e!==null&&typeof e=="object";var WPa=(...e)=>{for(let t of e)if((!BQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return yuc({},...e)},_uc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function uUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:yuc(e[r]??[],t[r]??[])}var huc=(e={},t={})=>({beforeRequest:uUo(e,t,"beforeRequest"),beforeRetry:uUo(e,t,"beforeRetry"),afterResponse:uUo(e,t,"afterResponse"),beforeError:uUo(e,t,"beforeError")}),yuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(BQn(n)){for(let[a,o]of Object.entries(n))BQn(o)&&a in t&&(o=yuc(t[a],o)),t={...t,[a]:o};BQn(n.hooks)&&(i=huc(i,n.hooks),t.hooks=i),BQn(n.headers)&&(r=_uc(r,n.headers),t.headers=r)}return t};var Qd_=e=>nUo.includes(e)?e.toUpperCase():e,O2S=["get","put","head","delete","options","trace"],A2S=[408,413,429,500,502,503,504],m2S=[413,429,503],Fd_={limit:2,methods:O2S,statusCodes:A2S,afterStatusCodes:m2S,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Ud_=(e={})=>{if(typeof e=="number")return{...Fd_,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{...Fd_,...e}};async function buc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new DQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function vuc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Ld_=(e,t)=>{let r={};for(let i in t)!(i in Td_)&&!(i in qd_)&&!(i in e)&&(r[i]=t[i]);return r},Vd_=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 xPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>aUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${aUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new VPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Dd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return zd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(Id_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:_uc(this._input.headers,r.headers),hooks:huc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Qd_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Ud_(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(Sd_&&Md_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(puc&&(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),Vd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(Bd_&&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(!puc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Nd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof DQn)throw t;if(t instanceof VPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),aUo);if(this._retryCount<1)throw r;await vuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Ld_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):buc(this._originalRequest,t,this.abortController,this._options)}};var guc=e=>{let t=(r,i)=>xPa.create(r,WPa(e,i));for(let r of nUo)t[r]=(i,n)=>xPa.create(i,WPa(e,n,{method:r}));return t.create=r=>guc(WPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),guc(WPa(e,r))),t.stop=oUo,t},P2S=guc(),Wd_=P2S;var dp_=ae(fp_(),1);function juc(e){let t=(0,dp_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var o__=ae(a__(),1),u__=ae(P_e(),1),Nuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Fuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Quc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??juc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,o__.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await Wd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Nuc(e):l}if(t.allVersions)return s;let u=new Fuc(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(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=u__.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function YPa(e,t){let{version:r}=await Quc(e.toLowerCase(),t);return r}async function zCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:YPa(e.packageName,{version:t?"prerelease":"latest"})}var s__=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new rUo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.0.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new RE}failWithoutThrowing(t,r){this.didSucceed=!1,kQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await wTn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await jd_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1400
+ `,i?WBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function y2S(e){let r=await new md_.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 b2S({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=UMi(u.name,l),_=await hNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=UMi(s.name,u),p=await hNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function wd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await X_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function Ed_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=tK(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function iUo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await b2S({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...Ed_(s,f,t.logger));else o.push(...Ed_(c.versions,void 0,t.logger))}return o}var VPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${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=i}};var DQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var puc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)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(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),Sd_=typeof globalThis.AbortController=="function",Md_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Dd_=typeof globalThis.ReadableStream=="function",Bd_=typeof globalThis.FormData=="function",nUo=["get","post","put","patch","head","delete"],v2S=()=>{};v2S();var Id_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},aUo=2147483647,Cd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oUo=Symbol("stop"),qd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Td_={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 g2S=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Cd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.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},Rd_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},zd_=(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(Rd_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Nd_=(e,t,r)=>{if(!e.body)return e;let i=g2S(r??e.body);return new Request(e,{duplex:"half",body:Rd_(e.body,i,t)})};var BQn=e=>e!==null&&typeof e=="object";var WPa=(...e)=>{for(let t of e)if((!BQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return yuc({},...e)},_uc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function uUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:yuc(e[r]??[],t[r]??[])}var huc=(e={},t={})=>({beforeRequest:uUo(e,t,"beforeRequest"),beforeRetry:uUo(e,t,"beforeRetry"),afterResponse:uUo(e,t,"afterResponse"),beforeError:uUo(e,t,"beforeError")}),yuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(BQn(n)){for(let[a,o]of Object.entries(n))BQn(o)&&a in t&&(o=yuc(t[a],o)),t={...t,[a]:o};BQn(n.hooks)&&(i=huc(i,n.hooks),t.hooks=i),BQn(n.headers)&&(r=_uc(r,n.headers),t.headers=r)}return t};var Qd_=e=>nUo.includes(e)?e.toUpperCase():e,O2S=["get","put","head","delete","options","trace"],A2S=[408,413,429,500,502,503,504],m2S=[413,429,503],Fd_={limit:2,methods:O2S,statusCodes:A2S,afterStatusCodes:m2S,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Ud_=(e={})=>{if(typeof e=="number")return{...Fd_,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{...Fd_,...e}};async function buc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new DQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function vuc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Ld_=(e,t)=>{let r={};for(let i in t)!(i in Td_)&&!(i in qd_)&&!(i in e)&&(r[i]=t[i]);return r},Vd_=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 xPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>aUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${aUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new VPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Dd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return zd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(Id_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:_uc(this._input.headers,r.headers),hooks:huc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Qd_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Ud_(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(Sd_&&Md_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(puc&&(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),Vd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(Bd_&&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(!puc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Nd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof DQn)throw t;if(t instanceof VPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=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(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n: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 i=Math.min(this._calculateRetryDelay(r),aUo);if(this._retryCount<1)throw r;await vuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Ld_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):buc(this._originalRequest,t,this.abortController,this._options)}};var guc=e=>{let t=(r,i)=>xPa.create(r,WPa(e,i));for(let r of nUo)t[r]=(i,n)=>xPa.create(i,WPa(e,n,{method:r}));return t.create=r=>guc(WPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),guc(WPa(e,r))),t.stop=oUo,t},P2S=guc(),Wd_=P2S;var dp_=ae(fp_(),1);function juc(e){let t=(0,dp_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var o__=ae(a__(),1),u__=ae(P_e(),1),Nuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Fuc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Quc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??juc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,o__.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await Wd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Nuc(e):l}if(t.allVersions)return s;let u=new Fuc(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(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=u__.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function YPa(e,t){let{version:r}=await Quc(e.toLowerCase(),t);return r}async function zCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:YPa(e.packageName,{version:t?"prerelease":"latest"})}var s__=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new rUo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.0.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new RE}failWithoutThrowing(t,r){this.didSucceed=!1,kQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await wTn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await jd_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1401
1401
  `)||(r+=`
1402
1402
  `),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=Ews(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.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 zPa(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 i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new RE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await wTn()).sendEvent(t)}logger=$8t((t,...r)=>this.log(t,...r));stderr=$8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=c__(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?c__(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=s__[this.numTasks++%s__.length],o=Ut.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===Oj.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 i=t.filter(n=>lMi.indexOf(n.level)>=lMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.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 zCi({cliEnvironment:this.environment,includePreReleases:t}),i=tK(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await iUo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await euc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Ut.yellow("?"),style:{answer:n=>Ut.cyan(n),message:n=>Ut.bold(n),highlight:n=>Ut.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
1403
1403
  Cancelled by user.`),new RE):i}}async getInput(t){return await Yoc({message:t.message,default:t.default})}};function c__(e){return`[${e}]:`}var vFt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function OUo(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>OUo.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function l__(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function f__(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var d__=Function.bind,p__=d__.bind(d__);function ___(e,t,r){let i=p__(f__,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=p__(l__,null).apply(null,a)})}function DkS(){let e=Symbol("Singular"),t={registry:{}},r=OUo.bind(null,t,e);return ___(r,t,e),r}function BkS(){let e={registry:{}},t=OUo.bind(null,e);return ___(t,e),t}var h__={Singular:DkS,Collection:BkS};var IkS="0.0.0-development",CkS=`octokit-endpoint.js/${IkS} ${RR()}`,qkS={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":CkS},mediaType:{format:""}};function TkS(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function RkS(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function v__(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{RkS(t[i])?i in e?r[i]=v__(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function y__(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Luc(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=TkS(r.headers),y__(r),y__(r.headers);let i=v__(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function zkS(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var NkS=/\{[^{}}]+\}/g;function FkS(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function QkS(e){let t=e.match(NkS);return t?t.map(FkS).reduce((r,i)=>r.concat(i),[]):[]}function b__(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function g__(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function FQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function XPa(e,t,r){return t=e==="+"||e==="#"?g__(t):FQn(t),r?FQn(r)+"="+t:t}function NQn(e){return e!=null}function Uuc(e){return e===";"||e==="&"||e==="?"}function UkS(e,t,r,i){var n=e[r],a=[];if(NQn(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(XPa(t,n,Uuc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(NQn).forEach(function(o){a.push(XPa(t,o,Uuc(t)?r:""))}):Object.keys(n).forEach(function(o){NQn(n[o])&&a.push(XPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(NQn).forEach(function(c){o.push(XPa(t,c))}):Object.keys(n).forEach(function(c){NQn(n[c])&&(o.push(FQn(c)),o.push(XPa(t,n[c].toString())))}),Uuc(t)?a.push(FQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?NQn(n)&&a.push(FQn(r)):n===""&&(t==="&"||t==="?")?a.push(FQn(r)+"="):n===""&&a.push("");return a}function LkS(e){return{expand:VkS.bind(null,e)}}function VkS(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",f=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);f.push(UkS(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return g__(a)}),e==="/"?e:e.replace(/\/$/,"")}function O__(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=b__(e,["method","baseUrl","url","headers","request","mediaType"]),o=QkS(r);r=LkS(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=b__(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=zkS(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function WkS(e,t,r){return O__(Luc(e,t,r))}function A__(e,t){let r=Luc(e,t),i=WkS.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:A__.bind(null,r),merge:Luc.bind(null,r),parse:O__})}var m__=A__(null,qkS);var M__=ae(E__(),1);var gFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var xkS="10.0.6",GkS={headers:{"user-agent":`octokit-request.js/${xkS} ${RR()}`}};function HkS(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function S__(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,i=e.request?.parseSuccessResponseBody!==!1,n=HkS(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new gFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new gFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await Vuc(o),new gFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await Vuc(o),new gFt(JkS(u.data),c,{response:u,request:e});return u.data=i?await Vuc(o):o.body,u}async function Vuc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,M__.safeParse)(t);if(KkS(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function KkS(e){return e.type==="application/json"||e.type==="application/scim+json"}function JkS(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function Wuc(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return S__(r.parse(o));let c=(f,s)=>S__(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:Wuc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:Wuc.bind(null,r)})}var xO=Wuc(m__,GkS);var $kS="0.0.0-development";function YkS(e){return`Request failed due to following response errors: