@fern-api/csharp-dynamic-snippets 2.21.0 → 2.22.0

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/dist/index.cjs CHANGED
@@ -169,7 +169,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
169
169
  `),this.hasSameAccess(this.init)||r.write(`${this.init} `),r.writeTextStatement("init"),r.writeNoIndent(`#else
170
170
  `),r.writeTextStatement("set"),r.writeNoIndent(`#endif
171
171
  `)):(this.hasSameAccess(this.init)||r.write(`${this.init} `),this.accessors?.init?(r.write("init"),r.write(" => "),this.accessors.init(r),r.writeTextStatement("")):r.write("init; "))),this.set&&(this.hasSameAccess(this.set)||r.write(`${this.set} `),this.accessors?.set?(r.write("set"),r.write(" => "),this.accessors.set(r),r.writeTextStatement("")):r.write("set; ")),r.write("}")),this.initializer!=null?(c?r.write(" => "):r.write(" = "),this.initializer.write(r),r.writeLine(";")):!this.skipDefaultInitializer&&!n&&i?pt.Type(this.type)&&this.type.writeEmptyCollectionInitializer(r):!this.get&&!this.init&&r.writeLine(";")}hasSameAccess(r){return r===!0||r===this.access}};u();o();a();var Ca;(function(t){t[t.INSTANCE=0]="INSTANCE",t[t.STATIC=1]="STATIC"})(Ca||(Ca={}));var Eh=class t extends z0{constructor({name:r,isAsync:n,override:i,access:c,return_:s,body:l,noBody:f,bodyType:b,summary:_,doc:O,type:v,classReference:w,parameters:P,typeParameters:T,annotations:S,codeExample:D,interfaceReference:B,origin:j,enclosingType:I},M){super({enclosingType:I},j,M);te(this,"name");te(this,"isAsync");te(this,"access");te(this,"return");te(this,"noBody");te(this,"body");te(this,"bodyType");te(this,"summary");te(this,"doc");te(this,"type");te(this,"reference");te(this,"override");te(this,"parameters");te(this,"typeParameters");te(this,"annotations");te(this,"interfaceReference");this.name=r,this.isAsync=n??!1,this.override=i??!1,this.access=c,this.return=s,this.noBody=f??!1,this.body=l,this.bodyType=b??t.BodyType.Statement,this.summary=_,this.doc=this.csharp.xmlDocBlockOf(O??{summary:_,codeExample:D}),this.type=v??Ca.INSTANCE,this.reference=w,this.parameters=P??[],this.typeParameters=T??[],this.annotations=(S??[]).map(x=>x instanceof In?this.csharp.annotation({reference:x}):x),this.interfaceReference=B}get isAsyncEnumerable(){return pt.AsyncEnumerable(this.return)}addParameter(r){return r instanceof Ma||(r=new Ma(r,this.generation)),this.parameters.push(r),r}write(r){if(r.writeNode(this.doc),this.annotations.forEach(n=>{n.write(r)}),r.writeNewLineIfLastLineNot(),this.access&&r.write(`${this.access} `),this.type===Ca.STATIC&&r.write("static "),this.isAsync&&r.write("async "),this.override&&r.write("override "),this.return==null?this.isAsync?(r.writeNode(this.System.Threading.Tasks.Task()),r.write(" ")):r.write("void "):(this.isAsync&&!this.isAsyncEnumerable?r.writeNode(this.System.Threading.Tasks.Task(this.return)):this.return.write(r),r.write(" ")),this.interfaceReference&&r.write(`${this.interfaceReference.name}.`),r.write(this.name),this.typeParameters.length>0&&(r.write("<"),this.typeParameters.forEach((n,i)=>{n.write(r),i<this.typeParameters.length-1&&r.write(", ")}),r.write(">")),r.write("("),this.parameters.forEach((n,i)=>{n.write(r),i<this.parameters.length-1&&r.write(", ")}),r.write(")"),this.noBody)r.writeLine(";");else switch(this.bodyType){case t.BodyType.Statement:r.write(" "),r.pushScope(),this.body?.write(r),r.popScope();break;case t.BodyType.Expression:r.write(" => "),this.body?.write(r),r.writeSemicolonIfLastCharacterIsNot();break;default:rr(this.bodyType)}}getParameters(){return this.parameters}};(function(t){t.BodyType={Statement:"statement",Expression:"expression"}})(Eh||(Eh={}));var xg=class extends di{constructor({name:r,namespace:n,access:i,partial:c,interfaceReferences:s,enclosingType:l,origin:f},b){super(f,b);te(this,"access");te(this,"partial");te(this,"reference");te(this,"interfaceReferences");te(this,"fields",[]);te(this,"methods",[]);r=r||(f?this.model.getClassNameFor(f):Ug("Class/Interface name or origin is required")),this.reference=l?this.csharp.classReference({name:r,enclosingType:l}):this.csharp.classReference({name:r,namespace:n||Ug("Class/Interface: Namespace or enclosingType is required ")}),this.access=i,this.partial=c??!1,this.interfaceReferences=s??[]}get name(){return this.reference.name}get namespace(){return this.reference.namespace}get enclosingType(){return this.reference.enclosingType}get isNested(){return this.enclosingType!=null}explicit(r){return this.origin?this.model.explicit(pt.Provenance(this.origin)?this.origin.node:this.origin,r):Ug(`Cannot create explicit named member '${r}' on '${this.name}' because the class is not bound to an origin.`)}getField(r){return this.fields.find(n=>this.model.provenance(n.origin)?.jsonPath===r.jsonPath)}addField(r){r.enclosingType=this.reference;let n=new zg(r,this.generation);return this.fields.push(n),n}addMethod(r){r.enclosingType=this.reference;let n=new Eh(r,this.generation);return this.methods.push(n),n}get multipartMethodName(){return"AddJsonPart"}get multipartMethodNameForCollection(){return"AddJsonParts"}get isOptional(){return!1}get isCollection(){return!1}get isReferenceType(){}asOptional(){return new pa(this,this.generation)}asNullable(){return new Lb(this,this.generation)}asNonOptional(){return this}get defaultValue(){return this.csharp.Literal.null()}get fullyQualifiedName(){return this.reference.fullyQualifiedName}};var Ci=class Ci extends xg{constructor({name:r,namespace:n,access:i,static_:c,abstract_:s,sealed:l,partial:f,readonly:b,parentClassReference:_,interfaceReferences:O,enclosingType:v,type:w,summary:P,doc:T,annotations:S,primaryConstructor:D,origin:B},j){super({name:r,namespace:n,access:i,partial:f,interfaceReferences:O,enclosingType:v,origin:B},j);te(this,"static_");te(this,"abstract_");te(this,"sealed");te(this,"readonly");te(this,"parentClassReference");te(this,"type");te(this,"summary");te(this,"doc");te(this,"annotations",[]);te(this,"primaryConstructor");te(this,"namespaceReferences",[]);te(this,"constructors",[]);te(this,"operators",[]);te(this,"nestedClasses",[]);te(this,"nestedInterfaces",[]);this.static_=c??!1,this.abstract_=s??!1,this.sealed=l??!1,this.readonly=b??!1,this.type=w??Ci.ClassType.Class,this.summary=P,this.doc=this.csharp.xmlDocBlockOf(T??{summary:P}),this.parentClassReference=_,this.annotations=(S??[]).map(I=>I instanceof In?this.csharp.annotation({reference:I}):I),this.primaryConstructor=D}addConstructor(r){let n=new Ci.Constructor(r,this.generation);return this.constructors.push(n),n}addNestedClass(r){if(r instanceof Ci||(r.enclosingType=this.reference,r=new Ci(r,this.generation)),!r.isNested)throw new Error(`Set the enclosingType of the class ${this.name} to add the nested class ${r.name}.`);return this.nestedClasses.push(r),r}addNestedClasses(r){r.forEach(n=>{n instanceof Ci?this.addNestedClass(n):this.addNestedClass(n)})}addAnnotation(r){return r instanceof I0||(r=new I0(r,this.generation)),this.annotations.push(r),r}addOperator(r){this.operators.push(r)}addOperators(r){r.forEach(n=>this.addOperator(n))}write(r){if(this.namespaceReferences.forEach(n=>{r.addNamespace(n)}),this.isNested||(r.writeLine(`namespace ${this.namespace};`),r.newLine()),r.writeNode(this.doc),this.annotations.forEach(n=>{n.write(r)}),r.writeNewLineIfLastLineNot(),r.write(`${this.access}`),this.static_&&r.write(" static"),this.abstract_&&r.write(" abstract"),this.sealed&&r.write(" sealed"),this.readonly&&r.write(" readonly"),this.partial&&r.write(" partial"),r.write(` ${this.type}`),r.write(` ${this.name}`),this.primaryConstructor!=null&&this.primaryConstructor.parameters.length>0){let n=this.primaryConstructor;r.write("("),n.parameters.forEach((i,c)=>{c>0&&r.write(","),i.write(r)}),r.write(")")}if(this.parentClassReference!=null||this.interfaceReferences.length>0){if(r.write(" : "),this.parentClassReference!=null&&(this.parentClassReference.write(r),this.interfaceReferences.length>0&&r.write(", ")),this.primaryConstructor!=null&&this.primaryConstructor.superClassArguments.length>0){let n=this.primaryConstructor;r.write("("),this.primaryConstructor.superClassArguments.forEach((i,c)=>{i.write(r),c<n.superClassArguments.length-1&&r.write(", ")}),r.write(")")}this.interfaceReferences.forEach((n,i)=>{n.write(r),i<this.interfaceReferences.length-1&&r.write(", ")})}if(!this.hasBody()){r.write(";");return}r.writeNewLineIfLastLineNot(),r.pushScope(),this.writeConsts(r),this.writeFieldFields(r),this.writeConstructors(r),this.writeProperties(r),this.writeMethods(r),this.writeOperators(r),this.writeNestedClasses(r),this.writeNestedInterfaces(r),r.popScope()}hasBody(){return this.fields.length>0||this.constructors.length>0||this.nestedClasses.length>0||this.nestedInterfaces.length>0||this.methods.length>0||this.operators.length>0}writeConstructors(r){this.constructors.forEach(n=>{r.writeNode(this.csharp.xmlDocBlockOf(n.doc)),r.write(`${n.access} ${this.name} (`),n.parameters.forEach((i,c)=>{i.write(r),c<n.parameters.length-1&&r.write(", ")}),r.write(")"),n.baseConstructorCall!=null&&(r.write(" : "),n.baseConstructorCall.write(r)),r.pushScope(),n.body.write(r),r.popScope(),r.newLine()})}writeFields({writer:r,fields:n}){n.forEach((i,c)=>{i.write(r),r.writeNewLineIfLastLineNot(),c<this.fields.length-1&&r.newLine()})}writeConsts(r){this.writeFields({writer:r,fields:this.getFields().sort(Wg).sort(KT).filter(this.fieldConstFilter())})}writeFieldFields(r){this.writeFields({writer:r,fields:this.getFields().sort(Wg).sort(KT).filter(this.fieldFieldFilter())})}writeProperties(r){this.writeFields({writer:r,fields:this.getFields().sort(Wg).sort(KT).filter(this.fieldPropertyFilter())})}writeMethods(r){this.methods.sort(Wg).sort(Mdt).sort(Bdt).forEach(n=>{n.write(r),r.writeNewLineIfLastLineNot(),r.newLine()})}writeOperators(r){this.operators.forEach(n=>{this.writeOperator({writer:r,operator:n}),r.newLine()})}writeNestedClasses(r){this.nestedClasses.sort(Wg).forEach((n,i)=>{n.write(r),r.writeNewLineIfLastLineNot(),i<this.fields.length-1&&r.newLine()})}writeNestedInterfaces(r){this.nestedInterfaces.sort(Wg).forEach((n,i)=>{n.write(r),r.writeNewLineIfLastLineNot(),i<this.fields.length-1&&r.newLine()})}fieldConstFilter(){return r=>r.isConst}fieldFieldFilter(){return r=>r.isField}fieldPropertyFilter(){return r=>r.isProperty}getFields(){return this.fields}get isReferenceType(){return this.type===Ci.ClassType.Class||this.type===Ci.ClassType.Record}writeOperator({writer:r,operator:n}){if(r.write("public static "),n.type===Ci.CastOperator.Type.Explicit||n.type===Ci.CastOperator.Type.Implicit){r.write(`${n.type} `),r.write("operator ");let i=n.to??this.reference;r.writeNode(i),r.write("("),n.parameter.write(r)}else{let i=n;i.return.write(r),r.write(" operator "),r.write(`${n.type}(`),i.parameters.forEach((c,s)=>{c.write(r),s<i.parameters.length-1&&r.write(", ")})}n.useExpressionBody?(r.write(") => "),r.writeNodeStatement(n.body)):(r.write(") {"),r.writeNode(n.body),r.writeLine("}"))}addNamespaceReference(r){this.namespaceReferences.push(r)}};te(Ci,"ClassType",{Class:"class",Record:"record",Struct:"struct",RecordStruct:"record struct"}),te(Ci,"Access",zr);var Yp=Ci;(function(t){class e{constructor({doc:i,body:c,parameters:s,access:l,baseConstructorCall:f},b){te(this,"generation");te(this,"doc");te(this,"body");te(this,"parameters");te(this,"access");te(this,"baseConstructorCall");this.generation=b,this.parameters=s??[],this.access=l??zr.Public,this.doc=i,this.body=new mh({},this.generation),c!=null&&this.body.append(c),this.baseConstructorCall=f}addParameter(i){let c=new Ma(i,this.generation);return this.parameters.push(c),c}}t.Constructor=e;let r;(function(n){n.Type={Implicit:"implicit",Explicit:"explicit"}})(r=t.CastOperator||(t.CastOperator={}))})(Yp||(Yp={}));function Hpe(t){switch(t){case void 0:return 0;case zr.Private:return 1;case zr.Protected:return 2;case zr.Internal:return 3;case zr.Public:return 4}}function Wg(t,e){return Hpe(t.access)-Hpe(e.access)}function KT(t,e){return t.isStatic===e.isStatic?0:t.isStatic?-1:1}function Bdt(t,e){return t.type===Ca.STATIC&&e.type!==Ca.STATIC?-1:t.type!==Ca.STATIC&&e.type===Ca.STATIC?1:0}function Mdt(t,e){return t.name==="FromProto"||t.name==="ToProto"?e.name==="Equals"||e.name==="ToString"?-1:1:e.name==="FromProto"||e.name==="ToProto"?t.name==="Equals"||t.name==="ToString"?1:-1:t.name==="ToString"?1:e.name==="ToString"?-1:t.name==="Equals"?e.name==="ToString"?-1:1:e.name==="Equals"?t.name==="ToString"?1:-1:0}u();o();a();var $g=class extends di{constructor({name:r,namespace:n,access:i,annotations:c,origin:s},l){super(s,l);te(this,"access");te(this,"reference");te(this,"annotations");te(this,"fields",[]);this.reference=this.csharp.classReference({name:r,namespace:n,origin:s}),this.access=i,this.annotations=c??[]}get name(){return this.reference.name}get namespace(){return this.reference.namespace}getNamespace(){return this.namespace}addMember(r){this.fields.push({name:r.name,value:this.csharp.annotation({reference:this.System.Runtime.Serialization.EnumMember,argument:this.csharp.codeblock(n=>{n.write("Value = "),n.writeNode(this.csharp.string_({string:r.value}))})})})}write(r){r.writeLine(`namespace ${this.namespace};`),r.newLine();for(let n of this.annotations)n.write(r);r.writeNewLineIfLastLineNot(),r.write(`${this.access} `),r.write("enum "),r.writeLine(`${this.name}`),r.pushScope(),this.fields.forEach((n,i)=>{n.value.write(r),r.write(n.name),i<this.fields.length-1&&(r.writeLine(","),r.newLine())}),r.writeNewLineIfLastLineNot(),r.popScope()}};u();o();a();var Vg=class extends xg{constructor({name:e,namespace:r,access:n,partial:i,interfaceReferences:c,enclosingType:s,origin:l},f){super({name:e,namespace:r,access:n,partial:i,interfaceReferences:c,enclosingType:s,origin:l},f)}write(e){this.isNested||(e.writeLine(`namespace ${this.namespace};`),e.newLine()),e.write(`${this.access} `),this.partial&&e.write("partial "),e.write("interface "),e.writeLine(`${this.name}`),this.interfaceReferences.length>0&&(e.write(" : "),this.interfaceReferences.forEach((r,n)=>{r.write(e),n<this.interfaceReferences.length-1&&e.write(", ")})),e.pushScope();for(let r of this.fields)r.write(e),e.writeLine("");e.dedent(),e.indent();for(let r of this.methods)r.write(e),e.writeLine("");e.popScope()}};u();o();a();var Hg=class extends di{constructor({name:r,namespace:n,parentClassReference:i,origin:c},s){super(c,s);te(this,"reference");te(this,"parentClassReference");te(this,"testMethods",[]);this.reference=this.csharp.classReference({name:r,namespace:n,origin:c}),this.parentClassReference=i}get name(){return this.reference.name}get namespace(){return this.reference.namespace}write(r){r.writeNode(this.getClass())}getClass(){let r=new Yp({access:zr.Public,name:this.name,namespace:this.namespace,annotations:[this.NUnit.Framework.TestFixture],parentClassReference:this.parentClassReference,origin:this.origin},this.generation);for(let n of this.testMethods)r.addMethod({access:zr.Public,isAsync:n.isAsync,name:n.name,parameters:[],body:n.body,annotations:[this.NUnit.Framework.Test]});return r}addTestMethod(r){this.testMethods.push(r)}};u();o();a();Gpe();u();o();a();var Kpe=require("assert");u();o();a();var zb=require("assert");u();o();a();var ZT={System:["AccessViolationException","Action","Activator","AggregateException","AppContext","AppDomain","AppDomainSetup","AppDomainUnloadedException","ApplicationException","ApplicationId","ArgIterator","ArgumentException","ArgumentNullException","ArgumentOutOfRangeException","ArithmeticException","Array","ArrayTypeMismatchException","AssemblyLoadEventArgs","AssemblyLoadEventHandler","AsyncCallback","Attribute","AttributeTargets","AttributeUsageAttribute","BadImageFormatException","Base64FormattingOptions","BitConverter","Boolean","Buffer","Byte","CannotUnloadAppDomainException","Char","CharEnumerator","CLSCompliantAttribute","Console","ConsoleCancelEventArgs","ConsoleCancelEventHandler","ConsoleColor","ConsoleKey","ConsoleKeyInfo","ConsoleModifiers","ConsoleSpecialKey","ContextBoundObject","ContextMarshalException","ContextStaticAttribute","Convert","CultureAwareComparer","DataMisalignedException","DateOnly","DateTime","DateTimeKind","DateTimeOffset","DayOfWeek","DBNull","Decimal","Delegate","DivideByZeroException","DllNotFoundException","Double","DuplicateWaitObjectException","EntryPointNotFoundException","Enum","Environment","EnvironmentVariableTarget","EventArgs","EventHandler","Exception","ExecutionEngineException","FieldAccessException","FlagsAttribute","FormatException","FormattableString","GC","GCCollectionMode","GCGenerationInfo","GCKind","GCMemoryInfo","GCNotificationStatus","Guid","Half","HashCode","IAsyncDisposable","IAsyncResult","ICloneable","IComparable","IConvertible","ICustomFormatter","IDisposable","IFormatProvider","IFormattable","Index","IndexOutOfRangeException","InsufficientExecutionStackException","InsufficientMemoryException","Int128","Int16","Int32","Int64","IntPtr","InvalidCastException","InvalidOperationException","InvalidProgramException","InvalidTimeZoneException","ISpanFormattable","IUtf8SpanFormattable","LoaderOptimization","LoaderOptimizationAttribute","LocalDataStoreSlot","MarshalByRefObject","Math","MathF","MemberAccessException","MemoryExtensions","MethodAccessException","MidpointRounding","MissingFieldException","MissingMemberException","MissingMethodException","ModuleHandle","MTAThreadAttribute","MulticastDelegate","MulticastNotSupportedException","NonSerializedAttribute","NotFiniteNumberException","NotImplementedException","NotSupportedException","Nullable","NullReferenceException","Object","ObjectDisposedException","ObsoleteAttribute","OperatingSystem","OperationCanceledException","OrdinalComparer","OutOfMemoryException","OverflowException","ParamArrayAttribute","PlatformID","PlatformNotSupportedException","Random","Range","RankException","ResolveEventArgs","ResolveEventHandler","RuntimeArgumentHandle","RuntimeFieldHandle","RuntimeMethodHandle","RuntimeTypeHandle","SByte","SerializableAttribute","Single","StackOverflowException","STAThreadAttribute","String","StringComparer","StringComparison","StringNormalizationExtensions","StringSplitOptions","SystemException","ThreadStaticAttribute","TimeOnly","TimeoutException","TimeProvider","TimeSpan","TimeZone","TimeZoneInfo","TimeZoneNotFoundException","Tuple","TupleExtensions","Type","TypeAccessException","TypeCode","TypedReference","TypeInitializationException","TypeLoadException","TypeUnloadedException","UInt128","UInt16","UInt32","UInt64","UIntPtr","UnauthorizedAccessException","UnhandledExceptionEventArgs","UnhandledExceptionEventHandler","UnitySerializationHolder","ValueTuple","ValueType","Version","Void","WeakReference","Buffers","Collections","ComponentModel","Diagnostics","Globalization","IO","Linq","Net","Numerics","Reflection","Resources","Runtime","Security","Text","Threading"],"System.Collections.Generic":["ByteEqualityComparer","CollectionExtensions","IEnumerable","KeyNotFoundException","KeyValuePair","NonRandomizedStringEqualityComparer","ReferenceEqualityComparer"],"System.IO":["BinaryReader","BinaryWriter","BufferedStream","Directory","DirectoryInfo","DirectoryNotFoundException","EndOfStreamException","EnumerationOptions","File","FileAccess","FileAttributes","FileInfo","FileLoadException","FileMode","FileNotFoundException","FileOptions","FileShare","FileStream","FileStreamOptions","FileSystemInfo","HandleInheritability","InvalidDataException","IOException","MatchCasing","MatchType","MemoryStream","Path","PathTooLongException","RandomAccess","SearchOption","SeekOrigin","Stream","StreamReader","StreamWriter","StringReader","StringWriter","TextReader","TextWriter","UnixFileMode","UnmanagedMemoryAccessor","UnmanagedMemoryStream","System.IO.Enumeration"],"System.Linq":["Enumerable"],"System.Net.Http":["HttpClient","HttpMethod"],"System.Threading":["AbandonedMutexException","ApartmentState","AsyncFlowControl","AutoResetEvent","CancellationToken","CancellationTokenRegistration","CancellationTokenSource","CompressedStack","ContextCallback","EventResetMode","EventWaitHandle","ExecutionContext","Interlocked","IOCompletionCallback","IThreadPoolWorkItem","ITimer","LazyInitializer","LazyThreadSafetyMode","Lock","LockRecursionException","LockRecursionPolicy","ManualResetEvent","ManualResetEventSlim","Monitor","Mutex","NativeOverlapped","Overlapped","ParameterizedThreadStart","PeriodicTimer","PreAllocatedOverlapped","ReaderWriterLockSlim","RegisteredWaitHandle","Semaphore","SemaphoreFullException","SemaphoreSlim","SendOrPostCallback","SpinLock","SpinWait","SynchronizationContext","SynchronizationLockException","Thread","ThreadAbortException","ThreadExceptionEventArgs","ThreadExceptionEventHandler","ThreadInterruptedException","ThreadPool","ThreadPoolBoundHandle","ThreadPriority","ThreadStart","ThreadStartException","ThreadState","ThreadStateException","Timeout","Timer","TimerCallback","Volatile","WaitCallback","WaitHandle","WaitHandleCannotBeOpenedException","WaitHandleExtensions","WaitOrTimerCallback","Tasks"],"System.Threading.Tasks":["ConcurrentExclusiveSchedulerPair","ConfigureAwaitOptions","Task","TaskAsyncEnumerableExtensions","TaskCanceledException","TaskCompletionSource","TaskContinuationOptions","TaskCreationOptions","TaskExtensions","TaskFactory","TaskScheduler","TaskSchedulerException","TaskStatus","TaskToAsyncResult","UnobservedTaskExceptionEventArgs","ValueTask","Sources"]};var Cdt=new Set(["abstract","as","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","virtual","void","volatile","while"]);var Tdt=new Set(["from","where","select","orderby","groupby","into","let","join","on","equals"]),Fdt=new Set(["async","await"]),Rdt=new Set(["yield"]),qdt=new Set(["var","dynamic"]),Ndt=new Set(["using","alias"]);var Idt=new Set(["required","scoped","unmanaged","managed"]),Ldt=new Set(["when","and","or","not"]),Udt=new Set(["Equals","GetHashCode","ToString","GetType","MemberwiseClone","Finalize"]),zdt=new Set([...Cdt,...Tdt,...Fdt,...Rdt,...qdt,...Ndt,...Idt,...Ldt]),G4=class{constructor(e,r,n){te(this,"registry");te(this,"name");te(this,"jsonPath");this.registry=e,this.name=r,this.jsonPath=n}};var K4=class{constructor(e){te(this,"scope");te(this,"byName",new Map);te(this,"byPath",new Map);te(this,"redirections",new Map);this.scope=e}[Symbol.iterator](){return this.byName.values()}has(e){return this.byName.has(e)}getByJsonPath(e){return this.byPath.get(e)}getByName(e){return this.byName.get(e)}getRedirectedName(e){return this.redirections.get(e)}set(e){this.byName.has(e.name)&&(0,zb.fail)(`set: ${e.name} in ${this.scope.fullyQualifiedName} already exists`),e.jsonPath&&this.byPath.has(e.jsonPath)&&(0,zb.fail)(`set: ${e.name} in ${this.scope.fullyQualifiedName} already exists by jsonPath`),this.byName.set(e.name,e),e.jsonPath&&this.byPath.set(e.jsonPath,e)}redirect(e,r){this.redirections.has(e)&&(0,zb.fail)(`redirect: ${e} in ${this.scope.fullyQualifiedName} already has a redirect`),this.redirections.set(e,r)}},JT=class extends G4{constructor(r,n,i,c){super(r,n);te(this,"namespace");te(this,"fullyQualifiedName");te(this,"fields");te(this,"methods");this.namespace=i,this.fullyQualifiedName=c,this.fields=new K4(this),this.methods=new K4(this)}isKeyword(r){return zdt.has(r)}isBuiltinMemberName(r){return Udt.has(r)}isTypeName(r){return this.name===r}isField(r){return this.fields.has(r)}isMethod(r){return this.methods.has(r)}isMember(r){return this.isField(r)||this.isMethod(r)}nameBlocked(r){if(this.isKeyword(r))return"keyword";if(this.isBuiltinMemberName(r))return"builtin";if(this.isTypeName(r))return"typeName";if(this.isField(r))return"field";if(this.isMethod(r))return"method"}getAlternativeName(r){let n=`${r}_`,i=2;for(;this.nameBlocked(n);)n=`${r}_${i}`,i++;return n}getFieldByJsonPath(r){return r!==void 0?this.fields.getByJsonPath(r):void 0}getFieldByName(r){return this.fields.getByName(r)}getRedirectedFieldName(r){return this.fields.getRedirectedName(r)}registerField(r,n,i){let c=this.registry.model.jsonPath(n);if(c){let f=this.fields.getByJsonPath(c);if(f)return f.name}let s=this.fields.getByName(r);if(s&&c===s.jsonPath)return r;switch(this.nameBlocked(r)){case"field":n&&pt.Provenance(n)&&n.explicit||(0,zb.fail)(`Field ${r} already exists - attempting to add a duplicate field with the same name that is not an explicitly named property`);break;case"keyword":case"builtin":case"typeName":case"method":break;default:return this.fields.set(new Z4(this.registry,r,this,c,i)),this.registry.setFieldNameShortcut(c,r),r}let l=this.getAlternativeName(r);return this.fields.set(new Z4(this.registry,l,this,c,i)),this.fields.redirect(r,l),this.registry.setFieldNameShortcut(c,l),l}getFieldName(r,n){let i=this.getFieldByJsonPath(this.registry.model.jsonPath(r))?.name;if(i)return i;if(pt.Provenance(r)){let l=this.getRedirectedFieldName(n);if(l)return l;let f=this.getFieldByName(n);return f?this.registry.model.provenance(f.jsonPath)?.explicit?n:`${n}_`:n}let c=this.getFieldByName(n);if(c)return this.registry.model.provenance(c.jsonPath)?.explicit?n:c.name;let s=this.getRedirectedFieldName(n);if(s)return s;this.isMethod(n)}},YT=class extends G4{constructor(r,n,i,c){super(r,n,c);te(this,"scope");this.scope=i}},Z4=class extends YT{constructor(r,n,i,c,s){super(r,n,i,c);te(this,"field");this.field=s}};var Kg=class t{constructor(e){te(this,"generation");te(this,"classReferenceByJsonPath",new Map);te(this,"typeRegistry",new Map);te(this,"namespaceRegistry",new Map);te(this,"typeNames",new Map);te(this,"namespaceNames",new Map);te(this,"implicitNamespaces",new Set);te(this,"shortcuts",new Map);te(this,"knownBuiltInIdentifiers",new Set(["Text","Json","Xml","Security","Collections","Data","Diagnostics","Globalization","Math","Reflection","Runtime","Security","Serialization","Threading","Xml"]));this.generation=e,this.initializeBuiltIns()}get csharp(){return this.generation.csharp}get model(){return this.generation.model}initializeBuiltIns(){for(let[e,r]of Object.entries(ZT))e.split(".").forEach(n=>this.knownBuiltInIdentifiers.add(n)),r.forEach(n=>this.knownBuiltInIdentifiers.add(n));for(let[e,r]of Object.entries(ZT)){for(let i of r)this.typeNames.set(i,new Set([e]));let n=e.split(".")[0];n&&this.typeNames.set(n,new Set([e]))}this.typeNames.set("System",new Set(["System"])),this.typeNames.set("NUnit",new Set(["NUnit"])),this.typeNames.set("OneOf",new Set(["OneOf"]))}setFieldNameShortcut(e,r){if(e){let n=this.shortcuts.get(e);n&&n!==r&&(0,zb.fail)(`BAD_BAD_BAD setFieldNameShortcut: ${e} already has a name: ${n} - while setting to ${r} - if this is happening, then you could be getting back the wrong name later!`),this.shortcuts.set(e,r)}}getFieldNameByOrigin(e){return this.shortcuts.get(this.model.jsonPath(e)??">ignore<")}isKnownBuiltInIdentifier(e){return!e||typeof e!="string"?!1:this.knownBuiltInIdentifiers.has(e)}isKnownNamespace(e){return!e||typeof e!="string"?!1:this.namespaceRegistry.has(e)}isRegisteredTypeName(e){return this.typeRegistry.has(e)}isAmbiguousTypeName(e){return e?(this.typeNames.get(e)?.size??0)>1:!1}isAmbiguousNamespaceName(e){return e?(this.namespaceNames.get(e)?.size??0)>1:!1}static fullyQualifiedNameOf(e){return e.enclosingType?`${e.namespace}.${e.enclosingType.name}.${e.name}`:`${e.namespace}.${e.name}`}registerNamespace(e,r){this.namespaceRegistry.has(e)&&this.namespaceRegistry.get(e)!==r||this.namespaceRegistry.set(e,r)}trackType(e,r){let{name:n,namespace:i,enclosingType:c,fullyQualifiedName:s,origin:l}=e;if(l){let f=this.model.jsonPath(l)??(0,zb.fail)(`JsonPath not found for origin: ${JSON.stringify(l).substring(0,100)}`);this.classReferenceByJsonPath.set(f,e)}if(r&&r!==s&&!this.typeRegistry.has(r)&&this.typeRegistry.set(r,e),!this.typeRegistry.has(s)){this.typeRegistry.set(s,e);for(let f of this.allNamespacesOf(i))this.registerNamespace(f,f);c||this.trackTypeName(n,i);for(let f of[this.generation.namespaces.root,...this.implicitNamespaces])if(i.startsWith(f)){let b=i.split(".")[f.split(".").length];b&&this.trackTypeName(b,i)}}return e}addImplicitNamespace(e){this.implicitNamespaces.add(e)}isNamespaceImplicit(e){return this.implicitNamespaces.has(e)}get implicitlyImportedNamespaces(){return[...this.implicitNamespaces]}trackTypeName(e,r){this.typeNames.has(e)?this.typeNames.get(e)?.add(r):this.typeNames.set(e,new Set([r]));let n=r.split("."),i="";for(let c of n)this.namespaceNames.has(c)?this.namespaceNames.get(c)?.add(i):this.namespaceNames.set(c,new Set([i])),i=i?`${i}.${c}`:c}allNamespacesOf(e){if(!e||typeof e!="string")return new Set;let r="",n=new Set;for(let i of e.split("."))i.trim()&&(r=r?`${r}.${i}`:`${i}`,n.add(r));return n}registerClassReference(e,r){let{name:n,namespace:i,enclosingType:c,origin:s}=e,l=this.model.jsonPath(s),f=(l?this.classReferenceByJsonPath.get(l):void 0)??this.typeRegistry.get(r),b=this.model.jsonPath(f?.origin),_=b&&l?b===l?"match":"mismatch":"no origin";if(f&&_!=="mismatch")return new In({name:f.name,namespace:f.namespace,enclosingType:f.enclosingType,fullyQualifiedName:f.fullyQualifiedName,namespaceAlias:e.namespaceAlias,fullyQualified:e.fullyQualified,generics:e.generics,global:e.global,origin:f.origin??s,isCollection:f.isCollection,isReferenceType:f.isReferenceType,multipartMethodName:f.multipartMethodName,multipartMethodNameForCollection:f.multipartMethodNameForCollection},f.scope,this.generation);let O=!1,v=this.resolveNamespace(i);v!==i&&(i=v,O=!0);let w;e:for(;;){w=t.fullyQualifiedNameOf({name:n,namespace:i,enclosingType:c});let P="",T=i.split(".");for(let S=0;S<T.length;S++)if(P=P?`${P}.${T[S]}`:`${T[S]}`,this.typeRegistry.has(P)){T[S]=`${T[S]}_`,i=T.join("."),O=!0;continue e}if(O&&this.registerNamespace(e.namespace,i),_==="mismatch"&&f?.name===n){n=`${n}_`,O=!0;continue e}if(this.namespaceRegistry.has(w)){n=`${n}_`,O=!0;continue e}break}return this.trackType(new In({name:n,namespace:i,enclosingType:c,namespaceAlias:e.namespaceAlias,fullyQualified:e.fullyQualified,generics:e.generics,global:e.global,fullyQualifiedName:w,origin:s,isCollection:e.isCollection,isReferenceType:e.isReferenceType,multipartMethodName:e.multipartMethodName,multipartMethodNameForCollection:e.multipartMethodNameForCollection},new JT(this,n,i,w),this.generation),r)}resolveNamespace(e){let r=this.namespaceRegistry.get(e);if(r!==void 0)return r;let n=e.split(".");for(let i=n.length-1;i>=0;i--){let c=n.slice(0,i).join(".");if(this.namespaceRegistry.has(c)){let s=this.namespaceRegistry.get(c);if(s!==void 0){let l=n.slice(i).join("."),f=`${s}.${l}`;return this.registerNamespace(e,f),f}}}return e}canonicalizeNamespace(e){let r=this.namespaceRegistry.get(e);if(r!==void 0)return r;let n=!1,i=e;e:for(;;){let c="",s=i.split(".");for(let l=0;l<s.length;l++)if(c=c?`${c}.${s[l]}`:`${s[l]}`,this.typeRegistry.has(c)){s[l]=`${s[l]}_`,i=s.join("."),n=!0;continue e}break}return n&&this.registerNamespace(e,i),i}};var J4=class{constructor(e){te(this,"generation");te(this,"frozen",!1);te(this,"extraClassReferences",new Map);te(this,"InstantiatedPrimitive",{string:e=>new On({type:"string",value:e},this.generation),boolean:e=>new On({type:"boolean",value:e},this.generation),integer:e=>new On({type:"integer",value:e},this.generation),long:e=>new On({type:"long",value:e},this.generation),uint:e=>new On({type:"uint",value:e},this.generation),ulong:e=>new On({type:"ulong",value:e},this.generation),float:e=>new On({type:"float",value:e},this.generation),double:e=>new On({type:"double",value:e},this.generation),date:e=>new On({type:"date",value:e},this.generation),dateTime:(e,r=!0)=>new On({type:"dateTime",value:e,parse:r},this.generation),uuid:e=>new On({type:"uuid",value:e},this.generation),null:()=>new On({type:"null"},this.generation)});te(this,"Literal",{class_:({reference:e,fields:r})=>new mt.Class_(e,r,this.generation),dictionary:({keyType:e,valueType:r,entries:n})=>new mt.Dictionary(e,r,n,this.generation),list:({valueType:e,values:r})=>new mt.List(e,r,this.generation),set:({valueType:e,values:r})=>new mt.Set(e,r,this.generation),boolean:e=>new mt.Boolean(e,this.generation),float:e=>new mt.Float(e,this.generation),date:e=>new mt.Date(e,this.generation),datetime:e=>new mt.DateTime(e,this.generation),decimal:e=>new mt.Decimal(e,this.generation),double:e=>new mt.Double(e,this.generation),integer:e=>new mt.Integer(e,this.generation),long:e=>new mt.Long(e,this.generation),uint:e=>new mt.Uint(e,this.generation),ulong:e=>new mt.Ulong(e,this.generation),reference:e=>new mt.Reference(e,this.generation),string:e=>new mt.String(e,this.generation),null:()=>new mt.Null(this.generation),nop:()=>new mt.Nop(this.generation),unknown:e=>new mt.Unknown(e,this.generation)});te(this,"VALID_READ_ONLY_MEMORY_TYPES",new Set(["int","long","uint","ulong","string","bool","float","double"]));this.generation=e}get model(){return this.generation.model}classReference(e){return this.classReferenceInternal(e)}classReferenceInternal(e){if(!e.name&&"origin"in e&&e.origin&&(e.name=this.model.getClassNameFor(e.origin)),e.enclosingType){if(e.namespace)throw new Error("ClassReference: Both enclosingType and namespace cannot be provided");e.namespace=e.enclosingType.namespace}let r=Kg.fullyQualifiedNameOf(e);if(this.frozen&&!this.generation.registry.isRegisteredTypeName(r)){let n=this.extraClassReferences.get(r);n||(n=new Set,this.extraClassReferences.set(r,n)),n.add(`${r} -
172
- ${r2()}`)}return this.generation.registry.registerClassReference(e,r)}freezeClassReferences(){this.frozen=!0}getPropertyName(e,r){let n=this.model.getPropertyNameFor(r),i=this.model.origin(r)??(0,Kpe.fail)(`Origin not found for property: ${JSON.stringify(r).substring(0,100)}`),c=e.getFieldName(i,n);return c||n}class_(e){let r=e;return"reference"in e&&(r={...e.reference,...e}),new Yp(r,this.generation)}testClass(e){return new Hg(e,this.generation)}annotation(e){return new I0(e,this.generation)}annotationGroup(e){return new Rg(e,this.generation)}instantiateClass(e){return new _g(e,this.generation)}invokeMethod(e){return new Og(e,this.generation)}codeblock(e){return new vh(e,this.generation)}code(){return new mh({},this.generation)}anonymousFunction(e){return new qg(e)}parameter(e){return new Ma(e,this.generation)}interface_(e){return new Vg(e,this.generation)}enum_(e){return new $g(e,this.generation)}dictionary(e){return new gg(e,this.generation)}list(e){return new mg(e,this.generation)}readOnlyMemory(e){return new wg(e,this.generation)}set(e){return new Pg(e,this.generation)}switch_(e){return new Ig(e,this.generation)}ternary(e){return new Lg(e,this.generation)}and(e){return new Fg(e,this.generation)}or(e){return new Ng(e,this.generation)}enumInstantiation(e){return new vg(e,this.generation)}string_(e){return new Eg(e,this.generation)}xmlDocBlock(e){return new Ph(e,this.generation)}xmlDocBlockOf(e){return e instanceof Ph?e:new Ph(e,this.generation)}validateReadOnlyMemoryTypes(){for(let e of this.generation.settings.readOnlyMemoryTypes)if(!this.VALID_READ_ONLY_MEMORY_TYPES.has(e))throw new Error(`Type "${e}" is not a valid 'read-only-memory-types' custom config option; expected one of ${JSON.stringify(this.VALID_READ_ONLY_MEMORY_TYPES)}.`)}};u();o();a();function vt(t){let e={},r={};for(let[n,i]of Object.entries(t))i.length===0?Object.defineProperty(r,n,{get(){return n in e||(e[n]=i()),e[n]},enumerable:!0,configurable:!0}):r[n]=i;return r}u();o();a();var Y4=class{constructor(e){te(this,"generation");te(this,"System",vt({Action:e=>this.csharp.classReference({name:"Action",namespace:"System",generics:e||void 0,multipartMethodName:null,multipartMethodNameForCollection:null,isReferenceType:!0}),Func:(e,r)=>this.csharp.classReference({name:"Func",namespace:"System",generics:e?r?[...e,r]:e:r?[r]:void 0,multipartMethodName:null,multipartMethodNameForCollection:null,isReferenceType:!0}),DateOnly:()=>this.csharp.classReference({name:"DateOnly",namespace:"System"}),DateTime:()=>this.csharp.classReference({name:"DateTime",namespace:"System"}),Enum:()=>this.csharp.classReference({name:"Enum",namespace:"System"}),Exception:()=>this.csharp.classReference({name:"Exception",namespace:"System"}),ReadOnlyMemory:e=>this.csharp.classReference({name:"ReadOnlyMemory",namespace:"System",generics:[e]}),Serializable:()=>this.csharp.classReference({name:"SerializableAttribute",namespace:"System"}),String:()=>this.csharp.classReference({name:"String",namespace:"System"}),Type:()=>this.csharp.classReference({name:"Type",namespace:"System",isReferenceType:!0,multipartMethodName:null,multipartMethodNameForCollection:null,fullyQualified:!0}),TimeSpan:()=>this.csharp.classReference({name:"TimeSpan",namespace:"System"}),Uri:()=>this.csharp.classReference({name:"Uri",namespace:"System"}),UriBuilder:()=>this.csharp.classReference({name:"UriBuilder",namespace:"System"}),Runtime:()=>vt({Serialization:()=>vt({EnumMember:()=>this.csharp.classReference({name:"EnumMemberAttribute",namespace:"System.Runtime.Serialization"})})}),Collections:()=>vt({Generic:()=>vt({IAsyncEnumerable:e=>this.csharp.classReference({name:"IAsyncEnumerable",namespace:"System.Collections.Generic",generics:e?[e]:void 0}),IEnumerable:e=>this.csharp.classReference({name:"IEnumerable",namespace:"System.Collections.Generic",generics:e?[e]:void 0}),KeyValuePair:(e,r)=>this.csharp.classReference({name:"KeyValuePair",namespace:"System.Collections.Generic",generics:e&&r?[e,r]:void 0}),List:e=>this.csharp.classReference({name:"List",namespace:"System.Collections.Generic",generics:e?[e]:void 0,isCollection:!0}),HashSet:e=>this.csharp.classReference({name:"HashSet",namespace:"System.Collections.Generic",generics:e?[e]:void 0,isCollection:!0}),Dictionary:(e,r)=>this.csharp.classReference({name:"Dictionary",namespace:"System.Collections.Generic",generics:e&&r?[e,r]:void 0,isCollection:!0}),IDictionary:(e,r)=>this.csharp.classReference({name:"IDictionary",namespace:"System.Collections.Generic",generics:[e,r]})}),Linq:()=>vt({Enumerable:()=>this.csharp.classReference({name:"Enumerable",namespace:"System.Linq"})})}),Globalization:()=>vt({DateTimeStyles:()=>this.csharp.classReference({name:"DateTimeStyles",namespace:"System.Globalization"})}),Linq:()=>vt({Enumerable:()=>this.csharp.classReference({name:"Enumerable",namespace:"System.Linq"})}),Net:()=>vt({Http:()=>vt({HttpClient:()=>this.csharp.classReference({name:"HttpClient",namespace:"System.Net.Http"}),HttpMethod:()=>this.csharp.classReference({name:"HttpMethod",namespace:"System.Net.Http"}),HttpResponseHeaders:()=>this.csharp.classReference({name:"HttpResponseHeaders",namespace:"System.Net.Http.Headers"})}),ServerSentEvents:()=>vt({SseEvent:()=>this.csharp.classReference({name:"SseEvent",namespace:"System.Net.ServerSentEvents"}),SseParser:()=>this.csharp.classReference({name:"SseParser",namespace:"System.Net.ServerSentEvents"})}),WebSockets:()=>vt({ClientWebSocketOptions:()=>this.csharp.classReference({name:"ClientWebSocketOptions",namespace:"System.Net.WebSockets"})})}),IO:()=>vt({MemoryStream:()=>this.csharp.classReference({name:"MemoryStream",namespace:"System.IO"}),Stream:()=>this.csharp.classReference({name:"Stream",namespace:"System.IO"}),StreamReader:()=>this.csharp.classReference({name:"StreamReader",namespace:"System.IO"})}),Text:()=>vt({Encoding:()=>this.csharp.classReference({name:"Encoding",namespace:"System.Text"}),Encoding_UTF8:()=>this.csharp.classReference({name:"UTF8",enclosingType:this.csharp.classReference({name:"Encoding",namespace:"System.Text"})}),Json:()=>vt({JsonElement:()=>this.csharp.classReference({name:"JsonElement",namespace:"System.Text.Json"}),JsonDocument:()=>this.csharp.classReference({name:"JsonDocument",namespace:"System.Text.Json"}),JsonException:()=>this.csharp.classReference({name:"JsonException",namespace:"System.Text.Json"}),Utf8JsonReader:()=>this.csharp.classReference({name:"Utf8JsonReader",namespace:"System.Text.Json"}),JsonSerializerOptions:()=>this.csharp.classReference({name:"JsonSerializerOptions",namespace:"System.Text.Json"}),JsonSerializer:()=>this.csharp.classReference({name:"JsonSerializer",namespace:"System.Text.Json"}),Utf8JsonWriter:()=>this.csharp.classReference({name:"Utf8JsonWriter",namespace:"System.Text.Json"}),Nodes:()=>vt({JsonNode:()=>this.csharp.classReference({name:"JsonNode",namespace:"System.Text.Json.Nodes"}),JsonObject:()=>this.csharp.classReference({name:"JsonObject",namespace:"System.Text.Json.Nodes"})}),Serialization:()=>vt({IJsonOnDeserialized:()=>this.csharp.classReference({name:"IJsonOnDeserialized",namespace:"System.Text.Json.Serialization"}),IJsonOnSerializing:()=>this.csharp.classReference({name:"IJsonOnSerializing",namespace:"System.Text.Json.Serialization"}),JsonOnDeserializedAttribute:()=>this.csharp.classReference({name:"JsonOnDeserializedAttribute",namespace:"System.Text.Json.Serialization"}),JsonExtensionData:()=>this.csharp.classReference({name:"JsonExtensionDataAttribute",namespace:"System.Text.Json.Serialization"}),JsonConverter:e=>this.csharp.classReference({name:"JsonConverter",namespace:"System.Text.Json.Serialization",generics:e?[e]:void 0}),JsonIgnore:()=>this.csharp.classReference({name:"JsonIgnoreAttribute",namespace:"System.Text.Json.Serialization"}),JsonPropertyName:()=>this.csharp.classReference({name:"JsonPropertyNameAttribute",namespace:"System.Text.Json.Serialization"})})})}),Threading:()=>vt({CancellationToken:()=>this.csharp.classReference({name:"CancellationToken",namespace:"System.Threading"}),Tasks:()=>vt({Task:e=>this.csharp.classReference({name:"Task",namespace:"System.Threading.Tasks",generics:e?[e]:void 0}),ValueTask:e=>this.csharp.classReference({name:"ValueTask",namespace:"System.Threading.Tasks",generics:e?[e]:void 0})})}),ComponentModel:()=>vt({INotifyPropertyChanged:()=>this.csharp.classReference({name:"INotifyPropertyChanged",namespace:"System.ComponentModel"}),PropertyChangedEventHandler:()=>this.csharp.classReference({name:"PropertyChangedEventHandler",namespace:"System.ComponentModel"})}),IAsyncDisposable:()=>this.csharp.classReference({name:"IAsyncDisposable",namespace:"System"}),IDisposable:()=>this.csharp.classReference({name:"IDisposable",namespace:"System"})}));te(this,"NUnit",vt({Framework:()=>vt({TestFixture:()=>this.csharp.classReference({name:"TestFixture",namespace:"NUnit.Framework"}),Test:()=>this.csharp.classReference({name:"Test",namespace:"NUnit.Framework"}),OneTimeTearDown:()=>this.csharp.classReference({name:"OneTimeTearDown",namespace:"NUnit.Framework"}),OneTimeSetUp:()=>this.csharp.classReference({name:"OneTimeSetUp",namespace:"NUnit.Framework"}),SetUpFixture:()=>this.csharp.classReference({name:"SetUpFixture",namespace:"NUnit.Framework"})})}));te(this,"OneOf",vt({OneOf:e=>this.csharp.classReference({name:"OneOf",namespace:"OneOf",generics:e}),OneOfBase:e=>this.csharp.classReference({name:"OneOfBase",namespace:"OneOf",generics:e})}));te(this,"Google",vt({Protobuf:()=>vt({WellKnownTypes:()=>vt({Struct:()=>this.csharp.classReference({name:"Struct",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),Value:()=>this.csharp.classReference({name:"Value",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),ListValue:()=>this.csharp.classReference({name:"ListValue",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),Timestamp:()=>this.csharp.classReference({name:"Timestamp",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"})})})}));te(this,"WireMock",vt({Server:()=>this.csharp.classReference({name:"WireMockServer",namespace:"WireMock.Server"}),WireMockServerSettings:()=>this.csharp.classReference({name:"WireMockServerSettings",namespace:"WireMock.Settings"}),WireMockConsoleLogger:()=>this.csharp.classReference({name:"WireMockConsoleLogger",namespace:"WireMock.Logging"})}));te(this,"Grpc",vt({Core:()=>vt({RpcException:()=>this.csharp.classReference({name:"RpcException",namespace:"Grpc.Core"})})}));this.generation=e}get csharp(){return this.generation.csharp}};u();o();a();var Sm=require("assert");function Zpe(t){return t.split(".").filter(e=>!["name","camelCase","snakeCase","screamingSnakeCase","pascalCase"].includes(e)).join(".")}var X4=class{constructor(e,r){te(this,"generation");te(this,"indexByObject",new Map);te(this,"indexByPath",new Map);te(this,"explicitByObject",new Map);te(this,"explicitByPath",new Map);te(this,"root");te(this,"ir");this.generation=r,this.root=this.createIndex(e),this.ir=e}get csharp(){return this.generation.csharp}get registry(){return this.generation.registry}createIndex(e,r="",n){let i=Zpe(n?.jsonPath?`${n.jsonPath}.${r}`:r);if(this.indexByPath.has(i)){n||(0,Sm.fail)(`Parent provenance not found for node: ${JSON.stringify(e).substring(0,100)}`),this.indexByObject.set(e,n);for(let[s,l]of Object.entries(e))typeof l=="object"&&l!==null&&this.createIndex(l,s,n);return n}let c={jsonPath:i,name:r,node:e,parent:n};this.indexByObject.set(e,c),this.indexByPath.set(i,c);for(let[s,l]of Object.entries(e))typeof l=="object"&&l!==null&&this.createIndex(l,s,c);return c}staticExplicit(e){return this.explicit(this.ir,e)}explicit(e,r){let n=this.provenance(e)??(0,Sm.fail)(`Provenance not found for node: ${JSON.stringify(e).substring(0,100)}`),i={...n,jsonPath:Zpe(`${n.jsonPath}+${r}`),name:r,node:n.node,parent:n,explicit:!0},c=this.explicitByObject.get(n.node);return c?c.add(i):this.explicitByObject.set(n.node,new Set([i])),this.explicitByPath.set(i.jsonPath,i),i}provenance(e){if(e!==void 0)return pt.string(e)?this.explicitByPath.get(e)??this.indexByPath.get(e):pt.Provenance(e)?this.explicitByPath.get(e.jsonPath)??this.indexByPath.get(e.jsonPath):this.indexByObject.get(e)}origin(e){let r=this.provenance(e);return r?.explicit?r:r?.node}irNode(e){return this.provenance(e)?.node}jsonPath(e){return this.provenance(e)?.jsonPath}getEnumValueName(e,r){let n=pt.IR.ExampleEnumType(r)?r.value.name:r.name,i=e.values.find(c=>this.nameEquals(c.name.name,n));return i?this.getPropertyNameFor(i):(0,Sm.fail)(`Unexpected - can't find enum value ${n} in enum`)}getPropertyNameFor(e){let r=this.registry.getFieldNameByOrigin(e);if(r)return r;if(pt.Provenance(e))return e.name;if("name"in e){if(pt.IR.NameAndWireValue(e.name))return e.name.name.pascalCase.safeName;if(pt.IR.Name(e.name))return e.name.pascalCase.safeName;if(typeof e.name=="string")return e.name}if("pascalCase"in e)return e.pascalCase.safeName;throw new Error(`Unknown property type: ${this.jsonPath(e)}`)}getClassNameFor(e){if(pt.Provenance(e))return e.name;if("name"in e){if(pt.IR.TypeDeclaration(e)||pt.IR.NameAndWireValue(e.name))return e.name.name.pascalCase.safeName;if(pt.IR.Name(e.name))return e.name.pascalCase.safeName;if(typeof e.name=="string")return e.name}if("pascalCase"in e)return e.pascalCase.safeName;throw new Error(`Unknown property type: ${JSON.stringify(e)}`)}nameEquals(e,r){return e.camelCase.safeName===r.camelCase.safeName}dereferenceType(e){let r=pt.string(e)?e:pt.IR.NamedType(e)||pt.IR.DeclaredTypeName(e)?e.typeId:pt.IR.ExampleNamedType(e)?e.typeName.typeId:e.name.typeId,n=this.irNode(this.ir.types[r]);if(pt.IR.TypeDeclaration(n))return{typeId:r,typeDeclaration:n};(0,Sm.fail)(`dereferenceType: typeId ${r} not resolved.`)}};var Dm=class{constructor(e,r,n,i,c={makeRelativeFilePath:s=>s,makeAbsoluteFilePath:s=>s,getNamespaceForTypeId:s=>"",getDirectoryForTypeId:s=>"",getCoreAsIsFiles:()=>[],getCoreTestAsIsFiles:()=>[],getPublicCoreAsIsFiles:()=>[],getAsyncCoreAsIsFiles:()=>[],getChildNamespaceSegments:s=>[]}){te(this,"intermediateRepresentation");te(this,"apiName");te(this,"customConfig");te(this,"generatorConfig");te(this,"support");te(this,"ir");te(this,"dir");te(this,"csharp",new J4(this));te(this,"registry",new Kg(this));te(this,"model");te(this,"extern",new Y4(this));te(this,"settings",vt({namespace:()=>this.customConfig.namespace??N4(I4(`${this.generatorConfig.organization}_${this.apiName}`)),readOnlyMemoryTypes:()=>this.customConfig["read-only-memory-types"]??[],simplifyObjectDictionaries:()=>this.customConfig["simplify-object-dictionaries"]??!1,useFullyQualifiedNamespaces:()=>this.customConfig["experimental-fully-qualified-namespaces"]??!1,useDotnetFormat:()=>this.customConfig["experimental-dotnet-format"]??!1,enableWebsockets:()=>this.customConfig["experimental-enable-websockets"]??!1,enableReadonlyConstants:()=>this.customConfig["experimental-readonly-constants"]??!1,enableExplicitNullableOptional:()=>this.customConfig["experimental-explicit-nullable-optional"]??!1,useDefaultRequestParameterValues:()=>this.customConfig["use-default-request-parameter-values"]??!1,temporaryWebsocketEnvironments:()=>this.customConfig["temporary-websocket-environments"]??{},baseApiExceptionClassName:()=>this.customConfig["base-api-exception-class-name"]??"",baseExceptionClassName:()=>this.customConfig["base-exception-class-name"]??"",shouldGeneratedDiscriminatedUnions:()=>this.customConfig["use-discriminated-unions"]??!0,shouldGenerateUndiscriminatedUnions:()=>this.customConfig["use-undiscriminated-unions"]??!1,exportedClientClassName:()=>this.customConfig["exported-client-class-name"]??"",clientClassName:()=>this.customConfig["client-class-name"]??"",rootNamespaceForCoreClasses:()=>this.customConfig["root-namespace-for-core-classes"]??!0,packageId:()=>this.customConfig["package-id"]??"",isForwardCompatibleEnumsEnabled:()=>this.customConfig["enable-forward-compatible-enums"]??this.customConfig["experimental-enable-forward-compatible-enums"]??!0,websocketEnvironments:()=>this.customConfig["temporary-websocket-environments"]??{},customPagerName:()=>this.customConfig["custom-pager-name"]??"",environmentClassName:()=>this.customConfig["environment-class-name"]??"",generateErrorTypes:()=>this.customConfig["generate-error-types"]??!0,shouldInlinePathParameters:()=>this.customConfig["inline-path-parameters"]??!0,includeExceptionHandler:()=>this.customConfig["include-exception-handler"]??!1,exceptionInterceptorClassName:()=>this.customConfig["exception-interceptor-class-name"]??"",shouldGenerateMockServerTests:()=>this.customConfig["generate-mock-server-tests"]??this.customConfig["enable-wire-tests"]??!0,rootClientAccess:()=>this.customConfig["root-client-class-access"]=="internal"?zr.Internal:zr.Public,extraDependencies:()=>this.customConfig["extra-dependencies"]??{},pascalCaseEnvironments:()=>this.customConfig["pascal-case-environments"]??!0,explicitNamespaces:()=>this.customConfig["explicit-namespaces"]===!0,outputPath:()=>{let e=this.customConfig["output-path"];return e==null?{library:"src",test:"src",solution:".",other:"."}:typeof e=="string"?{library:e,test:e,solution:".",other:"."}:{library:e.library??"src",test:e.test??"src",solution:e.solution??".",other:e.other??"."}}}));te(this,"constants",{folders:vt({mockServerTests:()=>this.support.makeRelativeFilePath("Unit/MockServer"),types:()=>"Types",exceptions:()=>"Exceptions",src:()=>"src",protobuf:()=>"proto",serializationTests:()=>this.support.makeRelativeFilePath("Unit/Serialization"),project:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.sourceFiles,this.support.makeRelativeFilePath(this.names.files.project))),sourceFiles:()=>this.support.makeRelativeFilePath(this.constants.folders.src),coreFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.project,this.support.makeRelativeFilePath(this.constants.defaults.core))),publicCoreFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.project,this.support.makeRelativeFilePath(this.constants.defaults.core),this.support.makeRelativeFilePath(this.constants.defaults.publicCore))),testFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.sourceFiles,this.support.makeRelativeFilePath(this.names.files.testProject)))}),formatting:vt({indent:()=>" "}),defaults:vt({core:()=>"Core",publicCore:()=>"Public",version:()=>"0.0.0"})});te(this,"namespaces",vt({root:()=>this.settings.namespace,core:()=>`${this.namespaces.root}.Core`,test:()=>this.registry.canonicalizeNamespace(`${this.namespaces.root}.Test`),testUtils:()=>`${this.namespaces.test}.Utils`,mockServerTest:()=>`${this.namespaces.test}.Unit.MockServer`,publicCore:()=>this.namespaces.root,webSocketsCore:()=>`${this.namespaces.core}.WebSockets`,publicCoreTest:()=>`${this.namespaces.root}.Test.PublicCore`,asIsTestUtils:()=>`${this.namespaces.root}.Test.Utils`,publicCoreClasses:()=>this.settings.rootNamespaceForCoreClasses?this.namespaces.root:this.namespaces.core,implicit:()=>new Set(["System","System.Collections.Generic","System.IO","System.Linq","System.Threading","System.Threading.Tasks","System.Net.Http"])}));te(this,"names",{classes:vt({baseApiException:()=>this.settings.baseApiExceptionClassName||`${this.names.project.clientPrefix}ApiException`,baseException:()=>this.settings.baseExceptionClassName||`${this.names.project.clientPrefix}Exception`,rootClient:()=>this.settings.clientClassName||`${this.names.project.clientPrefix}Client`,rootClientForSnippets:()=>this.settings.exportedClientClassName||this.names.classes.rootClient,customPager:()=>this.settings.customPagerName||`${this.names.project.packageId.replace(/[^a-zA-Z0-9]/g,"")}Pager`,environment:()=>this.settings.environmentClassName||`${this.names.project.clientPrefix}Environment`,exceptionInterceptor:()=>this.settings.exceptionInterceptorClassName||`${this.names.project.packageId.replace(/[^a-zA-Z0-9]/g,"")}ExceptionInterceptor`}),project:vt({client:()=>N4(I4(`${this.generatorConfig.organization}_${this.generatorConfig.workspaceName}`)),clientPrefix:()=>this.settings.exportedClientClassName||this.settings.clientClassName||this.names.project.client,packageId:()=>this.settings.packageId||this.namespaces.root}),files:vt({project:()=>this.namespaces.root,testProject:()=>`${this.namespaces.root}.Test`}),methods:vt({mockOauth:()=>"MockOAuthEndpoint",mockInferredAuth:()=>"MockInferredAuthEndpoint",getAccessTokenAsync:()=>"GetAccessTokenAsync",getAuthHeadersAsync:()=>"GetAuthHeadersAsync"}),variables:vt({client:()=>"client",response:()=>"response",httpRequest:()=>"httpRequest",sendRequest:()=>"sendRequest",responseBody:()=>"responseBody",query:()=>"_query",headers:()=>"_headers"}),parameters:vt({cancellationToken:()=>"cancellationToken",requestOptions:()=>"options",idempotentOptions:()=>"options"})});te(this,"Types",vt({Arbitrary:e=>new zt.ArbitraryType(e,this),HttpMethodExtensions:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("HttpMethodExtensions")}),FormRequest:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("FormRequest")}),Optional:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("Optional")}),ClientOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("ClientOptions"),namespace:this.namespaces.publicCoreClasses}),RawClient:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("RawClient")}),RequestOptions:()=>this.csharp.classReference({namespace:this.namespaces.publicCoreClasses,origin:this.model.staticExplicit("RequestOptions")}),RequestOptionsInterface:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("IRequestOptions")}),JsonRequest:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("JsonRequest")}),Version:()=>this.csharp.classReference({namespace:this.namespaces.publicCore,origin:this.model.staticExplicit("Version")}),ValueConvert:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("ValueConvert")}),FileParameter:()=>this.csharp.classReference({namespace:this.namespaces.publicCore,origin:this.model.staticExplicit("FileParameter"),multipartMethodName:"AddFileParameterPart",multipartMethodNameForCollection:"AddFileParameterParts",isReferenceType:!0}),Headers:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("Headers")}),HeaderValue:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("HeaderValue")}),RootClient:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.rootClient),namespace:this.namespaces.root}),RootClientForSnippets:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.rootClientForSnippets),namespace:this.namespaces.root}),BaseApiException:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.baseApiException),namespace:this.namespaces.publicCoreClasses}),BaseException:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.baseException),namespace:this.namespaces.publicCoreClasses}),ExceptionInterceptor:()=>this.csharp.classReference({origin:this.model.staticExplicit("IExceptionInterceptor"),namespace:this.namespaces.core}),ExceptionHandler:()=>this.csharp.classReference({origin:this.model.staticExplicit("ExceptionHandler"),namespace:this.namespaces.core}),CustomExceptionInterceptor:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.exceptionInterceptor),namespace:this.namespaces.core}),ProtoAnyMapper:()=>this.csharp.classReference({origin:this.model.staticExplicit("ProtoAnyMapper"),namespace:this.namespaces.core}),Constants:()=>this.csharp.classReference({origin:this.model.staticExplicit("Constants"),namespace:this.namespaces.core}),EnumSerializer:()=>this.csharp.classReference({origin:this.model.staticExplicit("EnumSerializer"),namespace:this.namespaces.core}),DateTimeSerializer:()=>this.csharp.classReference({origin:this.model.staticExplicit("DateTimeSerializer"),namespace:this.namespaces.core}),JsonUtils:()=>this.csharp.classReference({origin:this.model.staticExplicit("JsonUtils"),namespace:this.namespaces.core}),JsonAssert:()=>this.csharp.classReference({origin:this.model.staticExplicit("JsonAssert"),namespace:this.namespaces.testUtils}),CustomPagerFactory:()=>this.csharp.classReference({origin:this.model.staticExplicit(`${this.names.classes.customPager}Factory`),namespace:this.namespaces.core}),CustomPagerContext:()=>this.csharp.classReference({origin:this.model.staticExplicit(`${this.names.classes.customPager}Context`),namespace:this.namespaces.core}),Environments:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.environment),namespace:this.namespaces.publicCoreClasses}),TestClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("TestClient"),namespace:this.namespaces.test}),BaseMockServerTest:()=>this.csharp.classReference({origin:this.model.staticExplicit("BaseMockServerTest"),namespace:this.namespaces.mockServerTest}),IdempotentRequestOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("IdempotentRequestOptions"),namespace:this.namespaces.publicCoreClasses}),IdempotentRequestOptionsInterface:()=>this.csharp.classReference({origin:this.model.staticExplicit("IIdempotentRequestOptions"),namespace:this.namespaces.core}),IStringEnum:()=>this.csharp.classReference({origin:this.model.staticExplicit("IStringEnum"),namespace:this.namespaces.core}),WebSocketClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("WebSocketClient"),namespace:this.namespaces.webSocketsCore}),QueryBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("Query"),namespace:this.namespaces.webSocketsCore}),QueryStringBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("QueryStringBuilder"),namespace:this.namespaces.core}),QueryStringBuilderBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("QueryStringBuilder.Builder"),namespace:this.namespaces.core}),OAuthTokenProvider:()=>this.csharp.classReference({origin:this.model.staticExplicit("OAuthTokenProvider"),namespace:this.namespaces.core}),InferredAuthTokenProvider:()=>this.csharp.classReference({origin:this.model.staticExplicit("InferredAuthTokenProvider"),namespace:this.namespaces.core}),ProtoConverter:()=>this.csharp.classReference({origin:this.model.staticExplicit("ProtoConverter"),namespace:this.namespaces.core}),RawGrpcClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("RawGrpcClient"),namespace:this.namespaces.core}),Extensions:()=>this.csharp.classReference({origin:this.model.staticExplicit("Extensions"),namespace:this.namespaces.core}),GrpcRequestOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("GrpcRequestOptions"),namespace:this.namespaces.root}),GrpcChannelOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("GrpcChannelOptions"),namespace:"Grpc.Net.Client"}),StringEnum:e=>this.csharp.classReference({origin:this.model.staticExplicit("StringEnum"),namespace:this.namespaces.core,generics:e?[e]:void 0}),WebSocketEvent:e=>this.csharp.classReference({origin:this.model.staticExplicit("Event"),namespace:this.namespaces.webSocketsCore,generics:[e]}),ConnectionStatus:()=>this.csharp.classReference({origin:this.model.staticExplicit("ConnectionStatus"),namespace:this.namespaces.webSocketsCore}),WebSocketConnected:()=>this.csharp.classReference({origin:this.model.staticExplicit("Connected"),namespace:this.namespaces.webSocketsCore}),WebSocketClosed:()=>this.csharp.classReference({origin:this.model.staticExplicit("Closed"),namespace:this.namespaces.webSocketsCore}),StringEnumSerializer:e=>this.csharp.classReference({origin:this.model.staticExplicit("StringEnumSerializer"),namespace:this.namespaces.core,generics:[e]}),CustomPagerClass:e=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.customPager),namespace:this.namespaces.core,generics:[e]}),Pager:e=>this.csharp.classReference({origin:this.model.staticExplicit("Pager"),namespace:this.namespaces.core,generics:[e]}),OffsetPager:({requestType:e,requestOptionsType:r,responseType:n,offsetType:i,stepType:c,itemType:s})=>this.csharp.classReference({origin:this.model.staticExplicit("OffsetPager"),namespace:this.namespaces.core,generics:[e,r,n,i,c,s]}),CursorPager:({requestType:e,requestOptionsType:r,responseType:n,cursorType:i,itemType:c})=>this.csharp.classReference({origin:this.model.staticExplicit("CursorPager"),namespace:this.namespaces.core,generics:[e,r,n,i,c]}),CollectionItemSerializer:(e,r)=>this.csharp.classReference({origin:this.model.staticExplicit("CollectionItemSerializer"),namespace:this.namespaces.core,generics:[e,r]}),OneOfSerializer:e=>this.csharp.classReference({origin:this.model.staticExplicit("OneOfSerializer"),namespace:this.namespaces.core,generics:[e]}),AdditionalProperties:e=>this.csharp.classReference({origin:this.model.staticExplicit("AdditionalProperties"),namespace:this.namespaces.publicCore,generics:e?[e]:void 0}),ReadOnlyAdditionalProperties:e=>this.csharp.classReference({origin:this.model.staticExplicit("ReadOnlyAdditionalProperties"),namespace:this.namespaces.publicCore,generics:e?[e]:void 0})}));te(this,"Primitive",vt({string:()=>new zt.String(this),boolean:()=>new zt.Boolean(this),integer:()=>new zt.Integer(this),long:()=>new zt.Long(this),uint:()=>new zt.Uint(this),ulong:()=>new zt.ULong(this),float:()=>new zt.Float(this),double:()=>new zt.Double(this),object:()=>new zt.Object(this)}));te(this,"Value",vt({binary:()=>new Bi.Binary(this),dateOnly:()=>new Bi.DateOnly(this),dateTime:()=>new Bi.DateTime(this),uuid:()=>new Bi.Uuid(this),stringEnum:e=>new Bi.StringEnum(e,this)}));te(this,"Collection",vt({array:e=>new cn.Array(e,this),listType:e=>new cn.ListType(e,this),list:e=>new cn.List(e,this),set:e=>new cn.Set(e,this),map:(e,r,n)=>new cn.Map(e,r,this,n),idictionary:(e,r,n)=>new cn.IDictionary(e,r,this,n),keyValuePair:(e,r)=>new cn.KeyValuePair(e,r,this)}));te(this,"format",vt({private:e=>`_${L4.camelCase(e)}`}));te(this,"initializers",vt({implicitNamespaces:()=>{for(let e of this.namespaces.implicit)this.registry.addImplicitNamespace(e);return!0}}));this.intermediateRepresentation=e,this.apiName=r,this.customConfig=n,this.generatorConfig=i,this.support=c,this.model=new X4(e,this),this.ir=pt.IR.IntermediateRepresentation(e)?e:{},this.dir=pt.DynamicIR.DynamicIntermediateRepresentation(e)?e:{}}initialize(){return this.initializers.implicitNamespaces}get System(){return this.extern.System}get NUnit(){return this.extern.NUnit}get OneOf(){return this.extern.OneOf}get Google(){return this.extern.Google}get Grpc(){return this.extern.Grpc}get WireMock(){return this.extern.WireMock}};u();o();a();var Ta=class{constructor(e){te(this,"generation");this.generation=e}get csharp(){return this.generation.csharp}get settings(){return this.generation.settings}get constants(){return this.generation.constants}get namespaces(){return this.generation.namespaces}get names(){return this.generation.names}get model(){return this.generation.model}get format(){return this.generation.format}get registry(){return this.generation.registry}get Types(){return this.generation.Types}get System(){return this.generation.extern.System}get NUnit(){return this.generation.extern.NUnit}get OneOf(){return this.generation.extern.OneOf}get Google(){return this.generation.extern.Google}get Grpc(){return this.generation.extern.Grpc}get WireMock(){return this.generation.extern.WireMock}get Primitive(){return this.generation.Primitive}get Value(){return this.generation.Value}get Collection(){return this.generation.Collection}};u();o();a();var Q4=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}convert(r){if(r.value===null)return this.context.isNullable(r.typeReference)?this.csharp.Literal.null():(this.context.errors.add({severity:Lt.Critical,message:"Expected non-null value, but got null"}),this.csharp.Literal.nop());if(r.value===void 0&&!r.fallbackToDefault)return this.csharp.Literal.nop();switch(r.typeReference.type){case"list":return this.convertList({list:r.typeReference.value,value:r.value,fallbackToDefault:r.fallbackToDefault});case"literal":return this.convertLiteral({literal:r.typeReference.value,value:r.value});case"map":return this.convertMap({map:r.typeReference,value:r.value,fallbackToDefault:r.fallbackToDefault});case"named":{let n=this.context.resolveNamedType({typeId:r.typeReference.value});return n==null?this.csharp.Literal.nop():this.convertNamed({named:n,value:r.value,as:r.as,fallbackToDefault:r.fallbackToDefault})}case"nullable":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"optional":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"primitive":return this.convertPrimitive({primitive:r.typeReference.value,value:r.value,as:r.as,fallbackToDefault:r.fallbackToDefault});case"set":return this.convertSet({set:r.typeReference.value,value:r.value,fallbackToDefault:r.fallbackToDefault});case"unknown":return this.convertUnknown({value:r.value,fallbackToDefault:r.fallbackToDefault});default:rr(r.typeReference)}}convertList({list:r,value:n,fallbackToDefault:i}){return Array.isArray(n)?this.csharp.Literal.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:r,unboxOptionals:!0}),values:n.map((c,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:c})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Lt.Critical,message:`Expected array but got: ${typeof n}`}),this.csharp.Literal.nop())}convertLiteral({literal:r,value:n,fallbackToDefault:i}){switch(r.type){case"boolean":{let c=this.context.getValueAsBoolean({value:n});return c==null?this.csharp.Literal.nop():this.csharp.Literal.boolean(c)}case"string":{let c=this.context.getValueAsString({value:n});return c==null?i?this.Primitive.string.getDeterminsticDefault(i):this.csharp.Literal.nop():this.csharp.Literal.string(c)}default:rr(r)}}convertSet({set:r,value:n,fallbackToDefault:i}){return Array.isArray(n)?this.csharp.Literal.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:r,unboxOptionals:!0}),values:n.map((c,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:c})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Lt.Critical,message:`Expected array but got: ${typeof n}`}),this.csharp.Literal.nop())}convertMap({map:r,value:n,fallbackToDefault:i}){return typeof n!="object"||n==null?(this.context.errors.add({severity:Lt.Critical,message:`Expected object but got: ${n==null?"null":typeof n}`}),this.csharp.Literal.nop()):this.csharp.Literal.dictionary({keyType:this.context.dynamicTypeMapper.convert({typeReference:r.key}),valueType:r.value.type==="unknown"?this.context.dynamicTypeMapper.convert({typeReference:r.value}).asOptional():this.context.dynamicTypeMapper.convert({typeReference:r.value}),entries:Object.entries(n).map(([c,s])=>{this.context.errors.scope(c);try{return{key:this.convert({typeReference:r.key,value:c,as:"key"}),value:this.convert({typeReference:r.value,value:s})}}finally{this.context.errors.unscope()}})})}convertNamed({named:r,value:n,as:i,fallbackToDefault:c}){switch(r.type){case"alias":return this.convert({typeReference:r.typeReference,value:n,as:i,fallbackToDefault:c});case"discriminatedUnion":return this.settings.shouldGeneratedDiscriminatedUnions?this.convertDiscriminatedUnion({discriminatedUnion:r,value:n,fallbackToDefault:c}):this.convertUnknown({value:n,fallbackToDefault:c});case"enum":return this.getEnumValue(r,n);case"object":return this.convertObject({object_:r,value:n,fallbackToDefault:c});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:r,value:n,fallbackToDefault:c});default:rr(r)}}convertDiscriminatedUnion({discriminatedUnion:r,value:n,fallbackToDefault:i}){let c=this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),s=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:r,value:n});if(s==null)return this.csharp.Literal.nop();let l=s.singleDiscriminatedUnionType,f=this.getBaseProperties({discriminatedUnionTypeInstance:s,singleDiscriminatedUnionType:l});switch(l.type){case"samePropertiesAsObject":{let b=this.context.resolveNamedType({typeId:l.typeId});return b==null?this.csharp.Literal.nop():this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.convertNamed({named:b,value:s.value})]})}case"singleProperty":{if(this.context.getRecord(s.value)==null)return this.csharp.Literal.nop();try{let _=["Value","Type"].includes(l.discriminantValue.name.pascalCase.safeName)?`${l.discriminantValue.name.pascalCase.safeName}Inner`:l.discriminantValue.name.pascalCase.safeName;return this.context.errors.scope(l.discriminantValue.wireValue),this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({name:_,enclosingType:c}),arguments_:[this.convert({typeReference:l.typeReference,value:l.discriminantValue.wireValue})]})]})}finally{this.context.errors.unscope()}}case"noProperties":return this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({origin:s.discriminantValue,enclosingType:c}),arguments_:[]})]});default:rr(l)}}getBaseProperties({discriminatedUnionTypeInstance:r,singleDiscriminatedUnionType:n}){return this.context.associateByWireValue({parameters:n.properties??[],values:this.context.getRecord(r.value)??{},ignoreMissingParameters:!0}).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getPropertyName(c.name.name),assignment:this.convert(c)}}finally{this.context.errors.unscope()}})}instantiateUnionWithBaseProperties({classReference:r,arguments_:n,baseProperties:i}){let c=this.csharp.instantiateClass({classReference:r,arguments_:n,multiline:!0});return i.length===0?this.csharp.Literal.reference(c):this.csharp.Literal.reference(this.csharp.codeblock(s=>{s.write(c," "),s.pushScope();for(let l of i)s.write(l.name," = ",l.assignment,",");s.popScope(!1)}))}getEnumValue(r,n){if(typeof n!="string")return this.context.errors.add({severity:Lt.Critical,message:`Expected enum value string, got: ${typeof n}`}),this.csharp.Literal.nop();let i=r.values.find(l=>l.wireValue===n);if(i==null)return this.context.errors.add({severity:Lt.Critical,message:`An enum value named "${n}" does not exist in this context`}),this.csharp.Literal.nop();let c=this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),s=c.registerField(this.model.getPropertyNameFor(i),i);return this.csharp.Literal.reference(this.csharp.enumInstantiation({reference:c,value:s}))}convertObject({object_:r,value:n,fallbackToDefault:i}){let c=this.context.associateByWireValue({parameters:r.properties,values:this.context.getRecord(n)??{}});return this.csharp.Literal.class_({reference:this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),fields:c.map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getClassName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})})}convertUndiscriminatedUnion({undiscriminatedUnion:r,value:n,fallbackToDefault:i}){let c=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:n});return c==null?this.csharp.Literal.nop():c.typeLiteral}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:n}){for(let i of r.types)try{let c=this.convert({typeReference:i,value:n});return{valueTypeReference:i,typeLiteral:c}}catch{continue}this.context.errors.add({severity:Lt.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof n}" value`})}convertUnknown({value:r,fallbackToDefault:n}){return this.csharp.Literal.unknown(r)}convertPrimitive({primitive:r,value:n,as:i,fallbackToDefault:c}){switch(r){case"INTEGER":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.integer.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.integer(s)}case"LONG":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.long.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.long(s)}case"UINT":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.uint.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.uint(s)}case"UINT_64":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.ulong.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.ulong(s)}case"FLOAT":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.float.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.float(s)}case"DOUBLE":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.double.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.double(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:n,as:i});return s==null?c?this.Primitive.boolean.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.boolean(s)}case"STRING":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"DATE":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Value.dateOnly.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.date(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Value.dateTime.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.datetime(s)}case"UUID":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"BASE_64":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}default:rr(r)}}getValueAsNumber({value:r,as:n}){let i=n==="key"&&typeof r=="string"?Number(r):r;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:r,as:n}){let i=n==="key"?typeof r=="string"?r==="true":r==="false"?!1:r:r;return this.context.getValueAsBoolean({value:i})}};u();o();a();var k4=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}convert(r){switch(r.typeReference.type){case"list":return this.Collection.list(this.convert({typeReference:r.typeReference,unboxOptionals:!0}));case"literal":return this.convertLiteral({literal:r.typeReference.value});case"map":return this.Collection.map(this.convert({typeReference:r.typeReference.key}),this.convert({typeReference:r.typeReference.value}));case"named":{let n=this.context.resolveNamedType({typeId:r.typeReference.value});return n==null?this.convertUnknown():this.convertNamed({named:n})}case"optional":case"nullable":{let n=this.convert({typeReference:r.typeReference.value});return r.unboxOptionals?n.asNonOptional():n.asOptional()}case"primitive":return this.convertPrimitive({primitive:r.typeReference.value});case"set":return this.Collection.set(this.convert({typeReference:r.typeReference,unboxOptionals:!0}));case"unknown":return this.convertUnknown();default:rr(r.typeReference)}}convertToClassReference(r){return this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)})}convertNamed({named:r}){switch(r.type){case"alias":return this.convert({typeReference:r.typeReference});case"enum":case"object":return this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)});case"discriminatedUnion":return this.settings.shouldGeneratedDiscriminatedUnions?this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}):this.Primitive.object;case"undiscriminatedUnion":return this.OneOf.OneOf(r.types.map(n=>this.convert({typeReference:n})));default:rr(r)}}convertLiteral({literal:r}){switch(r.type){case"boolean":return this.Primitive.boolean;case"string":return this.Primitive.string}}convertUnknown(){return this.Primitive.object}convertPrimitive({primitive:r}){switch(r){case"INTEGER":return this.Primitive.integer;case"UINT":return this.Primitive.uint;case"LONG":return this.Primitive.long;case"UINT_64":return this.Primitive.ulong;case"FLOAT":return this.Primitive.float;case"DOUBLE":return this.Primitive.double;case"BOOLEAN":return this.Primitive.boolean;case"STRING":return this.Primitive.string;case"DATE":return this.Value.dateOnly;case"DATE_TIME":return this.Value.dateTime;case"UUID":return this.Primitive.string;case"BASE_64":return this.Primitive.string;case"BIG_INTEGER":return this.Primitive.string;default:rr(r)}}};u();o();a();var ew=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}getFilePropertyInfo({body:r,value:n}){let i={fileFields:[],bodyPropertyFields:[]},c=this.context.getRecord(n)??{};for(let s of r.properties)switch(s.type){case"file":pt.Record.missingKey(c,s.wireValue)&&(c[s.wireValue]="[bytes]"),i.fileFields.push({name:this.context.getPropertyName(s.name),value:this.getSingleFileProperty({property:s,record:c})});break;case"fileArray":pt.Record.missingKey(c,s.wireValue)&&(c[s.wireValue]=["[bytes]"]),i.fileFields.push({name:this.context.getPropertyName(s.name),value:this.getArrayFileProperty({property:s,record:c})});break;case"bodyProperty":if(pt.Record.missingKey(c,s.name.wireValue))switch(s.typeReference.type){case"optional":break;case"primitive":{switch(s.typeReference.value.toLowerCase()){case"integer":{c[s.name.wireValue]=123;break}case"string":{c[s.name.wireValue]="[string]";break}case"boolean":{c[s.name.wireValue]=!0;break}case"double":{c[s.name.wireValue]=123.456;break}case"float":{c[s.name.wireValue]=123.456;break}case"long":{c[s.name.wireValue]=123456789;break}case"uint":{c[s.name.wireValue]=123;break}case"uint64":{c[s.name.wireValue]=12345;break}case"date":{c[s.name.wireValue]=new Date(2021,1,1);break}case"datetime":{c[s.name.wireValue]=new Date(2021,1,1,12,0,0);break}case"uuid":{c[s.name.wireValue]="123e4567-e89b-12d3-a456-426614174000";break}case"base64":{c[s.name.wireValue]="SGVsbG8gd29ybGQh";break}case"biginteger":{c[s.name.wireValue]="12345678901234567890";break}}break}default:break}i.bodyPropertyFields.push({name:this.context.getPropertyName(s.name.name),value:this.getBodyProperty({property:s,record:c})});break;default:rr(s)}return i}getSingleFileProperty({property:r,record:n}){let i=this.context.getSingleFileValue({property:r,record:n});return i==null?this.csharp.Literal.nop():this.context.getFileParameterForString(i)}getArrayFileProperty({property:r,record:n}){let i=this.context.getFileArrayValues({property:r,record:n});return i==null?this.csharp.Literal.nop():this.csharp.Literal.list({valueType:this.Types.FileParameter,values:i.map(c=>this.context.getFileParameterForString(c))})}getBodyProperty({property:r,record:n}){let i=n[r.name.wireValue];return i==null?this.csharp.Literal.nop():this.context.dynamicLiteralMapper.convert({typeReference:r.typeReference,value:i})}};var tw=class t extends l2{constructor({ir:r,config:n,options:i,generation:c}){super({ir:r,config:n,options:i});te(this,"ir");te(this,"dynamicTypeMapper");te(this,"dynamicLiteralMapper");te(this,"filePropertyMapper");te(this,"generation");this.ir=r,this.generation=c??new Dm(r,n.workspaceName,n.customConfig!=null?n.customConfig:{},n),this.dynamicTypeMapper=new k4({context:this}),this.dynamicLiteralMapper=new Q4({context:this}),this.filePropertyMapper=new ew({context:this})}get namespaces(){return this.generation.namespaces}get registry(){return this.generation.registry}get settings(){return this.generation.settings}get constants(){return this.generation.constants}get names(){return this.generation.names}get model(){return this.generation.model}get format(){return this.generation.format}get csharp(){return this.generation.csharp}get Types(){return this.generation.Types}get System(){return this.generation.extern.System}get NUnit(){return this.generation.extern.NUnit}get OneOf(){return this.generation.extern.OneOf}get Google(){return this.generation.extern.Google}get WireMock(){return this.generation.extern.WireMock}get Primitive(){return this.generation.Primitive}get Value(){return this.generation.Value}get Collection(){return this.generation.Collection}clone(){return new t({ir:this.ir,config:this.config,options:this.options,generation:this.generation})}getFileParameterForString(r){return this.csharp.Literal.reference(this.csharp.instantiateClass({classReference:this.Types.FileParameter,arguments_:[],properties:[{name:"Stream",value:this.getMemoryStreamForString(r)}],multiline:!0}))}getMemoryStreamForString(r){return this.System.IO.MemoryStream.new({arguments_:[this.csharp.invokeMethod({on:this.System.Text.Encoding_UTF8,method:"GetBytes",arguments_:[this.csharp.Literal.string(r)]})]})}getClassName(r){return r.pascalCase.safeName}getParameterName(r){return r.camelCase.safeName}getPropertyName(r){return r.pascalCase.safeName}getMethodName(r){return`${r.pascalCase.safeName}Async`}getNamespace(r,n){let i=this.getNamespaceSegments(r);return i=n!=null?[...i,n]:i,[this.namespaces.root,...i].join(".")}getEnvironmentTypeReferenceFromID(r){let n=this.resolveEnvironmentName(r);if(n!=null)return this.getEnvironmentClassReferenceForEnumName(n)}getEnvironmentClassReferenceForEnumName(r){return this.csharp.classReference({name:`${this.generation.Types.Environments.name}.${this.getClassName(r)}`,namespace:this.namespaces.root})}getNamespaceSegments(r){return(this.settings.explicitNamespaces?r.allParts:r.packagePath).map(i=>i.pascalCase.safeName)}precalculate(r){this.generation.initialize(),this.System.Collections.Generic.KeyValuePair(),this.System.Collections.Generic.IEnumerable(),this.System.Collections.Generic.IAsyncEnumerable(),this.System.Collections.Generic.HashSet(),this.System.Collections.Generic.List(),this.System.Collections.Generic.Dictionary(),this.System.Threading.Tasks.Task(),Object.entries(this.ir.types).sort((n,i)=>n[0].length-i[0].length).forEach(([n,i])=>{this.dynamicTypeMapper.convertToClassReference(i)});for(let[n,i]of r.entries())if(this.csharp.classReference({origin:this.model.staticExplicit(`Example${n}`),namespace:"Usage"}),i.endpoint){let c=this.resolveEndpointLocation(i.endpoint);for(let s of c)switch(s.request.type){case"inlined":this.csharp.classReference({origin:s.request.declaration.name,namespace:this.getNamespace(s.request.declaration.fernFilepath)});break;case"body":break}}this.generation.Types.ClientOptions,this.generation.Types.RootClient,this.csharp.freezeClassReferences()}};u();o();a();var rw=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}async generateSnippet({endpoint:r,request:n,options:i}){return this.buildCodeBlock({endpoint:r,snippet:n,options:i}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}generateSnippetSync({endpoint:r,request:n,options:i}){return this.buildCodeBlock({endpoint:r,snippet:n,options:i}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}async generateSnippetAst({endpoint:r,request:n,options:i}){throw new Error("Unsupported")}buildCodeBlock({endpoint:r,snippet:n,options:i}){if(r.examples&&!r.examples?.find(l=>pt.DynamicIR.EndpointExample(n)&&l.id===n.id))throw new Error("Endpoint does not have an example that matches the snippet");let c=this.csharp.codeblock(l=>{l.writeNodeStatement(this.constructClient({endpoint:r,snippet:n})),l.newLine(),l.writeNodeStatement(this.callMethod({endpoint:r,snippet:n}))}),s=this.getStyle(i);switch(s){case Bh.Concise:return c;case Bh.Full:return this.buildFullCodeBlock({body:c,options:i});default:rr(s)}}buildFullCodeBlock({body:r,options:n}){let i=this.getConfig(n),c=this.csharp.class_({name:i.fullStyleClassName??"Example",namespace:"Usage",access:Gg.Access.Public});return c.addNamespaceReference(this.Types.RootClient.namespace),c.addMethod({name:"Do",access:Gg.Access.Public,isAsync:!0,parameters:[],body:r}),c}constructClient({endpoint:r,snippet:n}){return this.csharp.codeblock(i=>{i.write("var client = "),i.writeNode(this.getRootClientConstructorInvocation(this.getConstructorArgs({endpoint:r,snippet:n})))})}callMethod({endpoint:r,snippet:n}){let i=r.response?.type==="streaming"||r.response?.type==="streamParameter",c=this.csharp.invokeMethod({on:this.csharp.codeblock("client"),method:this.getMethod({endpoint:r}),arguments_:this.getMethodArgs({endpoint:r,snippet:n}),async:!0,configureAwait:!0,multiline:!0,isAsyncEnumerable:i});return i?this.csharp.codeblock(s=>{s.write("await foreach (var item in "),s.writeNode(c),s.writeLine(")"),s.pushScope(),s.writeLine("/* consume each item */"),s.popScope()}):c}getConstructorArgs({endpoint:r,snippet:n}){let i=[];r.auth!=null&&(n.auth!=null?i.push(...this.getConstructorAuthArgs({auth:r.auth,values:n.auth})):this.context.errors.add({severity:Lt.Warning,message:`Auth with ${r.auth.type} configuration is required for this endpoint`}));let c=[],s=this.getConstructorBaseUrlArgs({baseUrl:n.baseURL,environment:n.environment});s.length>0&&c.push(...s),this.context.errors.scope(Fa.Headers);let l=[];return this.context.ir.headers!=null&&n.headers!=null&&l.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:n.headers})),this.context.errors.unscope(),c.length===0?[...i,...l]:[...i,...l,{name:"clientOptions",assignment:this.csharp.instantiateClass({classReference:this.Types.ClientOptions,arguments_:c.map(f=>({name:f.name,assignment:f.assignment})),multiline:!0})}]}getConstructorBaseUrlArgs({baseUrl:r,environment:n}){let i=this.getBaseUrlArg({baseUrl:r,environment:n});return pt.Literal.nop(i)?[]:[{name:this.getBaseUrlOptionName(),assignment:i}]}getBaseUrlArg({baseUrl:r,environment:n}){if(r!=null&&n!=null)return this.context.errors.add({severity:Lt.Critical,message:"Cannot specify both baseUrl and environment options"}),this.csharp.Literal.nop();if(r!=null)return this.context.ir.environments?.environments.type==="multipleBaseUrls"?(this.context.errors.add({severity:Lt.Critical,message:"The C# SDK doesn't support a baseUrl when multiple URL environments are configured"}),this.csharp.Literal.nop()):this.csharp.Literal.string(r);if(n!=null){if(this.context.isSingleEnvironmentID(n)){let i=this.context.getEnvironmentTypeReferenceFromID(n);return i==null?(this.context.errors.add({severity:Lt.Warning,message:`Environment ${JSON.stringify(n)} was not found`}),this.csharp.Literal.nop()):this.csharp.Literal.reference(i)}if(this.context.isMultiEnvironmentValues(n))return this.context.validateMultiEnvironmentUrlValues(n)?this.csharp.Literal.reference(this.csharp.instantiateClass({classReference:this.Types.Environments,arguments_:Object.entries(n).map(([i,c])=>({name:Qg(lw(i)),assignment:this.context.dynamicLiteralMapper.convert({typeReference:{type:"primitive",value:"STRING"},value:c})})),multiline:!0})):this.csharp.Literal.nop()}return this.csharp.Literal.nop()}getConstructorAuthArgs({auth:r,values:n}){if(n.type!==r.type)return this.addError(this.context.newAuthMismatchError({auth:r,values:n}).message),[];switch(r.type){case"basic":return n.type==="basic"?this.getConstructorBasicAuthArg({auth:r,values:n}):[];case"bearer":return n.type==="bearer"?this.getConstructorBearerAuthArgs({auth:r,values:n}):[];case"header":return n.type==="header"?this.getConstructorHeaderAuthArgs({auth:r,values:n}):[];case"oauth":return n.type==="oauth"?this.getConstructorOAuthArgs({auth:r,values:n}):[];case"inferred":return n.type==="inferred"?this.getConstructorInferredAuthArgs({auth:r,values:n}):[];default:rr(r)}}addError(r){this.context.errors.add({severity:Lt.Critical,message:r})}addWarning(r){this.context.errors.add({severity:Lt.Warning,message:r})}getConstructorBasicAuthArg({auth:r,values:n}){return[{name:this.context.getParameterName(r.username),assignment:this.csharp.Literal.string(n.username)},{name:this.context.getParameterName(r.password),assignment:this.csharp.Literal.string(n.password)}]}getConstructorBearerAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.token),assignment:this.csharp.Literal.string(n.token)}]}getConstructorHeaderAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.header.name.name),assignment:this.context.dynamicLiteralMapper.convert({typeReference:r.header.typeReference,value:n.value,fallbackToDefault:r.header.name.wireValue})}]}getConstructorOAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.clientId),assignment:this.csharp.Literal.string(n.clientId)},{name:this.context.getParameterName(r.clientSecret),assignment:this.csharp.Literal.string(n.clientSecret)}]}getConstructorInferredAuthArgs({auth:r,values:n}){let i=[];if(r.parameters!=null)for(let c of r.parameters){let s=c.name.wireValue,l=n.values?.[s];i.push({name:this.context.getParameterName(c.name.name),assignment:this.context.dynamicLiteralMapper.convert({typeReference:c.typeReference,value:l,fallbackToDefault:s})})}else this.context.errors.add({severity:Lt.Critical,message:"Inferred auth parameters are not defined in the IR. Please ensure you're using IR version 62.3.0 or later."});return i}getConstructorHeaderArgs({headers:r,values:n}){let i=[];for(let c of r){let s=this.getConstructorHeaderArg({header:c,value:n.value});s!=null&&i.push({name:this.context.getParameterName(c.name.name),assignment:s})}return i}getConstructorHeaderArg({header:r,value:n}){let i=this.context.dynamicLiteralMapper.convert({typeReference:r.typeReference,value:n,fallbackToDefault:r.name.wireValue});if(!pt.Literal.nop(i))return i}getMethodArgs({endpoint:r,snippet:n}){switch(r.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:r.request,snippet:n});case"body":return this.getMethodArgsForBodyRequest({request:r.request,snippet:n});default:rr(r.request)}}getMethodArgsForInlinedRequest({request:r,snippet:n}){let i=[];this.context.errors.scope(Fa.PathParameters);let c=[],s=[...this.context.ir.pathParameters??[],...r.pathParameters??[]];s.length>0&&c.push(...this.getPathParameters({namedParameters:s,snippet:n})),this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody);let l=this.getFilePropertyInfo({request:r,snippet:n});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:r,inlinePathParameters:this.settings.shouldInlinePathParameters})||i.push(...c.map(f=>f.value)),i.push(this.getInlinedRequestArg({request:r,snippet:n,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:r,inlinePathParameters:this.settings.shouldInlinePathParameters})?c:[],filePropertyInfo:l})),i}getFilePropertyInfo({request:r,snippet:n}){return r.body==null||!this.context.isFileUploadRequestBody(r.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:r.body,value:n.requestBody})}getInlinedRequestArg({request:r,snippet:n,pathParameterFields:i,filePropertyInfo:c}){this.context.errors.scope(Fa.QueryParameters);let l=this.context.associateQueryParametersByWireValue({parameters:r.queryParameters??[],values:n.queryParameters??{}}).map(O=>({name:this.context.getPropertyName(O.name.name),value:this.context.dynamicLiteralMapper.convert(O)}));this.context.errors.unscope(),this.context.errors.scope(Fa.Headers);let b=this.context.associateByWireValue({parameters:r.headers??[],values:n.headers??{}}).map(O=>({name:this.context.getPropertyName(O.name.name),value:this.context.dynamicLiteralMapper.convert({...O,fallbackToDefault:O.name.wireValue})}));this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody);let _=r.body!=null?this.getInlinedRequestBodyConstructorFields({body:r.body,value:n.requestBody,filePropertyInfo:c}):[];return this.context.errors.unscope(),this.csharp.Literal.class_({reference:this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),fields:[...i,...l,...b,..._]})}getInlinedRequestBodyConstructorFields({body:r,value:n,filePropertyInfo:i}){switch(r.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:r.value,value:n});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:r,value:n})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:i});default:rr(r)}}getInlinedRequestBodyPropertyConstructorFields({parameters:r,value:n}){let i=[],c=this.context.associateByWireValue({parameters:r,values:this.context.getRecord(n)??{}});for(let s of c)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicLiteralMapper.convert({...s,fallbackToDefault:s.name.wireValue})});return i}getFileUploadRequestBodyConstructorFields({filePropertyInfo:r}){return[...r.fileFields,...r.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:r,value:n}){return{name:this.context.getPropertyName(r.bodyKey),value:this.getReferencedRequestBodyPropertyLiteral({body:r.bodyType,value:n})}}getReferencedRequestBodyPropertyLiteral({body:r,value:n}){switch(r.type){case"bytes":return this.getBytesBodyRequestArg({value:n});case"typeReference":return this.context.dynamicLiteralMapper.convert({typeReference:r.value,value:n,fallbackToDefault:JSON.stringify(r.value)});default:rr(r)}}getMethodArgsForBodyRequest({request:r,snippet:n}){let i=[];this.context.errors.scope(Fa.PathParameters);let c=[...this.context.ir.pathParameters??[],...r.pathParameters??[]];return c.length>0&&i.push(...this.getPathParameters({namedParameters:c,snippet:n}).map(s=>s.value)),this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody),r.body!=null&&i.push(this.getBodyRequestArg({body:r.body,value:n.requestBody})),this.context.errors.unscope(),i}getBodyRequestArg({body:r,value:n}){switch(r.type){case"bytes":return this.getBytesBodyRequestArg({value:n});case"typeReference":return r.value.type==="optional"&&n==null?this.csharp.Literal.null():this.context.dynamicLiteralMapper.convert({typeReference:r.value,value:n,fallbackToDefault:JSON.stringify(r.value)});default:rr(r)}}getBytesBodyRequestArg({value:r}){let n=this.context.getValueAsString({value:r});return n==null&&(this.context.errors.add({severity:Lt.Critical,message:"The bytes request body must be provided in string format"}),n="[bytes]"),this.csharp.Literal.reference(this.context.getMemoryStreamForString(n))}getRootClientConstructorInvocation(r){return this.csharp.instantiateClass({classReference:this.Types.RootClient,arguments_:r,forceUseConstructor:!0,multiline:!0})}getPathParameters({namedParameters:r,snippet:n}){let i=[],c=this.context.associateByWireValueOrDefault({parameters:r,values:n.pathParameters??{}});for(let s of c)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicLiteralMapper.convert({...s,fallbackToDefault:s.name.wireValue})});return i}getMethod({endpoint:r}){return r.declaration.fernFilepath.allParts.length>0?`${r.declaration.fernFilepath.allParts.map(n=>this.context.getClassName(n)).join(".")}.${this.context.getMethodName(r.declaration.name)}`:this.context.getMethodName(r.declaration.name)}getBaseUrlOptionName(){return this.context.ir.environments?.environments.type==="multipleBaseUrls"?"Environment":"BaseUrl"}getStyle(r){return r.style??this.context.options.style??Bh.Full}getConfig(r){return r.config??this.context.options.config??{}}};var nw=class extends o2{constructor({ir:e,config:r,options:n={}}){super(new tw({ir:e,config:r,options:n}))}precalculate(e){this.context.precalculate(e)}async generate(e,r={}){return super.generate(e,r)}generateSync(e,r={}){return super.generateSync(e,r)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new rw({context:e})}};0&&(module.exports={DynamicSnippetsGenerator});
172
+ ${r2()}`)}return this.generation.registry.registerClassReference(e,r)}freezeClassReferences(){this.frozen=!0}getPropertyName(e,r){let n=this.model.getPropertyNameFor(r),i=this.model.origin(r)??(0,Kpe.fail)(`Origin not found for property: ${JSON.stringify(r).substring(0,100)}`),c=e.getFieldName(i,n);return c||n}class_(e){let r=e;return"reference"in e&&(r={...e.reference,...e}),new Yp(r,this.generation)}testClass(e){return new Hg(e,this.generation)}annotation(e){return new I0(e,this.generation)}annotationGroup(e){return new Rg(e,this.generation)}instantiateClass(e){return new _g(e,this.generation)}invokeMethod(e){return new Og(e,this.generation)}codeblock(e){return new vh(e,this.generation)}code(){return new mh({},this.generation)}anonymousFunction(e){return new qg(e)}parameter(e){return new Ma(e,this.generation)}interface_(e){return new Vg(e,this.generation)}enum_(e){return new $g(e,this.generation)}dictionary(e){return new gg(e,this.generation)}list(e){return new mg(e,this.generation)}readOnlyMemory(e){return new wg(e,this.generation)}set(e){return new Pg(e,this.generation)}switch_(e){return new Ig(e,this.generation)}ternary(e){return new Lg(e,this.generation)}and(e){return new Fg(e,this.generation)}or(e){return new Ng(e,this.generation)}enumInstantiation(e){return new vg(e,this.generation)}string_(e){return new Eg(e,this.generation)}xmlDocBlock(e){return new Ph(e,this.generation)}xmlDocBlockOf(e){return e instanceof Ph?e:new Ph(e,this.generation)}validateReadOnlyMemoryTypes(){for(let e of this.generation.settings.readOnlyMemoryTypes)if(!this.VALID_READ_ONLY_MEMORY_TYPES.has(e))throw new Error(`Type "${e}" is not a valid 'read-only-memory-types' custom config option; expected one of ${JSON.stringify(this.VALID_READ_ONLY_MEMORY_TYPES)}.`)}};u();o();a();function vt(t){let e={},r={};for(let[n,i]of Object.entries(t))i.length===0?Object.defineProperty(r,n,{get(){return n in e||(e[n]=i()),e[n]},enumerable:!0,configurable:!0}):r[n]=i;return r}u();o();a();var Y4=class{constructor(e){te(this,"generation");te(this,"System",vt({Action:e=>this.csharp.classReference({name:"Action",namespace:"System",generics:e||void 0,multipartMethodName:null,multipartMethodNameForCollection:null,isReferenceType:!0}),Func:(e,r)=>this.csharp.classReference({name:"Func",namespace:"System",generics:e?r?[...e,r]:e:r?[r]:void 0,multipartMethodName:null,multipartMethodNameForCollection:null,isReferenceType:!0}),DateOnly:()=>this.csharp.classReference({name:"DateOnly",namespace:"System"}),DateTime:()=>this.csharp.classReference({name:"DateTime",namespace:"System"}),Enum:()=>this.csharp.classReference({name:"Enum",namespace:"System"}),Exception:()=>this.csharp.classReference({name:"Exception",namespace:"System"}),ReadOnlyMemory:e=>this.csharp.classReference({name:"ReadOnlyMemory",namespace:"System",generics:[e]}),Serializable:()=>this.csharp.classReference({name:"SerializableAttribute",namespace:"System"}),String:()=>this.csharp.classReference({name:"String",namespace:"System"}),Type:()=>this.csharp.classReference({name:"Type",namespace:"System",isReferenceType:!0,multipartMethodName:null,multipartMethodNameForCollection:null,fullyQualified:!0}),TimeSpan:()=>this.csharp.classReference({name:"TimeSpan",namespace:"System"}),Uri:()=>this.csharp.classReference({name:"Uri",namespace:"System"}),UriBuilder:()=>this.csharp.classReference({name:"UriBuilder",namespace:"System"}),Runtime:()=>vt({Serialization:()=>vt({EnumMember:()=>this.csharp.classReference({name:"EnumMemberAttribute",namespace:"System.Runtime.Serialization"})})}),Collections:()=>vt({Generic:()=>vt({IAsyncEnumerable:e=>this.csharp.classReference({name:"IAsyncEnumerable",namespace:"System.Collections.Generic",generics:e?[e]:void 0}),IEnumerable:e=>this.csharp.classReference({name:"IEnumerable",namespace:"System.Collections.Generic",generics:e?[e]:void 0}),KeyValuePair:(e,r)=>this.csharp.classReference({name:"KeyValuePair",namespace:"System.Collections.Generic",generics:e&&r?[e,r]:void 0}),List:e=>this.csharp.classReference({name:"List",namespace:"System.Collections.Generic",generics:e?[e]:void 0,isCollection:!0}),HashSet:e=>this.csharp.classReference({name:"HashSet",namespace:"System.Collections.Generic",generics:e?[e]:void 0,isCollection:!0}),Dictionary:(e,r)=>this.csharp.classReference({name:"Dictionary",namespace:"System.Collections.Generic",generics:e&&r?[e,r]:void 0,isCollection:!0}),IDictionary:(e,r)=>this.csharp.classReference({name:"IDictionary",namespace:"System.Collections.Generic",generics:[e,r]})}),Linq:()=>vt({Enumerable:()=>this.csharp.classReference({name:"Enumerable",namespace:"System.Linq"})})}),Globalization:()=>vt({DateTimeStyles:()=>this.csharp.classReference({name:"DateTimeStyles",namespace:"System.Globalization"})}),Linq:()=>vt({Enumerable:()=>this.csharp.classReference({name:"Enumerable",namespace:"System.Linq"})}),Net:()=>vt({Http:()=>vt({HttpClient:()=>this.csharp.classReference({name:"HttpClient",namespace:"System.Net.Http"}),HttpMethod:()=>this.csharp.classReference({name:"HttpMethod",namespace:"System.Net.Http"}),HttpResponseHeaders:()=>this.csharp.classReference({name:"HttpResponseHeaders",namespace:"System.Net.Http.Headers"})}),ServerSentEvents:()=>vt({SseEvent:()=>this.csharp.classReference({name:"SseEvent",namespace:"System.Net.ServerSentEvents"}),SseParser:()=>this.csharp.classReference({name:"SseParser",namespace:"System.Net.ServerSentEvents"})}),WebSockets:()=>vt({ClientWebSocketOptions:()=>this.csharp.classReference({name:"ClientWebSocketOptions",namespace:"System.Net.WebSockets"})})}),IO:()=>vt({MemoryStream:()=>this.csharp.classReference({name:"MemoryStream",namespace:"System.IO"}),Stream:()=>this.csharp.classReference({name:"Stream",namespace:"System.IO"}),StreamReader:()=>this.csharp.classReference({name:"StreamReader",namespace:"System.IO"})}),Text:()=>vt({Encoding:()=>this.csharp.classReference({name:"Encoding",namespace:"System.Text"}),Encoding_UTF8:()=>this.csharp.classReference({name:"UTF8",enclosingType:this.csharp.classReference({name:"Encoding",namespace:"System.Text"})}),Json:()=>vt({JsonElement:()=>this.csharp.classReference({name:"JsonElement",namespace:"System.Text.Json"}),JsonDocument:()=>this.csharp.classReference({name:"JsonDocument",namespace:"System.Text.Json"}),JsonException:()=>this.csharp.classReference({name:"JsonException",namespace:"System.Text.Json"}),Utf8JsonReader:()=>this.csharp.classReference({name:"Utf8JsonReader",namespace:"System.Text.Json"}),JsonSerializerOptions:()=>this.csharp.classReference({name:"JsonSerializerOptions",namespace:"System.Text.Json"}),JsonSerializer:()=>this.csharp.classReference({name:"JsonSerializer",namespace:"System.Text.Json"}),Utf8JsonWriter:()=>this.csharp.classReference({name:"Utf8JsonWriter",namespace:"System.Text.Json"}),Nodes:()=>vt({JsonNode:()=>this.csharp.classReference({name:"JsonNode",namespace:"System.Text.Json.Nodes"}),JsonObject:()=>this.csharp.classReference({name:"JsonObject",namespace:"System.Text.Json.Nodes"})}),Serialization:()=>vt({IJsonOnDeserialized:()=>this.csharp.classReference({name:"IJsonOnDeserialized",namespace:"System.Text.Json.Serialization"}),IJsonOnSerializing:()=>this.csharp.classReference({name:"IJsonOnSerializing",namespace:"System.Text.Json.Serialization"}),JsonOnDeserializedAttribute:()=>this.csharp.classReference({name:"JsonOnDeserializedAttribute",namespace:"System.Text.Json.Serialization"}),JsonExtensionData:()=>this.csharp.classReference({name:"JsonExtensionDataAttribute",namespace:"System.Text.Json.Serialization"}),JsonConverter:e=>this.csharp.classReference({name:"JsonConverter",namespace:"System.Text.Json.Serialization",generics:e?[e]:void 0}),JsonIgnore:()=>this.csharp.classReference({name:"JsonIgnoreAttribute",namespace:"System.Text.Json.Serialization"}),JsonPropertyName:()=>this.csharp.classReference({name:"JsonPropertyNameAttribute",namespace:"System.Text.Json.Serialization"})})})}),Threading:()=>vt({CancellationToken:()=>this.csharp.classReference({name:"CancellationToken",namespace:"System.Threading"}),Tasks:()=>vt({Task:e=>this.csharp.classReference({name:"Task",namespace:"System.Threading.Tasks",generics:e?[e]:void 0}),ValueTask:e=>this.csharp.classReference({name:"ValueTask",namespace:"System.Threading.Tasks",generics:e?[e]:void 0})})}),ComponentModel:()=>vt({INotifyPropertyChanged:()=>this.csharp.classReference({name:"INotifyPropertyChanged",namespace:"System.ComponentModel"}),PropertyChangedEventHandler:()=>this.csharp.classReference({name:"PropertyChangedEventHandler",namespace:"System.ComponentModel"})}),IAsyncDisposable:()=>this.csharp.classReference({name:"IAsyncDisposable",namespace:"System"}),IDisposable:()=>this.csharp.classReference({name:"IDisposable",namespace:"System"})}));te(this,"NUnit",vt({Framework:()=>vt({TestFixture:()=>this.csharp.classReference({name:"TestFixture",namespace:"NUnit.Framework"}),Test:()=>this.csharp.classReference({name:"Test",namespace:"NUnit.Framework"}),OneTimeTearDown:()=>this.csharp.classReference({name:"OneTimeTearDown",namespace:"NUnit.Framework"}),OneTimeSetUp:()=>this.csharp.classReference({name:"OneTimeSetUp",namespace:"NUnit.Framework"}),SetUpFixture:()=>this.csharp.classReference({name:"SetUpFixture",namespace:"NUnit.Framework"})})}));te(this,"OneOf",vt({OneOf:e=>this.csharp.classReference({name:"OneOf",namespace:"OneOf",generics:e}),OneOfBase:e=>this.csharp.classReference({name:"OneOfBase",namespace:"OneOf",generics:e})}));te(this,"Google",vt({Protobuf:()=>vt({WellKnownTypes:()=>vt({Struct:()=>this.csharp.classReference({name:"Struct",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),Value:()=>this.csharp.classReference({name:"Value",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),ListValue:()=>this.csharp.classReference({name:"ListValue",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"}),Timestamp:()=>this.csharp.classReference({name:"Timestamp",namespace:"Google.Protobuf.WellKnownTypes",namespaceAlias:"WellKnownProto"})})})}));te(this,"WireMock",vt({Server:()=>this.csharp.classReference({name:"WireMockServer",namespace:"WireMock.Server"}),WireMockServerSettings:()=>this.csharp.classReference({name:"WireMockServerSettings",namespace:"WireMock.Settings"}),WireMockConsoleLogger:()=>this.csharp.classReference({name:"WireMockConsoleLogger",namespace:"WireMock.Logging"})}));te(this,"Grpc",vt({Core:()=>vt({RpcException:()=>this.csharp.classReference({name:"RpcException",namespace:"Grpc.Core"})})}));this.generation=e}get csharp(){return this.generation.csharp}};u();o();a();var Sm=require("assert");function Zpe(t){return t.split(".").filter(e=>!["name","camelCase","snakeCase","screamingSnakeCase","pascalCase"].includes(e)).join(".")}var X4=class{constructor(e,r){te(this,"generation");te(this,"indexByObject",new Map);te(this,"indexByPath",new Map);te(this,"explicitByObject",new Map);te(this,"explicitByPath",new Map);te(this,"root");te(this,"ir");this.generation=r,this.root=this.createIndex(e),this.ir=e}get csharp(){return this.generation.csharp}get registry(){return this.generation.registry}createIndex(e,r="",n){let i=Zpe(n?.jsonPath?`${n.jsonPath}.${r}`:r);if(this.indexByPath.has(i)){n||(0,Sm.fail)(`Parent provenance not found for node: ${JSON.stringify(e).substring(0,100)}`),this.indexByObject.set(e,n);for(let[s,l]of Object.entries(e))typeof l=="object"&&l!==null&&this.createIndex(l,s,n);return n}let c={jsonPath:i,name:r,node:e,parent:n};this.indexByObject.set(e,c),this.indexByPath.set(i,c);for(let[s,l]of Object.entries(e))typeof l=="object"&&l!==null&&this.createIndex(l,s,c);return c}staticExplicit(e){return this.explicit(this.ir,e)}explicit(e,r){let n=this.provenance(e)??(0,Sm.fail)(`Provenance not found for node: ${JSON.stringify(e).substring(0,100)}`),i={...n,jsonPath:Zpe(`${n.jsonPath}+${r}`),name:r,node:n.node,parent:n,explicit:!0},c=this.explicitByObject.get(n.node);return c?c.add(i):this.explicitByObject.set(n.node,new Set([i])),this.explicitByPath.set(i.jsonPath,i),i}provenance(e){if(e!==void 0)return pt.string(e)?this.explicitByPath.get(e)??this.indexByPath.get(e):pt.Provenance(e)?this.explicitByPath.get(e.jsonPath)??this.indexByPath.get(e.jsonPath):this.indexByObject.get(e)}origin(e){let r=this.provenance(e);return r?.explicit?r:r?.node}irNode(e){return this.provenance(e)?.node}jsonPath(e){return this.provenance(e)?.jsonPath}getEnumValueName(e,r){let n=pt.IR.ExampleEnumType(r)?r.value.name:r.name,i=e.values.find(c=>this.nameEquals(c.name.name,n));return i?this.getPropertyNameFor(i):(0,Sm.fail)(`Unexpected - can't find enum value ${n} in enum`)}getPropertyNameFor(e){let r=this.registry.getFieldNameByOrigin(e);if(r)return r;if(pt.Provenance(e))return e.name;if("name"in e){if(pt.IR.NameAndWireValue(e.name))return e.name.name.pascalCase.safeName;if(pt.IR.Name(e.name))return e.name.pascalCase.safeName;if(typeof e.name=="string")return e.name}if("pascalCase"in e)return e.pascalCase.safeName;throw new Error(`Unknown property type: ${this.jsonPath(e)}`)}getClassNameFor(e){if(pt.Provenance(e))return e.name;if("name"in e){if(pt.IR.TypeDeclaration(e)||pt.IR.NameAndWireValue(e.name))return e.name.name.pascalCase.safeName;if(pt.IR.Name(e.name))return e.name.pascalCase.safeName;if(typeof e.name=="string")return e.name}if("pascalCase"in e)return e.pascalCase.safeName;throw new Error(`Unknown property type: ${JSON.stringify(e)}`)}nameEquals(e,r){return e.camelCase.safeName===r.camelCase.safeName}dereferenceType(e){let r=pt.string(e)?e:pt.IR.NamedType(e)||pt.IR.DeclaredTypeName(e)?e.typeId:pt.IR.ExampleNamedType(e)?e.typeName.typeId:e.name.typeId,n=this.irNode(this.ir.types[r]);if(pt.IR.TypeDeclaration(n))return{typeId:r,typeDeclaration:n};(0,Sm.fail)(`dereferenceType: typeId ${r} not resolved.`)}};var Dm=class{constructor(e,r,n,i,c={makeRelativeFilePath:s=>s,makeAbsoluteFilePath:s=>s,getNamespaceForTypeId:s=>"",getDirectoryForTypeId:s=>"",getCoreAsIsFiles:()=>[],getCoreTestAsIsFiles:()=>[],getPublicCoreAsIsFiles:()=>[],getAsyncCoreAsIsFiles:()=>[],getChildNamespaceSegments:s=>[]}){te(this,"intermediateRepresentation");te(this,"apiName");te(this,"customConfig");te(this,"generatorConfig");te(this,"support");te(this,"ir");te(this,"dir");te(this,"csharp",new J4(this));te(this,"registry",new Kg(this));te(this,"model");te(this,"extern",new Y4(this));te(this,"settings",vt({namespace:()=>this.customConfig.namespace??N4(I4(`${this.generatorConfig.organization}_${this.apiName}`)),readOnlyMemoryTypes:()=>this.customConfig["read-only-memory-types"]??[],simplifyObjectDictionaries:()=>this.customConfig["simplify-object-dictionaries"]??!1,useFullyQualifiedNamespaces:()=>this.customConfig["experimental-fully-qualified-namespaces"]??!1,useDotnetFormat:()=>this.customConfig["experimental-dotnet-format"]??!1,enableWebsockets:()=>this.customConfig["experimental-enable-websockets"]??!1,enableReadonlyConstants:()=>this.customConfig["experimental-readonly-constants"]??!1,enableExplicitNullableOptional:()=>this.customConfig["experimental-explicit-nullable-optional"]??!1,useDefaultRequestParameterValues:()=>this.customConfig["use-default-request-parameter-values"]??!1,redactResponseBodyOnError:()=>this.customConfig["redact-response-body-on-error"]??!1,temporaryWebsocketEnvironments:()=>this.customConfig["temporary-websocket-environments"]??{},baseApiExceptionClassName:()=>this.customConfig["base-api-exception-class-name"]??"",baseExceptionClassName:()=>this.customConfig["base-exception-class-name"]??"",shouldGeneratedDiscriminatedUnions:()=>this.customConfig["use-discriminated-unions"]??!0,shouldGenerateUndiscriminatedUnions:()=>this.customConfig["use-undiscriminated-unions"]??!1,exportedClientClassName:()=>this.customConfig["exported-client-class-name"]??"",clientClassName:()=>this.customConfig["client-class-name"]??"",rootNamespaceForCoreClasses:()=>this.customConfig["root-namespace-for-core-classes"]??!0,packageId:()=>this.customConfig["package-id"]??"",isForwardCompatibleEnumsEnabled:()=>this.customConfig["enable-forward-compatible-enums"]??this.customConfig["experimental-enable-forward-compatible-enums"]??!0,websocketEnvironments:()=>this.customConfig["temporary-websocket-environments"]??{},customPagerName:()=>this.customConfig["custom-pager-name"]??"",environmentClassName:()=>this.customConfig["environment-class-name"]??"",generateErrorTypes:()=>this.customConfig["generate-error-types"]??!0,shouldInlinePathParameters:()=>this.customConfig["inline-path-parameters"]??!0,includeExceptionHandler:()=>this.customConfig["include-exception-handler"]??!1,exceptionInterceptorClassName:()=>this.customConfig["exception-interceptor-class-name"]??"",shouldGenerateMockServerTests:()=>this.customConfig["generate-mock-server-tests"]??this.customConfig["enable-wire-tests"]??!0,rootClientAccess:()=>this.customConfig["root-client-class-access"]=="internal"?zr.Internal:zr.Public,extraDependencies:()=>this.customConfig["extra-dependencies"]??{},pascalCaseEnvironments:()=>this.customConfig["pascal-case-environments"]??!0,explicitNamespaces:()=>this.customConfig["explicit-namespaces"]===!0,outputPath:()=>{let e=this.customConfig["output-path"];return e==null?{library:"src",test:"src",solution:".",other:"."}:typeof e=="string"?{library:e,test:e,solution:".",other:"."}:{library:e.library??"src",test:e.test??"src",solution:e.solution??".",other:e.other??"."}}}));te(this,"constants",{folders:vt({mockServerTests:()=>this.support.makeRelativeFilePath("Unit/MockServer"),types:()=>"Types",exceptions:()=>"Exceptions",src:()=>"src",protobuf:()=>"proto",serializationTests:()=>this.support.makeRelativeFilePath("Unit/Serialization"),project:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.sourceFiles,this.support.makeRelativeFilePath(this.names.files.project))),sourceFiles:()=>this.support.makeRelativeFilePath(this.constants.folders.src),coreFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.project,this.support.makeRelativeFilePath(this.constants.defaults.core))),publicCoreFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.project,this.support.makeRelativeFilePath(this.constants.defaults.core),this.support.makeRelativeFilePath(this.constants.defaults.publicCore))),testFiles:()=>this.support.makeRelativeFilePath(Am(this.constants.folders.sourceFiles,this.support.makeRelativeFilePath(this.names.files.testProject)))}),formatting:vt({indent:()=>" "}),defaults:vt({core:()=>"Core",publicCore:()=>"Public",version:()=>"0.0.0"})});te(this,"namespaces",vt({root:()=>this.settings.namespace,core:()=>`${this.namespaces.root}.Core`,test:()=>this.registry.canonicalizeNamespace(`${this.namespaces.root}.Test`),testUtils:()=>`${this.namespaces.test}.Utils`,mockServerTest:()=>`${this.namespaces.test}.Unit.MockServer`,publicCore:()=>this.namespaces.root,webSocketsCore:()=>`${this.namespaces.core}.WebSockets`,publicCoreTest:()=>`${this.namespaces.root}.Test.PublicCore`,asIsTestUtils:()=>`${this.namespaces.root}.Test.Utils`,publicCoreClasses:()=>this.settings.rootNamespaceForCoreClasses?this.namespaces.root:this.namespaces.core,implicit:()=>new Set(["System","System.Collections.Generic","System.IO","System.Linq","System.Threading","System.Threading.Tasks","System.Net.Http"])}));te(this,"names",{classes:vt({baseApiException:()=>this.settings.baseApiExceptionClassName||`${this.names.project.clientPrefix}ApiException`,baseException:()=>this.settings.baseExceptionClassName||`${this.names.project.clientPrefix}Exception`,rootClient:()=>this.settings.clientClassName||`${this.names.project.clientPrefix}Client`,rootClientForSnippets:()=>this.settings.exportedClientClassName||this.names.classes.rootClient,customPager:()=>this.settings.customPagerName||`${this.names.project.packageId.replace(/[^a-zA-Z0-9]/g,"")}Pager`,environment:()=>this.settings.environmentClassName||`${this.names.project.clientPrefix}Environment`,exceptionInterceptor:()=>this.settings.exceptionInterceptorClassName||`${this.names.project.packageId.replace(/[^a-zA-Z0-9]/g,"")}ExceptionInterceptor`}),project:vt({client:()=>N4(I4(`${this.generatorConfig.organization}_${this.generatorConfig.workspaceName}`)),clientPrefix:()=>this.settings.exportedClientClassName||this.settings.clientClassName||this.names.project.client,packageId:()=>this.settings.packageId||this.namespaces.root}),files:vt({project:()=>this.namespaces.root,testProject:()=>`${this.namespaces.root}.Test`}),methods:vt({mockOauth:()=>"MockOAuthEndpoint",mockInferredAuth:()=>"MockInferredAuthEndpoint",getAccessTokenAsync:()=>"GetAccessTokenAsync",getAuthHeadersAsync:()=>"GetAuthHeadersAsync"}),variables:vt({client:()=>"client",response:()=>"response",httpRequest:()=>"httpRequest",sendRequest:()=>"sendRequest",responseBody:()=>"responseBody",query:()=>"_query",headers:()=>"_headers"}),parameters:vt({cancellationToken:()=>"cancellationToken",requestOptions:()=>"options",idempotentOptions:()=>"options"})});te(this,"Types",vt({Arbitrary:e=>new zt.ArbitraryType(e,this),HttpMethodExtensions:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("HttpMethodExtensions")}),FormRequest:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("FormRequest")}),Optional:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("Optional")}),ClientOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("ClientOptions"),namespace:this.namespaces.publicCoreClasses}),RawClient:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("RawClient")}),RequestOptions:()=>this.csharp.classReference({namespace:this.namespaces.publicCoreClasses,origin:this.model.staticExplicit("RequestOptions")}),RequestOptionsInterface:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("IRequestOptions")}),JsonRequest:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("JsonRequest")}),Version:()=>this.csharp.classReference({namespace:this.namespaces.publicCore,origin:this.model.staticExplicit("Version")}),ValueConvert:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("ValueConvert")}),FileParameter:()=>this.csharp.classReference({namespace:this.namespaces.publicCore,origin:this.model.staticExplicit("FileParameter"),multipartMethodName:"AddFileParameterPart",multipartMethodNameForCollection:"AddFileParameterParts",isReferenceType:!0}),Headers:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("Headers")}),HeaderValue:()=>this.csharp.classReference({namespace:this.namespaces.core,origin:this.model.staticExplicit("HeaderValue")}),RootClient:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.rootClient),namespace:this.namespaces.root}),RootClientForSnippets:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.rootClientForSnippets),namespace:this.namespaces.root}),BaseApiException:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.baseApiException),namespace:this.namespaces.publicCoreClasses}),BaseException:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.baseException),namespace:this.namespaces.publicCoreClasses}),ExceptionInterceptor:()=>this.csharp.classReference({origin:this.model.staticExplicit("IExceptionInterceptor"),namespace:this.namespaces.core}),ExceptionHandler:()=>this.csharp.classReference({origin:this.model.staticExplicit("ExceptionHandler"),namespace:this.namespaces.core}),CustomExceptionInterceptor:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.exceptionInterceptor),namespace:this.namespaces.core}),ProtoAnyMapper:()=>this.csharp.classReference({origin:this.model.staticExplicit("ProtoAnyMapper"),namespace:this.namespaces.core}),Constants:()=>this.csharp.classReference({origin:this.model.staticExplicit("Constants"),namespace:this.namespaces.core}),EnumSerializer:()=>this.csharp.classReference({origin:this.model.staticExplicit("EnumSerializer"),namespace:this.namespaces.core}),DateTimeSerializer:()=>this.csharp.classReference({origin:this.model.staticExplicit("DateTimeSerializer"),namespace:this.namespaces.core}),JsonUtils:()=>this.csharp.classReference({origin:this.model.staticExplicit("JsonUtils"),namespace:this.namespaces.core}),JsonAssert:()=>this.csharp.classReference({origin:this.model.staticExplicit("JsonAssert"),namespace:this.namespaces.testUtils}),CustomPagerFactory:()=>this.csharp.classReference({origin:this.model.staticExplicit(`${this.names.classes.customPager}Factory`),namespace:this.namespaces.core}),CustomPagerContext:()=>this.csharp.classReference({origin:this.model.staticExplicit(`${this.names.classes.customPager}Context`),namespace:this.namespaces.core}),Environments:()=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.environment),namespace:this.namespaces.publicCoreClasses}),TestClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("TestClient"),namespace:this.namespaces.test}),BaseMockServerTest:()=>this.csharp.classReference({origin:this.model.staticExplicit("BaseMockServerTest"),namespace:this.namespaces.mockServerTest}),IdempotentRequestOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("IdempotentRequestOptions"),namespace:this.namespaces.publicCoreClasses}),IdempotentRequestOptionsInterface:()=>this.csharp.classReference({origin:this.model.staticExplicit("IIdempotentRequestOptions"),namespace:this.namespaces.core}),IStringEnum:()=>this.csharp.classReference({origin:this.model.staticExplicit("IStringEnum"),namespace:this.namespaces.core}),WebSocketClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("WebSocketClient"),namespace:this.namespaces.webSocketsCore}),QueryBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("Query"),namespace:this.namespaces.webSocketsCore}),QueryStringBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("QueryStringBuilder"),namespace:this.namespaces.core}),QueryStringBuilderBuilder:()=>this.csharp.classReference({origin:this.model.staticExplicit("QueryStringBuilder.Builder"),namespace:this.namespaces.core}),OAuthTokenProvider:()=>this.csharp.classReference({origin:this.model.staticExplicit("OAuthTokenProvider"),namespace:this.namespaces.core}),InferredAuthTokenProvider:()=>this.csharp.classReference({origin:this.model.staticExplicit("InferredAuthTokenProvider"),namespace:this.namespaces.core}),ProtoConverter:()=>this.csharp.classReference({origin:this.model.staticExplicit("ProtoConverter"),namespace:this.namespaces.core}),RawGrpcClient:()=>this.csharp.classReference({origin:this.model.staticExplicit("RawGrpcClient"),namespace:this.namespaces.core}),Extensions:()=>this.csharp.classReference({origin:this.model.staticExplicit("Extensions"),namespace:this.namespaces.core}),GrpcRequestOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("GrpcRequestOptions"),namespace:this.namespaces.root}),GrpcChannelOptions:()=>this.csharp.classReference({origin:this.model.staticExplicit("GrpcChannelOptions"),namespace:"Grpc.Net.Client"}),StringEnum:e=>this.csharp.classReference({origin:this.model.staticExplicit("StringEnum"),namespace:this.namespaces.core,generics:e?[e]:void 0}),WebSocketEvent:e=>this.csharp.classReference({origin:this.model.staticExplicit("Event"),namespace:this.namespaces.webSocketsCore,generics:[e]}),ConnectionStatus:()=>this.csharp.classReference({origin:this.model.staticExplicit("ConnectionStatus"),namespace:this.namespaces.webSocketsCore}),WebSocketConnected:()=>this.csharp.classReference({origin:this.model.staticExplicit("Connected"),namespace:this.namespaces.webSocketsCore}),WebSocketClosed:()=>this.csharp.classReference({origin:this.model.staticExplicit("Closed"),namespace:this.namespaces.webSocketsCore}),StringEnumSerializer:e=>this.csharp.classReference({origin:this.model.staticExplicit("StringEnumSerializer"),namespace:this.namespaces.core,generics:[e]}),CustomPagerClass:e=>this.csharp.classReference({origin:this.model.staticExplicit(this.names.classes.customPager),namespace:this.namespaces.core,generics:[e]}),Pager:e=>this.csharp.classReference({origin:this.model.staticExplicit("Pager"),namespace:this.namespaces.core,generics:[e]}),OffsetPager:({requestType:e,requestOptionsType:r,responseType:n,offsetType:i,stepType:c,itemType:s})=>this.csharp.classReference({origin:this.model.staticExplicit("OffsetPager"),namespace:this.namespaces.core,generics:[e,r,n,i,c,s]}),CursorPager:({requestType:e,requestOptionsType:r,responseType:n,cursorType:i,itemType:c})=>this.csharp.classReference({origin:this.model.staticExplicit("CursorPager"),namespace:this.namespaces.core,generics:[e,r,n,i,c]}),CollectionItemSerializer:(e,r)=>this.csharp.classReference({origin:this.model.staticExplicit("CollectionItemSerializer"),namespace:this.namespaces.core,generics:[e,r]}),OneOfSerializer:e=>this.csharp.classReference({origin:this.model.staticExplicit("OneOfSerializer"),namespace:this.namespaces.core,generics:[e]}),AdditionalProperties:e=>this.csharp.classReference({origin:this.model.staticExplicit("AdditionalProperties"),namespace:this.namespaces.publicCore,generics:e?[e]:void 0}),ReadOnlyAdditionalProperties:e=>this.csharp.classReference({origin:this.model.staticExplicit("ReadOnlyAdditionalProperties"),namespace:this.namespaces.publicCore,generics:e?[e]:void 0})}));te(this,"Primitive",vt({string:()=>new zt.String(this),boolean:()=>new zt.Boolean(this),integer:()=>new zt.Integer(this),long:()=>new zt.Long(this),uint:()=>new zt.Uint(this),ulong:()=>new zt.ULong(this),float:()=>new zt.Float(this),double:()=>new zt.Double(this),object:()=>new zt.Object(this)}));te(this,"Value",vt({binary:()=>new Bi.Binary(this),dateOnly:()=>new Bi.DateOnly(this),dateTime:()=>new Bi.DateTime(this),uuid:()=>new Bi.Uuid(this),stringEnum:e=>new Bi.StringEnum(e,this)}));te(this,"Collection",vt({array:e=>new cn.Array(e,this),listType:e=>new cn.ListType(e,this),list:e=>new cn.List(e,this),set:e=>new cn.Set(e,this),map:(e,r,n)=>new cn.Map(e,r,this,n),idictionary:(e,r,n)=>new cn.IDictionary(e,r,this,n),keyValuePair:(e,r)=>new cn.KeyValuePair(e,r,this)}));te(this,"format",vt({private:e=>`_${L4.camelCase(e)}`}));te(this,"initializers",vt({implicitNamespaces:()=>{for(let e of this.namespaces.implicit)this.registry.addImplicitNamespace(e);return!0}}));this.intermediateRepresentation=e,this.apiName=r,this.customConfig=n,this.generatorConfig=i,this.support=c,this.model=new X4(e,this),this.ir=pt.IR.IntermediateRepresentation(e)?e:{},this.dir=pt.DynamicIR.DynamicIntermediateRepresentation(e)?e:{}}initialize(){return this.initializers.implicitNamespaces}get System(){return this.extern.System}get NUnit(){return this.extern.NUnit}get OneOf(){return this.extern.OneOf}get Google(){return this.extern.Google}get Grpc(){return this.extern.Grpc}get WireMock(){return this.extern.WireMock}};u();o();a();var Ta=class{constructor(e){te(this,"generation");this.generation=e}get csharp(){return this.generation.csharp}get settings(){return this.generation.settings}get constants(){return this.generation.constants}get namespaces(){return this.generation.namespaces}get names(){return this.generation.names}get model(){return this.generation.model}get format(){return this.generation.format}get registry(){return this.generation.registry}get Types(){return this.generation.Types}get System(){return this.generation.extern.System}get NUnit(){return this.generation.extern.NUnit}get OneOf(){return this.generation.extern.OneOf}get Google(){return this.generation.extern.Google}get Grpc(){return this.generation.extern.Grpc}get WireMock(){return this.generation.extern.WireMock}get Primitive(){return this.generation.Primitive}get Value(){return this.generation.Value}get Collection(){return this.generation.Collection}};u();o();a();var Q4=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}convert(r){if(r.value===null)return this.context.isNullable(r.typeReference)?this.csharp.Literal.null():(this.context.errors.add({severity:Lt.Critical,message:"Expected non-null value, but got null"}),this.csharp.Literal.nop());if(r.value===void 0&&!r.fallbackToDefault)return this.csharp.Literal.nop();switch(r.typeReference.type){case"list":return this.convertList({list:r.typeReference.value,value:r.value,fallbackToDefault:r.fallbackToDefault});case"literal":return this.convertLiteral({literal:r.typeReference.value,value:r.value});case"map":return this.convertMap({map:r.typeReference,value:r.value,fallbackToDefault:r.fallbackToDefault});case"named":{let n=this.context.resolveNamedType({typeId:r.typeReference.value});return n==null?this.csharp.Literal.nop():this.convertNamed({named:n,value:r.value,as:r.as,fallbackToDefault:r.fallbackToDefault})}case"nullable":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"optional":return this.convert({typeReference:r.typeReference.value,value:r.value,as:r.as});case"primitive":return this.convertPrimitive({primitive:r.typeReference.value,value:r.value,as:r.as,fallbackToDefault:r.fallbackToDefault});case"set":return this.convertSet({set:r.typeReference.value,value:r.value,fallbackToDefault:r.fallbackToDefault});case"unknown":return this.convertUnknown({value:r.value,fallbackToDefault:r.fallbackToDefault});default:rr(r.typeReference)}}convertList({list:r,value:n,fallbackToDefault:i}){return Array.isArray(n)?this.csharp.Literal.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:r,unboxOptionals:!0}),values:n.map((c,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:c})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Lt.Critical,message:`Expected array but got: ${typeof n}`}),this.csharp.Literal.nop())}convertLiteral({literal:r,value:n,fallbackToDefault:i}){switch(r.type){case"boolean":{let c=this.context.getValueAsBoolean({value:n});return c==null?this.csharp.Literal.nop():this.csharp.Literal.boolean(c)}case"string":{let c=this.context.getValueAsString({value:n});return c==null?i?this.Primitive.string.getDeterminsticDefault(i):this.csharp.Literal.nop():this.csharp.Literal.string(c)}default:rr(r)}}convertSet({set:r,value:n,fallbackToDefault:i}){return Array.isArray(n)?this.csharp.Literal.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:r,unboxOptionals:!0}),values:n.map((c,s)=>{this.context.errors.scope({index:s});try{return this.convert({typeReference:r,value:c})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Lt.Critical,message:`Expected array but got: ${typeof n}`}),this.csharp.Literal.nop())}convertMap({map:r,value:n,fallbackToDefault:i}){return typeof n!="object"||n==null?(this.context.errors.add({severity:Lt.Critical,message:`Expected object but got: ${n==null?"null":typeof n}`}),this.csharp.Literal.nop()):this.csharp.Literal.dictionary({keyType:this.context.dynamicTypeMapper.convert({typeReference:r.key}),valueType:r.value.type==="unknown"?this.context.dynamicTypeMapper.convert({typeReference:r.value}).asOptional():this.context.dynamicTypeMapper.convert({typeReference:r.value}),entries:Object.entries(n).map(([c,s])=>{this.context.errors.scope(c);try{return{key:this.convert({typeReference:r.key,value:c,as:"key"}),value:this.convert({typeReference:r.value,value:s})}}finally{this.context.errors.unscope()}})})}convertNamed({named:r,value:n,as:i,fallbackToDefault:c}){switch(r.type){case"alias":return this.convert({typeReference:r.typeReference,value:n,as:i,fallbackToDefault:c});case"discriminatedUnion":return this.settings.shouldGeneratedDiscriminatedUnions?this.convertDiscriminatedUnion({discriminatedUnion:r,value:n,fallbackToDefault:c}):this.convertUnknown({value:n,fallbackToDefault:c});case"enum":return this.getEnumValue(r,n);case"object":return this.convertObject({object_:r,value:n,fallbackToDefault:c});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:r,value:n,fallbackToDefault:c});default:rr(r)}}convertDiscriminatedUnion({discriminatedUnion:r,value:n,fallbackToDefault:i}){let c=this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),s=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:r,value:n});if(s==null)return this.csharp.Literal.nop();let l=s.singleDiscriminatedUnionType,f=this.getBaseProperties({discriminatedUnionTypeInstance:s,singleDiscriminatedUnionType:l});switch(l.type){case"samePropertiesAsObject":{let b=this.context.resolveNamedType({typeId:l.typeId});return b==null?this.csharp.Literal.nop():this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.convertNamed({named:b,value:s.value})]})}case"singleProperty":{if(this.context.getRecord(s.value)==null)return this.csharp.Literal.nop();try{let _=["Value","Type"].includes(l.discriminantValue.name.pascalCase.safeName)?`${l.discriminantValue.name.pascalCase.safeName}Inner`:l.discriminantValue.name.pascalCase.safeName;return this.context.errors.scope(l.discriminantValue.wireValue),this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({name:_,enclosingType:c}),arguments_:[this.convert({typeReference:l.typeReference,value:l.discriminantValue.wireValue})]})]})}finally{this.context.errors.unscope()}}case"noProperties":return this.instantiateUnionWithBaseProperties({classReference:c,baseProperties:f,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({origin:s.discriminantValue,enclosingType:c}),arguments_:[]})]});default:rr(l)}}getBaseProperties({discriminatedUnionTypeInstance:r,singleDiscriminatedUnionType:n}){return this.context.associateByWireValue({parameters:n.properties??[],values:this.context.getRecord(r.value)??{},ignoreMissingParameters:!0}).map(c=>{this.context.errors.scope(c.name.wireValue);try{return{name:this.context.getPropertyName(c.name.name),assignment:this.convert(c)}}finally{this.context.errors.unscope()}})}instantiateUnionWithBaseProperties({classReference:r,arguments_:n,baseProperties:i}){let c=this.csharp.instantiateClass({classReference:r,arguments_:n,multiline:!0});return i.length===0?this.csharp.Literal.reference(c):this.csharp.Literal.reference(this.csharp.codeblock(s=>{s.write(c," "),s.pushScope();for(let l of i)s.write(l.name," = ",l.assignment,",");s.popScope(!1)}))}getEnumValue(r,n){if(typeof n!="string")return this.context.errors.add({severity:Lt.Critical,message:`Expected enum value string, got: ${typeof n}`}),this.csharp.Literal.nop();let i=r.values.find(l=>l.wireValue===n);if(i==null)return this.context.errors.add({severity:Lt.Critical,message:`An enum value named "${n}" does not exist in this context`}),this.csharp.Literal.nop();let c=this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),s=c.registerField(this.model.getPropertyNameFor(i),i);return this.csharp.Literal.reference(this.csharp.enumInstantiation({reference:c,value:s}))}convertObject({object_:r,value:n,fallbackToDefault:i}){let c=this.context.associateByWireValue({parameters:r.properties,values:this.context.getRecord(n)??{}});return this.csharp.Literal.class_({reference:this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),fields:c.map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getClassName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})})}convertUndiscriminatedUnion({undiscriminatedUnion:r,value:n,fallbackToDefault:i}){let c=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:n});return c==null?this.csharp.Literal.nop():c.typeLiteral}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:r,value:n}){for(let i of r.types)try{let c=this.convert({typeReference:i,value:n});return{valueTypeReference:i,typeLiteral:c}}catch{continue}this.context.errors.add({severity:Lt.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof n}" value`})}convertUnknown({value:r,fallbackToDefault:n}){return this.csharp.Literal.unknown(r)}convertPrimitive({primitive:r,value:n,as:i,fallbackToDefault:c}){switch(r){case"INTEGER":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.integer.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.integer(s)}case"LONG":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.long.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.long(s)}case"UINT":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.uint.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.uint(s)}case"UINT_64":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.ulong.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.ulong(s)}case"FLOAT":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.float.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.float(s)}case"DOUBLE":{let s=this.getValueAsNumber({value:n,as:i});return s==null?c?this.Primitive.double.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.double(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:n,as:i});return s==null?c?this.Primitive.boolean.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.boolean(s)}case"STRING":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"DATE":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Value.dateOnly.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.date(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Value.dateTime.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.datetime(s)}case"UUID":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"BASE_64":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:n});return s==null?c?this.Primitive.string.getDeterminsticDefault(c):this.csharp.Literal.nop():this.csharp.Literal.string(s)}default:rr(r)}}getValueAsNumber({value:r,as:n}){let i=n==="key"&&typeof r=="string"?Number(r):r;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:r,as:n}){let i=n==="key"?typeof r=="string"?r==="true":r==="false"?!1:r:r;return this.context.getValueAsBoolean({value:i})}};u();o();a();var k4=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}convert(r){switch(r.typeReference.type){case"list":return this.Collection.list(this.convert({typeReference:r.typeReference,unboxOptionals:!0}));case"literal":return this.convertLiteral({literal:r.typeReference.value});case"map":return this.Collection.map(this.convert({typeReference:r.typeReference.key}),this.convert({typeReference:r.typeReference.value}));case"named":{let n=this.context.resolveNamedType({typeId:r.typeReference.value});return n==null?this.convertUnknown():this.convertNamed({named:n})}case"optional":case"nullable":{let n=this.convert({typeReference:r.typeReference.value});return r.unboxOptionals?n.asNonOptional():n.asOptional()}case"primitive":return this.convertPrimitive({primitive:r.typeReference.value});case"set":return this.Collection.set(this.convert({typeReference:r.typeReference,unboxOptionals:!0}));case"unknown":return this.convertUnknown();default:rr(r.typeReference)}}convertToClassReference(r){return this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)})}convertNamed({named:r}){switch(r.type){case"alias":return this.convert({typeReference:r.typeReference});case"enum":case"object":return this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)});case"discriminatedUnion":return this.settings.shouldGeneratedDiscriminatedUnions?this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}):this.Primitive.object;case"undiscriminatedUnion":return this.OneOf.OneOf(r.types.map(n=>this.convert({typeReference:n})));default:rr(r)}}convertLiteral({literal:r}){switch(r.type){case"boolean":return this.Primitive.boolean;case"string":return this.Primitive.string}}convertUnknown(){return this.Primitive.object}convertPrimitive({primitive:r}){switch(r){case"INTEGER":return this.Primitive.integer;case"UINT":return this.Primitive.uint;case"LONG":return this.Primitive.long;case"UINT_64":return this.Primitive.ulong;case"FLOAT":return this.Primitive.float;case"DOUBLE":return this.Primitive.double;case"BOOLEAN":return this.Primitive.boolean;case"STRING":return this.Primitive.string;case"DATE":return this.Value.dateOnly;case"DATE_TIME":return this.Value.dateTime;case"UUID":return this.Primitive.string;case"BASE_64":return this.Primitive.string;case"BIG_INTEGER":return this.Primitive.string;default:rr(r)}}};u();o();a();var ew=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}getFilePropertyInfo({body:r,value:n}){let i={fileFields:[],bodyPropertyFields:[]},c=this.context.getRecord(n)??{};for(let s of r.properties)switch(s.type){case"file":pt.Record.missingKey(c,s.wireValue)&&(c[s.wireValue]="[bytes]"),i.fileFields.push({name:this.context.getPropertyName(s.name),value:this.getSingleFileProperty({property:s,record:c})});break;case"fileArray":pt.Record.missingKey(c,s.wireValue)&&(c[s.wireValue]=["[bytes]"]),i.fileFields.push({name:this.context.getPropertyName(s.name),value:this.getArrayFileProperty({property:s,record:c})});break;case"bodyProperty":if(pt.Record.missingKey(c,s.name.wireValue))switch(s.typeReference.type){case"optional":break;case"primitive":{switch(s.typeReference.value.toLowerCase()){case"integer":{c[s.name.wireValue]=123;break}case"string":{c[s.name.wireValue]="[string]";break}case"boolean":{c[s.name.wireValue]=!0;break}case"double":{c[s.name.wireValue]=123.456;break}case"float":{c[s.name.wireValue]=123.456;break}case"long":{c[s.name.wireValue]=123456789;break}case"uint":{c[s.name.wireValue]=123;break}case"uint64":{c[s.name.wireValue]=12345;break}case"date":{c[s.name.wireValue]=new Date(2021,1,1);break}case"datetime":{c[s.name.wireValue]=new Date(2021,1,1,12,0,0);break}case"uuid":{c[s.name.wireValue]="123e4567-e89b-12d3-a456-426614174000";break}case"base64":{c[s.name.wireValue]="SGVsbG8gd29ybGQh";break}case"biginteger":{c[s.name.wireValue]="12345678901234567890";break}}break}default:break}i.bodyPropertyFields.push({name:this.context.getPropertyName(s.name.name),value:this.getBodyProperty({property:s,record:c})});break;default:rr(s)}return i}getSingleFileProperty({property:r,record:n}){let i=this.context.getSingleFileValue({property:r,record:n});return i==null?this.csharp.Literal.nop():this.context.getFileParameterForString(i)}getArrayFileProperty({property:r,record:n}){let i=this.context.getFileArrayValues({property:r,record:n});return i==null?this.csharp.Literal.nop():this.csharp.Literal.list({valueType:this.Types.FileParameter,values:i.map(c=>this.context.getFileParameterForString(c))})}getBodyProperty({property:r,record:n}){let i=n[r.name.wireValue];return i==null?this.csharp.Literal.nop():this.context.dynamicLiteralMapper.convert({typeReference:r.typeReference,value:i})}};var tw=class t extends l2{constructor({ir:r,config:n,options:i,generation:c}){super({ir:r,config:n,options:i});te(this,"ir");te(this,"dynamicTypeMapper");te(this,"dynamicLiteralMapper");te(this,"filePropertyMapper");te(this,"generation");this.ir=r,this.generation=c??new Dm(r,n.workspaceName,n.customConfig!=null?n.customConfig:{},n),this.dynamicTypeMapper=new k4({context:this}),this.dynamicLiteralMapper=new Q4({context:this}),this.filePropertyMapper=new ew({context:this})}get namespaces(){return this.generation.namespaces}get registry(){return this.generation.registry}get settings(){return this.generation.settings}get constants(){return this.generation.constants}get names(){return this.generation.names}get model(){return this.generation.model}get format(){return this.generation.format}get csharp(){return this.generation.csharp}get Types(){return this.generation.Types}get System(){return this.generation.extern.System}get NUnit(){return this.generation.extern.NUnit}get OneOf(){return this.generation.extern.OneOf}get Google(){return this.generation.extern.Google}get WireMock(){return this.generation.extern.WireMock}get Primitive(){return this.generation.Primitive}get Value(){return this.generation.Value}get Collection(){return this.generation.Collection}clone(){return new t({ir:this.ir,config:this.config,options:this.options,generation:this.generation})}getFileParameterForString(r){return this.csharp.Literal.reference(this.csharp.instantiateClass({classReference:this.Types.FileParameter,arguments_:[],properties:[{name:"Stream",value:this.getMemoryStreamForString(r)}],multiline:!0}))}getMemoryStreamForString(r){return this.System.IO.MemoryStream.new({arguments_:[this.csharp.invokeMethod({on:this.System.Text.Encoding_UTF8,method:"GetBytes",arguments_:[this.csharp.Literal.string(r)]})]})}getClassName(r){return r.pascalCase.safeName}getParameterName(r){return r.camelCase.safeName}getPropertyName(r){return r.pascalCase.safeName}getMethodName(r){return`${r.pascalCase.safeName}Async`}getNamespace(r,n){let i=this.getNamespaceSegments(r);return i=n!=null?[...i,n]:i,[this.namespaces.root,...i].join(".")}getEnvironmentTypeReferenceFromID(r){let n=this.resolveEnvironmentName(r);if(n!=null)return this.getEnvironmentClassReferenceForEnumName(n)}getEnvironmentClassReferenceForEnumName(r){return this.csharp.classReference({name:`${this.generation.Types.Environments.name}.${this.getClassName(r)}`,namespace:this.namespaces.root})}getNamespaceSegments(r){return(this.settings.explicitNamespaces?r.allParts:r.packagePath).map(i=>i.pascalCase.safeName)}precalculate(r){this.generation.initialize(),this.System.Collections.Generic.KeyValuePair(),this.System.Collections.Generic.IEnumerable(),this.System.Collections.Generic.IAsyncEnumerable(),this.System.Collections.Generic.HashSet(),this.System.Collections.Generic.List(),this.System.Collections.Generic.Dictionary(),this.System.Threading.Tasks.Task(),Object.entries(this.ir.types).sort((n,i)=>n[0].length-i[0].length).forEach(([n,i])=>{this.dynamicTypeMapper.convertToClassReference(i)});for(let[n,i]of r.entries())if(this.csharp.classReference({origin:this.model.staticExplicit(`Example${n}`),namespace:"Usage"}),i.endpoint){let c=this.resolveEndpointLocation(i.endpoint);for(let s of c)switch(s.request.type){case"inlined":this.csharp.classReference({origin:s.request.declaration.name,namespace:this.getNamespace(s.request.declaration.fernFilepath)});break;case"body":break}}this.generation.Types.ClientOptions,this.generation.Types.RootClient,this.csharp.freezeClassReferences()}};u();o();a();var rw=class extends Ta{constructor({context:r}){super(r.generation);te(this,"context");this.context=r}async generateSnippet({endpoint:r,request:n,options:i}){return this.buildCodeBlock({endpoint:r,snippet:n,options:i}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}generateSnippetSync({endpoint:r,request:n,options:i}){return this.buildCodeBlock({endpoint:r,snippet:n,options:i}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}async generateSnippetAst({endpoint:r,request:n,options:i}){throw new Error("Unsupported")}buildCodeBlock({endpoint:r,snippet:n,options:i}){if(r.examples&&!r.examples?.find(l=>pt.DynamicIR.EndpointExample(n)&&l.id===n.id))throw new Error("Endpoint does not have an example that matches the snippet");let c=this.csharp.codeblock(l=>{l.writeNodeStatement(this.constructClient({endpoint:r,snippet:n})),l.newLine(),l.writeNodeStatement(this.callMethod({endpoint:r,snippet:n}))}),s=this.getStyle(i);switch(s){case Bh.Concise:return c;case Bh.Full:return this.buildFullCodeBlock({body:c,options:i});default:rr(s)}}buildFullCodeBlock({body:r,options:n}){let i=this.getConfig(n),c=this.csharp.class_({name:i.fullStyleClassName??"Example",namespace:"Usage",access:Gg.Access.Public});return c.addNamespaceReference(this.Types.RootClient.namespace),c.addMethod({name:"Do",access:Gg.Access.Public,isAsync:!0,parameters:[],body:r}),c}constructClient({endpoint:r,snippet:n}){return this.csharp.codeblock(i=>{i.write("var client = "),i.writeNode(this.getRootClientConstructorInvocation(this.getConstructorArgs({endpoint:r,snippet:n})))})}callMethod({endpoint:r,snippet:n}){let i=r.response?.type==="streaming"||r.response?.type==="streamParameter",c=this.csharp.invokeMethod({on:this.csharp.codeblock("client"),method:this.getMethod({endpoint:r}),arguments_:this.getMethodArgs({endpoint:r,snippet:n}),async:!0,configureAwait:!0,multiline:!0,isAsyncEnumerable:i});return i?this.csharp.codeblock(s=>{s.write("await foreach (var item in "),s.writeNode(c),s.writeLine(")"),s.pushScope(),s.writeLine("/* consume each item */"),s.popScope()}):c}getConstructorArgs({endpoint:r,snippet:n}){let i=[];r.auth!=null&&(n.auth!=null?i.push(...this.getConstructorAuthArgs({auth:r.auth,values:n.auth})):this.context.errors.add({severity:Lt.Warning,message:`Auth with ${r.auth.type} configuration is required for this endpoint`}));let c=[],s=this.getConstructorBaseUrlArgs({baseUrl:n.baseURL,environment:n.environment});s.length>0&&c.push(...s),this.context.errors.scope(Fa.Headers);let l=[];return this.context.ir.headers!=null&&n.headers!=null&&l.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:n.headers})),this.context.errors.unscope(),c.length===0?[...i,...l]:[...i,...l,{name:"clientOptions",assignment:this.csharp.instantiateClass({classReference:this.Types.ClientOptions,arguments_:c.map(f=>({name:f.name,assignment:f.assignment})),multiline:!0})}]}getConstructorBaseUrlArgs({baseUrl:r,environment:n}){let i=this.getBaseUrlArg({baseUrl:r,environment:n});return pt.Literal.nop(i)?[]:[{name:this.getBaseUrlOptionName(),assignment:i}]}getBaseUrlArg({baseUrl:r,environment:n}){if(r!=null&&n!=null)return this.context.errors.add({severity:Lt.Critical,message:"Cannot specify both baseUrl and environment options"}),this.csharp.Literal.nop();if(r!=null)return this.context.ir.environments?.environments.type==="multipleBaseUrls"?(this.context.errors.add({severity:Lt.Critical,message:"The C# SDK doesn't support a baseUrl when multiple URL environments are configured"}),this.csharp.Literal.nop()):this.csharp.Literal.string(r);if(n!=null){if(this.context.isSingleEnvironmentID(n)){let i=this.context.getEnvironmentTypeReferenceFromID(n);return i==null?(this.context.errors.add({severity:Lt.Warning,message:`Environment ${JSON.stringify(n)} was not found`}),this.csharp.Literal.nop()):this.csharp.Literal.reference(i)}if(this.context.isMultiEnvironmentValues(n))return this.context.validateMultiEnvironmentUrlValues(n)?this.csharp.Literal.reference(this.csharp.instantiateClass({classReference:this.Types.Environments,arguments_:Object.entries(n).map(([i,c])=>({name:Qg(lw(i)),assignment:this.context.dynamicLiteralMapper.convert({typeReference:{type:"primitive",value:"STRING"},value:c})})),multiline:!0})):this.csharp.Literal.nop()}return this.csharp.Literal.nop()}getConstructorAuthArgs({auth:r,values:n}){if(n.type!==r.type)return this.addError(this.context.newAuthMismatchError({auth:r,values:n}).message),[];switch(r.type){case"basic":return n.type==="basic"?this.getConstructorBasicAuthArg({auth:r,values:n}):[];case"bearer":return n.type==="bearer"?this.getConstructorBearerAuthArgs({auth:r,values:n}):[];case"header":return n.type==="header"?this.getConstructorHeaderAuthArgs({auth:r,values:n}):[];case"oauth":return n.type==="oauth"?this.getConstructorOAuthArgs({auth:r,values:n}):[];case"inferred":return n.type==="inferred"?this.getConstructorInferredAuthArgs({auth:r,values:n}):[];default:rr(r)}}addError(r){this.context.errors.add({severity:Lt.Critical,message:r})}addWarning(r){this.context.errors.add({severity:Lt.Warning,message:r})}getConstructorBasicAuthArg({auth:r,values:n}){return[{name:this.context.getParameterName(r.username),assignment:this.csharp.Literal.string(n.username)},{name:this.context.getParameterName(r.password),assignment:this.csharp.Literal.string(n.password)}]}getConstructorBearerAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.token),assignment:this.csharp.Literal.string(n.token)}]}getConstructorHeaderAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.header.name.name),assignment:this.context.dynamicLiteralMapper.convert({typeReference:r.header.typeReference,value:n.value,fallbackToDefault:r.header.name.wireValue})}]}getConstructorOAuthArgs({auth:r,values:n}){return[{name:this.context.getParameterName(r.clientId),assignment:this.csharp.Literal.string(n.clientId)},{name:this.context.getParameterName(r.clientSecret),assignment:this.csharp.Literal.string(n.clientSecret)}]}getConstructorInferredAuthArgs({auth:r,values:n}){let i=[];if(r.parameters!=null)for(let c of r.parameters){let s=c.name.wireValue,l=n.values?.[s];i.push({name:this.context.getParameterName(c.name.name),assignment:this.context.dynamicLiteralMapper.convert({typeReference:c.typeReference,value:l,fallbackToDefault:s})})}else this.context.errors.add({severity:Lt.Critical,message:"Inferred auth parameters are not defined in the IR. Please ensure you're using IR version 62.3.0 or later."});return i}getConstructorHeaderArgs({headers:r,values:n}){let i=[];for(let c of r){let s=this.getConstructorHeaderArg({header:c,value:n.value});s!=null&&i.push({name:this.context.getParameterName(c.name.name),assignment:s})}return i}getConstructorHeaderArg({header:r,value:n}){let i=this.context.dynamicLiteralMapper.convert({typeReference:r.typeReference,value:n,fallbackToDefault:r.name.wireValue});if(!pt.Literal.nop(i))return i}getMethodArgs({endpoint:r,snippet:n}){switch(r.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:r.request,snippet:n});case"body":return this.getMethodArgsForBodyRequest({request:r.request,snippet:n});default:rr(r.request)}}getMethodArgsForInlinedRequest({request:r,snippet:n}){let i=[];this.context.errors.scope(Fa.PathParameters);let c=[],s=[...this.context.ir.pathParameters??[],...r.pathParameters??[]];s.length>0&&c.push(...this.getPathParameters({namedParameters:s,snippet:n})),this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody);let l=this.getFilePropertyInfo({request:r,snippet:n});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:r,inlinePathParameters:this.settings.shouldInlinePathParameters})||i.push(...c.map(f=>f.value)),i.push(this.getInlinedRequestArg({request:r,snippet:n,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:r,inlinePathParameters:this.settings.shouldInlinePathParameters})?c:[],filePropertyInfo:l})),i}getFilePropertyInfo({request:r,snippet:n}){return r.body==null||!this.context.isFileUploadRequestBody(r.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:r.body,value:n.requestBody})}getInlinedRequestArg({request:r,snippet:n,pathParameterFields:i,filePropertyInfo:c}){this.context.errors.scope(Fa.QueryParameters);let l=this.context.associateQueryParametersByWireValue({parameters:r.queryParameters??[],values:n.queryParameters??{}}).map(O=>({name:this.context.getPropertyName(O.name.name),value:this.context.dynamicLiteralMapper.convert(O)}));this.context.errors.unscope(),this.context.errors.scope(Fa.Headers);let b=this.context.associateByWireValue({parameters:r.headers??[],values:n.headers??{}}).map(O=>({name:this.context.getPropertyName(O.name.name),value:this.context.dynamicLiteralMapper.convert({...O,fallbackToDefault:O.name.wireValue})}));this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody);let _=r.body!=null?this.getInlinedRequestBodyConstructorFields({body:r.body,value:n.requestBody,filePropertyInfo:c}):[];return this.context.errors.unscope(),this.csharp.Literal.class_({reference:this.csharp.classReference({origin:r.declaration,namespace:this.context.getNamespace(r.declaration.fernFilepath)}),fields:[...i,...l,...b,..._]})}getInlinedRequestBodyConstructorFields({body:r,value:n,filePropertyInfo:i}){switch(r.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:r.value,value:n});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:r,value:n})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:i});default:rr(r)}}getInlinedRequestBodyPropertyConstructorFields({parameters:r,value:n}){let i=[],c=this.context.associateByWireValue({parameters:r,values:this.context.getRecord(n)??{}});for(let s of c)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicLiteralMapper.convert({...s,fallbackToDefault:s.name.wireValue})});return i}getFileUploadRequestBodyConstructorFields({filePropertyInfo:r}){return[...r.fileFields,...r.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:r,value:n}){return{name:this.context.getPropertyName(r.bodyKey),value:this.getReferencedRequestBodyPropertyLiteral({body:r.bodyType,value:n})}}getReferencedRequestBodyPropertyLiteral({body:r,value:n}){switch(r.type){case"bytes":return this.getBytesBodyRequestArg({value:n});case"typeReference":return this.context.dynamicLiteralMapper.convert({typeReference:r.value,value:n,fallbackToDefault:JSON.stringify(r.value)});default:rr(r)}}getMethodArgsForBodyRequest({request:r,snippet:n}){let i=[];this.context.errors.scope(Fa.PathParameters);let c=[...this.context.ir.pathParameters??[],...r.pathParameters??[]];return c.length>0&&i.push(...this.getPathParameters({namedParameters:c,snippet:n}).map(s=>s.value)),this.context.errors.unscope(),this.context.errors.scope(Fa.RequestBody),r.body!=null&&i.push(this.getBodyRequestArg({body:r.body,value:n.requestBody})),this.context.errors.unscope(),i}getBodyRequestArg({body:r,value:n}){switch(r.type){case"bytes":return this.getBytesBodyRequestArg({value:n});case"typeReference":return r.value.type==="optional"&&n==null?this.csharp.Literal.null():this.context.dynamicLiteralMapper.convert({typeReference:r.value,value:n,fallbackToDefault:JSON.stringify(r.value)});default:rr(r)}}getBytesBodyRequestArg({value:r}){let n=this.context.getValueAsString({value:r});return n==null&&(this.context.errors.add({severity:Lt.Critical,message:"The bytes request body must be provided in string format"}),n="[bytes]"),this.csharp.Literal.reference(this.context.getMemoryStreamForString(n))}getRootClientConstructorInvocation(r){return this.csharp.instantiateClass({classReference:this.Types.RootClient,arguments_:r,forceUseConstructor:!0,multiline:!0})}getPathParameters({namedParameters:r,snippet:n}){let i=[],c=this.context.associateByWireValueOrDefault({parameters:r,values:n.pathParameters??{}});for(let s of c)i.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicLiteralMapper.convert({...s,fallbackToDefault:s.name.wireValue})});return i}getMethod({endpoint:r}){return r.declaration.fernFilepath.allParts.length>0?`${r.declaration.fernFilepath.allParts.map(n=>this.context.getClassName(n)).join(".")}.${this.context.getMethodName(r.declaration.name)}`:this.context.getMethodName(r.declaration.name)}getBaseUrlOptionName(){return this.context.ir.environments?.environments.type==="multipleBaseUrls"?"Environment":"BaseUrl"}getStyle(r){return r.style??this.context.options.style??Bh.Full}getConfig(r){return r.config??this.context.options.config??{}}};var nw=class extends o2{constructor({ir:e,config:r,options:n={}}){super(new tw({ir:e,config:r,options:n}))}precalculate(e){this.context.precalculate(e)}async generate(e,r={}){return super.generate(e,r)}generateSync(e,r={}){return super.generateSync(e,r)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new rw({context:e})}};0&&(module.exports={DynamicSnippetsGenerator});
173
173
  /*! Bundled license information:
174
174
 
175
175
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: