fern-api 4.46.2 → 4.46.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +5 -5
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1465,7 +1465,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
1465
1465
|
`)}var _vt=class extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var rq={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},sms={[rq.Debug]:1,[rq.Info]:2,[rq.Warn]:3,[rq.Error]:4},Svt=class{debug(t,...r){console.debug(t,...r)}info(t,...r){console.info(t,...r)}warn(t,...r){console.warn(t,...r)}error(t,...r){console.error(t,...r)}},fui=class{level;logger;silent;constructor(t){this.level=sms[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=sms[t]}isDebug(){return this.shouldLog(rq.Debug)}debug(t,...r){this.isDebug()&&this.logger.debug(t,...r)}isInfo(){return this.shouldLog(rq.Info)}info(t,...r){this.isInfo()&&this.logger.info(t,...r)}isWarn(){return this.shouldLog(rq.Warn)}warn(t,...r){this.isWarn()&&this.logger.warn(t,...r)}isError(){return this.shouldLog(rq.Error)}error(t,...r){this.isError()&&this.logger.error(t,...r)}};var ClA=new fui({level:rq.Info,logger:new Svt,silent:!0});var dui;(function(e){e.LogLevel=rq,e.ConsoleLogger=Svt})(dui||(dui={}));var rk={};te(rk,{AbsoluteProductPath:()=>Etr,AiChatConfig:()=>Ovt,AiChatDatasource:()=>Itr,AiChatLocation:()=>wtr,AiChatModel:()=>Ctr,AiChatWebsiteDatasource:()=>vtr,AiExamplesConfig:()=>xtr,AnalyticsConfig:()=>Dtr,AnnouncementConfig:()=>uhe,ApiReferenceConfiguration:()=>jtr,ApiReferenceEndpointConfiguration:()=>Mtr,ApiReferenceLayoutItem:()=>g$,ApiReferenceOperationConfiguration:()=>Ltr,ApiReferencePackageConfiguration:()=>Utr,ApiReferencePackageConfigurationWithOptions:()=>Vtr,ApiReferenceSectionConfiguration:()=>ztr,Audience:()=>d$,AudienceId:()=>Pvt,Availability:()=>gx,BackgroundImageConfiguration:()=>Gtr,BackgroundImageThemedConfig:()=>qtr,BodyThemeConfig:()=>Wtr,ChangelogConfiguration:()=>$tr,ChangelogFolderRelativePath:()=>EVe,CheckConfig:()=>Ktr,CheckRuleSeverity:()=>Nse,CheckRulesConfig:()=>Htr,CollapsedStringValue:()=>Rtr,CollapsedValue:()=>m$,ColorConfig:()=>Y0,ColorThemedConfig:()=>Jtr,ColorsConfiguration:()=>Ytr,ContentAlignment:()=>Xtr,CssConfig:()=>Ztr,CustomDomain:()=>err,CustomPageAction:()=>trr,DocsConfiguration:()=>kms,DocsInstance:()=>orr,DocsSettingsConfig:()=>crr,DocsTypographyConfig:()=>frr,EditThisPageConfig:()=>irr,EditThisPageLaunch:()=>rrr,ExperimentalConfig:()=>drr,ExternalProduct:()=>Hrr,FeatureFlag:()=>Dvt,FeatureFlagConfiguration:()=>Qtr,FolderConfiguration:()=>anr,FontConfig:()=>xVe,FontConfigPath:()=>lrr,FontConfigVariant:()=>urr,FontDisplay:()=>prr,FontStyle:()=>wVe,FontWeight:()=>CVe,FooterLinksConfig:()=>mrr,FooterNavThemeConfig:()=>Zrr,FullStoryAnalyticsConfig:()=>_tr,GitLibraryInputSchema:()=>xrr,GithubEditThisPageConfig:()=>nrr,GoogleAnalytics4Config:()=>Str,GtmConfig:()=>Btr,HeaderPosition:()=>Err,HttpSnippetLanguage:()=>srr,HttpSnippetsConfig:()=>arr,IntegrationsConfig:()=>hrr,IntercomConfig:()=>Ttr,InternalProduct:()=>Krr,JsConfig:()=>brr,JsConfigOptions:()=>Rvt,JsFileConfig:()=>Arr,JsFileConfigSettings:()=>grr,JsRemoteConfig:()=>yrr,JsScriptStrategy:()=>_Ve,Language:()=>vVe,LanguageSwitcherThemeConfig:()=>enr,LayoutConfig:()=>wrr,LibraryConfig:()=>Crr,LibraryConfiguration:()=>Orr,LibraryInputConfiguration:()=>Srr,LibraryLanguage:()=>Brr,LibraryName:()=>BVe,LibraryOutputConfiguration:()=>Trr,LibraryReferenceConfiguration:()=>cnr,LinkConfiguration:()=>bVe,LogoConfiguration:()=>Prr,MetadataConfig:()=>Rrr,NavbarDropdownConfig:()=>Frr,NavbarGithubConfig:()=>Nrr,NavbarGithubConfigWithOptions:()=>krr,NavbarLink:()=>Qrr,NavbarLinkConfig:()=>A$,NavigationConfig:()=>phe,NavigationItem:()=>y$,PageActionOption:()=>qrr,PageActionOptions:()=>Grr,PageActionsConfig:()=>Wrr,PageActionsThemeConfig:()=>tnr,PageConfiguration:()=>GU,PathLibraryInputSchema:()=>_rr,PlaygroundButtonSettings:()=>Ftr,PlaygroundSettings:()=>h$,PostHogConfig:()=>Otr,ProductConfig:()=>Jrr,ProductConfigBase:()=>OVe,ProductFileConfig:()=>Nms,ProductPath:()=>Qms,ProductSwitcherThemeConfig:()=>rnr,ProgrammingLanguage:()=>Yrr,RedirectConfig:()=>Xrr,RelativeProductPath:()=>lnr,Role:()=>yVe,RoleId:()=>xOe,SearchbarPlacement:()=>vrr,SectionConfiguration:()=>unr,SegmentConfig:()=>Ptr,SidebarThemeConfig:()=>nnr,SnippetLanguageConfiguration:()=>VU,SnippetsConfiguration:()=>Ntr,SwitcherPlacement:()=>Irr,TabConfig:()=>fhe,TabId:()=>WU,TabVariant:()=>Mrr,TabbedNavigationConfig:()=>zrr,TabbedNavigationItem:()=>Urr,TabbedNavigationItemWithLayout:()=>jrr,TabbedNavigationItemWithVariants:()=>Lrr,TabsAlignment:()=>inr,TabsPlacement:()=>SVe,TabsThemeConfig:()=>onr,Target:()=>qU,ThemeConfig:()=>snr,TitleSource:()=>IVe,TwitterCardSetting:()=>Drr,UntabbedNavigationConfig:()=>Vrr,VersionAvailability:()=>$rr,VersionConfig:()=>TVe,VersionFileConfig:()=>jms,VersionedSnippetLanguageConfiguration:()=>ktr,WithFeatureFlags:()=>Vd,WithPermissions:()=>qd,WithViewers:()=>lhe,docs:()=>bui});var bui={};te(bui,{AbsoluteProductPath:()=>Etr,AiChatConfig:()=>Ovt,AiChatDatasource:()=>Itr,AiChatLocation:()=>wtr,AiChatModel:()=>Ctr,AiChatWebsiteDatasource:()=>vtr,AiExamplesConfig:()=>xtr,AnalyticsConfig:()=>Dtr,AnnouncementConfig:()=>uhe,ApiReferenceConfiguration:()=>jtr,ApiReferenceEndpointConfiguration:()=>Mtr,ApiReferenceLayoutItem:()=>g$,ApiReferenceOperationConfiguration:()=>Ltr,ApiReferencePackageConfiguration:()=>Utr,ApiReferencePackageConfigurationWithOptions:()=>Vtr,ApiReferenceSectionConfiguration:()=>ztr,Audience:()=>d$,AudienceId:()=>Pvt,Availability:()=>gx,BackgroundImageConfiguration:()=>Gtr,BackgroundImageThemedConfig:()=>qtr,BodyThemeConfig:()=>Wtr,ChangelogConfiguration:()=>$tr,ChangelogFolderRelativePath:()=>EVe,CheckConfig:()=>Ktr,CheckRuleSeverity:()=>Nse,CheckRulesConfig:()=>Htr,CollapsedStringValue:()=>Rtr,CollapsedValue:()=>m$,ColorConfig:()=>Y0,ColorThemedConfig:()=>Jtr,ColorsConfiguration:()=>Ytr,ContentAlignment:()=>Xtr,CssConfig:()=>Ztr,CustomDomain:()=>err,CustomPageAction:()=>trr,DocsConfiguration:()=>kms,DocsInstance:()=>orr,DocsSettingsConfig:()=>crr,DocsTypographyConfig:()=>frr,EditThisPageConfig:()=>irr,EditThisPageLaunch:()=>rrr,ExperimentalConfig:()=>drr,ExternalProduct:()=>Hrr,FeatureFlag:()=>Dvt,FeatureFlagConfiguration:()=>Qtr,FolderConfiguration:()=>anr,FontConfig:()=>xVe,FontConfigPath:()=>lrr,FontConfigVariant:()=>urr,FontDisplay:()=>prr,FontStyle:()=>wVe,FontWeight:()=>CVe,FooterLinksConfig:()=>mrr,FooterNavThemeConfig:()=>Zrr,FullStoryAnalyticsConfig:()=>_tr,GitLibraryInputSchema:()=>xrr,GithubEditThisPageConfig:()=>nrr,GoogleAnalytics4Config:()=>Str,GtmConfig:()=>Btr,HeaderPosition:()=>Err,HttpSnippetLanguage:()=>srr,HttpSnippetsConfig:()=>arr,IntegrationsConfig:()=>hrr,IntercomConfig:()=>Ttr,InternalProduct:()=>Krr,JsConfig:()=>brr,JsConfigOptions:()=>Rvt,JsFileConfig:()=>Arr,JsFileConfigSettings:()=>grr,JsRemoteConfig:()=>yrr,JsScriptStrategy:()=>_Ve,Language:()=>vVe,LanguageSwitcherThemeConfig:()=>enr,LayoutConfig:()=>wrr,LibraryConfig:()=>Crr,LibraryConfiguration:()=>Orr,LibraryInputConfiguration:()=>Srr,LibraryLanguage:()=>Brr,LibraryName:()=>BVe,LibraryOutputConfiguration:()=>Trr,LibraryReferenceConfiguration:()=>cnr,LinkConfiguration:()=>bVe,LogoConfiguration:()=>Prr,MetadataConfig:()=>Rrr,NavbarDropdownConfig:()=>Frr,NavbarGithubConfig:()=>Nrr,NavbarGithubConfigWithOptions:()=>krr,NavbarLink:()=>Qrr,NavbarLinkConfig:()=>A$,NavigationConfig:()=>phe,NavigationItem:()=>y$,PageActionOption:()=>qrr,PageActionOptions:()=>Grr,PageActionsConfig:()=>Wrr,PageActionsThemeConfig:()=>tnr,PageConfiguration:()=>GU,PathLibraryInputSchema:()=>_rr,PlaygroundButtonSettings:()=>Ftr,PlaygroundSettings:()=>h$,PostHogConfig:()=>Otr,ProductConfig:()=>Jrr,ProductConfigBase:()=>OVe,ProductFileConfig:()=>Nms,ProductPath:()=>Qms,ProductSwitcherThemeConfig:()=>rnr,ProgrammingLanguage:()=>Yrr,RedirectConfig:()=>Xrr,RelativeProductPath:()=>lnr,Role:()=>yVe,RoleId:()=>xOe,SearchbarPlacement:()=>vrr,SectionConfiguration:()=>unr,SegmentConfig:()=>Ptr,SidebarThemeConfig:()=>nnr,SnippetLanguageConfiguration:()=>VU,SnippetsConfiguration:()=>Ntr,SwitcherPlacement:()=>Irr,TabConfig:()=>fhe,TabId:()=>WU,TabVariant:()=>Mrr,TabbedNavigationConfig:()=>zrr,TabbedNavigationItem:()=>Urr,TabbedNavigationItemWithLayout:()=>jrr,TabbedNavigationItemWithVariants:()=>Lrr,TabsAlignment:()=>inr,TabsPlacement:()=>SVe,TabsThemeConfig:()=>onr,Target:()=>qU,ThemeConfig:()=>snr,TitleSource:()=>IVe,TwitterCardSetting:()=>Drr,UntabbedNavigationConfig:()=>Vrr,VersionAvailability:()=>$rr,VersionConfig:()=>TVe,VersionFileConfig:()=>jms,VersionedSnippetLanguageConfiguration:()=>ktr,WithFeatureFlags:()=>Vd,WithPermissions:()=>qd,WithViewers:()=>lhe});var ae={};te(ae,{JsonError:()=>hVe,ParseError:()=>gVe,any:()=>Ems,bigint:()=>cms,boolean:()=>vms,booleanLiteral:()=>yms,date:()=>ums,discriminant:()=>Pms,enum_:()=>Atr,getObjectLikeUtils:()=>nq,getObjectUtils:()=>COe,getSchemaUtils:()=>zd,isProperty:()=>kse,lazy:()=>lms,lazyObject:()=>gms,list:()=>btr,never:()=>Ims,number:()=>wms,object:()=>ytr,objectWithoutOptionalProperties:()=>hms,optional:()=>mui,property:()=>fms,record:()=>Sms,set:()=>Bms,string:()=>Cms,stringLiteral:()=>bms,transform:()=>hui,undiscriminatedUnion:()=>Oms,union:()=>Rms,unknown:()=>xms,withParsedProperties:()=>yui});var Iu={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function fd(e,t){return`Expected ${t}. Received ${mgl(e)}.`}function mgl(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 mx(e){return{...e,json:ams(e.json),parse:ams(e.parse)}}function ams(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1466
1466
|
`)),{ok:!0,value:t}):n}}function gtr(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var hVe=class e extends Error{errors;constructor(t){super(t.map(gtr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var gVe=class e extends Error{errors;constructor(t){super(t.map(gtr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function zd(e){return{nullable:()=>hgl(e),optional:()=>mui(e),optionalNullable:()=>ggl(e),transform:t=>hui(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new gVe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new hVe(n.errors)}}}function hgl(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Iu.NULLABLE};return{...t,...zd(t)}}function mui(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Iu.OPTIONAL};return{...t,...zd(t)}}function ggl(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>Iu.OPTIONAL_NULLABLE};return{...t,...zd(t)}}function hui(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...zd(r)}}function cms(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:fd(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:fd(t,"bigint")}]}:{ok:!0,value:t},getType:()=>Iu.BIGINT};return{...mx(e),...zd(e)}}var Agl=/^([+-]?\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 ums(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:fd(t,"string")}]}:Agl.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:fd(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:fd(t,"Date object")}]},getType:()=>Iu.DATE};return{...mx(e),...zd(e)}}function hx(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...mx(r),...zd(r)}}}function Atr(e){let t=new Set(e);return hx(Iu.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:fd(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:fd(n,"enum")}]}:{ok:!0,value:n})()}function lms(e){let t=gui(e);return{...t,...zd(t)}}function gui(e){return{parse:(t,r)=>AVe(e).parse(t,r),json:(t,r)=>AVe(e).json(t,r),getType:()=>AVe(e).getType()}}function AVe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Aui(e){return Object.entries(e)}function Bvt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function Fse(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function Tvt(e){return Object.keys(e)}function pms(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var ygl=Object.prototype.hasOwnProperty;function nq(e){return{withParsedProperties:t=>yui(e,t)}}function yui(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(ygl.call(t,a)){let c=t[a];s[a]=typeof c=="function"?c(o.value):c}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!Fse(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:fd(n,"object")}]};let o=new Set(Object.keys(t)),s=Bvt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...zd(r),...nq(r)}}function fms(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function kse(e){return e.isProperty}var bgl=Object.prototype.hasOwnProperty;function ytr(e){let t;function r(){if(t==null){t={};for(let[d,f]of Aui(e)){let m=kse(f)?f.rawKey:d,h=kse(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of Aui(e)){let m=kse(f)?f.rawKey:d,h=kse(f)?f.valueSchema:f;Egl(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function c(){return i==null&&a(),i}function u(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>kse(f)?f.rawKey:d),_getParsedProperties:()=>Tvt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return dms({value:d,requiredKeys:a(),requiredKeysSet:u(),getProperty:h=>{let g=r()[h];if(g!=null)return{transformedKey:g.parsedKey,transform:A=>{let b=[...m,h];return g.valueSchema.parse(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return dms({value:d,requiredKeys:c(),requiredKeysSet:l(),getProperty:h=>{let g=e[h];if(g!=null)return kse(g)?{transformedKey:g.rawKey,transform:A=>{let b=[...m,h];return g.valueSchema.json(A,{...f,breadcrumbsPrefix:b})}}:{transformedKey:h,transform:A=>{let b=[...m,h];return g.json(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>Iu.OBJECT};return{...mx(p),...zd(p),...nq(p),...COe(p)}}function dms({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!Fse(e))return{ok:!1,errors:[{path:s,message:fd(e,"object")}]};let a=t.length,c=[],u={};for(let l in e){if(!bgl.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?u[d.transformedKey]=f.value:(u[l]=p,c.push(...f.errors))}else switch(i){case"fail":c.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":u[l]=p;break}}if(a>0)for(let l of t)l in e||c.push({path:s,message:`Missing required key "${l}"`});return c.length===0||o?{ok:!0,value:u}:{ok:!1,errors:c}}function COe(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>mms({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>mms({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Iu.OBJECT};return{...r,...zd(r),...nq(r),...COe(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))t.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))r.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},getType:()=>Iu.OBJECT};return{...n,...zd(n),...nq(n),...COe(n)}}}}function mms({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!Fse(t))return{ok:!1,errors:[{path:i,message:fd(t,"object")}]};let o=new Set(e),[s,a]=pms(Tvt(t),l=>o.has(l)),c=r(Bvt(t,a)),u=n(Bvt(t,s));return c.ok&&u.ok?{ok:!0,value:{...c.value,...u.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...u.ok?[]:u.errors]}}function Egl(e){return!vgl(e)}function vgl(e){switch(e.getType()){case Iu.ANY:case Iu.UNKNOWN:case Iu.OPTIONAL:case Iu.OPTIONAL_NULLABLE:return!0;default:return!1}}function hms(e){return ytr(e)}function gms(e){let t={...gui(e),_getRawProperties:()=>AVe(e)._getRawProperties(),_getParsedProperties:()=>AVe(e)._getParsedProperties()};return{...t,...zd(t),...nq(t),...COe(t)}}function btr(e){let t={parse:(r,n)=>Ams(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>Ams(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>Iu.LIST};return{...mx(t),...zd(t)}}function Ams(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:fd(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function yms(e){return hx(Iu.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:fd(r,`${e.toString()}`)}]})()}function bms(e){return hx(Iu.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:fd(r,`"${e}"`)}]})()}var Ems=hx(Iu.ANY,e=>({ok:!0,value:e}));var vms=hx(Iu.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:fd(e,"boolean")}]});var Ims=hx(Iu.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var wms=hx(Iu.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:fd(e,"number")}]});var Cms=hx(Iu.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:fd(e,"string")}]});var xms=hx(Iu.UNKNOWN,e=>({ok:!0,value:e}));var Igl=Object.prototype.hasOwnProperty;function Sms(e,t){let r={parse:(n,i)=>_ms({value:n,isKeyNumeric:e.getType()===Iu.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>_ms({value:n,isKeyNumeric:e.getType()===Iu.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Iu.RECORD};return{...mx(r),...zd(r)}}function _ms({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!Fse(e))return{ok:!1,errors:[{path:i,message:fd(e,"object")}]};let o={},s=[];for(let a in e){if(!Igl.call(e,a))continue;let c=e[a];if(c===void 0)continue;let u=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(u=d)}let l=r(u),p=n(c,u);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function Bms(e){let t=btr(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:fd(n,"Set")}]},getType:()=>Iu.SET};return{...mx(r),...zd(r)}}function Oms(e){let t={parse:(r,n)=>Tms((i,o)=>i.parse(r,o),e,n),json:(r,n)=>Tms((i,o)=>i.json(r,o),e,n),getType:()=>Iu.UNDISCRIMINATED_UNION};return{...mx(t),...zd(t)}}function Tms(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function Pms(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var wgl=Object.prototype.hasOwnProperty;function Rms(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=Atr(Tvt(t)),o={parse:(s,a)=>Dms({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:c=>i.parse(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.parse(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>Dms({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:c=>i.json(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.json(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>Iu.UNION};return{...mx(o),...zd(o),...nq(o)}}function Dms({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!Fse(e))return{ok:!1,errors:[{path:a,message:fd(e,"object")}]};let c=e[t],u={};for(let f in e)wgl.call(e,f)&&f!==t&&(u[f]=e[f]);if(c==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(c);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...u}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(u,p);return d.ok?{ok:!0,value:{[r]:c,...d.value}}:d}var Etr=ae.object({href:ae.string()});var vtr=ae.object({url:ae.string(),title:ae.string().optional()});var Itr=ae.undiscriminatedUnion([vtr]);var wtr=ae.enum_(["docs","slack","discord"]);var Ctr=ae.enum_(["claude-3.7","claude-4","command-a"]);var Ovt=ae.object({model:Ctr.optional(),systemPrompt:ae.property("system-prompt",ae.string().optional()),location:ae.list(wtr).optional(),datasources:ae.list(Itr).optional()});var xtr=ae.object({enabled:ae.boolean().optional(),style:ae.string().optional()});var _tr=ae.object({orgId:ae.property("org-id",ae.string())});var Str=ae.object({measurementId:ae.property("measurement-id",ae.string())});var Btr=ae.object({containerId:ae.property("container-id",ae.string())});var Ttr=ae.object({appId:ae.property("app-id",ae.string()),apiBase:ae.property("api-base",ae.string().optional())});var Otr=ae.object({apiKey:ae.property("api-key",ae.string()),endpoint:ae.string().optional()});var Ptr=ae.object({writeKey:ae.property("write-key",ae.string())});var Dtr=ae.object({segment:Ptr.optional(),fullstory:_tr.optional(),intercom:Ttr.optional(),posthog:Otr.optional(),gtm:Btr.optional(),ga4:Str.optional()});var uhe=ae.object({message:ae.string()});var Pvt=ae.string();var d$=ae.undiscriminatedUnion([Pvt,ae.list(Pvt)]);var gx=ae.enum_(["stable","generally-available","in-development","pre-release","deprecated","beta"]);var Rtr=ae.enum_(["open-by-default"]);var m$=ae.undiscriminatedUnion([ae.boolean(),Rtr]);var Ftr=ae.object({href:ae.string().optional()});var h$=ae.object({hidden:ae.boolean().optional(),environments:ae.list(ae.string()).optional(),button:Ftr.optional(),oauth:ae.boolean().optional(),limitWebsocketMessagesPerConnection:ae.property("limit-websocket-messages-per-connection",ae.number().optional())});var ktr=ae.object({version:ae.string(),package:ae.string()});var VU=ae.undiscriminatedUnion([ae.string(),ktr]);var Ntr=ae.object({python:VU.optional(),typescript:VU.optional(),go:VU.optional(),java:VU.optional(),ruby:VU.optional(),csharp:VU.optional(),php:VU.optional(),swift:VU.optional(),rust:VU.optional()});var Dvt=ae.object({flag:ae.string(),fallbackValue:ae.property("fallback-value",ae.unknown().optional()),match:ae.unknown().optional()});var Qtr=ae.undiscriminatedUnion([ae.string(),Dvt,ae.list(Dvt)]);var Vd=ae.object({featureFlag:ae.property("feature-flag",Qtr.optional())});var xOe=ae.string();var yVe=ae.undiscriminatedUnion([xOe,ae.list(xOe)]);var qd=ae.object({viewers:yVe.optional(),orphaned:ae.boolean().optional()});var jtr=ae.object({api:ae.string(),apiName:ae.property("api-name",ae.string().optional()),openrpc:ae.string().optional(),audiences:d$.optional(),displayErrors:ae.property("display-errors",ae.boolean().optional()),tagDescriptionPages:ae.property("tag-description-pages",ae.boolean().optional()),snippets:Ntr.optional(),postman:ae.string().optional(),summary:ae.string().optional(),layout:ae.list(ae.lazy(()=>g$)).optional(),collapsed:m$.optional(),icon:ae.string().optional(),slug:ae.string().optional(),hidden:ae.boolean().optional(),availability:gx.optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),alphabetized:ae.boolean().optional(),flattened:ae.boolean().optional(),paginated:ae.boolean().optional(),playground:h$.optional()}).extend(qd).extend(Vd);var Mtr=ae.object({endpoint:ae.string(),title:ae.string().optional(),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),availability:gx.optional(),playground:h$.optional()}).extend(qd).extend(Vd);var Ltr=ae.object({operation:ae.string(),title:ae.string().optional(),slug:ae.string().optional(),hidden:ae.boolean().optional(),availability:gx.optional()}).extend(qd).extend(Vd);var qU=ae.enum_(["_blank","_self","_parent","_top"]);var bVe=ae.object({link:ae.string(),href:ae.string(),icon:ae.string().optional(),target:qU.optional()});var GU=ae.object({page:ae.string(),path:ae.string(),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),noindex:ae.boolean().optional(),availability:gx.optional()}).extend(qd).extend(Vd);var g$=ae.undiscriminatedUnion([ae.string(),ae.record(ae.string(),ae.lazy(()=>Utr)),ae.lazyObject(()=>ztr),Mtr,Ltr,GU,bVe]);var Utr=ae.undiscriminatedUnion([ae.list(ae.lazy(()=>g$)),ae.lazyObject(()=>Vtr)]);var Vtr=ae.object({title:ae.string().optional(),summary:ae.string().optional(),contents:ae.list(ae.lazy(()=>g$)).optional(),availability:gx.optional(),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),playground:h$.optional()}).extend(qd).extend(Vd);var ztr=ae.object({section:ae.string(),referencedPackages:ae.property("referenced-packages",ae.list(ae.string()).optional()),summary:ae.string().optional(),contents:ae.list(ae.lazy(()=>g$)).optional(),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),collapsed:m$.optional(),collapsible:ae.boolean().optional(),collapsedByDefault:ae.property("collapsed-by-default",ae.boolean().optional()),availability:gx.optional(),playground:h$.optional()}).extend(qd).extend(Vd);var qtr=ae.object({dark:ae.string().optional(),light:ae.string().optional()});var Gtr=ae.undiscriminatedUnion([ae.string(),qtr]);var Wtr=ae.enum_(["default","canvas"]);var EVe=ae.string();var $tr=ae.object({changelog:EVe,title:ae.string().optional(),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional()}).extend(qd).extend(Vd);var Nse=ae.enum_(["warn","error"]);var Htr=ae.object({exampleValidation:ae.property("example-validation",Nse.optional()),brokenLinks:ae.property("broken-links",Nse.optional()),noNonComponentRefs:ae.property("no-non-component-refs",Nse.optional()),validLocalReferences:ae.property("valid-local-references",Nse.optional()),noCircularRedirects:ae.property("no-circular-redirects",Nse.optional()),validDocsEndpoints:ae.property("valid-docs-endpoints",Nse.optional())});var Ktr=ae.object({rules:Htr.optional()});var Jtr=ae.object({dark:ae.string().optional(),light:ae.string().optional()});var Y0=ae.undiscriminatedUnion([ae.string(),Jtr]);var Ytr=ae.object({accentPrimary:ae.property("accent-primary",Y0.optional()),accentPrimaryDeprecated:ae.property("accentPrimary",Y0.optional()),background:Y0.optional(),border:Y0.optional(),sidebarBackground:ae.property("sidebar-background",Y0.optional()),headerBackground:ae.property("header-background",Y0.optional()),cardBackground:ae.property("card-background",Y0.optional()),accent1:ae.property("accent-1",Y0.optional()),accent2:ae.property("accent-2",Y0.optional()),accent3:ae.property("accent-3",Y0.optional()),accent4:ae.property("accent-4",Y0.optional()),accent5:ae.property("accent-5",Y0.optional()),accent6:ae.property("accent-6",Y0.optional()),accent7:ae.property("accent-7",Y0.optional()),accent8:ae.property("accent-8",Y0.optional()),accent9:ae.property("accent-9",Y0.optional()),accent10:ae.property("accent-10",Y0.optional()),accent11:ae.property("accent-11",Y0.optional()),accent12:ae.property("accent-12",Y0.optional())});var Xtr=ae.enum_(["center","left"]);var Ztr=ae.undiscriminatedUnion([ae.string(),ae.list(ae.string())]);var err=ae.undiscriminatedUnion([ae.string(),ae.list(ae.string())]);var trr=ae.object({title:ae.string(),subtitle:ae.string().optional(),url:ae.string(),icon:ae.string().optional(),default:ae.boolean().optional()});var rrr=ae.enum_(["github","dashboard"]);var nrr=ae.object({host:ae.string().optional(),owner:ae.string(),repo:ae.string(),branch:ae.string().optional()});var irr=ae.object({github:nrr.optional(),launch:rrr.optional()});var orr=ae.object({url:ae.string(),customDomain:ae.property("custom-domain",err.optional()),private:ae.boolean().optional(),editThisPage:ae.property("edit-this-page",irr.optional()),audiences:d$.optional()});var srr=ae.enum_(["curl","csharp","go","java","javascript","php","python","ruby","swift","typescript"]);var arr=ae.undiscriminatedUnion([ae.boolean(),ae.list(srr)]);var vVe=ae.enum_(["en","es","fr","de","it","pt","ja","zh","ko","el","no","pl","ru","sv","tr"]);var IVe=ae.enum_(["frontmatter","filename"]);var crr=ae.object({searchText:ae.property("search-text",ae.string().optional()),disableSearch:ae.property("disable-search",ae.boolean().optional()),darkModeCode:ae.property("dark-mode-code",ae.boolean().optional()),defaultSearchFilters:ae.property("default-search-filters",ae.boolean().optional()),httpSnippets:ae.property("http-snippets",arr.optional()),hide404Page:ae.property("hide-404-page",ae.boolean().optional()),useJavascriptAsTypescript:ae.property("use-javascript-as-typescript",ae.boolean().optional()),disableExplorerProxy:ae.property("disable-explorer-proxy",ae.boolean().optional()),disableAnalytics:ae.property("disable-analytics",ae.boolean().optional()),language:vVe.optional(),folderTitleSource:ae.property("folder-title-source",IVe.optional()),substituteEnvVars:ae.property("substitute-env-vars",ae.boolean().optional())});var wVe=ae.enum_(["normal","italic"]);var CVe=ae.undiscriminatedUnion([ae.string(),ae.number()]);var urr=ae.object({path:ae.string(),weight:CVe.optional(),style:wVe.optional()});var lrr=ae.undiscriminatedUnion([ae.string(),urr]);var prr=ae.enum_(["auto","block","swap","fallback","optional"]);var xVe=ae.object({name:ae.string().optional(),path:ae.string().optional(),weight:CVe.optional(),style:wVe.optional(),paths:ae.list(lrr).optional(),display:prr.optional(),fallback:ae.list(ae.string()).optional(),fontVariationSettings:ae.property("font-variation-settings",ae.string().optional())});var frr=ae.object({headingsFont:xVe.optional(),bodyFont:xVe.optional(),codeFont:xVe.optional()});var drr=ae.object({mdxComponents:ae.property("mdx-components",ae.list(ae.string()).optional()),disableStreamToggle:ae.property("disable-stream-toggle",ae.boolean().optional()),openapiParserV2:ae.property("openapi-parser-v2",ae.boolean().optional()),openapiParserV3:ae.property("openapi-parser-v3",ae.boolean().optional()),dynamicSnippets:ae.property("dynamic-snippets",ae.boolean().optional()),aiExamples:ae.property("ai-examples",ae.boolean().optional()),aiExampleStyleInstructions:ae.property("ai-example-style-instructions",ae.string().optional()),excludeApis:ae.property("exclude-apis",ae.boolean().optional()),basepathAware:ae.property("basepath-aware",ae.boolean().optional())});var mrr=ae.object({github:ae.string().optional(),twitter:ae.string().optional(),x:ae.string().optional(),linkedin:ae.string().optional(),youtube:ae.string().optional(),instagram:ae.string().optional(),facebook:ae.string().optional(),discord:ae.string().optional(),slack:ae.string().optional(),hackernews:ae.string().optional(),medium:ae.string().optional(),website:ae.string().optional()});var hrr=ae.object({intercom:ae.string().optional()});var _Ve=ae.enum_(["beforeInteractive","afterInteractive","lazyOnload"]);var grr=ae.object({path:ae.string(),strategy:_Ve.optional()});var Arr=ae.undiscriminatedUnion([ae.string(),grr]);var yrr=ae.object({url:ae.string(),strategy:_Ve.optional()});var Rvt=ae.undiscriminatedUnion([yrr,Arr]);var brr=ae.undiscriminatedUnion([Rvt,ae.list(Rvt)]);var Err=ae.enum_(["fixed","static"]);var vrr=ae.enum_(["header","header-tabs","sidebar"]);var Irr=ae.enum_(["header","sidebar"]);var SVe=ae.enum_(["header","sidebar"]);var wrr=ae.object({pageWidth:ae.property("page-width",ae.string().optional()),contentWidth:ae.property("content-width",ae.string().optional()),sidebarWidth:ae.property("sidebar-width",ae.string().optional()),headerHeight:ae.property("header-height",ae.string().optional()),searchbarPlacement:ae.property("searchbar-placement",vrr.optional()),tabsPlacement:ae.property("tabs-placement",SVe.optional()),switcherPlacement:ae.property("switcher-placement",Irr.optional()),contentAlignment:ae.property("content-alignment",Xtr.optional()),headerPosition:ae.property("header-position",Err.optional()),disableHeader:ae.property("disable-header",ae.boolean().optional()),hideNavLinks:ae.property("hide-nav-links",ae.boolean().optional()),hideFeedback:ae.property("hide-feedback",ae.boolean().optional())});var Crr=ae.object({doxyfile:ae.string().optional()});var xrr=ae.object({git:ae.string(),subpath:ae.string().optional()});var _rr=ae.object({path:ae.string()});var Srr=ae.undiscriminatedUnion([xrr,_rr]);var Brr=ae.enum_(["python","cpp"]);var Trr=ae.object({path:ae.string()});var Orr=ae.object({input:Srr,output:Trr,lang:Brr,config:Crr.optional()});var BVe=ae.string();var Prr=ae.object({dark:ae.string().optional(),light:ae.string().optional(),height:ae.number().optional(),href:ae.string().optional(),rightText:ae.property("right-text",ae.string().optional())});var Drr=ae.enum_(["summary","summary_large_image","app","player"]);var Rrr=ae.object({ogSiteName:ae.property("og:site_name",ae.string().optional()),ogTitle:ae.property("og:title",ae.string().optional()),ogDescription:ae.property("og:description",ae.string().optional()),ogUrl:ae.property("og:url",ae.string().optional()),ogImage:ae.property("og:image",ae.string().optional()),ogImageWidth:ae.property("og:image:width",ae.number().optional()),ogImageHeight:ae.property("og:image:height",ae.number().optional()),ogLocale:ae.property("og:locale",ae.string().optional()),ogLogo:ae.property("og:logo",ae.string().optional()),twitterTitle:ae.property("twitter:title",ae.string().optional()),twitterDescription:ae.property("twitter:description",ae.string().optional()),twitterHandle:ae.property("twitter:handle",ae.string().optional()),twitterImage:ae.property("twitter:image",ae.string().optional()),twitterSite:ae.property("twitter:site",ae.string().optional()),twitterUrl:ae.property("twitter:url",ae.string().optional()),twitterCard:ae.property("twitter:card",Drr.optional()),ogDynamic:ae.property("og:dynamic",ae.boolean().optional()),ogBackgroundImage:ae.property("og:background-image",ae.string().optional()),canonicalHost:ae.property("canonical-host",ae.string().optional())});var lhe=ae.object({viewers:yVe.optional()});var A$=ae.object({href:ae.string().optional(),target:qU.optional(),url:ae.string().optional(),text:ae.string().optional(),icon:ae.string().optional(),rightIcon:ae.string().optional(),rounded:ae.boolean().optional()}).extend(lhe);var Frr=ae.object({links:ae.list(A$),text:ae.string().optional(),icon:ae.string().optional(),rightIcon:ae.string().optional(),rounded:ae.boolean().optional()}).extend(lhe);var krr=ae.object({url:ae.string(),target:qU.optional()}).extend(lhe);var Nrr=ae.undiscriminatedUnion([ae.string(),krr]);var Qrr=ae.union("type",{filled:A$,outlined:A$,minimal:A$,github:ae.object({value:Nrr}),dropdown:Frr,primary:A$,secondary:A$}).transform({transform:e=>e,untransform:e=>e});var WU=ae.string();var jrr=ae.object({tab:WU,layout:ae.list(ae.lazy(()=>y$)).optional()});var Mrr=ae.object({title:ae.string(),subtitle:ae.string().optional(),icon:ae.string().optional(),layout:ae.list(ae.lazy(()=>y$)),slug:ae.string().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),hidden:ae.boolean().optional(),default:ae.boolean().optional()}).extend(qd).extend(Vd);var Lrr=ae.object({tab:WU,variants:ae.list(Mrr)});var Urr=ae.undiscriminatedUnion([jrr,Lrr]);var zrr=ae.list(Urr);var Vrr=ae.list(ae.lazy(()=>y$));var phe=ae.undiscriminatedUnion([Vrr,zrr]);var qrr=ae.enum_(["copy-page","view-as-markdown","ask-ai","chatgpt","claude","cursor","vscode"]);var Grr=ae.object({copyPage:ae.property("copy-page",ae.boolean().optional()),viewAsMarkdown:ae.property("view-as-markdown",ae.boolean().optional()),askAi:ae.property("ask-ai",ae.boolean().optional()),chatgpt:ae.boolean().optional(),claude:ae.boolean().optional(),cursor:ae.boolean().optional(),vscode:ae.boolean().optional(),custom:ae.list(trr).optional()});var Wrr=ae.object({default:qrr.optional(),options:Grr.optional()});var $rr=ae.enum_(["deprecated","ga","stable","beta"]);var TVe=ae.object({displayName:ae.property("display-name",ae.string()),path:ae.string(),slug:ae.string().optional(),availability:$rr.optional(),audiences:d$.optional(),hidden:ae.boolean().optional(),announcement:uhe.optional()}).extend(qd).extend(Vd);var OVe=ae.object({displayName:ae.property("display-name",ae.string()),subtitle:ae.string().optional(),icon:ae.string().optional(),image:ae.string().optional(),versions:ae.list(TVe).optional(),audiences:d$.optional()}).extend(qd).extend(Vd);var Hrr=ae.object({href:ae.string(),target:qU.optional()}).extend(OVe);var Krr=ae.object({path:ae.string(),slug:ae.string().optional(),announcement:uhe.optional()}).extend(OVe);var Jrr=ae.undiscriminatedUnion([Krr,Hrr]);var Yrr=ae.enum_(["typescript","javascript","python","java","go","ruby","csharp","php","swift","rust","nodets","nodejs","dotnet","curl","jvm","ts","js"]);var Xrr=ae.object({source:ae.string(),destination:ae.string(),permanent:ae.boolean().optional()});var fhe=ae.object({displayName:ae.property("display-name",ae.string()),icon:ae.string().optional(),slug:ae.string().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),hidden:ae.boolean().optional(),href:ae.string().optional(),target:qU.optional(),changelog:EVe.optional()}).extend(qd).extend(Vd);var Zrr=ae.enum_(["default","minimal"]);var enr=ae.enum_(["default","minimal"]);var tnr=ae.enum_(["default","toolbar"]);var rnr=ae.enum_(["default","toggle"]);var nnr=ae.enum_(["default","minimal"]);var inr=ae.enum_(["left","center"]);var Fms=ae.enum_(["default","bubble"]),Cgl=ae.object({style:Fms.optional(),alignment:inr.optional(),placement:SVe.optional()}),onr=ae.undiscriminatedUnion([Fms,Cgl]);var snr=ae.object({sidebar:nnr.optional(),body:Wtr.optional(),tabs:onr.optional(),pageActions:ae.property("page-actions",tnr.optional()),footerNav:ae.property("footer-nav",Zrr.optional()),languageSwitcher:ae.property("language-switcher",enr.optional()),productSwitcher:ae.property("product-switcher",rnr.optional())});var kms=ae.object({instances:ae.list(orr),title:ae.string().optional(),libraries:ae.record(BVe,Orr).optional(),analytics:Dtr.optional(),announcement:uhe.optional(),roles:ae.list(xOe).optional(),tabs:ae.record(WU,fhe).optional(),versions:ae.list(TVe).optional(),products:ae.list(Jrr).optional(),landingPage:ae.property("landing-page",GU.optional()),navigation:phe.optional(),navbarLinks:ae.property("navbar-links",ae.list(Qrr).optional()),footerLinks:ae.property("footer-links",mrr.optional()),pageActions:ae.property("page-actions",Wrr.optional()),experimental:drr.optional(),defaultLanguage:ae.property("default-language",Yrr.optional()),languages:ae.list(vVe).optional(),aiChat:ae.property("ai-chat",Ovt.optional()),aiSearch:ae.property("ai-search",Ovt.optional()),aiExamples:ae.property("ai-examples",xtr.optional()),metadata:Rrr.optional(),redirects:ae.list(Xrr).optional(),check:Ktr.optional(),logo:Prr.optional(),favicon:ae.string().optional(),backgroundImage:ae.property("background-image",Gtr.optional()),colors:Ytr.optional(),typography:frr.optional(),layout:wrr.optional(),settings:crr.optional(),theme:snr.optional(),integrations:hrr.optional(),css:Ztr.optional(),js:brr.optional(),header:ae.string().optional(),footer:ae.string().optional()});var anr=ae.object({folder:ae.string(),title:ae.string().optional(),titleSource:ae.property("title-source",IVe.optional()),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),collapsed:m$.optional(),collapsible:ae.boolean().optional(),collapsedByDefault:ae.property("collapsed-by-default",ae.boolean().optional()),availability:gx.optional()}).extend(qd).extend(Vd);var cnr=ae.object({library:BVe,title:ae.string().optional(),slug:ae.string().optional()}).extend(qd).extend(Vd);var y$=ae.undiscriminatedUnion([GU,ae.lazyObject(()=>unr),jtr,cnr,bVe,$tr,anr]);var Nms=ae.object({tabs:ae.record(WU,fhe).optional(),landingPage:ae.property("landing-page",GU.optional()),navigation:phe});var lnr=ae.object({displayName:ae.property("display-name",ae.string()),path:ae.string(),slug:ae.string().optional()}).extend(qd).extend(Vd);var Qms=ae.undiscriminatedUnion([lnr,Etr]);var unr=ae.object({section:ae.string(),path:ae.string().optional(),contents:ae.list(ae.lazy(()=>y$)),collapsed:m$.optional(),collapsible:ae.boolean().optional(),collapsedByDefault:ae.property("collapsed-by-default",ae.boolean().optional()),slug:ae.string().optional(),icon:ae.string().optional(),hidden:ae.boolean().optional(),skipSlug:ae.property("skip-slug",ae.boolean().optional()),availability:gx.optional()}).extend(qd).extend(Vd);var jms=ae.object({tabs:ae.record(WU,fhe).optional(),landingPage:ae.property("landing-page",GU.optional()),navigation:phe});var Mms=require("fs/promises");var xgl=/\r?\n/;async function dhe({absolutePathToFernignore:e}){let t=(await(0,Mms.readFile)(e)).toString();return Lms(t)}function Lms(e){return[oT,...e.trim().split(xgl).map(t=>{let r=t.indexOf("#");return r!==-1?t.slice(0,r).trim():t.trim()}).filter(t=>t.length>0)]}var In={};te(In,{API_ORIGIN_LOCATION_KEY:()=>vus,API_SETTINGS_KEY:()=>xus,ASYNC_API_LOCATION_KEY:()=>Ius,CoerceConstsTo:()=>ehs,DEFAULT_GROUP_GENERATORS_CONFIG_KEY:()=>k8e,DEFAULT_GROUP_NAME:()=>UEt,DefaultIntegerFormat:()=>ths,ExampleStyle:()=>rhs,FormParameterEncoding:()=>nhs,GenerationLanguage:()=>Ums,GithubCommitAndReleaseMode:()=>uhs,GithubLicenseType:()=>phs,GithubSelfhostedMode:()=>lhs,Language:()=>ihs,MessageNamingSettingsSchema:()=>ohs,ModelProvider:()=>qms,OPENAPI_LOCATION_KEY:()=>wus,OPENAPI_OVERRIDES_LOCATION_KEY:()=>Cus,PathParameterOrder:()=>shs,RemoveDiscriminantsFromSchemas:()=>ahs,UnionSettingsSchema:()=>chs,ai:()=>vui,fernDefinition:()=>wui,generators:()=>Cui,getPackageName:()=>zms,group:()=>xui,isApiConfigurationV2Schema:()=>zhs,isAsyncApiSpecSchema:()=>Vhs,isConjureSchema:()=>qhs,isGraphQLSpecSchema:()=>Ghs,isNamespacedApiConfiguration:()=>Whs,isOpenApiSpecSchema:()=>$hs,isOpenRpcSpecSchema:()=>Hhs,isProtoSpecSchema:()=>Khs,isRawProtobufAPIDefinitionSchema:()=>Vms,license:()=>_ui,replay:()=>fhs,reviewers:()=>dhs,serialization:()=>Hui});var Ums={TYPESCRIPT:"typescript",JAVA:"java",PYTHON:"python",GO:"go",RUBY:"ruby",CSHARP:"csharp",SWIFT:"swift",PHP:"php",RUST:"rust"};function zms({generatorInvocation:e}){return e.language==="go"?_gl(e):e.outputMode._visit({downloadFiles:()=>{},github:t=>t.publishInfo?._visit({maven:r=>r.coordinate,npm:r=>r.packageName,pypi:r=>r.packageName,postman:()=>{},rubygems:r=>r.packageName,nuget:r=>r.packageName,crates:r=>r.packageName,_other:()=>{}}),githubV2:t=>t.publishInfo?._visit({maven:r=>r.coordinate,npm:r=>r.packageName,pypi:r=>r.packageName,postman:()=>{},rubygems:r=>r.packageName,nuget:r=>r.packageName,crates:r=>r.packageName,_other:()=>{}}),publish:()=>{},publishV2:()=>{},_other:()=>{}})}function _gl(e){return e.outputMode._visit({downloadFiles:()=>{},github:t=>`github.com/${t.owner}/${t.repo}`,githubV2:t=>`github.com/${t.owner}/${t.repo}`,publish:()=>{},publishV2:()=>{},_other:()=>{}})}function Vms(e){return typeof e!="string"&&"proto"in e}var vui={};te(vui,{ModelProvider:()=>qms});var qms={Openai:"openai",Anthropic:"anthropic",Bedrock:"bedrock"};var wui={};te(wui,{AvailabilityStatusSchema:()=>Wms,auth:()=>Gms,availability:()=>Iui,commons:()=>$ms,encoding:()=>Hms,environments:()=>Kms,file:()=>Jms,service:()=>Yms,types:()=>Xms,validation:()=>Zms});var Gms={};var Iui={};te(Iui,{AvailabilityStatusSchema:()=>Wms});var Wms={InDevelopment:"in-development",PreRelease:"pre-release",Deprecated:"deprecated",GenerallyAvailable:"generally-available"};var $ms={};var Hms={};var Kms={};var Jms={};var Yms={};var Xms={};var Zms={};var Cui={};te(Cui,{CoerceConstsTo:()=>ehs,DefaultIntegerFormat:()=>ths,ExampleStyle:()=>rhs,FormParameterEncoding:()=>nhs,Language:()=>ihs,MessageNamingSettingsSchema:()=>ohs,PathParameterOrder:()=>shs,RemoveDiscriminantsFromSchemas:()=>ahs,UnionSettingsSchema:()=>chs});var ehs={Literals:"literals",Enums:"enums",EnumsCoerceableToLiterals:"enums-coerceable-to-literals"};var ths={Int32:"int32",Int64:"int64",Uint32:"uint32",Uint64:"uint64"};var rhs={Minimal:"minimal",Comprehensive:"comprehensive"};var nhs={Form:"form",Json:"json"};var ihs={Java:"java",Python:"python",Go:"go",Ruby:"ruby",Csharp:"csharp",Typescript:"typescript",Php:"php",Rust:"rust",Swift:"swift"};var ohs={V1:"v1",V2:"v2"};var shs={UrlOrder:"url-order",SpecOrder:"spec-order"};var ahs={Always:"always",Never:"never"};var chs={V1:"v1"};var xui={};te(xui,{GithubCommitAndReleaseMode:()=>uhs,GithubSelfhostedMode:()=>lhs});var uhs={Commit:"commit",Release:"release"};var lhs={PullRequest:"pull-request",Push:"push"};var _ui={};te(_ui,{GithubLicenseType:()=>phs});var phs={Mit:"MIT",Apache:"Apache-2.0"};var fhs={};var dhs={};var Hui={};te(Hui,{AiServicesSchema:()=>Anr,ApiConfigurationSchema:()=>Iir,ApiConfigurationSchemaInternal:()=>$Ve,ApiConfigurationV2Schema:()=>Eir,ApiConfigurationV2SettingsSchema:()=>JVe,ApiConfigurationV2SpecsSchema:()=>YVe,ApiDefinitionList:()=>oir,ApiDefinitionPathSchema:()=>Ahe,ApiDefinitionSchema:()=>iir,ApiDefinitionSettingsSchema:()=>VVe,ApiDefinitionWithOverridesSchema:()=>qVe,AsyncApiSettingsSchema:()=>KVe,AsyncApiSpecSchema:()=>mir,BaseApiSettingsSchema:()=>HVe,CoerceConstsTo:()=>sir,ConjureSchema:()=>dir,CratesOutputLocationSchema:()=>_ir,DefaultIntegerFormat:()=>air,ExampleStyle:()=>wir,FormParameterEncoding:()=>cir,GeneratorApiSettingsSchema:()=>xir,GeneratorGroupSchema:()=>Hir,GeneratorInvocationSchema:()=>$ir,GeneratorOutputSchema:()=>Nir,GeneratorPublishMetadataSchema:()=>jvt,GeneratorSnippetsSchema:()=>Mir,GeneratorsConfigurationSchema:()=>Uhs,GeneratorsOpenApiObjectSchema:()=>Jir,GeneratorsOpenApiSchema:()=>Yir,GithubCommitAndReleaseMode:()=>Lir,GithubCommitAndReleaseSchema:()=>Uir,GithubConfigurationSchema:()=>Wir,GithubLicenseCustomSchema:()=>Qir,GithubLicenseSchema:()=>HU,GithubLicenseType:()=>jir,GithubPullRequestSchema:()=>zir,GithubPushSchema:()=>Vir,GithubSelfhostedMode:()=>qir,GithubSelfhostedSchema:()=>Gir,GraphQlSpecSchema:()=>hir,Language:()=>Xir,LocalFileSystemOutputLocationSchema:()=>Sir,MavenOutputLocationSchema:()=>Tir,MavenOutputSignatureSchema:()=>Bir,MessageNamingSettingsSchema:()=>LVe,ModelName:()=>hnr,ModelProvider:()=>gnr,NamespacedApiConfigurationSchema:()=>vir,NpmOutputLocationSchema:()=>Oir,NugetOutputLocationSchema:()=>Pir,OpenApiExampleGenerationSchema:()=>uir,OpenApiFilterSchema:()=>lir,OpenApiSettingsSchema:()=>yhe,OpenApiSpecSchema:()=>gir,OpenRpcSpecSchema:()=>Air,OutputMetadataAuthor:()=>Cir,OutputMetadataSchema:()=>bhe,OverridesSchema:()=>$U,PathParameterOrder:()=>UVe,PostmanOutputLocationSchema:()=>Dir,ProtobufApiDefinitionSchema:()=>WVe,ProtobufDefinitionSchema:()=>GVe,ProtobufSpecSchema:()=>yir,PypiOutputLocationSchema:()=>Fir,PypiOutputMetadataSchema:()=>Rir,ReadmeCustomSectionSchema:()=>Zir,ReadmeEndpointObjectSchema:()=>eor,ReadmeEndpointSchema:()=>Mvt,ReadmeSchema:()=>tor,RemoveDiscriminantsFromSchemas:()=>zVe,ReplayConfigSchema:()=>Kir,RequestOrResponseExampleGenerationSchema:()=>Nvt,ResolveAliases:()=>fir,ResolveAliasesSchema:()=>pir,ReviewerSchema:()=>Qvt,ReviewersSchema:()=>Ehe,RubyGemsOutputLocationSchema:()=>kir,SpecSchema:()=>bir,UnionSettingsSchema:()=>nir,WhitelabelConfigurationSchema:()=>nor,WhitelabelGithubConfigurationSchema:()=>ror,ai:()=>Dui,fernDefinition:()=>zui,generators:()=>Vui,group:()=>qui,license:()=>Gui,replay:()=>Wui,reviewers:()=>$ui});var Dui={};te(Dui,{AiServicesSchema:()=>Anr,ModelName:()=>hnr,ModelProvider:()=>gnr});var Ce={};te(Ce,{JsonError:()=>PVe,ParseError:()=>DVe,any:()=>Shs,bigint:()=>hhs,boolean:()=>Bhs,booleanLiteral:()=>xhs,date:()=>ghs,discriminant:()=>jhs,enum_:()=>fnr,getObjectLikeUtils:()=>iq,getObjectUtils:()=>_Oe,getSchemaUtils:()=>Gd,isProperty:()=>jse,lazy:()=>Ahs,lazyObject:()=>whs,list:()=>mnr,never:()=>Ths,number:()=>Ohs,object:()=>dnr,objectWithoutOptionalProperties:()=>Ihs,optional:()=>Sui,property:()=>bhs,record:()=>Fhs,set:()=>khs,string:()=>Phs,stringLiteral:()=>_hs,transform:()=>Bui,undiscriminatedUnion:()=>Qhs,union:()=>Lhs,unknown:()=>Dhs,withParsedProperties:()=>Pui});var wu={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function dd(e,t){return`Expected ${t}. Received ${Sgl(e)}.`}function Sgl(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 yx(e){return{...e,json:mhs(e.json),parse:mhs(e.parse)}}function mhs(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1467
1467
|
`)),{ok:!0,value:t}):n}}function pnr(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var PVe=class e extends Error{errors;constructor(t){super(t.map(pnr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var DVe=class e extends Error{errors;constructor(t){super(t.map(pnr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Gd(e){return{nullable:()=>Bgl(e),optional:()=>Sui(e),optionalNullable:()=>Tgl(e),transform:t=>Bui(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new DVe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new PVe(n.errors)}}}function Bgl(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>wu.NULLABLE};return{...t,...Gd(t)}}function Sui(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>wu.OPTIONAL};return{...t,...Gd(t)}}function Tgl(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>wu.OPTIONAL_NULLABLE};return{...t,...Gd(t)}}function Bui(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Gd(r)}}function hhs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:dd(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:dd(t,"bigint")}]}:{ok:!0,value:t},getType:()=>wu.BIGINT};return{...yx(e),...Gd(e)}}var Ogl=/^([+-]?\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 ghs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:dd(t,"string")}]}:Ogl.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:dd(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:dd(t,"Date object")}]},getType:()=>wu.DATE};return{...yx(e),...Gd(e)}}function bx(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...yx(r),...Gd(r)}}}function fnr(e){let t=new Set(e);return bx(wu.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:dd(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:dd(n,"enum")}]}:{ok:!0,value:n})()}function Ahs(e){let t=Tui(e);return{...t,...Gd(t)}}function Tui(e){return{parse:(t,r)=>RVe(e).parse(t,r),json:(t,r)=>RVe(e).json(t,r),getType:()=>RVe(e).getType()}}function RVe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Oui(e){return Object.entries(e)}function Fvt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function Qse(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function kvt(e){return Object.keys(e)}function yhs(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var Pgl=Object.prototype.hasOwnProperty;function iq(e){return{withParsedProperties:t=>Pui(e,t)}}function Pui(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(Pgl.call(t,a)){let c=t[a];s[a]=typeof c=="function"?c(o.value):c}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!Qse(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:dd(n,"object")}]};let o=new Set(Object.keys(t)),s=Fvt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Gd(r),...iq(r)}}function bhs(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function jse(e){return e.isProperty}var Dgl=Object.prototype.hasOwnProperty;function dnr(e){let t;function r(){if(t==null){t={};for(let[d,f]of Oui(e)){let m=jse(f)?f.rawKey:d,h=jse(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of Oui(e)){let m=jse(f)?f.rawKey:d,h=jse(f)?f.valueSchema:f;Rgl(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function c(){return i==null&&a(),i}function u(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>jse(f)?f.rawKey:d),_getParsedProperties:()=>kvt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return Ehs({value:d,requiredKeys:a(),requiredKeysSet:u(),getProperty:h=>{let g=r()[h];if(g!=null)return{transformedKey:g.parsedKey,transform:A=>{let b=[...m,h];return g.valueSchema.parse(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return Ehs({value:d,requiredKeys:c(),requiredKeysSet:l(),getProperty:h=>{let g=e[h];if(g!=null)return jse(g)?{transformedKey:g.rawKey,transform:A=>{let b=[...m,h];return g.valueSchema.json(A,{...f,breadcrumbsPrefix:b})}}:{transformedKey:h,transform:A=>{let b=[...m,h];return g.json(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>wu.OBJECT};return{...yx(p),...Gd(p),...iq(p),..._Oe(p)}}function Ehs({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!Qse(e))return{ok:!1,errors:[{path:s,message:dd(e,"object")}]};let a=t.length,c=[],u={};for(let l in e){if(!Dgl.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?u[d.transformedKey]=f.value:(u[l]=p,c.push(...f.errors))}else switch(i){case"fail":c.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":u[l]=p;break}}if(a>0)for(let l of t)l in e||c.push({path:s,message:`Missing required key "${l}"`});return c.length===0||o?{ok:!0,value:u}:{ok:!1,errors:c}}function _Oe(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>vhs({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>vhs({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>wu.OBJECT};return{...r,...Gd(r),...iq(r),..._Oe(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))t.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))r.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},getType:()=>wu.OBJECT};return{...n,...Gd(n),...iq(n),..._Oe(n)}}}}function vhs({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!Qse(t))return{ok:!1,errors:[{path:i,message:dd(t,"object")}]};let o=new Set(e),[s,a]=yhs(kvt(t),l=>o.has(l)),c=r(Fvt(t,a)),u=n(Fvt(t,s));return c.ok&&u.ok?{ok:!0,value:{...c.value,...u.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...u.ok?[]:u.errors]}}function Rgl(e){return!Fgl(e)}function Fgl(e){switch(e.getType()){case wu.ANY:case wu.UNKNOWN:case wu.OPTIONAL:case wu.OPTIONAL_NULLABLE:return!0;default:return!1}}function Ihs(e){return dnr(e)}function whs(e){let t={...Tui(e),_getRawProperties:()=>RVe(e)._getRawProperties(),_getParsedProperties:()=>RVe(e)._getParsedProperties()};return{...t,...Gd(t),...iq(t),..._Oe(t)}}function mnr(e){let t={parse:(r,n)=>Chs(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>Chs(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>wu.LIST};return{...yx(t),...Gd(t)}}function Chs(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:dd(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function xhs(e){return bx(wu.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:dd(r,`${e.toString()}`)}]})()}function _hs(e){return bx(wu.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:dd(r,`"${e}"`)}]})()}var Shs=bx(wu.ANY,e=>({ok:!0,value:e}));var Bhs=bx(wu.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dd(e,"boolean")}]});var Ths=bx(wu.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var Ohs=bx(wu.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dd(e,"number")}]});var Phs=bx(wu.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:dd(e,"string")}]});var Dhs=bx(wu.UNKNOWN,e=>({ok:!0,value:e}));var kgl=Object.prototype.hasOwnProperty;function Fhs(e,t){let r={parse:(n,i)=>Rhs({value:n,isKeyNumeric:e.getType()===wu.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Rhs({value:n,isKeyNumeric:e.getType()===wu.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>wu.RECORD};return{...yx(r),...Gd(r)}}function Rhs({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!Qse(e))return{ok:!1,errors:[{path:i,message:dd(e,"object")}]};let o={},s=[];for(let a in e){if(!kgl.call(e,a))continue;let c=e[a];if(c===void 0)continue;let u=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(u=d)}let l=r(u),p=n(c,u);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function khs(e){let t=mnr(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:dd(n,"Set")}]},getType:()=>wu.SET};return{...yx(r),...Gd(r)}}function Qhs(e){let t={parse:(r,n)=>Nhs((i,o)=>i.parse(r,o),e,n),json:(r,n)=>Nhs((i,o)=>i.json(r,o),e,n),getType:()=>wu.UNDISCRIMINATED_UNION};return{...yx(t),...Gd(t)}}function Nhs(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function jhs(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var Ngl=Object.prototype.hasOwnProperty;function Lhs(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=fnr(kvt(t)),o={parse:(s,a)=>Mhs({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:c=>i.parse(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.parse(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>Mhs({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:c=>i.json(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.json(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>wu.UNION};return{...yx(o),...Gd(o),...iq(o)}}function Mhs({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!Qse(e))return{ok:!1,errors:[{path:a,message:dd(e,"object")}]};let c=e[t],u={};for(let f in e)Ngl.call(e,f)&&f!==t&&(u[f]=e[f]);if(c==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(c);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...u}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(u,p);return d.ok?{ok:!0,value:{[r]:c,...d.value}}:d}var hnr=Ce.string();var gnr=Ce.enum_(["openai","anthropic","bedrock"]);var Anr=Ce.object({provider:gnr,model:hnr});var zui={};te(zui,{AnyAuthItem:()=>ynr,AnyAuthSchemesSchema:()=>bnr,ApiAuthSchema:()=>kVe,AuthSchemeDeclarationSchema:()=>hhe,AuthSchemeReferenceSchema:()=>FVe,AuthScope:()=>Onr,AuthVariable:()=>SOe,AvailabilitySchema:()=>jnr,AvailabilityStatusSchema:()=>QVe,AvailabilityUnionSchema:()=>Mnr,BaseTypeReferenceSchema:()=>Xnr,BasicAuthSchemeSchema:()=>Inr,BearerAuthSchemeSchema:()=>Bnr,EncodingSchema:()=>znr,EndpointSecuritySchema:()=>vnr,EndpointSecuritySchemaDetails:()=>Enr,EnvironmentSchema:()=>Gnr,HeaderAuthSchemeSchema:()=>Tnr,HttpHeaderSchema:()=>MVe,InferredAuthenticatedRequestHeader:()=>wnr,InferredBearerAuthSchema:()=>_nr,InferredGetTokenEndpointSchema:()=>xnr,InferredGetTokenEndpointSchemaObject:()=>Cnr,ListValidationSchema:()=>$nr,MapValidationSchema:()=>Hnr,MultipleBaseUrlsEnvironmentSchema:()=>Vnr,NumberValidationSchema:()=>Knr,OAuthAccessTokenRequestPropertiesSchema:()=>Pnr,OAuthAccessTokenResponsePropertiesSchema:()=>Dnr,OAuthGetTokenEndpointSchema:()=>Rnr,OAuthRefreshTokenEndpointSchema:()=>Nnr,OAuthRefreshTokenRequestPropertiesSchema:()=>Fnr,OAuthRefreshTokenResponsePropertiesSchema:()=>knr,OAuthSchemeSchema:()=>Qnr,ProtobufTypeSchema:()=>Unr,ServerVariableSchema:()=>jVe,SingleBaseUrlEnvironmentSchema:()=>qnr,StringValidationSchema:()=>Jnr,TokenBearerAuthSchema:()=>Snr,TypeReferenceDeclarationWithEnvOverride:()=>tir,TypeReferenceDeclarationWithEnvOverrideSchema:()=>eir,TypeReferenceDeclarationWithName:()=>Znr,ValidationSchema:()=>Ynr,WithAudiences:()=>ghe,WithAvailability:()=>Lnr,WithDocsSchema:()=>ob,WithEnvironmentVariable:()=>NVe,WithEnvironmentsSchema:()=>Wnr,WithHeadersSchema:()=>rir,WithName:()=>mhe,auth:()=>Rui,availability:()=>Fui,commons:()=>kui,encoding:()=>Nui,environments:()=>Qui,file:()=>jui,service:()=>Mui,types:()=>Lui,validation:()=>Uui});var Rui={};te(Rui,{AnyAuthItem:()=>ynr,AnyAuthSchemesSchema:()=>bnr,ApiAuthSchema:()=>kVe,AuthSchemeDeclarationSchema:()=>hhe,AuthSchemeReferenceSchema:()=>FVe,AuthScope:()=>Onr,AuthVariable:()=>SOe,BasicAuthSchemeSchema:()=>Inr,BearerAuthSchemeSchema:()=>Bnr,EndpointSecuritySchema:()=>vnr,EndpointSecuritySchemaDetails:()=>Enr,HeaderAuthSchemeSchema:()=>Tnr,InferredAuthenticatedRequestHeader:()=>wnr,InferredBearerAuthSchema:()=>_nr,InferredGetTokenEndpointSchema:()=>xnr,InferredGetTokenEndpointSchemaObject:()=>Cnr,OAuthAccessTokenRequestPropertiesSchema:()=>Pnr,OAuthAccessTokenResponsePropertiesSchema:()=>Dnr,OAuthGetTokenEndpointSchema:()=>Rnr,OAuthRefreshTokenEndpointSchema:()=>Nnr,OAuthRefreshTokenRequestPropertiesSchema:()=>Fnr,OAuthRefreshTokenResponsePropertiesSchema:()=>knr,OAuthSchemeSchema:()=>Qnr,TokenBearerAuthSchema:()=>Snr,WithEnvironmentVariable:()=>NVe});var ob=Ce.object({docs:Ce.string().optional()});var FVe=Ce.object({scheme:Ce.string()}).extend(ob);var ynr=Ce.undiscriminatedUnion([Ce.string(),FVe]);var bnr=Ce.object({any:Ce.list(ynr)}).extend(ob);var Enr=Ce.object({});var vnr=Ce.object({"endpoint-security":Enr}).extend(ob);var kVe=Ce.undiscriminatedUnion([Ce.string(),FVe,bnr,vnr]);var mhe=Ce.object({name:Ce.string().optional()});var NVe=Ce.object({env:Ce.string().optional()});var SOe=Ce.object({omit:Ce.boolean().optional()}).extend(NVe).extend(mhe);var Inr=Ce.object({scheme:Ce.stringLiteral("basic"),username:SOe.optional(),password:SOe.optional()}).extend(ob);var wnr=Ce.object({"response-property":Ce.string(),"header-name":Ce.string(),"value-prefix":Ce.string().optional()});var Cnr=Ce.object({endpoint:Ce.string(),"expiry-response-property":Ce.string().optional(),"authenticated-request-headers":Ce.list(wnr).optional()});var xnr=Ce.undiscriminatedUnion([Ce.string(),Cnr]);var _nr=Ce.object({scheme:Ce.stringLiteral("bearer"),"get-token":xnr}).extend(ob);var Snr=Ce.object({scheme:Ce.stringLiteral("bearer"),token:SOe.optional()}).extend(ob);var Bnr=Ce.undiscriminatedUnion([Snr,_nr]);var Tnr=Ce.object({header:Ce.string(),type:Ce.string().optional(),prefix:Ce.string().optional()}).extend(NVe).extend(mhe).extend(ob);var Onr=Ce.string();var Pnr=Ce.object({"client-id":Ce.string().optional(),"client-secret":Ce.string().optional(),scopes:Ce.string().optional()});var Dnr=Ce.object({"access-token":Ce.string().optional(),"expires-in":Ce.string().optional(),"refresh-token":Ce.string().optional()});var Rnr=Ce.object({endpoint:Ce.string(),"request-properties":Pnr.optional(),"response-properties":Dnr.optional()});var Fnr=Ce.object({"refresh-token":Ce.string()});var knr=Ce.object({"access-token":Ce.string().optional(),"expires-in":Ce.string().optional(),"refresh-token":Ce.string().optional()});var Nnr=Ce.object({endpoint:Ce.string(),"request-properties":Fnr.optional(),"response-properties":knr.optional()});var Qnr=Ce.object({scheme:Ce.stringLiteral("oauth"),type:Ce.stringLiteral("client-credentials"),scopes:Ce.list(Onr).optional(),"client-id-env":Ce.string().optional(),"client-secret-env":Ce.string().optional(),"token-prefix":Ce.string().optional(),"token-header":Ce.string().optional(),"get-token":Rnr,"refresh-token":Nnr.optional()}).extend(ob);var hhe=Ce.undiscriminatedUnion([Qnr,Tnr,Inr,Bnr]);var Fui={};te(Fui,{AvailabilitySchema:()=>jnr,AvailabilityStatusSchema:()=>QVe,AvailabilityUnionSchema:()=>Mnr});var QVe=Ce.enum_(["in-development","pre-release","deprecated","generally-available"]);var jnr=Ce.object({status:QVe,message:Ce.string().optional()});var Mnr=Ce.undiscriminatedUnion([QVe,jnr]);var kui={};te(kui,{WithAudiences:()=>ghe,WithAvailability:()=>Lnr,WithDocsSchema:()=>ob,WithName:()=>mhe});var ghe=Ce.object({audiences:Ce.list(Ce.string()).optional()});var Lnr=Ce.object({availability:Mnr.optional()});var Nui={};te(Nui,{EncodingSchema:()=>znr,ProtobufTypeSchema:()=>Unr});var Unr=Ce.object({type:Ce.string()});var znr=Ce.object({proto:Unr.optional()});var Qui={};te(Qui,{EnvironmentSchema:()=>Gnr,MultipleBaseUrlsEnvironmentSchema:()=>Vnr,ServerVariableSchema:()=>jVe,SingleBaseUrlEnvironmentSchema:()=>qnr,WithEnvironmentsSchema:()=>Wnr});var jVe=Ce.object({id:Ce.string(),default:Ce.string().optional(),values:Ce.list(Ce.string()).optional()});var Vnr=Ce.object({urls:Ce.record(Ce.string(),Ce.string()),"url-templates":Ce.record(Ce.string(),Ce.string()).optional(),"default-urls":Ce.record(Ce.string(),Ce.string()).optional(),variables:Ce.record(Ce.string(),Ce.list(jVe)).optional()}).extend(ghe).extend(ob);var qnr=Ce.object({url:Ce.string(),"default-url":Ce.string().optional(),"url-template":Ce.string().optional(),variables:Ce.list(jVe).optional()}).extend(ghe).extend(ob);var Gnr=Ce.undiscriminatedUnion([Ce.string(),qnr,Vnr]);var Wnr=Ce.object({"default-url":Ce.string().optional(),"default-environment":Ce.string().optional(),environments:Ce.record(Ce.string(),Gnr).optional()});var jui={};te(jui,{WithHeadersSchema:()=>rir});var $nr=Ce.object({minItems:Ce.number().optional(),maxItems:Ce.number().optional()});var Hnr=Ce.object({minProperties:Ce.number().optional(),maxProperties:Ce.number().optional()});var Knr=Ce.object({min:Ce.number().optional(),max:Ce.number().optional(),exclusiveMin:Ce.boolean().optional(),exclusiveMax:Ce.boolean().optional(),multipleOf:Ce.number().optional()});var Jnr=Ce.object({minLength:Ce.number().optional(),maxLength:Ce.number().optional(),pattern:Ce.string().optional(),format:Ce.string().optional()});var Ynr=Ce.undiscriminatedUnion([Jnr,Knr,$nr,Hnr]);var Xnr=Ce.object({default:Ce.unknown().optional(),encoding:znr.optional(),validation:Ynr.optional()}).extend(ob).extend(Lnr);var Znr=Ce.object({type:Ce.string()}).extend(Xnr).extend(mhe).extend(ghe);var eir=Ce.object({env:Ce.string().optional()}).extend(Znr);var tir=Ce.undiscriminatedUnion([Ce.string(),eir]);var MVe=tir;var rir=Ce.object({headers:Ce.record(Ce.string(),MVe).optional()});var Mui={};te(Mui,{HttpHeaderSchema:()=>MVe,TypeReferenceDeclarationWithEnvOverride:()=>tir,TypeReferenceDeclarationWithEnvOverrideSchema:()=>eir});var Lui={};te(Lui,{BaseTypeReferenceSchema:()=>Xnr,TypeReferenceDeclarationWithName:()=>Znr});var Uui={};te(Uui,{ListValidationSchema:()=>$nr,MapValidationSchema:()=>Hnr,NumberValidationSchema:()=>Knr,StringValidationSchema:()=>Jnr,ValidationSchema:()=>Ynr});var Vui={};te(Vui,{ApiConfigurationSchema:()=>Iir,ApiConfigurationSchemaInternal:()=>$Ve,ApiConfigurationV2Schema:()=>Eir,ApiConfigurationV2SettingsSchema:()=>JVe,ApiConfigurationV2SpecsSchema:()=>YVe,ApiDefinitionList:()=>oir,ApiDefinitionPathSchema:()=>Ahe,ApiDefinitionSchema:()=>iir,ApiDefinitionSettingsSchema:()=>VVe,ApiDefinitionWithOverridesSchema:()=>qVe,AsyncApiSettingsSchema:()=>KVe,AsyncApiSpecSchema:()=>mir,BaseApiSettingsSchema:()=>HVe,CoerceConstsTo:()=>sir,ConjureSchema:()=>dir,DefaultIntegerFormat:()=>air,ExampleStyle:()=>wir,FormParameterEncoding:()=>cir,GeneratorsConfigurationSchema:()=>Uhs,GeneratorsOpenApiObjectSchema:()=>Jir,GeneratorsOpenApiSchema:()=>Yir,GraphQlSpecSchema:()=>hir,Language:()=>Xir,MessageNamingSettingsSchema:()=>LVe,NamespacedApiConfigurationSchema:()=>vir,OpenApiExampleGenerationSchema:()=>uir,OpenApiFilterSchema:()=>lir,OpenApiSettingsSchema:()=>yhe,OpenApiSpecSchema:()=>gir,OpenRpcSpecSchema:()=>Air,OutputMetadataAuthor:()=>Cir,OutputMetadataSchema:()=>bhe,OverridesSchema:()=>$U,PathParameterOrder:()=>UVe,ProtobufApiDefinitionSchema:()=>WVe,ProtobufDefinitionSchema:()=>GVe,ProtobufSpecSchema:()=>yir,ReadmeCustomSectionSchema:()=>Zir,ReadmeEndpointObjectSchema:()=>eor,ReadmeEndpointSchema:()=>Mvt,ReadmeSchema:()=>tor,RemoveDiscriminantsFromSchemas:()=>zVe,RequestOrResponseExampleGenerationSchema:()=>Nvt,ResolveAliases:()=>fir,ResolveAliasesSchema:()=>pir,SpecSchema:()=>bir,UnionSettingsSchema:()=>nir,WhitelabelConfigurationSchema:()=>nor,WhitelabelGithubConfigurationSchema:()=>ror});var Ahe=Ce.string();var LVe=Ce.enum_(["v1","v2"]);var UVe=Ce.enum_(["url-order","spec-order"]);var zVe=Ce.enum_(["always","never"]);var nir=Ce.enum_(["v1"]);var VVe=Ce.object({"use-title":Ce.boolean().optional(),unions:nir.optional(),"message-naming":LVe.optional(),"respect-nullable-schemas":Ce.boolean().optional(),"only-include-referenced-schemas":Ce.boolean().optional(),"inline-path-parameters":Ce.boolean().optional(),"idiomatic-request-names":Ce.boolean().optional(),"wrap-references-to-nullable-in-optional":Ce.boolean().optional(),"coerce-optional-schemas-to-nullable":Ce.boolean().optional(),"group-environments-by-host":Ce.boolean().optional(),"remove-discriminants-from-schemas":zVe.optional(),"path-parameter-order":UVe.optional()});var $U=Ce.undiscriminatedUnion([Ce.string(),Ce.list(Ce.string())]);var qVe=Ce.object({path:Ahe,origin:Ce.string().optional(),overrides:$U.optional(),audiences:Ce.list(Ce.string()).optional(),settings:VVe.optional()});var GVe=Ce.object({target:Ce.string().optional(),root:Ce.string(),overrides:$U.optional(),"local-generation":Ce.boolean().optional(),"from-openapi":Ce.boolean().optional(),dependencies:Ce.list(Ce.string()).optional()});var WVe=Ce.object({proto:GVe});var iir=Ce.undiscriminatedUnion([Ahe,qVe,WVe]);var oir=Ce.list(iir);var $Ve=Ce.undiscriminatedUnion([Ahe,qVe,oir,WVe]);var sir=Ce.enum_(["literals","enums","enums-coerceable-to-literals"]);var HVe=Ce.object({"respect-nullable-schemas":Ce.boolean().optional(),"title-as-schema-name":Ce.boolean().optional(),"optional-additional-properties":Ce.boolean().optional(),"coerce-enums-to-literals":Ce.boolean().optional(),"idiomatic-request-names":Ce.boolean().optional(),"wrap-references-to-nullable-in-optional":Ce.boolean().optional(),"coerce-optional-schemas-to-nullable":Ce.boolean().optional(),"group-environments-by-host":Ce.boolean().optional(),"remove-discriminants-from-schemas":zVe.optional(),"path-parameter-order":UVe.optional(),"resolve-schema-collisions":Ce.boolean().optional(),"infer-forward-compatible":Ce.boolean().optional(),"infer-default-environment":Ce.boolean().optional(),"coerce-consts-to":sir.optional()});var KVe=Ce.object({"message-naming":LVe.optional()}).extend(HVe);var air=Ce.enum_(["int32","int64","uint32","uint64"]);var cir=Ce.enum_(["form","json"]);var Nvt=Ce.object({"max-depth":Ce.number().optional()});var uir=Ce.object({request:Nvt.optional(),response:Nvt.optional()});var lir=Ce.object({endpoints:Ce.list(Ce.string()).optional()});var pir=Ce.object({except:Ce.list(Ce.string()).optional()});var fir=Ce.undiscriminatedUnion([Ce.boolean(),pir]);var yhe=Ce.object({"only-include-referenced-schemas":Ce.boolean().optional(),"inline-path-parameters":Ce.boolean().optional(),"prefer-undiscriminated-unions-with-literals":Ce.boolean().optional(),"object-query-parameters":Ce.boolean().optional(),"respect-readonly-schemas":Ce.boolean().optional(),"respect-forward-compatible-enums":Ce.boolean().optional(),"use-bytes-for-binary-response":Ce.boolean().optional(),"default-form-parameter-encoding":cir.optional(),filter:lir.optional(),"example-generation":uir.optional(),"additional-properties-defaults-to":Ce.boolean().optional(),"type-dates-as-strings":Ce.boolean().optional(),"preserve-single-schema-oneof":Ce.boolean().optional(),"inline-all-of-schemas":Ce.boolean().optional(),"resolve-aliases":fir.optional(),"group-multi-api-environments":Ce.boolean().optional(),"default-integer-format":air.optional()}).extend(HVe);var JVe=Ce.object({}).extend(yhe).extend(KVe);var dir=Ce.object({conjure:Ce.string()});var mir=Ce.object({asyncapi:Ce.string(),origin:Ce.string().optional(),overrides:$U.optional(),namespace:Ce.string().optional(),settings:KVe.optional()});var hir=Ce.object({graphql:Ce.string(),origin:Ce.string().optional(),overrides:Ce.string().optional(),name:Ce.string().optional()});var gir=Ce.object({openapi:Ce.string(),origin:Ce.string().optional(),overrides:$U.optional(),overlays:Ce.string().optional(),namespace:Ce.string().optional(),settings:yhe.optional()});var Air=Ce.object({openrpc:Ce.string(),overrides:$U.optional(),namespace:Ce.string().optional()});var yir=Ce.object({proto:GVe});var bir=Ce.undiscriminatedUnion([gir,mir,yir,Air,hir]);var YVe=Ce.undiscriminatedUnion([Ce.list(bir),dir]);var Eir=Ce.object({auth:kVe.optional(),"auth-schemes":Ce.record(Ce.string(),hhe).optional(),specs:YVe,settings:JVe.optional()}).extend(rir).extend(Wnr);var vir=Ce.object({namespaces:Ce.record(Ce.string(),$Ve)});var Iir=Ce.undiscriminatedUnion([$Ve,vir,Eir]);var wir=Ce.enum_(["minimal","comprehensive"]);var Cir=Ce.object({name:Ce.string(),email:Ce.string()});var bhe=Ce.object({description:Ce.string().optional(),authors:Ce.list(Cir).optional()});var Qvt=Ce.object({name:Ce.string()});var Ehe=Ce.object({teams:Ce.list(Qvt).optional(),users:Ce.list(Qvt).optional()});var xir=Ce.object({auth:kVe.optional(),"auth-schemes":Ce.record(Ce.string(),hhe).optional(),headers:Ce.record(Ce.string(),MVe).optional(),settings:JVe.optional(),specs:YVe.optional()});var _ir=Ce.object({url:Ce.string().optional(),"package-name":Ce.string(),token:Ce.string().optional()});var Sir=Ce.object({path:Ce.string()});var Bir=Ce.object({keyId:Ce.string(),password:Ce.string(),secretKey:Ce.string()});var Tir=Ce.object({url:Ce.string().optional(),coordinate:Ce.string(),username:Ce.string().optional(),password:Ce.string().optional(),signature:Bir.optional()});var Oir=Ce.object({url:Ce.string().optional(),"package-name":Ce.string(),token:Ce.string().optional()});var Pir=Ce.object({url:Ce.string().optional(),"package-name":Ce.string(),"api-key":Ce.string().optional()});var Dir=Ce.object({"api-key":Ce.string(),"workspace-id":Ce.string(),"collection-id":Ce.string().optional()});var Rir=Ce.object({keywords:Ce.list(Ce.string()).optional(),"documentation-link":Ce.string().optional(),"homepage-link":Ce.string().optional()}).extend(bhe);var Fir=Ce.object({url:Ce.string().optional(),"package-name":Ce.string(),token:Ce.string().optional(),username:Ce.string().optional(),password:Ce.string().optional(),metadata:Rir.optional()});var kir=Ce.object({url:Ce.string().optional(),"package-name":Ce.string(),"api-key":Ce.string().optional()});var Nir=Ce.union("location",{npm:Oir,maven:Tir,pypi:Fir,postman:Dir,"local-file-system":Sir,nuget:Pir,rubygems:kir,crates:_ir}).transform({transform:e=>e,untransform:e=>e});var Qir=Ce.object({custom:Ce.string()});var jir=Ce.enum_(["MIT","Apache-2.0"]);var HU=Ce.undiscriminatedUnion([jir,Qir]);var jvt=Ce.object({"package-description":Ce.string().optional(),email:Ce.string().optional(),"reference-url":Ce.string().optional(),author:Ce.string().optional(),license:HU.optional()});var Mir=Ce.object({path:Ce.string()});var Lir=Ce.enum_(["commit","release"]);var Uir=Ce.object({repository:Ce.string(),license:HU.optional(),mode:Lir.optional()});var zir=Ce.object({repository:Ce.string(),branch:Ce.string().optional(),license:HU.optional(),mode:Ce.stringLiteral("pull-request"),reviewers:Ehe.optional()});var Vir=Ce.object({repository:Ce.string(),license:HU.optional(),mode:Ce.stringLiteral("push"),branch:Ce.string().optional()});var qir=Ce.enum_(["pull-request","push"]);var Gir=Ce.object({uri:Ce.string(),token:Ce.string(),mode:qir.optional(),branch:Ce.string().optional(),license:HU.optional()});var Wir=Ce.undiscriminatedUnion([Gir,Uir,zir,Vir]);var $ir=Ce.object({name:Ce.string(),version:Ce.string(),output:Nir.optional(),github:Wir.optional(),config:Ce.unknown().optional(),metadata:jvt.optional(),keywords:Ce.list(Ce.string()).optional(),snippets:Mir.optional(),"ir-version":Ce.string().optional(),"smart-casing":Ce.boolean().optional(),api:xir.optional(),"disable-examples":Ce.boolean().optional(),"publish-metadata":jvt.optional(),autorelease:Ce.boolean().optional()});var Hir=Ce.object({audiences:Ce.list(Ce.string()).optional(),generators:Ce.list($ir),metadata:bhe.optional(),reviewers:Ehe.optional()});var Kir=Ce.object({enabled:Ce.boolean()});var Jir=Ce.object({path:Ce.string(),origin:Ce.string().optional(),overrides:Ce.string().optional(),"disable-examples":Ce.boolean().optional(),settings:yhe});var Yir=Ce.undiscriminatedUnion([Jir,Ce.string()]);var Xir=Ce.enum_(["java","python","go","ruby","csharp","typescript","php","rust","swift"]);var Zir=Ce.object({title:Ce.string(),language:Xir,content:Ce.string()});var eor=Ce.object({method:Ce.string(),path:Ce.string(),stream:Ce.boolean().optional()});var Mvt=Ce.undiscriminatedUnion([Ce.string(),eor]);var tor=Ce.object({bannerLink:Ce.string().optional(),introduction:Ce.string().optional(),apiReferenceLink:Ce.string().optional(),apiName:Ce.string().optional(),disabledSections:Ce.list(Ce.string()).optional(),defaultEndpoint:Mvt.optional(),features:Ce.record(Ce.string(),Ce.list(Mvt)).optional(),customSections:Ce.list(Zir).optional(),exampleStyle:wir.optional()});var ror=Ce.object({username:Ce.string(),email:Ce.string(),token:Ce.string()});var nor=Ce.object({github:ror.optional()});var Uhs=Ce.object({"auth-schemes":Ce.record(Ce.string(),hhe).optional(),api:Iir.optional(),whitelabel:nor.optional(),metadata:bhe.optional(),readme:tor.optional(),"default-group":Ce.string().optional(),aliases:Ce.record(Ce.string(),Ce.list(Ce.string())).optional(),groups:Ce.record(Ce.string(),Hir).optional(),reviewers:Ehe.optional(),replay:Kir.optional(),ai:Anr.optional(),autorelease:Ce.boolean().optional(),openapi:Yir.optional(),"openapi-overrides":Ce.string().optional(),"spec-origin":Ce.string().optional(),"async-api":Ce.string().optional(),"api-settings":VVe.optional()});var qui={};te(qui,{CratesOutputLocationSchema:()=>_ir,GeneratorApiSettingsSchema:()=>xir,GeneratorGroupSchema:()=>Hir,GeneratorInvocationSchema:()=>$ir,GeneratorOutputSchema:()=>Nir,GeneratorPublishMetadataSchema:()=>jvt,GeneratorSnippetsSchema:()=>Mir,GithubCommitAndReleaseMode:()=>Lir,GithubCommitAndReleaseSchema:()=>Uir,GithubConfigurationSchema:()=>Wir,GithubPullRequestSchema:()=>zir,GithubPushSchema:()=>Vir,GithubSelfhostedMode:()=>qir,GithubSelfhostedSchema:()=>Gir,LocalFileSystemOutputLocationSchema:()=>Sir,MavenOutputLocationSchema:()=>Tir,MavenOutputSignatureSchema:()=>Bir,NpmOutputLocationSchema:()=>Oir,NugetOutputLocationSchema:()=>Pir,PostmanOutputLocationSchema:()=>Dir,PypiOutputLocationSchema:()=>Fir,PypiOutputMetadataSchema:()=>Rir,RubyGemsOutputLocationSchema:()=>kir});var Gui={};te(Gui,{GithubLicenseCustomSchema:()=>Qir,GithubLicenseSchema:()=>HU,GithubLicenseType:()=>jir});var Wui={};te(Wui,{ReplayConfigSchema:()=>Kir});var $ui={};te($ui,{ReviewerSchema:()=>Qvt,ReviewersSchema:()=>Ehe});function zhs(e){return e?.specs!=null}function Vhs(e){return e?.asyncapi!=null}function qhs(e){return e?.conjure!=null}function Ghs(e){return e?.graphql!=null}function Whs(e){return e?.namespaces!=null}function $hs(e){return e?.openapi!=null}function Hhs(e){return e?.openrpc!=null}function Khs(e){return e?.proto!=null}var Qgl={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!0,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,groupEnvironmentsByHost:!1,removeDiscriminantsFromSchemas:In.RemoveDiscriminantsFromSchemas.Always,inferDefaultEnvironment:!0};function jgl(e){let{defaults:t,options:r,overrides:n,overrideOnly:i=new Set,undefinedIfAbsent:o=new Set}=e,s={};for(let a of Object.keys(t))i.has(a)?s[a]=n?.[a]!==void 0?n[a]:t[a]:o.has(a)?s[a]=n?.[a]!==void 0?n[a]:r?.[a]!==void 0?r[a]:void 0:s[a]=n?.[a]??r?.[a]??t[a];return s}function BOe({options:e,overrides:t}){return jgl({defaults:Qgl,options:e,overrides:t})}oA();oA();St();var XVe={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return XVe._visit(this,t)}}),_visit:(e,t)=>e.type==="protobuf"?t.protobuf(e):t._other(e)};var Ex={basic:e=>({...e,type:"basic",_visit:function(t){return Ex._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Ex._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Ex._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Ex._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Ex._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var uT={openapi:e=>({...e,type:"openapi",_visit:function(t){return uT._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return uT._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var lc={primitive:e=>({value:e,type:"primitive",_visit:function(t){return lc._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return lc._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return lc._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return lc._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return lc._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return lc._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return lc._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return lc._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return lc._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"null":return t.null(e);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var vhe={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return vhe._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return vhe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var Ihe={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ihe._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ihe._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 hs={int:e=>({value:e,type:"int",_visit:function(t){return hs._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return hs._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return hs._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return hs._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return hs._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return hs._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return hs._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return hs._visit(this,t)}}),datetimeRfc2822:e=>({value:e,type:"datetimeRfc2822",_visit:function(t){return hs._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return hs._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return hs._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return hs._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"datetimeRfc2822":return t.datetimeRfc2822(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var Qg={};te(Qg,{AsymmetricAlgorithm:()=>whe,Availability:()=>vx,CustomCodeSample:()=>b$,DiscriminatorContext:()=>Kui,EndpointExample:()=>KU,EndpointResponseExample:()=>JU,HttpMethod:()=>Ix,LiteralSchemaValue:()=>pA,MultipartRequestPropertyEncoding:()=>Jui,MultipartSchema:()=>E$,OneOfSchema:()=>v$,Pagination:()=>$w,PrimitiveSchemaValue:()=>ol,Request:()=>oq,Response:()=>JS,RetriesConfiguration:()=>Lvt,Schema:()=>ba,SupportedSdkLanguage:()=>wx,WebhookHttpMethod:()=>Yui,WebhookPayloadComponent:()=>Uvt,WebhookSignatureAlgorithm:()=>zvt,WebhookSignatureEncoding:()=>Xui,WebhookSignatureVerification:()=>TOe,WebhookTimestampFormat:()=>ior,WebsocketMessageOrigin:()=>Zui});var Mgl={RsaSha256:"rsa-sha256",RsaSha384:"rsa-sha384",RsaSha512:"rsa-sha512",EcdsaSha256:"ecdsa-sha256",EcdsaSha384:"ecdsa-sha384",EcdsaSha512:"ecdsa-sha512",Ed25519:"ed25519"},whe={...Mgl,_visit:(e,t)=>{switch(e){case whe.RsaSha256:return t.rsaSha256();case whe.RsaSha384:return t.rsaSha384();case whe.RsaSha512:return t.rsaSha512();case whe.EcdsaSha256:return t.ecdsaSha256();case whe.EcdsaSha384:return t.ecdsaSha384();case whe.EcdsaSha512:return t.ecdsaSha512();case whe.Ed25519:return t.ed25519();default:return t._other()}}};var Lgl={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated"},vx={...Lgl,_visit:(e,t)=>{switch(e){case vx.GenerallyAvailable:return t.generallyAvailable();case vx.Beta:return t.beta();case vx.Deprecated:return t.deprecated();default:return t._other()}}};var b$={language:e=>({...e,type:"language",_visit:function(t){return b$._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return b$._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 Ugl={Data:"data",Protocol:"protocol"},Kui={...Ugl,_visit:(e,t)=>{switch(e){case Kui.Data:return t.data();case Kui.Protocol:return t.protocol();default:return t._other()}}};var KU={unknown:e=>({value:e,type:"unknown",_visit:function(t){return KU._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return KU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var JU={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return JU._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return JU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var zgl={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE"},Ix={...zgl,_visit:(e,t)=>{switch(e){case Ix.Get:return t.get();case Ix.Post:return t.post();case Ix.Put:return t.put();case Ix.Patch:return t.patch();case Ix.Delete:return t.delete();case Ix.Head:return t.head();case Ix.Options:return t.options();case Ix.Trace:return t.trace();default:return t._other()}}};var pA={boolean:e=>({value:e,type:"boolean",_visit:function(t){return pA._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return pA._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 Vgl={Json:"json",Form:"form"},Jui={...Vgl,_visit:(e,t)=>{switch(e){case Jui.Json:return t.json();case Jui.Form:return t.form();default:return t._other()}}};var E$={file:e=>({...e,type:"file",_visit:function(t){return E$._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return E$._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var v$={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return v$._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return v$._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var $w={cursor:e=>({...e,type:"cursor",_visit:function(t){return $w._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return $w._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return $w._visit(this,t)}}),uri:e=>({...e,type:"uri",_visit:function(t){return $w._visit(this,t)}}),path:e=>({...e,type:"path",_visit:function(t){return $w._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);case"uri":return t.uri(e);case"path":return t.path(e);default:return t._other(e)}}};var ol={int:e=>({...e,type:"int",_visit:function(t){return ol._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ol._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return ol._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return ol._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return ol._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return ol._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ol._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return ol._visit(this,e)}}),datetimeRfc2822:()=>({type:"datetimeRfc2822",_visit:function(e){return ol._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return ol._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return ol._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ol._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"datetimeRfc2822":return t.datetimeRfc2822();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var oq={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return oq._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return oq._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return oq._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return oq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var JS={file:e=>({...e,type:"file",_visit:function(t){return JS._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return JS._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return JS._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return JS._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return JS._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return JS._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return JS._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Lvt={disabled:e=>({value:e,type:"disabled",_visit:function(t){return Lvt._visit(this,t)}}),_visit:(e,t)=>e.type==="disabled"?t.disabled(e.value):t._other(e)};var ba={primitive:e=>({...e,type:"primitive",_visit:function(t){return ba._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ba._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ba._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ba._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ba._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ba._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ba._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ba._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ba._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ba._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ba._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var qgl={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"},wx={...qgl,_visit:(e,t)=>{switch(e){case wx.Curl:return t.curl();case wx.Python:return t.python();case wx.Javascript:return t.javascript();case wx.Typescript:return t.typescript();case wx.Go:return t.go();case wx.Ruby:return t.ruby();case wx.Csharp:return t.csharp();case wx.Java:return t.java();case wx.Js:return t.js();case wx.Node:return t.node();case wx.Ts:return t.ts();case wx.Nodets:return t.nodets();case wx.Golang:return t.golang();case wx.Dotnet:return t.dotnet();case wx.Jvm:return t.jvm();default:return t._other()}}};var Ggl={Get:"GET",Post:"POST"},Yui={...Ggl,_visit:(e,t)=>{switch(e){case Yui.Get:return t.get();case Yui.Post:return t.post();default:return t._other()}}};var Wgl={Body:"body",Timestamp:"timestamp",NotificationUrl:"notification-url",MessageId:"message-id"},Uvt={...Wgl,_visit:(e,t)=>{switch(e){case Uvt.Body:return t.body();case Uvt.Timestamp:return t.timestamp();case Uvt.NotificationUrl:return t.notificationUrl();case Uvt.MessageId:return t.messageId();default:return t._other()}}};var $gl={Sha256:"sha256",Sha1:"sha1",Sha384:"sha384",Sha512:"sha512"},zvt={...$gl,_visit:(e,t)=>{switch(e){case zvt.Sha256:return t.sha256();case zvt.Sha1:return t.sha1();case zvt.Sha384:return t.sha384();case zvt.Sha512:return t.sha512();default:return t._other()}}};var Hgl={Base64:"base64",Hex:"hex"},Xui={...Hgl,_visit:(e,t)=>{switch(e){case Xui.Base64:return t.base64();case Xui.Hex:return t.hex();default:return t._other()}}};var TOe={hmac:e=>({...e,type:"hmac",_visit:function(t){return TOe._visit(this,t)}}),asymmetric:e=>({...e,type:"asymmetric",_visit:function(t){return TOe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"hmac":return t.hmac(e);case"asymmetric":return t.asymmetric(e);default:return t._other(e)}}};var Kgl={UnixSeconds:"unix-seconds",UnixMillis:"unix-millis",Iso8601:"iso8601"},ior={...Kgl,_visit:(e,t)=>{switch(e){case ior.UnixSeconds:return t.unixSeconds();case ior.UnixMillis:return t.unixMillis();case ior.Iso8601:return t.iso8601();default:return t._other()}}};var Jgl={Client:"client",Server:"server"},Zui={...Jgl,_visit:(e,t)=>{switch(e){case Zui.Client:return t.client();case Zui.Server:return t.server();default:return t._other()}}};var vj={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return vj._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return vj._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var xi={int:e=>({...e,type:"int",_visit:function(t){return xi._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return xi._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return xi._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return xi._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return xi._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return xi._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return xi._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return xi._visit(this,t)}}),datetimeRfc2822:e=>({...e,type:"datetimeRfc2822",_visit:function(t){return xi._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return xi._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return xi._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return xi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"datetimeRfc2822":return t.datetimeRfc2822(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var $P={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return $P._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return $P._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return $P._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return $P._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var Rh={file:e=>({...e,type:"file",_visit:function(t){return Rh._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Rh._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Rh._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Rh._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Rh._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Rh._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Rh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Fr={primitive:e=>({...e,type:"primitive",_visit:function(t){return Fr._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Fr._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Fr._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Fr._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Fr._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Fr._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Fr._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Fr._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Fr._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Fr._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Fr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Ea={};te(Ea,{AllOfPropertyConflict:()=>o6e,ArraySchema:()=>Ror,ArraySchemaWithExample:()=>zsr,AsymmetricAlgorithm:()=>For,AsymmetricWebhookSignatureVerification:()=>Nor,Availability:()=>Aor,Base64WithExample:()=>Vsr,BasicSecurityScheme:()=>uor,BearerSecurityScheme:()=>lor,BooleanSchema:()=>Qor,BooleanWithExample:()=>qsr,BytesResponse:()=>c6e,CasingOverrides:()=>Ior,CommonProperty:()=>jor,CommonPropertyWithExample:()=>Gsr,CursorPagination:()=>Mor,CustomCodeSample:()=>Vor,CustomCodeSampleLanguage:()=>Lor,CustomCodeSampleSdk:()=>zor,CustomPagination:()=>qor,DateWithExample:()=>Wsr,DatetimeWithExample:()=>Wvt,DiscriminatedOneOfSchema:()=>Gor,DiscriminatedOneOfSchemaWithExample:()=>$sr,DiscriminatorContext:()=>u6e,DoubleSchema:()=>Wor,DoubleWithExample:()=>Hsr,Encoding:()=>dor,Endpoint:()=>usr,EndpointExample:()=>f6e,EndpointResponseExample:()=>Kor,EndpointSdkName:()=>C$,EndpointSecurity:()=>d6e,EndpointWithExample:()=>Cgs,EnumSchema:()=>r6e,EnumSchemaWithExample:()=>rar,EnumValue:()=>xhe,ErrorExample:()=>Xor,FernExample:()=>$or,FileResponse:()=>v6e,FileSchema:()=>ssr,FloatWithExample:()=>nar,FormUrlEncodedRequest:()=>nsr,FullEndpointExample:()=>Yor,FullExample:()=>Vm,FullObjectExample:()=>Oor,FullOneOfExample:()=>Por,GlobalHeader:()=>lsr,GlobalSecurity:()=>psr,Header:()=>She,HeaderExample:()=>l6e,HeaderSecurityScheme:()=>mor,HeaderWithExample:()=>Phe,HmacWebhookSignatureVerification:()=>hsr,HttpEndpointServer:()=>m6e,HttpError:()=>Zor,HttpErrorWithExample:()=>Ksr,HttpMethod:()=>h6e,IdempotencyHeader:()=>gsr,Int64WithExample:()=>iar,IntSchema:()=>Asr,IntWithExample:()=>oar,JsonRequest:()=>isr,JsonRequestWithExample:()=>Ysr,JsonResponse:()=>I6e,JsonResponseWithExample:()=>P6e,KeyValuePair:()=>Dor,LiteralExample:()=>Bor,LiteralSchema:()=>x6e,LiteralSchemaValue:()=>ysr,LongSchema:()=>bsr,MapSchema:()=>Isr,MapSchemaWithExample:()=>lar,MultipartFormDataWebhookPayload:()=>wsr,MultipartFormDataWebhookPayloadWithExample:()=>par,MultipartRequest:()=>b6e,MultipartRequestProperty:()=>Bhe,MultipartRequestPropertyEncoding:()=>osr,MultipartSchema:()=>asr,NamedFullExample:()=>nk,Namespace:()=>hor,NamespaceId:()=>gor,NullExample:()=>Tor,NullableSchema:()=>Csr,NullableSchemaWithExample:()=>far,OauthSecurityScheme:()=>wor,ObjectProperty:()=>xsr,ObjectPropertyConflictInfo:()=>_6e,ObjectPropertyWithExample:()=>dar,ObjectSchema:()=>_sr,ObjectSchemaWithExample:()=>mar,OctetStreamRequest:()=>E6e,OffsetPagination:()=>esr,OneOfSchema:()=>Ssr,OneOfSchemaWithExample:()=>har,OpenApiIntermediateRepresentation:()=>wgs,OpenApiSource:()=>bor,OptionalSchema:()=>Lsr,OptionalSchemaWithExample:()=>Aar,Pagination:()=>g6e,ParseFormUrlEncodedRequest:()=>Xsr,ParseMultipartRequest:()=>Zsr,ParseOctetStreamRequest:()=>ear,PathPagination:()=>tsr,PathParameter:()=>A6e,PathParameterExample:()=>Jor,PathParameterWithExample:()=>Jsr,PrimitiveExample:()=>n6e,PrimitiveSchema:()=>Ohe,PrimitiveSchemaValue:()=>vsr,PrimitiveSchemaValueWithExample:()=>uar,PrimitiveSchemaWithExample:()=>R6e,PropertyKey:()=>i6e,ProtobufEncoding:()=>por,ProtobufSource:()=>Eor,QueryParameter:()=>y6e,QueryParameterExample:()=>p6e,QueryParameterWithExample:()=>O6e,QuerySecurityScheme:()=>Cor,ReferencedSchema:()=>x$,Request:()=>csr,RequestWithExample:()=>tar,Response:()=>w6e,ResponseWithExample:()=>D6e,RetriesConfiguration:()=>C6e,Schema:()=>$u,SchemaId:()=>HP,SchemaWithExample:()=>Uf,Schemas:()=>Tsr,SdkGroup:()=>yor,SdkGroupInfo:()=>Osr,SdkGroupName:()=>Che,SecurityScheme:()=>xor,SecuritySchemeId:()=>_he,Server:()=>Gvt,ServerVariable:()=>_or,Source:()=>vor,StatusCode:()=>I$,StreamingResponseExample:()=>Hor,StringSchema:()=>Esr,StringSchemaWithExample:()=>sar,SupportedSdkLanguage:()=>Uor,Tag:()=>Sor,TagId:()=>KP,Tags:()=>Psr,TextResponse:()=>The,Uint64WithExample:()=>aar,UintWithExample:()=>car,UnDiscriminatedOneOfSchema:()=>Bsr,UnDiscriminatedOneOfSchemaWithExample:()=>gar,UnknownSchema:()=>Usr,UnknownSchemaWithExample:()=>yar,UriPagination:()=>rsr,Webhook:()=>Dsr,WebhookExampleCall:()=>S6e,WebhookHttpMethod:()=>B6e,WebhookPayloadComponent:()=>fsr,WebhookPayloadFormat:()=>dsr,WebhookSignatureAlgorithm:()=>msr,WebhookSignatureEncoding:()=>s6e,WebhookSignatureVerification:()=>T6e,WebhookTimestamp:()=>a6e,WebhookTimestampFormat:()=>kor,WebhookWithExample:()=>xgs,WebsocketChannel:()=>Msr,WebsocketHandshake:()=>Rsr,WebsocketHandshakeWithExample:()=>_gs,WebsocketMessageExample:()=>Qsr,WebsocketMessageOrigin:()=>Fsr,WebsocketMessageSchema:()=>ksr,WebsocketServer:()=>Nsr,WebsocketSessionExample:()=>jsr,WithAvailability:()=>us,WithDescription:()=>mn,WithEncoding:()=>_x,WithInline:()=>Lf,WithName:()=>Nc,WithNamespace:()=>oc,WithSdkGroupName:()=>xu,WithSdkMethodName:()=>w$,WithSource:()=>$o,WithStatusCode:()=>YU,WithTitle:()=>_u,commons:()=>oli,example:()=>sli,finalIr:()=>ali,parseIr:()=>cli});var oli={};te(oli,{BasicSecurityScheme:()=>uor,BearerSecurityScheme:()=>lor,Encoding:()=>dor,HeaderSecurityScheme:()=>mor,Namespace:()=>hor,NamespaceId:()=>gor,OauthSecurityScheme:()=>wor,OpenApiSource:()=>bor,ProtobufEncoding:()=>por,ProtobufSource:()=>Eor,QuerySecurityScheme:()=>Cor,SchemaId:()=>HP,SdkGroup:()=>yor,SdkGroupName:()=>Che,SecurityScheme:()=>xor,SecuritySchemeId:()=>_he,Server:()=>Gvt,ServerVariable:()=>_or,Source:()=>vor,StatusCode:()=>I$,Tag:()=>Sor,TagId:()=>KP,WithAvailability:()=>us,WithDescription:()=>mn,WithEncoding:()=>_x,WithInline:()=>Lf,WithName:()=>Nc,WithNamespace:()=>oc,WithSdkGroupName:()=>xu,WithSdkMethodName:()=>w$,WithSource:()=>$o,WithStatusCode:()=>YU,WithTitle:()=>_u});var K={};te(K,{JsonError:()=>ZVe,ParseError:()=>e6e,any:()=>ugs,bigint:()=>Yhs,boolean:()=>lgs,booleanLiteral:()=>ags,date:()=>Xhs,discriminant:()=>Egs,enum_:()=>sor,getObjectLikeUtils:()=>sq,getObjectUtils:()=>OOe,getSchemaUtils:()=>Wd,isProperty:()=>Lse,lazy:()=>Zhs,lazyObject:()=>ogs,list:()=>cor,never:()=>pgs,number:()=>fgs,object:()=>aor,objectWithoutOptionalProperties:()=>igs,optional:()=>eli,property:()=>tgs,record:()=>ggs,set:()=>Ags,string:()=>dgs,stringLiteral:()=>cgs,transform:()=>tli,undiscriminatedUnion:()=>bgs,union:()=>Igs,unknown:()=>mgs,withParsedProperties:()=>ili});var Cu={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function md(e,t){return`Expected ${t}. Received ${Ygl(e)}.`}function Ygl(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 Cx(e){return{...e,json:Jhs(e.json),parse:Jhs(e.parse)}}function Jhs(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1468
|
-
`)),{ok:!0,value:t}):n}}function oor(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var ZVe=class e extends Error{errors;constructor(t){super(t.map(oor).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var e6e=class e extends Error{errors;constructor(t){super(t.map(oor).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Wd(e){return{nullable:()=>Xgl(e),optional:()=>eli(e),optionalNullable:()=>Zgl(e),transform:t=>tli(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new e6e(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new ZVe(n.errors)}}}function Xgl(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.NULLABLE};return{...t,...Wd(t)}}function eli(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.OPTIONAL};return{...t,...Wd(t)}}function Zgl(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.OPTIONAL_NULLABLE};return{...t,...Wd(t)}}function tli(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Wd(r)}}function Yhs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:md(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:md(t,"bigint")}]}:{ok:!0,value:t},getType:()=>Cu.BIGINT};return{...Cx(e),...Wd(e)}}var eAl=/^([+-]?\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 Xhs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:md(t,"string")}]}:eAl.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:md(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:md(t,"Date object")}]},getType:()=>Cu.DATE};return{...Cx(e),...Wd(e)}}function xx(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Cx(r),...Wd(r)}}}function sor(e){let t=new Set(e);return xx(Cu.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:md(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:md(n,"enum")}]}:{ok:!0,value:n})()}function Zhs(e){let t=rli(e);return{...t,...Wd(t)}}function rli(e){return{parse:(t,r)=>t6e(e).parse(t,r),json:(t,r)=>t6e(e).json(t,r),getType:()=>t6e(e).getType()}}function t6e(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function nli(e){return Object.entries(e)}function Vvt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function Mse(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function qvt(e){return Object.keys(e)}function egs(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var tAl=Object.prototype.hasOwnProperty;function sq(e){return{withParsedProperties:t=>ili(e,t)}}function ili(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(tAl.call(t,a)){let c=t[a];s[a]=typeof c=="function"?c(o.value):c}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!Mse(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:md(n,"object")}]};let o=new Set(Object.keys(t)),s=Vvt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Wd(r),...sq(r)}}function tgs(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Lse(e){return e.isProperty}var rAl=Object.prototype.hasOwnProperty;function aor(e){let t;function r(){if(t==null){t={};for(let[d,f]of nli(e)){let m=Lse(f)?f.rawKey:d,h=Lse(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of nli(e)){let m=Lse(f)?f.rawKey:d,h=Lse(f)?f.valueSchema:f;nAl(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function c(){return i==null&&a(),i}function u(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Lse(f)?f.rawKey:d),_getParsedProperties:()=>qvt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return rgs({value:d,requiredKeys:a(),requiredKeysSet:u(),getProperty:h=>{let g=r()[h];if(g!=null)return{transformedKey:g.parsedKey,transform:A=>{let b=[...m,h];return g.valueSchema.parse(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return rgs({value:d,requiredKeys:c(),requiredKeysSet:l(),getProperty:h=>{let g=e[h];if(g!=null)return Lse(g)?{transformedKey:g.rawKey,transform:A=>{let b=[...m,h];return g.valueSchema.json(A,{...f,breadcrumbsPrefix:b})}}:{transformedKey:h,transform:A=>{let b=[...m,h];return g.json(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>Cu.OBJECT};return{...Cx(p),...Wd(p),...sq(p),...OOe(p)}}function rgs({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!Mse(e))return{ok:!1,errors:[{path:s,message:md(e,"object")}]};let a=t.length,c=[],u={};for(let l in e){if(!rAl.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?u[d.transformedKey]=f.value:(u[l]=p,c.push(...f.errors))}else switch(i){case"fail":c.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":u[l]=p;break}}if(a>0)for(let l of t)l in e||c.push({path:s,message:`Missing required key "${l}"`});return c.length===0||o?{ok:!0,value:u}:{ok:!1,errors:c}}function OOe(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>ngs({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>ngs({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Cu.OBJECT};return{...r,...Wd(r),...sq(r),...OOe(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))t.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))r.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},getType:()=>Cu.OBJECT};return{...n,...Wd(n),...sq(n),...OOe(n)}}}}function ngs({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!Mse(t))return{ok:!1,errors:[{path:i,message:md(t,"object")}]};let o=new Set(e),[s,a]=egs(qvt(t),l=>o.has(l)),c=r(Vvt(t,a)),u=n(Vvt(t,s));return c.ok&&u.ok?{ok:!0,value:{...c.value,...u.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...u.ok?[]:u.errors]}}function nAl(e){return!iAl(e)}function iAl(e){switch(e.getType()){case Cu.ANY:case Cu.UNKNOWN:case Cu.OPTIONAL:case Cu.OPTIONAL_NULLABLE:return!0;default:return!1}}function igs(e){return aor(e)}function ogs(e){let t={...rli(e),_getRawProperties:()=>t6e(e)._getRawProperties(),_getParsedProperties:()=>t6e(e)._getParsedProperties()};return{...t,...Wd(t),...sq(t),...OOe(t)}}function cor(e){let t={parse:(r,n)=>sgs(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>sgs(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>Cu.LIST};return{...Cx(t),...Wd(t)}}function sgs(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:md(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function ags(e){return xx(Cu.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:md(r,`${e.toString()}`)}]})()}function cgs(e){return xx(Cu.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:md(r,`"${e}"`)}]})()}var ugs=xx(Cu.ANY,e=>({ok:!0,value:e}));var lgs=xx(Cu.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"boolean")}]});var pgs=xx(Cu.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var fgs=xx(Cu.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"number")}]});var dgs=xx(Cu.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"string")}]});var mgs=xx(Cu.UNKNOWN,e=>({ok:!0,value:e}));var oAl=Object.prototype.hasOwnProperty;function ggs(e,t){let r={parse:(n,i)=>hgs({value:n,isKeyNumeric:e.getType()===Cu.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>hgs({value:n,isKeyNumeric:e.getType()===Cu.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Cu.RECORD};return{...Cx(r),...Wd(r)}}function hgs({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!Mse(e))return{ok:!1,errors:[{path:i,message:md(e,"object")}]};let o={},s=[];for(let a in e){if(!oAl.call(e,a))continue;let c=e[a];if(c===void 0)continue;let u=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(u=d)}let l=r(u),p=n(c,u);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function Ags(e){let t=cor(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:md(n,"Set")}]},getType:()=>Cu.SET};return{...Cx(r),...Wd(r)}}function bgs(e){let t={parse:(r,n)=>ygs((i,o)=>i.parse(r,o),e,n),json:(r,n)=>ygs((i,o)=>i.json(r,o),e,n),getType:()=>Cu.UNDISCRIMINATED_UNION};return{...Cx(t),...Wd(t)}}function ygs(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function Egs(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var sAl=Object.prototype.hasOwnProperty;function Igs(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=sor(qvt(t)),o={parse:(s,a)=>vgs({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:c=>i.parse(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.parse(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>vgs({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:c=>i.json(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.json(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>Cu.UNION};return{...Cx(o),...Wd(o),...sq(o)}}function vgs({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!Mse(e))return{ok:!1,errors:[{path:a,message:md(e,"object")}]};let c=e[t],u={};for(let f in e)sAl.call(e,f)&&f!==t&&(u[f]=e[f]);if(c==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(c);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...u}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(u,p);return d.ok?{ok:!0,value:{[r]:c,...d.value}}:d}var uor=K.objectWithoutOptionalProperties({usernameVariableName:K.string().optional(),usernameEnvVar:K.string().optional(),passwordVariableName:K.string().optional(),passwordEnvVar:K.string().optional()});var lor=K.objectWithoutOptionalProperties({tokenVariableName:K.string().optional(),tokenEnvVar:K.string().optional()});var por=K.objectWithoutOptionalProperties({typeName:K.string()});var dor=K.union("type",{protobuf:por}).transform({transform:e=>e.type==="protobuf"?XVe.protobuf(e):e,untransform:({_visit:e,...t})=>t});var mor=K.objectWithoutOptionalProperties({headerName:K.string(),prefix:K.string().optional(),headerVariableName:K.string().optional(),headerEnvVar:K.string().optional()});var hor=K.objectWithoutOptionalProperties({type:K.stringLiteral("namespace"),name:K.string()});var gor=K.string();var Aor=K.enum_(["GenerallyAvailable","Beta","Deprecated"]);var us=K.objectWithoutOptionalProperties({availability:Aor.optional()});var mn=K.objectWithoutOptionalProperties({description:K.string().optional()});var Lf=K.objectWithoutOptionalProperties({inline:K.boolean().optional()});var Nc=K.objectWithoutOptionalProperties({nameOverride:K.string().optional(),generatedName:K.string()});var oc=K.objectWithoutOptionalProperties({namespace:K.string().optional()});var yor=K.undiscriminatedUnion([K.string(),hor]);var Che=K.list(yor);var xu=K.objectWithoutOptionalProperties({groupName:Che.optional()});var bor=K.objectWithoutOptionalProperties({file:K.string()});var Eor=K.objectWithoutOptionalProperties({file:K.string()});var vor=K.union("type",{openapi:bor,protobuf:Eor}).transform({transform:e=>{switch(e.type){case"openapi":return uT.openapi(e);case"protobuf":return uT.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var $o=K.objectWithoutOptionalProperties({source:vor.optional()});var _u=K.objectWithoutOptionalProperties({title:K.string().optional()});var Ior=K.objectWithoutOptionalProperties({snake:K.string().optional(),camel:K.string().optional(),screamingSnake:K.string().optional(),pascal:K.string().optional()});var xhe=K.objectWithoutOptionalProperties({nameOverride:K.string().optional(),generatedName:K.string(),value:K.string(),casing:Ior.optional()}).extend(mn).extend(us);var r6e=K.objectWithoutOptionalProperties({default:xhe.optional(),values:K.list(xhe)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u).extend(Lf);var wor=K.objectWithoutOptionalProperties({scopesEnum:r6e.optional()});var Cor=K.objectWithoutOptionalProperties({queryParameterName:K.string()});var HP=K.string();var xor=K.union("type",{basic:uor,bearer:lor,header:mor,query:Cor,oauth:wor}).transform({transform:e=>{switch(e.type){case"basic":return Ex.basic(e);case"bearer":return Ex.bearer(e);case"header":return Ex.header(e);case"query":return Ex.query(e);case"oauth":return Ex.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var _he=K.string();var _or=K.objectWithoutOptionalProperties({id:K.string(),default:K.string().optional(),values:K.list(K.string()).optional()});var Gvt=K.objectWithoutOptionalProperties({name:K.string().optional(),url:K.string(),audiences:K.list(K.string()).optional(),defaultUrl:K.string().optional(),urlTemplate:K.string().optional(),variables:K.list(_or).optional()}).extend(mn);var I$=K.number();var KP=K.string();var Sor=K.objectWithoutOptionalProperties({id:KP}).extend(mn);var _x=K.objectWithoutOptionalProperties({encoding:dor.optional()});var w$=K.objectWithoutOptionalProperties({sdkMethodName:K.string().optional()});var YU=K.objectWithoutOptionalProperties({statusCode:I$.optional()});var sli={};te(sli,{FullExample:()=>Vm,FullObjectExample:()=>Oor,FullOneOfExample:()=>Por,KeyValuePair:()=>Dor,LiteralExample:()=>Bor,NullExample:()=>Tor,PrimitiveExample:()=>n6e,PropertyKey:()=>i6e});var Bor=K.union("type",{boolean:K.object({value:K.boolean()}),string:K.object({value:K.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ihe.boolean(e.value);case"string":return Ihe.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Tor=K.objectWithoutOptionalProperties({});var n6e=K.union("type",{int:K.object({value:K.number()}),int64:K.object({value:K.number()}),uint:K.object({value:K.number()}),uint64:K.object({value:K.number()}),float:K.object({value:K.number()}),double:K.object({value:K.number()}),string:K.object({value:K.string()}),datetime:K.object({value:K.string()}),datetimeRfc2822:K.object({value:K.string()}),date:K.object({value:K.string()}),base64:K.object({value:K.string()}),boolean:K.object({value:K.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return hs.int(e.value);case"int64":return hs.int64(e.value);case"uint":return hs.uint(e.value);case"uint64":return hs.uint64(e.value);case"float":return hs.float(e.value);case"double":return hs.double(e.value);case"string":return hs.string(e.value);case"datetime":return hs.datetime(e.value);case"datetimeRfc2822":return hs.datetimeRfc2822(e.value);case"date":return hs.date(e.value);case"base64":return hs.base64(e.value);case"boolean":return hs.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vm=K.union("type",{primitive:K.object({value:n6e}),object:K.lazyObject(()=>Oor),array:K.object({value:K.list(K.lazy(()=>Vm))}),map:K.object({value:K.list(K.lazyObject(()=>Dor))}),enum:K.object({value:K.string()}),literal:K.object({value:Bor}),oneOf:K.object({value:K.lazy(()=>Por)}),null:Tor,unknown:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"primitive":return lc.primitive(e.value);case"object":return lc.object(e);case"array":return lc.array(e.value);case"map":return lc.map(e.value);case"enum":return lc.enum(e.value);case"literal":return lc.literal(e.value);case"oneOf":return lc.oneOf(e.value);case"null":return lc.null(e);case"unknown":return lc.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var i6e=K.string();var Oor=K.objectWithoutOptionalProperties({properties:K.record(i6e,K.lazy(()=>Vm))});var Por=K.union("type",{discriminated:K.object({value:K.record(i6e,K.lazy(()=>Vm))}),undiscriminated:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return vhe.discriminated(e.value);case"undiscriminated":return vhe.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Dor=K.objectWithoutOptionalProperties({key:n6e,value:K.lazy(()=>Vm)});var ali={};te(ali,{AllOfPropertyConflict:()=>o6e,ArraySchema:()=>Ror,AsymmetricAlgorithm:()=>For,AsymmetricWebhookSignatureVerification:()=>Nor,Availability:()=>Aor,BooleanSchema:()=>Qor,BytesResponse:()=>c6e,CasingOverrides:()=>Ior,CommonProperty:()=>jor,CursorPagination:()=>Mor,CustomCodeSample:()=>Vor,CustomCodeSampleLanguage:()=>Lor,CustomCodeSampleSdk:()=>zor,CustomPagination:()=>qor,DiscriminatedOneOfSchema:()=>Gor,DiscriminatorContext:()=>u6e,DoubleSchema:()=>Wor,Endpoint:()=>usr,EndpointExample:()=>f6e,EndpointResponseExample:()=>Kor,EndpointSdkName:()=>C$,EndpointSecurity:()=>d6e,EnumSchema:()=>r6e,EnumValue:()=>xhe,ErrorExample:()=>Xor,FernExample:()=>$or,FileResponse:()=>v6e,FileSchema:()=>ssr,FormUrlEncodedRequest:()=>nsr,FullEndpointExample:()=>Yor,GlobalHeader:()=>lsr,GlobalSecurity:()=>psr,Header:()=>She,HeaderExample:()=>l6e,HmacWebhookSignatureVerification:()=>hsr,HttpEndpointServer:()=>m6e,HttpError:()=>Zor,HttpMethod:()=>h6e,IdempotencyHeader:()=>gsr,IntSchema:()=>Asr,JsonRequest:()=>isr,JsonResponse:()=>I6e,LiteralSchema:()=>x6e,LiteralSchemaValue:()=>ysr,LongSchema:()=>bsr,MapSchema:()=>Isr,MultipartFormDataWebhookPayload:()=>wsr,MultipartRequest:()=>b6e,MultipartRequestProperty:()=>Bhe,MultipartRequestPropertyEncoding:()=>osr,MultipartSchema:()=>asr,NullableSchema:()=>Csr,ObjectProperty:()=>xsr,ObjectPropertyConflictInfo:()=>_6e,ObjectSchema:()=>_sr,OctetStreamRequest:()=>E6e,OffsetPagination:()=>esr,OneOfSchema:()=>Ssr,OpenApiIntermediateRepresentation:()=>wgs,OptionalSchema:()=>Lsr,Pagination:()=>g6e,PathPagination:()=>tsr,PathParameter:()=>A6e,PathParameterExample:()=>Jor,PrimitiveSchema:()=>Ohe,PrimitiveSchemaValue:()=>vsr,QueryParameter:()=>y6e,QueryParameterExample:()=>p6e,ReferencedSchema:()=>x$,Request:()=>csr,Response:()=>w6e,RetriesConfiguration:()=>C6e,Schema:()=>$u,Schemas:()=>Tsr,SdkGroupInfo:()=>Osr,StreamingResponseExample:()=>Hor,StringSchema:()=>Esr,SupportedSdkLanguage:()=>Uor,Tags:()=>Psr,TextResponse:()=>The,UnDiscriminatedOneOfSchema:()=>Bsr,UnknownSchema:()=>Usr,UriPagination:()=>rsr,Webhook:()=>Dsr,WebhookExampleCall:()=>S6e,WebhookHttpMethod:()=>B6e,WebhookPayloadComponent:()=>fsr,WebhookPayloadFormat:()=>dsr,WebhookSignatureAlgorithm:()=>msr,WebhookSignatureEncoding:()=>s6e,WebhookSignatureVerification:()=>T6e,WebhookTimestamp:()=>a6e,WebhookTimestampFormat:()=>kor,WebsocketChannel:()=>Msr,WebsocketHandshake:()=>Rsr,WebsocketMessageExample:()=>Qsr,WebsocketMessageOrigin:()=>Fsr,WebsocketMessageSchema:()=>ksr,WebsocketServer:()=>Nsr,WebsocketSessionExample:()=>jsr});var o6e=K.objectWithoutOptionalProperties({propertyKey:K.string(),allOfSchemaIds:K.list(HP),conflictingTypeSignatures:K.boolean()});var Ror=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u),minItems:K.number().optional(),maxItems:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var For=K.enum_(["rsa-sha256","rsa-sha384","rsa-sha512","ecdsa-sha256","ecdsa-sha384","ecdsa-sha512","ed25519"]);var s6e=K.enum_(["base64","hex"]);var kor=K.enum_(["unix-seconds","unix-millis","iso8601"]);var a6e=K.objectWithoutOptionalProperties({header:K.string(),format:kor.optional(),tolerance:K.number().optional()});var Nor=K.objectWithoutOptionalProperties({header:K.string(),asymmetricAlgorithm:For,encoding:s6e.optional(),signaturePrefix:K.string().optional(),jwksUrl:K.string().optional(),keyIdHeader:K.string().optional(),timestamp:a6e.optional()});var Qor=K.objectWithoutOptionalProperties({default:K.boolean().optional()});var c6e=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var jor=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>$u)});var Mor=K.objectWithoutOptionalProperties({cursor:K.string(),nextCursor:K.property("next_cursor",K.string()),results:K.string()});var Lor=K.objectWithoutOptionalProperties({name:K.string().optional(),language:K.string(),code:K.string(),install:K.string().optional()}).extend(mn);var Uor=K.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var zor=K.objectWithoutOptionalProperties({name:K.string().optional(),sdk:Uor,code:K.string()}).extend(mn);var Vor=K.union("type",{language:Lor,sdk:zor}).transform({transform:e=>{switch(e.type){case"language":return b$.language(e);case"sdk":return b$.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var qor=K.objectWithoutOptionalProperties({results:K.string()});var u6e=K.enum_(["data","protocol"]);var Gor=K.objectWithoutOptionalProperties({discriminantProperty:K.string(),discriminantPropertyNameOverride:K.string().optional(),discriminatorContext:u6e.optional(),commonProperties:K.list(K.lazyObject(()=>jor)),schemas:K.record(K.string(),K.lazy(()=>$u))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Wor=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional()});var $or=K.unknown();var Hor=K.objectWithoutOptionalProperties({sse:K.boolean(),events:K.list(K.lazy(()=>Vm))});var Kor=K.union("type",{withStreaming:Hor,withoutStreaming:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return JU.withStreaming(e);case"withoutStreaming":return JU.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var l6e=K.objectWithoutOptionalProperties({name:K.string(),value:K.lazy(()=>Vm)});var Jor=K.objectWithoutOptionalProperties({name:K.string(),parameterNameOverride:K.string().optional(),value:K.lazy(()=>Vm)});var p6e=K.objectWithoutOptionalProperties({name:K.string(),value:K.lazy(()=>Vm)});var Yor=K.objectWithoutOptionalProperties({name:K.string().optional(),pathParameters:K.list(Jor).optional(),queryParameters:K.list(p6e).optional(),headers:K.list(l6e).optional(),request:K.lazy(()=>Vm).optional(),response:Kor.optional(),codeSamples:K.list(Vor)}).extend(mn);var f6e=K.union("type",{unknown:K.object({value:$or}),full:Yor}).transform({transform:e=>{switch(e.type){case"unknown":return KU.unknown(e.value);case"full":return KU.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var C$=K.objectWithoutOptionalProperties({groupName:Che,methodName:K.string()});var d6e=K.list(K.record(_he,K.list(K.string())));var She=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),env:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var m6e=K.objectWithoutOptionalProperties({name:K.string().optional(),url:K.string().optional(),audiences:K.list(K.string()).optional()});var Xor=K.objectWithoutOptionalProperties({name:K.string().optional(),description:K.string().optional(),example:K.lazy(()=>Vm)});var Zor=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u).optional(),examples:K.list(Xor).optional()}).extend(mn).extend(Nc).extend($o);var h6e=K.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var esr=K.objectWithoutOptionalProperties({offset:K.string(),results:K.string(),step:K.string().optional(),hasNextPage:K.string().optional()});var tsr=K.objectWithoutOptionalProperties({nextPath:K.string(),results:K.string()});var rsr=K.objectWithoutOptionalProperties({nextUri:K.string(),results:K.string()});var g6e=K.union("type",{cursor:Mor,offset:esr,custom:qor,uri:rsr,path:tsr}).transform({transform:e=>{switch(e.type){case"cursor":return $w.cursor(e);case"offset":return $w.offset(e);case"custom":return $w.custom(e);case"uri":return $w.uri(e);case"path":return $w.path(e);default:return e}},untransform:({_visit:e,...t})=>t});var A6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),variableReference:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var y6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var nsr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),contentType:K.string().optional(),additionalProperties:K.boolean()}).extend(mn).extend($o);var isr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),contentType:K.string().optional(),additionalProperties:K.boolean()}).extend(mn).extend($o);var osr=K.enum_(["json","form"]);var ssr=K.objectWithoutOptionalProperties({isOptional:K.boolean(),isArray:K.boolean()}).extend(mn);var asr=K.union("type",{file:ssr,json:K.object({value:K.lazy(()=>$u)})}).transform({transform:e=>{switch(e.type){case"file":return E$.file(e);case"json":return E$.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Bhe=K.objectWithoutOptionalProperties({key:K.string(),schema:asr,contentType:K.string().optional(),exploded:K.boolean().optional(),encoding:osr.optional()}).extend(mn);var b6e=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var E6e=K.objectWithoutOptionalProperties({contentType:K.string().optional()}).extend(mn).extend($o);var csr=K.union("type",{octetStream:E6e,multipart:b6e,json:isr,formUrlEncoded:nsr}).transform({transform:e=>{switch(e.type){case"octetStream":return oq.octetStream(e);case"multipart":return oq.multipart(e);case"json":return oq.json(e);case"formUrlEncoded":return oq.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var v6e=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var I6e=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),responseProperty:K.string().optional(),terminator:K.string().optional()}).extend(mn).extend($o).extend(YU);var The=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var w6e=K.union("type",{file:v6e,json:I6e,text:The,bytes:c6e,streamingSse:I6e,streamingText:The,streamingJson:I6e}).transform({transform:e=>{switch(e.type){case"file":return JS.file(e);case"json":return JS.json(e);case"text":return JS.text(e);case"bytes":return JS.bytes(e);case"streamingSse":return JS.streamingSse(e);case"streamingText":return JS.streamingText(e);case"streamingJson":return JS.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var C6e=K.union("type",{disabled:K.object({value:K.boolean().optional()})}).transform({transform:e=>e.type==="disabled"?Lvt.disabled(e.value):e,untransform:({_visit:e,...t})=>t});var usr=K.objectWithoutOptionalProperties({authed:K.boolean(),security:d6e.optional(),internal:K.boolean().optional(),idempotent:K.boolean().optional(),method:h6e,audiences:K.list(K.string()),path:K.string(),summary:K.string().optional(),operationId:K.string().optional(),tags:K.list(KP),pathParameters:K.list(A6e),queryParameters:K.list(y6e),headers:K.list(She),sdkName:C$.optional(),generatedRequestName:K.string(),requestNameOverride:K.string().optional(),request:csr.optional(),response:w6e.optional(),errors:K.record(I$,Zor),servers:K.list(m6e),examples:K.list(f6e),pagination:g6e.optional(),retries:C6e.optional()}).extend(mn).extend(us).extend($o).extend(oc);var lsr=K.objectWithoutOptionalProperties({header:K.string(),name:K.string().optional(),optional:K.boolean().optional(),env:K.string().optional(),schema:K.lazy(()=>$u).optional()});var psr=K.list(K.record(_he,K.list(K.string())));var fsr=K.enum_(["body","timestamp","notification-url","message-id"]);var dsr=K.objectWithoutOptionalProperties({components:K.list(fsr),delimiter:K.string().optional()});var msr=K.enum_(["sha256","sha1","sha384","sha512"]);var hsr=K.objectWithoutOptionalProperties({header:K.string(),algorithm:msr.optional(),encoding:s6e.optional(),signaturePrefix:K.string().optional(),payloadFormat:dsr.optional(),timestamp:a6e.optional()});var gsr=K.objectWithoutOptionalProperties({header:K.string(),name:K.string().optional(),env:K.string().optional(),schema:K.lazy(()=>$u).optional()});var Asr=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional()});var ysr=K.union("type",{boolean:K.object({value:K.boolean()}),string:K.object({value:K.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return pA.boolean(e.value);case"string":return pA.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var x6e=K.objectWithoutOptionalProperties({value:ysr}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var bsr=K.objectWithoutOptionalProperties({default:K.number().optional()});var Esr=K.objectWithoutOptionalProperties({default:K.string().optional(),pattern:K.string().optional(),format:K.string().optional(),minLength:K.number().optional(),maxLength:K.number().optional()});var vsr=K.union("type",{int:Asr,int64:bsr,uint:K.object({}),uint64:K.object({}),float:K.object({}),double:Wor,string:Esr,datetime:K.object({}),datetimeRfc2822:K.object({}),date:K.object({}),base64:K.object({}),boolean:Qor}).transform({transform:e=>{switch(e.type){case"int":return ol.int(e);case"int64":return ol.int64(e);case"uint":return ol.uint();case"uint64":return ol.uint64();case"float":return ol.float();case"double":return ol.double(e);case"string":return ol.string(e);case"datetime":return ol.datetime();case"datetimeRfc2822":return ol.datetimeRfc2822();case"date":return ol.date();case"base64":return ol.base64();case"boolean":return ol.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ohe=K.objectWithoutOptionalProperties({schema:vsr}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var Isr=K.objectWithoutOptionalProperties({key:Ohe,value:K.lazy(()=>$u),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend(_u).extend(Lf);var wsr=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var Csr=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var _6e=K.objectWithoutOptionalProperties({differentSchema:K.boolean()});var xsr=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>$u),readonly:K.boolean().optional(),writeonly:K.boolean().optional(),conflict:K.record(HP,_6e),generatedName:K.string(),nameOverride:K.string().optional(),audiences:K.list(K.string())}).extend(us);var x$=K.objectWithoutOptionalProperties({schema:HP}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u);var _sr=K.objectWithoutOptionalProperties({allOf:K.list(x$),properties:K.list(K.lazyObject(()=>xsr)),allOfPropertyConflicts:K.list(o6e),additionalProperties:K.boolean(),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Ssr=K.union("type",{discriminated:K.lazyObject(()=>Gor),undiscriminated:K.lazyObject(()=>Bsr)}).transform({transform:e=>{switch(e.type){case"discriminated":return v$.discriminated(e);case"undiscriminated":return v$.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tsr=K.objectWithoutOptionalProperties({rootSchemas:K.record(HP,K.lazy(()=>$u)),namespacedSchemas:K.record(gor,K.record(HP,K.lazy(()=>$u)))});var Osr=K.objectWithoutOptionalProperties({summary:K.string().optional(),description:K.string().optional()});var Psr=K.objectWithoutOptionalProperties({tagsById:K.record(KP,Sor),orderedTagIds:K.list(KP).optional()});var S6e=K.objectWithoutOptionalProperties({name:K.string().optional(),payload:K.lazy(()=>Vm)}).extend(mn);var B6e=K.enum_(["GET","POST"]);var T6e=K.union("type",{hmac:hsr,asymmetric:Nor}).transform({transform:e=>{switch(e.type){case"hmac":return TOe.hmac(e);case"asymmetric":return TOe.asymmetric(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dsr=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),sdkName:C$.optional(),method:B6e,summary:K.string().optional(),operationId:K.string(),tags:K.list(KP),headers:K.list(She),generatedPayloadName:K.string(),payload:K.lazy(()=>$u),multipartFormData:wsr.optional(),response:w6e.optional(),signatureVerification:T6e.optional(),examples:K.list(S6e)}).extend(mn).extend($o).extend(oc);var Rsr=K.objectWithoutOptionalProperties({queryParameters:K.list(y6e),headers:K.list(She),pathParameters:K.list(A6e)});var Fsr=K.enum_(["client","server"]);var ksr=K.objectWithoutOptionalProperties({name:K.string(),origin:Fsr,body:K.lazy(()=>$u),methodName:K.string().optional()});var Nsr=K.objectWithoutOptionalProperties({name:K.string(),url:K.string()});var Qsr=K.objectWithoutOptionalProperties({messageType:K.string(),payload:K.lazy(()=>Vm)}).extend(mn);var jsr=K.objectWithoutOptionalProperties({name:K.string().optional(),queryParameters:K.list(p6e).optional(),headers:K.list(l6e).optional(),messages:K.list(Qsr)}).extend(mn);var Msr=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),path:K.string(),groupName:Che,summary:K.string().optional(),connectMethodName:K.string().optional(),handshake:Rsr,messages:K.list(ksr),servers:K.list(Nsr),examples:K.list(jsr)}).extend(mn).extend($o);var wgs=K.objectWithoutOptionalProperties({apiVersion:K.unknown().optional(),title:K.string().optional(),description:K.string().optional(),basePath:K.string().optional(),servers:K.list(Gvt),websocketServers:K.list(Gvt),groups:K.record(K.string(),Osr),tags:Psr,hasEndpointsMarkedInternal:K.boolean(),endpoints:K.list(usr),webhooks:K.list(Dsr),channels:K.record(K.string(),Msr),groupedSchemas:Tsr,variables:K.record(K.string(),Ohe),nonRequestReferencedSchemas:K.set(HP),securitySchemes:K.record(_he,xor),security:psr.optional(),globalHeaders:K.list(lsr).optional(),idempotencyHeaders:K.list(gsr).optional()});var Lsr=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var Usr=K.objectWithoutOptionalProperties({}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var $u=K.union("type",{primitive:Ohe,object:K.lazyObject(()=>_sr),array:K.lazyObject(()=>Ror),map:K.lazyObject(()=>Isr),optional:K.lazyObject(()=>Lsr),enum:r6e,reference:x$,literal:x6e,oneOf:K.object({value:K.lazy(()=>Ssr)}),nullable:K.lazyObject(()=>Csr),unknown:Usr}).transform({transform:e=>{switch(e.type){case"primitive":return ba.primitive(e);case"object":return ba.object(e);case"array":return ba.array(e);case"map":return ba.map(e);case"optional":return ba.optional(e);case"enum":return ba.enum(e);case"reference":return ba.reference(e);case"literal":return ba.literal(e);case"oneOf":return ba.oneOf(e.value);case"nullable":return ba.nullable(e);case"unknown":return ba.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bsr=K.objectWithoutOptionalProperties({schemas:K.list(K.lazy(()=>$u))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var cli={};te(cli,{ArraySchemaWithExample:()=>zsr,Base64WithExample:()=>Vsr,BooleanWithExample:()=>qsr,CommonPropertyWithExample:()=>Gsr,DateWithExample:()=>Wsr,DatetimeWithExample:()=>Wvt,DiscriminatedOneOfSchemaWithExample:()=>$sr,DoubleWithExample:()=>Hsr,EndpointWithExample:()=>Cgs,EnumSchemaWithExample:()=>rar,FloatWithExample:()=>nar,HeaderWithExample:()=>Phe,HttpErrorWithExample:()=>Ksr,Int64WithExample:()=>iar,IntWithExample:()=>oar,JsonRequestWithExample:()=>Ysr,JsonResponseWithExample:()=>P6e,MapSchemaWithExample:()=>lar,MultipartFormDataWebhookPayloadWithExample:()=>par,NamedFullExample:()=>nk,NullableSchemaWithExample:()=>far,ObjectPropertyWithExample:()=>dar,ObjectSchemaWithExample:()=>mar,OneOfSchemaWithExample:()=>har,OptionalSchemaWithExample:()=>Aar,ParseFormUrlEncodedRequest:()=>Xsr,ParseMultipartRequest:()=>Zsr,ParseOctetStreamRequest:()=>ear,PathParameterWithExample:()=>Jsr,PrimitiveSchemaValueWithExample:()=>uar,PrimitiveSchemaWithExample:()=>R6e,QueryParameterWithExample:()=>O6e,RequestWithExample:()=>tar,ResponseWithExample:()=>D6e,SchemaWithExample:()=>Uf,StringSchemaWithExample:()=>sar,Uint64WithExample:()=>aar,UintWithExample:()=>car,UnDiscriminatedOneOfSchemaWithExample:()=>gar,UnknownSchemaWithExample:()=>yar,WebhookWithExample:()=>xgs,WebsocketHandshakeWithExample:()=>_gs});var zsr=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf),minItems:K.number().optional(),maxItems:K.number().optional(),example:K.list(K.unknown()).optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var Vsr=K.objectWithoutOptionalProperties({example:K.string().optional()});var qsr=K.objectWithoutOptionalProperties({default:K.boolean().optional(),example:K.boolean().optional()});var Gsr=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>Uf)});var Wvt=K.objectWithoutOptionalProperties({example:K.string().optional()});var Wsr=K.objectWithoutOptionalProperties({example:K.string().optional()});var $sr=K.objectWithoutOptionalProperties({discriminantProperty:K.string(),discriminantPropertyNameOverride:K.string().optional(),discriminatorContext:u6e.optional(),commonProperties:K.list(K.lazyObject(()=>Gsr)),schemas:K.record(K.string(),K.lazy(()=>Uf))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Hsr=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional(),example:K.number().optional()});var Phe=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),env:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var nk=K.objectWithoutOptionalProperties({name:K.string().optional(),value:K.unknown()}).extend(mn);var Ksr=K.objectWithoutOptionalProperties({statusCode:I$,schema:K.lazy(()=>Uf),fullExamples:K.list(nk).optional()}).extend(mn).extend(Nc).extend($o);var Jsr=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),variableReference:K.string().optional(),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var O6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var Ysr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),contentType:K.string().optional(),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean()}).extend(mn).extend($o).extend(w$);var Xsr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),contentType:K.string().optional(),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean()}).extend(mn).extend($o).extend(w$);var Zsr=K.objectWithoutOptionalProperties({fullExamples:K.list(nk).optional()}).extend(b6e).extend(w$);var ear=K.objectWithoutOptionalProperties({}).extend(E6e).extend(w$);var tar=K.union("type",{octetStream:ear,multipart:Zsr,json:Ysr,formUrlEncoded:Xsr}).transform({transform:e=>{switch(e.type){case"octetStream":return $P.octetStream(e);case"multipart":return $P.multipart(e);case"json":return $P.json(e);case"formUrlEncoded":return $P.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var P6e=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),responseProperty:K.string().optional(),terminator:K.string().optional(),fullExamples:K.list(nk).optional()}).extend(mn).extend($o).extend(YU);var D6e=K.union("type",{file:v6e,json:P6e,text:The,bytes:c6e,streamingSse:P6e,streamingText:The,streamingJson:P6e}).transform({transform:e=>{switch(e.type){case"file":return Rh.file(e);case"json":return Rh.json(e);case"text":return Rh.text(e);case"bytes":return Rh.bytes(e);case"streamingSse":return Rh.streamingSse(e);case"streamingText":return Rh.streamingText(e);case"streamingJson":return Rh.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Cgs=K.objectWithoutOptionalProperties({authed:K.boolean(),security:d6e.optional(),internal:K.boolean().optional(),idempotent:K.boolean().optional(),method:h6e,audiences:K.list(K.string()),path:K.string(),summary:K.string().optional(),operationId:K.string().optional(),tags:K.list(KP),pathParameters:K.list(Jsr),queryParameters:K.list(O6e),headers:K.list(Phe),sdkName:C$.optional(),generatedRequestName:K.string(),requestNameOverride:K.string().optional(),request:tar.optional(),response:D6e.optional(),errors:K.record(I$,Ksr),servers:K.list(m6e),examples:K.list(f6e),pagination:g6e.optional(),retries:C6e.optional()}).extend(mn).extend(us).extend($o).extend(oc);var rar=K.objectWithoutOptionalProperties({default:xhe.optional(),values:K.list(xhe),example:K.string().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u).extend(Lf);var nar=K.objectWithoutOptionalProperties({example:K.number().optional()});var iar=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var oar=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional(),example:K.number().optional()});var sar=K.objectWithoutOptionalProperties({default:K.string().optional(),pattern:K.string().optional(),format:K.string().optional(),minLength:K.number().optional(),maxLength:K.number().optional(),example:K.string().optional()});var aar=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var car=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var uar=K.union("type",{int:oar,int64:iar,uint:car,uint64:aar,float:nar,double:Hsr,string:sar,datetime:Wvt,datetimeRfc2822:Wvt,date:Wsr,base64:Vsr,boolean:qsr}).transform({transform:e=>{switch(e.type){case"int":return xi.int(e);case"int64":return xi.int64(e);case"uint":return xi.uint(e);case"uint64":return xi.uint64(e);case"float":return xi.float(e);case"double":return xi.double(e);case"string":return xi.string(e);case"datetime":return xi.datetime(e);case"datetimeRfc2822":return xi.datetimeRfc2822(e);case"date":return xi.date(e);case"base64":return xi.base64(e);case"boolean":return xi.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var R6e=K.objectWithoutOptionalProperties({schema:uar}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var lar=K.objectWithoutOptionalProperties({key:R6e,value:K.lazy(()=>Uf),minProperties:K.number().optional(),maxProperties:K.number().optional(),example:K.unknown().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend(_u).extend(Lf);var par=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var far=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var dar=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>Uf),readonly:K.boolean().optional(),writeonly:K.boolean().optional(),audiences:K.list(K.string()),conflict:K.record(HP,_6e),nameOverride:K.string().optional(),generatedName:K.string()}).extend(us);var mar=K.objectWithoutOptionalProperties({allOf:K.list(x$),properties:K.list(K.lazyObject(()=>dar)),allOfPropertyConflicts:K.list(o6e),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean(),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var har=K.union("type",{discriminated:K.lazyObject(()=>$sr),undiscriminated:K.lazyObject(()=>gar)}).transform({transform:e=>{switch(e.type){case"discriminated":return vj.discriminated(e);case"undiscriminated":return vj.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Aar=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var yar=K.objectWithoutOptionalProperties({example:K.unknown()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var Uf=K.union("type",{primitive:R6e,object:K.lazyObject(()=>mar),array:K.lazyObject(()=>zsr),map:K.lazyObject(()=>lar),optional:K.lazyObject(()=>Aar),enum:rar,reference:x$,literal:x6e,oneOf:K.object({value:K.lazy(()=>har)}),nullable:K.lazyObject(()=>far),unknown:yar}).transform({transform:e=>{switch(e.type){case"primitive":return Fr.primitive(e);case"object":return Fr.object(e);case"array":return Fr.array(e);case"map":return Fr.map(e);case"optional":return Fr.optional(e);case"enum":return Fr.enum(e);case"reference":return Fr.reference(e);case"literal":return Fr.literal(e);case"oneOf":return Fr.oneOf(e.value);case"nullable":return Fr.nullable(e);case"unknown":return Fr.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var gar=K.objectWithoutOptionalProperties({schemas:K.list(K.lazy(()=>Uf))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var xgs=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),sdkName:C$.optional(),method:B6e,summary:K.string().optional(),operationId:K.string(),tags:K.list(KP),headers:K.list(Phe),generatedPayloadName:K.string(),payload:K.lazy(()=>Uf),multipartFormData:par.optional(),response:D6e.optional(),signatureVerification:T6e.optional(),examples:K.list(S6e)}).extend(mn).extend($o).extend(oc);var _gs=K.objectWithoutOptionalProperties({queryParameters:K.list(O6e),headers:K.list(Phe)});var Sgs=/^(\d+)/,F6e=/^[a-zA-Z][a-zA-Z0-9_]*$/,Bgs={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function POe(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let s=Math.floor(e/10),a=e%10;return a===0?n[s]:`${n[s]}_${t[a]}`}if(e<1e3){let s=Math.floor(e/100),a=e%100;return a===0?`${t[s]}_hundred`:`${t[s]}_hundred_${POe(a)}`}let i=Math.floor(e/1e3),o=e%1e3;return o===0?`${t[i]}_thousand`:`${t[i]}_thousand_${POe(o)}`}Bi();function $vt(e){let t=e.match(Sgs);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let o=POe(i);return n.length>0?`${o}_${n}`:o}}}function k6e(e){let t=$vt(e),r=Bgs[e];return t!=null?gu(qn(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":gu(qn(e)))}Bi();function ik(e,t){return e.type==="primitive"&&t.type==="primitive"?Tgs(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?aAl(e.values,t.values):e.type==="array"&&t.type==="array"?ik(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?ik(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?cAl(e.value,t.value):e.type==="object"&&t.type==="object"?uAl(e,t):e.type==="map"&&t.type==="map"?Tgs(e.key.schema,t.key.schema)&&ik(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Tgs(e,t){return e.type===t.type}function aAl(e,t){let r=new Set(e.map(i=>i.value)),n=new Set(t.map(i=>i.value));return q0(r,n)}function cAl(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:ik(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:ik(r,i)}):!1}function uAl(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let o=r[n];return o==null?!1:ik(o,i.schema)})}St();function sb(e){switch(e){case vx.Deprecated:return"deprecated";case vx.Beta:return"pre-release";case vx.GenerallyAvailable:return"generally-available";default:return}}St();function Hvt(e){if(e.type==="protobuf")return{proto:{type:e.typeName}};Be(e.type)}St();St();oA();Bi();function Ogs(e){let t=e.match(/^(_+)/),r=e.match(/(_+)$/),n=t?.[1]??"",i=r?.[1]??"";if(n===""&&i==="")return qn(e);if(n.length+i.length>=e.length)return e;let o=e.slice(n.length,e.length-i.length||void 0);return`${n}${qn(o)}${i}`}function lAl(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function Pgs(e){let t=e?lAl(e):void 0;if(t==null||t.length===0)return dOe;let r=[];for(let[n,i]of t.entries())typeof i=="string"?r.push(Ogs(i)):typeof i=="object"?i.type==="namespace"?n<t.length-1?r.push(Ogs(i.name)):r.push(i.name,dOe):Be(i.type):Be(i);return r.join("/")}function Use(e){return Qs.of(`${Pgs(e)}.yml`)}function uli({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?dOe:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,Pgs(r))}function Dgs({sdkName:e,namespaceOverride:t}){return Qs.of(`${uli({sdkName:e,namespaceOverride:t})}.yml`)}function Rgs({location:e,namespaceOverride:t}){return t!=null?G0(Qs.of(t),e):e}function Fgs(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"unknown":return bar({namespace:e.namespace,groupName:e.groupName});case"oneOf":return bar({namespace:e.value.namespace,groupName:e.value.groupName});default:Be(e)}}function bar({namespace:e,groupName:t}){return e!=null&&t!=null?Use([{type:"namespace",name:e},...t]):e!=null?Use([{type:"namespace",name:e}]):Use(t)}St();function zse(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":case"unknown":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;default:Be(e)}}function yp(e){return typeof e=="string"?e:e.type}function N6e(e){if(typeof e!="string")return e.docs}function Kvt(e){if(typeof e!="string")return e.default}function lli(e){if(typeof e!="string")return e.validation}function Q6e(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Ngs(e){let t=yp(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?kgs(e):{...e,type:kgs(e.type)}}function kgs(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function DOe(e){return yp(e).startsWith("optional<")?e:typeof e=="string"?Qgs(e):{...e,type:Qgs(e.type)}}function Qgs(e){return e.startsWith("optional<")?e:`optional<${e}>`}var pAl=-2147483648,fAl=2147483647,dAl=-17976931348623157e292,mAl=17976931348623157e292;function pc({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:o,variant:s}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return Ear(e);case"array":return dli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"map":return mli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"reference":return fli({schema:e,fileContainingReference:t,context:n,namespace:i,variant:s});case"unknown":return gli();case"optional":return Iar({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"nullable":return hli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"enum":return wAl({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:o});case"literal":return e.value,Ali(e);case"object":return CAl({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"oneOf":return xAl({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});default:Be(e)}}function Ear(e){switch(e.schema.type){case"string":return AAl({description:e.description,schema:e.schema});case"int":return yAl({description:e.description,schema:e.schema});case"float":return bAl({description:e.description,schema:e.schema});case"double":return EAl({description:e.description,schema:e.schema});case"boolean":return hAl({description:e.description,schema:e.schema});case"int64":return gAl({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",datetimeRfc2822:()=>"datetime-rfc-2822",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function hAl({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function gAl({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function AAl({description:e,schema:t}){let r="string",n=vAl(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function yAl({description:e,schema:t}){let r="integer",n=jgs(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function bAl({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function EAl({description:e,schema:t}){let r="double",n=jgs(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function vAl(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,o=IAl(t);if(!(o==null&&r==null&&n==null&&i==null))return{format:o,pattern:r,minLength:n,maxLength:i}}function IAl(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function jgs(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:o,exclusiveMaximum:s}=e;if(r=pli(r,t),n=pli(n,t),i=pli(i,t),!(r==null&&n==null&&o==null&&s==null&&i==null))return{min:r,max:n,exclusiveMin:o,exclusiveMax:s,multipleOf:i}}function pli(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[pAl,fAl]:[dAl,mAl];return e<r||e>n?void 0:e}function fli({schema:e,fileContainingReference:t,context:r,variant:n}){let i=r.getSchema(e.schema,e.namespace);if(i==null)return"unknown";let o=_Al(i)??e.schema,s=r.options.respectReadonlySchemas&&n!=null?r.getSchemaFinalName(o,n):o,a=zse(i),c=SAl(i),l=war({context:r,fileContainingReference:t,declarationFile:bar({namespace:e.namespace,groupName:a}),type:s});return i.type==="nullable"&&(l=r.options.wrapReferencesToNullableInOptional?`optional<${l}>`:`nullable<${l}>`),i.type==="optional"&&!l.startsWith("optional<")&&(l=`optional<${l}>`),e.description==null&&c==null?l:{type:l,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function dli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=`list<${yp(a)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{},type:c}}function mli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=Ear(e.key),c=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),u=e.encoding!=null?Hvt(e.encoding):void 0,l=`map<${yp(a)}, ${yp(c)}>`;if(e.description==null&&u==null&&e.title==null)return l;let p={type:l};return e.description!=null&&(p.docs=e.description),e.encoding!=null&&(p.encoding=u),e.availability!=null&&(p.availability=sb(e.availability)),p}function hli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){if(!n.options.respectNullableSchemas)return Iar({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=yp(a),u=N6e(a),l=Kvt(a),p=lli(a),d=Ngs(c);if(n.options.wrapReferencesToNullableInOptional&&(d=DOe(d)),e.availability==null&&e.description==null&&u==null&&l==null&&p==null&&e.title==null)return d;let f=typeof d=="string"?{type:d}:d;return(e.description!=null||u!=null)&&(f.docs=e.description??u),l!=null&&(f.default=l),p!=null&&(f.validation=p),e.availability!=null&&(f.availability=sb(e.availability)),f}function Iar({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=yp(a),u=N6e(a),l=Kvt(a),p=lli(a),d=DOe(c);if(e.availability==null&&e.description==null&&u==null&&l==null&&p==null&&e.title==null)return d;let f=typeof d=="string"?{type:d}:d;return(e.description!=null||u!=null)&&(f.docs=e.description??u),l!=null&&(f.default=l),p!=null&&(f.validation=p),e.availability!=null&&(f.availability=sb(e.availability)),f}function gli(){return"unknown"}function Ali(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Be(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function wAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let o=Jvt(e,i),s=e.nameOverride??e.generatedName;n.builder.addType(r,{name:s,schema:o.schema});let a=war({type:s,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return a;let c={type:a};return e.description!=null&&(c.docs=e.description),e.default!=null&&(c.default=e.default.value),e.availability!=null&&(c.availability=sb(e.availability)),c}function CAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=ROe({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:a.schema});let u=war({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function xAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=yli({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:a.schema});let u=war({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function war({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function _Al(e){return ba._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function SAl(e){return ba._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}St();function Vse(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Be(e)}}function Lgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o}){let s;switch(e.type){case"primitive":s=OAl(e);break;case"array":s=BAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":s=TAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":s=PAl({schema:e,context:t,declarationFile:r,namespace:n,variant:o});break;case"unknown":s=RAl(e.nameOverride,e.generatedName,e.description);break;case"optional":s=zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":s=DAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":s=Jvt(e,i);break;case"literal":s=FAl(e,e.nameOverride,e.generatedName);break;case"object":s=ROe({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o});break;case"oneOf":s=yli({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o});break;default:Be(e)}return s}function ROe({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,skipReadonlyProperties:o,variant:s}){let a=o===!0||s==="write",c=!1,u={},l=new Set;for(let g of e.properties){if(g.readonly&&(c=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([x,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([x])=>{bli({property:g.key,schemaId:x,context:t,namespace:n}).forEach(_=>{l.add(_)})})}let A=pc({schema:g.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s}),b=g.audiences,v=g.nameOverride,E=sb(g.availability),I=jAl(g);u[g.key]=QAl({typeReference:A,audiences:b,name:v,availability:E,propertyAccess:I})}let p=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(A=>l.add(A)),g.conflictingTypeSignatures&&p.add(g.propertyKey);let d=[];for(let g of e.allOf){let A=Car({schema:g.schema,context:t,namespace:n});if(A==null||l.has(g.schema)||l.has(A))continue;let b=pc({schema:ba.reference(g),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s});d.push(Q6e(yp(b)))}for(let g of l){let A=j6e(t,g,n);for(let b of A.properties)u[b.key]==null&&(p.has(b.key)&&(u[b.key]="unknown"),u[b.key]=pc({schema:b.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s}));for(let b of A.allOf){if(l.has(b.schema))continue;let v=pc({schema:ba.reference(b),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s});d.push(Q6e(yp(v)))}}let f={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(u).map(([g,A])=>NAl(g)?[g,typeof A=="string"?{type:A,name:`_${g}`}:{...A,name:`_${g}`}]:[g,A]))};d.length>0&&(f.extends=d),e.additionalProperties&&(f["extra-properties"]=!0),e.availability!=null&&(f.availability=sb(e.availability)),e.source!=null&&(f.source=Vse(e.source)),e.encoding!=null&&(f.encoding=Hvt(e.encoding)),f.inline=Eli(e,i);let m=e.nameOverride??e.generatedName;return{name:s==="read"&&c&&t.options.respectReadonlySchemas&&t.hasReadVariant(m)?`${m}Read`:m,schema:f}}function bli({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return bli({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:o,allOf:s}=j6e(r,t,n),a=o.some(u=>u.key===e),c=[...s.flatMap(u=>bli({property:e,context:r,schemaId:u.schema,namespace:n}))];if(a||c.length>0)return[t,...c]}return[]}function Ugs(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?j6e(e,t.schema,r):t.type==="nullable"?Ugs(e,t.value,r):{properties:[],allOf:[]}}function j6e(e,t,r){let n=e.getSchema(t,r);return n==null?{properties:[],allOf:[]}:Ugs(e,n,r)}function BAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:dli({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function TAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:mli({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function OAl(e){let t=Ear(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function Mgs(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Jvt(e,t){let r={enum:e.values.map(o=>{let s=o.nameOverride??o.generatedName,a=o.value;if(s===a&&o.description==null&&(o.casing==null||Mgs(o.casing)))return s;let c={value:o.value};if(s!==a&&(c.name=s),o.description!=null&&(c.docs=o.description),o.casing!=null&&!Mgs(o.casing)){let u={},l=!1;o.casing.camel!=null&&(u.camel=o.casing.camel,l=!0),o.casing.screamingSnake!=null&&(u["screaming-snake"]=o.casing.screamingSnake,l=!0),o.casing.snake!=null&&(u.snake=o.casing.snake,l=!0),o.casing.pascal!=null&&(u.pascal=o.casing.pascal,l=!0),l&&(c.casing=u)}return c})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=Eli(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?Vse(e.source):void 0};for(let o of r.enum){let s=typeof o=="string"?o:o.name??o.value;n.has(s.toLowerCase())||(i.enum.push(o),n.add(s.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function PAl({schema:e,context:t,declarationFile:r,namespace:n,variant:i}){return{name:e.nameOverride??e.generatedName,schema:fli({schema:e,context:t,fileContainingReference:r,namespace:n,variant:i})}}function DAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:hli({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:Iar({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function RAl(e,t,r){return r!=null?{name:e??t,schema:{type:"unknown",docs:r}}:{name:e??t,schema:gli()}}function FAl(e,t,r){return{name:t??r,schema:Ali(e)}}function yli({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o}){let s=e.encoding!=null?Hvt(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let l of e.commonProperties)c[l.key]=pc({schema:l.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1,variant:o});let u={};for(let[l,p]of Object.entries(e.schemas))u[l]=pc({schema:p,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:o});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantPropertyNameOverride!=null?{name:e.discriminantPropertyNameOverride,value:e.discriminantProperty}:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?sb(e.availability):void 0,union:u,encoding:s,source:e.source!=null?Vse(e.source):void 0,...e.discriminatorContext&&{context:e.discriminatorContext}}}}let a=[];for(let c of e.schemas)a.push(pc({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1,variant:o}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:s,source:e.source!=null?Vse(e.source):void 0,inline:Eli(e,i)}}}var kAl=/^[0-9]/;function NAl(e){return kAl.test(e)}function Car({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?Car({context:t,schema:n.schema,namespace:r}):e}function QAl({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function Eli(e,t){return e.inline===!0||t>0?!0:void 0}function jAl(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return xm.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return xm.ObjectPropertyAccess.WriteOnly}}Bi();function Vgs(e){let t=e.replace(/^x-|^X-/,"");return qn(t)}function qgs(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??Vgs(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(Qs.of("__package__.yml"),{name:"OauthScope",schema:Jvt(n.scopesEnum,0).schema})}}Bi();function _$({header:e,context:t,fileContainingReference:r,namespace:n}){let i=pc({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),o=yp(i),s=e.name.replace(/^x-|^X-/,""),a=e.parameterNameOverride!=null?e.parameterNameOverride:qn(s);if(e.description==null&&e.name===a&&e.env==null&&e.availability==null)return o;let c={type:o};return a!==e.name&&(c.name=a),e.description!=null&&(c.docs=e.description),e.env!=null&&(c.env=e.env),e.availability!=null&&(c.availability=sb(e.availability)),c}function xar({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=pc({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return yp(i);let o=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:yp(i)};return e.description!=null&&(o.docs=e.description),e.availability!=null&&(o.availability=sb(e.availability)),o}oA();function Sar({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=vli({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let o=yp(i.value),s=Kvt(i.value);o==="unknown"?o="string":o==="optional<unknown>"&&(o="optional<string>");let a={type:o};return s!=null&&(a.default=s),i.allowMultiple&&(a["allow-multiple"]=!0),e.explode!=null&&(a.explode=e.explode),e.description!=null&&(a.docs=e.description),e.parameterNameOverride!=null&&(a.name=e.parameterNameOverride),e.availability!=null&&(a.availability=sb(e.availability)),MAl(i.value)&&i.value.validation!==void 0&&(a.validation=i.value.validation),a.default==null&&a["allow-multiple"]==null&&a.docs==null&&a.name==null&&a.availability==null&&a.validation==null&&a.explode==null?o:a}function vli({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Qs.of(ef),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,c]of Object.entries(i.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(s=!0),c.type==="literal"&&c.value.type==="string"&&(F6e.test(c.value.value)?o.push(c.value.value):o.push({value:c.value.value,name:k6e(c.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[a,c]=i.value.schemas;if(a!=null&&c!=null&&_ar({array:a,primitive:c}))return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&c!=null&&_ar({array:c,primitive:a}))return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[a,c]of Object.entries(i.value.schemas))return vli({schema:c,context:t,fileContainingReference:r,namespace:n})}else if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?ba.optional:ba.nullable;if(e.value.type==="reference"){let o=t.getSchema(e.value.schema,n);if(o==null)return;if(o.type==="array")return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:o.value,description:e.description??o.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(s=!0),c.type==="literal"&&c.value.type==="string"&&(F6e.test(c.value.value)?o.push(c.value.value):o.push({value:c.value.value,name:k6e(c.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,c]=e.value.value.schemas;if(a!=null&&c!=null&&_ar({array:a,primitive:c}))return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&c!=null&&_ar({array:c,primitive:a}))return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[a,c]of Object.entries(e.value.value.schemas))return vli({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:pc({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}:{value:pc({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function _ar({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function MAl(e){return typeof e=="object"&&e!==null&&"type"in e}St();function Ggs({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=LAl(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=UAl({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Dhe(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function LAl(e){let t={};return e.forEach(r=>{let n=Dhe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function UAl({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let o=Dhe(i.value);r.has(i.name)||o!=null&&(n[i.name]=o)}),n}function Dhe(e){switch(e.type){case"primitive":return Wgs(e.value);case"object":return $gs(e.properties);case"array":return zAl(e.value);case"map":return VAl(e.value);case"oneOf":return qAl(e.value);case"enum":return e.value;case"literal":return GAl(e.value);case"unknown":return Dhe(e.value);case"null":return null;default:Be(e)}}function Wgs(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:Be(e)}}function $gs(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Dhe(r)]))}function zAl(e){return e.map(t=>Dhe(t))}function VAl(e){return Object.fromEntries(e.map(t=>[Wgs(t.key),Dhe(t.value)]))}function qAl(e){return e.type==="discriminated"?$gs(e.value):Dhe(e.value)}function GAl(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Be(e)}}function Yvt(e){try{let r=new URL(e).pathname.split("/").filter(n=>n.length>0);if(r.length>0)return r[r.length-1]}catch{}}function Bar(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function Tar(e,t,r=!1){let n=Yvt(t);return r&&n!=null?n:e!=null&&n!=null?`${e}_${n}`:n??e??"websocket"}function qse(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Oar(e,t){return t??(e?.groupName!=null?qse(e.groupName):void 0)}function Hgs({channel:e,context:t,declarationFile:r}){let n=e.servers[0],i=t.ir.servers.length===0&&t.ir.websocketServers.length<=1,o=n!=null&&!i?t.options.groupEnvironmentsByHost?t.getUrlId(n.url)??Tar(n.name,n.url,!0):n.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${n?.name}", server url="${n?.url}", resolved urlId="${o}" (from collision map: ${t.getUrlId(n?.url??"")!=null})`);let s=e.path;for(let f of e.handshake.pathParameters)f.parameterNameOverride!=null&&(s=s.replace(`{${f.name}}`,`{${f.parameterNameOverride}}`));let a=t.authOverrides?.auth!=null,c={path:s,url:o,auth:a};e.audiences!=null&&e.audiences.length>0&&(c.audiences=e.audiences),e.summary!=null&&(c["display-name"]=e.summary),e.connectMethodName!=null&&(c["connect-method-name"]=e.connectMethodName),e.description!=null&&(c.docs=e.description);let u=qse(e.groupName),l={};if(e.handshake.pathParameters.length>0)for(let f of e.handshake.pathParameters){let m=f.parameterNameOverride??f.name;l[m]=xar({pathParameter:f,context:t,fileContainingReference:r,namespace:u})}Object.keys(l).length>0&&(c["path-parameters"]=l);let p={};if(e.handshake.queryParameters.length>0)for(let f of e.handshake.queryParameters){let m=Sar({queryParameter:f,context:t,fileContainingReference:r,namespace:u});m!=null&&(p[f.name]=m)}Object.keys(p).length>0&&(c["query-parameters"]=p);let d={};if(e.handshake.headers.length>0)for(let f of e.handshake.headers){let m=_$({header:f,context:t,fileContainingReference:r,namespace:u});d[f.name]=m}Object.keys(d).length>0&&(c.headers=d),t.builder.addChannel(r,{channel:c});for(let f of e.messages){let m={origin:f.origin,body:pc({schema:f.body,context:t,fileContainingReference:r,namespace:u,declarationDepth:0})};f.methodName!=null&&(m["method-name"]=f.methodName),t.builder.addChannelMessage(r,{messageId:f.name,message:m})}for(let f of e.examples){let m=Ggs({context:t,websocketExample:f});t.builder.addChannelExample(r,{example:m})}}function Ili(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var II="Base",Ygs="Default";function Kgs(e){try{return new URL(e).hostname}catch{return}}function Jgs(e){return e??Ygs}function WAl(e,t){let r=new Map;for(let n of e){if(Ili(n)||!("url"in n)||!n.url)continue;let i=Kgs(n.url)??n.url;r.has(i)||r.set(i,{environmentName:Jgs(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.httpServers.push({name:n.name,url:n.url,audiences:n.audiences})}for(let n of t){let i=Kgs(n.url)??n.url;r.has(i)||r.set(i,{environmentName:Jgs(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.websocketServers.push(n)}return r}function FOe(e){return Object.entries(e).reduce((t,[r,n])=>(WF(n)?Object.entries(n.urls).forEach(([i,o])=>{t[i]=o}):t[r]=typeof n=="string"?n:n.url,t),{})}function Xgs(e){if(e.environmentOverrides!=null){for(let[E,I]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:E,schema:I});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],n=e.ir.servers.some(E=>Ili(E)),i=e.ir.servers;for(let E of i)if(Ili(E)){let I={urls:{}},w={},x={},C={};for(let[D,V]of Object.entries(E.urls))I.urls[D]=V.defaultUrl??V.url,V.urlTemplate&&(w[D]=V.urlTemplate),V.defaultUrl&&(x[D]=V.defaultUrl),V.variables&&V.variables.length>0&&(C[D]=V.variables);(Object.keys(w).length>0||Object.keys(C).length>0)&&(I["url-templates"]=w,I["default-urls"]=x,I.variables=C),E.name&&(t[E.name]=I)}else if("url"in E&&E.url){let w=E.urlTemplate!=null&&E.variables!=null&&E.variables.length>0?{url:E.url,audiences:E.audiences,"default-url":E.defaultUrl,"url-template":E.urlTemplate,variables:E.variables?.map(x=>({id:x.id,default:x.default,values:x.values}))}:E.audiences?{url:E.url,audiences:E.audiences}:E.url;if(E.name==null){r.push(w);continue}t[E.name]=w}let o={},s={},a=[],c={},u={},l={};for(let E of e.ir.endpoints)for(let I of E.servers){if(I.url==null&&I.name!=null){o[I.name]||(o[I.name]=[]);continue}if(I.url==null)continue;let w=I,x="defaultUrl"in I&&typeof w.defaultUrl=="string"?w.defaultUrl:void 0,C="urlTemplate"in I&&typeof w.urlTemplate=="string"?w.urlTemplate:void 0,_="variables"in I&&Array.isArray(w.variables)?w.variables:void 0,D=x??I.url,V=I.audiences?{url:D,audiences:I.audiences}:D;if(I.name==null){a.push(V);continue}o[I.name]||(o[I.name]=[]),o[I.name]?.push({url:D,audiences:I.audiences}),s[I.name]=V,C&&I.name&&(c[I.name]=C),x&&I.name&&(u[I.name]=x),_&&_.length>0&&I.name&&(l[I.name]=_)}let p={},d=[];for(let E of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${E.name}", url="${E.url}"`);let I=E.audiences?{url:E.url,audiences:E.audiences}:E.url;if(E.name==null){d.push(I);continue}p[E.name]=I}let f=Object.keys(t).length,m=f>0,h=Object.keys(s).length>0,g=Object.keys(o).some(E=>o[E]?.length===0),A=Object.keys(p).length>0;if(e.options.groupEnvironmentsByHost&&A&&(m||e.ir.servers.length>0)){let E=Object.entries(p).map(([w,x])=>({name:w,url:typeof x=="string"?x:x.url,audiences:typeof x=="string"?void 0:x.audiences})),I=WAl(i,E);if(I.size>0){let w=!0;for(let[x,C]of I.entries()){let _={},D=[...C.httpServers.map(q=>({...q,isHttp:!0})),...C.websocketServers.map(q=>({...q,isHttp:!1}))],V=new Map;for(let q of D){let U=Yvt(q.url),W=Bar(q.url);U&&W&&(V.has(U)||V.set(U,new Set),V.get(U)?.add(W))}if(C.httpServers.length>0){let q=C.httpServers[0];q!=null&&(_[II]=q.url,e.setUrlId(q.url,II));for(let U=1;U<C.httpServers.length;U++){let W=C.httpServers[U];if(W!=null){let re=Yvt(W.url),z=Bar(W.url),$=re?V.get(re):void 0,ge=$&&$.size>1,J=ge&&z!=="https"?`${re}_${z}`:re||`Http${U+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${W.url}", pathSegment="${re}", protocol="${z}", hasCollision=${ge}, urlId="${J}"`),_[J]=W.url,e.setUrlId(W.url,J)}}}for(let q of C.websocketServers){let U=Yvt(q.url),W=Bar(q.url),re=U?V.get(U):void 0,z=re&&re.size>1,$=z?`${U}_${W}`:Tar(q.name,q.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${q.name}", url="${q.url}", pathSegment="${U}", protocol="${W}", hasCollision=${z}, urlId="${$}"`),_[$]=q.url,e.setUrlId(q.url,$)}if(Object.keys(_).length>1)e.builder.addEnvironment({name:C.environmentName,schema:{urls:_}});else if(Object.keys(_).length===1){let q=Object.values(_)[0];q!=null&&e.builder.addEnvironment({name:C.environmentName,schema:q})}w&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(C.environmentName),Object.keys(_).length>1&&e.builder.setDefaultUrl(II),w=!1)}return}}if(!m&&!h&&A&&e.ir.servers.length===0){for(let[E,I]of Object.entries(p))e.builder.addEnvironment({name:E,schema:I});e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(Object.keys(p)[0]),e.builder.setDefaultUrl(II);return}if(a.length>0&&e.logger.debug(`Skipping endpoint level servers ${a.map(E=>typeof E=="string"?E:E.url).join(", ")} because x-fern-server-name was not provided.`),!m){let E=e.ir.servers[0],I=E?.url,w=E?.audiences,x=E?.defaultUrl,C=E?.urlTemplate,_=E?.variables;if(I!=null){let V=C!=null&&_!=null&&_.length>0?{url:I,audiences:w,"default-url":x,"url-template":C,variables:_?.map(q=>({id:q.id,default:q.default,values:q.values}))}:w?{url:I,audiences:w}:I;t[Ygs]=V}}let b=Object.values(t).map(E=>typeof E=="string"?E:WF(E)?Object.values(E.urls)[0]:E.url),v=r.filter(E=>{let I=typeof E=="string"?E:E.url;return!b.includes(I)});if(v.length>0&&e.logger.debug(`Skipping top level servers ${v.map(E=>typeof E=="string"?E:E.url).join(", ")} because x-fern-server-name was not provided.`),n){let E=!0;for(let[I,w]of Object.entries(t))if(e.builder.addEnvironment({name:I,schema:w}),E){if(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(I),WF(w)){let x=Object.keys(w.urls)[0];x&&e.builder.setDefaultUrl(x)}E=!1}return}if(!h&&!g){let E=!0;for(let[I,w]of Object.entries(t))if(E){if(A){let x=typeof w=="string"?w:WF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;x!=null&&e.setUrlId(x,II),e.builder.addEnvironment({name:I,schema:{urls:{[II]:x??"",...FOe(p)}}})}else e.builder.addEnvironment({name:I,schema:w});e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(I),E=!1}else if(A){let x=typeof w=="string"?w:WF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;x!=null&&e.setUrlId(x,II),e.builder.addEnvironment({name:I,schema:{urls:{[II]:x??"",...FOe(p)}}})}else e.builder.addEnvironment({name:I,schema:w});A&&e.builder.setDefaultUrl(II)}else if(f===1){let E=Object.keys(t)[0],I=Object.values(t)[0],w=typeof I=="string"?I:WF(I)?Object.values(I.urls)[0]:I["default-url"]??I.url,x={},C={},_={};typeof I!="string"&&!WF(I)&&(I["url-template"]&&(x[II]=I["url-template"]),I["default-url"]&&(C[II]=I["default-url"]),I.variables&&I.variables.length>0&&(_[II]=I.variables)),Object.assign(x,c),Object.assign(C,u),Object.assign(_,l);let D=Object.keys(x).length>0||Object.keys(_).length>0;w!=null&&e.setUrlId(w,II);let V={urls:{[II]:w??"",...FOe(s),...FOe(p)},...D?{"url-templates":x,"default-urls":C,variables:_}:{}};e.builder.addEnvironment({name:E,schema:V}),e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(E),e.builder.setDefaultUrl(II)}else{let E=new Map;for(let I of e.ir.endpoints)for(let w of I.servers)if(w.url!=null&&w.name!=null){E.has(w.name)||E.set(w.name,new Map);let x=w.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",C=E.get(w.name);C&&C.set(x,w.url)}if(E.size>0){let I=!0;for(let[w,x]of Object.entries(t)){let C=typeof x=="string"?x:WF(x)?Object.values(x.urls)[0]:x["default-url"]??x.url;if(!C)continue;e.setUrlId(C,II);let _=C.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",D={[II]:C};for(let[V,q]of E.entries()){let U=q.get(_)||q.get("production")||q.values().next().value;U&&(D[V]=U)}A&&Object.assign(D,FOe(p)),Object.keys(D).length>1?e.builder.addEnvironment({name:w,schema:{urls:D}}):e.builder.addEnvironment({name:w,schema:C}),I&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(w),I=!1)}E.size>0&&e.builder.setDefaultUrl(II)}else{let I=!0;for(let[w,x]of Object.entries(t)){if(A||Object.keys(s).length>0){let C=typeof x=="string"?x:WF(x)?Object.values(x.urls)[0]:x["default-url"]??x.url;C!=null&&e.setUrlId(C,II),e.builder.addEnvironment({name:w,schema:{urls:{[II]:C??"",...FOe(s),...FOe(p)}}})}else e.builder.addEnvironment({name:w,schema:x});I&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(w),I=!1)}}}}oA();Bi();var wli=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},$Al=.75,HAl=new Set(["authorization"]);function Zgs(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let o=n.optional===!0?"optional<string>":"string",s=o;if(n.name==null&&n.env==null&&typeof n.schema=="string")s=n.schema;else if(n!=null){let a=n.schema?zse(n.schema):void 0,c=a!=null?qse(a):void 0,u=Qs.of("api.yml");s={name:n.name,env:n.env,type:n.schema!=null?yp(pc({schema:n.schema,context:e,fileContainingReference:c?G0(Qs.of(qn(c)),u):u,namespace:c,declarationDepth:0}))??o:o}}e.builder.addGlobalHeader({name:r,schema:s})}if(e.options.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let o of i.headers){if(HAl.has(o.name.toLowerCase()))continue;let s=r[o.name];if(s==null){let a=t[o.name],c=_$({header:{...o,schema:a?.schema??o.schema,name:a?.name??o.name},fileContainingReference:Qs.of(H0),context:e,namespace:void 0});s=new wli(c),r[o.name]=s}s.increment()}let n=e.ir.endpoints.length*$Al;for(let[i,o]of Object.entries(r)){let s=t[i],a=o.count===e.ir.endpoints.length,c=o.count>=n;s==null&&(a?e.builder.addGlobalHeader({name:i,schema:o.schema}):c&&e.builder.addGlobalHeader({name:i,schema:DOe(o.schema)}))}}}oA();function eAs(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?zse(t.schema):void 0,n=r!=null?qse(r):void 0,i=_$({header:{...t,schema:t.schema??ba.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ol.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:Qs.of(H0),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:DOe(i)})}}St();oA();St();St();function lT(e){switch(e.type){case"primitive":return rAs(e.value);case"object":return nAs(e.properties);case"array":return iAs(e.value);case"map":return JAl(e.value);case"oneOf":return YAl(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return XAl(e.value);case"unknown":return lT(e.value);case"null":return null;default:Be(e)}}function tAs(e){switch(e.type){case"withStreaming":return e.sse?{stream:KAl(e.events)}:{stream:iAs(e.events)};case"withoutStreaming":return{body:lT(e.value)};default:Be(e)}}function rAs(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:Be(e)}}function nAs(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lT(r)]))}function KAl(e){return e.map(t=>({event:"",data:lT(t)}))}function iAs(e){return e.map(t=>lT(t))}function JAl(e){return Object.fromEntries(e.map(t=>[rAs(t.key),lT(t.value)]))}function YAl(e){return e.type==="discriminated"?nAs(e.value):lT(e.value)}function XAl(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:Be(e)}}function oAs({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=ZAl(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=eyl(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),o=Object.keys(i).length>0,s=new Set(e.headers?.map(a=>a.name)??[]);if(n||o){let a=[];if(e.headers!=null)for(let c of e.headers)c.name!==t.builder.getAuthHeaderName()&&a.push(c);for(let[c,u]of Object.entries(i)){if(u!=null&&typeof u=="object"&&u.type!=null){let l=GE({type:u.type,_default:void 0,validation:void 0,visitor:{primitive:pt,map:pt,list:pt,optional:p=>p,nullable:p=>p,set:pt,named:pt,literal:p=>{if(p.type==="string")return p.string;if(p.type==="boolean")return p.boolean.toString()},unknown:pt}});if(l!=null){let p=a.findIndex(f=>f.name===c),d={name:c,value:lc.literal(Ihe.string(l))};p>=0?a[p]=d:a.push(d);continue}}s.has(c)||a.push({name:c,value:lc.primitive(hs.string(c))})}r.headers=tyl({context:t,namedFullExamples:a})}return e.request!=null&&(r.request=lT(e.request)),e.response!=null&&(r.response=tAs(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(a=>a.type==="language"?{name:a.name??void 0,docs:a.description??void 0,language:a.language,code:a.code,install:a.install??void 0}:{name:a.name??void 0,docs:a.description??void 0,sdk:a.sdk,code:a.code}).filter(ya)),r}function ZAl(e){let t={};return e.forEach(r=>{let n=lT(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function eyl(e){let t={};return e.forEach(r=>{let n=lT(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function tyl({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=lT(n.value);i!=null&&(r[n.name]=i)}),r}var YS;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(YS||(YS={}));function sAs(e){return Ix._visit(e,{get:()=>xm.HttpMethodSchema.Get,post:()=>xm.HttpMethodSchema.Post,put:()=>xm.HttpMethodSchema.Put,patch:()=>xm.HttpMethodSchema.Patch,delete:()=>xm.HttpMethodSchema.Delete,head:()=>xm.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Cli(e){return e==="POST"||e==="PUT"||e==="PATCH"}function aAs({endpoint:e,declarationFile:t,context:r}){let n=[],i=new Set,o=e.path,s=Oar(e.sdkName,e.namespace),a={};for(let h of e.pathParameters)h.parameterNameOverride&&(o=o.replace(h.name,h.parameterNameOverride)),a[h.parameterNameOverride??h.name]=xar({pathParameter:h,context:r,fileContainingReference:t,namespace:s}),i.add(h.name);let c={};for(let h of e.queryParameters){let g=Sar({queryParameter:h,context:r,fileContainingReference:t,namespace:s});g!=null&&(c[h.name]=g,i.add(h.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;case"uri":u={next_uri:e.pagination.nextUri,results:e.pagination.results};break;case"path":u={next_path:e.pagination.nextPath,results:e.pagination.results};break;default:Be(e.pagination)}let l={path:o,method:sAs(e.method),auth:ryl({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Vse(e.source):void 0};!syl({context:r,request:e.request})&&Object.keys(a).length>0&&(l["path-parameters"]=a),e.summary!=null&&(l["display-name"]=e.summary);let p={},d=r.builder.getGlobalHeaderNames(),f=r.builder.getAuthHeaderName();f!=null&&d.add(f);let m=e.headers.filter(h=>!d.has(h.name));for(let h of m){let g=_$({header:h,context:r,fileContainingReference:t,namespace:s});p[h.name]=g,i.add(typeof g=="string"?h.name:g.name??h.name)}if(e.request!=null){r.setInState(YS.Request);let h=oyl({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(a).length>0?a:void 0,queryParameters:Object.keys(c).length>0?c:void 0,headers:Object.keys(p).length>0?p:void 0,usedNames:i,namespace:s});l.request=h.value,n=[...n,...h.schemaIdsToExclude??[]],r.unsetInState(YS.Request)}else{let h=r.options.inlinePathParameters&&Object.keys(a).length>0,g=Object.keys(c).length>0,A=Object.keys(p).length>0,b={};(h||g||A)&&(b.name=e.requestNameOverride??e.generatedRequestName),h&&(b["path-parameters"]=a),g&&(b["query-parameters"]=c),A&&(b.headers=p),Object.keys(b).length>0&&(l.request=b)}if(e.response!=null&&e.response._visit({json:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l.response={docs:h.description??void 0,type:yp(g)},h.statusCode!=null&&(l.response["status-code"]=h.statusCode),h.responseProperty!=null&&(l.response.property=h.responseProperty)},streamingJson:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l["response-stream"]={docs:h.description??void 0,type:yp(g),format:"json",terminator:h.terminator??void 0}},streamingSse:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l["response-stream"]={docs:h.description??void 0,type:yp(g),format:"sse",terminator:h.terminator??void 0}},file:h=>{l.response={docs:h.description??void 0,type:"file","status-code":h.statusCode}},bytes:h=>{l.response={docs:h.description??void 0,type:"bytes","status-code":h.statusCode}},streamingText:h=>{l["response-stream"]={docs:h.description??void 0,type:"text"}},text:h=>{l.response={docs:h.description??void 0,type:"text","status-code":h.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let h=r.getDefaultServerName(),g=e.servers[0];if(g==null)h!=null&&(l.url=h);else{let A=g.url!=null?r.getUrlId(g.url):void 0;l.url=A??g.name??void 0}}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=sb(e.availability)),Object.entries(e.errors).forEach(([h,g])=>{let A=g.generatedName,b=Qs.of(ef);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${g.generatedName}`,g.schema!=null&&(g.schema.type!=="reference"&&g.schema.type!=="oneOf"?g.schema.generatedName=`${e.generatedRequestName}${g.schema.generatedName}`:g.schema.type==="oneOf"&&(g.schema.value.generatedName=`${e.generatedRequestName}${g.schema.value.generatedName}`)));let v={"status-code":parseInt(h)},E=Rgs({location:cAs,namespaceOverride:s});if(g.schema!=null){let x=pc({schema:g.schema,context:r,fileContainingReference:E,declarationFile:E,namespace:s,declarationDepth:0});v.type=yp(x),v.docs=g.description}r.builder.addError(E,{name:A,schema:r.isErrorUnknownSchema(parseInt(h))?{...v,type:"unknown"}:v}),l.errors==null&&(l.errors=[]);let I=r.builder.addImport({file:t,fileToImport:E});l.errors.push(I!=null?`${I}.${A}`:A),v.type!=null&&g.examples?.forEach(x=>{let C={value:lT(x.example),name:x.name,docs:x.description};r.builder.addErrorExample(E,{name:A,example:C})})}),e.examples.length>0&&(l.examples=nyl({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=iyl({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[xli,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function ryl({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function nyl({endpointExamples:e,context:t}){return e.map(r=>{try{return oAs({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function iyl({retries:e}){if(e!=null){if(e.type==="disabled")return{disabled:e.value??void 0};Be(e)}}function oyl({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:o,pathParameters:s,queryParameters:a,headers:c,usedNames:u,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let p=n.schema.type==="reference"?n.schema.schema:void 0,d=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(d?.type!=="object"||p!=null&&r.isResponseReachable(p)){let I=r.options.respectReadonlySchemas&&Cli(e.method)?"write":void 0,w=pc({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0,variant:I}),x={schemaIdsToExclude:[],value:{body:w}},C=Object.keys(s??{}).length>0,_=Object.keys(a??{}).length>0,D=Object.keys(c??{}).length>0;return C&&(x.value["path-parameters"]=s),_&&(x.value["query-parameters"]=a),D&&(x.value.headers=c),(C||_||D)&&(x.value.name=i??o),n.contentType!=null&&(x.value["content-type"]=n.contentType),n.description!=null&&(x.value.docs=n.description),x}let f=new Map;for(let E of d.allOf){let I=r.getSchema(E.schema,l);if(I==null)continue;let w=zse(I),x=Use(w),{properties:C}=j6e(r,E.schema,l);for(let _ of C)f.set(_.key,x)}let m=Object.fromEntries(d.properties.filter(E=>E.readonly==null?!0:!(Cli(e.method)&&E.readonly)).map(E=>{let I=f.get(E.key)??t,w=pc({schema:E.schema,fileContainingReference:t,declarationFile:I,context:r,namespace:l,declarationDepth:1}),x=E.nameOverride??E.key,C=sb(E.availability);if(!u.has(x)&&E.audiences.length<=0)return u.add(x),E.nameOverride!=null?[E.key,{type:yp(w),docs:N6e(w),name:E.nameOverride,availability:C}]:[E.key,C?{...typeof w=="string"?{type:w}:w,availability:C}:w];let _={type:yp(w),docs:N6e(w)};return u.has(x)&&(_.name=E.generatedName),E.audiences.length>0&&(_.audiences=E.audiences),C!=null&&(_.availability=C),u.add(x),[E.key,_]})),h=new Set,g=new Set;for(let E of d.allOfPropertyConflicts)E.allOfSchemaIds.forEach(I=>h.add(I)),E.conflictingTypeSignatures&&g.add(E.propertyKey);let A=[];for(let E of d.allOf){let I=Car({schema:E.schema,context:r,namespace:l});if(I==null||h.has(E.schema)||h.has(I))continue;let w=pc({schema:ba.reference(E),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),x=Q6e(yp(w));x!=="unknown"&&A.push(x)}for(let E of h){let I=j6e(r,E,l),w=r.getSchema(E,l),x=w!=null?Use(zse(w)):t;for(let C of I.properties)m[C.key]==null&&(g.has(C.key)?m[C.key]="unknown":m[C.key]=pc({schema:C.schema,fileContainingReference:t,declarationFile:x,context:r,namespace:l,declarationDepth:1}));for(let C of I.allOf){if(h.has(C.schema))continue;let _=pc({schema:ba.reference(C),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),D=Q6e(yp(_));D!=="unknown"&&!A.includes(D)&&A.push(D)}}let b={properties:m};A.length>0&&(b.extends=A),n.additionalProperties&&(b["extra-properties"]=!0);let v={name:i??d.nameOverride??d.generatedName,"path-parameters":s,"query-parameters":a,headers:c,body:b};return n.contentType!=null&&(v["content-type"]=n.contentType),n.description!=null&&(v.docs=n.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(n.type==="octetStream"){let p={body:"bytes","content-type":n.contentType??Ef.APPLICATION_OCTET_STREAM,"query-parameters":a};return a!=null&&(p.name=i??o),n.description!=null&&(p.docs=n.description),{schemaIdsToExclude:[],value:p}}else if(n.type==="multipart"){let p=Object.fromEntries(n.properties.map(d=>{if(d.schema.type==="file"){let f=d.schema.isArray?"list<file>":"file";if(f=d.schema.isOptional?`optional<${f}>`:f,d.description!=null||d.contentType!=null){let m={type:f};if(d.description!=null&&(m.docs=d.description),d.contentType!=null){let h=d.contentType.split(",")[0];m["content-type"]=h}return[d.key,m]}return[d.key,f]}else{let f=pc({schema:d.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(d.contentType||d.exploded||d.encoding){let m=typeof f=="string"?{type:f}:f;d.contentType!=null&&(m["content-type"]=d.contentType),d.encoding==="form"?m.style="form":d.encoding==="json"?m.style="json":d.exploded&&(m.style="exploded"),f=m}return[d.key,f]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??o,"path-parameters":s,"query-parameters":a,headers:c,body:{properties:p},"content-type":Ef.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else Be(n)}function syl({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:Be(t)}}oA();Bi();function ayl({location:e,namespaceOverride:t}){return t!=null?{...e,file:G0(Qs.of(t),e.file)}:e}function cyl(e){let t=e.namespace,r=e.tags.filter(c=>c!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:Qs.of(`${qn(r)}.yml`),endpointId:e.summary!=null?qn(e.summary):qn(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Qs.of(ef),endpointId:qn(e.summary)}:{file:Qs.of(ef),endpointId:qn(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Qs.of(ef),endpointId:n};let i=Xvt(r),o=Xvt(n);if(q0(i,o))return{file:Qs.of("__package__.yml"),endpointId:r};let s=pyl({operationId:n,tag:r,path:e.path,method:e.method});if(s!=null)return s;let a=[];for(let c=0;c<i.length;++c){let u=i[c];if(u!=null&&u===o[c])a.push(u);else{let l=qn(r);return{file:Qs.of(`${l}.yml`),endpointId:n,tag:r}}}if(a.length>=o.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Qs.of(qn(a.join("_"))+".yml"),endpointId:qn(o.slice(a.length).join("_")),tag:r}}function Zvt(e){let t=e.tags[0];if(e.sdkName!=null){let r=uli({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Qs.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return ayl({namespaceOverride:e.namespace,location:cyl(e)})}function Xvt(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=sU(t),t}var uyl=new RegExp("[^a-zA-Z0-9{}]+"),lyl=new RegExp("[{}]","g");function pyl({operationId:e,tag:t,path:r,method:n}){let o=`${r.split(uyl).join("_").replaceAll(lyl,"_")}_${n.toLowerCase()}`;if(e.endsWith(o))return{file:Qs.of(qn(t)+".yml"),endpointId:qn(e.slice(0,-1*o.length)),tag:t}}function uAs(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let o of r){let{endpointId:s,file:a,tag:c}=Zvt(o),u=a.split(".")[0];u!=null&&t.add(u);let l;if(o.sdkName!=null){let f=e.ir.groups;for(let m of o.sdkName.groupName){let h=typeof m=="string"?m:m.name,g=f[h];if(g==null)break;if(g.summary!=null||g.description!=null){l=f[h];break}}}let p=c==null?void 0:n.tagsById[c];e.setInState(YS.Endpoint),e.setEndpointMethod(o.method);let d=aAs({context:e,endpoint:o,declarationFile:a});e.unsetEndpointMethod(),e.unsetInState(YS.Endpoint),i=[...i,...d.schemaIdsToExclude],e.builder.addEndpoint(a,{name:s,schema:d.value,source:o.source!=null?Vse(o.source):void 0}),(p?.id!=null||p?.description!=null)&&e.builder.setServiceInfo(a,{"display-name":l?.summary??p?.id,docs:l?.description??p?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}oA();function lAs(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?qse(r.groupName):void 0,i=pc({schema:ba.primitive(r),context:e,fileContainingReference:Qs.of(ef),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:yp(i),docs:r.description??void 0}})}}oA();Bi();function dAs(e){for(let t of e.ir.webhooks){let r=myl({webhook:t,context:e});if(r==null)continue;let n=Oar(t.sdkName,t.namespace),i={};for(let s of t.headers)i[s.name]=_$({header:s,context:e,fileContainingReference:r.file,namespace:n});let o={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:pc({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),signature:hyl(t.signatureVerification),examples:t.examples!=null?t.examples.map(s=>({docs:s.description,name:s.name,payload:lT(s.payload)})):void 0};t.response!=null&&t.response._visit({json:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o.response={docs:s.description??void 0,type:yp(a)},s.statusCode!=null&&(o.response["status-code"]=s.statusCode)},file:s=>{o.response={docs:s.description??void 0,type:"file","status-code":s.statusCode}},bytes:s=>{o.response={docs:s.description??void 0,type:"bytes","status-code":s.statusCode}},text:s=>{o.response={docs:s.description??void 0,type:"text","status-code":s.statusCode}},streamingJson:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:yp(a),format:"json"}},streamingSse:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:yp(a),format:"sse"}},streamingText:s=>{o["response-stream"]={docs:s.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:o}),t.description!=null&&(o.docs=t.description)}}function fyl({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:G0(Qs.of(t),e.file)}:e}function dyl({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:Qs.of(ef),endpointId:n};let i=Xvt(r),o=Xvt(n);if(q0(i,o))return{file:Qs.of("__package__.yml"),endpointId:r};let s=[];for(let a=0;a<i.length;++a){let c=i[a];if(c!=null&&c===o[a])s.push(c);else{let u=qn(r);return{file:Qs.of(`${u}.yml`),endpointId:n,tag:r}}}if(s.length>=o.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Qs.of(qn(s.join("_"))+".yml"),endpointId:qn(o.slice(s.length).join("_")),tag:r}}function myl({webhook:e,context:t}){return e.sdkName!=null?{file:Dgs({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:fyl({namespaceOverride:e.namespace,location:dyl({webhook:e,context:t})})}function hyl(e){if(e!=null)switch(e.type){case"hmac":return{type:"hmac",header:e.header,algorithm:gyl(e.algorithm),encoding:pAs(e.encoding),"signature-prefix":e.signaturePrefix,"payload-format":yyl(e.payloadFormat),timestamp:fAs(e.timestamp)};case"asymmetric":return{type:"asymmetric",header:e.header,"asymmetric-algorithm":Ayl(e.asymmetricAlgorithm),encoding:pAs(e.encoding),"signature-prefix":e.signaturePrefix,"jwks-url":e.jwksUrl,"key-id-header":e.keyIdHeader,timestamp:fAs(e.timestamp)};default:return}}function gyl(e){if(e!=null)switch(e){case"sha256":return"sha256";case"sha1":return"sha1";case"sha384":return"sha384";case"sha512":return"sha512";default:return}}function pAs(e){if(e!=null)switch(e){case"base64":return"base64";case"hex":return"hex";default:return}}function Ayl(e){switch(e){case"rsa-sha256":return"rsa-sha256";case"rsa-sha384":return"rsa-sha384";case"rsa-sha512":return"rsa-sha512";case"ecdsa-sha256":return"ecdsa-sha256";case"ecdsa-sha384":return"ecdsa-sha384";case"ecdsa-sha512":return"ecdsa-sha512";case"ed25519":return"ed25519";default:return"rsa-sha256"}}function yyl(e){if(e!=null)return{components:e.components.map(byl),delimiter:e.delimiter}}function byl(e){switch(e){case"body":return"body";case"timestamp":return"timestamp";case"notification-url":return"notification-url";case"message-id":return"message-id";default:return"body"}}function Eyl(e){switch(e){case"unix-seconds":return"unix-seconds";case"unix-millis":return"unix-millis";case"iso8601":return"iso8601";default:return}}function fAs(e){if(e!=null)return{header:e.header,format:e.format!=null?Eyl(e.format):void 0,tolerance:e.tolerance}}St();function Rhe(e,t,r){switch(e.type){case"primitive":case"enum":case"literal":case"unknown":return;case"reference":{let n=e.schema;if(r.has(n))return;r.add(n);let i=mAs(n,e.namespace,t);i!=null&&Rhe(i,t,r);return}case"object":for(let n of e.allOf)if(!r.has(n.schema)){r.add(n.schema);let i=mAs(n.schema,n.namespace,t);i!=null&&Rhe(i,t,r)}for(let n of e.properties)Rhe(n.schema,t,r);return;case"array":case"map":case"optional":case"nullable":Rhe(e.value,t,r);return;case"oneOf":vyl(e.value,t,r);return;default:Be(e)}}function vyl(e,t,r){switch(e.type){case"discriminated":for(let n of Object.values(e.schemas))Rhe(n,t,r);for(let n of e.commonProperties)Rhe(n.schema,t,r);return;case"undiscriminated":for(let n of e.schemas)Rhe(n,t,r);return;default:Be(e)}}function mAs(e,t,r){return t==null?r.rootSchemas[e]:r.namespacedSchemas[t]?.[e]}function XU(e,t,r){Rhe(e,t,r)}function hAs(e){let t=new Set,r=new Set,{groupedSchemas:n}=e;for(let i of e.endpoints){if(i.request!=null)switch(i.request.type){case"json":case"formUrlEncoded":XU(i.request.schema,n,t);break;case"multipart":for(let o of i.request.properties)o.schema.type==="json"&&XU(o.schema.value,n,t);break;case"octetStream":break;default:Be(i.request)}if(i.response!=null)switch(i.response.type){case"json":case"streamingJson":case"streamingSse":XU(i.response.schema,n,r);break;case"file":case"text":case"bytes":case"streamingText":break;default:Be(i.response)}for(let o of Object.values(i.errors))o.schema!=null&&XU(o.schema,n,r);for(let o of i.pathParameters)XU(o.schema,n,r);for(let o of i.queryParameters)XU(o.schema,n,r);for(let o of i.headers)XU(o.schema,n,r)}for(let i of e.webhooks)XU(i.payload,n,r);for(let i of Object.values(e.channels)){for(let o of i.messages)XU(o.body,n,r);for(let o of i.handshake.queryParameters)XU(o.schema,n,r);for(let o of i.handshake.headers)XU(o.schema,n,r);for(let o of i.handshake.pathParameters)XU(o.schema,n,r)}return{requestReachable:t,responseReachable:r}}function Iyl(e){return e.type!=="object"?!1:e.properties.some(t=>t.readonly===!0)}function gAs(e,t){let r=new Set,n=new Set,i=new Set;function o(s){for(let[a,c]of Object.entries(s)){if(!Iyl(c))continue;let u=t.requestReachable.has(a),l=t.responseReachable.has(a);u&&l?r.add(a):u&&!l?n.add(a):!u&&l&&i.add(a)}}o(e.groupedSchemas.rootSchemas);for(let s of Object.values(e.groupedSchemas.namespacedSchemas))o(s);return{needsBothVariants:r,requestOnlyWithReadonly:n,responseOnlyWithReadonly:i}}var xli="external",cAs=Qs.of(ef);function AAs({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,o]of Object.entries(e)){if(t.has(i))continue;let s=Fgs(o);if(n.options.respectReadonlySchemas&&n.needsBothVariants(i)&&o.type==="object"){let u=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,variant:"read"});n.builder.addType(s,{name:u.name??i,schema:u.schema});let l=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,skipReadonlyProperties:!0,variant:"write"});n.builder.addType(s,{name:l.name??i,schema:l.schema});continue}if(n.options.respectReadonlySchemas&&n.isRequestOnlyWithReadonly(i)&&o.type==="object"){let u=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,skipReadonlyProperties:!0,variant:"write"});n.builder.addType(s,{name:u.name??i,schema:u.schema});continue}let a;n.options.respectReadonlySchemas&&(a=n.isRequestOnly(i)?"write":"read");let c=Lgs({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,variant:a});if(Wme(c.schema)){let u=yp(c.schema);if(u===(c.name??i)||u===`optional<${c.name??i}>`||u===`nullable<${c.name??i}>`||u===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(s,{name:c.name??i,schema:c.schema})}}function yAs(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Xgs(e),Zgs(e),eAs(e),qgs(e),lAs(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(xli);let t=uAs(e),r=t.sdkGroups;e.setInState(YS.Webhook),dAs(e),e.unsetInState(YS.Webhook),e.setInState(YS.Channel);for(let i of Object.values(e.ir.channels)){let o=Use(i.groupName);Hgs({channel:i,context:e,declarationFile:o})}e.unsetInState(YS.Channel);let n=wyl({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});if(e.options.respectReadonlySchemas){let i=hAs(e.ir),o=gAs(e.ir,i);e.setVariantPlan(o,i)}AAs({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,o]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))AAs({schemas:o,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(o=>r.has(o))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function wyl({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return new Set(t);let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(o=>Object.keys(o))]),i=new Set(t);for(let o of n)r.includes(o)||i.add(o);return i}St();var eIt=class{context;constructor(t){this.context=t}};oA();Bi();oA();var Par=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[s,a]of Object.entries(n.files)){let c=i!=null?Qs.of(`${i}${"/"}${s}`):Qs.of(s);t[c]=a}let o=Object.keys(n.directories).sort();for(let s of o){let a=i!=null?`${i}${"/"}${s}`:s,c=n.directories[s];r(c,a)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Qs.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var kOe=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new Par,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":n,"display-name":i,docs:o}){let s=this.getOrCreateFile(t);s.service==null&&(s.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(s.service.auth=r),n!=null&&(s.service["base-path"]=n),i!=null&&(s.service["display-name"]=i),o!=null&&(s.docs=o)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return n$(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let n of Object.values(this.rootApiFile["auth-schemes"]))bAs(n)&&t.push(n.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(bAs(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??qn((gU(r)+"/"+qB(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Qs.of(H0))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=_ze(gU(xze.of(`/${t}`)),xze.of(`/${r}`)),i;let o=this.getOrCreateFile(t);return o.imports==null&&(o.imports={}),o.imports[i]=_ze(gU(xze.of(`/${t}`)),xze.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===Qs.of(H0))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let o=i.types[r];o!=null&&(typeof o=="string"?i.types[r]={type:o,examples:[n]}:(o.examples==null&&(o.examples=[]),o.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let o=i.errors[r];if(o==null)return;o.examples==null&&(o.examples=[]),(o.examples.some(a=>q0(a,n))??!1)||o.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(o.service.source=i),o.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=G0(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let n=Object.values(r.service.endpoints);if(n.length===0)continue;if(n.every(o=>o.auth===!0)){r.service.auth=!0;for(let o of Object.values(r.service.endpoints))delete o.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,o])=>[i,{...o,path:G0(r,o.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([o,s])=>[o,{...s,path:G0(r,s.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ef?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function bAs(e){return e?.header!=null}var Dar=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;schemaNameMapping=new Map;variantPlan;reachability;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:o,authOverrides:s}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=s,this.globalHeaderOverrides=o,this.options=BOe({options:n}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new kOe(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let a={};if(!this.enableUniqueErrorsPerEndpoint)for(let c of r.endpoints)for(let[u,l]of Object.entries(c.errors)){let p=parseInt(u),d=a[p];d==null&&l.schema!=null?a[p]=l.schema:d!=null&&l.schema!=null&&ik(d,l.schema)||this.unknownSchema.add(p)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(YS.Channel,YS.Endpoint,YS.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Be(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:Be(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}setSchemaFinalName(t,r){this.schemaNameMapping.set(t,r)}hasReadVariant(t){return this.schemaNameMapping.has(t)}setVariantPlan(t,r){this.variantPlan=t,this.reachability=r;let n=[this.ir.groupedSchemas.rootSchemas,...Object.values(this.ir.groupedSchemas.namespacedSchemas)];for(let i of n)for(let[o,s]of Object.entries(i))if(t.needsBothVariants.has(o)&&s.type==="object"){let a=s.nameOverride??s.generatedName;this.schemaNameMapping.set(a,`${a}Read`)}}needsBothVariants(t){return this.variantPlan?.needsBothVariants.has(t)??!1}isRequestOnlyWithReadonly(t){return this.variantPlan?.requestOnlyWithReadonly.has(t)??!1}isResponseReachable(t){return this.reachability==null?this.ir.nonRequestReferencedSchemas.has(t):this.reachability.responseReachable.has(t)}isRequestOnly(t){return this.reachability==null?!this.ir.nonRequestReferencedSchemas.has(t):this.reachability.requestReachable.has(t)&&!this.reachability.responseReachable.has(t)}getSchemaFinalName(t,r){return!this.options.respectReadonlySchemas||r==="write"?t:this.schemaNameMapping.get(t)??t}};function _li(e){let t=new Dar(e);return yAs(t)}oA();function kAs(e){return typeof e>"u"||e===null}function Cyl(e){return typeof e=="object"&&e!==null}function xyl(e){return Array.isArray(e)?e:kAs(e)?[]:[e]}function _yl(e,t){var r,n,i,o;if(t)for(o=Object.keys(t),r=0,n=o.length;r<n;r+=1)i=o[r],e[i]=t[i];return e}function Syl(e,t){var r="",n;for(n=0;n<t;n+=1)r+=e;return r}function Byl(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Tyl=kAs,Oyl=Cyl,Pyl=xyl,Dyl=Syl,Ryl=Byl,Fyl=_yl,Hw={isNothing:Tyl,isObject:Oyl,toArray:Pyl,repeat:Dyl,isNegativeZero:Ryl,extend:Fyl};function NAs(e,t){var r="",n=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(r+=`
|
|
1468
|
+
`)),{ok:!0,value:t}):n}}function oor(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var ZVe=class e extends Error{errors;constructor(t){super(t.map(oor).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var e6e=class e extends Error{errors;constructor(t){super(t.map(oor).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Wd(e){return{nullable:()=>Xgl(e),optional:()=>eli(e),optionalNullable:()=>Zgl(e),transform:t=>tli(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new e6e(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new ZVe(n.errors)}}}function Xgl(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.NULLABLE};return{...t,...Wd(t)}}function eli(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.OPTIONAL};return{...t,...Wd(t)}}function Zgl(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>Cu.OPTIONAL_NULLABLE};return{...t,...Wd(t)}}function tli(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Wd(r)}}function Yhs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:md(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:md(t,"bigint")}]}:{ok:!0,value:t},getType:()=>Cu.BIGINT};return{...Cx(e),...Wd(e)}}var eAl=/^([+-]?\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 Xhs(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:md(t,"string")}]}:eAl.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:md(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:md(t,"Date object")}]},getType:()=>Cu.DATE};return{...Cx(e),...Wd(e)}}function xx(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Cx(r),...Wd(r)}}}function sor(e){let t=new Set(e);return xx(Cu.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:md(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:md(n,"enum")}]}:{ok:!0,value:n})()}function Zhs(e){let t=rli(e);return{...t,...Wd(t)}}function rli(e){return{parse:(t,r)=>t6e(e).parse(t,r),json:(t,r)=>t6e(e).json(t,r),getType:()=>t6e(e).getType()}}function t6e(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function nli(e){return Object.entries(e)}function Vvt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function Mse(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function qvt(e){return Object.keys(e)}function egs(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var tAl=Object.prototype.hasOwnProperty;function sq(e){return{withParsedProperties:t=>ili(e,t)}}function ili(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(tAl.call(t,a)){let c=t[a];s[a]=typeof c=="function"?c(o.value):c}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!Mse(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:md(n,"object")}]};let o=new Set(Object.keys(t)),s=Vvt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Wd(r),...sq(r)}}function tgs(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Lse(e){return e.isProperty}var rAl=Object.prototype.hasOwnProperty;function aor(e){let t;function r(){if(t==null){t={};for(let[d,f]of nli(e)){let m=Lse(f)?f.rawKey:d,h=Lse(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of nli(e)){let m=Lse(f)?f.rawKey:d,h=Lse(f)?f.valueSchema:f;nAl(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function c(){return i==null&&a(),i}function u(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Lse(f)?f.rawKey:d),_getParsedProperties:()=>qvt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return rgs({value:d,requiredKeys:a(),requiredKeysSet:u(),getProperty:h=>{let g=r()[h];if(g!=null)return{transformedKey:g.parsedKey,transform:A=>{let b=[...m,h];return g.valueSchema.parse(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return rgs({value:d,requiredKeys:c(),requiredKeysSet:l(),getProperty:h=>{let g=e[h];if(g!=null)return Lse(g)?{transformedKey:g.rawKey,transform:A=>{let b=[...m,h];return g.valueSchema.json(A,{...f,breadcrumbsPrefix:b})}}:{transformedKey:h,transform:A=>{let b=[...m,h];return g.json(A,{...f,breadcrumbsPrefix:b})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>Cu.OBJECT};return{...Cx(p),...Wd(p),...sq(p),...OOe(p)}}function rgs({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!Mse(e))return{ok:!1,errors:[{path:s,message:md(e,"object")}]};let a=t.length,c=[],u={};for(let l in e){if(!rAl.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?u[d.transformedKey]=f.value:(u[l]=p,c.push(...f.errors))}else switch(i){case"fail":c.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":u[l]=p;break}}if(a>0)for(let l of t)l in e||c.push({path:s,message:`Missing required key "${l}"`});return c.length===0||o?{ok:!0,value:u}:{ok:!1,errors:c}}function OOe(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>ngs({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>ngs({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Cu.OBJECT};return{...r,...Wd(r),...sq(r),...OOe(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))t.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[c,u]of Object.entries(i))r.has(c)||(a[c]=u);return{ok:!0,value:{...a,...s.value}}},getType:()=>Cu.OBJECT};return{...n,...Wd(n),...sq(n),...OOe(n)}}}}function ngs({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!Mse(t))return{ok:!1,errors:[{path:i,message:md(t,"object")}]};let o=new Set(e),[s,a]=egs(qvt(t),l=>o.has(l)),c=r(Vvt(t,a)),u=n(Vvt(t,s));return c.ok&&u.ok?{ok:!0,value:{...c.value,...u.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...u.ok?[]:u.errors]}}function nAl(e){return!iAl(e)}function iAl(e){switch(e.getType()){case Cu.ANY:case Cu.UNKNOWN:case Cu.OPTIONAL:case Cu.OPTIONAL_NULLABLE:return!0;default:return!1}}function igs(e){return aor(e)}function ogs(e){let t={...rli(e),_getRawProperties:()=>t6e(e)._getRawProperties(),_getParsedProperties:()=>t6e(e)._getParsedProperties()};return{...t,...Wd(t),...sq(t),...OOe(t)}}function cor(e){let t={parse:(r,n)=>sgs(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>sgs(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>Cu.LIST};return{...Cx(t),...Wd(t)}}function sgs(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:md(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function ags(e){return xx(Cu.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:md(r,`${e.toString()}`)}]})()}function cgs(e){return xx(Cu.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:md(r,`"${e}"`)}]})()}var ugs=xx(Cu.ANY,e=>({ok:!0,value:e}));var lgs=xx(Cu.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"boolean")}]});var pgs=xx(Cu.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var fgs=xx(Cu.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"number")}]});var dgs=xx(Cu.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:md(e,"string")}]});var mgs=xx(Cu.UNKNOWN,e=>({ok:!0,value:e}));var oAl=Object.prototype.hasOwnProperty;function ggs(e,t){let r={parse:(n,i)=>hgs({value:n,isKeyNumeric:e.getType()===Cu.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>hgs({value:n,isKeyNumeric:e.getType()===Cu.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>Cu.RECORD};return{...Cx(r),...Wd(r)}}function hgs({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!Mse(e))return{ok:!1,errors:[{path:i,message:md(e,"object")}]};let o={},s=[];for(let a in e){if(!oAl.call(e,a))continue;let c=e[a];if(c===void 0)continue;let u=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(u=d)}let l=r(u),p=n(c,u);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function Ags(e){let t=cor(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:md(n,"Set")}]},getType:()=>Cu.SET};return{...Cx(r),...Wd(r)}}function bgs(e){let t={parse:(r,n)=>ygs((i,o)=>i.parse(r,o),e,n),json:(r,n)=>ygs((i,o)=>i.json(r,o),e,n),getType:()=>Cu.UNDISCRIMINATED_UNION};return{...Cx(t),...Wd(t)}}function ygs(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function Egs(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var sAl=Object.prototype.hasOwnProperty;function Igs(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=sor(qvt(t)),o={parse:(s,a)=>vgs({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:c=>i.parse(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.parse(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>vgs({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:c=>i.json(c,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:c=>t[c],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(c,u)=>u.json(c,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>Cu.UNION};return{...Cx(o),...Wd(o),...sq(o)}}function vgs({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!Mse(e))return{ok:!1,errors:[{path:a,message:md(e,"object")}]};let c=e[t],u={};for(let f in e)sAl.call(e,f)&&f!==t&&(u[f]=e[f]);if(c==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(c);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...u}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(u,p);return d.ok?{ok:!0,value:{[r]:c,...d.value}}:d}var uor=K.objectWithoutOptionalProperties({usernameVariableName:K.string().optional(),usernameEnvVar:K.string().optional(),passwordVariableName:K.string().optional(),passwordEnvVar:K.string().optional()});var lor=K.objectWithoutOptionalProperties({tokenVariableName:K.string().optional(),tokenEnvVar:K.string().optional()});var por=K.objectWithoutOptionalProperties({typeName:K.string()});var dor=K.union("type",{protobuf:por}).transform({transform:e=>e.type==="protobuf"?XVe.protobuf(e):e,untransform:({_visit:e,...t})=>t});var mor=K.objectWithoutOptionalProperties({headerName:K.string(),prefix:K.string().optional(),headerVariableName:K.string().optional(),headerEnvVar:K.string().optional()});var hor=K.objectWithoutOptionalProperties({type:K.stringLiteral("namespace"),name:K.string()});var gor=K.string();var Aor=K.enum_(["GenerallyAvailable","Beta","Deprecated"]);var us=K.objectWithoutOptionalProperties({availability:Aor.optional()});var mn=K.objectWithoutOptionalProperties({description:K.string().optional()});var Lf=K.objectWithoutOptionalProperties({inline:K.boolean().optional()});var Nc=K.objectWithoutOptionalProperties({nameOverride:K.string().optional(),generatedName:K.string()});var oc=K.objectWithoutOptionalProperties({namespace:K.string().optional()});var yor=K.undiscriminatedUnion([K.string(),hor]);var Che=K.list(yor);var xu=K.objectWithoutOptionalProperties({groupName:Che.optional()});var bor=K.objectWithoutOptionalProperties({file:K.string()});var Eor=K.objectWithoutOptionalProperties({file:K.string()});var vor=K.union("type",{openapi:bor,protobuf:Eor}).transform({transform:e=>{switch(e.type){case"openapi":return uT.openapi(e);case"protobuf":return uT.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var $o=K.objectWithoutOptionalProperties({source:vor.optional()});var _u=K.objectWithoutOptionalProperties({title:K.string().optional()});var Ior=K.objectWithoutOptionalProperties({snake:K.string().optional(),camel:K.string().optional(),screamingSnake:K.string().optional(),pascal:K.string().optional()});var xhe=K.objectWithoutOptionalProperties({nameOverride:K.string().optional(),generatedName:K.string(),value:K.string(),casing:Ior.optional()}).extend(mn).extend(us);var r6e=K.objectWithoutOptionalProperties({default:xhe.optional(),values:K.list(xhe)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u).extend(Lf);var wor=K.objectWithoutOptionalProperties({scopesEnum:r6e.optional()});var Cor=K.objectWithoutOptionalProperties({queryParameterName:K.string()});var HP=K.string();var xor=K.union("type",{basic:uor,bearer:lor,header:mor,query:Cor,oauth:wor}).transform({transform:e=>{switch(e.type){case"basic":return Ex.basic(e);case"bearer":return Ex.bearer(e);case"header":return Ex.header(e);case"query":return Ex.query(e);case"oauth":return Ex.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var _he=K.string();var _or=K.objectWithoutOptionalProperties({id:K.string(),default:K.string().optional(),values:K.list(K.string()).optional()});var Gvt=K.objectWithoutOptionalProperties({name:K.string().optional(),url:K.string(),audiences:K.list(K.string()).optional(),defaultUrl:K.string().optional(),urlTemplate:K.string().optional(),variables:K.list(_or).optional()}).extend(mn);var I$=K.number();var KP=K.string();var Sor=K.objectWithoutOptionalProperties({id:KP}).extend(mn);var _x=K.objectWithoutOptionalProperties({encoding:dor.optional()});var w$=K.objectWithoutOptionalProperties({sdkMethodName:K.string().optional()});var YU=K.objectWithoutOptionalProperties({statusCode:I$.optional()});var sli={};te(sli,{FullExample:()=>Vm,FullObjectExample:()=>Oor,FullOneOfExample:()=>Por,KeyValuePair:()=>Dor,LiteralExample:()=>Bor,NullExample:()=>Tor,PrimitiveExample:()=>n6e,PropertyKey:()=>i6e});var Bor=K.union("type",{boolean:K.object({value:K.boolean()}),string:K.object({value:K.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ihe.boolean(e.value);case"string":return Ihe.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Tor=K.objectWithoutOptionalProperties({});var n6e=K.union("type",{int:K.object({value:K.number()}),int64:K.object({value:K.number()}),uint:K.object({value:K.number()}),uint64:K.object({value:K.number()}),float:K.object({value:K.number()}),double:K.object({value:K.number()}),string:K.object({value:K.string()}),datetime:K.object({value:K.string()}),datetimeRfc2822:K.object({value:K.string()}),date:K.object({value:K.string()}),base64:K.object({value:K.string()}),boolean:K.object({value:K.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return hs.int(e.value);case"int64":return hs.int64(e.value);case"uint":return hs.uint(e.value);case"uint64":return hs.uint64(e.value);case"float":return hs.float(e.value);case"double":return hs.double(e.value);case"string":return hs.string(e.value);case"datetime":return hs.datetime(e.value);case"datetimeRfc2822":return hs.datetimeRfc2822(e.value);case"date":return hs.date(e.value);case"base64":return hs.base64(e.value);case"boolean":return hs.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Vm=K.union("type",{primitive:K.object({value:n6e}),object:K.lazyObject(()=>Oor),array:K.object({value:K.list(K.lazy(()=>Vm))}),map:K.object({value:K.list(K.lazyObject(()=>Dor))}),enum:K.object({value:K.string()}),literal:K.object({value:Bor}),oneOf:K.object({value:K.lazy(()=>Por)}),null:Tor,unknown:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"primitive":return lc.primitive(e.value);case"object":return lc.object(e);case"array":return lc.array(e.value);case"map":return lc.map(e.value);case"enum":return lc.enum(e.value);case"literal":return lc.literal(e.value);case"oneOf":return lc.oneOf(e.value);case"null":return lc.null(e);case"unknown":return lc.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var i6e=K.string();var Oor=K.objectWithoutOptionalProperties({properties:K.record(i6e,K.lazy(()=>Vm))});var Por=K.union("type",{discriminated:K.object({value:K.record(i6e,K.lazy(()=>Vm))}),undiscriminated:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return vhe.discriminated(e.value);case"undiscriminated":return vhe.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Dor=K.objectWithoutOptionalProperties({key:n6e,value:K.lazy(()=>Vm)});var ali={};te(ali,{AllOfPropertyConflict:()=>o6e,ArraySchema:()=>Ror,AsymmetricAlgorithm:()=>For,AsymmetricWebhookSignatureVerification:()=>Nor,Availability:()=>Aor,BooleanSchema:()=>Qor,BytesResponse:()=>c6e,CasingOverrides:()=>Ior,CommonProperty:()=>jor,CursorPagination:()=>Mor,CustomCodeSample:()=>Vor,CustomCodeSampleLanguage:()=>Lor,CustomCodeSampleSdk:()=>zor,CustomPagination:()=>qor,DiscriminatedOneOfSchema:()=>Gor,DiscriminatorContext:()=>u6e,DoubleSchema:()=>Wor,Endpoint:()=>usr,EndpointExample:()=>f6e,EndpointResponseExample:()=>Kor,EndpointSdkName:()=>C$,EndpointSecurity:()=>d6e,EnumSchema:()=>r6e,EnumValue:()=>xhe,ErrorExample:()=>Xor,FernExample:()=>$or,FileResponse:()=>v6e,FileSchema:()=>ssr,FormUrlEncodedRequest:()=>nsr,FullEndpointExample:()=>Yor,GlobalHeader:()=>lsr,GlobalSecurity:()=>psr,Header:()=>She,HeaderExample:()=>l6e,HmacWebhookSignatureVerification:()=>hsr,HttpEndpointServer:()=>m6e,HttpError:()=>Zor,HttpMethod:()=>h6e,IdempotencyHeader:()=>gsr,IntSchema:()=>Asr,JsonRequest:()=>isr,JsonResponse:()=>I6e,LiteralSchema:()=>x6e,LiteralSchemaValue:()=>ysr,LongSchema:()=>bsr,MapSchema:()=>Isr,MultipartFormDataWebhookPayload:()=>wsr,MultipartRequest:()=>b6e,MultipartRequestProperty:()=>Bhe,MultipartRequestPropertyEncoding:()=>osr,MultipartSchema:()=>asr,NullableSchema:()=>Csr,ObjectProperty:()=>xsr,ObjectPropertyConflictInfo:()=>_6e,ObjectSchema:()=>_sr,OctetStreamRequest:()=>E6e,OffsetPagination:()=>esr,OneOfSchema:()=>Ssr,OpenApiIntermediateRepresentation:()=>wgs,OptionalSchema:()=>Lsr,Pagination:()=>g6e,PathPagination:()=>tsr,PathParameter:()=>A6e,PathParameterExample:()=>Jor,PrimitiveSchema:()=>Ohe,PrimitiveSchemaValue:()=>vsr,QueryParameter:()=>y6e,QueryParameterExample:()=>p6e,ReferencedSchema:()=>x$,Request:()=>csr,Response:()=>w6e,RetriesConfiguration:()=>C6e,Schema:()=>$u,Schemas:()=>Tsr,SdkGroupInfo:()=>Osr,StreamingResponseExample:()=>Hor,StringSchema:()=>Esr,SupportedSdkLanguage:()=>Uor,Tags:()=>Psr,TextResponse:()=>The,UnDiscriminatedOneOfSchema:()=>Bsr,UnknownSchema:()=>Usr,UriPagination:()=>rsr,Webhook:()=>Dsr,WebhookExampleCall:()=>S6e,WebhookHttpMethod:()=>B6e,WebhookPayloadComponent:()=>fsr,WebhookPayloadFormat:()=>dsr,WebhookSignatureAlgorithm:()=>msr,WebhookSignatureEncoding:()=>s6e,WebhookSignatureVerification:()=>T6e,WebhookTimestamp:()=>a6e,WebhookTimestampFormat:()=>kor,WebsocketChannel:()=>Msr,WebsocketHandshake:()=>Rsr,WebsocketMessageExample:()=>Qsr,WebsocketMessageOrigin:()=>Fsr,WebsocketMessageSchema:()=>ksr,WebsocketServer:()=>Nsr,WebsocketSessionExample:()=>jsr});var o6e=K.objectWithoutOptionalProperties({propertyKey:K.string(),allOfSchemaIds:K.list(HP),conflictingTypeSignatures:K.boolean()});var Ror=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u),minItems:K.number().optional(),maxItems:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var For=K.enum_(["rsa-sha256","rsa-sha384","rsa-sha512","ecdsa-sha256","ecdsa-sha384","ecdsa-sha512","ed25519"]);var s6e=K.enum_(["base64","hex"]);var kor=K.enum_(["unix-seconds","unix-millis","iso8601"]);var a6e=K.objectWithoutOptionalProperties({header:K.string(),format:kor.optional(),tolerance:K.number().optional()});var Nor=K.objectWithoutOptionalProperties({header:K.string(),asymmetricAlgorithm:For,encoding:s6e.optional(),signaturePrefix:K.string().optional(),jwksUrl:K.string().optional(),keyIdHeader:K.string().optional(),timestamp:a6e.optional()});var Qor=K.objectWithoutOptionalProperties({default:K.boolean().optional()});var c6e=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var jor=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>$u)});var Mor=K.objectWithoutOptionalProperties({cursor:K.string(),nextCursor:K.property("next_cursor",K.string()),results:K.string()});var Lor=K.objectWithoutOptionalProperties({name:K.string().optional(),language:K.string(),code:K.string(),install:K.string().optional()}).extend(mn);var Uor=K.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var zor=K.objectWithoutOptionalProperties({name:K.string().optional(),sdk:Uor,code:K.string()}).extend(mn);var Vor=K.union("type",{language:Lor,sdk:zor}).transform({transform:e=>{switch(e.type){case"language":return b$.language(e);case"sdk":return b$.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var qor=K.objectWithoutOptionalProperties({results:K.string()});var u6e=K.enum_(["data","protocol"]);var Gor=K.objectWithoutOptionalProperties({discriminantProperty:K.string(),discriminantPropertyNameOverride:K.string().optional(),discriminatorContext:u6e.optional(),commonProperties:K.list(K.lazyObject(()=>jor)),schemas:K.record(K.string(),K.lazy(()=>$u))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Wor=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional()});var $or=K.unknown();var Hor=K.objectWithoutOptionalProperties({sse:K.boolean(),events:K.list(K.lazy(()=>Vm))});var Kor=K.union("type",{withStreaming:Hor,withoutStreaming:K.object({value:K.lazy(()=>Vm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return JU.withStreaming(e);case"withoutStreaming":return JU.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var l6e=K.objectWithoutOptionalProperties({name:K.string(),value:K.lazy(()=>Vm)});var Jor=K.objectWithoutOptionalProperties({name:K.string(),parameterNameOverride:K.string().optional(),value:K.lazy(()=>Vm)});var p6e=K.objectWithoutOptionalProperties({name:K.string(),value:K.lazy(()=>Vm)});var Yor=K.objectWithoutOptionalProperties({name:K.string().optional(),pathParameters:K.list(Jor).optional(),queryParameters:K.list(p6e).optional(),headers:K.list(l6e).optional(),request:K.lazy(()=>Vm).optional(),response:Kor.optional(),codeSamples:K.list(Vor)}).extend(mn);var f6e=K.union("type",{unknown:K.object({value:$or}),full:Yor}).transform({transform:e=>{switch(e.type){case"unknown":return KU.unknown(e.value);case"full":return KU.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var C$=K.objectWithoutOptionalProperties({groupName:Che,methodName:K.string()});var d6e=K.list(K.record(_he,K.list(K.string())));var She=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),env:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var m6e=K.objectWithoutOptionalProperties({name:K.string().optional(),url:K.string().optional(),audiences:K.list(K.string()).optional()});var Xor=K.objectWithoutOptionalProperties({name:K.string().optional(),description:K.string().optional(),example:K.lazy(()=>Vm)});var Zor=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u).optional(),examples:K.list(Xor).optional()}).extend(mn).extend(Nc).extend($o);var h6e=K.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var esr=K.objectWithoutOptionalProperties({offset:K.string(),results:K.string(),step:K.string().optional(),hasNextPage:K.string().optional()});var tsr=K.objectWithoutOptionalProperties({nextPath:K.string(),results:K.string()});var rsr=K.objectWithoutOptionalProperties({nextUri:K.string(),results:K.string()});var g6e=K.union("type",{cursor:Mor,offset:esr,custom:qor,uri:rsr,path:tsr}).transform({transform:e=>{switch(e.type){case"cursor":return $w.cursor(e);case"offset":return $w.offset(e);case"custom":return $w.custom(e);case"uri":return $w.uri(e);case"path":return $w.path(e);default:return e}},untransform:({_visit:e,...t})=>t});var A6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),variableReference:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var y6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>$u),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var nsr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),contentType:K.string().optional(),additionalProperties:K.boolean()}).extend(mn).extend($o);var isr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),contentType:K.string().optional(),additionalProperties:K.boolean()}).extend(mn).extend($o);var osr=K.enum_(["json","form"]);var ssr=K.objectWithoutOptionalProperties({isOptional:K.boolean(),isArray:K.boolean()}).extend(mn);var asr=K.union("type",{file:ssr,json:K.object({value:K.lazy(()=>$u)})}).transform({transform:e=>{switch(e.type){case"file":return E$.file(e);case"json":return E$.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Bhe=K.objectWithoutOptionalProperties({key:K.string(),schema:asr,contentType:K.string().optional(),exploded:K.boolean().optional(),encoding:osr.optional()}).extend(mn);var b6e=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var E6e=K.objectWithoutOptionalProperties({contentType:K.string().optional()}).extend(mn).extend($o);var csr=K.union("type",{octetStream:E6e,multipart:b6e,json:isr,formUrlEncoded:nsr}).transform({transform:e=>{switch(e.type){case"octetStream":return oq.octetStream(e);case"multipart":return oq.multipart(e);case"json":return oq.json(e);case"formUrlEncoded":return oq.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var v6e=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var I6e=K.objectWithoutOptionalProperties({schema:K.lazy(()=>$u),responseProperty:K.string().optional(),terminator:K.string().optional()}).extend(mn).extend($o).extend(YU);var The=K.objectWithoutOptionalProperties({}).extend(mn).extend($o).extend(YU);var w6e=K.union("type",{file:v6e,json:I6e,text:The,bytes:c6e,streamingSse:I6e,streamingText:The,streamingJson:I6e}).transform({transform:e=>{switch(e.type){case"file":return JS.file(e);case"json":return JS.json(e);case"text":return JS.text(e);case"bytes":return JS.bytes(e);case"streamingSse":return JS.streamingSse(e);case"streamingText":return JS.streamingText(e);case"streamingJson":return JS.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var C6e=K.union("type",{disabled:K.object({value:K.boolean().optional()})}).transform({transform:e=>e.type==="disabled"?Lvt.disabled(e.value):e,untransform:({_visit:e,...t})=>t});var usr=K.objectWithoutOptionalProperties({authed:K.boolean(),security:d6e.optional(),internal:K.boolean().optional(),idempotent:K.boolean().optional(),method:h6e,audiences:K.list(K.string()),path:K.string(),summary:K.string().optional(),operationId:K.string().optional(),tags:K.list(KP),pathParameters:K.list(A6e),queryParameters:K.list(y6e),headers:K.list(She),sdkName:C$.optional(),generatedRequestName:K.string(),requestNameOverride:K.string().optional(),request:csr.optional(),response:w6e.optional(),errors:K.record(I$,Zor),servers:K.list(m6e),examples:K.list(f6e),pagination:g6e.optional(),retries:C6e.optional()}).extend(mn).extend(us).extend($o).extend(oc);var lsr=K.objectWithoutOptionalProperties({header:K.string(),name:K.string().optional(),optional:K.boolean().optional(),env:K.string().optional(),schema:K.lazy(()=>$u).optional()});var psr=K.list(K.record(_he,K.list(K.string())));var fsr=K.enum_(["body","timestamp","notification-url","message-id"]);var dsr=K.objectWithoutOptionalProperties({components:K.list(fsr),delimiter:K.string().optional()});var msr=K.enum_(["sha256","sha1","sha384","sha512"]);var hsr=K.objectWithoutOptionalProperties({header:K.string(),algorithm:msr.optional(),encoding:s6e.optional(),signaturePrefix:K.string().optional(),payloadFormat:dsr.optional(),timestamp:a6e.optional()});var gsr=K.objectWithoutOptionalProperties({header:K.string(),name:K.string().optional(),env:K.string().optional(),schema:K.lazy(()=>$u).optional()});var Asr=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional()});var ysr=K.union("type",{boolean:K.object({value:K.boolean()}),string:K.object({value:K.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return pA.boolean(e.value);case"string":return pA.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var x6e=K.objectWithoutOptionalProperties({value:ysr}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var bsr=K.objectWithoutOptionalProperties({default:K.number().optional()});var Esr=K.objectWithoutOptionalProperties({default:K.string().optional(),pattern:K.string().optional(),format:K.string().optional(),minLength:K.number().optional(),maxLength:K.number().optional()});var vsr=K.union("type",{int:Asr,int64:bsr,uint:K.object({}),uint64:K.object({}),float:K.object({}),double:Wor,string:Esr,datetime:K.object({}),datetimeRfc2822:K.object({}),date:K.object({}),base64:K.object({}),boolean:Qor}).transform({transform:e=>{switch(e.type){case"int":return ol.int(e);case"int64":return ol.int64(e);case"uint":return ol.uint();case"uint64":return ol.uint64();case"float":return ol.float();case"double":return ol.double(e);case"string":return ol.string(e);case"datetime":return ol.datetime();case"datetimeRfc2822":return ol.datetimeRfc2822();case"date":return ol.date();case"base64":return ol.base64();case"boolean":return ol.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ohe=K.objectWithoutOptionalProperties({schema:vsr}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var Isr=K.objectWithoutOptionalProperties({key:Ohe,value:K.lazy(()=>$u),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend(_u).extend(Lf);var wsr=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var Csr=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var _6e=K.objectWithoutOptionalProperties({differentSchema:K.boolean()});var xsr=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>$u),readonly:K.boolean().optional(),writeonly:K.boolean().optional(),conflict:K.record(HP,_6e),generatedName:K.string(),nameOverride:K.string().optional(),audiences:K.list(K.string())}).extend(us);var x$=K.objectWithoutOptionalProperties({schema:HP}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u);var _sr=K.objectWithoutOptionalProperties({allOf:K.list(x$),properties:K.list(K.lazyObject(()=>xsr)),allOfPropertyConflicts:K.list(o6e),additionalProperties:K.boolean(),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Ssr=K.union("type",{discriminated:K.lazyObject(()=>Gor),undiscriminated:K.lazyObject(()=>Bsr)}).transform({transform:e=>{switch(e.type){case"discriminated":return v$.discriminated(e);case"undiscriminated":return v$.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tsr=K.objectWithoutOptionalProperties({rootSchemas:K.record(HP,K.lazy(()=>$u)),namespacedSchemas:K.record(gor,K.record(HP,K.lazy(()=>$u)))});var Osr=K.objectWithoutOptionalProperties({summary:K.string().optional(),description:K.string().optional()});var Psr=K.objectWithoutOptionalProperties({tagsById:K.record(KP,Sor),orderedTagIds:K.list(KP).optional()});var S6e=K.objectWithoutOptionalProperties({name:K.string().optional(),payload:K.lazy(()=>Vm)}).extend(mn);var B6e=K.enum_(["GET","POST"]);var T6e=K.union("type",{hmac:hsr,asymmetric:Nor}).transform({transform:e=>{switch(e.type){case"hmac":return TOe.hmac(e);case"asymmetric":return TOe.asymmetric(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dsr=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),sdkName:C$.optional(),method:B6e,summary:K.string().optional(),operationId:K.string(),tags:K.list(KP),headers:K.list(She),generatedPayloadName:K.string(),payload:K.lazy(()=>$u),multipartFormData:wsr.optional(),response:w6e.optional(),signatureVerification:T6e.optional(),examples:K.list(S6e)}).extend(mn).extend($o).extend(oc);var Rsr=K.objectWithoutOptionalProperties({queryParameters:K.list(y6e),headers:K.list(She),pathParameters:K.list(A6e)});var Fsr=K.enum_(["client","server"]);var ksr=K.objectWithoutOptionalProperties({name:K.string(),origin:Fsr,body:K.lazy(()=>$u),methodName:K.string().optional()});var Nsr=K.objectWithoutOptionalProperties({name:K.string(),url:K.string()});var Qsr=K.objectWithoutOptionalProperties({messageType:K.string(),payload:K.lazy(()=>Vm)}).extend(mn);var jsr=K.objectWithoutOptionalProperties({name:K.string().optional(),queryParameters:K.list(p6e).optional(),headers:K.list(l6e).optional(),messages:K.list(Qsr)}).extend(mn);var Msr=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),path:K.string(),groupName:Che,summary:K.string().optional(),connectMethodName:K.string().optional(),handshake:Rsr,messages:K.list(ksr),servers:K.list(Nsr),examples:K.list(jsr)}).extend(mn).extend($o);var wgs=K.objectWithoutOptionalProperties({apiVersion:K.unknown().optional(),title:K.string().optional(),description:K.string().optional(),basePath:K.string().optional(),servers:K.list(Gvt),websocketServers:K.list(Gvt),groups:K.record(K.string(),Osr),tags:Psr,hasEndpointsMarkedInternal:K.boolean(),endpoints:K.list(usr),webhooks:K.list(Dsr),channels:K.record(K.string(),Msr),groupedSchemas:Tsr,variables:K.record(K.string(),Ohe),nonRequestReferencedSchemas:K.set(HP),securitySchemes:K.record(_he,xor),security:psr.optional(),globalHeaders:K.list(lsr).optional(),idempotencyHeaders:K.list(gsr).optional()});var Lsr=K.objectWithoutOptionalProperties({value:K.lazy(()=>$u)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var Usr=K.objectWithoutOptionalProperties({}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var $u=K.union("type",{primitive:Ohe,object:K.lazyObject(()=>_sr),array:K.lazyObject(()=>Ror),map:K.lazyObject(()=>Isr),optional:K.lazyObject(()=>Lsr),enum:r6e,reference:x$,literal:x6e,oneOf:K.object({value:K.lazy(()=>Ssr)}),nullable:K.lazyObject(()=>Csr),unknown:Usr}).transform({transform:e=>{switch(e.type){case"primitive":return ba.primitive(e);case"object":return ba.object(e);case"array":return ba.array(e);case"map":return ba.map(e);case"optional":return ba.optional(e);case"enum":return ba.enum(e);case"reference":return ba.reference(e);case"literal":return ba.literal(e);case"oneOf":return ba.oneOf(e.value);case"nullable":return ba.nullable(e);case"unknown":return ba.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bsr=K.objectWithoutOptionalProperties({schemas:K.list(K.lazy(()=>$u))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var cli={};te(cli,{ArraySchemaWithExample:()=>zsr,Base64WithExample:()=>Vsr,BooleanWithExample:()=>qsr,CommonPropertyWithExample:()=>Gsr,DateWithExample:()=>Wsr,DatetimeWithExample:()=>Wvt,DiscriminatedOneOfSchemaWithExample:()=>$sr,DoubleWithExample:()=>Hsr,EndpointWithExample:()=>Cgs,EnumSchemaWithExample:()=>rar,FloatWithExample:()=>nar,HeaderWithExample:()=>Phe,HttpErrorWithExample:()=>Ksr,Int64WithExample:()=>iar,IntWithExample:()=>oar,JsonRequestWithExample:()=>Ysr,JsonResponseWithExample:()=>P6e,MapSchemaWithExample:()=>lar,MultipartFormDataWebhookPayloadWithExample:()=>par,NamedFullExample:()=>nk,NullableSchemaWithExample:()=>far,ObjectPropertyWithExample:()=>dar,ObjectSchemaWithExample:()=>mar,OneOfSchemaWithExample:()=>har,OptionalSchemaWithExample:()=>Aar,ParseFormUrlEncodedRequest:()=>Xsr,ParseMultipartRequest:()=>Zsr,ParseOctetStreamRequest:()=>ear,PathParameterWithExample:()=>Jsr,PrimitiveSchemaValueWithExample:()=>uar,PrimitiveSchemaWithExample:()=>R6e,QueryParameterWithExample:()=>O6e,RequestWithExample:()=>tar,ResponseWithExample:()=>D6e,SchemaWithExample:()=>Uf,StringSchemaWithExample:()=>sar,Uint64WithExample:()=>aar,UintWithExample:()=>car,UnDiscriminatedOneOfSchemaWithExample:()=>gar,UnknownSchemaWithExample:()=>yar,WebhookWithExample:()=>xgs,WebsocketHandshakeWithExample:()=>_gs});var zsr=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf),minItems:K.number().optional(),maxItems:K.number().optional(),example:K.list(K.unknown()).optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var Vsr=K.objectWithoutOptionalProperties({example:K.string().optional()});var qsr=K.objectWithoutOptionalProperties({default:K.boolean().optional(),example:K.boolean().optional()});var Gsr=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>Uf)});var Wvt=K.objectWithoutOptionalProperties({example:K.string().optional()});var Wsr=K.objectWithoutOptionalProperties({example:K.string().optional()});var $sr=K.objectWithoutOptionalProperties({discriminantProperty:K.string(),discriminantPropertyNameOverride:K.string().optional(),discriminatorContext:u6e.optional(),commonProperties:K.list(K.lazyObject(()=>Gsr)),schemas:K.record(K.string(),K.lazy(()=>Uf))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var Hsr=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional(),example:K.number().optional()});var Phe=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),env:K.string().optional(),parameterNameOverride:K.string().optional()}).extend(mn).extend(us).extend($o);var nk=K.objectWithoutOptionalProperties({name:K.string().optional(),value:K.unknown()}).extend(mn);var Ksr=K.objectWithoutOptionalProperties({statusCode:I$,schema:K.lazy(()=>Uf),fullExamples:K.list(nk).optional()}).extend(mn).extend(Nc).extend($o);var Jsr=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),variableReference:K.string().optional(),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var O6e=K.objectWithoutOptionalProperties({name:K.string(),schema:K.lazy(()=>Uf),parameterNameOverride:K.string().optional(),explode:K.boolean().optional()}).extend(mn).extend(us).extend($o);var Ysr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),contentType:K.string().optional(),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean()}).extend(mn).extend($o).extend(w$);var Xsr=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),contentType:K.string().optional(),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean()}).extend(mn).extend($o).extend(w$);var Zsr=K.objectWithoutOptionalProperties({fullExamples:K.list(nk).optional()}).extend(b6e).extend(w$);var ear=K.objectWithoutOptionalProperties({}).extend(E6e).extend(w$);var tar=K.union("type",{octetStream:ear,multipart:Zsr,json:Ysr,formUrlEncoded:Xsr}).transform({transform:e=>{switch(e.type){case"octetStream":return $P.octetStream(e);case"multipart":return $P.multipart(e);case"json":return $P.json(e);case"formUrlEncoded":return $P.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var P6e=K.objectWithoutOptionalProperties({schema:K.lazy(()=>Uf),responseProperty:K.string().optional(),terminator:K.string().optional(),fullExamples:K.list(nk).optional()}).extend(mn).extend($o).extend(YU);var D6e=K.union("type",{file:v6e,json:P6e,text:The,bytes:c6e,streamingSse:P6e,streamingText:The,streamingJson:P6e}).transform({transform:e=>{switch(e.type){case"file":return Rh.file(e);case"json":return Rh.json(e);case"text":return Rh.text(e);case"bytes":return Rh.bytes(e);case"streamingSse":return Rh.streamingSse(e);case"streamingText":return Rh.streamingText(e);case"streamingJson":return Rh.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Cgs=K.objectWithoutOptionalProperties({authed:K.boolean(),security:d6e.optional(),internal:K.boolean().optional(),idempotent:K.boolean().optional(),method:h6e,audiences:K.list(K.string()),path:K.string(),summary:K.string().optional(),operationId:K.string().optional(),tags:K.list(KP),pathParameters:K.list(Jsr),queryParameters:K.list(O6e),headers:K.list(Phe),sdkName:C$.optional(),generatedRequestName:K.string(),requestNameOverride:K.string().optional(),request:tar.optional(),response:D6e.optional(),errors:K.record(I$,Ksr),servers:K.list(m6e),examples:K.list(f6e),pagination:g6e.optional(),retries:C6e.optional()}).extend(mn).extend(us).extend($o).extend(oc);var rar=K.objectWithoutOptionalProperties({default:xhe.optional(),values:K.list(xhe),example:K.string().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend($o).extend(_u).extend(Lf);var nar=K.objectWithoutOptionalProperties({example:K.number().optional()});var iar=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var oar=K.objectWithoutOptionalProperties({default:K.number().optional(),minimum:K.number().optional(),maximum:K.number().optional(),exclusiveMinimum:K.boolean().optional(),exclusiveMaximum:K.boolean().optional(),multipleOf:K.number().optional(),example:K.number().optional()});var sar=K.objectWithoutOptionalProperties({default:K.string().optional(),pattern:K.string().optional(),format:K.string().optional(),minLength:K.number().optional(),maxLength:K.number().optional(),example:K.string().optional()});var aar=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var car=K.objectWithoutOptionalProperties({default:K.number().optional(),example:K.number().optional()});var uar=K.union("type",{int:oar,int64:iar,uint:car,uint64:aar,float:nar,double:Hsr,string:sar,datetime:Wvt,datetimeRfc2822:Wvt,date:Wsr,base64:Vsr,boolean:qsr}).transform({transform:e=>{switch(e.type){case"int":return xi.int(e);case"int64":return xi.int64(e);case"uint":return xi.uint(e);case"uint64":return xi.uint64(e);case"float":return xi.float(e);case"double":return xi.double(e);case"string":return xi.string(e);case"datetime":return xi.datetime(e);case"datetimeRfc2822":return xi.datetimeRfc2822(e);case"date":return xi.date(e);case"base64":return xi.base64(e);case"boolean":return xi.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var R6e=K.objectWithoutOptionalProperties({schema:uar}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var lar=K.objectWithoutOptionalProperties({key:R6e,value:K.lazy(()=>Uf),minProperties:K.number().optional(),maxProperties:K.number().optional(),example:K.unknown().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend(_u).extend(Lf);var par=K.objectWithoutOptionalProperties({name:K.string().optional(),properties:K.list(Bhe)}).extend(mn).extend($o);var far=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var dar=K.objectWithoutOptionalProperties({key:K.string(),schema:K.lazy(()=>Uf),readonly:K.boolean().optional(),writeonly:K.boolean().optional(),audiences:K.list(K.string()),conflict:K.record(HP,_6e),nameOverride:K.string().optional(),generatedName:K.string()}).extend(us);var mar=K.objectWithoutOptionalProperties({allOf:K.list(x$),properties:K.list(K.lazyObject(()=>dar)),allOfPropertyConflicts:K.list(o6e),fullExamples:K.list(nk).optional(),additionalProperties:K.boolean(),minProperties:K.number().optional(),maxProperties:K.number().optional()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var har=K.union("type",{discriminated:K.lazyObject(()=>$sr),undiscriminated:K.lazyObject(()=>gar)}).transform({transform:e=>{switch(e.type){case"discriminated":return vj.discriminated(e);case"undiscriminated":return vj.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Aar=K.objectWithoutOptionalProperties({value:K.lazy(()=>Uf)}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u).extend(Lf);var yar=K.objectWithoutOptionalProperties({example:K.unknown()}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_u);var Uf=K.union("type",{primitive:R6e,object:K.lazyObject(()=>mar),array:K.lazyObject(()=>zsr),map:K.lazyObject(()=>lar),optional:K.lazyObject(()=>Aar),enum:rar,reference:x$,literal:x6e,oneOf:K.object({value:K.lazy(()=>har)}),nullable:K.lazyObject(()=>far),unknown:yar}).transform({transform:e=>{switch(e.type){case"primitive":return Fr.primitive(e);case"object":return Fr.object(e);case"array":return Fr.array(e);case"map":return Fr.map(e);case"optional":return Fr.optional(e);case"enum":return Fr.enum(e);case"reference":return Fr.reference(e);case"literal":return Fr.literal(e);case"oneOf":return Fr.oneOf(e.value);case"nullable":return Fr.nullable(e);case"unknown":return Fr.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var gar=K.objectWithoutOptionalProperties({schemas:K.list(K.lazy(()=>Uf))}).extend(xu).extend(oc).extend(Nc).extend(mn).extend(us).extend(_x).extend($o).extend(_u).extend(Lf);var xgs=K.objectWithoutOptionalProperties({audiences:K.list(K.string()),sdkName:C$.optional(),method:B6e,summary:K.string().optional(),operationId:K.string(),tags:K.list(KP),headers:K.list(Phe),generatedPayloadName:K.string(),payload:K.lazy(()=>Uf),multipartFormData:par.optional(),response:D6e.optional(),signatureVerification:T6e.optional(),examples:K.list(S6e)}).extend(mn).extend($o).extend(oc);var _gs=K.objectWithoutOptionalProperties({queryParameters:K.list(O6e),headers:K.list(Phe)});var Sgs=/^(\d+)/,F6e=/^[a-zA-Z][a-zA-Z0-9_]*$/,Bgs={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function POe(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let s=Math.floor(e/10),a=e%10;return a===0?n[s]:`${n[s]}_${t[a]}`}if(e<1e3){let s=Math.floor(e/100),a=e%100;return a===0?`${t[s]}_hundred`:`${t[s]}_hundred_${POe(a)}`}let i=Math.floor(e/1e3),o=e%1e3;return o===0?`${t[i]}_thousand`:`${t[i]}_thousand_${POe(o)}`}Bi();function $vt(e){let t=e.match(Sgs);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let o=POe(i);return n.length>0?`${o}_${n}`:o}}}function k6e(e){let t=$vt(e),r=Bgs[e];return t!=null?gu(qn(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":gu(qn(e)))}Bi();function ik(e,t){return e.type==="primitive"&&t.type==="primitive"?Tgs(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?aAl(e.values,t.values):e.type==="array"&&t.type==="array"?ik(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?ik(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?cAl(e.value,t.value):e.type==="object"&&t.type==="object"?uAl(e,t):e.type==="map"&&t.type==="map"?Tgs(e.key.schema,t.key.schema)&&ik(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Tgs(e,t){return e.type===t.type}function aAl(e,t){let r=new Set(e.map(i=>i.value)),n=new Set(t.map(i=>i.value));return q0(r,n)}function cAl(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:ik(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:ik(r,i)}):!1}function uAl(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let o=r[n];return o==null?!1:ik(o,i.schema)})}St();function sb(e){switch(e){case vx.Deprecated:return"deprecated";case vx.Beta:return"pre-release";case vx.GenerallyAvailable:return"generally-available";default:return}}St();function Hvt(e){if(e.type==="protobuf")return{proto:{type:e.typeName}};Be(e.type)}St();St();oA();Bi();function Ogs(e){let t=e.match(/^(_+)/),r=e.match(/(_+)$/),n=t?.[1]??"",i=r?.[1]??"";if(n===""&&i==="")return qn(e);if(n.length+i.length>=e.length)return e;let o=e.slice(n.length,e.length-i.length||void 0);return`${n}${qn(o)}${i}`}function lAl(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function Pgs(e){let t=e?lAl(e):void 0;if(t==null||t.length===0)return dOe;let r=[];for(let[n,i]of t.entries())typeof i=="string"?r.push(Ogs(i)):typeof i=="object"?i.type==="namespace"?n<t.length-1?r.push(Ogs(i.name)):r.push(i.name,dOe):Be(i.type):Be(i);return r.join("/")}function Use(e){return Qs.of(`${Pgs(e)}.yml`)}function uli({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?dOe:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,Pgs(r))}function Dgs({sdkName:e,namespaceOverride:t}){return Qs.of(`${uli({sdkName:e,namespaceOverride:t})}.yml`)}function Rgs({location:e,namespaceOverride:t}){return t!=null?G0(Qs.of(t),e):e}function Fgs(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"unknown":return bar({namespace:e.namespace,groupName:e.groupName});case"oneOf":return bar({namespace:e.value.namespace,groupName:e.value.groupName});default:Be(e)}}function bar({namespace:e,groupName:t}){return e!=null&&t!=null?Use([{type:"namespace",name:e},...t]):e!=null?Use([{type:"namespace",name:e}]):Use(t)}St();function zse(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":case"unknown":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;default:Be(e)}}function yp(e){return typeof e=="string"?e:e.type}function N6e(e){if(typeof e!="string")return e.docs}function Kvt(e){if(typeof e!="string")return e.default}function lli(e){if(typeof e!="string")return e.validation}function Q6e(e){let t=e.match(/^optional<\s*nullable<\s*(.+)\s*>\s*>$/);if(t!=null&&t[1]!=null)return t[1].trim();let r=e.match(/^nullable<\s*(.+)\s*>$/);return r!=null&&r[1]!=null?r[1].trim():e}function Ngs(e){let t=yp(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?kgs(e):{...e,type:kgs(e.type)}}function kgs(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function DOe(e){return yp(e).startsWith("optional<")?e:typeof e=="string"?Qgs(e):{...e,type:Qgs(e.type)}}function Qgs(e){return e.startsWith("optional<")?e:`optional<${e}>`}var pAl=-2147483648,fAl=2147483647,dAl=-17976931348623157e292,mAl=17976931348623157e292;function pc({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:o,variant:s}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return Ear(e);case"array":return dli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"map":return mli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"reference":return fli({schema:e,fileContainingReference:t,context:n,namespace:i,variant:s});case"unknown":return gli();case"optional":return Iar({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"nullable":return hli({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"enum":return wAl({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:o});case"literal":return e.value,Ali(e);case"object":return CAl({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});case"oneOf":return xAl({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});default:Be(e)}}function Ear(e){switch(e.schema.type){case"string":return AAl({description:e.description,schema:e.schema});case"int":return yAl({description:e.description,schema:e.schema});case"float":return bAl({description:e.description,schema:e.schema});case"double":return EAl({description:e.description,schema:e.schema});case"boolean":return hAl({description:e.description,schema:e.schema});case"int64":return gAl({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",datetimeRfc2822:()=>"datetime-rfc-2822",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function hAl({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function gAl({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function AAl({description:e,schema:t}){let r="string",n=vAl(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function yAl({description:e,schema:t}){let r="integer",n=jgs(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function bAl({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function EAl({description:e,schema:t}){let r="double",n=jgs(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function vAl(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,o=IAl(t);if(!(o==null&&r==null&&n==null&&i==null))return{format:o,pattern:r,minLength:n,maxLength:i}}function IAl(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function jgs(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:o,exclusiveMaximum:s}=e;if(r=pli(r,t),n=pli(n,t),i=pli(i,t),!(r==null&&n==null&&o==null&&s==null&&i==null))return{min:r,max:n,exclusiveMin:o,exclusiveMax:s,multipleOf:i}}function pli(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[pAl,fAl]:[dAl,mAl];return e<r||e>n?void 0:e}function fli({schema:e,fileContainingReference:t,context:r,variant:n}){let i=r.getSchema(e.schema,e.namespace);if(i==null)return"unknown";let o=_Al(i)??e.schema,s=r.options.respectReadonlySchemas&&n!=null?r.getSchemaFinalName(o,n):o,a=zse(i),c=SAl(i),l=war({context:r,fileContainingReference:t,declarationFile:bar({namespace:e.namespace,groupName:a}),type:s});return i.type==="nullable"&&(l=r.options.wrapReferencesToNullableInOptional?`optional<${l}>`:`nullable<${l}>`),i.type==="optional"&&!l.startsWith("optional<")&&(l=`optional<${l}>`),e.description==null&&c==null?l:{type:l,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function dli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=`list<${yp(a)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{},type:c}}function mli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=Ear(e.key),c=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),u=e.encoding!=null?Hvt(e.encoding):void 0,l=`map<${yp(a)}, ${yp(c)}>`;if(e.description==null&&u==null&&e.title==null)return l;let p={type:l};return e.description!=null&&(p.docs=e.description),e.encoding!=null&&(p.encoding=u),e.availability!=null&&(p.availability=sb(e.availability)),p}function hli({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){if(!n.options.respectNullableSchemas)return Iar({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o,variant:s});let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=yp(a),u=N6e(a),l=Kvt(a),p=lli(a),d=Ngs(c);if(n.options.wrapReferencesToNullableInOptional&&(d=DOe(d)),e.availability==null&&e.description==null&&u==null&&l==null&&p==null&&e.title==null)return d;let f=typeof d=="string"?{type:d}:d;return(e.description!=null||u!=null)&&(f.docs=e.description??u),l!=null&&(f.default=l),p!=null&&(f.validation=p),e.availability!=null&&(f.availability=sb(e.availability)),f}function Iar({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=pc({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=yp(a),u=N6e(a),l=Kvt(a),p=lli(a),d=DOe(c);if(e.availability==null&&e.description==null&&u==null&&l==null&&p==null&&e.title==null)return d;let f=typeof d=="string"?{type:d}:d;return(e.description!=null||u!=null)&&(f.docs=e.description??u),l!=null&&(f.default=l),p!=null&&(f.validation=p),e.availability!=null&&(f.availability=sb(e.availability)),f}function gli(){return"unknown"}function Ali(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Be(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function wAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let o=Jvt(e,i),s=e.nameOverride??e.generatedName;n.builder.addType(r,{name:s,schema:o.schema});let a=war({type:s,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return a;let c={type:a};return e.description!=null&&(c.docs=e.description),e.default!=null&&(c.default=e.default.value),e.availability!=null&&(c.availability=sb(e.availability)),c}function CAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=ROe({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:a.schema});let u=war({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function xAl({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}){let a=yli({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o,variant:s}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:a.schema});let u=war({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:sb(e.availability)}:{}}}function war({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function _Al(e){return ba._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function SAl(e){return ba._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}St();function Vse(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Be(e)}}function Lgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o}){let s;switch(e.type){case"primitive":s=OAl(e);break;case"array":s=BAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":s=TAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":s=PAl({schema:e,context:t,declarationFile:r,namespace:n,variant:o});break;case"unknown":s=RAl(e.nameOverride,e.generatedName,e.description);break;case"optional":s=zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":s=DAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":s=Jvt(e,i);break;case"literal":s=FAl(e,e.nameOverride,e.generatedName);break;case"object":s=ROe({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o});break;case"oneOf":s=yli({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o});break;default:Be(e)}return s}function ROe({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,skipReadonlyProperties:o,variant:s}){let a=o===!0||s==="write",c=!1,u={},l=new Set;for(let g of e.properties){if(g.readonly&&(c=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([x,C])=>!C.differentSchema))continue;Object.entries(g.conflict).forEach(([x])=>{bli({property:g.key,schemaId:x,context:t,namespace:n}).forEach(_=>{l.add(_)})})}let A=pc({schema:g.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s}),b=g.audiences,v=g.nameOverride,E=sb(g.availability),I=jAl(g);u[g.key]=QAl({typeReference:A,audiences:b,name:v,availability:E,propertyAccess:I})}let p=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(A=>l.add(A)),g.conflictingTypeSignatures&&p.add(g.propertyKey);let d=[];for(let g of e.allOf){let A=Car({schema:g.schema,context:t,namespace:n});if(A==null||l.has(g.schema)||l.has(A))continue;let b=pc({schema:ba.reference(g),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s});d.push(Q6e(yp(b)))}for(let g of l){let A=j6e(t,g,n);for(let b of A.properties)u[b.key]==null&&(p.has(b.key)&&(u[b.key]="unknown"),u[b.key]=pc({schema:b.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s}));for(let b of A.allOf){if(l.has(b.schema))continue;let v=pc({schema:ba.reference(b),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:s});d.push(Q6e(yp(v)))}}let f={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(u).map(([g,A])=>NAl(g)?[g,typeof A=="string"?{type:A,name:`_${g}`}:{...A,name:`_${g}`}]:[g,A]))};d.length>0&&(f.extends=d),e.additionalProperties&&(f["extra-properties"]=!0),e.availability!=null&&(f.availability=sb(e.availability)),e.source!=null&&(f.source=Vse(e.source)),e.encoding!=null&&(f.encoding=Hvt(e.encoding)),f.inline=Eli(e,i);let m=e.nameOverride??e.generatedName;return{name:s==="read"&&c&&t.options.respectReadonlySchemas&&t.hasReadVariant(m)?`${m}Read`:m,schema:f}}function bli({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return bli({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:o,allOf:s}=j6e(r,t,n),a=o.some(u=>u.key===e),c=[...s.flatMap(u=>bli({property:e,context:r,schemaId:u.schema,namespace:n}))];if(a||c.length>0)return[t,...c]}return[]}function Ugs(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?j6e(e,t.schema,r):t.type==="nullable"?Ugs(e,t.value,r):{properties:[],allOf:[]}}function j6e(e,t,r){let n=e.getSchema(t,r);return n==null?{properties:[],allOf:[]}:Ugs(e,n,r)}function BAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:dli({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function TAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:mli({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function OAl(e){let t=Ear(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function Mgs(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Jvt(e,t){let r={enum:e.values.map(o=>{let s=o.nameOverride??o.generatedName,a=o.value;if(s===a&&o.description==null&&(o.casing==null||Mgs(o.casing)))return s;let c={value:o.value};if(s!==a&&(c.name=s),o.description!=null&&(c.docs=o.description),o.casing!=null&&!Mgs(o.casing)){let u={},l=!1;o.casing.camel!=null&&(u.camel=o.casing.camel,l=!0),o.casing.screamingSnake!=null&&(u["screaming-snake"]=o.casing.screamingSnake,l=!0),o.casing.snake!=null&&(u.snake=o.casing.snake,l=!0),o.casing.pascal!=null&&(u.pascal=o.casing.pascal,l=!0),l&&(c.casing=u)}return c})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=Eli(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?Vse(e.source):void 0};for(let o of r.enum){let s=typeof o=="string"?o:o.name??o.value;n.has(s.toLowerCase())||(i.enum.push(o),n.add(s.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function PAl({schema:e,context:t,declarationFile:r,namespace:n,variant:i}){return{name:e.nameOverride??e.generatedName,schema:fli({schema:e,context:t,fileContainingReference:r,namespace:n,variant:i})}}function DAl({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:hli({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function zgs({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:Iar({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function RAl(e,t,r){return r!=null?{name:e??t,schema:{type:"unknown",docs:r}}:{name:e??t,schema:gli()}}function FAl(e,t,r){return{name:t??r,schema:Ali(e)}}function yli({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i,variant:o}){let s=e.encoding!=null?Hvt(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let l of e.commonProperties)c[l.key]=pc({schema:l.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1,variant:o});let u={};for(let[l,p]of Object.entries(e.schemas))u[l]=pc({schema:p,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1,variant:o});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantPropertyNameOverride!=null||e.discriminatorContext!=null?{...e.discriminantPropertyNameOverride!=null&&{name:e.discriminantPropertyNameOverride},value:e.discriminantProperty,...e.discriminatorContext!=null&&{context:e.discriminatorContext}}:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?sb(e.availability):void 0,union:u,encoding:s,source:e.source!=null?Vse(e.source):void 0}}}let a=[];for(let c of e.schemas)a.push(pc({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1,variant:o}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:s,source:e.source!=null?Vse(e.source):void 0,inline:Eli(e,i)}}}var kAl=/^[0-9]/;function NAl(e){return kAl.test(e)}function Car({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?Car({context:t,schema:n.schema,namespace:r}):e}function QAl({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function Eli(e,t){return e.inline===!0||t>0?!0:void 0}function jAl(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return xm.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return xm.ObjectPropertyAccess.WriteOnly}}Bi();function Vgs(e){let t=e.replace(/^x-|^X-/,"");return qn(t)}function qgs(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??Vgs(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(Qs.of("__package__.yml"),{name:"OauthScope",schema:Jvt(n.scopesEnum,0).schema})}}Bi();function _$({header:e,context:t,fileContainingReference:r,namespace:n}){let i=pc({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),o=yp(i),s=e.name.replace(/^x-|^X-/,""),a=e.parameterNameOverride!=null?e.parameterNameOverride:qn(s);if(e.description==null&&e.name===a&&e.env==null&&e.availability==null)return o;let c={type:o};return a!==e.name&&(c.name=a),e.description!=null&&(c.docs=e.description),e.env!=null&&(c.env=e.env),e.availability!=null&&(c.availability=sb(e.availability)),c}function xar({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=pc({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return yp(i);let o=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:yp(i)};return e.description!=null&&(o.docs=e.description),e.availability!=null&&(o.availability=sb(e.availability)),o}oA();function Sar({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=vli({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let o=yp(i.value),s=Kvt(i.value);o==="unknown"?o="string":o==="optional<unknown>"&&(o="optional<string>");let a={type:o};return s!=null&&(a.default=s),i.allowMultiple&&(a["allow-multiple"]=!0),e.explode!=null&&(a.explode=e.explode),e.description!=null&&(a.docs=e.description),e.parameterNameOverride!=null&&(a.name=e.parameterNameOverride),e.availability!=null&&(a.availability=sb(e.availability)),MAl(i.value)&&i.value.validation!==void 0&&(a.validation=i.value.validation),a.default==null&&a["allow-multiple"]==null&&a.docs==null&&a.name==null&&a.availability==null&&a.validation==null&&a.explode==null?o:a}function vli({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Qs.of(ef),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,c]of Object.entries(i.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(s=!0),c.type==="literal"&&c.value.type==="string"&&(F6e.test(c.value.value)?o.push(c.value.value):o.push({value:c.value.value,name:k6e(c.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[a,c]=i.value.schemas;if(a!=null&&c!=null&&_ar({array:a,primitive:c}))return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&c!=null&&_ar({array:c,primitive:a}))return{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[a,c]of Object.entries(i.value.schemas))return vli({schema:c,context:t,fileContainingReference:r,namespace:n})}else if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?ba.optional:ba.nullable;if(e.value.type==="reference"){let o=t.getSchema(e.value.schema,n);if(o==null)return;if(o.type==="array")return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:o.value,description:e.description??o.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(s=!0),c.type==="literal"&&c.value.type==="string"&&(F6e.test(c.value.value)?o.push(c.value.value):o.push({value:c.value.value,name:k6e(c.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,c]=e.value.value.schemas;if(a!=null&&c!=null&&_ar({array:a,primitive:c}))return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&c!=null&&_ar({array:c,primitive:a}))return{value:pc({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[a,c]of Object.entries(e.value.value.schemas))return vli({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:pc({schema:e,context:t,fileContainingReference:r,declarationFile:Qs.of(ef),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:pc({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:pc({schema:ba.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}:{value:pc({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function _ar({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function MAl(e){return typeof e=="object"&&e!==null&&"type"in e}St();function Ggs({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=LAl(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=UAl({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Dhe(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function LAl(e){let t={};return e.forEach(r=>{let n=Dhe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function UAl({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let o=Dhe(i.value);r.has(i.name)||o!=null&&(n[i.name]=o)}),n}function Dhe(e){switch(e.type){case"primitive":return Wgs(e.value);case"object":return $gs(e.properties);case"array":return zAl(e.value);case"map":return VAl(e.value);case"oneOf":return qAl(e.value);case"enum":return e.value;case"literal":return GAl(e.value);case"unknown":return Dhe(e.value);case"null":return null;default:Be(e)}}function Wgs(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:Be(e)}}function $gs(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Dhe(r)]))}function zAl(e){return e.map(t=>Dhe(t))}function VAl(e){return Object.fromEntries(e.map(t=>[Wgs(t.key),Dhe(t.value)]))}function qAl(e){return e.type==="discriminated"?$gs(e.value):Dhe(e.value)}function GAl(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Be(e)}}function Yvt(e){try{let r=new URL(e).pathname.split("/").filter(n=>n.length>0);if(r.length>0)return r[r.length-1]}catch{}}function Bar(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function Tar(e,t,r=!1){let n=Yvt(t);return r&&n!=null?n:e!=null&&n!=null?`${e}_${n}`:n??e??"websocket"}function qse(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Oar(e,t){return t??(e?.groupName!=null?qse(e.groupName):void 0)}function Hgs({channel:e,context:t,declarationFile:r}){let n=e.servers[0],i=t.ir.servers.length===0&&t.ir.websocketServers.length<=1,o=n!=null&&!i?t.options.groupEnvironmentsByHost?t.getUrlId(n.url)??Tar(n.name,n.url,!0):n.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${n?.name}", server url="${n?.url}", resolved urlId="${o}" (from collision map: ${t.getUrlId(n?.url??"")!=null})`);let s=e.path;for(let f of e.handshake.pathParameters)f.parameterNameOverride!=null&&(s=s.replace(`{${f.name}}`,`{${f.parameterNameOverride}}`));let a=t.authOverrides?.auth!=null,c={path:s,url:o,auth:a};e.audiences!=null&&e.audiences.length>0&&(c.audiences=e.audiences),e.summary!=null&&(c["display-name"]=e.summary),e.connectMethodName!=null&&(c["connect-method-name"]=e.connectMethodName),e.description!=null&&(c.docs=e.description);let u=qse(e.groupName),l={};if(e.handshake.pathParameters.length>0)for(let f of e.handshake.pathParameters){let m=f.parameterNameOverride??f.name;l[m]=xar({pathParameter:f,context:t,fileContainingReference:r,namespace:u})}Object.keys(l).length>0&&(c["path-parameters"]=l);let p={};if(e.handshake.queryParameters.length>0)for(let f of e.handshake.queryParameters){let m=Sar({queryParameter:f,context:t,fileContainingReference:r,namespace:u});m!=null&&(p[f.name]=m)}Object.keys(p).length>0&&(c["query-parameters"]=p);let d={};if(e.handshake.headers.length>0)for(let f of e.handshake.headers){let m=_$({header:f,context:t,fileContainingReference:r,namespace:u});d[f.name]=m}Object.keys(d).length>0&&(c.headers=d),t.builder.addChannel(r,{channel:c});for(let f of e.messages){let m={origin:f.origin,body:pc({schema:f.body,context:t,fileContainingReference:r,namespace:u,declarationDepth:0})};f.methodName!=null&&(m["method-name"]=f.methodName),t.builder.addChannelMessage(r,{messageId:f.name,message:m})}for(let f of e.examples){let m=Ggs({context:t,websocketExample:f});t.builder.addChannelExample(r,{example:m})}}function Ili(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var II="Base",Ygs="Default";function Kgs(e){try{return new URL(e).hostname}catch{return}}function Jgs(e){return e??Ygs}function WAl(e,t){let r=new Map;for(let n of e){if(Ili(n)||!("url"in n)||!n.url)continue;let i=Kgs(n.url)??n.url;r.has(i)||r.set(i,{environmentName:Jgs(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.httpServers.push({name:n.name,url:n.url,audiences:n.audiences})}for(let n of t){let i=Kgs(n.url)??n.url;r.has(i)||r.set(i,{environmentName:Jgs(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.websocketServers.push(n)}return r}function FOe(e){return Object.entries(e).reduce((t,[r,n])=>(WF(n)?Object.entries(n.urls).forEach(([i,o])=>{t[i]=o}):t[r]=typeof n=="string"?n:n.url,t),{})}function Xgs(e){if(e.environmentOverrides!=null){for(let[E,I]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:E,schema:I});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],n=e.ir.servers.some(E=>Ili(E)),i=e.ir.servers;for(let E of i)if(Ili(E)){let I={urls:{}},w={},x={},C={};for(let[D,V]of Object.entries(E.urls))I.urls[D]=V.defaultUrl??V.url,V.urlTemplate&&(w[D]=V.urlTemplate),V.defaultUrl&&(x[D]=V.defaultUrl),V.variables&&V.variables.length>0&&(C[D]=V.variables);(Object.keys(w).length>0||Object.keys(C).length>0)&&(I["url-templates"]=w,I["default-urls"]=x,I.variables=C),E.name&&(t[E.name]=I)}else if("url"in E&&E.url){let w=E.urlTemplate!=null&&E.variables!=null&&E.variables.length>0?{url:E.url,audiences:E.audiences,"default-url":E.defaultUrl,"url-template":E.urlTemplate,variables:E.variables?.map(x=>({id:x.id,default:x.default,values:x.values}))}:E.audiences?{url:E.url,audiences:E.audiences}:E.url;if(E.name==null){r.push(w);continue}t[E.name]=w}let o={},s={},a=[],c={},u={},l={};for(let E of e.ir.endpoints)for(let I of E.servers){if(I.url==null&&I.name!=null){o[I.name]||(o[I.name]=[]);continue}if(I.url==null)continue;let w=I,x="defaultUrl"in I&&typeof w.defaultUrl=="string"?w.defaultUrl:void 0,C="urlTemplate"in I&&typeof w.urlTemplate=="string"?w.urlTemplate:void 0,_="variables"in I&&Array.isArray(w.variables)?w.variables:void 0,D=x??I.url,V=I.audiences?{url:D,audiences:I.audiences}:D;if(I.name==null){a.push(V);continue}o[I.name]||(o[I.name]=[]),o[I.name]?.push({url:D,audiences:I.audiences}),s[I.name]=V,C&&I.name&&(c[I.name]=C),x&&I.name&&(u[I.name]=x),_&&_.length>0&&I.name&&(l[I.name]=_)}let p={},d=[];for(let E of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${E.name}", url="${E.url}"`);let I=E.audiences?{url:E.url,audiences:E.audiences}:E.url;if(E.name==null){d.push(I);continue}p[E.name]=I}let f=Object.keys(t).length,m=f>0,h=Object.keys(s).length>0,g=Object.keys(o).some(E=>o[E]?.length===0),A=Object.keys(p).length>0;if(e.options.groupEnvironmentsByHost&&A&&(m||e.ir.servers.length>0)){let E=Object.entries(p).map(([w,x])=>({name:w,url:typeof x=="string"?x:x.url,audiences:typeof x=="string"?void 0:x.audiences})),I=WAl(i,E);if(I.size>0){let w=!0;for(let[x,C]of I.entries()){let _={},D=[...C.httpServers.map(q=>({...q,isHttp:!0})),...C.websocketServers.map(q=>({...q,isHttp:!1}))],V=new Map;for(let q of D){let U=Yvt(q.url),W=Bar(q.url);U&&W&&(V.has(U)||V.set(U,new Set),V.get(U)?.add(W))}if(C.httpServers.length>0){let q=C.httpServers[0];q!=null&&(_[II]=q.url,e.setUrlId(q.url,II));for(let U=1;U<C.httpServers.length;U++){let W=C.httpServers[U];if(W!=null){let re=Yvt(W.url),z=Bar(W.url),$=re?V.get(re):void 0,ge=$&&$.size>1,J=ge&&z!=="https"?`${re}_${z}`:re||`Http${U+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${W.url}", pathSegment="${re}", protocol="${z}", hasCollision=${ge}, urlId="${J}"`),_[J]=W.url,e.setUrlId(W.url,J)}}}for(let q of C.websocketServers){let U=Yvt(q.url),W=Bar(q.url),re=U?V.get(U):void 0,z=re&&re.size>1,$=z?`${U}_${W}`:Tar(q.name,q.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${q.name}", url="${q.url}", pathSegment="${U}", protocol="${W}", hasCollision=${z}, urlId="${$}"`),_[$]=q.url,e.setUrlId(q.url,$)}if(Object.keys(_).length>1)e.builder.addEnvironment({name:C.environmentName,schema:{urls:_}});else if(Object.keys(_).length===1){let q=Object.values(_)[0];q!=null&&e.builder.addEnvironment({name:C.environmentName,schema:q})}w&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(C.environmentName),Object.keys(_).length>1&&e.builder.setDefaultUrl(II),w=!1)}return}}if(!m&&!h&&A&&e.ir.servers.length===0){for(let[E,I]of Object.entries(p))e.builder.addEnvironment({name:E,schema:I});e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(Object.keys(p)[0]),e.builder.setDefaultUrl(II);return}if(a.length>0&&e.logger.debug(`Skipping endpoint level servers ${a.map(E=>typeof E=="string"?E:E.url).join(", ")} because x-fern-server-name was not provided.`),!m){let E=e.ir.servers[0],I=E?.url,w=E?.audiences,x=E?.defaultUrl,C=E?.urlTemplate,_=E?.variables;if(I!=null){let V=C!=null&&_!=null&&_.length>0?{url:I,audiences:w,"default-url":x,"url-template":C,variables:_?.map(q=>({id:q.id,default:q.default,values:q.values}))}:w?{url:I,audiences:w}:I;t[Ygs]=V}}let b=Object.values(t).map(E=>typeof E=="string"?E:WF(E)?Object.values(E.urls)[0]:E.url),v=r.filter(E=>{let I=typeof E=="string"?E:E.url;return!b.includes(I)});if(v.length>0&&e.logger.debug(`Skipping top level servers ${v.map(E=>typeof E=="string"?E:E.url).join(", ")} because x-fern-server-name was not provided.`),n){let E=!0;for(let[I,w]of Object.entries(t))if(e.builder.addEnvironment({name:I,schema:w}),E){if(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(I),WF(w)){let x=Object.keys(w.urls)[0];x&&e.builder.setDefaultUrl(x)}E=!1}return}if(!h&&!g){let E=!0;for(let[I,w]of Object.entries(t))if(E){if(A){let x=typeof w=="string"?w:WF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;x!=null&&e.setUrlId(x,II),e.builder.addEnvironment({name:I,schema:{urls:{[II]:x??"",...FOe(p)}}})}else e.builder.addEnvironment({name:I,schema:w});e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(I),E=!1}else if(A){let x=typeof w=="string"?w:WF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;x!=null&&e.setUrlId(x,II),e.builder.addEnvironment({name:I,schema:{urls:{[II]:x??"",...FOe(p)}}})}else e.builder.addEnvironment({name:I,schema:w});A&&e.builder.setDefaultUrl(II)}else if(f===1){let E=Object.keys(t)[0],I=Object.values(t)[0],w=typeof I=="string"?I:WF(I)?Object.values(I.urls)[0]:I["default-url"]??I.url,x={},C={},_={};typeof I!="string"&&!WF(I)&&(I["url-template"]&&(x[II]=I["url-template"]),I["default-url"]&&(C[II]=I["default-url"]),I.variables&&I.variables.length>0&&(_[II]=I.variables)),Object.assign(x,c),Object.assign(C,u),Object.assign(_,l);let D=Object.keys(x).length>0||Object.keys(_).length>0;w!=null&&e.setUrlId(w,II);let V={urls:{[II]:w??"",...FOe(s),...FOe(p)},...D?{"url-templates":x,"default-urls":C,variables:_}:{}};e.builder.addEnvironment({name:E,schema:V}),e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(E),e.builder.setDefaultUrl(II)}else{let E=new Map;for(let I of e.ir.endpoints)for(let w of I.servers)if(w.url!=null&&w.name!=null){E.has(w.name)||E.set(w.name,new Map);let x=w.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",C=E.get(w.name);C&&C.set(x,w.url)}if(E.size>0){let I=!0;for(let[w,x]of Object.entries(t)){let C=typeof x=="string"?x:WF(x)?Object.values(x.urls)[0]:x["default-url"]??x.url;if(!C)continue;e.setUrlId(C,II);let _=C.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",D={[II]:C};for(let[V,q]of E.entries()){let U=q.get(_)||q.get("production")||q.values().next().value;U&&(D[V]=U)}A&&Object.assign(D,FOe(p)),Object.keys(D).length>1?e.builder.addEnvironment({name:w,schema:{urls:D}}):e.builder.addEnvironment({name:w,schema:C}),I&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(w),I=!1)}E.size>0&&e.builder.setDefaultUrl(II)}else{let I=!0;for(let[w,x]of Object.entries(t)){if(A||Object.keys(s).length>0){let C=typeof x=="string"?x:WF(x)?Object.values(x.urls)[0]:x["default-url"]??x.url;C!=null&&e.setUrlId(C,II),e.builder.addEnvironment({name:w,schema:{urls:{[II]:C??"",...FOe(s),...FOe(p)}}})}else e.builder.addEnvironment({name:w,schema:x});I&&(e.options.inferDefaultEnvironment!==!1&&e.builder.setDefaultEnvironment(w),I=!1)}}}}oA();Bi();var wli=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},$Al=.75,HAl=new Set(["authorization"]);function Zgs(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let o=n.optional===!0?"optional<string>":"string",s=o;if(n.name==null&&n.env==null&&typeof n.schema=="string")s=n.schema;else if(n!=null){let a=n.schema?zse(n.schema):void 0,c=a!=null?qse(a):void 0,u=Qs.of("api.yml");s={name:n.name,env:n.env,type:n.schema!=null?yp(pc({schema:n.schema,context:e,fileContainingReference:c?G0(Qs.of(qn(c)),u):u,namespace:c,declarationDepth:0}))??o:o}}e.builder.addGlobalHeader({name:r,schema:s})}if(e.options.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let o of i.headers){if(HAl.has(o.name.toLowerCase()))continue;let s=r[o.name];if(s==null){let a=t[o.name],c=_$({header:{...o,schema:a?.schema??o.schema,name:a?.name??o.name},fileContainingReference:Qs.of(H0),context:e,namespace:void 0});s=new wli(c),r[o.name]=s}s.increment()}let n=e.ir.endpoints.length*$Al;for(let[i,o]of Object.entries(r)){let s=t[i],a=o.count===e.ir.endpoints.length,c=o.count>=n;s==null&&(a?e.builder.addGlobalHeader({name:i,schema:o.schema}):c&&e.builder.addGlobalHeader({name:i,schema:DOe(o.schema)}))}}}oA();function eAs(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?zse(t.schema):void 0,n=r!=null?qse(r):void 0,i=_$({header:{...t,schema:t.schema??ba.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ol.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:Qs.of(H0),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:DOe(i)})}}St();oA();St();St();function lT(e){switch(e.type){case"primitive":return rAs(e.value);case"object":return nAs(e.properties);case"array":return iAs(e.value);case"map":return JAl(e.value);case"oneOf":return YAl(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return XAl(e.value);case"unknown":return lT(e.value);case"null":return null;default:Be(e)}}function tAs(e){switch(e.type){case"withStreaming":return e.sse?{stream:KAl(e.events)}:{stream:iAs(e.events)};case"withoutStreaming":return{body:lT(e.value)};default:Be(e)}}function rAs(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:Be(e)}}function nAs(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lT(r)]))}function KAl(e){return e.map(t=>({event:"",data:lT(t)}))}function iAs(e){return e.map(t=>lT(t))}function JAl(e){return Object.fromEntries(e.map(t=>[rAs(t.key),lT(t.value)]))}function YAl(e){return e.type==="discriminated"?nAs(e.value):lT(e.value)}function XAl(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:Be(e)}}function oAs({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=ZAl(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=eyl(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),o=Object.keys(i).length>0,s=new Set(e.headers?.map(a=>a.name)??[]);if(n||o){let a=[];if(e.headers!=null)for(let c of e.headers)c.name!==t.builder.getAuthHeaderName()&&a.push(c);for(let[c,u]of Object.entries(i)){if(u!=null&&typeof u=="object"&&u.type!=null){let l=GE({type:u.type,_default:void 0,validation:void 0,visitor:{primitive:pt,map:pt,list:pt,optional:p=>p,nullable:p=>p,set:pt,named:pt,literal:p=>{if(p.type==="string")return p.string;if(p.type==="boolean")return p.boolean.toString()},unknown:pt}});if(l!=null){let p=a.findIndex(f=>f.name===c),d={name:c,value:lc.literal(Ihe.string(l))};p>=0?a[p]=d:a.push(d);continue}}s.has(c)||a.push({name:c,value:lc.primitive(hs.string(c))})}r.headers=tyl({context:t,namedFullExamples:a})}return e.request!=null&&(r.request=lT(e.request)),e.response!=null&&(r.response=tAs(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(a=>a.type==="language"?{name:a.name??void 0,docs:a.description??void 0,language:a.language,code:a.code,install:a.install??void 0}:{name:a.name??void 0,docs:a.description??void 0,sdk:a.sdk,code:a.code}).filter(ya)),r}function ZAl(e){let t={};return e.forEach(r=>{let n=lT(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function eyl(e){let t={};return e.forEach(r=>{let n=lT(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function tyl({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=lT(n.value);i!=null&&(r[n.name]=i)}),r}var YS;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(YS||(YS={}));function sAs(e){return Ix._visit(e,{get:()=>xm.HttpMethodSchema.Get,post:()=>xm.HttpMethodSchema.Post,put:()=>xm.HttpMethodSchema.Put,patch:()=>xm.HttpMethodSchema.Patch,delete:()=>xm.HttpMethodSchema.Delete,head:()=>xm.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function Cli(e){return e==="POST"||e==="PUT"||e==="PATCH"}function aAs({endpoint:e,declarationFile:t,context:r}){let n=[],i=new Set,o=e.path,s=Oar(e.sdkName,e.namespace),a={};for(let h of e.pathParameters)h.parameterNameOverride&&(o=o.replace(h.name,h.parameterNameOverride)),a[h.parameterNameOverride??h.name]=xar({pathParameter:h,context:r,fileContainingReference:t,namespace:s}),i.add(h.name);let c={};for(let h of e.queryParameters){let g=Sar({queryParameter:h,context:r,fileContainingReference:t,namespace:s});g!=null&&(c[h.name]=g,i.add(h.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;case"uri":u={next_uri:e.pagination.nextUri,results:e.pagination.results};break;case"path":u={next_path:e.pagination.nextPath,results:e.pagination.results};break;default:Be(e.pagination)}let l={path:o,method:sAs(e.method),auth:ryl({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Vse(e.source):void 0};!syl({context:r,request:e.request})&&Object.keys(a).length>0&&(l["path-parameters"]=a),e.summary!=null&&(l["display-name"]=e.summary);let p={},d=r.builder.getGlobalHeaderNames(),f=r.builder.getAuthHeaderName();f!=null&&d.add(f);let m=e.headers.filter(h=>!d.has(h.name));for(let h of m){let g=_$({header:h,context:r,fileContainingReference:t,namespace:s});p[h.name]=g,i.add(typeof g=="string"?h.name:g.name??h.name)}if(e.request!=null){r.setInState(YS.Request);let h=oyl({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(a).length>0?a:void 0,queryParameters:Object.keys(c).length>0?c:void 0,headers:Object.keys(p).length>0?p:void 0,usedNames:i,namespace:s});l.request=h.value,n=[...n,...h.schemaIdsToExclude??[]],r.unsetInState(YS.Request)}else{let h=r.options.inlinePathParameters&&Object.keys(a).length>0,g=Object.keys(c).length>0,A=Object.keys(p).length>0,b={};(h||g||A)&&(b.name=e.requestNameOverride??e.generatedRequestName),h&&(b["path-parameters"]=a),g&&(b["query-parameters"]=c),A&&(b.headers=p),Object.keys(b).length>0&&(l.request=b)}if(e.response!=null&&e.response._visit({json:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l.response={docs:h.description??void 0,type:yp(g)},h.statusCode!=null&&(l.response["status-code"]=h.statusCode),h.responseProperty!=null&&(l.response.property=h.responseProperty)},streamingJson:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l["response-stream"]={docs:h.description??void 0,type:yp(g),format:"json",terminator:h.terminator??void 0}},streamingSse:h=>{let g=pc({schema:h.schema,context:r,fileContainingReference:t,namespace:s,declarationDepth:0});l["response-stream"]={docs:h.description??void 0,type:yp(g),format:"sse",terminator:h.terminator??void 0}},file:h=>{l.response={docs:h.description??void 0,type:"file","status-code":h.statusCode}},bytes:h=>{l.response={docs:h.description??void 0,type:"bytes","status-code":h.statusCode}},streamingText:h=>{l["response-stream"]={docs:h.description??void 0,type:"text"}},text:h=>{l.response={docs:h.description??void 0,type:"text","status-code":h.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let h=r.getDefaultServerName(),g=e.servers[0];if(g==null)h!=null&&(l.url=h);else{let A=g.url!=null?r.getUrlId(g.url):void 0;l.url=A??g.name??void 0}}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=sb(e.availability)),Object.entries(e.errors).forEach(([h,g])=>{let A=g.generatedName,b=Qs.of(ef);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${g.generatedName}`,g.schema!=null&&(g.schema.type!=="reference"&&g.schema.type!=="oneOf"?g.schema.generatedName=`${e.generatedRequestName}${g.schema.generatedName}`:g.schema.type==="oneOf"&&(g.schema.value.generatedName=`${e.generatedRequestName}${g.schema.value.generatedName}`)));let v={"status-code":parseInt(h)},E=Rgs({location:cAs,namespaceOverride:s});if(g.schema!=null){let x=pc({schema:g.schema,context:r,fileContainingReference:E,declarationFile:E,namespace:s,declarationDepth:0});v.type=yp(x),v.docs=g.description}r.builder.addError(E,{name:A,schema:r.isErrorUnknownSchema(parseInt(h))?{...v,type:"unknown"}:v}),l.errors==null&&(l.errors=[]);let I=r.builder.addImport({file:t,fileToImport:E});l.errors.push(I!=null?`${I}.${A}`:A),v.type!=null&&g.examples?.forEach(x=>{let C={value:lT(x.example),name:x.name,docs:x.description};r.builder.addErrorExample(E,{name:A,example:C})})}),e.examples.length>0&&(l.examples=nyl({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=iyl({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[xli,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function ryl({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function nyl({endpointExamples:e,context:t}){return e.map(r=>{try{return oAs({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function iyl({retries:e}){if(e!=null){if(e.type==="disabled")return{disabled:e.value??void 0};Be(e)}}function oyl({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:o,pathParameters:s,queryParameters:a,headers:c,usedNames:u,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let p=n.schema.type==="reference"?n.schema.schema:void 0,d=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(d?.type!=="object"||p!=null&&r.isResponseReachable(p)){let I=r.options.respectReadonlySchemas&&Cli(e.method)?"write":void 0,w=pc({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0,variant:I}),x={schemaIdsToExclude:[],value:{body:w}},C=Object.keys(s??{}).length>0,_=Object.keys(a??{}).length>0,D=Object.keys(c??{}).length>0;return C&&(x.value["path-parameters"]=s),_&&(x.value["query-parameters"]=a),D&&(x.value.headers=c),(C||_||D)&&(x.value.name=i??o),n.contentType!=null&&(x.value["content-type"]=n.contentType),n.description!=null&&(x.value.docs=n.description),x}let f=new Map;for(let E of d.allOf){let I=r.getSchema(E.schema,l);if(I==null)continue;let w=zse(I),x=Use(w),{properties:C}=j6e(r,E.schema,l);for(let _ of C)f.set(_.key,x)}let m=Object.fromEntries(d.properties.filter(E=>E.readonly==null?!0:!(Cli(e.method)&&E.readonly)).map(E=>{let I=f.get(E.key)??t,w=pc({schema:E.schema,fileContainingReference:t,declarationFile:I,context:r,namespace:l,declarationDepth:1}),x=E.nameOverride??E.key,C=sb(E.availability);if(!u.has(x)&&E.audiences.length<=0)return u.add(x),E.nameOverride!=null?[E.key,{type:yp(w),docs:N6e(w),name:E.nameOverride,availability:C}]:[E.key,C?{...typeof w=="string"?{type:w}:w,availability:C}:w];let _={type:yp(w),docs:N6e(w)};return u.has(x)&&(_.name=E.generatedName),E.audiences.length>0&&(_.audiences=E.audiences),C!=null&&(_.availability=C),u.add(x),[E.key,_]})),h=new Set,g=new Set;for(let E of d.allOfPropertyConflicts)E.allOfSchemaIds.forEach(I=>h.add(I)),E.conflictingTypeSignatures&&g.add(E.propertyKey);let A=[];for(let E of d.allOf){let I=Car({schema:E.schema,context:r,namespace:l});if(I==null||h.has(E.schema)||h.has(I))continue;let w=pc({schema:ba.reference(E),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),x=Q6e(yp(w));x!=="unknown"&&A.push(x)}for(let E of h){let I=j6e(r,E,l),w=r.getSchema(E,l),x=w!=null?Use(zse(w)):t;for(let C of I.properties)m[C.key]==null&&(g.has(C.key)?m[C.key]="unknown":m[C.key]=pc({schema:C.schema,fileContainingReference:t,declarationFile:x,context:r,namespace:l,declarationDepth:1}));for(let C of I.allOf){if(h.has(C.schema))continue;let _=pc({schema:ba.reference(C),fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),D=Q6e(yp(_));D!=="unknown"&&!A.includes(D)&&A.push(D)}}let b={properties:m};A.length>0&&(b.extends=A),n.additionalProperties&&(b["extra-properties"]=!0);let v={name:i??d.nameOverride??d.generatedName,"path-parameters":s,"query-parameters":a,headers:c,body:b};return n.contentType!=null&&(v["content-type"]=n.contentType),n.description!=null&&(v.docs=n.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(n.type==="octetStream"){let p={body:"bytes","content-type":n.contentType??Ef.APPLICATION_OCTET_STREAM,"query-parameters":a};return a!=null&&(p.name=i??o),n.description!=null&&(p.docs=n.description),{schemaIdsToExclude:[],value:p}}else if(n.type==="multipart"){let p=Object.fromEntries(n.properties.map(d=>{if(d.schema.type==="file"){let f=d.schema.isArray?"list<file>":"file";if(f=d.schema.isOptional?`optional<${f}>`:f,d.description!=null||d.contentType!=null){let m={type:f};if(d.description!=null&&(m.docs=d.description),d.contentType!=null){let h=d.contentType.split(",")[0];m["content-type"]=h}return[d.key,m]}return[d.key,f]}else{let f=pc({schema:d.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(d.contentType||d.exploded||d.encoding){let m=typeof f=="string"?{type:f}:f;d.contentType!=null&&(m["content-type"]=d.contentType),d.encoding==="form"?m.style="form":d.encoding==="json"?m.style="json":d.exploded&&(m.style="exploded"),f=m}return[d.key,f]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??o,"path-parameters":s,"query-parameters":a,headers:c,body:{properties:p},"content-type":Ef.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else Be(n)}function syl({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:Be(t)}}oA();Bi();function ayl({location:e,namespaceOverride:t}){return t!=null?{...e,file:G0(Qs.of(t),e.file)}:e}function cyl(e){let t=e.namespace,r=e.tags.filter(c=>c!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:Qs.of(`${qn(r)}.yml`),endpointId:e.summary!=null?qn(e.summary):qn(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Qs.of(ef),endpointId:qn(e.summary)}:{file:Qs.of(ef),endpointId:qn(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Qs.of(ef),endpointId:n};let i=Xvt(r),o=Xvt(n);if(q0(i,o))return{file:Qs.of("__package__.yml"),endpointId:r};let s=pyl({operationId:n,tag:r,path:e.path,method:e.method});if(s!=null)return s;let a=[];for(let c=0;c<i.length;++c){let u=i[c];if(u!=null&&u===o[c])a.push(u);else{let l=qn(r);return{file:Qs.of(`${l}.yml`),endpointId:n,tag:r}}}if(a.length>=o.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Qs.of(qn(a.join("_"))+".yml"),endpointId:qn(o.slice(a.length).join("_")),tag:r}}function Zvt(e){let t=e.tags[0];if(e.sdkName!=null){let r=uli({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Qs.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return ayl({namespaceOverride:e.namespace,location:cyl(e)})}function Xvt(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=sU(t),t}var uyl=new RegExp("[^a-zA-Z0-9{}]+"),lyl=new RegExp("[{}]","g");function pyl({operationId:e,tag:t,path:r,method:n}){let o=`${r.split(uyl).join("_").replaceAll(lyl,"_")}_${n.toLowerCase()}`;if(e.endsWith(o))return{file:Qs.of(qn(t)+".yml"),endpointId:qn(e.slice(0,-1*o.length)),tag:t}}function uAs(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let o of r){let{endpointId:s,file:a,tag:c}=Zvt(o),u=a.split(".")[0];u!=null&&t.add(u);let l;if(o.sdkName!=null){let f=e.ir.groups;for(let m of o.sdkName.groupName){let h=typeof m=="string"?m:m.name,g=f[h];if(g==null)break;if(g.summary!=null||g.description!=null){l=f[h];break}}}let p=c==null?void 0:n.tagsById[c];e.setInState(YS.Endpoint),e.setEndpointMethod(o.method);let d=aAs({context:e,endpoint:o,declarationFile:a});e.unsetEndpointMethod(),e.unsetInState(YS.Endpoint),i=[...i,...d.schemaIdsToExclude],e.builder.addEndpoint(a,{name:s,schema:d.value,source:o.source!=null?Vse(o.source):void 0}),(p?.id!=null||p?.description!=null)&&e.builder.setServiceInfo(a,{"display-name":l?.summary??p?.id,docs:l?.description??p?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}oA();function lAs(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?qse(r.groupName):void 0,i=pc({schema:ba.primitive(r),context:e,fileContainingReference:Qs.of(ef),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:yp(i),docs:r.description??void 0}})}}oA();Bi();function dAs(e){for(let t of e.ir.webhooks){let r=myl({webhook:t,context:e});if(r==null)continue;let n=Oar(t.sdkName,t.namespace),i={};for(let s of t.headers)i[s.name]=_$({header:s,context:e,fileContainingReference:r.file,namespace:n});let o={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:pc({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),signature:hyl(t.signatureVerification),examples:t.examples!=null?t.examples.map(s=>({docs:s.description,name:s.name,payload:lT(s.payload)})):void 0};t.response!=null&&t.response._visit({json:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o.response={docs:s.description??void 0,type:yp(a)},s.statusCode!=null&&(o.response["status-code"]=s.statusCode)},file:s=>{o.response={docs:s.description??void 0,type:"file","status-code":s.statusCode}},bytes:s=>{o.response={docs:s.description??void 0,type:"bytes","status-code":s.statusCode}},text:s=>{o.response={docs:s.description??void 0,type:"text","status-code":s.statusCode}},streamingJson:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:yp(a),format:"json"}},streamingSse:s=>{let a=pc({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:yp(a),format:"sse"}},streamingText:s=>{o["response-stream"]={docs:s.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:o}),t.description!=null&&(o.docs=t.description)}}function fyl({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:G0(Qs.of(t),e.file)}:e}function dyl({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:Qs.of(ef),endpointId:n};let i=Xvt(r),o=Xvt(n);if(q0(i,o))return{file:Qs.of("__package__.yml"),endpointId:r};let s=[];for(let a=0;a<i.length;++a){let c=i[a];if(c!=null&&c===o[a])s.push(c);else{let u=qn(r);return{file:Qs.of(`${u}.yml`),endpointId:n,tag:r}}}if(s.length>=o.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Qs.of(qn(s.join("_"))+".yml"),endpointId:qn(o.slice(s.length).join("_")),tag:r}}function myl({webhook:e,context:t}){return e.sdkName!=null?{file:Dgs({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:fyl({namespaceOverride:e.namespace,location:dyl({webhook:e,context:t})})}function hyl(e){if(e!=null)switch(e.type){case"hmac":return{type:"hmac",header:e.header,algorithm:gyl(e.algorithm),encoding:pAs(e.encoding),"signature-prefix":e.signaturePrefix,"payload-format":yyl(e.payloadFormat),timestamp:fAs(e.timestamp)};case"asymmetric":return{type:"asymmetric",header:e.header,"asymmetric-algorithm":Ayl(e.asymmetricAlgorithm),encoding:pAs(e.encoding),"signature-prefix":e.signaturePrefix,"jwks-url":e.jwksUrl,"key-id-header":e.keyIdHeader,timestamp:fAs(e.timestamp)};default:return}}function gyl(e){if(e!=null)switch(e){case"sha256":return"sha256";case"sha1":return"sha1";case"sha384":return"sha384";case"sha512":return"sha512";default:return}}function pAs(e){if(e!=null)switch(e){case"base64":return"base64";case"hex":return"hex";default:return}}function Ayl(e){switch(e){case"rsa-sha256":return"rsa-sha256";case"rsa-sha384":return"rsa-sha384";case"rsa-sha512":return"rsa-sha512";case"ecdsa-sha256":return"ecdsa-sha256";case"ecdsa-sha384":return"ecdsa-sha384";case"ecdsa-sha512":return"ecdsa-sha512";case"ed25519":return"ed25519";default:return"rsa-sha256"}}function yyl(e){if(e!=null)return{components:e.components.map(byl),delimiter:e.delimiter}}function byl(e){switch(e){case"body":return"body";case"timestamp":return"timestamp";case"notification-url":return"notification-url";case"message-id":return"message-id";default:return"body"}}function Eyl(e){switch(e){case"unix-seconds":return"unix-seconds";case"unix-millis":return"unix-millis";case"iso8601":return"iso8601";default:return}}function fAs(e){if(e!=null)return{header:e.header,format:e.format!=null?Eyl(e.format):void 0,tolerance:e.tolerance}}St();function Rhe(e,t,r){switch(e.type){case"primitive":case"enum":case"literal":case"unknown":return;case"reference":{let n=e.schema;if(r.has(n))return;r.add(n);let i=mAs(n,e.namespace,t);i!=null&&Rhe(i,t,r);return}case"object":for(let n of e.allOf)if(!r.has(n.schema)){r.add(n.schema);let i=mAs(n.schema,n.namespace,t);i!=null&&Rhe(i,t,r)}for(let n of e.properties)Rhe(n.schema,t,r);return;case"array":case"map":case"optional":case"nullable":Rhe(e.value,t,r);return;case"oneOf":vyl(e.value,t,r);return;default:Be(e)}}function vyl(e,t,r){switch(e.type){case"discriminated":for(let n of Object.values(e.schemas))Rhe(n,t,r);for(let n of e.commonProperties)Rhe(n.schema,t,r);return;case"undiscriminated":for(let n of e.schemas)Rhe(n,t,r);return;default:Be(e)}}function mAs(e,t,r){return t==null?r.rootSchemas[e]:r.namespacedSchemas[t]?.[e]}function XU(e,t,r){Rhe(e,t,r)}function hAs(e){let t=new Set,r=new Set,{groupedSchemas:n}=e;for(let i of e.endpoints){if(i.request!=null)switch(i.request.type){case"json":case"formUrlEncoded":XU(i.request.schema,n,t);break;case"multipart":for(let o of i.request.properties)o.schema.type==="json"&&XU(o.schema.value,n,t);break;case"octetStream":break;default:Be(i.request)}if(i.response!=null)switch(i.response.type){case"json":case"streamingJson":case"streamingSse":XU(i.response.schema,n,r);break;case"file":case"text":case"bytes":case"streamingText":break;default:Be(i.response)}for(let o of Object.values(i.errors))o.schema!=null&&XU(o.schema,n,r);for(let o of i.pathParameters)XU(o.schema,n,r);for(let o of i.queryParameters)XU(o.schema,n,r);for(let o of i.headers)XU(o.schema,n,r)}for(let i of e.webhooks)XU(i.payload,n,r);for(let i of Object.values(e.channels)){for(let o of i.messages)XU(o.body,n,r);for(let o of i.handshake.queryParameters)XU(o.schema,n,r);for(let o of i.handshake.headers)XU(o.schema,n,r);for(let o of i.handshake.pathParameters)XU(o.schema,n,r)}return{requestReachable:t,responseReachable:r}}function Iyl(e){return e.type!=="object"?!1:e.properties.some(t=>t.readonly===!0)}function gAs(e,t){let r=new Set,n=new Set,i=new Set;function o(s){for(let[a,c]of Object.entries(s)){if(!Iyl(c))continue;let u=t.requestReachable.has(a),l=t.responseReachable.has(a);u&&l?r.add(a):u&&!l?n.add(a):!u&&l&&i.add(a)}}o(e.groupedSchemas.rootSchemas);for(let s of Object.values(e.groupedSchemas.namespacedSchemas))o(s);return{needsBothVariants:r,requestOnlyWithReadonly:n,responseOnlyWithReadonly:i}}var xli="external",cAs=Qs.of(ef);function AAs({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,o]of Object.entries(e)){if(t.has(i))continue;let s=Fgs(o);if(n.options.respectReadonlySchemas&&n.needsBothVariants(i)&&o.type==="object"){let u=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,variant:"read"});n.builder.addType(s,{name:u.name??i,schema:u.schema});let l=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,skipReadonlyProperties:!0,variant:"write"});n.builder.addType(s,{name:l.name??i,schema:l.schema});continue}if(n.options.respectReadonlySchemas&&n.isRequestOnlyWithReadonly(i)&&o.type==="object"){let u=ROe({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,skipReadonlyProperties:!0,variant:"write"});n.builder.addType(s,{name:u.name??i,schema:u.schema});continue}let a;n.options.respectReadonlySchemas&&(a=n.isRequestOnly(i)?"write":"read");let c=Lgs({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0,variant:a});if(Wme(c.schema)){let u=yp(c.schema);if(u===(c.name??i)||u===`optional<${c.name??i}>`||u===`nullable<${c.name??i}>`||u===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(s,{name:c.name??i,schema:c.schema})}}function yAs(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Xgs(e),Zgs(e),eAs(e),qgs(e),lAs(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(xli);let t=uAs(e),r=t.sdkGroups;e.setInState(YS.Webhook),dAs(e),e.unsetInState(YS.Webhook),e.setInState(YS.Channel);for(let i of Object.values(e.ir.channels)){let o=Use(i.groupName);Hgs({channel:i,context:e,declarationFile:o})}e.unsetInState(YS.Channel);let n=wyl({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});if(e.options.respectReadonlySchemas){let i=hAs(e.ir),o=gAs(e.ir,i);e.setVariantPlan(o,i)}AAs({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,o]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))AAs({schemas:o,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(o=>r.has(o))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function wyl({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return new Set(t);let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(o=>Object.keys(o))]),i=new Set(t);for(let o of n)r.includes(o)||i.add(o);return i}St();var eIt=class{context;constructor(t){this.context=t}};oA();Bi();oA();var Par=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[s,a]of Object.entries(n.files)){let c=i!=null?Qs.of(`${i}${"/"}${s}`):Qs.of(s);t[c]=a}let o=Object.keys(n.directories).sort();for(let s of o){let a=i!=null?`${i}${"/"}${s}`:s,c=n.directories[s];r(c,a)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Qs.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var kOe=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new Par,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":n,"display-name":i,docs:o}){let s=this.getOrCreateFile(t);s.service==null&&(s.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(s.service.auth=r),n!=null&&(s.service["base-path"]=n),i!=null&&(s.service["display-name"]=i),o!=null&&(s.docs=o)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return n$(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let n of Object.values(this.rootApiFile["auth-schemes"]))bAs(n)&&t.push(n.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(bAs(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??qn((gU(r)+"/"+qB(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Qs.of(H0))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=_ze(gU(xze.of(`/${t}`)),xze.of(`/${r}`)),i;let o=this.getOrCreateFile(t);return o.imports==null&&(o.imports={}),o.imports[i]=_ze(gU(xze.of(`/${t}`)),xze.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===Qs.of(H0))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let o=i.types[r];o!=null&&(typeof o=="string"?i.types[r]={type:o,examples:[n]}:(o.examples==null&&(o.examples=[]),o.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let o=i.errors[r];if(o==null)return;o.examples==null&&(o.examples=[]),(o.examples.some(a=>q0(a,n))??!1)||o.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(o.service.source=i),o.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=G0(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let n=Object.values(r.service.endpoints);if(n.length===0)continue;if(n.every(o=>o.auth===!0)){r.service.auth=!0;for(let o of Object.values(r.service.endpoints))delete o.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,o])=>[i,{...o,path:G0(r,o.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([o,s])=>[o,{...s,path:G0(r,s.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ef?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function bAs(e){return e?.header!=null}var Dar=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;schemaNameMapping=new Map;variantPlan;reachability;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:o,authOverrides:s}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=s,this.globalHeaderOverrides=o,this.options=BOe({options:n}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new kOe(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let a={};if(!this.enableUniqueErrorsPerEndpoint)for(let c of r.endpoints)for(let[u,l]of Object.entries(c.errors)){let p=parseInt(u),d=a[p];d==null&&l.schema!=null?a[p]=l.schema:d!=null&&l.schema!=null&&ik(d,l.schema)||this.unknownSchema.add(p)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(YS.Channel,YS.Endpoint,YS.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Be(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:Be(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}setSchemaFinalName(t,r){this.schemaNameMapping.set(t,r)}hasReadVariant(t){return this.schemaNameMapping.has(t)}setVariantPlan(t,r){this.variantPlan=t,this.reachability=r;let n=[this.ir.groupedSchemas.rootSchemas,...Object.values(this.ir.groupedSchemas.namespacedSchemas)];for(let i of n)for(let[o,s]of Object.entries(i))if(t.needsBothVariants.has(o)&&s.type==="object"){let a=s.nameOverride??s.generatedName;this.schemaNameMapping.set(a,`${a}Read`)}}needsBothVariants(t){return this.variantPlan?.needsBothVariants.has(t)??!1}isRequestOnlyWithReadonly(t){return this.variantPlan?.requestOnlyWithReadonly.has(t)??!1}isResponseReachable(t){return this.reachability==null?this.ir.nonRequestReferencedSchemas.has(t):this.reachability.responseReachable.has(t)}isRequestOnly(t){return this.reachability==null?!this.ir.nonRequestReferencedSchemas.has(t):this.reachability.requestReachable.has(t)&&!this.reachability.responseReachable.has(t)}getSchemaFinalName(t,r){return!this.options.respectReadonlySchemas||r==="write"?t:this.schemaNameMapping.get(t)??t}};function _li(e){let t=new Dar(e);return yAs(t)}oA();function kAs(e){return typeof e>"u"||e===null}function Cyl(e){return typeof e=="object"&&e!==null}function xyl(e){return Array.isArray(e)?e:kAs(e)?[]:[e]}function _yl(e,t){var r,n,i,o;if(t)for(o=Object.keys(t),r=0,n=o.length;r<n;r+=1)i=o[r],e[i]=t[i];return e}function Syl(e,t){var r="",n;for(n=0;n<t;n+=1)r+=e;return r}function Byl(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Tyl=kAs,Oyl=Cyl,Pyl=xyl,Dyl=Syl,Ryl=Byl,Fyl=_yl,Hw={isNothing:Tyl,isObject:Oyl,toArray:Pyl,repeat:Dyl,isNegativeZero:Ryl,extend:Fyl};function NAs(e,t){var r="",n=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(r+=`
|
|
1469
1469
|
|
|
1470
1470
|
`+e.mark.snippet),n+" "+r):n}function rIt(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=NAs(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}rIt.prototype=Object.create(Error.prototype);rIt.prototype.constructor=rIt;rIt.prototype.toString=function(t){return this.name+": "+NAs(this,t)};var JP=rIt;function Sli(e,t,r,n,i){var o="",s="",a=Math.floor(i/2)-1;return n-t>a&&(o=" ... ",t=n-a+o.length),r-n>a&&(s=" ...",r=n+a-s.length),{str:o+e.slice(t,r).replace(/\t/g,"\u2192")+s,pos:n-t+o.length}}function Bli(e,t){return Hw.repeat(" ",t-e.length)+e}function kyl(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var r=/\r?\n|\r|\0/g,n=[0],i=[],o,s=-1;o=r.exec(e.buffer);)i.push(o.index),n.push(o.index+o[0].length),e.position<=o.index&&s<0&&(s=n.length-2);s<0&&(s=n.length-1);var a="",c,u,l=Math.min(e.line+t.linesAfter,i.length).toString().length,p=t.maxLength-(t.indent+l+3);for(c=1;c<=t.linesBefore&&!(s-c<0);c++)u=Sli(e.buffer,n[s-c],i[s-c],e.position-(n[s]-n[s-c]),p),a=Hw.repeat(" ",t.indent)+Bli((e.line-c+1).toString(),l)+" | "+u.str+`
|
|
1471
1471
|
`+a;for(u=Sli(e.buffer,n[s],i[s],e.position,p),a+=Hw.repeat(" ",t.indent)+Bli((e.line+1).toString(),l)+" | "+u.str+`
|
|
@@ -1662,7 +1662,7 @@ ${d8a.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&M4i(th
|
|
|
1662
1662
|
`+uNe.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?uNe.default.cyan(I8a(t,this.opt.mask)):uNe.default.italic(uNe.default.dim("[hidden]")):this.opt.mask?I8a(t,this.opt.mask):uNe.default.italic(uNe.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 dPr=ye(dC(),1);var vVa=ye(E3i(),1),pPr=require("child_process"),KKe=require("fs"),lPr=ye(require("path"),1),IVa=ye(require("os"),1),wVa=require("crypto"),izi=ye(bVa(),1);var aPr=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var gDt=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var cPr=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var uPr=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function fPr(e="",t,r){let n=new ozi(e,r);n.runAsync((i,o)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,o)}catch(s){setImmediate(t,s,void 0)}})}function EVa(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function Ptd(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var ozi=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=Ptd(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??IVa.default.tmpdir(),r=(0,wVa.randomUUID)(),n=EVa(this.fileOptions.prefix),i=EVa(this.fileOptions.postfix),o=`${n}${r}${i}`,s=lPr.default.resolve(t,o),a=lPr.default.resolve(t)+lPr.default.sep;if(!s.startsWith(a))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=s;let c={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(c.mode=this.fileOptions.mode),(0,KKe.writeFileSync)(this.tempFile,this.text,c)}catch(t){throw new aPr(t)}}readTemporaryFile(){try{let t=(0,KKe.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,vVa.detect)(t)??"utf8";izi.default.encodingExists(r)||(r="utf8"),this.text=izi.default.decode(t,r)}}catch(t){throw new cPr(t)}}removeTemporaryFile(){try{(0,KKe.unlinkSync)(this.tempFile)}catch(t){throw new uPr(t)}}launchEditor(){try{let t=(0,pPr.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new gDt(t)}}launchEditorAsync(t){try{(0,pPr.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new gDt(r)}}};var CVa=ye(mM(),1);var ADt=class extends mC{_run(t){this.done=t,this.editorResult=new CVa.Subject;let r=G1(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?dPr.default.dim("Received"):dPr.default.dim("Press <enter> to launch your preferred editor."),t&&(r=dPr.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),fPr(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 TVa=require("stream");var SVa=ye(require("readline"),1),BVa=ye(_Va(),1),dNe=class{constructor(t){this.rl||=SVa.default.createInterface(Rtd(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 Rtd(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new BVa.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var yDt=class extends dNe{constructor(t={}){super(t),this.log=new TVa.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return tDt(this.rl,this.bottomBar.split(`
|
|
1663
1663
|
`).length),this}updateBottomBar(t){return tDt(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+`
|
|
1664
1664
|
`}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&&kOr(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Jf=ye(mM(),1),DVa=ye(DPt(),1);var mPr=ye(mM(),1),OVa=ye(DPt(),1),hPr=function(e,t,r){return typeof e[t]!="function"?(0,mPr.of)(e):(0,mPr.from)((0,OVa.default)(e[t])(r).then(n=>(e[t]=n,e)))};var PVa={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,o,s)=>{i==="__proto__"||i==="constructor"||(o===s.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=o=>String.prototype.split.call(t,o).filter(Boolean).reduce((s,a)=>s!=null?s[a]:s,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},JKe=class extends dNe{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,Jf.from)(t):(0,Jf.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,Jf.from)(Object.entries(t).map(([i,o])=>({name:i,...o}))):n=(0,Jf.from)([t]),this.process=n.pipe((0,Jf.concatMap)(this.processQuestion.bind(this)),(0,Jf.publish)()),this.process.connect(),this.process.pipe((0,Jf.reduce)((i,o)=>(PVa.set(i,o.name,o.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Jf.defer)(()=>(0,Jf.of)(t).pipe((0,Jf.concatMap)(this.setDefaultType.bind(this)),(0,Jf.concatMap)(this.filterIfRunnable.bind(this)),(0,Jf.concatMap)(()=>hPr(t,"message",this.answers)),(0,Jf.concatMap)(()=>hPr(t,"default",this.answers)),(0,Jf.concatMap)(()=>hPr(t,"choices",this.answers)),(0,Jf.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Jf.defer)(()=>(0,Jf.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Jf.defer)(()=>(0,Jf.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&PVa.get(this.answers,t.name)!==void 0)return Jf.EMPTY;if(t.when===!1)return Jf.EMPTY;if(typeof t.when!="function")return(0,Jf.of)(t);let{answers:r}=this;return(0,Jf.defer)(()=>(0,Jf.from)((0,DVa.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Jf.filter)(n=>n!=null)))}};function RVa(e){let t=function(r,n){let i;try{i=new JKe(t.prompts,e)}catch(s){return Promise.reject(s)}let o=i.run(r,n);return o.ui=i,o};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",nDt),this.registerPrompt("input",cNe),this.registerPrompt("number",iDt),this.registerPrompt("confirm",oDt),this.registerPrompt("rawlist",sDt),this.registerPrompt("expand",aDt),this.registerPrompt("checkbox",cDt),this.registerPrompt("password",uDt),this.registerPrompt("editor",ADt)},t.restoreDefaultPrompts(),t}var azi=RVa();function ktd(e,t){azi.registerPrompt(e,t)}function Ntd(){azi.restoreDefaultPrompts()}var Qtd={prompt:azi,ui:{BottomBar:yDt,Prompt:JKe},createPromptModule:RVa,registerPrompt:ktd,restoreDefaultPrompts:Ntd,Separator:BN},Dp=Qtd;var YKe=require("path");function kVa(){let e=jtd();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function jtd(e=process.argv[1]?(0,YKe.dirname)(process.argv[1]):process.cwd(),t=YKe.sep==="\\"){let r=t?FVa(e):e;return n=>{if(!n)return;let i=t?FVa(n):n,{dir:o,base:s,ext:a}=YKe.posix.parse(i);(a===".js"||a===".mjs"||a===".cjs")&&(s=s.slice(0,-1*a.length));let c=decodeURIComponent(s);o||(o=".");let u=o.lastIndexOf("/node_modules");if(u>-1)return`${o.slice(u+14).replace(/\//g,".")}:${c}`;if(o.startsWith(r)){let l=o.slice(r.length+1).replace(/\//g,".");return l?`${l}:${c}`:c}return c}}function FVa(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var czi=e=>{if("flags"in e){let t=NVa(e.flags),r=QVa(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,o])=>[i,uzi(o)])),n=Object.fromEntries(Object.entries(t).map(([i,o])=>[i,Mtd(i,o,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function Mtd(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 NVa=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,bDt(r)]).filter(([,t])=>t!==void 0)),QVa=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?uzi(n):void 0]}))};var bDt=e=>e===void 0?void 0:e.variant??e.enabled,uzi=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var gPr="0123456789abcdef",APr=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length===16)return new e(t);throw new TypeError("not 128-bit length")}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let o=new Uint8Array(16);return o[0]=t/2**40,o[1]=t/2**32,o[2]=t/2**24,o[3]=t/2**16,o[4]=t/256,o[5]=t,o[6]=112|r>>>8,o[7]=r,o[8]=128|n>>>24,o[9]=n>>>16,o[10]=n>>>8,o[11]=n,o[12]=i>>>24,o[13]=i>>>16,o[14]=i>>>8,o[15]=i,new e(o)}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;default:break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let o=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=o>>>24,n[i+1]=o>>>16,n[i+2]=o>>>8,n[i+3]=o}return new e(n)}throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=gPr.charAt(this.bytes[r]>>>4),t+=gPr.charAt(15&this.bytes[r]),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=gPr.charAt(this.bytes[r]>>>4),t+=gPr.charAt(15&this.bytes[r]);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},lzi=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Ltd()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+r>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return APr.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}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,APr.ofInner(t)}},Ltd=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),jVa,Lbe=()=>Utd().toString(),Utd=()=>(jVa||(jVa=new lzi)).generate();var ON=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",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.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e})({});var ztd=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],MVa=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return ztd.concat(t).some(n=>{let i=n.toLowerCase();return r.indexOf(i)!==-1})};var qtd=Array.isArray,LVa=Object.prototype,s8b=LVa.hasOwnProperty,pzi=LVa.toString,fzi=qtd||function(e){return pzi.call(e)==="[object Array]"};var dzi=e=>e===Object(e)&&!fzi(e);var XKe=e=>e===void 0,EDt=e=>pzi.call(e)=="[object String]",UVa=e=>EDt(e)&&e.trim().length===0;var zVa=e=>pzi.call(e)=="[object Number]"&&e===e;var mzi=e=>e instanceof Error;function yPr(e){return e===null||typeof e!="object"}function mNe(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function VVa(e){return mNe(e,"ErrorEvent")}function ZKe(e){return!XKe(Event)&&Gtd(e,Event)}function qVa(e){return mNe(e,"Object")}function Gtd(e,t){try{return e instanceof t}catch{return!1}}function vDt(e,t,r,n,i){return t>r&&(n.warn("min cannot be greater than max."),t=r),zVa(e)?e>r?(n.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(n.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(n.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+i),vDt(i||r,t,r,n))}var Wtd=864e5,bPr=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=vDt(t.bucketSize,0,100,t._logger),this._refillRate=vDt(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=vDt(t.refillInterval,0,Wtd,t._logger)}_applyRefill(t,r){let n=r-t.lastAccess,i=Math.floor(n/this._refillInterval);if(i>0){let o=i*this._refillRate;t.tokens=Math.min(t.tokens+o,this._bucketSize),t.lastAccess=t.lastAccess+i*this._refillInterval}}consumeRateLimit(t){let r=Date.now(),n=String(t),i=this._buckets[n];return i?this._applyRefill(i,r):(i={tokens:this._bucketSize,lastAccess:r},this._buckets[n]=i),i.tokens===0?!0:(i.tokens--,i.tokens===0&&this._onBucketRateLimited?.(t),i.tokens===0)}stop(){this._buckets={}}};var EPr=class{add(t){let r=Lbe();return this.promiseByIds[r]=t,t.catch(()=>{}).finally(()=>{delete this.promiseByIds[r]}),t}async join(){let t=Object.values(this.promiseByIds),r=t.length;for(;r>0;)await Promise.all(t),t=Object.values(this.promiseByIds),r=t.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function $td(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var GVa=(e,t,r)=>{function n(o,...s){t(()=>{let a=r[o];a(e,...s)})}return{info:(...o)=>{n("log",...o)},warn:(...o)=>{n("warn",...o)},error:(...o)=>{n("error",...o)},critical:(...o)=>{r.error(e,...o)},createLogger:o=>GVa(`${e} ${o}`,t,r)}},Htd=e=>e();function WVa(e,t=Htd){return GVa(e,t,$td())}var tJe="Mobile",IPr="iOS",eJe="Android",$Va="Tablet",y8b=eJe+" "+$Va;var Ktd="Apple",b8b=Ktd+" Watch",HVa="Safari",wPr="BlackBerry",KVa="Samsung",Jtd=KVa+"Browser",Ytd=KVa+" Internet",CPr="Chrome",Xtd=CPr+" OS",Ztd=CPr+" "+IPr,JVa="Internet Explorer",erd=JVa+" "+tJe,gzi="Opera",E8b=gzi+" Mini",YVa="Edge",trd="Microsoft "+YVa,Azi="Firefox",rrd=Azi+" "+IPr,yzi="Nintendo",bzi="PlayStation",vPr="Xbox",nrd=eJe+" "+tJe,ird=tJe+" "+HVa,IDt="Windows",ord=IDt+" Phone";var XVa="Generic",v8b=XVa+" "+tJe.toLowerCase(),I8b=XVa+" "+$Va.toLowerCase(),srd="Konqueror",TD="(\\d+(\\.\\d+)?)",hzi=new RegExp("Version/"+TD),w8b=new RegExp(vPr,"i"),C8b=new RegExp(bzi+" \\w+","i"),x8b=new RegExp(yzi+" \\w+","i"),ard=new RegExp(wPr+"|PlayBook|BB10","i"),crd={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000","5.1":"XP","5.2":"XP","6.0":"Vista","6.1":"7","6.2":"8","6.3":"8.1","6.4":"10","10.0":"10"};var _8b={[erd]:[new RegExp("rv:"+TD)],[trd]:[new RegExp(YVa+"?\\/"+TD)],[CPr]:[new RegExp("("+CPr+"|CrMo)\\/"+TD)],[Ztd]:[new RegExp("CriOS\\/"+TD)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+TD)],[HVa]:[hzi],[ird]:[hzi],[gzi]:[new RegExp("("+gzi+"|OPR)\\/"+TD)],[Azi]:[new RegExp(Azi+"\\/"+TD)],[rrd]:[new RegExp("FxiOS\\/"+TD)],[srd]:[new RegExp("Konqueror[:/]?"+TD,"i")],[wPr]:[new RegExp(wPr+" "+TD),hzi],[nrd]:[new RegExp("android\\s"+TD,"i")],[Ytd]:[new RegExp(Jtd+"\\/"+TD)],[JVa]:[new RegExp("(rv:|MSIE )"+TD)],Mozilla:[new RegExp("rv:"+TD)]};var S8b=[[new RegExp(vPr+"; "+vPr+" (.*?)[);]","i"),e=>[vPr,e&&e[1]||""]],[new RegExp(yzi,"i"),[yzi,""]],[new RegExp(bzi,"i"),[bzi,""]],[ard,[wPr,""]],[new RegExp(IDt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ord,""];if(new RegExp(tJe).test(t)&&!/IEMobile\b/.test(t))return[IDt+" "+tJe,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let n=r[1],i=crd[n]||"";return/arm/i.test(t)&&(i="RT"),[IDt,i]}return[IDt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[IPr,t.join(".")]}return[IPr,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=XKe(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+eJe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+eJe+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[eJe,t.join(".")]}return[eJe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=["Mac OS X",""];if(e&&e[1]){let r=[e[1],e[2],e[3]||"0"];t[1]=r.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Xtd,""]],[/Linux|debian/i,["Linux",""]]];var ZVa="utf8";function e6a(e,t){if(!e||typeof e!="string"||urd(e))throw new Error(t)}function urd(e){return e.trim().length===0}function t6a(e){return e?.replace(/\/+$/,"")}async function r6a(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function xPr(){return new Date().toISOString()}function Yue(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var n6a=e=>e instanceof Error;function Ezi(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var _Pr=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};function i6a(){return"CompressionStream"in globalThis}async function vzi(e,t=!0){try{let n=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(n).blob()}catch(r){return t&&console.error("Failed to gzip compress data",r),null}}var hNe=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()}},rJe=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function o6a(e){if(e instanceof hNe){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 Izi(e){return typeof e=="object"&&(e instanceof hNe||e instanceof rJe)}function s6a(e){return typeof e=="object"&&e instanceof hNe&&e.status===413}var wDt=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new EPr,this._events=new _Pr,this._isInitialized=!1,e6a(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=t6a(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.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:Izi},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,this._logger=WVa("[PostHog]",this.logMsgIfDebug.bind(this)),this.evaluationContexts=r?.evaluationContexts??r?.evaluationEnvironments,r?.evaluationEnvironments&&!r?.evaluationContexts&&this._logger.warn("evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version."),this.disableCompression=!i6a()||(r?.disableCompression??!1)}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(ON.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(ON.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(ON.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>this._logger.info(n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){return this.promiseQueue.add(t)}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let o=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",o,i)})}async captureStatelessImmediate(t,r,n,i){let o=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",o,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let o=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",o,i)})}async aliasStatelessImmediate(t,r,n,i){let o=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",o,i)}groupIdentifyStateless(t,r,n,i,o,s){this.wrap(()=>{let a=this.buildPayload({distinct_id:o||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...s||{}}});this.enqueue("capture",a,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this._logger.error("Remote config could not be loaded",i),this._events.emit("error",i)})}async getFlags(t,r={},n={},i={},o={},s=!1){await this._initPromise;let a=s?"&config=true":"",c=`${this.host}/flags/?v=2${a}`,u={token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...o};this.evaluationContexts&&this.evaluationContexts.length>0&&(u.evaluation_contexts=this.evaluationContexts);let l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(u)};return this._logger.info("Flags URL",c),this.fetchWithRetry(c,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(p=>p.json()).then(p=>({success:!0,response:czi(p)})).catch(p=>(this._events.emit("error",p),{success:!1,error:this.categorizeRequestError(p)}))}categorizeRequestError(t){if(t instanceof hNe)return{type:"api_error",statusCode:t.status};if(t instanceof rJe){let r=t.error;return r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError")?{type:"timeout"}:{type:"connection_error"}}return{type:"unknown_error"}}async getFeatureFlagStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagDetailStateless(t,r,n,i,o,s);if(a===void 0)return{response:void 0,requestId:void 0};let c=bDt(a.response);return c===void 0&&(c=!1),{response:c,requestId:a.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagDetailsStateless(r,n,i,o,s,[t]);return a===void 0?void 0:{response:a.flags[t],requestId:a.requestId,evaluatedAt:a.evaluatedAt}}async getFeatureFlagPayloadStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagPayloadsStateless(r,n,i,o,s,[t]);if(!a)return;let c=a[t];return c===void 0?null:c}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},o,s){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,o,s)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},o,s){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,o,s)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},o,s){await this._initPromise;let a=await this.getFeatureFlagDetailsStateless(t,r,n,i,o,s);return a?{flags:a.featureFlags,payloads:a.featureFlagPayloads,requestId:a.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},o,s){await this._initPromise;let a={};(o??this.disableGeoip)&&(a.geoip_disable=!0),s&&(a.flag_keys_to_evaluate=s);let c=await this.getFlags(t,r,n,i,a);if(!c.success)return;let u=c.response;return u.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"),u.quotaLimited?.includes("feature_flags")?(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:u?.requestId,quotaLimited:u.quotaLimited}):u}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this._logger.info("Loading surveys is disabled."),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(o=>{if(o.status!==200||!o.json){let s=`Surveys API could not be loaded: ${o.status}`,a=new Error(s);this._logger.error(a),this._events.emit("error",new Error(s));return}return o.json()}).catch(o=>{this._logger.error("Surveys API could not be loaded",o),this._events.emit("error",o)}))?.surveys;return i&&this._logger.info("Surveys fetched from API: ",JSON.stringify(i)),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(ON.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(ON.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(ON.Props,this.props)})}processBeforeEnqueue(t){return t}async flushStorage(){}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let i=this.prepareMessage(t,r,n);if(i=this.processBeforeEnqueue(i),i===null)return;let o=this.getPersistedProperty(ON.Queue)||[];o.length>=this.maxQueueSize&&(o.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),o.push({message:i}),this.setPersistedProperty(ON.Queue,o),this._events.emit(t,i),o.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Yue(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let i=this.prepareMessage(t,r,n);if(i=this.processBeforeEnqueue(i),i===null)return;let o={api_key:this.apiKey,batch:[i],sent_at:xPr()};this.historicalMigration&&(o.historical_migration=!0);let s=JSON.stringify(o),a=`${this.host}/batch/`,c=this.disableCompression?null:await vzi(s,this.isDebug),u={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...c!==null&&{"Content-Encoding":"gzip"}},body:c||s};try{await this.fetchWithRetry(a,u)}catch(l){this._events.emit("error",l)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:xPr(),uuid:n?.uuid?n.uuid:Lbe()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await o6a(t)})}async flush(){let t=Ezi([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),Ezi([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(ON.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),o=i.map(f=>f.message),s=async()=>{let m=(this.getPersistedProperty(ON.Queue)||[]).slice(i.length);this.setPersistedProperty(ON.Queue,m),t=m,await this.flushStorage()},a={api_key:this.apiKey,batch:o,sent_at:xPr()};this.historicalMigration&&(a.historical_migration=!0);let c=JSON.stringify(a),u=`${this.host}/batch/`,l=this.disableCompression?null:await vzi(c,this.isDebug),p={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...l!==null&&{"Content-Encoding":"gzip"}},body:l||c},d={retryCheck:f=>s6a(f)?!1:Izi(f)};try{await this.fetchWithRetry(u,p,d)}catch(f){if(s6a(f)&&o.length>1){this.maxBatchSize=Math.max(1,Math.floor(o.length/2)),this._logger.warn(`Received 413 when sending batch of size ${o.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw f instanceof rJe||await s(),this._events.emit("error",f),f}await s(),r.push(...o)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){let o=r.body?r.body:"",s=-1;try{s=o instanceof Blob?o.size:Buffer.byteLength(o,ZVa)}catch{o instanceof Blob?s=o.size:s=new TextEncoder().encode(o).length}return await r6a(async()=>{let a=new AbortController,c=i??this.requestTimeout,u=Yue(()=>a.abort(),c),l=null;try{l=await this.fetch(t,{signal:a.signal,...r})}catch(d){throw new rJe(d)}finally{clearTimeout(u)}if(!(r.mode==="no-cors")&&(l.status<200||l.status>=400))throw new hNe(l,s);return l},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(ON.Queue)||[]).length===0||(await this.flush(),r)););}catch(o){if(!Izi(o))throw o;await o6a(o)}},i;try{return await Promise.race([new Promise((o,s)=>{i=Yue(()=>{this._logger.error("Timed out while shutting down PostHog"),r=!0,s("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}finally{clearTimeout(i)}}async shutdown(t=3e4){return this.shutdownPromise?this._logger.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}};var PN={};te(PN,{DOMExceptionCoercer:()=>_zi,ErrorCoercer:()=>Szi,ErrorEventCoercer:()=>Bzi,ErrorPropertiesBuilder:()=>wzi,EventCoercer:()=>Pzi,ObjectCoercer:()=>Ozi,PrimitiveCoercer:()=>Dzi,PromiseRejectionEventCoercer:()=>Rzi,ReduceableCache:()=>Fzi,StringCoercer:()=>Tzi,chromeStackLineParser:()=>Czi,createDefaultStackParser:()=>Crd,createStackParser:()=>A6a,geckoStackLineParser:()=>xzi,nodeStackLineParser:()=>d6a,opera10StackLineParser:()=>l6a,opera11StackLineParser:()=>p6a,reverseAndStripFrames:()=>g6a,winjsStackLineParser:()=>u6a});var SPr,a6a,BPr;function c6a(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return BPr&&r.length===a6a||(a6a=r.length,BPr=r.reduce((n,i)=>{SPr||(SPr={});let o=SPr[i];if(o)n[o[0]]=o[1];else{let s=e(i);for(let a=s.length-1;a>=0;a--){let u=s[a]?.filename,l=t[i];if(u&&l){n[u]=l,SPr[i]=[u,l];break}}}return n},{})),BPr}var prd=4,wzi=class{constructor(t,r,n=[]){this.coercers=t,this.stackParser=r,this.modifiers=n}buildFromUnknown(t,r={}){let i=r&&r.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,r,0).apply(t),a=this.buildParsingContext(r),c=this.parseStacktrace(s,a);return{$exception_list:this.convertToExceptionList(c,i),$exception_level:"error"}}async modifyFrames(t){for(let r of t)r.stacktrace&&r.stacktrace.frames&&fzi(r.stacktrace.frames)&&(r.stacktrace.frames=await this.applyModifiers(r.stacktrace.frames));return t}coerceFallback(t){return{type:"Error",value:"Unknown error",stack:t.syntheticException?.stack,synthetic:!0}}parseStacktrace(t,r){let n;t.cause!=null&&(n=this.parseStacktrace(t.cause,r));let i;return t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?r.skipFirstLines:0),r.chunkIdMap)),{...t,cause:n,stack:i}}applyChunkIds(t,r){return t.map(n=>(n.filename&&r&&(n.chunk_id=r[n.filename]),n))}applyCoercers(t,r){for(let n of this.coercers)if(n.match(t))return n.coerce(t,r);return this.coerceFallback(r)}async applyModifiers(t){let r=t;for(let n of this.modifiers)r=await n(r);return r}convertToExceptionList(t,r){let n={type:t.type,value:t.value,mechanism:{type:r.type??"generic",handled:r.handled??!0,synthetic:t.synthetic??!1}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});let i=[n];return t.cause!=null&&i.push(...this.convertToExceptionList(t.cause,{...r,handled:!0})),i}buildParsingContext(t){return{chunkIdMap:c6a(this.stackParser),skipFirstLines:t.skipFirstLines??1}}buildCoercingContext(t,r,n=0){let i=(s,a)=>{if(a<=prd){let c=this.buildCoercingContext(t,r,a);return this.applyCoercers(s,c)}};return{...r,syntheticException:n==0?r.syntheticException:void 0,mechanism:t,apply:s=>i(s,n),next:s=>i(s,n+1)}}};var $1="?";function OX(e,t,r,n,i){let o={platform:e,filename:t,function:r==="<anonymous>"?$1:r,in_app:!0};return XKe(n)||(o.lineno=n),XKe(i)||(o.colno=i),o}var TPr=(e,t)=>{let r=e.indexOf("safari-extension")!==-1,n=e.indexOf("safari-web-extension")!==-1;return r||n?[e.indexOf("@")!==-1?e.split("@")[0]:$1,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var frd=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,drd=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mrd=/\((\S*)(?::(\d+))(?::(\d+))\)/,Czi=(e,t)=>{let r=frd.exec(e);if(r){let[,i,o,s]=r;return OX(t,i,$1,+o,+s)}let n=drd.exec(e);if(n){if(n[2]&&n[2].indexOf("eval")===0){let a=mrd.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}let[o,s]=TPr(n[1]||$1,n[2]);return OX(t,s,o,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}};var hrd=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,grd=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,xzi=(e,t)=>{let r=hrd.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let s=grd.exec(r[3]);s&&(r[1]=r[1]||"eval",r[3]=s[1],r[4]=s[2],r[5]="")}let i=r[3],o=r[1]||$1;return[o,i]=TPr(o,i),OX(t,i,o,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var Ard=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,u6a=(e,t)=>{let r=Ard.exec(e);return r?OX(t,r[2],r[1]||$1,+r[3],r[4]?+r[4]:void 0):void 0};var yrd=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,l6a=(e,t)=>{let r=yrd.exec(e);return r?OX(t,r[2],r[3]||$1,+r[1]):void 0},brd=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,p6a=(e,t)=>{let r=brd.exec(e);return r?OX(t,r[5],r[3]||r[4]||$1,+r[1],+r[2]):void 0};var Erd=/^\s*[-]{4,}$/,vrd=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,d6a=(e,t)=>{let r=e.match(vrd);if(r){let n,i,o,s,a;if(r[1]){o=r[1];let l=o.lastIndexOf(".");if(o[l-1]==="."&&l--,l>0){n=o.slice(0,l),i=o.slice(l+1);let p=n.indexOf(".Module");p>0&&(o=o.slice(p+1),n=n.slice(0,p))}s=void 0}i&&(s=n,a=i),i==="<anonymous>"&&(a=void 0,o=void 0),o===void 0&&(a=a||$1,o=s?`${s}.${a}`:a);let c=r[2]?.startsWith("file://")?r[2].slice(7):r[2],u=r[5]==="native";return c?.match(/\/[A-Z]:/)&&(c=c.slice(1)),!c&&r[5]&&!u&&(c=r[5]),{filename:c?decodeURI(c):void 0,module:void 0,function:o,lineno:f6a(r[3]),colno:f6a(r[4]),in_app:Ird(c||"",u),platform:t}}if(e.match(Erd))return{filename:e,platform:t}};function Ird(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 f6a(e){return parseInt(e||"",10)||void 0}var m6a=/\(error: (.*)\)/,h6a=50;function g6a(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,h6a).map(r=>({...r,filename:r.filename||wrd(t).filename,function:r.function||$1}))}function wrd(e){return e[e.length-1]||{}}function Crd(){return A6a("web:javascript",Czi,xzi)}function A6a(e,...t){return(r,n=0)=>{let i=[],o=r.split(`
|
|
1665
|
-
`);for(let s=n;s<o.length;s++){let a=o[s];if(a.length>1024)continue;let c=m6a.test(a)?a.replace(m6a,"$1"):a;if(!c.match(/\S*Error: /)){for(let u of t){let l=u(c,e);if(l){i.push(l);break}}if(i.length>=h6a)break}}return g6a(i)}}var _zi=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let n=EDt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:n?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return mNe(t,"DOMException")}isDOMError(t){return mNe(t,"DOMError")}};var Szi=class{match(t){return mzi(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let n=t.message;return n.error&&typeof n.error.message=="string"?String(n.error.message):String(n)}getStack(t){return t.stacktrace||t.stack||void 0}};var Bzi=class{constructor(){}match(t){return VVa(t)&&t.error!=null}coerce(t,r){let n=r.apply(t.error);return n||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var xrd=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Tzi=class{match(t){return typeof t=="string"}coerce(t,r){let[n,i]=this.getInfos(t);return{type:n??"Error",value:i??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",n=t,i=t.match(xrd);return i&&(r=i[1],n=i[2]),[r,n]}};var y6a=["fatal","error","warning","log","info","debug"];function OPr(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let n=r.length;n>0;n--){let i=r.slice(0,n).join(", ");if(!(i.length>t))return n===r.length||i.length<=t?i:`${i.slice(0,t)}...`}return""}var Ozi=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let n=this.getErrorPropertyFromObject(t);return n?r.apply(n):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return ZKe(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let i=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(i+=` with message: '${t.message}'`),i}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),n=OPr(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${n}`}isSeverityLevel(t){return EDt(t)&&!UVa(t)&&y6a.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n6a(n))return n}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var Pzi=class{match(t){return ZKe(t)}coerce(t,r){let n=t.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${OPr(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Dzi=class{match(t){return yPr(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Rzi=class{match(t){return mNe(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!ZKe(t))return!1;try{let r=t.detail;return r!=null&&typeof r=="object"&&"reason"in r}catch{return!1}}coerce(t,r){let n=this.getUnhandledRejectionReason(t);return yPr(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(n)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var Fzi=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)}}};var v6a=require("fs"),I6a=require("readline"),PPr=new PN.ReduceableCache(25),w6a=new PN.ReduceableCache(20),kzi=7,_rd=1e3,Srd=1e4;async function C6a(e){let t={};for(let i=e.length-1;i>=0;i--){let o=e[i],s=o?.filename;if(!o||typeof s!="string"||typeof o.lineno!="number"||Prd(s)||Drd(o))continue;t[s]||(t[s]=[]),t[s].push(o.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(w6a.get(i))continue;let o=t[i];if(!o)continue;o.sort((c,u)=>c-u);let s=Frd(o);if(s.every(c=>Rrd(i,c)))continue;let a=krd(PPr,i,{});n.push(Brd(i,s,a))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&Trd(e,PPr),PPr.reduce(),e}function Brd(e,t,r){return new Promise(n=>{let i=(0,v6a.createReadStream)(e),o=(0,I6a.createInterface)({input:i});function s(){i.destroy(),n()}let a=0,c=0,u=t[c];if(u===void 0)return void s();let l=u[0],p=u[1];function d(){w6a.set(e,1),o.close(),o.removeAllListeners(),s()}i.on("error",d),o.on("error",d),o.on("close",s),o.on("line",f=>{if(a++,!(a<l)&&(r[a]=Nrd(f,0),a>=p)){if(c===t.length-1){o.close(),o.removeAllListeners();return}c++;let m=t[c];if(m===void 0){o.close(),o.removeAllListeners();return}l=m[0],p=m[1]}})})}function Trd(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;Ord(r.lineno,r,n)}}function Ord(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=x6a(e);i<e;i++){let o=r[i];if(o===void 0)return void b6a(t);t.pre_context.push(o)}if(r[e]===void 0)return void b6a(t);t.context_line=r[e];let n=_6a(e);t.post_context=[];for(let i=e+1;i<=n;i++){let o=r[i];if(o===void 0)break;t.post_context.push(o)}}function b6a(e){delete e.pre_context,delete e.context_line,delete e.post_context}function Prd(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function Drd(e){return e.lineno!==void 0&&e.lineno>Srd||e.colno!==void 0&&e.colno>_rd}function Rrd(e,t){let r=PPr.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function Frd(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=E6a(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let o=e[t+1];if(typeof o!="number")break;o<=n[1]?n[1]=o+kzi:(i.push(n),n=E6a(o)),t++}return i}function E6a(e){return[x6a(e),_6a(e)]}function x6a(e){return Math.max(1,e-kzi)}function _6a(e){return e+kzi}function krd(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function Nrd(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let o=Math.min(i+140,n);return o>n-5&&(o=n),o===n&&(i=Math.max(o-140,0)),r=r.slice(i,o),i>0&&(r=`...${r}`),o<n&&(r+="..."),r}function Qrd(e,t){let r=!1;return Object.assign(n=>{let o=global.process.listeners("uncaughtException").filter(s=>s.name!=="domainUncaughtExceptionClear"&&s._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&o&&(r=!0,t(n))},{_posthogErrorHandler:!0})}function S6a(e,t){globalThis.process?.on("uncaughtException",Qrd(e,t))}function B6a(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var jrd=2e3,l9=class e{constructor(t,r,n){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new bPr({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return dzi(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,n,i){let o={...i},s=this.errorPropertiesBuilder.buildFromUnknown(t,r);return s.$exception_list=await this.errorPropertiesBuilder.modifyFrames(s.$exception_list),{event:"$exception",distinctId:n,properties:{...s,...o},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(S6a(this.onException.bind(this),this.onFatalError.bind(this)),B6a(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let n=await e.buildEventMessage(t,r),o=n.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(o)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:o}):this.client.capture(n)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(jrd),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var T6a="5.28.6";var CDt={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function O6a(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}var Mrd=6e4,Lrd=1152921504606847e3,Urd=["is_not"],nJe=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Yf=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},PX=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},DPr=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:o,customHeaders:s,...a}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=o,this.poller=void 0,this.fetch=a.fetch||fetch,this.onError=a.onError,this.customHeaders=s,this.onLoad=a.onLoad,this.cacheProvider=a.cacheProvider,this.strictLocalEvaluation=a.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}createEvaluationContext(t,r={},n={},i={},o={}){return{distinctId:t,groups:r,personProperties:n,groupProperties:i,evaluationCache:o}}async getFeatureFlag(t,r,n={},i={},o={}){await this.loadFeatureFlags();let s,a;if(!this.loadedSuccessfullyOnce)return s;if(a=this.featureFlagsByKey[t],a!==void 0){let c=this.createEvaluationContext(r,n,i,o);try{s=(await this.computeFlagAndPayloadLocally(a,c)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${s}`))}catch(u){u instanceof PX||u instanceof Yf?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${t}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${u}`))}}return s}async getAllFlagsAndPayloads(t,r){await this.loadFeatureFlags();let n={},i={},o=this.featureFlags.length==0,s=r?r.map(c=>this.featureFlagsByKey[c]).filter(Boolean):this.featureFlags,a={...t,evaluationCache:t.evaluationCache??{}};return await Promise.all(s.map(async c=>{try{let{value:u,payload:l}=await this.computeFlagAndPayloadLocally(c,a);n[c.key]=u,l&&(i[c.key]=l)}catch(u){u instanceof PX||u instanceof Yf?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${c.key}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${c.key}: ${u}`)),o=!0}})),{response:n,payloads:i,fallbackToFlags:o}}async computeFlagAndPayloadLocally(t,r,n={}){let{matchValue:i,skipLoadCheck:o=!1}=n;if(o||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=i!==void 0?i:await this.computeFlagValueLocally(t,r);let a=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:a}}async computeFlagValueLocally(t,r){let{distinctId:n,groups:i,personProperties:o,groupProperties:s}=r;if(t.ensure_experience_continuity)throw new Yf("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let u=this.groupTypeMapping[String(c)];if(!u)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new Yf("Flag has unknown group type index");if(!(u in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;t.bucketing_identifier==="device_id"&&(o?.$device_id===void 0||o?.$device_id===null||o?.$device_id==="")&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${t.key}`));let l=s[u];return await this.matchFeatureFlagProperties(t,i[u],l,r)}{let u=this.getBucketingValueForFlag(t,n,o);if(u===void 0)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${t.key} without $device_id, falling back to server evaluation`)),new Yf(`Can't compute feature flag: ${t.key} without $device_id`);return await this.matchFeatureFlagProperties(t,u,o,r)}}getBucketingValueForFlag(t,r,n){if(t.filters?.aggregation_group_type_index!=null)return r;if(t.bucketing_identifier==="device_id"){let i=n?.$device_id;return i==null||i===""?void 0:i}return r}getFeatureFlagPayload(t,r){let n=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),n!=null)){if(typeof n=="object")return n;if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(t,r,n){let{evaluationCache:i}=n,o=t.key;if(!this.featureFlagsByKey)throw new Yf("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new Yf(`Flag dependency property for '${o}' is missing required 'dependency_chain' field`);let s=t.dependency_chain;if(!Array.isArray(s))throw new Yf(`Flag dependency property for '${o}' has an invalid 'dependency_chain' (expected array, got ${typeof s})`);if(s.length===0)throw new Yf(`Circular dependency detected for flag '${o}' (empty dependency chain)`);for(let c of s){if(!(c in i)){let l=this.featureFlagsByKey[c];if(l)if(l.active)try{let p=await this.computeFlagValueLocally(l,n);i[c]=p}catch(p){throw new Yf(`Error evaluating flag dependency '${c}' for flag '${o}': ${p}`)}else i[c]=!1;else throw new Yf(`Missing flag dependency '${c}' for flag '${o}'`)}if(i[c]==null)throw new Yf(`Dependency '${c}' could not be evaluated`)}let a=i[o];return this.flagEvaluatesToExpectedValue(t.value,a)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,n,i){let o=t.filters||{},s=o.groups||[],a=!1,c;for(let u of s)try{if(await this.isConditionMatch(t,r,u,n,i)){let l=u.variant,p=o.multivariate?.variants||[];c=l&&p.some(d=>d.key===l)?l:await this.getMatchingVariant(t,r)||!0;break}}catch(l){if(l instanceof PX)throw l;if(l instanceof Yf)a=!0;else throw l}if(c!==void 0)return c;if(a)throw new Yf("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i,o){let s=n.rollout_percentage,a=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let u=c.type,l=!1;if(l=u==="cohort"?k6a(c,i,this.cohorts,this.debugMode):u==="flag"?await this.evaluateFlagDependency(c,i,o):F6a(c,i,a),!l)return!1}if(s==null)return!0}return!(s!=null&&await P6a(t.key,r)>s/100)}async getMatchingVariant(t,r){let n=await P6a(t.key,r,"variant"),i=this.variantLookupTable(t).find(o=>n>=o.valueMin&&n<o.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(a=>{i=n+a.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:a.key}),n=i}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,n)=>(r[n.key]=n,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(n=>n.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(n=>n.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(Mrd,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(n){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${n}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new nJe(`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.beginBackoff(),new nJe(`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.beginBackoff(),new nJe(`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 n=await r.json()??{};if(!("flags"in n))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let i={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(i),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(i)}catch(o){this.onError?.(new Error(`Failed to store in cache: ${o}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(i.flags);break}default:return}}catch(t){t instanceof nJe&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let n={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(n["If-None-Match"]=r),{method:t,headers:n}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Yue(()=>{i.abort()},this.timeout),r.signal=i.signal}try{let i=this.fetch;return i(t,r)}finally{clearTimeout(n)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((n,i)=>setTimeout(()=>i(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function P6a(e,t,r=""){let n=await O6a(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/Lrd}function F6a(e,t,r){let n=e.key,i=e.value,o=e.operator||"exact";if(n in t){if(o==="is_not_set")throw new Yf("Operator is_not_set is not supported")}else throw new Yf(`Property ${n} not found in propertyValues`);let s=t[n];if(s==null&&!Urd.includes(o))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${o} operator`),!1;function a(u,l){return Array.isArray(u)?u.map(p=>String(p).toLowerCase()).includes(String(l).toLowerCase()):String(u).toLowerCase()===String(l).toLowerCase()}function c(u,l,p){if(p==="gt")return u>l;if(p==="gte")return u>=l;if(p==="lt")return u<l;if(p==="lte")return u<=l;throw new Error(`Invalid operator: ${p}`)}switch(o){case"exact":return a(i,s);case"is_not":return!a(i,s);case"is_set":return n in t;case"icontains":return String(s).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(s).toLowerCase().includes(String(i).toLowerCase());case"regex":return D6a(String(i))&&String(s).match(String(i))!==null;case"not_regex":return D6a(String(i))&&String(s).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u==null||s==null?c(String(s),String(i),o):typeof s=="string"?c(s,String(i),o):c(s,u,o)}case"is_date_after":case"is_date_before":{if(typeof i=="boolean")throw new Yf("Date operations cannot be performed on boolean values");let u=Wrd(String(i));if(u==null&&(u=R6a(i)),u==null)throw new Yf(`Invalid date: ${i}`);let l=R6a(s);return["is_date_before"].includes(o)?l<u:l>u}case"semver_eq":return Z3(H1(String(s)),H1(String(i)))===0;case"semver_neq":return Z3(H1(String(s)),H1(String(i)))!==0;case"semver_gt":return Z3(H1(String(s)),H1(String(i)))>0;case"semver_gte":return Z3(H1(String(s)),H1(String(i)))>=0;case"semver_lt":return Z3(H1(String(s)),H1(String(i)))<0;case"semver_lte":return Z3(H1(String(s)),H1(String(i)))<=0;case"semver_tilde":{let u=H1(String(s)),{lower:l,upper:p}=Vrd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}case"semver_caret":{let u=H1(String(s)),{lower:l,upper:p}=qrd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}case"semver_wildcard":{let u=H1(String(s)),{lower:l,upper:p}=Grd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}default:throw new Yf(`Unknown operator: ${o}`)}}function zrd(e,t){if(!(e in t))throw new PX(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function k6a(e,t,r,n=!1){let i=String(e.value);zrd(i,r);let o=r[i];return N6a(o,t,r,n)}function N6a(e,t,r,n=!1){if(!e)return!0;let i=e.type,o=e.values;if(!o||o.length===0)return!0;let s=!1;if("values"in o[0]){for(let a of o)try{let c=N6a(a,t,r,n);if(i==="AND"){if(!c)return!1}else if(c)return!0}catch(c){if(c instanceof PX)throw c;if(c instanceof Yf)n&&console.debug(`Failed to compute property ${a} locally: ${c}`),s=!0;else throw c}if(s)throw new Yf("Can't match cohort without a given cohort property value");return i==="AND"}for(let a of o)try{let c;if(a.type==="cohort")c=k6a(a,t,r,n);else if(a.type==="flag"){n&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${a.key||"unknown"}'`);continue}else c=F6a(a,t);let u=a.negation||!1;if(i==="AND"){if(!c&&!u||c&&u)return!1}else if(c&&!u||!c&&u)return!0}catch(c){if(c instanceof PX)throw c;if(c instanceof Yf)n&&console.debug(`Failed to compute property ${a} locally: ${c}`),s=!0;else throw c}if(s)throw new Yf("can't match cohort without a given cohort property value");return i==="AND"}function D6a(e){try{return new RegExp(e),!0}catch{return!1}}function H1(e){let r=String(e).trim().replace(/^[vV]/,"").split("-")[0].split("+")[0];if(!r||r.startsWith("."))throw new Yf(`Invalid semver: ${e}`);let n=r.split("."),i=c=>{if(c===void 0||c==="")return 0;if(!/^\d+$/.test(c))throw new Yf(`Invalid semver: ${e}`);return parseInt(c,10)},o=i(n[0]),s=i(n[1]),a=i(n[2]);return[o,s,a]}function Z3(e,t){for(let r=0;r<3;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return 0}function Vrd(e){let t=H1(e),r=[t[0],t[1],t[2]],n=[t[0],t[1]+1,0];return{lower:r,upper:n}}function qrd(e){let t=H1(e),[r,n,i]=t,o=[r,n,i],s;return s=r>0?[r+1,0,0]:n>0?[0,n+1,0]:[0,0,i+1],{lower:o,upper:s}}function Grd(e){let r=String(e).trim().replace(/^[vV]/,"").replace(/\.\*$/,"").replace(/\*$/,"");if(!r)throw new Yf(`Invalid wildcard semver: ${e}`);let n=r.split("."),i=parseInt(n[0],10);if(isNaN(i))throw new Yf(`Invalid wildcard semver: ${e}`);let o,s;if(n.length===1)o=[i,0,0],s=[i+1,0,0];else{let a=parseInt(n[1],10);if(isNaN(a))throw new Yf(`Invalid wildcard semver: ${e}`);o=[i,a,0],s=[i,a+1,0]}return{lower:o,upper:s}}function R6a(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 Yf(`${e} is in an invalid date format`)}throw new Yf(`The date provided ${e} must be a string, number, or date object`)}function Wrd(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let o=r.groups.interval;if(o=="h")n.setUTCHours(n.getUTCHours()-i);else if(o=="d")n.setUTCDate(n.getUTCDate()-i);else if(o=="w")n.setUTCDate(n.getUTCDate()-7*i);else if(o=="m")n.setUTCMonth(n.getUTCMonth()-i);else{if(o!="y")return null;n.setUTCFullYear(n.getUTCFullYear()-i)}return n}}var RPr=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var $rd=100,Q6a=3e4,Hrd=5e4,Krd=50,Jrd=500,FPr=class extends wDt{constructor(t,r={}){if(super(t,r),this._memoryStorage=new RPr,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,$rd):Q6a,typeof r.waitUntilDebounceMs=="number"&&(this.options.waitUntilDebounceMs=Math.max(r.waitUntilDebounceMs,0)),typeof r.waitUntilMaxWaitMs=="number"&&(this.options.waitUntilMaxWaitMs=Math.max(r.waitUntilMaxWaitMs,0)),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.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new DPr({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(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new l9(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Hrd}enqueue(t,r,n){super.enqueue(t,r,n),this.scheduleDebouncedFlush()}async flush(){let t=super.flush(),r=this.options.waitUntil;if(r&&!this._waitUntilCycle)try{r(t.catch(()=>{}))}catch{}return t}scheduleDebouncedFlush(){let t=this.options.waitUntil;if(!t||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let s,a=new Promise(c=>{s=c});try{t(a)}catch{return}this._waitUntilCycle={resolve:s,startedAt:Date.now(),timer:void 0}}let r=Date.now()-this._waitUntilCycle.startedAt,n=this.options.waitUntilMaxWaitMs??Jrd,i=r>=n;if(this._waitUntilCycle.timer!==void 0&&clearTimeout(this._waitUntilCycle.timer),i)return void this.resolveWaitUntilFlush();let o=this.options.waitUntilDebounceMs??Krd;this._waitUntilCycle.timer=Yue(()=>{this.resolveWaitUntilFlush()},o)}_consumeWaitUntilCycle(){let t=this._waitUntilCycle;return t&&(clearTimeout(t.timer),this._waitUntilCycle=void 0),t?.resolve}async resolveWaitUntilFlush(){let t=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{t?.()}}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):fetch(t,r)}getLibraryVersion(){return T6a}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._logger.warn("Called capture() with a string as the first argument when an object was expected."),t.event==="$exception"&&!t._originatedFromCaptureException&&this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:n,properties:i,options:o})=>super.captureStateless(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),t.event==="$exception"&&!t._originatedFromCaptureException&&this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:n,properties:i,options:o})=>super.captureStatelessImmediate(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStateless(t,l,{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStatelessImmediate(t,l,{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=Q6a){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",o=>{clearTimeout(n),i(),r(o>0)})})}_resolveDistinctId(t,r){return typeof t=="string"?{distinctId:t,options:r}:{distinctId:this.context?.get()?.distinctId,options:t}}async _getFeatureFlagResult(t,r,n={},i){let o=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let w=this._flagOverrides[t];if(w===void 0)return;let x=this._payloadOverrides?.[t];return{key:t,enabled:w!==!1,variant:typeof w=="string"?w:void 0,payload:x}}let{groups:s,disableGeoip:a}=n,{onlyEvaluateLocally:c,personProperties:u,groupProperties:l}=n,p=this.addLocalPersonAndGroupProperties(r,s,u,l);u=p.allPersonProperties,l=p.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(r,s,u,l);c==null&&(c=this.options.strictLocalEvaluation??!1);let f,m=!1,h,g,A,b,v,E;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let w=this.featureFlagsPoller?.featureFlagsByKey[t];if(w)try{let x=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(w,d,{matchValue:i});if(x){m=!0;let C=x.value;b=w.id,E="Evaluated locally",f={key:t,enabled:C!==!1,variant:typeof C=="string"?C:void 0,payload:x.payload??void 0}}}catch(x){if(x instanceof PX||x instanceof Yf)this._logger?.info(`${x.name} when computing flag locally: ${t}: ${x.message}`);else throw x}}if(!m&&!c){let w=await super.getFeatureFlagDetailsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,a,[t]);if(w===void 0)A=CDt.UNKNOWN_ERROR;else{h=w.requestId,g=w.evaluatedAt;let x=[];w.errorsWhileComputingFlags&&x.push(CDt.ERRORS_WHILE_COMPUTING),w.quotaLimited?.includes("feature_flags")&&x.push(CDt.QUOTA_LIMITED);let C=w.flags[t];if(C===void 0)x.push(CDt.FLAG_MISSING);else{b=C.metadata?.id,v=C.metadata?.version,E=C.reason?.description??C.reason?.code;let _;if(C.metadata?.payload!==void 0)try{_=JSON.parse(C.metadata.payload)}catch{_=C.metadata.payload}f={key:t,enabled:C.enabled,variant:C.variant,payload:_}}x.length>0&&(A=x.join(","))}}if(o){let w=f===void 0?void 0:f.enabled===!1?!1:f.variant??!0,x=`${t}_${w}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(x)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(x):this.distinctIdHasSentFlagCalls[r]=[x];let C={$feature_flag:t,$feature_flag_response:w,$feature_flag_id:b,$feature_flag_version:v,$feature_flag_reason:E,locally_evaluated:m,[`$feature/${t}`]:w,$feature_flag_request_id:h,$feature_flag_evaluated_at:m?Date.now():g};if(m&&this.featureFlagsPoller){let _=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();_!==void 0&&(C.$feature_flag_definitions_loaded_at=_)}A&&(C.$feature_flag_error=A),this.capture({distinctId:r,event:"$feature_flag_called",properties:C,groups:s,disableGeoip:a})}}return f!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(f={...f,payload:this._payloadOverrides[t]}),f}async getFeatureFlag(t,r,n){let i=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(i!==void 0)return i.enabled===!1?!1:i.variant??!0}async getFeatureFlagPayload(t,r,n,i){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let o=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:!1},n);if(o!==void 0)return o.payload??null}async getFeatureFlagResult(t,r,n){let{distinctId:i,options:o}=this._resolveDistinctId(r,n);return i?this._getFeatureFlagResult(t,i,{...o,sendFeatureFlagEvents:o?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn("[PostHog] distinctId is required \u2014 pass it explicitly or use withContext()")}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let n=await r.json();if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){let{distinctId:n,options:i}=this._resolveDistinctId(t,r);return n?(await this.getAllFlagsAndPayloads(n,i)).featureFlags||{}:(this._logger.warn("[PostHog] distinctId is required to get feature flags \u2014 pass it explicitly or use withContext()"),{})}async getAllFlagsAndPayloads(t,r){let{distinctId:n,options:i}=this._resolveDistinctId(t,r);if(!n)return this._logger.warn("[PostHog] distinctId is required to get feature flags and payloads \u2014 pass it explicitly or use withContext()"),{featureFlags:{},featureFlagPayloads:{}};let{groups:o,disableGeoip:s,flagKeys:a}=i||{},{onlyEvaluateLocally:c,personProperties:u,groupProperties:l}=i||{},p=this.addLocalPersonAndGroupProperties(n,o,u,l);u=p.allPersonProperties,l=p.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(n,o,u,l);c==null&&(c=this.options.strictLocalEvaluation??!1);let f=await this.featureFlagsPoller?.getAllFlagsAndPayloads(d,a),m={},h={},g=!0;if(f&&(m=f.response,h=f.payloads,g=f.fallbackToFlags),g&&!c){let A=await super.getFeatureFlagsAndPayloadsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,s,a);m={...m,...A.flags||{}},h={...h,...A.payloads||{}}}return this._flagOverrides!==void 0&&(m={...m,...this._flagOverrides}),this._payloadOverrides!==void 0&&(h={...h,...this._payloadOverrides}),{featureFlags:m,featureFlagPayloads:h}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:o}){super.groupIdentifyStateless(t,r,n,{disableGeoip:o},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=n=>Object.fromEntries(n.map(i=>[i,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let n=r.flags;if(n===!1||Array.isArray(n)||typeof n=="object"&&n!==null)return!0}if("payloads"in r){let n=r.payloads;if(n===!1||typeof n=="object"&&n!==null)return!0}return!1}withContext(t,r,n){return this.context?this.context.run(t,r,n):r()}getContext(){return this.context?.get()}enterContext(t,r){this.context?.enter(t,r)}async _shutdown(t){let r=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown();try{return await super._shutdown(t)}finally{r?.()}}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},i=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let o=new AbortController;i=Yue(()=>{o.abort()},this.options.requestTimeout),n.signal=o.signal}try{return await this.fetch(r,n)}catch(o){this._events.emit("error",o);return}finally{i&&clearTimeout(i)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let n={},i={};for(let[o,s]of Object.entries(t))if(qVa(s)&&r&&o in r){let a={};for(let[c,u]of Object.entries(s))a[String(c)]=String(u);i[String(o)]=a}else n[String(o)]=String(s);return{personProperties:n,groupProperties:i}}async getFeatureFlagsForEvent(t,r,n,i){let o=i?.personProperties||{},s=i?.groupProperties||{},a=i?.flagKeys;if(i?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let u={};for(let[l,p]of Object.entries(r||{}))u[l]=String(p);return await this.getAllFlags(t,{groups:u,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let u={};for(let[l,p]of Object.entries(r||{}))u[l]=String(p);return await this.getAllFlags(t,{groups:u,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}return(await super.getFeatureFlagsStateless(t,r,o,s,n)).flags}addLocalPersonAndGroupProperties(t,r,n,i){let o={distinct_id:t,...n||{}},s={};if(r)for(let a of Object.keys(r))s[a]={$group_key:r[a],...i?.[a]||{}};return{allPersonProperties:o,allGroupProperties:s}}createFeatureFlagEvaluationContext(t,r,n,i){return{distinctId:t,groups:r||{},personProperties:n||{},groupProperties:i||{},evaluationCache:{}}}captureException(t,r,n,i){if(!l9.isPreviouslyCapturedError(t)){let o=new Error("PostHog syntheticException");this.addPendingPromise(l9.buildEventMessage(t,{syntheticException:o},r,n).then(s=>this.capture({...s,uuid:i})))}}async captureExceptionImmediate(t,r,n){if(!l9.isPreviouslyCapturedError(t)){let i=new Error("PostHog syntheticException");return this.addPendingPromise(l9.buildEventMessage(t,{syntheticException:i},r,n).then(o=>this.captureImmediate(o)))}}async prepareEventMessage(t){let{distinctId:r,event:n,properties:i,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:c,uuid:u}=t,l=this.context?.get(),p=r||l?.distinctId,d={...this.props,...l?.properties||{},...i||{}};p||(p=Lbe(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:p,event:n,properties:d,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:c,uuid:u});if(!f)return Promise.reject(null);let m=await Promise.resolve().then(async()=>{if(s){let h=typeof s=="object"?s:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,o,c,h)}return f.event,{}}).then(h=>{let g={};if(h)for(let[b,v]of Object.entries(h))g[`$feature/${b}`]=v;let A=Object.keys(h||{}).filter(b=>h?.[b]!==!1).sort();return A.length>0&&(g.$active_feature_flags=A),g}).catch(()=>({})).then(h=>({...h,...f.properties||{},$groups:f.groups||o}));return f.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof m.$raw_user_agent=="string"&&MVa(m.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event="$bot_pageview",m.$browser_type="bot"),{distinctId:f.distinctId,event:f.event,properties:m,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let n=Array.isArray(r)?r:[r],i=t;for(let o of n){if(i=o(i),!i)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!i.properties||Object.keys(i.properties).length===0){let s=`Event '${i.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(s)}}return i}};var j6a=require("async_hooks"),kPr=class{constructor(){this.storage=new j6a.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,n){return this.storage.run(this.resolve(t,n),r)}enter(t,r){this.storage.enterWith(this.resolve(t,r))}resolve(t,r){if(r?.fresh===!0)return t;let n=this.get()||{};return{distinctId:t.distinctId??n.distinctId,sessionId:t.sessionId??n.sessionId,properties:{...n.properties||{},...t.properties||{}}}}};var M6a="posthog-node";function Yrd(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"],sendExceptionsToPostHog:o=!0}={}){return s=>{if(!(i==="*"||i.includes(s.level)))return s;s.tags||(s.tags={});let c=s.tags[Nzi.POSTHOG_ID_TAG];if(c===void 0)return s;let u=e.options.host??"https://us.i.posthog.com",l=new URL(`/project/${e.apiKey}/person/${c}`,u).toString();s.tags["PostHog Person URL"]=l;let p=s.exception?.values||[],d=p.map(m=>({...m,stacktrace:m.stacktrace?{...m.stacktrace,type:"raw",frames:(m.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),f={$exception_message:p[0]?.value||s.message,$exception_type:p[0]?.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:p[0]?.value||s.message,$sentry_exception_type:p[0]?.type,$sentry_tags:s.tags};return t&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+s.event_id),o&&e.capture({event:"$exception",distinctId:c,properties:f}),s}}var Nzi=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,n,i,o){this.name=M6a,this.name=M6a,this.setupOnce=function(s,a){let c=a()?.getClient()?.getDsn()?.projectId;s(Yrd(t,{organization:r,projectId:c,prefix:n,severityAllowList:i,sendExceptionsToPostHog:o??!0}))}}};l9.errorPropertiesBuilder=new PN.ErrorPropertiesBuilder([new PN.EventCoercer,new PN.ErrorCoercer,new PN.ObjectCoercer,new PN.StringCoercer,new PN.PrimitiveCoercer],PN.createStackParser("node:javascript",PN.nodeStackLineParser),[kVa(),C6a]);var Ube=class extends FPr{getLibraryId(){return"posthog-node"}initializeContext(){return new kPr}};var NPr=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Ube(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"4.46.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xDt=class{async sendEvent(){}async identify(){}async flush(){}};qt();var iJe=require("fs/promises"),L6a=require("os"),U6a=require("path");var Xrd="id",Zrd=".fern",_Dt=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new Ube(r),this.userId=t==null?void 0:ZQi(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"4.46.2",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await vy({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=We(Ut.of((0,L6a.homedir)()),Se.of(Zrd),Se.of(Xrd));await er(t)||(await(0,iJe.mkdir)((0,U6a.dirname)(t),{recursive:!0}),await(0,iJe.writeFile)(t,Yx())),this.persistedDistinctId=(await(0,iJe.readFile)(t)).toString()}return this.persistedDistinctId}};var Qzi;async function oJe(){return Qzi==null&&(Qzi=await end()),Qzi}async function end(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xDt;let r=await Kxr();return r!=null?new _Dt({token:r,posthogApiKey:e}):await dX()!=null?new NPr({posthogApiKey:e}):new _Dt({token:void 0,posthogApiKey:e})}catch{return new xDt}}St();var SDt=ye(require("process"),1);var q6a=ye(KOi(),1),G6a=ye(V6a(),1);function m_(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=oue(e),e.length===0))return 0;e=e.replace((0,G6a.default)()," ");let r=t.ambiguousIsNarrow?1:2,n=0;for(let i of e){let o=i.codePointAt(0);if(o<=31||o>=127&&o<=159||o>=768&&o<=879)continue;switch(q6a.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function QPr(e){let t=0;for(let r of e.split(`
|
|
1665
|
+
`);for(let s=n;s<o.length;s++){let a=o[s];if(a.length>1024)continue;let c=m6a.test(a)?a.replace(m6a,"$1"):a;if(!c.match(/\S*Error: /)){for(let u of t){let l=u(c,e);if(l){i.push(l);break}}if(i.length>=h6a)break}}return g6a(i)}}var _zi=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let n=EDt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:n?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return mNe(t,"DOMException")}isDOMError(t){return mNe(t,"DOMError")}};var Szi=class{match(t){return mzi(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let n=t.message;return n.error&&typeof n.error.message=="string"?String(n.error.message):String(n)}getStack(t){return t.stacktrace||t.stack||void 0}};var Bzi=class{constructor(){}match(t){return VVa(t)&&t.error!=null}coerce(t,r){let n=r.apply(t.error);return n||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var xrd=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Tzi=class{match(t){return typeof t=="string"}coerce(t,r){let[n,i]=this.getInfos(t);return{type:n??"Error",value:i??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",n=t,i=t.match(xrd);return i&&(r=i[1],n=i[2]),[r,n]}};var y6a=["fatal","error","warning","log","info","debug"];function OPr(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let n=r.length;n>0;n--){let i=r.slice(0,n).join(", ");if(!(i.length>t))return n===r.length||i.length<=t?i:`${i.slice(0,t)}...`}return""}var Ozi=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let n=this.getErrorPropertyFromObject(t);return n?r.apply(n):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return ZKe(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let i=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(i+=` with message: '${t.message}'`),i}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),n=OPr(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${n}`}isSeverityLevel(t){return EDt(t)&&!UVa(t)&&y6a.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(n6a(n))return n}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var Pzi=class{match(t){return ZKe(t)}coerce(t,r){let n=t.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${OPr(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Dzi=class{match(t){return yPr(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Rzi=class{match(t){return mNe(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!ZKe(t))return!1;try{let r=t.detail;return r!=null&&typeof r=="object"&&"reason"in r}catch{return!1}}coerce(t,r){let n=this.getUnhandledRejectionReason(t);return yPr(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(n)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var Fzi=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)}}};var v6a=require("fs"),I6a=require("readline"),PPr=new PN.ReduceableCache(25),w6a=new PN.ReduceableCache(20),kzi=7,_rd=1e3,Srd=1e4;async function C6a(e){let t={};for(let i=e.length-1;i>=0;i--){let o=e[i],s=o?.filename;if(!o||typeof s!="string"||typeof o.lineno!="number"||Prd(s)||Drd(o))continue;t[s]||(t[s]=[]),t[s].push(o.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(w6a.get(i))continue;let o=t[i];if(!o)continue;o.sort((c,u)=>c-u);let s=Frd(o);if(s.every(c=>Rrd(i,c)))continue;let a=krd(PPr,i,{});n.push(Brd(i,s,a))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&Trd(e,PPr),PPr.reduce(),e}function Brd(e,t,r){return new Promise(n=>{let i=(0,v6a.createReadStream)(e),o=(0,I6a.createInterface)({input:i});function s(){i.destroy(),n()}let a=0,c=0,u=t[c];if(u===void 0)return void s();let l=u[0],p=u[1];function d(){w6a.set(e,1),o.close(),o.removeAllListeners(),s()}i.on("error",d),o.on("error",d),o.on("close",s),o.on("line",f=>{if(a++,!(a<l)&&(r[a]=Nrd(f,0),a>=p)){if(c===t.length-1){o.close(),o.removeAllListeners();return}c++;let m=t[c];if(m===void 0){o.close(),o.removeAllListeners();return}l=m[0],p=m[1]}})})}function Trd(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;Ord(r.lineno,r,n)}}function Ord(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=x6a(e);i<e;i++){let o=r[i];if(o===void 0)return void b6a(t);t.pre_context.push(o)}if(r[e]===void 0)return void b6a(t);t.context_line=r[e];let n=_6a(e);t.post_context=[];for(let i=e+1;i<=n;i++){let o=r[i];if(o===void 0)break;t.post_context.push(o)}}function b6a(e){delete e.pre_context,delete e.context_line,delete e.post_context}function Prd(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function Drd(e){return e.lineno!==void 0&&e.lineno>Srd||e.colno!==void 0&&e.colno>_rd}function Rrd(e,t){let r=PPr.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function Frd(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=E6a(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let o=e[t+1];if(typeof o!="number")break;o<=n[1]?n[1]=o+kzi:(i.push(n),n=E6a(o)),t++}return i}function E6a(e){return[x6a(e),_6a(e)]}function x6a(e){return Math.max(1,e-kzi)}function _6a(e){return e+kzi}function krd(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function Nrd(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let o=Math.min(i+140,n);return o>n-5&&(o=n),o===n&&(i=Math.max(o-140,0)),r=r.slice(i,o),i>0&&(r=`...${r}`),o<n&&(r+="..."),r}function Qrd(e,t){let r=!1;return Object.assign(n=>{let o=global.process.listeners("uncaughtException").filter(s=>s.name!=="domainUncaughtExceptionClear"&&s._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&o&&(r=!0,t(n))},{_posthogErrorHandler:!0})}function S6a(e,t){globalThis.process?.on("uncaughtException",Qrd(e,t))}function B6a(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var jrd=2e3,l9=class e{constructor(t,r,n){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new bPr({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return dzi(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,n,i){let o={...i},s=this.errorPropertiesBuilder.buildFromUnknown(t,r);return s.$exception_list=await this.errorPropertiesBuilder.modifyFrames(s.$exception_list),{event:"$exception",distinctId:n,properties:{...s,...o},_originatedFromCaptureException:!0}}startAutocaptureIfEnabled(){this.isEnabled()&&(S6a(this.onException.bind(this),this.onFatalError.bind(this)),B6a(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let n=await e.buildEventMessage(t,r),o=n.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(o)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:o}):this.client.capture(n)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(jrd),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var T6a="5.28.6";var CDt={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function O6a(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(i=>i.toString(16).padStart(2,"0")).join("")}var Mrd=6e4,Lrd=1152921504606847e3,Urd=["is_not"],nJe=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Yf=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},PX=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},DPr=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:o,customHeaders:s,...a}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=o,this.poller=void 0,this.fetch=a.fetch||fetch,this.onError=a.onError,this.customHeaders=s,this.onLoad=a.onLoad,this.cacheProvider=a.cacheProvider,this.strictLocalEvaluation=a.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}createEvaluationContext(t,r={},n={},i={},o={}){return{distinctId:t,groups:r,personProperties:n,groupProperties:i,evaluationCache:o}}async getFeatureFlag(t,r,n={},i={},o={}){await this.loadFeatureFlags();let s,a;if(!this.loadedSuccessfullyOnce)return s;if(a=this.featureFlagsByKey[t],a!==void 0){let c=this.createEvaluationContext(r,n,i,o);try{s=(await this.computeFlagAndPayloadLocally(a,c)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${s}`))}catch(u){u instanceof PX||u instanceof Yf?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${t}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${u}`))}}return s}async getAllFlagsAndPayloads(t,r){await this.loadFeatureFlags();let n={},i={},o=this.featureFlags.length==0,s=r?r.map(c=>this.featureFlagsByKey[c]).filter(Boolean):this.featureFlags,a={...t,evaluationCache:t.evaluationCache??{}};return await Promise.all(s.map(async c=>{try{let{value:u,payload:l}=await this.computeFlagAndPayloadLocally(c,a);n[c.key]=u,l&&(i[c.key]=l)}catch(u){u instanceof PX||u instanceof Yf?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${c.key}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${c.key}: ${u}`)),o=!0}})),{response:n,payloads:i,fallbackToFlags:o}}async computeFlagAndPayloadLocally(t,r,n={}){let{matchValue:i,skipLoadCheck:o=!1}=n;if(o||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=i!==void 0?i:await this.computeFlagValueLocally(t,r);let a=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:a}}async computeFlagValueLocally(t,r){let{distinctId:n,groups:i,personProperties:o,groupProperties:s}=r;if(t.ensure_experience_continuity)throw new Yf("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let u=this.groupTypeMapping[String(c)];if(!u)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new Yf("Flag has unknown group type index");if(!(u in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;t.bucketing_identifier==="device_id"&&(o?.$device_id===void 0||o?.$device_id===null||o?.$device_id==="")&&this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Ignoring bucketing_identifier for group flag: ${t.key}`));let l=s[u];return await this.matchFeatureFlagProperties(t,i[u],l,r)}{let u=this.getBucketingValueForFlag(t,n,o);if(u===void 0)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute feature flag: ${t.key} without $device_id, falling back to server evaluation`)),new Yf(`Can't compute feature flag: ${t.key} without $device_id`);return await this.matchFeatureFlagProperties(t,u,o,r)}}getBucketingValueForFlag(t,r,n){if(t.filters?.aggregation_group_type_index!=null)return r;if(t.bucketing_identifier==="device_id"){let i=n?.$device_id;return i==null||i===""?void 0:i}return r}getFeatureFlagPayload(t,r){let n=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),n!=null)){if(typeof n=="object")return n;if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(t,r,n){let{evaluationCache:i}=n,o=t.key;if(!this.featureFlagsByKey)throw new Yf("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new Yf(`Flag dependency property for '${o}' is missing required 'dependency_chain' field`);let s=t.dependency_chain;if(!Array.isArray(s))throw new Yf(`Flag dependency property for '${o}' has an invalid 'dependency_chain' (expected array, got ${typeof s})`);if(s.length===0)throw new Yf(`Circular dependency detected for flag '${o}' (empty dependency chain)`);for(let c of s){if(!(c in i)){let l=this.featureFlagsByKey[c];if(l)if(l.active)try{let p=await this.computeFlagValueLocally(l,n);i[c]=p}catch(p){throw new Yf(`Error evaluating flag dependency '${c}' for flag '${o}': ${p}`)}else i[c]=!1;else throw new Yf(`Missing flag dependency '${c}' for flag '${o}'`)}if(i[c]==null)throw new Yf(`Dependency '${c}' could not be evaluated`)}let a=i[o];return this.flagEvaluatesToExpectedValue(t.value,a)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,n,i){let o=t.filters||{},s=o.groups||[],a=!1,c;for(let u of s)try{if(await this.isConditionMatch(t,r,u,n,i)){let l=u.variant,p=o.multivariate?.variants||[];c=l&&p.some(d=>d.key===l)?l:await this.getMatchingVariant(t,r)||!0;break}}catch(l){if(l instanceof PX)throw l;if(l instanceof Yf)a=!0;else throw l}if(c!==void 0)return c;if(a)throw new Yf("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i,o){let s=n.rollout_percentage,a=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let u=c.type,l=!1;if(l=u==="cohort"?k6a(c,i,this.cohorts,this.debugMode):u==="flag"?await this.evaluateFlagDependency(c,i,o):F6a(c,i,a),!l)return!1}if(s==null)return!0}return!(s!=null&&await P6a(t.key,r)>s/100)}async getMatchingVariant(t,r){let n=await P6a(t.key,r,"variant"),i=this.variantLookupTable(t).find(o=>n>=o.valueMin&&n<o.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(a=>{i=n+a.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:a.key}),n=i}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,n)=>(r[n.key]=n,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(n=>n.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(n=>n.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getFlagDefinitionsLoadedAt(){return this.flagDefinitionsLoadedAt}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(Mrd,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(n){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${n}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new nJe(`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.beginBackoff(),new nJe(`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.beginBackoff(),new nJe(`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 n=await r.json()??{};if(!("flags"in n))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let i={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(i),this.flagDefinitionsLoadedAt=Date.now(),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(i)}catch(o){this.onError?.(new Error(`Failed to store in cache: ${o}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(i.flags);break}default:return}}catch(t){t instanceof nJe&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let n={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(n["If-None-Match"]=r),{method:t,headers:n}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Yue(()=>{i.abort()},this.timeout),r.signal=i.signal}try{let i=this.fetch;return i(t,r)}finally{clearTimeout(n)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((n,i)=>setTimeout(()=>i(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function P6a(e,t,r=""){let n=await O6a(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/Lrd}function F6a(e,t,r){let n=e.key,i=e.value,o=e.operator||"exact";if(n in t){if(o==="is_not_set")throw new Yf("Operator is_not_set is not supported")}else throw new Yf(`Property ${n} not found in propertyValues`);let s=t[n];if(s==null&&!Urd.includes(o))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${o} operator`),!1;function a(u,l){return Array.isArray(u)?u.map(p=>String(p).toLowerCase()).includes(String(l).toLowerCase()):String(u).toLowerCase()===String(l).toLowerCase()}function c(u,l,p){if(p==="gt")return u>l;if(p==="gte")return u>=l;if(p==="lt")return u<l;if(p==="lte")return u<=l;throw new Error(`Invalid operator: ${p}`)}switch(o){case"exact":return a(i,s);case"is_not":return!a(i,s);case"is_set":return n in t;case"icontains":return String(s).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(s).toLowerCase().includes(String(i).toLowerCase());case"regex":return D6a(String(i))&&String(s).match(String(i))!==null;case"not_regex":return D6a(String(i))&&String(s).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u==null||s==null?c(String(s),String(i),o):typeof s=="string"?c(s,String(i),o):c(s,u,o)}case"is_date_after":case"is_date_before":{if(typeof i=="boolean")throw new Yf("Date operations cannot be performed on boolean values");let u=Wrd(String(i));if(u==null&&(u=R6a(i)),u==null)throw new Yf(`Invalid date: ${i}`);let l=R6a(s);return["is_date_before"].includes(o)?l<u:l>u}case"semver_eq":return Z3(H1(String(s)),H1(String(i)))===0;case"semver_neq":return Z3(H1(String(s)),H1(String(i)))!==0;case"semver_gt":return Z3(H1(String(s)),H1(String(i)))>0;case"semver_gte":return Z3(H1(String(s)),H1(String(i)))>=0;case"semver_lt":return Z3(H1(String(s)),H1(String(i)))<0;case"semver_lte":return Z3(H1(String(s)),H1(String(i)))<=0;case"semver_tilde":{let u=H1(String(s)),{lower:l,upper:p}=Vrd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}case"semver_caret":{let u=H1(String(s)),{lower:l,upper:p}=qrd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}case"semver_wildcard":{let u=H1(String(s)),{lower:l,upper:p}=Grd(String(i));return Z3(u,l)>=0&&Z3(u,p)<0}default:throw new Yf(`Unknown operator: ${o}`)}}function zrd(e,t){if(!(e in t))throw new PX(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function k6a(e,t,r,n=!1){let i=String(e.value);zrd(i,r);let o=r[i];return N6a(o,t,r,n)}function N6a(e,t,r,n=!1){if(!e)return!0;let i=e.type,o=e.values;if(!o||o.length===0)return!0;let s=!1;if("values"in o[0]){for(let a of o)try{let c=N6a(a,t,r,n);if(i==="AND"){if(!c)return!1}else if(c)return!0}catch(c){if(c instanceof PX)throw c;if(c instanceof Yf)n&&console.debug(`Failed to compute property ${a} locally: ${c}`),s=!0;else throw c}if(s)throw new Yf("Can't match cohort without a given cohort property value");return i==="AND"}for(let a of o)try{let c;if(a.type==="cohort")c=k6a(a,t,r,n);else if(a.type==="flag"){n&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${a.key||"unknown"}'`);continue}else c=F6a(a,t);let u=a.negation||!1;if(i==="AND"){if(!c&&!u||c&&u)return!1}else if(c&&!u||!c&&u)return!0}catch(c){if(c instanceof PX)throw c;if(c instanceof Yf)n&&console.debug(`Failed to compute property ${a} locally: ${c}`),s=!0;else throw c}if(s)throw new Yf("can't match cohort without a given cohort property value");return i==="AND"}function D6a(e){try{return new RegExp(e),!0}catch{return!1}}function H1(e){let r=String(e).trim().replace(/^[vV]/,"").split("-")[0].split("+")[0];if(!r||r.startsWith("."))throw new Yf(`Invalid semver: ${e}`);let n=r.split("."),i=c=>{if(c===void 0||c==="")return 0;if(!/^\d+$/.test(c))throw new Yf(`Invalid semver: ${e}`);return parseInt(c,10)},o=i(n[0]),s=i(n[1]),a=i(n[2]);return[o,s,a]}function Z3(e,t){for(let r=0;r<3;r++){if(e[r]<t[r])return-1;if(e[r]>t[r])return 1}return 0}function Vrd(e){let t=H1(e),r=[t[0],t[1],t[2]],n=[t[0],t[1]+1,0];return{lower:r,upper:n}}function qrd(e){let t=H1(e),[r,n,i]=t,o=[r,n,i],s;return s=r>0?[r+1,0,0]:n>0?[0,n+1,0]:[0,0,i+1],{lower:o,upper:s}}function Grd(e){let r=String(e).trim().replace(/^[vV]/,"").replace(/\.\*$/,"").replace(/\*$/,"");if(!r)throw new Yf(`Invalid wildcard semver: ${e}`);let n=r.split("."),i=parseInt(n[0],10);if(isNaN(i))throw new Yf(`Invalid wildcard semver: ${e}`);let o,s;if(n.length===1)o=[i,0,0],s=[i+1,0,0];else{let a=parseInt(n[1],10);if(isNaN(a))throw new Yf(`Invalid wildcard semver: ${e}`);o=[i,a,0],s=[i,a+1,0]}return{lower:o,upper:s}}function R6a(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 Yf(`${e} is in an invalid date format`)}throw new Yf(`The date provided ${e} must be a string, number, or date object`)}function Wrd(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let o=r.groups.interval;if(o=="h")n.setUTCHours(n.getUTCHours()-i);else if(o=="d")n.setUTCDate(n.getUTCDate()-i);else if(o=="w")n.setUTCDate(n.getUTCDate()-7*i);else if(o=="m")n.setUTCMonth(n.getUTCMonth()-i);else{if(o!="y")return null;n.setUTCFullYear(n.getUTCFullYear()-i)}return n}}var RPr=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var $rd=100,Q6a=3e4,Hrd=5e4,Krd=50,Jrd=500,FPr=class extends wDt{constructor(t,r={}){if(super(t,r),this._memoryStorage=new RPr,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,$rd):Q6a,typeof r.waitUntilDebounceMs=="number"&&(this.options.waitUntilDebounceMs=Math.max(r.waitUntilDebounceMs,0)),typeof r.waitUntilMaxWaitMs=="number"&&(this.options.waitUntilMaxWaitMs=Math.max(r.waitUntilMaxWaitMs,0)),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.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new DPr({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(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new l9(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||Hrd}enqueue(t,r,n){super.enqueue(t,r,n),this.scheduleDebouncedFlush()}async flush(){let t=super.flush(),r=this.options.waitUntil;if(r&&!this._waitUntilCycle)try{r(t.catch(()=>{}))}catch{}return t}scheduleDebouncedFlush(){let t=this.options.waitUntil;if(!t||this.disabled||this.optedOut)return;if(!this._waitUntilCycle){let s,a=new Promise(c=>{s=c});try{t(a)}catch{return}this._waitUntilCycle={resolve:s,startedAt:Date.now(),timer:void 0}}let r=Date.now()-this._waitUntilCycle.startedAt,n=this.options.waitUntilMaxWaitMs??Jrd,i=r>=n;if(this._waitUntilCycle.timer!==void 0&&clearTimeout(this._waitUntilCycle.timer),i)return void this.resolveWaitUntilFlush();let o=this.options.waitUntilDebounceMs??Krd;this._waitUntilCycle.timer=Yue(()=>{this.resolveWaitUntilFlush()},o)}_consumeWaitUntilCycle(){let t=this._waitUntilCycle;return t&&(clearTimeout(t.timer),this._waitUntilCycle=void 0),t?.resolve}async resolveWaitUntilFlush(){let t=this._consumeWaitUntilCycle();try{await super.flush()}catch{}finally{t?.()}}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):fetch(t,r)}getLibraryVersion(){return T6a}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._logger.warn("Called capture() with a string as the first argument when an object was expected."),t.event==="$exception"&&!t._originatedFromCaptureException&&this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:n,properties:i,options:o})=>super.captureStateless(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),t.event==="$exception"&&!t._originatedFromCaptureException&&this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:n,properties:i,options:o})=>super.captureStatelessImmediate(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStateless(t,l,{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStatelessImmediate(t,l,{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=Q6a){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",o=>{clearTimeout(n),i(),r(o>0)})})}_resolveDistinctId(t,r){return typeof t=="string"?{distinctId:t,options:r}:{distinctId:this.context?.get()?.distinctId,options:t}}async _getFeatureFlagResult(t,r,n={},i){let o=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let w=this._flagOverrides[t];if(w===void 0)return;let x=this._payloadOverrides?.[t];return{key:t,enabled:w!==!1,variant:typeof w=="string"?w:void 0,payload:x}}let{groups:s,disableGeoip:a}=n,{onlyEvaluateLocally:c,personProperties:u,groupProperties:l}=n,p=this.addLocalPersonAndGroupProperties(r,s,u,l);u=p.allPersonProperties,l=p.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(r,s,u,l);c==null&&(c=this.options.strictLocalEvaluation??!1);let f,m=!1,h,g,A,b,v,E;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let w=this.featureFlagsPoller?.featureFlagsByKey[t];if(w)try{let x=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(w,d,{matchValue:i});if(x){m=!0;let C=x.value;b=w.id,E="Evaluated locally",f={key:t,enabled:C!==!1,variant:typeof C=="string"?C:void 0,payload:x.payload??void 0}}}catch(x){if(x instanceof PX||x instanceof Yf)this._logger?.info(`${x.name} when computing flag locally: ${t}: ${x.message}`);else throw x}}if(!m&&!c){let w=await super.getFeatureFlagDetailsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,a,[t]);if(w===void 0)A=CDt.UNKNOWN_ERROR;else{h=w.requestId,g=w.evaluatedAt;let x=[];w.errorsWhileComputingFlags&&x.push(CDt.ERRORS_WHILE_COMPUTING),w.quotaLimited?.includes("feature_flags")&&x.push(CDt.QUOTA_LIMITED);let C=w.flags[t];if(C===void 0)x.push(CDt.FLAG_MISSING);else{b=C.metadata?.id,v=C.metadata?.version,E=C.reason?.description??C.reason?.code;let _;if(C.metadata?.payload!==void 0)try{_=JSON.parse(C.metadata.payload)}catch{_=C.metadata.payload}f={key:t,enabled:C.enabled,variant:C.variant,payload:_}}x.length>0&&(A=x.join(","))}}if(o){let w=f===void 0?void 0:f.enabled===!1?!1:f.variant??!0,x=`${t}_${w}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(x)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(x):this.distinctIdHasSentFlagCalls[r]=[x];let C={$feature_flag:t,$feature_flag_response:w,$feature_flag_id:b,$feature_flag_version:v,$feature_flag_reason:E,locally_evaluated:m,[`$feature/${t}`]:w,$feature_flag_request_id:h,$feature_flag_evaluated_at:m?Date.now():g};if(m&&this.featureFlagsPoller){let _=this.featureFlagsPoller.getFlagDefinitionsLoadedAt();_!==void 0&&(C.$feature_flag_definitions_loaded_at=_)}A&&(C.$feature_flag_error=A),this.capture({distinctId:r,event:"$feature_flag_called",properties:C,groups:s,disableGeoip:a})}}return f!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(f={...f,payload:this._payloadOverrides[t]}),f}async getFeatureFlag(t,r,n){let i=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(i!==void 0)return i.enabled===!1?!1:i.variant??!0}async getFeatureFlagPayload(t,r,n,i){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let o=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:!1},n);if(o!==void 0)return o.payload??null}async getFeatureFlagResult(t,r,n){let{distinctId:i,options:o}=this._resolveDistinctId(r,n);return i?this._getFeatureFlagResult(t,i,{...o,sendFeatureFlagEvents:o?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0}):void this._logger.warn("[PostHog] distinctId is required \u2014 pass it explicitly or use withContext()")}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let n=await r.json();if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){let{distinctId:n,options:i}=this._resolveDistinctId(t,r);return n?(await this.getAllFlagsAndPayloads(n,i)).featureFlags||{}:(this._logger.warn("[PostHog] distinctId is required to get feature flags \u2014 pass it explicitly or use withContext()"),{})}async getAllFlagsAndPayloads(t,r){let{distinctId:n,options:i}=this._resolveDistinctId(t,r);if(!n)return this._logger.warn("[PostHog] distinctId is required to get feature flags and payloads \u2014 pass it explicitly or use withContext()"),{featureFlags:{},featureFlagPayloads:{}};let{groups:o,disableGeoip:s,flagKeys:a}=i||{},{onlyEvaluateLocally:c,personProperties:u,groupProperties:l}=i||{},p=this.addLocalPersonAndGroupProperties(n,o,u,l);u=p.allPersonProperties,l=p.allGroupProperties;let d=this.createFeatureFlagEvaluationContext(n,o,u,l);c==null&&(c=this.options.strictLocalEvaluation??!1);let f=await this.featureFlagsPoller?.getAllFlagsAndPayloads(d,a),m={},h={},g=!0;if(f&&(m=f.response,h=f.payloads,g=f.fallbackToFlags),g&&!c){let A=await super.getFeatureFlagsAndPayloadsStateless(d.distinctId,d.groups,d.personProperties,d.groupProperties,s,a);m={...m,...A.flags||{}},h={...h,...A.payloads||{}}}return this._flagOverrides!==void 0&&(m={...m,...this._flagOverrides}),this._payloadOverrides!==void 0&&(h={...h,...this._payloadOverrides}),{featureFlags:m,featureFlagPayloads:h}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:o}){super.groupIdentifyStateless(t,r,n,{disableGeoip:o},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=n=>Object.fromEntries(n.map(i=>[i,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let n=r.flags;if(n===!1||Array.isArray(n)||typeof n=="object"&&n!==null)return!0}if("payloads"in r){let n=r.payloads;if(n===!1||typeof n=="object"&&n!==null)return!0}return!1}withContext(t,r,n){return this.context?this.context.run(t,r,n):r()}getContext(){return this.context?.get()}enterContext(t,r){this.context?.enter(t,r)}async _shutdown(t){let r=this._consumeWaitUntilCycle();await this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown();try{return await super._shutdown(t)}finally{r?.()}}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},i=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let o=new AbortController;i=Yue(()=>{o.abort()},this.options.requestTimeout),n.signal=o.signal}try{return await this.fetch(r,n)}catch(o){this._events.emit("error",o);return}finally{i&&clearTimeout(i)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let n={},i={};for(let[o,s]of Object.entries(t))if(qVa(s)&&r&&o in r){let a={};for(let[c,u]of Object.entries(s))a[String(c)]=String(u);i[String(o)]=a}else n[String(o)]=String(s);return{personProperties:n,groupProperties:i}}async getFeatureFlagsForEvent(t,r,n,i){let o=i?.personProperties||{},s=i?.groupProperties||{},a=i?.flagKeys;if(i?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let u={};for(let[l,p]of Object.entries(r||{}))u[l]=String(p);return await this.getAllFlags(t,{groups:u,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let u={};for(let[l,p]of Object.entries(r||{}))u[l]=String(p);return await this.getAllFlags(t,{groups:u,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}return(await super.getFeatureFlagsStateless(t,r,o,s,n)).flags}addLocalPersonAndGroupProperties(t,r,n,i){let o={distinct_id:t,...n||{}},s={};if(r)for(let a of Object.keys(r))s[a]={$group_key:r[a],...i?.[a]||{}};return{allPersonProperties:o,allGroupProperties:s}}createFeatureFlagEvaluationContext(t,r,n,i){return{distinctId:t,groups:r||{},personProperties:n||{},groupProperties:i||{},evaluationCache:{}}}captureException(t,r,n,i){if(!l9.isPreviouslyCapturedError(t)){let o=new Error("PostHog syntheticException");this.addPendingPromise(l9.buildEventMessage(t,{syntheticException:o},r,n).then(s=>this.capture({...s,uuid:i})))}}async captureExceptionImmediate(t,r,n){if(!l9.isPreviouslyCapturedError(t)){let i=new Error("PostHog syntheticException");return this.addPendingPromise(l9.buildEventMessage(t,{syntheticException:i},r,n).then(o=>this.captureImmediate(o)))}}async prepareEventMessage(t){let{distinctId:r,event:n,properties:i,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:c,uuid:u}=t,l=this.context?.get(),p=r||l?.distinctId,d={...this.props,...l?.properties||{},...i||{}};p||(p=Lbe(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:p,event:n,properties:d,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:c,uuid:u});if(!f)return Promise.reject(null);let m=await Promise.resolve().then(async()=>{if(s){let h=typeof s=="object"?s:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,o,c,h)}return f.event,{}}).then(h=>{let g={};if(h)for(let[b,v]of Object.entries(h))g[`$feature/${b}`]=v;let A=Object.keys(h||{}).filter(b=>h?.[b]!==!1).sort();return A.length>0&&(g.$active_feature_flags=A),g}).catch(()=>({})).then(h=>({...h,...f.properties||{},$groups:f.groups||o}));return f.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof m.$raw_user_agent=="string"&&MVa(m.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event="$bot_pageview",m.$browser_type="bot"),{distinctId:f.distinctId,event:f.event,properties:m,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let n=Array.isArray(r)?r:[r],i=t;for(let o of n){if(i=o(i),!i)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!i.properties||Object.keys(i.properties).length===0){let s=`Event '${i.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(s)}}return i}};var j6a=require("async_hooks"),kPr=class{constructor(){this.storage=new j6a.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,n){return this.storage.run(this.resolve(t,n),r)}enter(t,r){this.storage.enterWith(this.resolve(t,r))}resolve(t,r){if(r?.fresh===!0)return t;let n=this.get()||{};return{distinctId:t.distinctId??n.distinctId,sessionId:t.sessionId??n.sessionId,properties:{...n.properties||{},...t.properties||{}}}}};var M6a="posthog-node";function Yrd(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"],sendExceptionsToPostHog:o=!0}={}){return s=>{if(!(i==="*"||i.includes(s.level)))return s;s.tags||(s.tags={});let c=s.tags[Nzi.POSTHOG_ID_TAG];if(c===void 0)return s;let u=e.options.host??"https://us.i.posthog.com",l=new URL(`/project/${e.apiKey}/person/${c}`,u).toString();s.tags["PostHog Person URL"]=l;let p=s.exception?.values||[],d=p.map(m=>({...m,stacktrace:m.stacktrace?{...m.stacktrace,type:"raw",frames:(m.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),f={$exception_message:p[0]?.value||s.message,$exception_type:p[0]?.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:p[0]?.value||s.message,$sentry_exception_type:p[0]?.type,$sentry_tags:s.tags};return t&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+s.event_id),o&&e.capture({event:"$exception",distinctId:c,properties:f}),s}}var Nzi=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,n,i,o){this.name=M6a,this.name=M6a,this.setupOnce=function(s,a){let c=a()?.getClient()?.getDsn()?.projectId;s(Yrd(t,{organization:r,projectId:c,prefix:n,severityAllowList:i,sendExceptionsToPostHog:o??!0}))}}};l9.errorPropertiesBuilder=new PN.ErrorPropertiesBuilder([new PN.EventCoercer,new PN.ErrorCoercer,new PN.ObjectCoercer,new PN.StringCoercer,new PN.PrimitiveCoercer],PN.createStackParser("node:javascript",PN.nodeStackLineParser),[kVa(),C6a]);var Ube=class extends FPr{getLibraryId(){return"posthog-node"}initializeContext(){return new kPr}};var NPr=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Ube(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"4.46.3",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xDt=class{async sendEvent(){}async identify(){}async flush(){}};qt();var iJe=require("fs/promises"),L6a=require("os"),U6a=require("path");var Xrd="id",Zrd=".fern",_Dt=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new Ube(r),this.userId=t==null?void 0:ZQi(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"4.46.3",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await vy({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=We(Ut.of((0,L6a.homedir)()),Se.of(Zrd),Se.of(Xrd));await er(t)||(await(0,iJe.mkdir)((0,U6a.dirname)(t),{recursive:!0}),await(0,iJe.writeFile)(t,Yx())),this.persistedDistinctId=(await(0,iJe.readFile)(t)).toString()}return this.persistedDistinctId}};var Qzi;async function oJe(){return Qzi==null&&(Qzi=await end()),Qzi}async function end(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xDt;let r=await Kxr();return r!=null?new _Dt({token:r,posthogApiKey:e}):await dX()!=null?new NPr({posthogApiKey:e}):new _Dt({token:void 0,posthogApiKey:e})}catch{return new xDt}}St();var SDt=ye(require("process"),1);var q6a=ye(KOi(),1),G6a=ye(V6a(),1);function m_(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=oue(e),e.length===0))return 0;e=e.replace((0,G6a.default)()," ");let r=t.ambiguousIsNarrow?1:2,n=0;for(let i of e){let o=i.codePointAt(0);if(o<=31||o>=127&&o<=159||o>=768&&o<=879)continue;switch(q6a.default.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=r;break;default:n+=1}}return n}function QPr(e){let t=0;for(let r of e.split(`
|
|
1666
1666
|
`))t=Math.max(t,m_(r));return t}var pqa=ye(Mzi(),1);var rnd=/[\p{Lu}]/u,nnd=/[\p{Ll}]/u,H6a=/^[\p{Lu}](?![\p{Lu}])/gu,Y6a=/([\p{Alpha}\p{N}_]|$)/u,Lzi=/[_.\- ]+/,ind=new RegExp("^"+Lzi.source),K6a=new RegExp(Lzi.source+Y6a.source,"gu"),J6a=new RegExp("\\d+"+Y6a.source,"gu"),ond=(e,t,r,n)=>{let i=!1,o=!1,s=!1,a=!1;for(let c=0;c<e.length;c++){let u=e[c];a=c>2?e[c-3]==="-":!0,i&&rnd.test(u)?(e=e.slice(0,c)+"-"+e.slice(c),i=!1,s=o,o=!0,c++):o&&s&&nnd.test(u)&&(!a||n)?(e=e.slice(0,c-1)+"-"+e.slice(c-1),s=o,o=!1,i=!0):(i=t(u)===u&&r(u)!==u,s=o,o=r(u)===u&&t(u)!==u)}return e},snd=(e,t)=>(H6a.lastIndex=0,e.replace(H6a,r=>t(r))),and=(e,t)=>(K6a.lastIndex=0,J6a.lastIndex=0,e.replace(K6a,(r,n)=>t(n)).replace(J6a,r=>t(r)));function Uzi(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(o=>o.trim()).filter(o=>o.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?o=>o.toLowerCase():o=>o.toLocaleLowerCase(t.locale),n=t.locale===!1?o=>o.toUpperCase():o=>o.toLocaleUpperCase(t.locale);return e.length===1?Lzi.test(e)?"":t.pascalCase?n(e):r(e):(e!==r(e)&&(e=ond(e,r,n,t.preserveConsecutiveUppercase)),e=e.replace(ind,""),e=t.preserveConsecutiveUppercase?snd(e,r):r(e),t.pascalCase&&(e=n(e.charAt(0))+e.slice(1)),and(e,n))}var Gzi=ye(Z6a(),1);var eqa=(e=0)=>t=>`\x1B[${t+e}m`,tqa=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,rqa=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`,bb={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},kqb=Object.keys(bb.modifier),pnd=Object.keys(bb.color),fnd=Object.keys(bb.bgColor),Nqb=[...pnd,...fnd];function dnd(){let e=new Map;for(let[t,r]of Object.entries(bb)){for(let[n,i]of Object.entries(r))bb[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=bb[n],e.set(i[0],i[1]);Object.defineProperty(bb,t,{value:r,enumerable:!1})}return Object.defineProperty(bb,"codes",{value:e,enumerable:!1}),bb.color.close="\x1B[39m",bb.bgColor.close="\x1B[49m",bb.color.ansi=eqa(),bb.color.ansi256=tqa(),bb.color.ansi16m=rqa(),bb.bgColor.ansi=eqa(10),bb.bgColor.ansi256=tqa(10),bb.bgColor.ansi16m=rqa(10),Object.defineProperties(bb,{rgbToAnsi256:{value(t,r,n){return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:t=>bb.rgbToAnsi256(...bb.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,n,i;if(t>=232)r=((t-232)*10+8)/255,n=r,i=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,n)=>bb.ansi256ToAnsi(bb.rgbToAnsi256(t,r,n)),enumerable:!1},hexToAnsi:{value:t=>bb.ansi256ToAnsi(bb.hexToAnsi256(t)),enumerable:!1}}),bb}var mnd=dnd(),nqa=mnd;var jPr=new Set(["\x1B","\x9B"]),hnd=39,Vzi="\x07",sqa="[",gnd="]",aqa="m",qzi=`${gnd}8;;`,iqa=e=>`${jPr.values().next().value}${sqa}${e}${aqa}`,oqa=e=>`${jPr.values().next().value}${qzi}${e}${Vzi}`,And=e=>e.split(" ").map(t=>m_(t)),zzi=(e,t,r)=>{let n=[...t],i=!1,o=!1,s=m_(oue(e[e.length-1]));for(let[a,c]of n.entries()){let u=m_(c);if(s+u<=r?e[e.length-1]+=c:(e.push(c),s=0),jPr.has(c)&&(i=!0,o=n.slice(a+1).join("").startsWith(qzi)),i){o?c===Vzi&&(i=!1,o=!1):c===aqa&&(i=!1);continue}s+=u,s===r&&a<n.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ynd=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(m_(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},bnd=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",i,o,s=And(e),a=[""];for(let[u,l]of e.split(" ").entries()){r.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let p=m_(a[a.length-1]);if(u!==0&&(p>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),p=0),(p>0||r.trim===!1)&&(a[a.length-1]+=" ",p++)),r.hard&&s[u]>t){let d=t-p,f=1+Math.floor((s[u]-d-1)/t);Math.floor((s[u]-1)/t)<f&&a.push(""),zzi(a,l,t);continue}if(p+s[u]>t&&p>0&&s[u]>0){if(r.wordWrap===!1&&p<t){zzi(a,l,t);continue}a.push("")}if(p+s[u]>t&&r.wordWrap===!1){zzi(a,l,t);continue}a[a.length-1]+=l}r.trim!==!1&&(a=a.map(u=>ynd(u)));let c=[...a.join(`
|
|
1667
1667
|
`)];for(let[u,l]of c.entries()){if(n+=l,jPr.has(l)){let{groups:d}=new RegExp(`(?:\\${sqa}(?<code>\\d+)m|\\${qzi}(?<uri>.*)${Vzi})`).exec(c.slice(u).join(""))||{groups:{}};if(d.code!==void 0){let f=Number.parseFloat(d.code);i=f===hnd?void 0:f}else d.uri!==void 0&&(o=d.uri.length===0?void 0:d.uri)}let p=nqa.codes.get(Number(i));c[u+1]===`
|
|
1668
1668
|
`?(o&&(n+=oqa("")),i&&p&&(n+=iqa(p))):l===`
|
|
@@ -2201,7 +2201,7 @@ Hint: Values starting with "@" (such as scoped npm packages) must be wrapped in
|
|
|
2201
2201
|
Example: package-name: "@scope/package"`)}return{success:!1,warnings:[{type:"conflict",message:`Failed to parse generators.yml: ${o}`}]}}}checkDeprecatedFields(t,r){t.openapi!=null&&r.push({type:"deprecated",message:"The 'openapi' field is deprecated",suggestion:"Use 'api.specs' instead"}),t["openapi-overrides"]!=null&&r.push({type:"deprecated",message:"The 'openapi-overrides' field is deprecated",suggestion:"Use 'api.specs.[].overrides' instead"}),t["spec-origin"]!=null&&r.push({type:"deprecated",message:"The 'spec-origin' field is deprecated",suggestion:"Use 'api.specs.[].origin' instead"}),t["async-api"]!=null&&r.push({type:"deprecated",message:"The 'async-api' field is deprecated",suggestion:"Use 'api.specs' with asyncapi instead"}),t["api-settings"]!=null&&r.push({type:"deprecated",message:"The 'api-settings' field is deprecated",suggestion:"Use 'api.specs.[].settings' instead"}),t.whitelabel!=null&&r.push({type:"unsupported",message:"Whitelabel configuration is not yet supported in fern.yml"}),t.metadata!=null&&r.push({type:"unsupported",message:"Metadata configuration is not yet supported in fern.yml"}),t.reviewers!=null&&r.push({type:"unsupported",message:"Reviewers configuration is not yet supported in fern.yml"}),t.aliases!=null&&r.push({type:"unsupported",message:"Group aliases are not yet supported in fern.yml",suggestion:"Use multiple group names in target.group array instead"}),t["auth-schemes"]!=null&&r.push({type:"info",message:"Auth schemes configuration detected but not yet migrated",suggestion:"Auth schemes will be supported in a future version"})}async getAbsoluteFilePath(){let t=We(this.cwd,Se.of(_m)),r=We(this.cwd,Se.of(F8e));if(await er(t,"file"))return t;if(await er(r,"file"))return r}};var QQt=class{cwd;logger;deleteOriginals;constructor(t){this.cwd=t.cwd,this.logger=t.logger,this.deleteOriginals=t.deleteOriginals??!0}async migrate(){let t=[],r=[],n=await this.findFernDirectory();if(n==null)return{success:!1,warnings:[{type:"conflict",message:"Could not find fern directory",suggestion:"Run this command from a directory containing a 'fern' folder"}],migratedFiles:r};let o=await new NQt({cwd:n}).migrate();if(t.push(...o.warnings),!o.success||o.org==null)return{success:!1,warnings:[...t,{type:"conflict",message:"Failed to migrate fern.config.json - organization is required"}],migratedFiles:r};o.absoluteFilePath!=null&&r.push(o.absoluteFilePath);let s=We(n,Se.of(VP)),a=await er(s,"directory"),c;if(a){let p=await this.migrateMultiApi({fernDir:n,apisDir:s,org:o.org,warnings:t,migratedFiles:r});if(!p.success)return{success:!1,warnings:t,migratedFiles:r};c=p.fernYml}else{let p=await this.migrateSingleApi({fernDir:n,org:o.org,warnings:t,migratedFiles:r});if(!p.success)return{success:!1,warnings:t,migratedFiles:r};c=p.fernYml}let u=We(this.cwd,Se.of(Qv)),l=this.serializeFernYml(c);if(await(0,Blt.writeFile)(u,l,"utf-8"),this.deleteOriginals)for(let p of r)try{await(0,Blt.rm)(p),this.logger.debug(`Deleted ${p}`)}catch{t.push({type:"info",message:`Could not delete ${p}`})}return this.logger.info(`Created ${u}`),{success:!0,warnings:t,migratedFiles:r,outputPath:u}}async migrateSingleApi(t){let{fernDir:r,org:n,warnings:i,migratedFiles:o}=t,a=await new XQe({cwd:r}).migrate();i.push(...a.warnings),a.absoluteFilePath!=null&&o.push(a.absoluteFilePath);let c=await hso({fernDir:r,generatorsYmlApi:a.rawApi});i.push(...c.warnings);let u={org:n};return c.api!=null&&(u.api=c.api),a.sdks!=null&&(u.sdks=a.sdks),{success:!0,fernYml:u}}async migrateMultiApi(t){let{fernDir:r,apisDir:n,org:i,warnings:o,migratedFiles:s}=t,c=(await(0,Blt.readdir)(n,{withFileTypes:!0})).filter(A=>A.isDirectory()).map(A=>A.name);if(c.length===0)return o.push({type:"conflict",message:"No API directories found in fern/apis/"}),{success:!1,fernYml:{org:i}};let u={},l={targets:{}},p,d;for(let A of c){let b=We(n,Se.of(A)),E=await new XQe({cwd:b,apiName:A}).migrate();if(o.push(...E.warnings),E.absoluteFilePath!=null&&s.push(E.absoluteFilePath),u[A]=E.rawApi,E.sdks!=null){for(let[I,w]of Object.entries(E.sdks.targets))l.targets[I]=w;E.sdks.defaultGroup!=null&&p==null&&(p=E.sdks.defaultGroup),E.sdks.autorelease!=null&&d==null&&(d=E.sdks.autorelease)}}let f=await gso({fernDir:r,apisDir:n,generatorsYmlApis:u});o.push(...f.warnings);let m={org:i,apis:f.apis};Object.keys(l.targets).length>0&&(p!=null&&(l.defaultGroup=p),d!=null&&(l.autorelease=d),m.sdks=l);let g=await new XQe({cwd:r}).detect();return g.found&&g.absoluteFilePath!=null&&(o.push({type:"info",message:"Found generators.yml in fern root alongside apis/ directory",suggestion:"Review the migrated configuration to ensure it's correct"}),s.push(g.absoluteFilePath)),{success:!0,fernYml:m}}async findFernDirectory(){if(this.cwd.split("/").pop()===Fg)return this.cwd;let r=We(this.cwd,Se.of(Fg));if(await er(r,"directory"))return r}serializeFernYml(t){let r={edition:t.edition,org:t.org};return t.api!=null&&(r.api=t.api),t.apis!=null&&(r.apis=t.apis),t.ai!=null&&(r.ai=t.ai),t.cli!=null&&(r.cli=t.cli),t.sdks!=null&&(r.sdks=this.simplifySdks(t.sdks)),_r.dump(r,{indent:2,lineWidth:120,noRefs:!0,sortKeys:!1,quotingType:'"',forceQuotes:!1})}simplifySdks(t){let r={...t},n={};for(let[i,o]of Object.entries(t.targets)){let s=o.output;if(typeof s=="string"){n[i]=o;continue}if(s.git==null&&s.path!=null){n[i]={...o,output:s.path};continue}n[i]=o}return r.targets=n,r}};var Aso=class{async handle(t,r){let i=await new QQt({cwd:t.cwd,logger:t.stdout,deleteOriginals:r.delete}).migrate();for(let o of i.warnings){switch(o.type){case"deprecated":t.stdout.warn(`Deprecated: ${o.message}`);break;case"unsupported":t.stdout.warn(`Unsupported: ${o.message}`);break;case"conflict":t.stderr.error(`Error: ${o.message}`);break;case"info":t.stdout.info(o.message);break}o.suggestion!=null&&t.stdout.info(` Suggestion: ${o.suggestion}`)}if(i.success){i.outputPath!=null&&t.stdout.debug(`Created: ${i.outputPath}`);return}throw new Yr({message:"Migration failed"})}};function yso(e){let t=new Aso;Ra(e,"migrate","Migrate legacy configuration files to fern.yml",(r,n)=>t.handle(r,n),r=>r.option("delete",{type:"boolean",description:"Keep original files after migration",default:!0}))}function bso(e){QB(e,"config","Configure, edit, and inspect your settings",[yso])}var Eso=class{async handle(t,r){let n=await t.loadWorkspaceOrThrow();if(n.docs==null)throw new Yr({message:`No docs configuration found in fern.yml.
|
|
2202
2202
|
|
|
2203
2203
|
Add a 'docs:' section to your fern.yml to get started.`});let o=await new L_e({context:t}).check({workspace:n,strict:r.strict}),s=o.hasErrors||r.strict&&o.hasWarnings;if(r.json){let a=this.buildJsonResponse({result:o,hasErrors:s});if(t.stdout.info(JSON.stringify(a,null,2)),s)throw Yr.exit();return}if(o.violations.length>0)for(let a of o.violations){let c=a.severity==="warning"?ve.yellow:ve.red;process.stderr.write(`${c(`${a.displayRelativeFilepath}:${a.line}:${a.column}: ${a.message}`)}
|
|
2204
|
-
`)}if(s)throw Yr.exit();if(o.warningCount>0){t.stderr.info(`${bo.warning} ${ve.yellow(`Found ${o.warningCount} warnings`)}`),t.stderr.info(ve.dim(" Run 'fern docs check --strict' to treat warnings as errors"));return}t.stderr.info(`${bo.success} ${ve.green("All checks passed")}`)}buildJsonResponse({result:t,hasErrors:r}){let n={};return t.violations.length>0&&(n.docs=t.violations.map(i=>ZX(i))),{success:!r,results:n}}};function vso(e){let t=new Eso;Ra(e,"check","Validate docs configuration",(r,n)=>t.handle(r,n),r=>r.option("strict",{type:"boolean",description:"Treat warnings as errors",default:!1}).option("json",{type:"boolean",description:"Output results as JSON to stdout",default:!1}))}var aNc=ye(require("net"),1),cNc=ye(require("os"),1),cFn=class extends Error{constructor(t){super(`${t} is locked`)}},Tlt={old:new Set,young:new Set},Snm=1e3*15;var jQt,Bnm=()=>{let e=cNc.default.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let n of r)t.add(n.address);return t},oNc=e=>new Promise((t,r)=>{let n=aNc.default.createServer();n.unref(),n.on("error",r),n.listen(e,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),sNc=async(e,t)=>{if(e.host||e.port===0)return oNc(e);for(let r of t)try{await oNc({port:e.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return e.port},Tnm=function*(e){e&&(yield*e),yield 0};async function U_e(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let i=e.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let o of i){if(typeof o!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(o))throw new TypeError(`Number ${o} in the exclude option is not a safe integer and can't be used`)}r=new Set(i)}jQt===void 0&&(jQt=setTimeout(()=>{jQt=void 0,Tlt.old=Tlt.young,Tlt.young=new Set},Snm),jQt.unref&&jQt.unref());let n=Bnm();for(let i of Tnm(t))try{if(r.has(i))continue;let o=await sNc({...e,port:i},n);for(;Tlt.old.has(o)||Tlt.young.has(o);){if(i!==0)throw new cFn(i);o=await sNc({...e,port:i},n)}return Tlt.young.add(o),o}catch(o){if(!["EADDRINUSE","EACCES"].includes(o.code)&&!(o instanceof cFn))throw o}throw new Error("No available ports found")}St();Vg();qt();var CVc=ye(Cso(),1),xVc=ye(HFn(),1),RNn=require("fs/promises"),_Vc=ye(require("http"),1),SVc=ye(require("path"),1);var sLc=require("events"),ZFn=ye(require("fs"),1),cje=ye(require("path"),1);var zMc=ye(require("os"),1),VMc=300,H_e=20,ujt=1e7,qMc=zMc.default.platform();var qlm=qMc==="darwin",Vao=qMc==="win32",K_e=qlm||Vao,GMc=3e3,WMc=2e4,qao=1250;var Cre;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(Cre||(Cre={}));var aje;(function(e){e.CHANGE="change",e.RENAME="rename"})(aje||(aje={}));var ljt;(function(e){e.CHANGE="change",e.ERROR="error"})(ljt||(ljt={}));var gc;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(gc||(gc={}));var $R;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})($R||($R={}));var Glm=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,o=Math.max(r?.maxWait??1/0,t),s,a,c=0,u=0,l=()=>{let E=Date.now(),I=E-c,w=E-u,x=I>=t||w>=o;return[E,x]},p=E=>{if(u=E,!s)return;let I=s;s=void 0,e.apply(void 0,I)},d=()=>{b(0)},f=()=>{a&&(d(),p(Date.now()))},m=E=>{if(u=E,n)return p(E)},h=E=>{if(i&&s)return p(E);s=void 0},g=()=>{a=void 0;let[E,I]=l();return I?h(E):A(E)},A=E=>{let I=E-c,w=E-u,x=t-I,C=o-w,_=Math.min(x,C);return b(_)},b=E=>{a&&clearTimeout(a),!(E<=0)&&(a=setTimeout(g,E))},v=(...E)=>{let[I,w]=l(),x=!!a;if(s=E,c=I,(w||!a)&&b(t),w)return x?p(I):m(I)};return v.cancel=d,v.flush=f,v},KFn=Glm;var Hao=ye(require("fs"),1),YFn=ye(require("path"),1);var Zf=ye(require("fs"),1),hB=require("util");var Dpe=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},xre=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var Gao=ye(require("process"),1),$Mc=Gao.default.getuid?!Gao.default.getuid():!1,HMc=1e4,H2=()=>{};var pjt={isChangeErrorOk:e=>{if(!pjt.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!$Mc&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!pjt.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!pjt.isNodeError(e))throw e;if(!pjt.isChangeErrorOk(e))throw e}},qv=pjt;var Wao=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=HMc,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(n),n=()=>t(r);this.add(n)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},KMc=new Wao;var Rpe=(e,t)=>function(n){return function i(...o){return KMc.schedule().then(s=>{let a=u=>(s(),u),c=u=>{if(s(),Date.now()>=n)throw u;if(t(u)){let l=Math.round(100*Math.random());return new Promise(d=>setTimeout(d,l)).then(()=>i.apply(void 0,o))}throw u};return e.apply(void 0,o).then(a,c)})}},Fpe=(e,t)=>function(n){return function i(...o){try{return e.apply(void 0,o)}catch(s){if(Date.now()>n)throw s;if(t(s))return i.apply(void 0,o);throw s}}};var Wlm={attempt:{chmod:Dpe((0,hB.promisify)(Zf.default.chmod),qv.onChangeError),chown:Dpe((0,hB.promisify)(Zf.default.chown),qv.onChangeError),close:Dpe((0,hB.promisify)(Zf.default.close),H2),fsync:Dpe((0,hB.promisify)(Zf.default.fsync),H2),mkdir:Dpe((0,hB.promisify)(Zf.default.mkdir),H2),realpath:Dpe((0,hB.promisify)(Zf.default.realpath),H2),stat:Dpe((0,hB.promisify)(Zf.default.stat),H2),unlink:Dpe((0,hB.promisify)(Zf.default.unlink),H2),chmodSync:xre(Zf.default.chmodSync,qv.onChangeError),chownSync:xre(Zf.default.chownSync,qv.onChangeError),closeSync:xre(Zf.default.closeSync,H2),existsSync:xre(Zf.default.existsSync,H2),fsyncSync:xre(Zf.default.fsync,H2),mkdirSync:xre(Zf.default.mkdirSync,H2),realpathSync:xre(Zf.default.realpathSync,H2),statSync:xre(Zf.default.statSync,H2),unlinkSync:xre(Zf.default.unlinkSync,H2)},retry:{close:Rpe((0,hB.promisify)(Zf.default.close),qv.isRetriableError),fsync:Rpe((0,hB.promisify)(Zf.default.fsync),qv.isRetriableError),open:Rpe((0,hB.promisify)(Zf.default.open),qv.isRetriableError),readFile:Rpe((0,hB.promisify)(Zf.default.readFile),qv.isRetriableError),rename:Rpe((0,hB.promisify)(Zf.default.rename),qv.isRetriableError),stat:Rpe((0,hB.promisify)(Zf.default.stat),qv.isRetriableError),write:Rpe((0,hB.promisify)(Zf.default.write),qv.isRetriableError),writeFile:Rpe((0,hB.promisify)(Zf.default.writeFile),qv.isRetriableError),closeSync:Fpe(Zf.default.closeSync,qv.isRetriableError),fsyncSync:Fpe(Zf.default.fsyncSync,qv.isRetriableError),openSync:Fpe(Zf.default.openSync,qv.isRetriableError),readFileSync:Fpe(Zf.default.readFileSync,qv.isRetriableError),renameSync:Fpe(Zf.default.renameSync,qv.isRetriableError),statSync:Fpe(Zf.default.statSync,qv.isRetriableError),writeSync:Fpe(Zf.default.writeSync,qv.isRetriableError),writeFileSync:Fpe(Zf.default.writeFileSync,qv.isRetriableError)}},JMc=Wlm;var JFn=ye(require("fs"),1),fjt=ye(require("path"),1);var $ao=()=>{};var $lm=()=>{let e=$ao,t=$ao,r=!1,n=!1;return{promise:new Promise((c,u)=>{e=l=>(r=!0,c(l)),t=l=>(n=!0,u(l))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},YMc=$lm;var Hlm=()=>{let{promise:e,resolve:t,isPending:r}=YMc(),n=0,i=()=>{n+=1},o=()=>{n-=1,!n&&t()};return i(),queueMicrotask(o),{promise:e,isPending:r,increment:i,decrement:o}},XMc=Hlm;var ZMc={then:e=>{e()}};var eLc=e=>Array.isArray(e)?e:[e],tLc=e=>typeof e=="function";var Klm=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,o=t?.ignore??[],s=eLc(o).map(J=>tLc(J)?J:X=>J.test(X)),a=J=>s.some(X=>X(J)),c=t?.signal??{aborted:!1},u=t?.onDirents||(()=>{}),l=[],p=new Set,d={},f=[],m=new Set,h={},g=[],A=new Set,b={},v={},E=new Set,I={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},w={directories:l,directoriesNames:p,directoriesNamesToPaths:d,files:f,filesNames:m,filesNamesToPaths:h,symlinks:g,symlinksNames:A,symlinksNamesToPaths:b,map:v},{promise:x,increment:C,decrement:_}=XMc(),D=0,V=(J,X,Ae,he)=>{E.has(X)||D>=i||(D+=1,J.directories.push(X),J.directoriesNames.add(Ae),l.push(X),p.add(Ae),d.propertyIsEnumerable(Ae)||(d[Ae]=[]),d[Ae].push(X),E.add(X),!(he>=n)&&(D>=i||$(X,he+1)))},q=(J,X,Ae)=>{E.has(X)||D>=i||(D+=1,J.files.push(X),J.filesNames.add(Ae),f.push(X),m.add(Ae),h.propertyIsEnumerable(Ae)||(h[Ae]=[]),h[Ae].push(X),E.add(X))},U=(J,X,Ae,he)=>{E.has(X)||D>=i||(D+=1,J.symlinks.push(X),J.symlinksNames.add(Ae),g.push(X),A.add(Ae),b.propertyIsEnumerable(Ae)||(b[Ae]=[]),b[Ae].push(X),E.add(X),r&&(he>=n||D>=i||ge(X,he+1)))},W=(J,X,Ae,he,we)=>{c.aborted||a(X)||(he.isDirectory()?V(J,X,Ae,we):he.isFile()?q(J,X,Ae):he.isSymbolicLink()&&U(J,X,Ae,we))},re=(J,X,Ae,he)=>{if(c.aborted)return;let we=X===fjt.default.sep?"":fjt.default.sep,_e=Ae.name,ue=`${X}${we}${_e}`;a(ue)||(Ae.isDirectory()?V(J,ue,_e,he):Ae.isFile()?q(J,ue,_e):Ae.isSymbolicLink()&&U(J,ue,_e,he))},z=(J,X,Ae,he)=>{for(let we=0,_e=Ae.length;we<_e;we++)re(J,X,Ae[we],he)},$=(J,X)=>{c.aborted||X>n||D>=i||(C(),JFn.default.readdir(J,{withFileTypes:!0},(Ae,he)=>{if(Ae||c.aborted||!he.length)return _();(u(he)||ZMc).then(()=>{let _e=v[J]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(_e,J,he,X),_()})}))},ge=(J,X)=>{C(),JFn.default.realpath(J,(Ae,he)=>{if(Ae||c.aborted)return _();JFn.default.stat(he,(we,_e)=>{if(we||c.aborted)return _();let ue=fjt.default.basename(he),ce=v[J]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};W(ce,he,ue,_e,X),_()})})};return(async(J,X=1)=>(J=fjt.default.normalize(J),E.add(J),$(J,X),await x,c.aborted?I:w))(e)},rLc=Klm;var _re={lang:{debounce:KFn,attempt:e=>{try{return e()}catch(t){return _re.lang.castError(t)}},castArray:e=>_re.lang.isArray(e)?e:[e],castError:e=>_re.lang.isError(e)?e:_re.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(_re.lang.isNaN(e))return _re.lang.isNaN(t);if(_re.lang.isPrimitive(e)||_re.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(YFn.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Hao.default.realpathSync.native(e):Hao.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===YFn.default.sep&&t.length-e.length>YFn.default.sep.length,poll:(e,t=WMc)=>JMc.retry.stat(t)(e,{bigint:!0}).catch(_re.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,o)=>{if(o&&r===1&&e in o){let s=o[e];return[s.directories,s.files]}else{let s=await rLc(e,{depth:r,limit:n,ignore:t,signal:i});return[s.directories,s.files]}}}},Pl=_re;var XFn=ye(require("path"),1);var Kao=class{constructor(t,r,n){this.base=n,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Pl.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=VMc){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,o=async(a,c)=>{let u=this.options.ignoreInitial?[]:a,l=await this.eventsPopulate([...c]),p=this.eventsDeduplicate([...u,...l]);this.onTargetEvents(p)},s=Pl.lang.debounce(()=>{this.watcher.isClosed()||(r=o(n,i),n=[],i=new Set)},t);return async(a,c="",u=!1)=>{u?await this.eventsPopulate([c],n,!0):i.add(c),r.then(s)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[o,s]=i,a=r[s];return o===a||o===gc.CHANGE&&a===gc.ADD||(r[s]=o,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let o=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(o.map(async s=>{r.push([s,i]),s===gc.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):s===gc.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let o=this.options.recursive?this.options.depth??H_e:Math.min(1,this.options.depth??H_e),s=this.options.limit??ujt,[a,c]=await Pl.fs.readdir(r,this.options.ignore,o,s,this.watcher._closeSignal),u=[...a,...c];return await Promise.all(u.map(l=>{if(!this.watcher.isIgnored(l,this.options.ignore)&&!t.includes(l))return this.eventsPopulate([l],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let o of this.watcher._poller.stats.keys())Pl.fs.isSubPath(r,o)&&(t.includes(o)||await this.eventsPopulate([o],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(gc.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!K_e&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(gc.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(gc.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(XFn.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(gc.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(XFn.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(gc.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===gc.ADD?this.onTargetAdd(n):r===gc.ADD_DIR?this.onTargetAddDir(n):r===gc.CHANGE?this.onTargetChange(n):r===gc.UNLINK?this.onTargetUnlink(n):r===gc.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=aje.CHANGE,r){if(this.watcher.isClosed())return;let n=XFn.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){Vao&&t.code==="EPERM"?this.onWatcherChange(aje.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(ljt.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(ljt.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(aje.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&K_e&&this.options.native!==!1?this.options.depth??H_e:Math.min(1,this.options.depth??H_e),n=this.options.limit??ujt,[i,o]=await Pl.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),s=[this.folderPath,...i,...o];await Promise.all(s.map(a=>{if(!this.watcher._poller.stats.has(a)&&!this.watcher.isIgnored(a,this.options.ignore))return this.onWatcherEvent(aje.CHANGE,a,t)}))}}},nLc=Kao;var HR={interval:100,intervalId:void 0,fns:new Map,init:()=>{HR.intervalId||(HR.intervalId=setInterval(HR.resolve,HR.interval))},reset:()=>{HR.intervalId&&(clearInterval(HR.intervalId),delete HR.intervalId)},add:(e,t)=>{HR.fns.set(e,Date.now()+t),HR.init()},remove:e=>{HR.fns.delete(e)},resolve:()=>{if(!HR.fns.size)return HR.reset();let e=Date.now();for(let[t,r]of HR.fns)r>=e||(HR.remove(t),t())}},djt=HR;var mjt=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=qao){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{let p=this._watcher._poller.paths.find(n||-1,d=>d!==i);if(p&&p!==i){if(Pl.fs.getRealPath(i,!0)===p)return;this._watcher.event(o.rename,p,i)}else this._watcher.event(o.add,i)};if(!n)return a();let c=()=>{s.add.delete(n),djt.remove(u)},u=()=>{c(),a()};djt.add(u,r);let l=()=>{let p=s.unlink.get(n);if(!p)return;c();let d=p();i===d?o.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(o.change,i):this._watcher.event(o.rename,d,i)};s.add.set(n,l),l()}getLockUnlink(t,r=qao){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{this._watcher.event(o.unlink,i)};if(!n)return a();let c=()=>{s.unlink.delete(n),djt.remove(u)},u=()=>{c(),a()};djt.add(u,r);let l=()=>(c(),i);s.unlink.set(n,l),s.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,gc.ADD,Cre.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,gc.ADD_DIR,Cre.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,gc.UNLINK,Cre.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,gc.UNLINK_DIR,Cre.DIR);return this.getLockUnlink({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};mjt.DIR_EVENTS={add:gc.ADD_DIR,rename:gc.RENAME_DIR,unlink:gc.UNLINK_DIR};mjt.FILE_EVENTS={add:gc.ADD,change:gc.CHANGE,rename:gc.RENAME,unlink:gc.UNLINK};var iLc=mjt;var Jao=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Pl.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(Pl.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(Pl.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(Pl.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return Pl.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);Pl.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},Yao=Jao;var Xao=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},oLc=Xao;var Zao=class{constructor(){this.inos={},this.paths=new Yao,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let o=i[t];if(o&&!(n&&o[1]!==n))return o[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await Pl.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new oLc(n)}reset(){this.inos={},this.paths=new Yao,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,gc.ADD,i),[gc.ADD];if(i.isDirectory())return this.updateIno(t,gc.ADD_DIR,i),[gc.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,gc.UNLINK,n),[gc.UNLINK];if(n.isDirectory())return this.updateIno(t,gc.UNLINK_DIR,n),[gc.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,gc.CHANGE,i),[gc.CHANGE]);if(i.isDirectory())return this.updateIno(t,gc.UNLINK,n),this.updateIno(t,gc.ADD_DIR,i),[gc.UNLINK,gc.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,gc.UNLINK_DIR,n),this.updateIno(t,gc.ADD,i),[gc.UNLINK_DIR,gc.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,gc.UNLINK_DIR,n),this.updateIno(t,gc.ADD_DIR,i),[gc.UNLINK_DIR,gc.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),o=n.isFile()?Cre.FILE:Cre.DIR;i[t]=[n.ino,o]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},eco=Zao;var tco=class e extends sLc.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on($R.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on($R.CLOSE,i)),this._readyWait=new Promise(i=>this.on($R.READY,i)),this._locker=new iLc(this),this._roots=new Set,this._poller=new eco,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Pl.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit($R.CLOSE))}error(t){if(this.isClosed())return!1;let r=Pl.lang.castError(t);return this.emit($R.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit($R.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit($R.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&Pl.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&Pl.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let o of[...i])r&&o.filePath!==r||this.watcherClose(o);if(n)for(let o in this._watchers)Pl.fs.isSubPath(t,o)&&this.watchersClose(o,r,!1)}else for(let i in this._watchers)this.watchersClose(i,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let o=new nLc(this,t,r);return await o.init(),o}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let o=r.indexOf(t);r.splice(o,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Pl.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(a=>a.handler===n&&(!a.filePath||a.filePath===i)&&a.options.ignore===r.ignore&&!!a.options.native==!!r.native&&(!r.recursive||a.options.recursive)))return!0;let s=cje.default.dirname(t);for(let a=1;a<1/0;a++){if(this._watchers[s]?.find(l=>(a===1||l.options.recursive&&a<=(l.options.depth??H_e))&&l.handler===n&&(!l.filePath||l.filePath===i)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive&&K_e&&l.options.native!==!1)))return!0;if(!K_e)break;let u=cje.default.dirname(t);if(s===u)break;s=u}return!1}async watchDirectories(t,r,n,i,o){if(this.isClosed())return;t=Pl.lang.uniq(t).sort();let s;for(let a of t)if(!this.isIgnored(a,r.ignore)&&!this.watcherExists(a,r,n,i))try{let c=!r.recursive||K_e&&r.native!==!1?r:{...r,recursive:!1},l={watcher:ZFn.default.watch(a,c),handler:n,options:r,folderPath:a,filePath:i},p=s=await this.watcherAdd(l,o);if(this._roots.has(i||a)){let f={...r,ignoreInitial:!0,recursive:!1},m=cje.default.dirname(a),h=a;await this.watchDirectories([m],f,n,h,p)}}catch(c){this.error(c)}return s}async watchDirectory(t,r,n,i,o){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||K_e&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,o));{r={...r,recursive:!0};let s=r.depth??H_e,a=r.limit??ujt,[c]=await Pl.fs.readdir(t,r.ignore,s,a,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let u=await this.watchDirectories([t],r,n,i,o);if(c.length){let l=Pl.fs.getDepth(t);for(let p of c){let d=Pl.fs.getDepth(p),f=Math.max(0,s-(d-l)),m={...r,depth:f};await this.watchDirectories([p],m,n,i,o||u)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},o=(u,l)=>{l===t&&(c(),n())},s=new e(o),a=()=>{this._subwatchers.add(i),this.on($R.CLOSE,c),s.watchFile(t,r,o)},c=()=>{this._subwatchers.delete(i),this.removeListener($R.CLOSE,c),s.close()};return a()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=cje.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,o=new eco,s=await this.watchPolling(t,r,async()=>{i||!(await o.update(t,r.pollingTimeout)).length||i||(i=!0,s(),n())})}async watchPolling(t,r,n){if(this.isClosed())return Pl.lang.noop;if(this.pollerExists(t,r))return Pl.lang.noop;let i={...r,interval:r.pollingInterval??GMc},o={targetPath:t,options:r},s=()=>{this._pollers.add(o),this.on($R.CLOSE,a),ZFn.default.watchFile(t,i,n)},a=()=>{this._pollers.delete(o),this.removeListener($R.CLOSE,a),ZFn.default.unwatchFile(t,n)};return Pl.lang.attempt(s),()=>Pl.lang.attempt(a)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=Pl.lang.uniq(t).sort(),t.every((o,s)=>t.every((a,c)=>c===s||!Pl.fs.isSubPath(o,a))))await Promise.all(t.map(o=>this.watchPath(o,r,n)));else for(let o of t)await this.watchPath(o,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=cje.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await Pl.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let o=cje.default.dirname(t);return(await Pl.fs.poll(o,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=Pl.lang.noop){if(Pl.lang.isFunction(t))return this.watch([],{},t);if(Pl.lang.isUndefined(t))return this.watch([],r,n);if(Pl.lang.isFunction(r))return this.watch(t,{},r);if(Pl.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=Pl.lang.castArray(t);i.forEach(o=>this._roots.add(o)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==Pl.lang.noop&&this.on($R.ALL,n),r.readdirMap=void 0,this.ready())}},ekn=tco;hkn();qt();var ept=require("fs/promises"),pUc=require("os"),fUc=ye(require("path"),1),vfm=".fern",Ifm="logs";function wfm(){return"cli@4.46.2"}var mje=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=We(Ut.of((0,pUc.homedir)()),Se.of(vfm)),r=We(t,Se.of(Ifm));await er(r)||await(0,ept.mkdir)(r,{recursive:!0});let i=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=We(r,Se.of(i));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${fUc.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2204
|
+
`)}if(s)throw Yr.exit();if(o.warningCount>0){t.stderr.info(`${bo.warning} ${ve.yellow(`Found ${o.warningCount} warnings`)}`),t.stderr.info(ve.dim(" Run 'fern docs check --strict' to treat warnings as errors"));return}t.stderr.info(`${bo.success} ${ve.green("All checks passed")}`)}buildJsonResponse({result:t,hasErrors:r}){let n={};return t.violations.length>0&&(n.docs=t.violations.map(i=>ZX(i))),{success:!r,results:n}}};function vso(e){let t=new Eso;Ra(e,"check","Validate docs configuration",(r,n)=>t.handle(r,n),r=>r.option("strict",{type:"boolean",description:"Treat warnings as errors",default:!1}).option("json",{type:"boolean",description:"Output results as JSON to stdout",default:!1}))}var aNc=ye(require("net"),1),cNc=ye(require("os"),1),cFn=class extends Error{constructor(t){super(`${t} is locked`)}},Tlt={old:new Set,young:new Set},Snm=1e3*15;var jQt,Bnm=()=>{let e=cNc.default.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let n of r)t.add(n.address);return t},oNc=e=>new Promise((t,r)=>{let n=aNc.default.createServer();n.unref(),n.on("error",r),n.listen(e,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),sNc=async(e,t)=>{if(e.host||e.port===0)return oNc(e);for(let r of t)try{await oNc({port:e.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return e.port},Tnm=function*(e){e&&(yield*e),yield 0};async function U_e(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let i=e.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let o of i){if(typeof o!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(o))throw new TypeError(`Number ${o} in the exclude option is not a safe integer and can't be used`)}r=new Set(i)}jQt===void 0&&(jQt=setTimeout(()=>{jQt=void 0,Tlt.old=Tlt.young,Tlt.young=new Set},Snm),jQt.unref&&jQt.unref());let n=Bnm();for(let i of Tnm(t))try{if(r.has(i))continue;let o=await sNc({...e,port:i},n);for(;Tlt.old.has(o)||Tlt.young.has(o);){if(i!==0)throw new cFn(i);o=await sNc({...e,port:i},n)}return Tlt.young.add(o),o}catch(o){if(!["EADDRINUSE","EACCES"].includes(o.code)&&!(o instanceof cFn))throw o}throw new Error("No available ports found")}St();Vg();qt();var CVc=ye(Cso(),1),xVc=ye(HFn(),1),RNn=require("fs/promises"),_Vc=ye(require("http"),1),SVc=ye(require("path"),1);var sLc=require("events"),ZFn=ye(require("fs"),1),cje=ye(require("path"),1);var zMc=ye(require("os"),1),VMc=300,H_e=20,ujt=1e7,qMc=zMc.default.platform();var qlm=qMc==="darwin",Vao=qMc==="win32",K_e=qlm||Vao,GMc=3e3,WMc=2e4,qao=1250;var Cre;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(Cre||(Cre={}));var aje;(function(e){e.CHANGE="change",e.RENAME="rename"})(aje||(aje={}));var ljt;(function(e){e.CHANGE="change",e.ERROR="error"})(ljt||(ljt={}));var gc;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(gc||(gc={}));var $R;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})($R||($R={}));var Glm=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,o=Math.max(r?.maxWait??1/0,t),s,a,c=0,u=0,l=()=>{let E=Date.now(),I=E-c,w=E-u,x=I>=t||w>=o;return[E,x]},p=E=>{if(u=E,!s)return;let I=s;s=void 0,e.apply(void 0,I)},d=()=>{b(0)},f=()=>{a&&(d(),p(Date.now()))},m=E=>{if(u=E,n)return p(E)},h=E=>{if(i&&s)return p(E);s=void 0},g=()=>{a=void 0;let[E,I]=l();return I?h(E):A(E)},A=E=>{let I=E-c,w=E-u,x=t-I,C=o-w,_=Math.min(x,C);return b(_)},b=E=>{a&&clearTimeout(a),!(E<=0)&&(a=setTimeout(g,E))},v=(...E)=>{let[I,w]=l(),x=!!a;if(s=E,c=I,(w||!a)&&b(t),w)return x?p(I):m(I)};return v.cancel=d,v.flush=f,v},KFn=Glm;var Hao=ye(require("fs"),1),YFn=ye(require("path"),1);var Zf=ye(require("fs"),1),hB=require("util");var Dpe=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},xre=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var Gao=ye(require("process"),1),$Mc=Gao.default.getuid?!Gao.default.getuid():!1,HMc=1e4,H2=()=>{};var pjt={isChangeErrorOk:e=>{if(!pjt.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!$Mc&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!pjt.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!pjt.isNodeError(e))throw e;if(!pjt.isChangeErrorOk(e))throw e}},qv=pjt;var Wao=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=HMc,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(n),n=()=>t(r);this.add(n)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},KMc=new Wao;var Rpe=(e,t)=>function(n){return function i(...o){return KMc.schedule().then(s=>{let a=u=>(s(),u),c=u=>{if(s(),Date.now()>=n)throw u;if(t(u)){let l=Math.round(100*Math.random());return new Promise(d=>setTimeout(d,l)).then(()=>i.apply(void 0,o))}throw u};return e.apply(void 0,o).then(a,c)})}},Fpe=(e,t)=>function(n){return function i(...o){try{return e.apply(void 0,o)}catch(s){if(Date.now()>n)throw s;if(t(s))return i.apply(void 0,o);throw s}}};var Wlm={attempt:{chmod:Dpe((0,hB.promisify)(Zf.default.chmod),qv.onChangeError),chown:Dpe((0,hB.promisify)(Zf.default.chown),qv.onChangeError),close:Dpe((0,hB.promisify)(Zf.default.close),H2),fsync:Dpe((0,hB.promisify)(Zf.default.fsync),H2),mkdir:Dpe((0,hB.promisify)(Zf.default.mkdir),H2),realpath:Dpe((0,hB.promisify)(Zf.default.realpath),H2),stat:Dpe((0,hB.promisify)(Zf.default.stat),H2),unlink:Dpe((0,hB.promisify)(Zf.default.unlink),H2),chmodSync:xre(Zf.default.chmodSync,qv.onChangeError),chownSync:xre(Zf.default.chownSync,qv.onChangeError),closeSync:xre(Zf.default.closeSync,H2),existsSync:xre(Zf.default.existsSync,H2),fsyncSync:xre(Zf.default.fsync,H2),mkdirSync:xre(Zf.default.mkdirSync,H2),realpathSync:xre(Zf.default.realpathSync,H2),statSync:xre(Zf.default.statSync,H2),unlinkSync:xre(Zf.default.unlinkSync,H2)},retry:{close:Rpe((0,hB.promisify)(Zf.default.close),qv.isRetriableError),fsync:Rpe((0,hB.promisify)(Zf.default.fsync),qv.isRetriableError),open:Rpe((0,hB.promisify)(Zf.default.open),qv.isRetriableError),readFile:Rpe((0,hB.promisify)(Zf.default.readFile),qv.isRetriableError),rename:Rpe((0,hB.promisify)(Zf.default.rename),qv.isRetriableError),stat:Rpe((0,hB.promisify)(Zf.default.stat),qv.isRetriableError),write:Rpe((0,hB.promisify)(Zf.default.write),qv.isRetriableError),writeFile:Rpe((0,hB.promisify)(Zf.default.writeFile),qv.isRetriableError),closeSync:Fpe(Zf.default.closeSync,qv.isRetriableError),fsyncSync:Fpe(Zf.default.fsyncSync,qv.isRetriableError),openSync:Fpe(Zf.default.openSync,qv.isRetriableError),readFileSync:Fpe(Zf.default.readFileSync,qv.isRetriableError),renameSync:Fpe(Zf.default.renameSync,qv.isRetriableError),statSync:Fpe(Zf.default.statSync,qv.isRetriableError),writeSync:Fpe(Zf.default.writeSync,qv.isRetriableError),writeFileSync:Fpe(Zf.default.writeFileSync,qv.isRetriableError)}},JMc=Wlm;var JFn=ye(require("fs"),1),fjt=ye(require("path"),1);var $ao=()=>{};var $lm=()=>{let e=$ao,t=$ao,r=!1,n=!1;return{promise:new Promise((c,u)=>{e=l=>(r=!0,c(l)),t=l=>(n=!0,u(l))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},YMc=$lm;var Hlm=()=>{let{promise:e,resolve:t,isPending:r}=YMc(),n=0,i=()=>{n+=1},o=()=>{n-=1,!n&&t()};return i(),queueMicrotask(o),{promise:e,isPending:r,increment:i,decrement:o}},XMc=Hlm;var ZMc={then:e=>{e()}};var eLc=e=>Array.isArray(e)?e:[e],tLc=e=>typeof e=="function";var Klm=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,o=t?.ignore??[],s=eLc(o).map(J=>tLc(J)?J:X=>J.test(X)),a=J=>s.some(X=>X(J)),c=t?.signal??{aborted:!1},u=t?.onDirents||(()=>{}),l=[],p=new Set,d={},f=[],m=new Set,h={},g=[],A=new Set,b={},v={},E=new Set,I={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},w={directories:l,directoriesNames:p,directoriesNamesToPaths:d,files:f,filesNames:m,filesNamesToPaths:h,symlinks:g,symlinksNames:A,symlinksNamesToPaths:b,map:v},{promise:x,increment:C,decrement:_}=XMc(),D=0,V=(J,X,Ae,he)=>{E.has(X)||D>=i||(D+=1,J.directories.push(X),J.directoriesNames.add(Ae),l.push(X),p.add(Ae),d.propertyIsEnumerable(Ae)||(d[Ae]=[]),d[Ae].push(X),E.add(X),!(he>=n)&&(D>=i||$(X,he+1)))},q=(J,X,Ae)=>{E.has(X)||D>=i||(D+=1,J.files.push(X),J.filesNames.add(Ae),f.push(X),m.add(Ae),h.propertyIsEnumerable(Ae)||(h[Ae]=[]),h[Ae].push(X),E.add(X))},U=(J,X,Ae,he)=>{E.has(X)||D>=i||(D+=1,J.symlinks.push(X),J.symlinksNames.add(Ae),g.push(X),A.add(Ae),b.propertyIsEnumerable(Ae)||(b[Ae]=[]),b[Ae].push(X),E.add(X),r&&(he>=n||D>=i||ge(X,he+1)))},W=(J,X,Ae,he,we)=>{c.aborted||a(X)||(he.isDirectory()?V(J,X,Ae,we):he.isFile()?q(J,X,Ae):he.isSymbolicLink()&&U(J,X,Ae,we))},re=(J,X,Ae,he)=>{if(c.aborted)return;let we=X===fjt.default.sep?"":fjt.default.sep,_e=Ae.name,ue=`${X}${we}${_e}`;a(ue)||(Ae.isDirectory()?V(J,ue,_e,he):Ae.isFile()?q(J,ue,_e):Ae.isSymbolicLink()&&U(J,ue,_e,he))},z=(J,X,Ae,he)=>{for(let we=0,_e=Ae.length;we<_e;we++)re(J,X,Ae[we],he)},$=(J,X)=>{c.aborted||X>n||D>=i||(C(),JFn.default.readdir(J,{withFileTypes:!0},(Ae,he)=>{if(Ae||c.aborted||!he.length)return _();(u(he)||ZMc).then(()=>{let _e=v[J]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(_e,J,he,X),_()})}))},ge=(J,X)=>{C(),JFn.default.realpath(J,(Ae,he)=>{if(Ae||c.aborted)return _();JFn.default.stat(he,(we,_e)=>{if(we||c.aborted)return _();let ue=fjt.default.basename(he),ce=v[J]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};W(ce,he,ue,_e,X),_()})})};return(async(J,X=1)=>(J=fjt.default.normalize(J),E.add(J),$(J,X),await x,c.aborted?I:w))(e)},rLc=Klm;var _re={lang:{debounce:KFn,attempt:e=>{try{return e()}catch(t){return _re.lang.castError(t)}},castArray:e=>_re.lang.isArray(e)?e:[e],castError:e=>_re.lang.isError(e)?e:_re.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(_re.lang.isNaN(e))return _re.lang.isNaN(t);if(_re.lang.isPrimitive(e)||_re.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(YFn.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Hao.default.realpathSync.native(e):Hao.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===YFn.default.sep&&t.length-e.length>YFn.default.sep.length,poll:(e,t=WMc)=>JMc.retry.stat(t)(e,{bigint:!0}).catch(_re.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,o)=>{if(o&&r===1&&e in o){let s=o[e];return[s.directories,s.files]}else{let s=await rLc(e,{depth:r,limit:n,ignore:t,signal:i});return[s.directories,s.files]}}}},Pl=_re;var XFn=ye(require("path"),1);var Kao=class{constructor(t,r,n){this.base=n,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Pl.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=VMc){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,o=async(a,c)=>{let u=this.options.ignoreInitial?[]:a,l=await this.eventsPopulate([...c]),p=this.eventsDeduplicate([...u,...l]);this.onTargetEvents(p)},s=Pl.lang.debounce(()=>{this.watcher.isClosed()||(r=o(n,i),n=[],i=new Set)},t);return async(a,c="",u=!1)=>{u?await this.eventsPopulate([c],n,!0):i.add(c),r.then(s)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[o,s]=i,a=r[s];return o===a||o===gc.CHANGE&&a===gc.ADD||(r[s]=o,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let o=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(o.map(async s=>{r.push([s,i]),s===gc.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):s===gc.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let o=this.options.recursive?this.options.depth??H_e:Math.min(1,this.options.depth??H_e),s=this.options.limit??ujt,[a,c]=await Pl.fs.readdir(r,this.options.ignore,o,s,this.watcher._closeSignal),u=[...a,...c];return await Promise.all(u.map(l=>{if(!this.watcher.isIgnored(l,this.options.ignore)&&!t.includes(l))return this.eventsPopulate([l],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let o of this.watcher._poller.stats.keys())Pl.fs.isSubPath(r,o)&&(t.includes(o)||await this.eventsPopulate([o],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(gc.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!K_e&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(gc.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(gc.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(XFn.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(gc.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(XFn.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(gc.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===gc.ADD?this.onTargetAdd(n):r===gc.ADD_DIR?this.onTargetAddDir(n):r===gc.CHANGE?this.onTargetChange(n):r===gc.UNLINK?this.onTargetUnlink(n):r===gc.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=aje.CHANGE,r){if(this.watcher.isClosed())return;let n=XFn.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){Vao&&t.code==="EPERM"?this.onWatcherChange(aje.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(ljt.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(ljt.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(aje.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&K_e&&this.options.native!==!1?this.options.depth??H_e:Math.min(1,this.options.depth??H_e),n=this.options.limit??ujt,[i,o]=await Pl.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),s=[this.folderPath,...i,...o];await Promise.all(s.map(a=>{if(!this.watcher._poller.stats.has(a)&&!this.watcher.isIgnored(a,this.options.ignore))return this.onWatcherEvent(aje.CHANGE,a,t)}))}}},nLc=Kao;var HR={interval:100,intervalId:void 0,fns:new Map,init:()=>{HR.intervalId||(HR.intervalId=setInterval(HR.resolve,HR.interval))},reset:()=>{HR.intervalId&&(clearInterval(HR.intervalId),delete HR.intervalId)},add:(e,t)=>{HR.fns.set(e,Date.now()+t),HR.init()},remove:e=>{HR.fns.delete(e)},resolve:()=>{if(!HR.fns.size)return HR.reset();let e=Date.now();for(let[t,r]of HR.fns)r>=e||(HR.remove(t),t())}},djt=HR;var mjt=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=qao){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{let p=this._watcher._poller.paths.find(n||-1,d=>d!==i);if(p&&p!==i){if(Pl.fs.getRealPath(i,!0)===p)return;this._watcher.event(o.rename,p,i)}else this._watcher.event(o.add,i)};if(!n)return a();let c=()=>{s.add.delete(n),djt.remove(u)},u=()=>{c(),a()};djt.add(u,r);let l=()=>{let p=s.unlink.get(n);if(!p)return;c();let d=p();i===d?o.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(o.change,i):this._watcher.event(o.rename,d,i)};s.add.set(n,l),l()}getLockUnlink(t,r=qao){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{this._watcher.event(o.unlink,i)};if(!n)return a();let c=()=>{s.unlink.delete(n),djt.remove(u)},u=()=>{c(),a()};djt.add(u,r);let l=()=>(c(),i);s.unlink.set(n,l),s.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,gc.ADD,Cre.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,gc.ADD_DIR,Cre.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,gc.UNLINK,Cre.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,gc.UNLINK_DIR,Cre.DIR);return this.getLockUnlink({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};mjt.DIR_EVENTS={add:gc.ADD_DIR,rename:gc.RENAME_DIR,unlink:gc.UNLINK_DIR};mjt.FILE_EVENTS={add:gc.ADD,change:gc.CHANGE,rename:gc.RENAME,unlink:gc.UNLINK};var iLc=mjt;var Jao=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Pl.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(Pl.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(Pl.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(Pl.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return Pl.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);Pl.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},Yao=Jao;var Xao=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},oLc=Xao;var Zao=class{constructor(){this.inos={},this.paths=new Yao,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let o=i[t];if(o&&!(n&&o[1]!==n))return o[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await Pl.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new oLc(n)}reset(){this.inos={},this.paths=new Yao,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,gc.ADD,i),[gc.ADD];if(i.isDirectory())return this.updateIno(t,gc.ADD_DIR,i),[gc.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,gc.UNLINK,n),[gc.UNLINK];if(n.isDirectory())return this.updateIno(t,gc.UNLINK_DIR,n),[gc.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,gc.CHANGE,i),[gc.CHANGE]);if(i.isDirectory())return this.updateIno(t,gc.UNLINK,n),this.updateIno(t,gc.ADD_DIR,i),[gc.UNLINK,gc.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,gc.UNLINK_DIR,n),this.updateIno(t,gc.ADD,i),[gc.UNLINK_DIR,gc.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,gc.UNLINK_DIR,n),this.updateIno(t,gc.ADD_DIR,i),[gc.UNLINK_DIR,gc.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),o=n.isFile()?Cre.FILE:Cre.DIR;i[t]=[n.ino,o]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},eco=Zao;var tco=class e extends sLc.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on($R.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on($R.CLOSE,i)),this._readyWait=new Promise(i=>this.on($R.READY,i)),this._locker=new iLc(this),this._roots=new Set,this._poller=new eco,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Pl.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit($R.CLOSE))}error(t){if(this.isClosed())return!1;let r=Pl.lang.castError(t);return this.emit($R.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit($R.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit($R.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&Pl.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&Pl.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let o of[...i])r&&o.filePath!==r||this.watcherClose(o);if(n)for(let o in this._watchers)Pl.fs.isSubPath(t,o)&&this.watchersClose(o,r,!1)}else for(let i in this._watchers)this.watchersClose(i,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let o=new nLc(this,t,r);return await o.init(),o}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let o=r.indexOf(t);r.splice(o,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Pl.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(a=>a.handler===n&&(!a.filePath||a.filePath===i)&&a.options.ignore===r.ignore&&!!a.options.native==!!r.native&&(!r.recursive||a.options.recursive)))return!0;let s=cje.default.dirname(t);for(let a=1;a<1/0;a++){if(this._watchers[s]?.find(l=>(a===1||l.options.recursive&&a<=(l.options.depth??H_e))&&l.handler===n&&(!l.filePath||l.filePath===i)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive&&K_e&&l.options.native!==!1)))return!0;if(!K_e)break;let u=cje.default.dirname(t);if(s===u)break;s=u}return!1}async watchDirectories(t,r,n,i,o){if(this.isClosed())return;t=Pl.lang.uniq(t).sort();let s;for(let a of t)if(!this.isIgnored(a,r.ignore)&&!this.watcherExists(a,r,n,i))try{let c=!r.recursive||K_e&&r.native!==!1?r:{...r,recursive:!1},l={watcher:ZFn.default.watch(a,c),handler:n,options:r,folderPath:a,filePath:i},p=s=await this.watcherAdd(l,o);if(this._roots.has(i||a)){let f={...r,ignoreInitial:!0,recursive:!1},m=cje.default.dirname(a),h=a;await this.watchDirectories([m],f,n,h,p)}}catch(c){this.error(c)}return s}async watchDirectory(t,r,n,i,o){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||K_e&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,o));{r={...r,recursive:!0};let s=r.depth??H_e,a=r.limit??ujt,[c]=await Pl.fs.readdir(t,r.ignore,s,a,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let u=await this.watchDirectories([t],r,n,i,o);if(c.length){let l=Pl.fs.getDepth(t);for(let p of c){let d=Pl.fs.getDepth(p),f=Math.max(0,s-(d-l)),m={...r,depth:f};await this.watchDirectories([p],m,n,i,o||u)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},o=(u,l)=>{l===t&&(c(),n())},s=new e(o),a=()=>{this._subwatchers.add(i),this.on($R.CLOSE,c),s.watchFile(t,r,o)},c=()=>{this._subwatchers.delete(i),this.removeListener($R.CLOSE,c),s.close()};return a()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=cje.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,o=new eco,s=await this.watchPolling(t,r,async()=>{i||!(await o.update(t,r.pollingTimeout)).length||i||(i=!0,s(),n())})}async watchPolling(t,r,n){if(this.isClosed())return Pl.lang.noop;if(this.pollerExists(t,r))return Pl.lang.noop;let i={...r,interval:r.pollingInterval??GMc},o={targetPath:t,options:r},s=()=>{this._pollers.add(o),this.on($R.CLOSE,a),ZFn.default.watchFile(t,i,n)},a=()=>{this._pollers.delete(o),this.removeListener($R.CLOSE,a),ZFn.default.unwatchFile(t,n)};return Pl.lang.attempt(s),()=>Pl.lang.attempt(a)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=Pl.lang.uniq(t).sort(),t.every((o,s)=>t.every((a,c)=>c===s||!Pl.fs.isSubPath(o,a))))await Promise.all(t.map(o=>this.watchPath(o,r,n)));else for(let o of t)await this.watchPath(o,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=cje.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await Pl.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let o=cje.default.dirname(t);return(await Pl.fs.poll(o,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=Pl.lang.noop){if(Pl.lang.isFunction(t))return this.watch([],{},t);if(Pl.lang.isUndefined(t))return this.watch([],r,n);if(Pl.lang.isFunction(r))return this.watch(t,{},r);if(Pl.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=Pl.lang.castArray(t);i.forEach(o=>this._roots.add(o)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==Pl.lang.noop&&this.on($R.ALL,n),r.readdirMap=void 0,this.ready())}},ekn=tco;hkn();qt();var ept=require("fs/promises"),pUc=require("os"),fUc=ye(require("path"),1),vfm=".fern",Ifm="logs";function wfm(){return"cli@4.46.3"}var mje=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=We(Ut.of((0,pUc.homedir)()),Se.of(vfm)),r=We(t,Se.of(Ifm));await er(r)||await(0,ept.mkdir)(r,{recursive:!0});let i=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=We(r,Se.of(i));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${fUc.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2205
2205
|
`);await(0,ept.writeFile)(this.logFilePath,o,"utf-8"),this.initialized=!0}getLogFilePath(){return this.logFilePath}async writeEntry(t){if(!this.initialized||!this.logFilePath)return;let r=JSON.stringify(t)+`
|
|
2206
2206
|
`;try{await(0,ept.appendFile)(this.logFilePath,r,"utf-8")}catch{}}async logFrontendMetrics(t){let r={timestamp:t.timestamp,source:t.source,level:t.level,eventType:this.getEventType(t.payload,t.isAggregate),isAggregate:t.isAggregate,data:t.payload};await this.writeEntry(r)}async logCliMetric(t,r="info"){let n={timestamp:t.timestamp,source:wfm(),level:r,eventType:t.type,data:{durationMs:t.durationMs,metadata:t.metadata}};await this.writeEntry(n)}async logCliMemory(){let t=process.memoryUsage(),r={type:"cli_memory",timestamp:new Date().toISOString(),metadata:{heapUsed:t.heapUsed,heapTotal:t.heapTotal,external:t.external,rss:t.rss,heapUsedMB:Math.round(t.heapUsed/1024/1024*100)/100,heapTotalMB:Math.round(t.heapTotal/1024/1024*100)/100,rssMB:Math.round(t.rss/1024/1024*100)/100}};await this.logCliMetric(r)}async logCliReloadStart(){let t={type:"cli_reload_start",timestamp:new Date().toISOString()};await this.logCliMetric(t)}async logCliReloadFinish(t,r){let n={type:"cli_reload_finish",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(n)}async logCliDocsGeneration(t,r){let n={type:"cli_docs_generation",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(n)}async logCliValidation(t,r){let n={type:"cli_validation",timestamp:new Date().toISOString(),durationMs:t,metadata:{success:r}};await this.logCliMetric(n)}getEventType(t,r){return r?"aggregate_summary":"type"in t&&typeof t.type=="string"?t.type:"unknown"}static isMetricsMessage(t){if(typeof t!="object"||t===null)return!1;let r=t;return r.type==="metrics"&&typeof r.timestamp=="string"&&typeof r.source=="string"}};var wco={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"};function dUc(e){let t=Cfm();if(t==null)return;let{port:r,debugLogger:n,getDocsLoadResponse:i}=e,o=new Map;function s(c){let u=JSON.stringify(c),l=[];for(let[p]of o)try{p.send(u)}catch{l.push(p)}for(let p of l){let d=o.get(p);d&&(clearInterval(d.pingInterval),o.delete(p))}}let a=t.serve({port:r,fetch(c,u){if(c.method==="OPTIONS")return new Response(null,{status:204,headers:wco});let l=new URL(c.url);if(c.headers.get("upgrade")?.toLowerCase()==="websocket"){u.upgrade(c,{data:{connectionId:`${Date.now()}`}});return}if(c.method==="POST"&&l.pathname==="/v2/registry/docs/load-with-url")return new Response(JSON.stringify(i()),{headers:{"Content-Type":"application/json",...wco}});let p=/^\/_local\/(.*)/.exec(l.pathname);return c.method==="GET"&&p!=null?new Response(t.file(`/${p[1]}`),{headers:wco}):new Response("Not Found",{status:404})},websocket:{open(c){let{connectionId:u}=c.data,l=setInterval(()=>{let p=o.get(c);if(!p)return;let d=Date.now();if(d-p.lastPong>9e4){c.close();return}try{c.send(JSON.stringify({type:"ping",timestamp:d}))}catch{c.close()}},3e4);o.set(c,{pingInterval:l,lastPong:Date.now()});try{c.send(JSON.stringify({type:"connected",connectionId:u}))}catch{}},message(c,u){try{let l=JSON.parse(u.toString());if(l.type==="pong"){let p=o.get(c);p&&(p.lastPong=Date.now())}else mje.isMetricsMessage(l)&&n.logFrontendMetrics(l)}catch{}},close(c){let u=o.get(c);u&&(clearInterval(u.pingInterval),o.delete(c))}}});return{sendData:s,stop:c=>a.stop(c)}}function Cfm(){return globalThis.Bun}qt();var nlo=ye(Dco(),1),gVc=ye(Guo(),1),K2=require("fs/promises"),AVc=require("os"),yVc=ye(ZC(),1),bVc=ye(mVc(),1),SNn=process.platform==="win32",rlo=ve.cyan("[docs]:"),eAm="etag",tAm=23,hVc=e=>e.padEnd(tAm," "),rAm="preview",nAm="app-preview",iAm="bundle",oAm=".next",sAm="standalone",aAm=".fern",cAm="packages/fern-docs/bundle/.next/server/instrumentation.js",uAm=".npmrc",lAm=".pnpmfile.cjs",pAm="pnpm-workspace.yaml",fAm='Cannot find matching keyid: {"signatures":';function dAm(){return We(Ut.of((0,AVc.homedir)()),Se.of(aAm))}function ypt({app:e=!1}){return We(dAm(),Se.of(e?nAm:rAm))}function sSe({app:e=!1}){return We(ypt({app:e}),Se.of(e?oAm:iAm))}function Wjt({app:e=!1}){return We(sSe({app:e}),Se.of(sAm))}function mAm({app:e=!1}){return We(Wjt({app:e}),Se.of(cAm))}function hAm({app:e=!1}){return We(Wjt({app:e}),Se.of(pAm))}function gAm({app:e=!1}){return We(Wjt({app:e}),Se.of(lAm))}function AAm({app:e=!1}){return We(Wjt({app:e}),Se.of(uAm))}function wje(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function yAm({app:e=!1}){return We(ypt({app:e}),Se.of(eAm))}var bAm=`module.exports = {
|
|
2207
2207
|
hooks: {
|
|
@@ -2242,7 +2242,7 @@ Please ensure you have membership at https://dashboard.buildwithfern.com, and as
|
|
|
2242
2242
|
|
|
2243
2243
|
Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`);case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function p0m(e,t){let n=e?.content;if(n?.reason==="status-code"){let i=n.statusCode;if(i===401||i===403)return`${`You do not have permission to publish docs to organization '${t}'. Please run 'fern login' to ensure you are logged in with the correct account.`}
|
|
2244
2244
|
|
|
2245
|
-
Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`}}function f0m(e){try{return new URL(MR(e)).pathname}catch{return}}async function d0m({fdr:e,workspace:t,organization:r,context:n,snippetsConfig:i}){if(!t)return;let o=await m0m({fdr:e,workspace:t,snippetsConfig:i,context:n});if(Object.keys(o).length===0){n.logger.debug("[SDK Dynamic IR] No snippet configs found, skipping S3 check");return}try{let s=await e.api.v1.register.checkSdkDynamicIrExists({orgId:Sr.OrgId(r),snippetConfiguration:o});if(!s.ok||!s.body){n.logger.debug("[SDK Dynamic IR] API call failed or returned empty body");return}let a=s.body.existingDynamicIrs;if(Object.keys(a).length===0){n.logger.debug("[SDK Dynamic IR] No existing SDK dynamic IRs found in S3");return}let c={};for(let[u,l]of Object.entries(a))try{n.logger.debug(`Downloading existing SDK dynamic IR for ${u}...`);let p=await fetch(l.downloadUrl);if(p.ok){let d=await p.json();c[u]={dynamicIR:d},n.logger.debug(`Successfully downloaded SDK dynamic IR for ${u}`)}else n.logger.warn(`Failed to download SDK dynamic IR for ${u}: ${p.status}`)}catch(p){n.logger.warn(`Error downloading SDK dynamic IR for ${u}: ${p}`)}return Object.keys(c).length>0?c:void 0}catch(s){n.logger.debug(`Error checking for existing SDK dynamic IRs: ${s}`);return}}function oqc(e){return e.replace(/^https:\/\//,"")}async function m0m({fdr:e,workspace:t,snippetsConfig:r,context:n}){let i={},o=[{language:"typescript",snippetName:r.typescriptSdk?.package,explicitVersion:r.typescriptSdk?.version},{language:"python",snippetName:r.pythonSdk?.package,explicitVersion:r.pythonSdk?.version},{language:"java",snippetName:r.javaSdk?.coordinate,explicitVersion:r.javaSdk?.version},{language:"go",snippetName:r.goSdk?.githubRepo&&oqc(r.goSdk?.githubRepo),explicitVersion:r.goSdk?.version},{language:"csharp",snippetName:r.csharpSdk?.package,explicitVersion:r.csharpSdk?.version},{language:"ruby",snippetName:r.rubySdk?.gem,explicitVersion:r.rubySdk?.version},{language:"php",snippetName:r.phpSdk?.package,explicitVersion:r.phpSdk?.version},{language:"swift",snippetName:r.swiftSdk?.package,explicitVersion:r.swiftSdk?.version},{language:"rust",snippetName:r.rustSdk?.package,explicitVersion:r.rustSdk?.version}];for(let s of o){if(!s.snippetName)continue;let a=s.explicitVersion;a||(a=(await h0m({fdr:e,workspace:t,language:s.language,snippetName:s.snippetName,context:n}))?.version),i[s.language]={packageName:s.snippetName,version:a},a||n.logger.debug(`[SDK Dynamic IR] ${s.language}: no version specified, will use latest`)}return i}async function h0m({fdr:e,workspace:t,language:r,snippetName:n,context:i}){let o;switch(r){case"csharp":o="Csharp";break;case"go":o="Go";break;case"java":o="Java";break;case"python":o="Python";break;case"ruby":o="Ruby";break;case"typescript":o="TypeScript";break;case"php":o="Php";break;case"swift":o="Swift";break;default:return}let s,a,c;if(t.generatorsConfiguration?.groups){let u=[];for(let l of t.generatorsConfiguration.groups)for(let p of l.generators)if(p.language===r){let d=In.getPackageName({generatorInvocation:p});d&&u.push(d),!a&&d&&(a=d,c=p.name,p.outputMode.type==="githubV2"&&(s=`${p.outputMode.githubV2.owner}/${p.outputMode.githubV2.repo}`))}}if(!a){i.logger.debug(`[SDK Dynamic IR] ${r}: no generator found with a package name`);return}try{let u=await e.sdks.versions.computeSemanticVersion({githubRepository:s,language:o,package:a});if(!u.ok){i.logger.debug(`[SDK Dynamic IR] ${r}: version computation failed for package "${a}"`);return}return i.logger.debug(`[SDK Dynamic IR] ${r}: computed version ${u.body.version} for package "${a}"`),{version:u.body.version,generatorPackage:a}}catch(u){i.logger.debug(`[SDK Dynamic IR] ${r}: error computing version: ${u}`);return}}async function g0m({workspace:e,organization:t,context:r,snippetsConfig:n,skipLanguages:i=new Set}){let o={};if(!e)return;let s={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo&&oqc(n.goSdk?.githubRepo),csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:n.rustSdk?.package};if(e.generatorsConfiguration?.groups)for(let a of e.generatorsConfiguration.groups)for(let c of a.generators){let u=Cje({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),l="";if(u?.outputConfig.type==="publish")switch(u.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":l=u.outputConfig.value.packageName;break;case"maven":l=u.outputConfig.value.coordinate;break;case"go":l=u.outputConfig.value.repoUrl;break;case"swift":l=u.outputConfig.value.repoUrl;break;case"crates":l=u.outputConfig.value.packageName;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(l=c.config.packageName??""),!!c.language){if(i.has(c.language)){r.logger.debug(`Skipping dynamic IR generation for ${c.language} (using existing SDK dynamic IR)`);continue}if(c.language&&s[c.language]===l){let p=Qh({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:l,version:void 0,context:r,sourceResolver:new Fm(r,e),dynamicGeneratorConfig:u}),d=EFe({ir:p,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:u});d?o[c.language]={dynamicIR:d}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}}for(let[a,c]of Object.entries(s))a&&c&&!Object.keys(o).includes(a)&&!i.has(a)&&(r.logger.warn(),r.logger.warn(`Failed to upload ${a} SDK snippets because of unknown package \`${c}\`.`),r.logger.warn(`Please make sure your ${e.workspaceName?`${e.workspaceName}/`:""}generators.yml has a generator that publishes a ${c} package.`),r.logger.warn());if(Object.keys(o).length>0)return o}async function A0m({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,o]of Object.entries(t)){let s=e[i]?.dynamicIR;if(s){let a=JSON.stringify(s);(await fetch(o.uploadUrl,{method:"PUT",body:a,headers:{"Content-Type":"application/octet-stream","Content-Length":Buffer.byteLength(a,"utf8").toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`)}else r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function y0m({docsDefinition:e,isPreview:t,context:r}){e.config.aiChatConfig==null||t||r.logger.warn(ve.yellow("Enabling Ask Fern from docs.yml is deprecated. Please enable it from the Fern dashboard instead."))}function b0m(e,t){if(e)return{enabled:!0,model:process.env.FERN_AI_MODEL||"gpt-4o-mini",maxRetries:parseInt(process.env.FERN_AI_MAX_RETRIES||"3"),requestTimeoutMs:parseInt(process.env.FERN_AI_TIMEOUT_MS||"25000"),styleInstructions:t}}function E0m(e){let t=e,r=t?.content;return{errorType:t?.error,statusCode:t?.statusCode??r?.statusCode,reason:r?.reason,errorMessage:r?.errorMessage??r?.message,body:r?.body,cause:r?.cause,rawError:e}}var eMt=[60*1e3,300*1e3,300*1e3];async function tMt({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:o,instanceUrl:s,preview:a,previewId:c,disableTemplates:u,skipUpload:l,cliVersion:p,ciSource:d}){let f=a&&!n.config.settings?.substituteEnvVars;n.config=Xy(n.config,{onError:b=>i.failAndThrow(b)},{substituteAsEmpty:f});let m=n.config.instances;if(m.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(m.length>1&&s==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${m[0]?.url})`);return}let h=m.find(b=>b.url===s)??m[0];if(h==null){i.failAndThrow(`No docs instance with url ${s}. Failed to register.`);return}let g=[];h.customDomain!=null&&(typeof h.customDomain=="string"?g.push(h.customDomain):Array.isArray(h.customDomain)&&g.push(...h.customDomain)),i.logger.info(`Starting docs publishing for ${a?"preview":"production"}: ${h.url}`),i.logger.debug(`Organization: ${e}, Preview: ${a}, APIs: ${t.length}, OSS: ${r.length}`);let A;return await i.runInteractiveTask({name:h.url},async()=>{let b=performance.now(),v=()=>iqc({docsWorkspace:n,customDomains:g,domain:h.url,token:o,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:a,previewId:c,editThisPage:h.editThisPage,isPrivate:h.private,disableTemplates:u,skipUpload:l,withAiExamples:n.config.aiExamples?.enabled??n.config.experimental?.aiExamples??!0,excludeApis:n.config.experimental?.excludeApis??!1,targetAudiences:h.audiences?Array.isArray(h.audiences)?h.audiences:[h.audiences]:void 0,docsUrl:h.url,cliVersion:p,ciSource:d});for(let I=0;;I++)try{A=await v();break}catch(w){if(!(w instanceof Ipt)||I>=eMt.length){if(w instanceof Ipt)return i.failAndThrow("Another docs publish is currently in progress. Please try again once the other publish is complete.");throw w}let x=eMt[I]??eMt[eMt.length-1]??6e4,C=x/6e4;i.logger.warn(`Another docs publish is in progress. Retrying in ${C} minute${C===1?"":"s"} (attempt ${I+1}/${eMt.length})...`),await new Promise(_=>setTimeout(_,x))}let E=performance.now()-b;i.logger.debug(`Docs publishing completed in ${E.toFixed(0)}ms`)}),A}var w2n=class{context;task;project;docsWorkspace;ossWorkspaces;token;constructor({context:t,task:r,project:n,docsWorkspace:i,ossWorkspaces:o,token:s}){this.context=t,this.task=r,this.project=n,this.docsWorkspace=i,this.ossWorkspaces=o,this.token=s}async publish({instanceUrl:t,preview:r,skipUpload:n}){let i=new zh({context:this.context,task:this.task});try{let o=await tMt({organization:this.project.config.organization,apiWorkspaces:this.project.apiWorkspaces,ossWorkspaces:this.ossWorkspaces,docsWorkspace:this.docsWorkspace,context:i,token:this.token,instanceUrl:t,preview:r,previewId:void 0,disableTemplates:void 0,skipUpload:n,cliVersion:"4.46.2"});return i.getResult()===tf.Failure?{success:!1}:{success:!0,url:o}}catch(o){return{success:!1,error:Ti(o)}}}};St();var wpt=class e{static MAX_DISPLAYED_LOGS_TTY=10;static URL_PATTERN=/https?:\/\/[^\s]+/;context;stream;tasks={};taskOrder=[];startTime;isRegistered=!1;constructor(t){this.context=t.context,this.stream=t.stream??process.stderr}addTask(t){let r={...t,status:t.status??"pending"};return this.tasks[t.id]=r,this.taskOrder.push(t.id),this}async start(t){return this.startTime=Date.now(),t!=null&&await this.context.ttyAwareLogger.takeOverTerminal(()=>{this.stream.write(`
|
|
2245
|
+
Please ensure you have membership at https://dashboard.buildwithfern.com, and ask a team member for an invite if not.`}}function f0m(e){try{return new URL(MR(e)).pathname}catch{return}}async function d0m({fdr:e,workspace:t,organization:r,context:n,snippetsConfig:i}){if(!t)return;let o=await m0m({fdr:e,workspace:t,snippetsConfig:i,context:n});if(Object.keys(o).length===0){n.logger.debug("[SDK Dynamic IR] No snippet configs found, skipping S3 check");return}try{let s=await e.api.v1.register.checkSdkDynamicIrExists({orgId:Sr.OrgId(r),snippetConfiguration:o});if(!s.ok||!s.body){n.logger.debug("[SDK Dynamic IR] API call failed or returned empty body");return}let a=s.body.existingDynamicIrs;if(Object.keys(a).length===0){n.logger.debug("[SDK Dynamic IR] No existing SDK dynamic IRs found in S3");return}let c={};for(let[u,l]of Object.entries(a))try{n.logger.debug(`Downloading existing SDK dynamic IR for ${u}...`);let p=await fetch(l.downloadUrl);if(p.ok){let d=await p.json();c[u]={dynamicIR:d},n.logger.debug(`Successfully downloaded SDK dynamic IR for ${u}`)}else n.logger.warn(`Failed to download SDK dynamic IR for ${u}: ${p.status}`)}catch(p){n.logger.warn(`Error downloading SDK dynamic IR for ${u}: ${p}`)}return Object.keys(c).length>0?c:void 0}catch(s){n.logger.debug(`Error checking for existing SDK dynamic IRs: ${s}`);return}}function oqc(e){return e.replace(/^https:\/\//,"")}async function m0m({fdr:e,workspace:t,snippetsConfig:r,context:n}){let i={},o=[{language:"typescript",snippetName:r.typescriptSdk?.package,explicitVersion:r.typescriptSdk?.version},{language:"python",snippetName:r.pythonSdk?.package,explicitVersion:r.pythonSdk?.version},{language:"java",snippetName:r.javaSdk?.coordinate,explicitVersion:r.javaSdk?.version},{language:"go",snippetName:r.goSdk?.githubRepo&&oqc(r.goSdk?.githubRepo),explicitVersion:r.goSdk?.version},{language:"csharp",snippetName:r.csharpSdk?.package,explicitVersion:r.csharpSdk?.version},{language:"ruby",snippetName:r.rubySdk?.gem,explicitVersion:r.rubySdk?.version},{language:"php",snippetName:r.phpSdk?.package,explicitVersion:r.phpSdk?.version},{language:"swift",snippetName:r.swiftSdk?.package,explicitVersion:r.swiftSdk?.version},{language:"rust",snippetName:r.rustSdk?.package,explicitVersion:r.rustSdk?.version}];for(let s of o){if(!s.snippetName)continue;let a=s.explicitVersion;a||(a=(await h0m({fdr:e,workspace:t,language:s.language,snippetName:s.snippetName,context:n}))?.version),i[s.language]={packageName:s.snippetName,version:a},a||n.logger.debug(`[SDK Dynamic IR] ${s.language}: no version specified, will use latest`)}return i}async function h0m({fdr:e,workspace:t,language:r,snippetName:n,context:i}){let o;switch(r){case"csharp":o="Csharp";break;case"go":o="Go";break;case"java":o="Java";break;case"python":o="Python";break;case"ruby":o="Ruby";break;case"typescript":o="TypeScript";break;case"php":o="Php";break;case"swift":o="Swift";break;default:return}let s,a,c;if(t.generatorsConfiguration?.groups){let u=[];for(let l of t.generatorsConfiguration.groups)for(let p of l.generators)if(p.language===r){let d=In.getPackageName({generatorInvocation:p});d&&u.push(d),!a&&d&&(a=d,c=p.name,p.outputMode.type==="githubV2"&&(s=`${p.outputMode.githubV2.owner}/${p.outputMode.githubV2.repo}`))}}if(!a){i.logger.debug(`[SDK Dynamic IR] ${r}: no generator found with a package name`);return}try{let u=await e.sdks.versions.computeSemanticVersion({githubRepository:s,language:o,package:a});if(!u.ok){i.logger.debug(`[SDK Dynamic IR] ${r}: version computation failed for package "${a}"`);return}return i.logger.debug(`[SDK Dynamic IR] ${r}: computed version ${u.body.version} for package "${a}"`),{version:u.body.version,generatorPackage:a}}catch(u){i.logger.debug(`[SDK Dynamic IR] ${r}: error computing version: ${u}`);return}}async function g0m({workspace:e,organization:t,context:r,snippetsConfig:n,skipLanguages:i=new Set}){let o={};if(!e)return;let s={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo&&oqc(n.goSdk?.githubRepo),csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:n.rustSdk?.package};if(e.generatorsConfiguration?.groups)for(let a of e.generatorsConfiguration.groups)for(let c of a.generators){let u=Cje({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),l="";if(u?.outputConfig.type==="publish")switch(u.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":l=u.outputConfig.value.packageName;break;case"maven":l=u.outputConfig.value.coordinate;break;case"go":l=u.outputConfig.value.repoUrl;break;case"swift":l=u.outputConfig.value.repoUrl;break;case"crates":l=u.outputConfig.value.packageName;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(l=c.config.packageName??""),!!c.language){if(i.has(c.language)){r.logger.debug(`Skipping dynamic IR generation for ${c.language} (using existing SDK dynamic IR)`);continue}if(c.language&&s[c.language]===l){let p=Qh({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:l,version:void 0,context:r,sourceResolver:new Fm(r,e),dynamicGeneratorConfig:u}),d=EFe({ir:p,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:u});d?o[c.language]={dynamicIR:d}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}}for(let[a,c]of Object.entries(s))a&&c&&!Object.keys(o).includes(a)&&!i.has(a)&&(r.logger.warn(),r.logger.warn(`Failed to upload ${a} SDK snippets because of unknown package \`${c}\`.`),r.logger.warn(`Please make sure your ${e.workspaceName?`${e.workspaceName}/`:""}generators.yml has a generator that publishes a ${c} package.`),r.logger.warn());if(Object.keys(o).length>0)return o}async function A0m({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,o]of Object.entries(t)){let s=e[i]?.dynamicIR;if(s){let a=JSON.stringify(s);(await fetch(o.uploadUrl,{method:"PUT",body:a,headers:{"Content-Type":"application/octet-stream","Content-Length":Buffer.byteLength(a,"utf8").toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`)}else r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function y0m({docsDefinition:e,isPreview:t,context:r}){e.config.aiChatConfig==null||t||r.logger.warn(ve.yellow("Enabling Ask Fern from docs.yml is deprecated. Please enable it from the Fern dashboard instead."))}function b0m(e,t){if(e)return{enabled:!0,model:process.env.FERN_AI_MODEL||"gpt-4o-mini",maxRetries:parseInt(process.env.FERN_AI_MAX_RETRIES||"3"),requestTimeoutMs:parseInt(process.env.FERN_AI_TIMEOUT_MS||"25000"),styleInstructions:t}}function E0m(e){let t=e,r=t?.content;return{errorType:t?.error,statusCode:t?.statusCode??r?.statusCode,reason:r?.reason,errorMessage:r?.errorMessage??r?.message,body:r?.body,cause:r?.cause,rawError:e}}var eMt=[60*1e3,300*1e3,300*1e3];async function tMt({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:o,instanceUrl:s,preview:a,previewId:c,disableTemplates:u,skipUpload:l,cliVersion:p,ciSource:d}){let f=a&&!n.config.settings?.substituteEnvVars;n.config=Xy(n.config,{onError:b=>i.failAndThrow(b)},{substituteAsEmpty:f});let m=n.config.instances;if(m.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(m.length>1&&s==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${m[0]?.url})`);return}let h=m.find(b=>b.url===s)??m[0];if(h==null){i.failAndThrow(`No docs instance with url ${s}. Failed to register.`);return}let g=[];h.customDomain!=null&&(typeof h.customDomain=="string"?g.push(h.customDomain):Array.isArray(h.customDomain)&&g.push(...h.customDomain)),i.logger.info(`Starting docs publishing for ${a?"preview":"production"}: ${h.url}`),i.logger.debug(`Organization: ${e}, Preview: ${a}, APIs: ${t.length}, OSS: ${r.length}`);let A;return await i.runInteractiveTask({name:h.url},async()=>{let b=performance.now(),v=()=>iqc({docsWorkspace:n,customDomains:g,domain:h.url,token:o,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:a,previewId:c,editThisPage:h.editThisPage,isPrivate:h.private,disableTemplates:u,skipUpload:l,withAiExamples:n.config.aiExamples?.enabled??n.config.experimental?.aiExamples??!0,excludeApis:n.config.experimental?.excludeApis??!1,targetAudiences:h.audiences?Array.isArray(h.audiences)?h.audiences:[h.audiences]:void 0,docsUrl:h.url,cliVersion:p,ciSource:d});for(let I=0;;I++)try{A=await v();break}catch(w){if(!(w instanceof Ipt)||I>=eMt.length){if(w instanceof Ipt)return i.failAndThrow("Another docs publish is currently in progress. Please try again once the other publish is complete.");throw w}let x=eMt[I]??eMt[eMt.length-1]??6e4,C=x/6e4;i.logger.warn(`Another docs publish is in progress. Retrying in ${C} minute${C===1?"":"s"} (attempt ${I+1}/${eMt.length})...`),await new Promise(_=>setTimeout(_,x))}let E=performance.now()-b;i.logger.debug(`Docs publishing completed in ${E.toFixed(0)}ms`)}),A}var w2n=class{context;task;project;docsWorkspace;ossWorkspaces;token;constructor({context:t,task:r,project:n,docsWorkspace:i,ossWorkspaces:o,token:s}){this.context=t,this.task=r,this.project=n,this.docsWorkspace=i,this.ossWorkspaces=o,this.token=s}async publish({instanceUrl:t,preview:r,skipUpload:n}){let i=new zh({context:this.context,task:this.task});try{let o=await tMt({organization:this.project.config.organization,apiWorkspaces:this.project.apiWorkspaces,ossWorkspaces:this.ossWorkspaces,docsWorkspace:this.docsWorkspace,context:i,token:this.token,instanceUrl:t,preview:r,previewId:void 0,disableTemplates:void 0,skipUpload:n,cliVersion:"4.46.3"});return i.getResult()===tf.Failure?{success:!1}:{success:!0,url:o}}catch(o){return{success:!1,error:Ti(o)}}}};St();var wpt=class e{static MAX_DISPLAYED_LOGS_TTY=10;static URL_PATTERN=/https?:\/\/[^\s]+/;context;stream;tasks={};taskOrder=[];startTime;isRegistered=!1;constructor(t){this.context=t.context,this.stream=t.stream??process.stderr}addTask(t){let r={...t,status:t.status??"pending"};return this.tasks[t.id]=r,this.taskOrder.push(t.id),this}async start(t){return this.startTime=Date.now(),t!=null&&await this.context.ttyAwareLogger.takeOverTerminal(()=>{this.stream.write(`
|
|
2246
2246
|
`),this.stream.write(`${ve.cyan("\u25C6")} ${ve.bold(t.title)}
|
|
2247
2247
|
`),t.subtitle!=null&&this.stream.write(` ${ve.dim(t.subtitle)}
|
|
2248
2248
|
`),this.stream.write(`
|
|
@@ -3643,7 +3643,7 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
|
|
|
3643
3643
|
Run ${ve.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
3644
3644
|
Run ${ve.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),sJe(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function ajo({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!T_u(e))return;let i=t??"",o=e.filter(a=>a.isUpgradeAvailable);r!=null&&(o=o.slice(0,r+1));let s=o.sort((a,c)=>a.generatorName.localeCompare(c.generatorName)||a.currentVersion.localeCompare(c.currentVersion));for(let a of s)i+=`
|
|
3645
3645
|
${await fNh(a.generatorName)} (${a.apiName!=null?"API: "+a.apiName+", ":""}Group: ${a.generatorGroup}) `+ve.dim(a.currentVersion)+ve.reset(" \u2192 ")+ve.green(a.latestVersion);return i+=`
|
|
3646
|
-
`,n?sJe(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function fNh(e){let r=await new B_u.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 dNh({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){if(t.length===1){let a={type:"singleApi",versions:{}};return await P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,u,l,p)=>{a.versions[u]==null&&(a.versions[u]={});let d=FRe(l.name);if(d==null){p.logger.debug(`Skipping unknown generator: ${l.name}`);return}let f=await DT({generatorName:d,cliVersion:e.environment.packageVersion,currentGeneratorVersion:l.version,channel:i,includeMajor:o,context:p});f!=null&&(a.versions[u][l.name]={previousVersion:l.version,latestVersion:f})},generatorFilter:r,groupFilter:n}),a}let s={type:"multiApi",versions:{}};return await P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(a,c,u,l)=>{if(a==null)return;s.versions[a]==null&&(s.versions[a]={}),s.versions[a][c]==null&&(s.versions[a][c]={});let p=FRe(u.name);if(p==null){l.logger.debug(`Skipping unknown generator: ${u.name}`);return}let d=await DT({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:o,context:l});d!=null&&(s.versions[a][c][u.name]={previousVersion:u.version,latestVersion:d})},generatorFilter:r,groupFilter:n}),s}async function P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async o=>{await e.runTaskForWorkspace(o,async s=>{let a=await Vj({absolutePathToWorkspace:o.absoluteFilePath,context:s});if(a==null||a.groups==null)return;let c=n!=null?zx(n):void 0;for(let u of a.groups)if(!(i!=null&&u.groupName!==i))for(let l of u.generators)c!=null&&l.name!==c||await r(o.workspaceName,u.groupName,l,s)})}))}function D_u(e,t,r){let n=[];for(let[i,o]of Object.entries(e))for(let[s,a]of Object.entries(o)){r.debug(`Checking if ${s} in group ${i} has an upgrade available...`);let c=lN(a.latestVersion,a.previousVersion);r.debug(`Latest version: ${a.latestVersion}. `+(c?"Upgrade available.":"No upgrade available.")),n.push({generatorName:s,generatorGroup:i,apiName:t,isUpgradeAvailable:c,currentVersion:a.previousVersion,latestVersion:a.latestVersion})}return n}async function TGn({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){let s=[];if(e!=null){let a=await dNh({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o});if(a.type==="multiApi")for(let[c,u]of Object.entries(a.versions))s.push(...D_u(u,c,t.logger));else s.push(...D_u(a.versions,void 0,t.logger))}return s}async function Ede({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:jEt(e.packageName,{version:t?"prerelease":"latest"})}var R_u=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],OGn=class{environment;sentryClient;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Wn.Info;isLocal;stdoutRedirector=new BGn;jsonMode=!1;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new kFe(t,r),this.isLocal=n??!1;let i=this.getPackageName(),o=this.getPackageVersion(),s=this.getCliName();(i==null||o==null||s==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:o,cliName:s},this.sentryClient=new SGn({release:`cli@${this.environment.packageVersion}`})}getPackageName(){return"fern-api"}getPackageVersion(){return"4.46.
|
|
3646
|
+
`,n?sJe(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function fNh(e){let r=await new B_u.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 dNh({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){if(t.length===1){let a={type:"singleApi",versions:{}};return await P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,u,l,p)=>{a.versions[u]==null&&(a.versions[u]={});let d=FRe(l.name);if(d==null){p.logger.debug(`Skipping unknown generator: ${l.name}`);return}let f=await DT({generatorName:d,cliVersion:e.environment.packageVersion,currentGeneratorVersion:l.version,channel:i,includeMajor:o,context:p});f!=null&&(a.versions[u][l.name]={previousVersion:l.version,latestVersion:f})},generatorFilter:r,groupFilter:n}),a}let s={type:"multiApi",versions:{}};return await P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(a,c,u,l)=>{if(a==null)return;s.versions[a]==null&&(s.versions[a]={}),s.versions[a][c]==null&&(s.versions[a][c]={});let p=FRe(u.name);if(p==null){l.logger.debug(`Skipping unknown generator: ${u.name}`);return}let d=await DT({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:o,context:l});d!=null&&(s.versions[a][c][u.name]={previousVersion:u.version,latestVersion:d})},generatorFilter:r,groupFilter:n}),s}async function P_u({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async o=>{await e.runTaskForWorkspace(o,async s=>{let a=await Vj({absolutePathToWorkspace:o.absoluteFilePath,context:s});if(a==null||a.groups==null)return;let c=n!=null?zx(n):void 0;for(let u of a.groups)if(!(i!=null&&u.groupName!==i))for(let l of u.generators)c!=null&&l.name!==c||await r(o.workspaceName,u.groupName,l,s)})}))}function D_u(e,t,r){let n=[];for(let[i,o]of Object.entries(e))for(let[s,a]of Object.entries(o)){r.debug(`Checking if ${s} in group ${i} has an upgrade available...`);let c=lN(a.latestVersion,a.previousVersion);r.debug(`Latest version: ${a.latestVersion}. `+(c?"Upgrade available.":"No upgrade available.")),n.push({generatorName:s,generatorGroup:i,apiName:t,isUpgradeAvailable:c,currentVersion:a.previousVersion,latestVersion:a.latestVersion})}return n}async function TGn({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){let s=[];if(e!=null){let a=await dNh({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o});if(a.type==="multiApi")for(let[c,u]of Object.entries(a.versions))s.push(...D_u(u,c,t.logger));else s.push(...D_u(a.versions,void 0,t.logger))}return s}async function Ede({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:jEt(e.packageName,{version:t?"prerelease":"latest"})}var R_u=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],OGn=class{environment;sentryClient;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Wn.Info;isLocal;stdoutRedirector=new BGn;jsonMode=!1;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new kFe(t,r),this.isLocal=n??!1;let i=this.getPackageName(),o=this.getPackageVersion(),s=this.getCliName();(i==null||o==null||s==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:o,cliName:s},this.sentryClient=new SGn({release:`cli@${this.environment.packageVersion}`})}getPackageName(){return"fern-api"}getPackageVersion(){return"4.46.3"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${ve.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Sm}failWithoutThrowing(t,r){this.didSucceed=!1,O1t({message:t,error:r,logger:this.logger})}enableJsonMode(){this.jsonMode||(this.jsonMode=!0,this.stdoutRedirector.redirect())}get isJsonMode(){return this.jsonMode}writeJsonToStdout(t){this.stdoutRedirector.restore(),process.stdout.write(JSON.stringify(t,null,2)+`
|
|
3647
3647
|
`),this.jsonMode&&this.stdoutRedirector.redirect()}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await oJe()).flush(),await this.sentryClient.flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await O_u({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
3648
3648
|
`)||(r+=`
|
|
3649
3649
|
`),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=uJn(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Gzt(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(o){throw o.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,o),new Sm}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await oJe()).sendEvent(t)}async captureException(t){await this.sentryClient.captureException(t)}logger=oD((t,...r)=>this.log(t,...r));stderr=oD((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=F_u(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?F_u(this.longestWorkspaceName):r).length,i=r.padEnd(n),o=R_u[this.numTasks++%R_u.length],s=ve.hex(o)(i);return{...this.constructTaskInit(),logPrefix:s}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===tf.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>u1.indexOf(i.level)>=u1.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===Wn.Debug,stderr:r||this.jsonMode})}_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 Ede({cliEnvironment:this.environment,includePreReleases:t}),n=lN(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},o=await TGn({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:o}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await ojo({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:ve.yellow("?"),style:{answer:i=>ve.cyan(i),message:i=>ve.bold(i),highlight:i=>ve.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|