raspberry_games_server_game_logic 1.8.396 → 1.8.398

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/Kosi-Kaverit-kaverit.js +23 -23
  2. package/Kosi-Kodein-kodein-di.js +161 -161
  3. package/Kotlin-DateTime-library-kotlinx-datetime.js +171 -171
  4. package/Kotlin-DateTime-library-kotlinx-datetime.js.map +1 -1
  5. package/Logic_Debertz-ai_module.js +1944 -0
  6. package/Logic_Debertz-ai_module.js.map +1 -0
  7. package/Logic_Debertz-core.js +385 -385
  8. package/Logic_Debertz-engine.js +13846 -13246
  9. package/Logic_Debertz-engine.js.map +1 -1
  10. package/Logic_Debertz-game_server.d.ts +5 -3
  11. package/Logic_Debertz-game_server.js +1451 -1451
  12. package/Logic_Debertz-game_server.js.map +1 -1
  13. package/error-library-error.js +5 -5
  14. package/kotlin-kotlin-stdlib.js +2071 -2010
  15. package/kotlin-kotlin-stdlib.js.map +1 -1
  16. package/kotlinx-atomicfu.js +9 -9
  17. package/kotlinx-coroutines-core.js +703 -703
  18. package/kotlinx-coroutines-core.js.map +1 -1
  19. package/kotlinx-io-kotlinx-io-core.js +41 -41
  20. package/kotlinx-serialization-kotlinx-serialization-core.js +196 -196
  21. package/kotlinx-serialization-kotlinx-serialization-core.js.map +1 -1
  22. package/kotlinx-serialization-kotlinx-serialization-json.js +253 -253
  23. package/ktor-ktor-client-content-negotiation.js +89 -89
  24. package/ktor-ktor-client-core.js +1054 -1029
  25. package/ktor-ktor-client-core.js.map +1 -1
  26. package/ktor-ktor-client-logging.js +293 -288
  27. package/ktor-ktor-client-logging.js.map +1 -1
  28. package/ktor-ktor-events.js +5 -5
  29. package/ktor-ktor-http.js +164 -160
  30. package/ktor-ktor-http.js.map +1 -1
  31. package/ktor-ktor-io.js +372 -372
  32. package/ktor-ktor-serialization-kotlinx.js +127 -127
  33. package/ktor-ktor-serialization.js +68 -68
  34. package/ktor-ktor-utils.js +278 -278
  35. package/ktor-ktor-websockets.js +15 -15
  36. package/package.json +1 -1
  37. package/random-library-crypto-rand.js +13 -13
  38. package/random-library-secure-random.js +5 -5
  39. package/raspberry-cardgame-lib-core.js +97 -97
  40. package/raspberry-cardgame-lib-core.js.map +1 -1
  41. package/raspberry-cardgame-lib-logger.js +12 -12
  42. package/raspberry-cardgame-lib-random.js +237 -237
  43. package/uuid.js +15 -15
  44. package/uuid.js.map +1 -1
@@ -0,0 +1,1944 @@
1
+ (function (factory) {
2
+ if (typeof define === 'function' && define.amd)
3
+ define(['exports', './kotlin-kotlin-stdlib.js', './ktor-ktor-http.js', './ktor-ktor-client-core.js', './ktor-ktor-utils.js', './kotlinx-serialization-kotlinx-serialization-core.js', './Kosi-Kodein-kodein-di.js', './ktor-ktor-client-content-negotiation.js', './ktor-ktor-client-logging.js', './kotlinx-serialization-kotlinx-serialization-json.js', './ktor-ktor-serialization-kotlinx-json.js', './Kosi-Kaverit-kaverit.js'], factory);
4
+ else if (typeof exports === 'object')
5
+ factory(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./ktor-ktor-http.js'), require('./ktor-ktor-client-core.js'), require('./ktor-ktor-utils.js'), require('./kotlinx-serialization-kotlinx-serialization-core.js'), require('./Kosi-Kodein-kodein-di.js'), require('./ktor-ktor-client-content-negotiation.js'), require('./ktor-ktor-client-logging.js'), require('./kotlinx-serialization-kotlinx-serialization-json.js'), require('./ktor-ktor-serialization-kotlinx-json.js'), require('./Kosi-Kaverit-kaverit.js'));
6
+ else {
7
+ if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
8
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'Logic_Debertz-ai_module'.");
9
+ }
10
+ if (typeof globalThis['ktor-ktor-http'] === 'undefined') {
11
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-http' was not found. Please, check whether 'ktor-ktor-http' is loaded prior to 'Logic_Debertz-ai_module'.");
12
+ }
13
+ if (typeof globalThis['ktor-ktor-client-core'] === 'undefined') {
14
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-client-core' was not found. Please, check whether 'ktor-ktor-client-core' is loaded prior to 'Logic_Debertz-ai_module'.");
15
+ }
16
+ if (typeof globalThis['ktor-ktor-utils'] === 'undefined') {
17
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-utils' was not found. Please, check whether 'ktor-ktor-utils' is loaded prior to 'Logic_Debertz-ai_module'.");
18
+ }
19
+ if (typeof globalThis['kotlinx-serialization-kotlinx-serialization-core'] === 'undefined') {
20
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'kotlinx-serialization-kotlinx-serialization-core' was not found. Please, check whether 'kotlinx-serialization-kotlinx-serialization-core' is loaded prior to 'Logic_Debertz-ai_module'.");
21
+ }
22
+ if (typeof globalThis['Kosi-Kodein-kodein-di'] === 'undefined') {
23
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'Kosi-Kodein-kodein-di' was not found. Please, check whether 'Kosi-Kodein-kodein-di' is loaded prior to 'Logic_Debertz-ai_module'.");
24
+ }
25
+ if (typeof globalThis['ktor-ktor-client-content-negotiation'] === 'undefined') {
26
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-client-content-negotiation' was not found. Please, check whether 'ktor-ktor-client-content-negotiation' is loaded prior to 'Logic_Debertz-ai_module'.");
27
+ }
28
+ if (typeof globalThis['ktor-ktor-client-logging'] === 'undefined') {
29
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-client-logging' was not found. Please, check whether 'ktor-ktor-client-logging' is loaded prior to 'Logic_Debertz-ai_module'.");
30
+ }
31
+ if (typeof globalThis['kotlinx-serialization-kotlinx-serialization-json'] === 'undefined') {
32
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'kotlinx-serialization-kotlinx-serialization-json' was not found. Please, check whether 'kotlinx-serialization-kotlinx-serialization-json' is loaded prior to 'Logic_Debertz-ai_module'.");
33
+ }
34
+ if (typeof globalThis['ktor-ktor-serialization-kotlinx-json'] === 'undefined') {
35
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'ktor-ktor-serialization-kotlinx-json' was not found. Please, check whether 'ktor-ktor-serialization-kotlinx-json' is loaded prior to 'Logic_Debertz-ai_module'.");
36
+ }
37
+ if (typeof globalThis['Kosi-Kaverit-kaverit'] === 'undefined') {
38
+ throw new Error("Error loading module 'Logic_Debertz-ai_module'. Its dependency 'Kosi-Kaverit-kaverit' was not found. Please, check whether 'Kosi-Kaverit-kaverit' is loaded prior to 'Logic_Debertz-ai_module'.");
39
+ }
40
+ globalThis['Logic_Debertz-ai_module'] = factory(typeof globalThis['Logic_Debertz-ai_module'] === 'undefined' ? {} : globalThis['Logic_Debertz-ai_module'], globalThis['kotlin-kotlin-stdlib'], globalThis['ktor-ktor-http'], globalThis['ktor-ktor-client-core'], globalThis['ktor-ktor-utils'], globalThis['kotlinx-serialization-kotlinx-serialization-core'], globalThis['Kosi-Kodein-kodein-di'], globalThis['ktor-ktor-client-content-negotiation'], globalThis['ktor-ktor-client-logging'], globalThis['kotlinx-serialization-kotlinx-serialization-json'], globalThis['ktor-ktor-serialization-kotlinx-json'], globalThis['Kosi-Kaverit-kaverit']);
41
+ }
42
+ }(function (_, kotlin_kotlin, kotlin_io_ktor_ktor_http, kotlin_io_ktor_ktor_client_core, kotlin_io_ktor_ktor_utils, kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core, kotlin_org_kodein_di_kodein_di, kotlin_io_ktor_ktor_client_content_negotiation, kotlin_io_ktor_ktor_client_logging, kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json, kotlin_io_ktor_ktor_serialization_kotlinx_json, kotlin_org_kodein_type_kaverit) {
43
+ 'use strict';
44
+ //region block: imports
45
+ var imul = Math.imul;
46
+ var protoOf = kotlin_kotlin.$_$.kd;
47
+ var initMetadataForInterface = kotlin_kotlin.$_$.nc;
48
+ var VOID = kotlin_kotlin.$_$.b;
49
+ var HttpHeaders_getInstance = kotlin_io_ktor_ktor_http.$_$.e;
50
+ var Unit_instance = kotlin_kotlin.$_$.f5;
51
+ var CoroutineImpl = kotlin_kotlin.$_$.qa;
52
+ var HttpRequestBuilder = kotlin_io_ktor_ktor_client_core.$_$.l;
53
+ var url = kotlin_io_ktor_ktor_client_core.$_$.p;
54
+ var headers = kotlin_io_ktor_ktor_client_core.$_$.n;
55
+ var Application_getInstance = kotlin_io_ktor_ktor_http.$_$.b;
56
+ var contentType = kotlin_io_ktor_ktor_http.$_$.e1;
57
+ var JsType_instance = kotlin_io_ktor_ktor_utils.$_$.b;
58
+ var getKClass = kotlin_kotlin.$_$.fe;
59
+ var arrayOf = kotlin_kotlin.$_$.bi;
60
+ var createKType = kotlin_kotlin.$_$.de;
61
+ var typeInfoImpl = kotlin_io_ktor_ktor_utils.$_$.l;
62
+ var OutgoingContent = kotlin_io_ktor_ktor_http.$_$.p;
63
+ var NullBody_instance = kotlin_io_ktor_ktor_http.$_$.a;
64
+ var Companion_getInstance = kotlin_io_ktor_ktor_http.$_$.f;
65
+ var HttpStatement = kotlin_io_ktor_ktor_client_core.$_$.s;
66
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.ba;
67
+ var Companion_instance = kotlin_kotlin.$_$.a5;
68
+ var THROW_CCE = kotlin_kotlin.$_$.nh;
69
+ var _Result___init__impl__xyqfz8 = kotlin_kotlin.$_$.t2;
70
+ var createFailure = kotlin_kotlin.$_$.di;
71
+ var Exception = kotlin_kotlin.$_$.fh;
72
+ var Result = kotlin_kotlin.$_$.lh;
73
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.mc;
74
+ var initMetadataForClass = kotlin_kotlin.$_$.kc;
75
+ var getStringHashCode = kotlin_kotlin.$_$.ic;
76
+ var equalsLong = kotlin_kotlin.$_$.eb;
77
+ var System_instance = kotlin_kotlin.$_$.u4;
78
+ var removeAll = kotlin_kotlin.$_$.t8;
79
+ var subtract = kotlin_kotlin.$_$.ob;
80
+ var compare = kotlin_kotlin.$_$.za;
81
+ var Long = kotlin_kotlin.$_$.ih;
82
+ var LinkedHashMap_init_$Create$ = kotlin_kotlin.$_$.q;
83
+ var compareTo = kotlin_kotlin.$_$.bc;
84
+ var StringSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.v;
85
+ var ArrayListSerializer = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.x1;
86
+ var LazyThreadSafetyMode_PUBLICATION_getInstance = kotlin_kotlin.$_$.e;
87
+ var lazy = kotlin_kotlin.$_$.ji;
88
+ var initMetadataForCompanion = kotlin_kotlin.$_$.lc;
89
+ var PluginGeneratedSerialDescriptor = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.e2;
90
+ var emptyList = kotlin_kotlin.$_$.d7;
91
+ var equals = kotlin_kotlin.$_$.dc;
92
+ var UnknownFieldException_init_$Create$ = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.g;
93
+ var get_nullable = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.z;
94
+ var typeParametersSerializers = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.z1;
95
+ var GeneratedSerializer = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.a2;
96
+ var initMetadataForObject = kotlin_kotlin.$_$.pc;
97
+ var throwMissingFieldException = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.j2;
98
+ var objectCreate = kotlin_kotlin.$_$.jd;
99
+ var toString = kotlin_kotlin.$_$.nd;
100
+ var hashCode = kotlin_kotlin.$_$.jc;
101
+ var createAnnotatedEnumSerializer = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.g2;
102
+ var SerializerFactory = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.f2;
103
+ var Enum = kotlin_kotlin.$_$.dh;
104
+ var DoubleSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.q;
105
+ var IntSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.t;
106
+ var LongSerializer_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_core.$_$.u;
107
+ var getNumberHashCode = kotlin_kotlin.$_$.gc;
108
+ var toString_0 = kotlin_kotlin.$_$.ri;
109
+ var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.z;
110
+ var take = kotlin_kotlin.$_$.ag;
111
+ var ArrayList_init_$Create$ = kotlin_kotlin.$_$.h;
112
+ var takeLast = kotlin_kotlin.$_$.h9;
113
+ var listOf = kotlin_kotlin.$_$.g8;
114
+ var _Result___get_value__impl__bjfvqg = kotlin_kotlin.$_$.x2;
115
+ var firstOrNull = kotlin_kotlin.$_$.h7;
116
+ var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.p1;
117
+ var _Result___get_isSuccess__impl__sndoy8 = kotlin_kotlin.$_$.w2;
118
+ var Module_init_$Create$ = kotlin_org_kodein_di_kodein_di.$_$.a;
119
+ var HttpClient = kotlin_io_ktor_ktor_client_core.$_$.u;
120
+ var Plugin_getInstance = kotlin_io_ktor_ktor_client_content_negotiation.$_$.a;
121
+ var Companion_getInstance_0 = kotlin_io_ktor_ktor_client_logging.$_$.d;
122
+ var Json = kotlin_org_jetbrains_kotlinx_kotlinx_serialization_json.$_$.b;
123
+ var json = kotlin_io_ktor_ktor_serialization_kotlinx_json.$_$.a;
124
+ var Companion_instance_0 = kotlin_io_ktor_ktor_client_logging.$_$.c;
125
+ var get_DEFAULT = kotlin_io_ktor_ktor_client_logging.$_$.e;
126
+ var LogLevel_INFO_getInstance = kotlin_io_ktor_ktor_client_logging.$_$.b;
127
+ var typeToken = kotlin_org_kodein_type_kaverit.$_$.d;
128
+ var TypeToken = kotlin_org_kodein_type_kaverit.$_$.b;
129
+ var isInterface = kotlin_kotlin.$_$.yc;
130
+ var HttpClient_0 = kotlin_io_ktor_ktor_client_core.$_$.v;
131
+ var Singleton = kotlin_org_kodein_di_kodein_di.$_$.d;
132
+ //endregion
133
+ //region block: pre-declaration
134
+ initMetadataForInterface(OpenAIApi, 'OpenAIApi', VOID, VOID, VOID, [1]);
135
+ initMetadataForCoroutine($chatCompletionCOROUTINE$, CoroutineImpl);
136
+ initMetadataForClass(OpenAIApiImpl, 'OpenAIApiImpl', VOID, VOID, [OpenAIApi], [1]);
137
+ initMetadataForInterface(BotChatCache, 'BotChatCache');
138
+ initMetadataForClass(CacheEntry, 'CacheEntry');
139
+ initMetadataForClass(InMemoryBotChatCache, 'InMemoryBotChatCache', InMemoryBotChatCache, VOID, [BotChatCache]);
140
+ initMetadataForCompanion(Companion);
141
+ initMetadataForObject($serializer, '$serializer', VOID, VOID, [GeneratedSerializer]);
142
+ initMetadataForClass(BotChatContext, 'BotChatContext', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance});
143
+ initMetadataForCompanion(Companion_0, VOID, [SerializerFactory]);
144
+ initMetadataForClass(Role, 'Role', VOID, Enum, VOID, VOID, VOID, {0: Companion_getInstance_2});
145
+ initMetadataForCompanion(Companion_1);
146
+ initMetadataForObject($serializer_0, '$serializer', VOID, VOID, [GeneratedSerializer]);
147
+ initMetadataForClass(ChatMessage, 'ChatMessage', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_0});
148
+ initMetadataForCompanion(Companion_2);
149
+ initMetadataForObject($serializer_1, '$serializer', VOID, VOID, [GeneratedSerializer]);
150
+ initMetadataForClass(OpenAIConfig, 'OpenAIConfig', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_1});
151
+ initMetadataForCompanion(Companion_3);
152
+ initMetadataForObject($serializer_2, '$serializer', VOID, VOID, [GeneratedSerializer]);
153
+ initMetadataForClass(OpenAIRequest, 'OpenAIRequest', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_2});
154
+ initMetadataForObject($serializer_3, '$serializer', VOID, VOID, [GeneratedSerializer]);
155
+ initMetadataForObject($serializer_4, '$serializer', VOID, VOID, [GeneratedSerializer]);
156
+ initMetadataForClass(Choice, 'Choice', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_3});
157
+ initMetadataForClass(Usage, 'Usage', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_4});
158
+ initMetadataForCompanion(Companion_4);
159
+ initMetadataForObject($serializer_5, '$serializer', VOID, VOID, [GeneratedSerializer]);
160
+ initMetadataForClass(OpenAIResponse, 'OpenAIResponse', VOID, VOID, VOID, VOID, VOID, {0: $serializer_getInstance_5});
161
+ initMetadataForInterface(BotChatRepository, 'BotChatRepository', VOID, VOID, VOID, [2, 1]);
162
+ initMetadataForCoroutine($executeRequestCOROUTINE$, CoroutineImpl);
163
+ initMetadataForClass(BotChatRepositoryImpl, 'BotChatRepositoryImpl', VOID, VOID, [BotChatRepository], [2, 1]);
164
+ initMetadataForInterface(BotChatInteractor, 'BotChatInteractor', VOID, VOID, VOID, [2, 1]);
165
+ initMetadataForClass(BotChatInteractorImpl, 'BotChatInteractorImpl', VOID, VOID, [BotChatInteractor], [2, 1]);
166
+ //endregion
167
+ function OpenAIApi() {
168
+ }
169
+ function OpenAIApiImpl$chatCompletion$lambda(this$0) {
170
+ return function ($this$headers) {
171
+ $this$headers.w39(HttpHeaders_getInstance().s3f_1, 'Bearer ' + this$0.g6m_1.a6m_1);
172
+ return Unit_instance;
173
+ };
174
+ }
175
+ function $chatCompletionCOROUTINE$(_this__u8e3s4, messages, resultContinuation) {
176
+ CoroutineImpl.call(this, resultContinuation);
177
+ this.q6m_1 = _this__u8e3s4;
178
+ this.r6m_1 = messages;
179
+ }
180
+ protoOf($chatCompletionCOROUTINE$).a9 = function () {
181
+ var suspendResult = this.u8_1;
182
+ $sm: do
183
+ try {
184
+ var tmp = this.s8_1;
185
+ switch (tmp) {
186
+ case 0:
187
+ this.t8_1 = 4;
188
+ this.t8_1 = 3;
189
+ var request = new OpenAIRequest(this.q6m_1.g6m_1.b6m_1, this.r6m_1, this.q6m_1.g6m_1.d6m_1, this.q6m_1.g6m_1.e6m_1);
190
+ var tmp0 = this.q6m_1.h6m_1;
191
+ var urlString = this.q6m_1.g6m_1.c6m_1 + '/chat/completions';
192
+ var this_0 = new HttpRequestBuilder();
193
+ url(this_0, urlString);
194
+ headers(this_0, OpenAIApiImpl$chatCompletion$lambda(this.q6m_1));
195
+ contentType(this_0, Application_getInstance().x3d_1);
196
+ if (request == null) {
197
+ this_0.o3s_1 = NullBody_instance;
198
+ var tmp_0 = JsType_instance;
199
+ var tmp_1 = getKClass(OpenAIRequest);
200
+ var tmp_2;
201
+ try {
202
+ tmp_2 = createKType(getKClass(OpenAIRequest), arrayOf([]), false);
203
+ } catch ($p) {
204
+ var tmp_3;
205
+ if ($p instanceof Error) {
206
+ var cause = $p;
207
+ tmp_3 = null;
208
+ } else {
209
+ throw $p;
210
+ }
211
+ tmp_2 = tmp_3;
212
+ }
213
+ this_0.a3y(typeInfoImpl(tmp_0, tmp_1, tmp_2));
214
+ } else {
215
+ if (request instanceof OutgoingContent) {
216
+ this_0.o3s_1 = request;
217
+ this_0.a3y(null);
218
+ } else {
219
+ this_0.o3s_1 = request;
220
+ var tmp_4 = JsType_instance;
221
+ var tmp_5 = getKClass(OpenAIRequest);
222
+ var tmp_6;
223
+ try {
224
+ tmp_6 = createKType(getKClass(OpenAIRequest), arrayOf([]), false);
225
+ } catch ($p) {
226
+ var tmp_7;
227
+ if ($p instanceof Error) {
228
+ var cause_0 = $p;
229
+ tmp_7 = null;
230
+ } else {
231
+ throw $p;
232
+ }
233
+ tmp_6 = tmp_7;
234
+ }
235
+ this_0.a3y(typeInfoImpl(tmp_4, tmp_5, tmp_6));
236
+ }
237
+ }
238
+
239
+ this_0.m3s_1 = Companion_getInstance().o3j_1;
240
+ this.s8_1 = 1;
241
+ suspendResult = (new HttpStatement(this_0, tmp0)).b4j(this);
242
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
243
+ return suspendResult;
244
+ }
245
+
246
+ continue $sm;
247
+ case 1:
248
+ var response = suspendResult;
249
+ var tmp_8 = this;
250
+ tmp_8.t6m_1 = Companion_instance;
251
+ this.s8_1 = 2;
252
+ var tmp_9 = response.p3v();
253
+ var tmp_10 = JsType_instance;
254
+ var tmp_11 = getKClass(OpenAIResponse);
255
+ var tmp_12;
256
+ try {
257
+ tmp_12 = createKType(getKClass(OpenAIResponse), arrayOf([]), false);
258
+ } catch ($p) {
259
+ var tmp_13;
260
+ if ($p instanceof Error) {
261
+ var cause_1 = $p;
262
+ tmp_13 = null;
263
+ } else {
264
+ throw $p;
265
+ }
266
+ tmp_12 = tmp_13;
267
+ }
268
+
269
+ suspendResult = tmp_9.t3u(typeInfoImpl(tmp_10, tmp_11, tmp_12), this);
270
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
271
+ return suspendResult;
272
+ }
273
+
274
+ continue $sm;
275
+ case 2:
276
+ var tmp2 = suspendResult instanceof OpenAIResponse ? suspendResult : THROW_CCE();
277
+ var tmp_14 = this;
278
+ this.t6m_1;
279
+ tmp_14.s6m_1 = _Result___init__impl__xyqfz8(tmp2);
280
+ this.t8_1 = 4;
281
+ this.s8_1 = 5;
282
+ continue $sm;
283
+ case 3:
284
+ this.t8_1 = 4;
285
+ var tmp_15 = this.v8_1;
286
+ if (tmp_15 instanceof Exception) {
287
+ var e = this.v8_1;
288
+ var tmp_16 = this;
289
+ tmp_16.s6m_1 = _Result___init__impl__xyqfz8(createFailure(e));
290
+ this.s8_1 = 5;
291
+ continue $sm;
292
+ } else {
293
+ throw this.v8_1;
294
+ }
295
+
296
+ case 4:
297
+ throw this.v8_1;
298
+ case 5:
299
+ this.t8_1 = 4;
300
+ return new Result(this.s6m_1);
301
+ }
302
+ } catch ($p) {
303
+ var e_0 = $p;
304
+ if (this.t8_1 === 4) {
305
+ throw e_0;
306
+ } else {
307
+ this.s8_1 = this.t8_1;
308
+ this.v8_1 = e_0;
309
+ }
310
+ }
311
+ while (true);
312
+ };
313
+ function OpenAIApiImpl(config, httpClient) {
314
+ this.g6m_1 = config;
315
+ this.h6m_1 = httpClient;
316
+ }
317
+ protoOf(OpenAIApiImpl).z6l = function (messages, $completion) {
318
+ var tmp = new $chatCompletionCOROUTINE$(this, messages, $completion);
319
+ tmp.u8_1 = Unit_instance;
320
+ tmp.v8_1 = null;
321
+ var tmp_0 = tmp.a9();
322
+ if (tmp_0 === get_COROUTINE_SUSPENDED())
323
+ return tmp_0;
324
+ return tmp_0;
325
+ };
326
+ function BotChatCache() {
327
+ }
328
+ function CacheEntry(value, timestamp) {
329
+ this.v6m_1 = value;
330
+ this.w6m_1 = timestamp;
331
+ }
332
+ protoOf(CacheEntry).toString = function () {
333
+ return 'CacheEntry(value=' + this.v6m_1 + ', timestamp=' + this.w6m_1.toString() + ')';
334
+ };
335
+ protoOf(CacheEntry).hashCode = function () {
336
+ var result = getStringHashCode(this.v6m_1);
337
+ result = imul(result, 31) + this.w6m_1.hashCode() | 0;
338
+ return result;
339
+ };
340
+ protoOf(CacheEntry).equals = function (other) {
341
+ if (this === other)
342
+ return true;
343
+ if (!(other instanceof CacheEntry))
344
+ return false;
345
+ if (!(this.v6m_1 === other.v6m_1))
346
+ return false;
347
+ if (!equalsLong(this.w6m_1, other.w6m_1))
348
+ return false;
349
+ return true;
350
+ };
351
+ function cleanExpired($this) {
352
+ var now = System_instance.ck().qk();
353
+ var tmp = $this.z6m_1.v();
354
+ removeAll(tmp, InMemoryBotChatCache$cleanExpired$lambda(now, $this));
355
+ }
356
+ function InMemoryBotChatCache$cleanExpired$lambda($now, this$0) {
357
+ return function (_destruct__k2r9zo) {
358
+ // Inline function 'kotlin.collections.component2' call
359
+ var entry = _destruct__k2r9zo.x();
360
+ return compare(subtract($now, entry.w6m_1), this$0.x6m_1) > 0;
361
+ };
362
+ }
363
+ function InMemoryBotChatCache(ttlMillis, maxSize) {
364
+ ttlMillis = ttlMillis === VOID ? new Long(300000, 0) : ttlMillis;
365
+ maxSize = maxSize === VOID ? 100 : maxSize;
366
+ this.x6m_1 = ttlMillis;
367
+ this.y6m_1 = maxSize;
368
+ var tmp = this;
369
+ // Inline function 'kotlin.collections.mutableMapOf' call
370
+ tmp.z6m_1 = LinkedHashMap_init_$Create$();
371
+ }
372
+ protoOf(InMemoryBotChatCache).t1b = function (key) {
373
+ cleanExpired(this);
374
+ var tmp0_elvis_lhs = this.z6m_1.c2(key);
375
+ var tmp;
376
+ if (tmp0_elvis_lhs == null) {
377
+ return null;
378
+ } else {
379
+ tmp = tmp0_elvis_lhs;
380
+ }
381
+ var entry = tmp;
382
+ if (compare(subtract(System_instance.ck().qk(), entry.w6m_1), this.x6m_1) > 0) {
383
+ this.z6m_1.g2(key);
384
+ return null;
385
+ }
386
+ return entry.v6m_1;
387
+ };
388
+ protoOf(InMemoryBotChatCache).u6m = function (key, value) {
389
+ cleanExpired(this);
390
+ if (this.z6m_1.o() >= this.y6m_1) {
391
+ // Inline function 'kotlin.collections.minByOrNull' call
392
+ var tmp0 = this.z6m_1.v();
393
+ var tmp$ret$0;
394
+ $l$block_0: {
395
+ // Inline function 'kotlin.collections.minByOrNull' call
396
+ var iterator = tmp0.l();
397
+ if (!iterator.m()) {
398
+ tmp$ret$0 = null;
399
+ break $l$block_0;
400
+ }
401
+ var minElem = iterator.n();
402
+ if (!iterator.m()) {
403
+ tmp$ret$0 = minElem;
404
+ break $l$block_0;
405
+ }
406
+ var minValue = minElem.x().w6m_1;
407
+ do {
408
+ var e = iterator.n();
409
+ var v = e.x().w6m_1;
410
+ if (compareTo(minValue, v) > 0) {
411
+ minElem = e;
412
+ minValue = v;
413
+ }
414
+ }
415
+ while (iterator.m());
416
+ tmp$ret$0 = minElem;
417
+ }
418
+ var tmp0_safe_receiver = tmp$ret$0;
419
+ var oldestKey = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.w();
420
+ if (oldestKey == null)
421
+ null;
422
+ else {
423
+ // Inline function 'kotlin.let' call
424
+ this.z6m_1.g2(oldestKey);
425
+ }
426
+ }
427
+ var tmp0_0 = this.z6m_1;
428
+ // Inline function 'kotlin.collections.set' call
429
+ var value_0 = new CacheEntry(value, System_instance.ck().qk());
430
+ tmp0_0.f2(key, value_0);
431
+ };
432
+ function BotChatContext$Companion$$childSerializers$_anonymous__c0jn7e() {
433
+ return new ArrayListSerializer(StringSerializer_getInstance());
434
+ }
435
+ function Companion() {
436
+ Companion_instance_1 = this;
437
+ var tmp = this;
438
+ var tmp_0 = LazyThreadSafetyMode_PUBLICATION_getInstance();
439
+ // Inline function 'kotlin.arrayOf' call
440
+ // Inline function 'kotlin.js.unsafeCast' call
441
+ // Inline function 'kotlin.js.asDynamic' call
442
+ tmp.a6n_1 = [null, null, lazy(tmp_0, BotChatContext$Companion$$childSerializers$_anonymous__c0jn7e), null];
443
+ }
444
+ var Companion_instance_1;
445
+ function Companion_getInstance_1() {
446
+ if (Companion_instance_1 == null)
447
+ new Companion();
448
+ return Companion_instance_1;
449
+ }
450
+ function $serializer() {
451
+ $serializer_instance = this;
452
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.BotChatContext', this, 4);
453
+ tmp0_serialDesc.gz('botPersonality', false);
454
+ tmp0_serialDesc.gz('gameState', false);
455
+ tmp0_serialDesc.gz('conversationHistory', true);
456
+ tmp0_serialDesc.gz('playerName', true);
457
+ this.b6n_1 = tmp0_serialDesc;
458
+ }
459
+ protoOf($serializer).c6n = function (encoder, value) {
460
+ var tmp0_desc = this.b6n_1;
461
+ var tmp1_output = encoder.or(tmp0_desc);
462
+ var tmp2_cached = Companion_getInstance_1().a6n_1;
463
+ tmp1_output.dt(tmp0_desc, 0, value.d6n_1);
464
+ tmp1_output.dt(tmp0_desc, 1, value.e6n_1);
465
+ if (tmp1_output.lt(tmp0_desc, 2) ? true : !equals(value.f6n_1, emptyList())) {
466
+ tmp1_output.ft(tmp0_desc, 2, tmp2_cached[2].x(), value.f6n_1);
467
+ }
468
+ if (tmp1_output.lt(tmp0_desc, 3) ? true : !(value.g6n_1 == null)) {
469
+ tmp1_output.ht(tmp0_desc, 3, StringSerializer_getInstance(), value.g6n_1);
470
+ }
471
+ tmp1_output.pr(tmp0_desc);
472
+ };
473
+ protoOf($serializer).co = function (encoder, value) {
474
+ return this.c6n(encoder, value instanceof BotChatContext ? value : THROW_CCE());
475
+ };
476
+ protoOf($serializer).do = function (decoder) {
477
+ var tmp0_desc = this.b6n_1;
478
+ var tmp1_flag = true;
479
+ var tmp2_index = 0;
480
+ var tmp3_bitMask0 = 0;
481
+ var tmp4_local0 = null;
482
+ var tmp5_local1 = null;
483
+ var tmp6_local2 = null;
484
+ var tmp7_local3 = null;
485
+ var tmp8_input = decoder.or(tmp0_desc);
486
+ var tmp9_cached = Companion_getInstance_1().a6n_1;
487
+ if (tmp8_input.es()) {
488
+ tmp4_local0 = tmp8_input.yr(tmp0_desc, 0);
489
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
490
+ tmp5_local1 = tmp8_input.yr(tmp0_desc, 1);
491
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
492
+ tmp6_local2 = tmp8_input.as(tmp0_desc, 2, tmp9_cached[2].x(), tmp6_local2);
493
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
494
+ tmp7_local3 = tmp8_input.cs(tmp0_desc, 3, StringSerializer_getInstance(), tmp7_local3);
495
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
496
+ } else
497
+ while (tmp1_flag) {
498
+ tmp2_index = tmp8_input.fs(tmp0_desc);
499
+ switch (tmp2_index) {
500
+ case -1:
501
+ tmp1_flag = false;
502
+ break;
503
+ case 0:
504
+ tmp4_local0 = tmp8_input.yr(tmp0_desc, 0);
505
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
506
+ break;
507
+ case 1:
508
+ tmp5_local1 = tmp8_input.yr(tmp0_desc, 1);
509
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
510
+ break;
511
+ case 2:
512
+ tmp6_local2 = tmp8_input.as(tmp0_desc, 2, tmp9_cached[2].x(), tmp6_local2);
513
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
514
+ break;
515
+ case 3:
516
+ tmp7_local3 = tmp8_input.cs(tmp0_desc, 3, StringSerializer_getInstance(), tmp7_local3);
517
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
518
+ break;
519
+ default:
520
+ throw UnknownFieldException_init_$Create$(tmp2_index);
521
+ }
522
+ }
523
+ tmp8_input.pr(tmp0_desc);
524
+ return BotChatContext_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, tmp7_local3, null);
525
+ };
526
+ protoOf($serializer).bo = function () {
527
+ return this.b6n_1;
528
+ };
529
+ protoOf($serializer).vz = function () {
530
+ var tmp0_cached = Companion_getInstance_1().a6n_1;
531
+ // Inline function 'kotlin.arrayOf' call
532
+ // Inline function 'kotlin.js.unsafeCast' call
533
+ // Inline function 'kotlin.js.asDynamic' call
534
+ return [StringSerializer_getInstance(), StringSerializer_getInstance(), tmp0_cached[2].x(), get_nullable(StringSerializer_getInstance())];
535
+ };
536
+ var $serializer_instance;
537
+ function $serializer_getInstance() {
538
+ if ($serializer_instance == null)
539
+ new $serializer();
540
+ return $serializer_instance;
541
+ }
542
+ function BotChatContext_init_$Init$(seen0, botPersonality, gameState, conversationHistory, playerName, serializationConstructorMarker, $this) {
543
+ if (!(3 === (3 & seen0))) {
544
+ throwMissingFieldException(seen0, 3, $serializer_getInstance().b6n_1);
545
+ }
546
+ $this.d6n_1 = botPersonality;
547
+ $this.e6n_1 = gameState;
548
+ if (0 === (seen0 & 4))
549
+ $this.f6n_1 = emptyList();
550
+ else
551
+ $this.f6n_1 = conversationHistory;
552
+ if (0 === (seen0 & 8))
553
+ $this.g6n_1 = null;
554
+ else
555
+ $this.g6n_1 = playerName;
556
+ return $this;
557
+ }
558
+ function BotChatContext_init_$Create$(seen0, botPersonality, gameState, conversationHistory, playerName, serializationConstructorMarker) {
559
+ return BotChatContext_init_$Init$(seen0, botPersonality, gameState, conversationHistory, playerName, serializationConstructorMarker, objectCreate(protoOf(BotChatContext)));
560
+ }
561
+ function BotChatContext(botPersonality, gameState, conversationHistory, playerName) {
562
+ Companion_getInstance_1();
563
+ conversationHistory = conversationHistory === VOID ? emptyList() : conversationHistory;
564
+ playerName = playerName === VOID ? null : playerName;
565
+ this.d6n_1 = botPersonality;
566
+ this.e6n_1 = gameState;
567
+ this.f6n_1 = conversationHistory;
568
+ this.g6n_1 = playerName;
569
+ }
570
+ protoOf(BotChatContext).toString = function () {
571
+ return 'BotChatContext(botPersonality=' + this.d6n_1 + ', gameState=' + this.e6n_1 + ', conversationHistory=' + toString(this.f6n_1) + ', playerName=' + this.g6n_1 + ')';
572
+ };
573
+ protoOf(BotChatContext).hashCode = function () {
574
+ var result = getStringHashCode(this.d6n_1);
575
+ result = imul(result, 31) + getStringHashCode(this.e6n_1) | 0;
576
+ result = imul(result, 31) + hashCode(this.f6n_1) | 0;
577
+ result = imul(result, 31) + (this.g6n_1 == null ? 0 : getStringHashCode(this.g6n_1)) | 0;
578
+ return result;
579
+ };
580
+ protoOf(BotChatContext).equals = function (other) {
581
+ if (this === other)
582
+ return true;
583
+ if (!(other instanceof BotChatContext))
584
+ return false;
585
+ if (!(this.d6n_1 === other.d6n_1))
586
+ return false;
587
+ if (!(this.e6n_1 === other.e6n_1))
588
+ return false;
589
+ if (!equals(this.f6n_1, other.f6n_1))
590
+ return false;
591
+ if (!(this.g6n_1 == other.g6n_1))
592
+ return false;
593
+ return true;
594
+ };
595
+ function _get_$cachedSerializer__te6jhj($this) {
596
+ return $this.h6n_1.x();
597
+ }
598
+ function ChatMessage$Role$Companion$_anonymous__13jozo() {
599
+ var tmp = values();
600
+ // Inline function 'kotlin.arrayOf' call
601
+ // Inline function 'kotlin.js.unsafeCast' call
602
+ // Inline function 'kotlin.js.asDynamic' call
603
+ var tmp_0 = ['system', 'user', 'assistant'];
604
+ // Inline function 'kotlin.arrayOf' call
605
+ // Inline function 'kotlin.js.unsafeCast' call
606
+ // Inline function 'kotlin.js.asDynamic' call
607
+ var tmp$ret$5 = [null, null, null];
608
+ return createAnnotatedEnumSerializer('com.logic.ai.data.models.ChatMessage.Role', tmp, tmp_0, tmp$ret$5, null);
609
+ }
610
+ var Role_SYSTEM_instance;
611
+ var Role_USER_instance;
612
+ var Role_ASSISTANT_instance;
613
+ function values() {
614
+ return [Role_SYSTEM_getInstance(), Role_USER_getInstance(), Role_ASSISTANT_getInstance()];
615
+ }
616
+ function Companion_0() {
617
+ Companion_instance_2 = this;
618
+ var tmp = this;
619
+ var tmp_0 = LazyThreadSafetyMode_PUBLICATION_getInstance();
620
+ tmp.h6n_1 = lazy(tmp_0, ChatMessage$Role$Companion$_anonymous__13jozo);
621
+ }
622
+ protoOf(Companion_0).a1c = function () {
623
+ return _get_$cachedSerializer__te6jhj(this);
624
+ };
625
+ protoOf(Companion_0).g10 = function (typeParamsSerializers) {
626
+ return this.a1c();
627
+ };
628
+ var Companion_instance_2;
629
+ function Companion_getInstance_2() {
630
+ Role_initEntries();
631
+ if (Companion_instance_2 == null)
632
+ new Companion_0();
633
+ return Companion_instance_2;
634
+ }
635
+ var Role_entriesInitialized;
636
+ function Role_initEntries() {
637
+ if (Role_entriesInitialized)
638
+ return Unit_instance;
639
+ Role_entriesInitialized = true;
640
+ Role_SYSTEM_instance = new Role('SYSTEM', 0);
641
+ Role_USER_instance = new Role('USER', 1);
642
+ Role_ASSISTANT_instance = new Role('ASSISTANT', 2);
643
+ Companion_getInstance_2();
644
+ }
645
+ function ChatMessage$Companion$$childSerializers$_anonymous__qywqat() {
646
+ return Companion_getInstance_2().a1c();
647
+ }
648
+ function Role(name, ordinal) {
649
+ Enum.call(this, name, ordinal);
650
+ }
651
+ function Companion_1() {
652
+ Companion_instance_3 = this;
653
+ var tmp = this;
654
+ var tmp_0 = LazyThreadSafetyMode_PUBLICATION_getInstance();
655
+ // Inline function 'kotlin.arrayOf' call
656
+ // Inline function 'kotlin.js.unsafeCast' call
657
+ // Inline function 'kotlin.js.asDynamic' call
658
+ tmp.i6n_1 = [lazy(tmp_0, ChatMessage$Companion$$childSerializers$_anonymous__qywqat), null];
659
+ }
660
+ protoOf(Companion_1).j6n = function (content) {
661
+ return new ChatMessage(Role_SYSTEM_getInstance(), content);
662
+ };
663
+ protoOf(Companion_1).k6n = function (content) {
664
+ return new ChatMessage(Role_USER_getInstance(), content);
665
+ };
666
+ protoOf(Companion_1).l6n = function (content) {
667
+ return new ChatMessage(Role_ASSISTANT_getInstance(), content);
668
+ };
669
+ var Companion_instance_3;
670
+ function Companion_getInstance_3() {
671
+ if (Companion_instance_3 == null)
672
+ new Companion_1();
673
+ return Companion_instance_3;
674
+ }
675
+ function $serializer_0() {
676
+ $serializer_instance_0 = this;
677
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.ChatMessage', this, 2);
678
+ tmp0_serialDesc.gz('role', false);
679
+ tmp0_serialDesc.gz('content', false);
680
+ this.m6n_1 = tmp0_serialDesc;
681
+ }
682
+ protoOf($serializer_0).n6n = function (encoder, value) {
683
+ var tmp0_desc = this.m6n_1;
684
+ var tmp1_output = encoder.or(tmp0_desc);
685
+ var tmp2_cached = Companion_getInstance_3().i6n_1;
686
+ tmp1_output.ft(tmp0_desc, 0, tmp2_cached[0].x(), value.o6n_1);
687
+ tmp1_output.dt(tmp0_desc, 1, value.p6n_1);
688
+ tmp1_output.pr(tmp0_desc);
689
+ };
690
+ protoOf($serializer_0).co = function (encoder, value) {
691
+ return this.n6n(encoder, value instanceof ChatMessage ? value : THROW_CCE());
692
+ };
693
+ protoOf($serializer_0).do = function (decoder) {
694
+ var tmp0_desc = this.m6n_1;
695
+ var tmp1_flag = true;
696
+ var tmp2_index = 0;
697
+ var tmp3_bitMask0 = 0;
698
+ var tmp4_local0 = null;
699
+ var tmp5_local1 = null;
700
+ var tmp6_input = decoder.or(tmp0_desc);
701
+ var tmp7_cached = Companion_getInstance_3().i6n_1;
702
+ if (tmp6_input.es()) {
703
+ tmp4_local0 = tmp6_input.as(tmp0_desc, 0, tmp7_cached[0].x(), tmp4_local0);
704
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
705
+ tmp5_local1 = tmp6_input.yr(tmp0_desc, 1);
706
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
707
+ } else
708
+ while (tmp1_flag) {
709
+ tmp2_index = tmp6_input.fs(tmp0_desc);
710
+ switch (tmp2_index) {
711
+ case -1:
712
+ tmp1_flag = false;
713
+ break;
714
+ case 0:
715
+ tmp4_local0 = tmp6_input.as(tmp0_desc, 0, tmp7_cached[0].x(), tmp4_local0);
716
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
717
+ break;
718
+ case 1:
719
+ tmp5_local1 = tmp6_input.yr(tmp0_desc, 1);
720
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
721
+ break;
722
+ default:
723
+ throw UnknownFieldException_init_$Create$(tmp2_index);
724
+ }
725
+ }
726
+ tmp6_input.pr(tmp0_desc);
727
+ return ChatMessage_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, null);
728
+ };
729
+ protoOf($serializer_0).bo = function () {
730
+ return this.m6n_1;
731
+ };
732
+ protoOf($serializer_0).vz = function () {
733
+ // Inline function 'kotlin.arrayOf' call
734
+ // Inline function 'kotlin.js.unsafeCast' call
735
+ // Inline function 'kotlin.js.asDynamic' call
736
+ return [Companion_getInstance_3().i6n_1[0].x(), StringSerializer_getInstance()];
737
+ };
738
+ var $serializer_instance_0;
739
+ function $serializer_getInstance_0() {
740
+ if ($serializer_instance_0 == null)
741
+ new $serializer_0();
742
+ return $serializer_instance_0;
743
+ }
744
+ function ChatMessage_init_$Init$(seen0, role, content, serializationConstructorMarker, $this) {
745
+ if (!(3 === (3 & seen0))) {
746
+ throwMissingFieldException(seen0, 3, $serializer_getInstance_0().m6n_1);
747
+ }
748
+ $this.o6n_1 = role;
749
+ $this.p6n_1 = content;
750
+ return $this;
751
+ }
752
+ function ChatMessage_init_$Create$(seen0, role, content, serializationConstructorMarker) {
753
+ return ChatMessage_init_$Init$(seen0, role, content, serializationConstructorMarker, objectCreate(protoOf(ChatMessage)));
754
+ }
755
+ function Role_SYSTEM_getInstance() {
756
+ Role_initEntries();
757
+ return Role_SYSTEM_instance;
758
+ }
759
+ function Role_USER_getInstance() {
760
+ Role_initEntries();
761
+ return Role_USER_instance;
762
+ }
763
+ function Role_ASSISTANT_getInstance() {
764
+ Role_initEntries();
765
+ return Role_ASSISTANT_instance;
766
+ }
767
+ function ChatMessage(role, content) {
768
+ Companion_getInstance_3();
769
+ this.o6n_1 = role;
770
+ this.p6n_1 = content;
771
+ }
772
+ protoOf(ChatMessage).toString = function () {
773
+ return 'ChatMessage(role=' + this.o6n_1.toString() + ', content=' + this.p6n_1 + ')';
774
+ };
775
+ protoOf(ChatMessage).hashCode = function () {
776
+ var result = this.o6n_1.hashCode();
777
+ result = imul(result, 31) + getStringHashCode(this.p6n_1) | 0;
778
+ return result;
779
+ };
780
+ protoOf(ChatMessage).equals = function (other) {
781
+ if (this === other)
782
+ return true;
783
+ if (!(other instanceof ChatMessage))
784
+ return false;
785
+ if (!this.o6n_1.equals(other.o6n_1))
786
+ return false;
787
+ if (!(this.p6n_1 === other.p6n_1))
788
+ return false;
789
+ return true;
790
+ };
791
+ function Companion_2() {
792
+ }
793
+ var Companion_instance_4;
794
+ function Companion_getInstance_4() {
795
+ return Companion_instance_4;
796
+ }
797
+ function $serializer_1() {
798
+ $serializer_instance_1 = this;
799
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.OpenAIConfig', this, 6);
800
+ tmp0_serialDesc.gz('apiKey', false);
801
+ tmp0_serialDesc.gz('model', true);
802
+ tmp0_serialDesc.gz('baseUrl', true);
803
+ tmp0_serialDesc.gz('temperature', true);
804
+ tmp0_serialDesc.gz('maxTokens', true);
805
+ tmp0_serialDesc.gz('timeout', true);
806
+ this.q6n_1 = tmp0_serialDesc;
807
+ }
808
+ protoOf($serializer_1).r6n = function (encoder, value) {
809
+ var tmp0_desc = this.q6n_1;
810
+ var tmp1_output = encoder.or(tmp0_desc);
811
+ tmp1_output.dt(tmp0_desc, 0, value.a6m_1);
812
+ if (tmp1_output.lt(tmp0_desc, 1) ? true : !(value.b6m_1 === 'gpt-3.5-turbo')) {
813
+ tmp1_output.dt(tmp0_desc, 1, value.b6m_1);
814
+ }
815
+ if (tmp1_output.lt(tmp0_desc, 2) ? true : !(value.c6m_1 === 'https://api.openai.com/v1')) {
816
+ tmp1_output.dt(tmp0_desc, 2, value.c6m_1);
817
+ }
818
+ if (tmp1_output.lt(tmp0_desc, 3) ? true : !equals(value.d6m_1, 0.7)) {
819
+ tmp1_output.bt(tmp0_desc, 3, value.d6m_1);
820
+ }
821
+ if (tmp1_output.lt(tmp0_desc, 4) ? true : !(value.e6m_1 === 150)) {
822
+ tmp1_output.ys(tmp0_desc, 4, value.e6m_1);
823
+ }
824
+ if (tmp1_output.lt(tmp0_desc, 5) ? true : !equalsLong(value.f6m_1, new Long(30000, 0))) {
825
+ tmp1_output.zs(tmp0_desc, 5, value.f6m_1);
826
+ }
827
+ tmp1_output.pr(tmp0_desc);
828
+ };
829
+ protoOf($serializer_1).co = function (encoder, value) {
830
+ return this.r6n(encoder, value instanceof OpenAIConfig ? value : THROW_CCE());
831
+ };
832
+ protoOf($serializer_1).do = function (decoder) {
833
+ var tmp0_desc = this.q6n_1;
834
+ var tmp1_flag = true;
835
+ var tmp2_index = 0;
836
+ var tmp3_bitMask0 = 0;
837
+ var tmp4_local0 = null;
838
+ var tmp5_local1 = null;
839
+ var tmp6_local2 = null;
840
+ var tmp7_local3 = 0.0;
841
+ var tmp8_local4 = 0;
842
+ var tmp9_local5 = new Long(0, 0);
843
+ var tmp10_input = decoder.or(tmp0_desc);
844
+ if (tmp10_input.es()) {
845
+ tmp4_local0 = tmp10_input.yr(tmp0_desc, 0);
846
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
847
+ tmp5_local1 = tmp10_input.yr(tmp0_desc, 1);
848
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
849
+ tmp6_local2 = tmp10_input.yr(tmp0_desc, 2);
850
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
851
+ tmp7_local3 = tmp10_input.wr(tmp0_desc, 3);
852
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
853
+ tmp8_local4 = tmp10_input.tr(tmp0_desc, 4);
854
+ tmp3_bitMask0 = tmp3_bitMask0 | 16;
855
+ tmp9_local5 = tmp10_input.ur(tmp0_desc, 5);
856
+ tmp3_bitMask0 = tmp3_bitMask0 | 32;
857
+ } else
858
+ while (tmp1_flag) {
859
+ tmp2_index = tmp10_input.fs(tmp0_desc);
860
+ switch (tmp2_index) {
861
+ case -1:
862
+ tmp1_flag = false;
863
+ break;
864
+ case 0:
865
+ tmp4_local0 = tmp10_input.yr(tmp0_desc, 0);
866
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
867
+ break;
868
+ case 1:
869
+ tmp5_local1 = tmp10_input.yr(tmp0_desc, 1);
870
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
871
+ break;
872
+ case 2:
873
+ tmp6_local2 = tmp10_input.yr(tmp0_desc, 2);
874
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
875
+ break;
876
+ case 3:
877
+ tmp7_local3 = tmp10_input.wr(tmp0_desc, 3);
878
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
879
+ break;
880
+ case 4:
881
+ tmp8_local4 = tmp10_input.tr(tmp0_desc, 4);
882
+ tmp3_bitMask0 = tmp3_bitMask0 | 16;
883
+ break;
884
+ case 5:
885
+ tmp9_local5 = tmp10_input.ur(tmp0_desc, 5);
886
+ tmp3_bitMask0 = tmp3_bitMask0 | 32;
887
+ break;
888
+ default:
889
+ throw UnknownFieldException_init_$Create$(tmp2_index);
890
+ }
891
+ }
892
+ tmp10_input.pr(tmp0_desc);
893
+ return OpenAIConfig_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, tmp7_local3, tmp8_local4, tmp9_local5, null);
894
+ };
895
+ protoOf($serializer_1).bo = function () {
896
+ return this.q6n_1;
897
+ };
898
+ protoOf($serializer_1).vz = function () {
899
+ // Inline function 'kotlin.arrayOf' call
900
+ // Inline function 'kotlin.js.unsafeCast' call
901
+ // Inline function 'kotlin.js.asDynamic' call
902
+ return [StringSerializer_getInstance(), StringSerializer_getInstance(), StringSerializer_getInstance(), DoubleSerializer_getInstance(), IntSerializer_getInstance(), LongSerializer_getInstance()];
903
+ };
904
+ var $serializer_instance_1;
905
+ function $serializer_getInstance_1() {
906
+ if ($serializer_instance_1 == null)
907
+ new $serializer_1();
908
+ return $serializer_instance_1;
909
+ }
910
+ function OpenAIConfig_init_$Init$(seen0, apiKey, model, baseUrl, temperature, maxTokens, timeout, serializationConstructorMarker, $this) {
911
+ if (!(1 === (1 & seen0))) {
912
+ throwMissingFieldException(seen0, 1, $serializer_getInstance_1().q6n_1);
913
+ }
914
+ $this.a6m_1 = apiKey;
915
+ if (0 === (seen0 & 2))
916
+ $this.b6m_1 = 'gpt-3.5-turbo';
917
+ else
918
+ $this.b6m_1 = model;
919
+ if (0 === (seen0 & 4))
920
+ $this.c6m_1 = 'https://api.openai.com/v1';
921
+ else
922
+ $this.c6m_1 = baseUrl;
923
+ if (0 === (seen0 & 8))
924
+ $this.d6m_1 = 0.7;
925
+ else
926
+ $this.d6m_1 = temperature;
927
+ if (0 === (seen0 & 16))
928
+ $this.e6m_1 = 150;
929
+ else
930
+ $this.e6m_1 = maxTokens;
931
+ if (0 === (seen0 & 32))
932
+ $this.f6m_1 = new Long(30000, 0);
933
+ else
934
+ $this.f6m_1 = timeout;
935
+ return $this;
936
+ }
937
+ function OpenAIConfig_init_$Create$(seen0, apiKey, model, baseUrl, temperature, maxTokens, timeout, serializationConstructorMarker) {
938
+ return OpenAIConfig_init_$Init$(seen0, apiKey, model, baseUrl, temperature, maxTokens, timeout, serializationConstructorMarker, objectCreate(protoOf(OpenAIConfig)));
939
+ }
940
+ function OpenAIConfig(apiKey, model, baseUrl, temperature, maxTokens, timeout) {
941
+ model = model === VOID ? 'gpt-3.5-turbo' : model;
942
+ baseUrl = baseUrl === VOID ? 'https://api.openai.com/v1' : baseUrl;
943
+ temperature = temperature === VOID ? 0.7 : temperature;
944
+ maxTokens = maxTokens === VOID ? 150 : maxTokens;
945
+ timeout = timeout === VOID ? new Long(30000, 0) : timeout;
946
+ this.a6m_1 = apiKey;
947
+ this.b6m_1 = model;
948
+ this.c6m_1 = baseUrl;
949
+ this.d6m_1 = temperature;
950
+ this.e6m_1 = maxTokens;
951
+ this.f6m_1 = timeout;
952
+ }
953
+ protoOf(OpenAIConfig).toString = function () {
954
+ return 'OpenAIConfig(apiKey=' + this.a6m_1 + ', model=' + this.b6m_1 + ', baseUrl=' + this.c6m_1 + ', temperature=' + this.d6m_1 + ', maxTokens=' + this.e6m_1 + ', timeout=' + this.f6m_1.toString() + ')';
955
+ };
956
+ protoOf(OpenAIConfig).hashCode = function () {
957
+ var result = getStringHashCode(this.a6m_1);
958
+ result = imul(result, 31) + getStringHashCode(this.b6m_1) | 0;
959
+ result = imul(result, 31) + getStringHashCode(this.c6m_1) | 0;
960
+ result = imul(result, 31) + getNumberHashCode(this.d6m_1) | 0;
961
+ result = imul(result, 31) + this.e6m_1 | 0;
962
+ result = imul(result, 31) + this.f6m_1.hashCode() | 0;
963
+ return result;
964
+ };
965
+ protoOf(OpenAIConfig).equals = function (other) {
966
+ if (this === other)
967
+ return true;
968
+ if (!(other instanceof OpenAIConfig))
969
+ return false;
970
+ if (!(this.a6m_1 === other.a6m_1))
971
+ return false;
972
+ if (!(this.b6m_1 === other.b6m_1))
973
+ return false;
974
+ if (!(this.c6m_1 === other.c6m_1))
975
+ return false;
976
+ if (!equals(this.d6m_1, other.d6m_1))
977
+ return false;
978
+ if (!(this.e6m_1 === other.e6m_1))
979
+ return false;
980
+ if (!equalsLong(this.f6m_1, other.f6m_1))
981
+ return false;
982
+ return true;
983
+ };
984
+ function OpenAIRequest$Companion$$childSerializers$_anonymous__ff5rn1() {
985
+ return new ArrayListSerializer($serializer_getInstance_0());
986
+ }
987
+ function Companion_3() {
988
+ Companion_instance_5 = this;
989
+ var tmp = this;
990
+ var tmp_0 = LazyThreadSafetyMode_PUBLICATION_getInstance();
991
+ // Inline function 'kotlin.arrayOf' call
992
+ // Inline function 'kotlin.js.unsafeCast' call
993
+ // Inline function 'kotlin.js.asDynamic' call
994
+ tmp.s6n_1 = [null, lazy(tmp_0, OpenAIRequest$Companion$$childSerializers$_anonymous__ff5rn1), null, null];
995
+ }
996
+ var Companion_instance_5;
997
+ function Companion_getInstance_5() {
998
+ if (Companion_instance_5 == null)
999
+ new Companion_3();
1000
+ return Companion_instance_5;
1001
+ }
1002
+ function $serializer_2() {
1003
+ $serializer_instance_2 = this;
1004
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.OpenAIRequest', this, 4);
1005
+ tmp0_serialDesc.gz('model', false);
1006
+ tmp0_serialDesc.gz('messages', false);
1007
+ tmp0_serialDesc.gz('temperature', false);
1008
+ tmp0_serialDesc.gz('max_tokens', false);
1009
+ this.t6n_1 = tmp0_serialDesc;
1010
+ }
1011
+ protoOf($serializer_2).u6n = function (encoder, value) {
1012
+ var tmp0_desc = this.t6n_1;
1013
+ var tmp1_output = encoder.or(tmp0_desc);
1014
+ var tmp2_cached = Companion_getInstance_5().s6n_1;
1015
+ tmp1_output.dt(tmp0_desc, 0, value.v6n_1);
1016
+ tmp1_output.ft(tmp0_desc, 1, tmp2_cached[1].x(), value.w6n_1);
1017
+ tmp1_output.bt(tmp0_desc, 2, value.x6n_1);
1018
+ tmp1_output.ys(tmp0_desc, 3, value.y6n_1);
1019
+ tmp1_output.pr(tmp0_desc);
1020
+ };
1021
+ protoOf($serializer_2).co = function (encoder, value) {
1022
+ return this.u6n(encoder, value instanceof OpenAIRequest ? value : THROW_CCE());
1023
+ };
1024
+ protoOf($serializer_2).do = function (decoder) {
1025
+ var tmp0_desc = this.t6n_1;
1026
+ var tmp1_flag = true;
1027
+ var tmp2_index = 0;
1028
+ var tmp3_bitMask0 = 0;
1029
+ var tmp4_local0 = null;
1030
+ var tmp5_local1 = null;
1031
+ var tmp6_local2 = 0.0;
1032
+ var tmp7_local3 = 0;
1033
+ var tmp8_input = decoder.or(tmp0_desc);
1034
+ var tmp9_cached = Companion_getInstance_5().s6n_1;
1035
+ if (tmp8_input.es()) {
1036
+ tmp4_local0 = tmp8_input.yr(tmp0_desc, 0);
1037
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1038
+ tmp5_local1 = tmp8_input.as(tmp0_desc, 1, tmp9_cached[1].x(), tmp5_local1);
1039
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1040
+ tmp6_local2 = tmp8_input.wr(tmp0_desc, 2);
1041
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1042
+ tmp7_local3 = tmp8_input.tr(tmp0_desc, 3);
1043
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
1044
+ } else
1045
+ while (tmp1_flag) {
1046
+ tmp2_index = tmp8_input.fs(tmp0_desc);
1047
+ switch (tmp2_index) {
1048
+ case -1:
1049
+ tmp1_flag = false;
1050
+ break;
1051
+ case 0:
1052
+ tmp4_local0 = tmp8_input.yr(tmp0_desc, 0);
1053
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1054
+ break;
1055
+ case 1:
1056
+ tmp5_local1 = tmp8_input.as(tmp0_desc, 1, tmp9_cached[1].x(), tmp5_local1);
1057
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1058
+ break;
1059
+ case 2:
1060
+ tmp6_local2 = tmp8_input.wr(tmp0_desc, 2);
1061
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1062
+ break;
1063
+ case 3:
1064
+ tmp7_local3 = tmp8_input.tr(tmp0_desc, 3);
1065
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
1066
+ break;
1067
+ default:
1068
+ throw UnknownFieldException_init_$Create$(tmp2_index);
1069
+ }
1070
+ }
1071
+ tmp8_input.pr(tmp0_desc);
1072
+ return OpenAIRequest_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, tmp7_local3, null);
1073
+ };
1074
+ protoOf($serializer_2).bo = function () {
1075
+ return this.t6n_1;
1076
+ };
1077
+ protoOf($serializer_2).vz = function () {
1078
+ var tmp0_cached = Companion_getInstance_5().s6n_1;
1079
+ // Inline function 'kotlin.arrayOf' call
1080
+ // Inline function 'kotlin.js.unsafeCast' call
1081
+ // Inline function 'kotlin.js.asDynamic' call
1082
+ return [StringSerializer_getInstance(), tmp0_cached[1].x(), DoubleSerializer_getInstance(), IntSerializer_getInstance()];
1083
+ };
1084
+ var $serializer_instance_2;
1085
+ function $serializer_getInstance_2() {
1086
+ if ($serializer_instance_2 == null)
1087
+ new $serializer_2();
1088
+ return $serializer_instance_2;
1089
+ }
1090
+ function OpenAIRequest_init_$Init$(seen0, model, messages, temperature, maxTokens, serializationConstructorMarker, $this) {
1091
+ if (!(15 === (15 & seen0))) {
1092
+ throwMissingFieldException(seen0, 15, $serializer_getInstance_2().t6n_1);
1093
+ }
1094
+ $this.v6n_1 = model;
1095
+ $this.w6n_1 = messages;
1096
+ $this.x6n_1 = temperature;
1097
+ $this.y6n_1 = maxTokens;
1098
+ return $this;
1099
+ }
1100
+ function OpenAIRequest_init_$Create$(seen0, model, messages, temperature, maxTokens, serializationConstructorMarker) {
1101
+ return OpenAIRequest_init_$Init$(seen0, model, messages, temperature, maxTokens, serializationConstructorMarker, objectCreate(protoOf(OpenAIRequest)));
1102
+ }
1103
+ function OpenAIRequest(model, messages, temperature, maxTokens) {
1104
+ Companion_getInstance_5();
1105
+ this.v6n_1 = model;
1106
+ this.w6n_1 = messages;
1107
+ this.x6n_1 = temperature;
1108
+ this.y6n_1 = maxTokens;
1109
+ }
1110
+ protoOf(OpenAIRequest).toString = function () {
1111
+ return 'OpenAIRequest(model=' + this.v6n_1 + ', messages=' + toString(this.w6n_1) + ', temperature=' + this.x6n_1 + ', maxTokens=' + this.y6n_1 + ')';
1112
+ };
1113
+ protoOf(OpenAIRequest).hashCode = function () {
1114
+ var result = getStringHashCode(this.v6n_1);
1115
+ result = imul(result, 31) + hashCode(this.w6n_1) | 0;
1116
+ result = imul(result, 31) + getNumberHashCode(this.x6n_1) | 0;
1117
+ result = imul(result, 31) + this.y6n_1 | 0;
1118
+ return result;
1119
+ };
1120
+ protoOf(OpenAIRequest).equals = function (other) {
1121
+ if (this === other)
1122
+ return true;
1123
+ if (!(other instanceof OpenAIRequest))
1124
+ return false;
1125
+ if (!(this.v6n_1 === other.v6n_1))
1126
+ return false;
1127
+ if (!equals(this.w6n_1, other.w6n_1))
1128
+ return false;
1129
+ if (!equals(this.x6n_1, other.x6n_1))
1130
+ return false;
1131
+ if (!(this.y6n_1 === other.y6n_1))
1132
+ return false;
1133
+ return true;
1134
+ };
1135
+ function $serializer_3() {
1136
+ $serializer_instance_3 = this;
1137
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.OpenAIResponse.Choice', this, 3);
1138
+ tmp0_serialDesc.gz('index', false);
1139
+ tmp0_serialDesc.gz('message', false);
1140
+ tmp0_serialDesc.gz('finish_reason', true);
1141
+ this.z6n_1 = tmp0_serialDesc;
1142
+ }
1143
+ protoOf($serializer_3).a6o = function (encoder, value) {
1144
+ var tmp0_desc = this.z6n_1;
1145
+ var tmp1_output = encoder.or(tmp0_desc);
1146
+ tmp1_output.ys(tmp0_desc, 0, value.b6o_1);
1147
+ tmp1_output.ft(tmp0_desc, 1, $serializer_getInstance_0(), value.c6o_1);
1148
+ if (tmp1_output.lt(tmp0_desc, 2) ? true : !(value.d6o_1 == null)) {
1149
+ tmp1_output.ht(tmp0_desc, 2, StringSerializer_getInstance(), value.d6o_1);
1150
+ }
1151
+ tmp1_output.pr(tmp0_desc);
1152
+ };
1153
+ protoOf($serializer_3).co = function (encoder, value) {
1154
+ return this.a6o(encoder, value instanceof Choice ? value : THROW_CCE());
1155
+ };
1156
+ protoOf($serializer_3).do = function (decoder) {
1157
+ var tmp0_desc = this.z6n_1;
1158
+ var tmp1_flag = true;
1159
+ var tmp2_index = 0;
1160
+ var tmp3_bitMask0 = 0;
1161
+ var tmp4_local0 = 0;
1162
+ var tmp5_local1 = null;
1163
+ var tmp6_local2 = null;
1164
+ var tmp7_input = decoder.or(tmp0_desc);
1165
+ if (tmp7_input.es()) {
1166
+ tmp4_local0 = tmp7_input.tr(tmp0_desc, 0);
1167
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1168
+ tmp5_local1 = tmp7_input.as(tmp0_desc, 1, $serializer_getInstance_0(), tmp5_local1);
1169
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1170
+ tmp6_local2 = tmp7_input.cs(tmp0_desc, 2, StringSerializer_getInstance(), tmp6_local2);
1171
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1172
+ } else
1173
+ while (tmp1_flag) {
1174
+ tmp2_index = tmp7_input.fs(tmp0_desc);
1175
+ switch (tmp2_index) {
1176
+ case -1:
1177
+ tmp1_flag = false;
1178
+ break;
1179
+ case 0:
1180
+ tmp4_local0 = tmp7_input.tr(tmp0_desc, 0);
1181
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1182
+ break;
1183
+ case 1:
1184
+ tmp5_local1 = tmp7_input.as(tmp0_desc, 1, $serializer_getInstance_0(), tmp5_local1);
1185
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1186
+ break;
1187
+ case 2:
1188
+ tmp6_local2 = tmp7_input.cs(tmp0_desc, 2, StringSerializer_getInstance(), tmp6_local2);
1189
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1190
+ break;
1191
+ default:
1192
+ throw UnknownFieldException_init_$Create$(tmp2_index);
1193
+ }
1194
+ }
1195
+ tmp7_input.pr(tmp0_desc);
1196
+ return Choice_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, null);
1197
+ };
1198
+ protoOf($serializer_3).bo = function () {
1199
+ return this.z6n_1;
1200
+ };
1201
+ protoOf($serializer_3).vz = function () {
1202
+ // Inline function 'kotlin.arrayOf' call
1203
+ // Inline function 'kotlin.js.unsafeCast' call
1204
+ // Inline function 'kotlin.js.asDynamic' call
1205
+ return [IntSerializer_getInstance(), $serializer_getInstance_0(), get_nullable(StringSerializer_getInstance())];
1206
+ };
1207
+ var $serializer_instance_3;
1208
+ function $serializer_getInstance_3() {
1209
+ if ($serializer_instance_3 == null)
1210
+ new $serializer_3();
1211
+ return $serializer_instance_3;
1212
+ }
1213
+ function Choice_init_$Init$(seen0, index, message, finishReason, serializationConstructorMarker, $this) {
1214
+ if (!(3 === (3 & seen0))) {
1215
+ throwMissingFieldException(seen0, 3, $serializer_getInstance_3().z6n_1);
1216
+ }
1217
+ $this.b6o_1 = index;
1218
+ $this.c6o_1 = message;
1219
+ if (0 === (seen0 & 4))
1220
+ $this.d6o_1 = null;
1221
+ else
1222
+ $this.d6o_1 = finishReason;
1223
+ return $this;
1224
+ }
1225
+ function Choice_init_$Create$(seen0, index, message, finishReason, serializationConstructorMarker) {
1226
+ return Choice_init_$Init$(seen0, index, message, finishReason, serializationConstructorMarker, objectCreate(protoOf(Choice)));
1227
+ }
1228
+ function $serializer_4() {
1229
+ $serializer_instance_4 = this;
1230
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.OpenAIResponse.Usage', this, 3);
1231
+ tmp0_serialDesc.gz('prompt_tokens', false);
1232
+ tmp0_serialDesc.gz('completion_tokens', false);
1233
+ tmp0_serialDesc.gz('total_tokens', false);
1234
+ this.e6o_1 = tmp0_serialDesc;
1235
+ }
1236
+ protoOf($serializer_4).f6o = function (encoder, value) {
1237
+ var tmp0_desc = this.e6o_1;
1238
+ var tmp1_output = encoder.or(tmp0_desc);
1239
+ tmp1_output.ys(tmp0_desc, 0, value.g6o_1);
1240
+ tmp1_output.ys(tmp0_desc, 1, value.h6o_1);
1241
+ tmp1_output.ys(tmp0_desc, 2, value.i6o_1);
1242
+ tmp1_output.pr(tmp0_desc);
1243
+ };
1244
+ protoOf($serializer_4).co = function (encoder, value) {
1245
+ return this.f6o(encoder, value instanceof Usage ? value : THROW_CCE());
1246
+ };
1247
+ protoOf($serializer_4).do = function (decoder) {
1248
+ var tmp0_desc = this.e6o_1;
1249
+ var tmp1_flag = true;
1250
+ var tmp2_index = 0;
1251
+ var tmp3_bitMask0 = 0;
1252
+ var tmp4_local0 = 0;
1253
+ var tmp5_local1 = 0;
1254
+ var tmp6_local2 = 0;
1255
+ var tmp7_input = decoder.or(tmp0_desc);
1256
+ if (tmp7_input.es()) {
1257
+ tmp4_local0 = tmp7_input.tr(tmp0_desc, 0);
1258
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1259
+ tmp5_local1 = tmp7_input.tr(tmp0_desc, 1);
1260
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1261
+ tmp6_local2 = tmp7_input.tr(tmp0_desc, 2);
1262
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1263
+ } else
1264
+ while (tmp1_flag) {
1265
+ tmp2_index = tmp7_input.fs(tmp0_desc);
1266
+ switch (tmp2_index) {
1267
+ case -1:
1268
+ tmp1_flag = false;
1269
+ break;
1270
+ case 0:
1271
+ tmp4_local0 = tmp7_input.tr(tmp0_desc, 0);
1272
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1273
+ break;
1274
+ case 1:
1275
+ tmp5_local1 = tmp7_input.tr(tmp0_desc, 1);
1276
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1277
+ break;
1278
+ case 2:
1279
+ tmp6_local2 = tmp7_input.tr(tmp0_desc, 2);
1280
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1281
+ break;
1282
+ default:
1283
+ throw UnknownFieldException_init_$Create$(tmp2_index);
1284
+ }
1285
+ }
1286
+ tmp7_input.pr(tmp0_desc);
1287
+ return Usage_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, null);
1288
+ };
1289
+ protoOf($serializer_4).bo = function () {
1290
+ return this.e6o_1;
1291
+ };
1292
+ protoOf($serializer_4).vz = function () {
1293
+ // Inline function 'kotlin.arrayOf' call
1294
+ // Inline function 'kotlin.js.unsafeCast' call
1295
+ // Inline function 'kotlin.js.asDynamic' call
1296
+ return [IntSerializer_getInstance(), IntSerializer_getInstance(), IntSerializer_getInstance()];
1297
+ };
1298
+ var $serializer_instance_4;
1299
+ function $serializer_getInstance_4() {
1300
+ if ($serializer_instance_4 == null)
1301
+ new $serializer_4();
1302
+ return $serializer_instance_4;
1303
+ }
1304
+ function Usage_init_$Init$(seen0, promptTokens, completionTokens, totalTokens, serializationConstructorMarker, $this) {
1305
+ if (!(7 === (7 & seen0))) {
1306
+ throwMissingFieldException(seen0, 7, $serializer_getInstance_4().e6o_1);
1307
+ }
1308
+ $this.g6o_1 = promptTokens;
1309
+ $this.h6o_1 = completionTokens;
1310
+ $this.i6o_1 = totalTokens;
1311
+ return $this;
1312
+ }
1313
+ function Usage_init_$Create$(seen0, promptTokens, completionTokens, totalTokens, serializationConstructorMarker) {
1314
+ return Usage_init_$Init$(seen0, promptTokens, completionTokens, totalTokens, serializationConstructorMarker, objectCreate(protoOf(Usage)));
1315
+ }
1316
+ function OpenAIResponse$Companion$$childSerializers$_anonymous__z8nlex() {
1317
+ return new ArrayListSerializer($serializer_getInstance_3());
1318
+ }
1319
+ function Choice() {
1320
+ }
1321
+ protoOf(Choice).toString = function () {
1322
+ return 'Choice(index=' + this.b6o_1 + ', message=' + this.c6o_1.toString() + ', finishReason=' + this.d6o_1 + ')';
1323
+ };
1324
+ protoOf(Choice).hashCode = function () {
1325
+ var result = this.b6o_1;
1326
+ result = imul(result, 31) + this.c6o_1.hashCode() | 0;
1327
+ result = imul(result, 31) + (this.d6o_1 == null ? 0 : getStringHashCode(this.d6o_1)) | 0;
1328
+ return result;
1329
+ };
1330
+ protoOf(Choice).equals = function (other) {
1331
+ if (this === other)
1332
+ return true;
1333
+ if (!(other instanceof Choice))
1334
+ return false;
1335
+ if (!(this.b6o_1 === other.b6o_1))
1336
+ return false;
1337
+ if (!this.c6o_1.equals(other.c6o_1))
1338
+ return false;
1339
+ if (!(this.d6o_1 == other.d6o_1))
1340
+ return false;
1341
+ return true;
1342
+ };
1343
+ function Usage() {
1344
+ }
1345
+ protoOf(Usage).toString = function () {
1346
+ return 'Usage(promptTokens=' + this.g6o_1 + ', completionTokens=' + this.h6o_1 + ', totalTokens=' + this.i6o_1 + ')';
1347
+ };
1348
+ protoOf(Usage).hashCode = function () {
1349
+ var result = this.g6o_1;
1350
+ result = imul(result, 31) + this.h6o_1 | 0;
1351
+ result = imul(result, 31) + this.i6o_1 | 0;
1352
+ return result;
1353
+ };
1354
+ protoOf(Usage).equals = function (other) {
1355
+ if (this === other)
1356
+ return true;
1357
+ if (!(other instanceof Usage))
1358
+ return false;
1359
+ if (!(this.g6o_1 === other.g6o_1))
1360
+ return false;
1361
+ if (!(this.h6o_1 === other.h6o_1))
1362
+ return false;
1363
+ if (!(this.i6o_1 === other.i6o_1))
1364
+ return false;
1365
+ return true;
1366
+ };
1367
+ function Companion_4() {
1368
+ Companion_instance_6 = this;
1369
+ var tmp = this;
1370
+ var tmp_0 = LazyThreadSafetyMode_PUBLICATION_getInstance();
1371
+ // Inline function 'kotlin.arrayOf' call
1372
+ // Inline function 'kotlin.js.unsafeCast' call
1373
+ // Inline function 'kotlin.js.asDynamic' call
1374
+ tmp.j6o_1 = [null, null, null, null, lazy(tmp_0, OpenAIResponse$Companion$$childSerializers$_anonymous__z8nlex), null];
1375
+ }
1376
+ var Companion_instance_6;
1377
+ function Companion_getInstance_6() {
1378
+ if (Companion_instance_6 == null)
1379
+ new Companion_4();
1380
+ return Companion_instance_6;
1381
+ }
1382
+ function $serializer_5() {
1383
+ $serializer_instance_5 = this;
1384
+ var tmp0_serialDesc = new PluginGeneratedSerialDescriptor('com.logic.ai.data.models.OpenAIResponse', this, 6);
1385
+ tmp0_serialDesc.gz('id', false);
1386
+ tmp0_serialDesc.gz('object', false);
1387
+ tmp0_serialDesc.gz('created', false);
1388
+ tmp0_serialDesc.gz('model', false);
1389
+ tmp0_serialDesc.gz('choices', false);
1390
+ tmp0_serialDesc.gz('usage', true);
1391
+ this.k6o_1 = tmp0_serialDesc;
1392
+ }
1393
+ protoOf($serializer_5).l6o = function (encoder, value) {
1394
+ var tmp0_desc = this.k6o_1;
1395
+ var tmp1_output = encoder.or(tmp0_desc);
1396
+ var tmp2_cached = Companion_getInstance_6().j6o_1;
1397
+ tmp1_output.dt(tmp0_desc, 0, value.m6o_1);
1398
+ tmp1_output.dt(tmp0_desc, 1, value.n6o_1);
1399
+ tmp1_output.zs(tmp0_desc, 2, value.o6o_1);
1400
+ tmp1_output.dt(tmp0_desc, 3, value.p6o_1);
1401
+ tmp1_output.ft(tmp0_desc, 4, tmp2_cached[4].x(), value.q6o_1);
1402
+ if (tmp1_output.lt(tmp0_desc, 5) ? true : !(value.r6o_1 == null)) {
1403
+ tmp1_output.ht(tmp0_desc, 5, $serializer_getInstance_4(), value.r6o_1);
1404
+ }
1405
+ tmp1_output.pr(tmp0_desc);
1406
+ };
1407
+ protoOf($serializer_5).co = function (encoder, value) {
1408
+ return this.l6o(encoder, value instanceof OpenAIResponse ? value : THROW_CCE());
1409
+ };
1410
+ protoOf($serializer_5).do = function (decoder) {
1411
+ var tmp0_desc = this.k6o_1;
1412
+ var tmp1_flag = true;
1413
+ var tmp2_index = 0;
1414
+ var tmp3_bitMask0 = 0;
1415
+ var tmp4_local0 = null;
1416
+ var tmp5_local1 = null;
1417
+ var tmp6_local2 = new Long(0, 0);
1418
+ var tmp7_local3 = null;
1419
+ var tmp8_local4 = null;
1420
+ var tmp9_local5 = null;
1421
+ var tmp10_input = decoder.or(tmp0_desc);
1422
+ var tmp11_cached = Companion_getInstance_6().j6o_1;
1423
+ if (tmp10_input.es()) {
1424
+ tmp4_local0 = tmp10_input.yr(tmp0_desc, 0);
1425
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1426
+ tmp5_local1 = tmp10_input.yr(tmp0_desc, 1);
1427
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1428
+ tmp6_local2 = tmp10_input.ur(tmp0_desc, 2);
1429
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1430
+ tmp7_local3 = tmp10_input.yr(tmp0_desc, 3);
1431
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
1432
+ tmp8_local4 = tmp10_input.as(tmp0_desc, 4, tmp11_cached[4].x(), tmp8_local4);
1433
+ tmp3_bitMask0 = tmp3_bitMask0 | 16;
1434
+ tmp9_local5 = tmp10_input.cs(tmp0_desc, 5, $serializer_getInstance_4(), tmp9_local5);
1435
+ tmp3_bitMask0 = tmp3_bitMask0 | 32;
1436
+ } else
1437
+ while (tmp1_flag) {
1438
+ tmp2_index = tmp10_input.fs(tmp0_desc);
1439
+ switch (tmp2_index) {
1440
+ case -1:
1441
+ tmp1_flag = false;
1442
+ break;
1443
+ case 0:
1444
+ tmp4_local0 = tmp10_input.yr(tmp0_desc, 0);
1445
+ tmp3_bitMask0 = tmp3_bitMask0 | 1;
1446
+ break;
1447
+ case 1:
1448
+ tmp5_local1 = tmp10_input.yr(tmp0_desc, 1);
1449
+ tmp3_bitMask0 = tmp3_bitMask0 | 2;
1450
+ break;
1451
+ case 2:
1452
+ tmp6_local2 = tmp10_input.ur(tmp0_desc, 2);
1453
+ tmp3_bitMask0 = tmp3_bitMask0 | 4;
1454
+ break;
1455
+ case 3:
1456
+ tmp7_local3 = tmp10_input.yr(tmp0_desc, 3);
1457
+ tmp3_bitMask0 = tmp3_bitMask0 | 8;
1458
+ break;
1459
+ case 4:
1460
+ tmp8_local4 = tmp10_input.as(tmp0_desc, 4, tmp11_cached[4].x(), tmp8_local4);
1461
+ tmp3_bitMask0 = tmp3_bitMask0 | 16;
1462
+ break;
1463
+ case 5:
1464
+ tmp9_local5 = tmp10_input.cs(tmp0_desc, 5, $serializer_getInstance_4(), tmp9_local5);
1465
+ tmp3_bitMask0 = tmp3_bitMask0 | 32;
1466
+ break;
1467
+ default:
1468
+ throw UnknownFieldException_init_$Create$(tmp2_index);
1469
+ }
1470
+ }
1471
+ tmp10_input.pr(tmp0_desc);
1472
+ return OpenAIResponse_init_$Create$(tmp3_bitMask0, tmp4_local0, tmp5_local1, tmp6_local2, tmp7_local3, tmp8_local4, tmp9_local5, null);
1473
+ };
1474
+ protoOf($serializer_5).bo = function () {
1475
+ return this.k6o_1;
1476
+ };
1477
+ protoOf($serializer_5).vz = function () {
1478
+ var tmp0_cached = Companion_getInstance_6().j6o_1;
1479
+ // Inline function 'kotlin.arrayOf' call
1480
+ // Inline function 'kotlin.js.unsafeCast' call
1481
+ // Inline function 'kotlin.js.asDynamic' call
1482
+ return [StringSerializer_getInstance(), StringSerializer_getInstance(), LongSerializer_getInstance(), StringSerializer_getInstance(), tmp0_cached[4].x(), get_nullable($serializer_getInstance_4())];
1483
+ };
1484
+ var $serializer_instance_5;
1485
+ function $serializer_getInstance_5() {
1486
+ if ($serializer_instance_5 == null)
1487
+ new $serializer_5();
1488
+ return $serializer_instance_5;
1489
+ }
1490
+ function OpenAIResponse_init_$Init$(seen0, id, objectType, created, model, choices, usage, serializationConstructorMarker, $this) {
1491
+ if (!(31 === (31 & seen0))) {
1492
+ throwMissingFieldException(seen0, 31, $serializer_getInstance_5().k6o_1);
1493
+ }
1494
+ $this.m6o_1 = id;
1495
+ $this.n6o_1 = objectType;
1496
+ $this.o6o_1 = created;
1497
+ $this.p6o_1 = model;
1498
+ $this.q6o_1 = choices;
1499
+ if (0 === (seen0 & 32))
1500
+ $this.r6o_1 = null;
1501
+ else
1502
+ $this.r6o_1 = usage;
1503
+ return $this;
1504
+ }
1505
+ function OpenAIResponse_init_$Create$(seen0, id, objectType, created, model, choices, usage, serializationConstructorMarker) {
1506
+ return OpenAIResponse_init_$Init$(seen0, id, objectType, created, model, choices, usage, serializationConstructorMarker, objectCreate(protoOf(OpenAIResponse)));
1507
+ }
1508
+ function OpenAIResponse(id, objectType, created, model, choices, usage) {
1509
+ Companion_getInstance_6();
1510
+ usage = usage === VOID ? null : usage;
1511
+ this.m6o_1 = id;
1512
+ this.n6o_1 = objectType;
1513
+ this.o6o_1 = created;
1514
+ this.p6o_1 = model;
1515
+ this.q6o_1 = choices;
1516
+ this.r6o_1 = usage;
1517
+ }
1518
+ protoOf(OpenAIResponse).toString = function () {
1519
+ return 'OpenAIResponse(id=' + this.m6o_1 + ', objectType=' + this.n6o_1 + ', created=' + this.o6o_1.toString() + ', model=' + this.p6o_1 + ', choices=' + toString(this.q6o_1) + ', usage=' + toString_0(this.r6o_1) + ')';
1520
+ };
1521
+ protoOf(OpenAIResponse).hashCode = function () {
1522
+ var result = getStringHashCode(this.m6o_1);
1523
+ result = imul(result, 31) + getStringHashCode(this.n6o_1) | 0;
1524
+ result = imul(result, 31) + this.o6o_1.hashCode() | 0;
1525
+ result = imul(result, 31) + getStringHashCode(this.p6o_1) | 0;
1526
+ result = imul(result, 31) + hashCode(this.q6o_1) | 0;
1527
+ result = imul(result, 31) + (this.r6o_1 == null ? 0 : this.r6o_1.hashCode()) | 0;
1528
+ return result;
1529
+ };
1530
+ protoOf(OpenAIResponse).equals = function (other) {
1531
+ if (this === other)
1532
+ return true;
1533
+ if (!(other instanceof OpenAIResponse))
1534
+ return false;
1535
+ if (!(this.m6o_1 === other.m6o_1))
1536
+ return false;
1537
+ if (!(this.n6o_1 === other.n6o_1))
1538
+ return false;
1539
+ if (!equalsLong(this.o6o_1, other.o6o_1))
1540
+ return false;
1541
+ if (!(this.p6o_1 === other.p6o_1))
1542
+ return false;
1543
+ if (!equals(this.q6o_1, other.q6o_1))
1544
+ return false;
1545
+ if (!equals(this.r6o_1, other.r6o_1))
1546
+ return false;
1547
+ return true;
1548
+ };
1549
+ function BotChatRepository() {
1550
+ }
1551
+ function executeRequest($this, messages, cacheKey, $completion) {
1552
+ var tmp = new $executeRequestCOROUTINE$($this, messages, cacheKey, $completion);
1553
+ tmp.u8_1 = Unit_instance;
1554
+ tmp.v8_1 = null;
1555
+ var tmp_0 = tmp.a9();
1556
+ if (tmp_0 === get_COROUTINE_SUSPENDED())
1557
+ return tmp_0;
1558
+ return tmp_0;
1559
+ }
1560
+ function buildCacheKey($this, type, message, context) {
1561
+ // Inline function 'kotlin.text.buildString' call
1562
+ // Inline function 'kotlin.apply' call
1563
+ var this_0 = StringBuilder_init_$Create$();
1564
+ this_0.d8(type);
1565
+ this_0.d8(':');
1566
+ if (message == null)
1567
+ null;
1568
+ else {
1569
+ // Inline function 'kotlin.let' call
1570
+ this_0.sb(getStringHashCode(take(message, 50))).d8(':');
1571
+ }
1572
+ this_0.sb(getStringHashCode(context.d6n_1));
1573
+ this_0.d8(':');
1574
+ this_0.sb(getStringHashCode(context.e6n_1));
1575
+ var key = this_0.toString();
1576
+ return key;
1577
+ }
1578
+ function buildConversationMessages($this, playerMessage, context) {
1579
+ // Inline function 'kotlin.collections.mutableListOf' call
1580
+ var messages = ArrayList_init_$Create$();
1581
+ var tmp = Companion_getInstance_3();
1582
+ // Inline function 'kotlin.text.buildString' call
1583
+ // Inline function 'kotlin.apply' call
1584
+ var this_0 = StringBuilder_init_$Create$();
1585
+ this_0.d8('You are a card game player with the following personality: ' + context.d6n_1 + '. ');
1586
+ this_0.d8('Current game state: ' + context.e6n_1 + '. ');
1587
+ this_0.d8('Respond naturally and in character. ');
1588
+ this_0.d8('Keep responses SHORT (max 1-2 sentences). ');
1589
+ this_0.d8('Use casual language appropriate for a friendly card game. ');
1590
+ if (!(context.g6n_1 == null)) {
1591
+ this_0.d8('You are chatting with ' + context.g6n_1 + '. ');
1592
+ }
1593
+ var tmp$ret$3 = this_0.toString();
1594
+ messages.j(tmp.j6n(tmp$ret$3));
1595
+ // Inline function 'kotlin.collections.forEach' call
1596
+ var _iterator__ex2g4s = takeLast(context.f6n_1, 5).l();
1597
+ while (_iterator__ex2g4s.m()) {
1598
+ var element = _iterator__ex2g4s.n();
1599
+ messages.j(Companion_getInstance_3().l6n(element));
1600
+ }
1601
+ messages.j(Companion_getInstance_3().k6n(playerMessage));
1602
+ return messages;
1603
+ }
1604
+ function buildRandomMessagePrompt($this, context) {
1605
+ var tmp = Companion_getInstance_3();
1606
+ // Inline function 'kotlin.text.buildString' call
1607
+ // Inline function 'kotlin.apply' call
1608
+ var this_0 = StringBuilder_init_$Create$();
1609
+ this_0.d8('You are a card game player with the following personality: ' + context.d6n_1 + '. ');
1610
+ this_0.d8('Current game state: ' + context.e6n_1 + '. ');
1611
+ this_0.d8('Generate a SHORT spontaneous comment or reaction (max 1 sentence). ');
1612
+ this_0.d8('React to the game state naturally. ');
1613
+ this_0.d8('Use casual language appropriate for a friendly card game. ');
1614
+ this_0.d8('Be brief and authentic. ');
1615
+ var tmp$ret$2 = this_0.toString();
1616
+ return listOf([tmp.j6n(tmp$ret$2), Companion_getInstance_3().k6n('Generate a spontaneous comment about the current game situation.')]);
1617
+ }
1618
+ function $executeRequestCOROUTINE$(_this__u8e3s4, messages, cacheKey, resultContinuation) {
1619
+ CoroutineImpl.call(this, resultContinuation);
1620
+ this.c6p_1 = _this__u8e3s4;
1621
+ this.d6p_1 = messages;
1622
+ this.e6p_1 = cacheKey;
1623
+ }
1624
+ protoOf($executeRequestCOROUTINE$).a9 = function () {
1625
+ var suspendResult = this.u8_1;
1626
+ $sm: do
1627
+ try {
1628
+ var tmp = this.s8_1;
1629
+ switch (tmp) {
1630
+ case 0:
1631
+ this.t8_1 = 3;
1632
+ this.s8_1 = 1;
1633
+ suspendResult = this.c6p_1.f6p_1.z6l(this.d6p_1, this);
1634
+ if (suspendResult === get_COROUTINE_SUSPENDED()) {
1635
+ return suspendResult;
1636
+ }
1637
+
1638
+ this.s8_1 = 2;
1639
+ continue $sm;
1640
+ case 1:
1641
+ var unboxed = suspendResult.tl_1;
1642
+ suspendResult = new Result(unboxed);
1643
+ this.s8_1 = 2;
1644
+ continue $sm;
1645
+ case 2:
1646
+ var this_0 = suspendResult.tl_1;
1647
+ var tmp_0;
1648
+ if (_Result___get_isSuccess__impl__sndoy8(this_0)) {
1649
+ var this_1 = new Result(this_0);
1650
+ var tmp_1;
1651
+ try {
1652
+ var $this$runCatching = this_1.tl_1;
1653
+ var tmp_2 = _Result___get_value__impl__bjfvqg($this$runCatching);
1654
+ var response = (tmp_2 == null ? true : !(tmp_2 == null)) ? tmp_2 : THROW_CCE();
1655
+ var tmp0_safe_receiver = firstOrNull(response.q6o_1);
1656
+ var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.c6o_1;
1657
+ var tmp2_elvis_lhs = tmp1_safe_receiver == null ? null : tmp1_safe_receiver.p6n_1;
1658
+ var tmp_3;
1659
+ if (tmp2_elvis_lhs == null) {
1660
+ throw IllegalStateException_init_$Create$('No response from OpenAI');
1661
+ } else {
1662
+ tmp_3 = tmp2_elvis_lhs;
1663
+ }
1664
+ var content = tmp_3;
1665
+ this.c6p_1.g6p_1.u6m(this.e6p_1, content);
1666
+ tmp_1 = _Result___init__impl__xyqfz8(content);
1667
+ } catch ($p) {
1668
+ var tmp_4;
1669
+ if ($p instanceof Error) {
1670
+ var e = $p;
1671
+ tmp_4 = _Result___init__impl__xyqfz8(createFailure(e));
1672
+ } else {
1673
+ throw $p;
1674
+ }
1675
+ tmp_1 = tmp_4;
1676
+ }
1677
+ tmp_0 = tmp_1;
1678
+ } else {
1679
+ tmp_0 = _Result___init__impl__xyqfz8(_Result___get_value__impl__bjfvqg(this_0));
1680
+ }
1681
+
1682
+ return new Result(tmp_0);
1683
+ case 3:
1684
+ throw this.v8_1;
1685
+ }
1686
+ } catch ($p) {
1687
+ var e_0 = $p;
1688
+ if (this.t8_1 === 3) {
1689
+ throw e_0;
1690
+ } else {
1691
+ this.s8_1 = this.t8_1;
1692
+ this.v8_1 = e_0;
1693
+ }
1694
+ }
1695
+ while (true);
1696
+ };
1697
+ function BotChatRepositoryImpl(openAIApi, cache) {
1698
+ this.f6p_1 = openAIApi;
1699
+ this.g6p_1 = cache;
1700
+ }
1701
+ protoOf(BotChatRepositoryImpl).s6o = function (playerMessage, context, $completion) {
1702
+ var cacheKey = buildCacheKey(this, 'answer', playerMessage, context);
1703
+ var tmp0_safe_receiver = this.g6p_1.t1b(cacheKey);
1704
+ if (tmp0_safe_receiver == null)
1705
+ null;
1706
+ else {
1707
+ // Inline function 'kotlin.let' call
1708
+ // Inline function 'kotlin.Companion.success' call
1709
+ var tmp$ret$0 = _Result___init__impl__xyqfz8(tmp0_safe_receiver);
1710
+ return new Result(tmp$ret$0);
1711
+ }
1712
+ var messages = buildConversationMessages(this, playerMessage, context);
1713
+ var tmp = executeRequest(this, messages, cacheKey, $completion);
1714
+ if (tmp === get_COROUTINE_SUSPENDED())
1715
+ return tmp;
1716
+ return tmp;
1717
+ };
1718
+ protoOf(BotChatRepositoryImpl).t6o = function (context, $completion) {
1719
+ var cacheKey = buildCacheKey(this, 'random', null, context);
1720
+ var tmp0_safe_receiver = this.g6p_1.t1b(cacheKey);
1721
+ if (tmp0_safe_receiver == null)
1722
+ null;
1723
+ else {
1724
+ // Inline function 'kotlin.let' call
1725
+ // Inline function 'kotlin.Companion.success' call
1726
+ var tmp$ret$0 = _Result___init__impl__xyqfz8(tmp0_safe_receiver);
1727
+ return new Result(tmp$ret$0);
1728
+ }
1729
+ var messages = buildRandomMessagePrompt(this, context);
1730
+ var tmp = executeRequest(this, messages, cacheKey, $completion);
1731
+ if (tmp === get_COROUTINE_SUSPENDED())
1732
+ return tmp;
1733
+ return tmp;
1734
+ };
1735
+ function aiModule(config) {
1736
+ return Module_init_$Create$('AIModule', VOID, VOID, aiModule$lambda(config));
1737
+ }
1738
+ function aiModule$lambda$lambda($config) {
1739
+ return function ($this$singleton) {
1740
+ return $config;
1741
+ };
1742
+ }
1743
+ function aiModule$lambda$lambda_0($this$singleton) {
1744
+ return new InMemoryBotChatCache(new Long(300000, 0), 100);
1745
+ }
1746
+ function aiModule$lambda$lambda_1($this$singleton) {
1747
+ return HttpClient(aiModule$lambda$lambda$lambda);
1748
+ }
1749
+ function aiModule$lambda$lambda$lambda($this$HttpClient) {
1750
+ var tmp = Plugin_getInstance();
1751
+ $this$HttpClient.s3t(tmp, aiModule$lambda$lambda$lambda$lambda);
1752
+ var tmp_0 = Companion_getInstance_0();
1753
+ $this$HttpClient.s3t(tmp_0, aiModule$lambda$lambda$lambda$lambda_0);
1754
+ return Unit_instance;
1755
+ }
1756
+ function aiModule$lambda$lambda$lambda$lambda($this$install) {
1757
+ json($this$install, Json(VOID, aiModule$lambda$lambda$lambda$lambda$lambda));
1758
+ return Unit_instance;
1759
+ }
1760
+ function aiModule$lambda$lambda$lambda$lambda$lambda($this$Json) {
1761
+ $this$Json.f1a_1 = true;
1762
+ $this$Json.g1a_1 = true;
1763
+ $this$Json.h1a_1 = false;
1764
+ return Unit_instance;
1765
+ }
1766
+ function aiModule$lambda$lambda$lambda$lambda_0($this$install) {
1767
+ $this$install.g4q(get_DEFAULT(Companion_instance_0));
1768
+ $this$install.f4q_1 = LogLevel_INFO_getInstance();
1769
+ return Unit_instance;
1770
+ }
1771
+ function aiModule$lambda$lambda_2($this$singleton) {
1772
+ // Inline function 'org.kodein.di.instance' call
1773
+ var tmp = $this$singleton.o60();
1774
+ // Inline function 'org.kodein.type.generic' call
1775
+ var tmp_0 = typeToken(createKType(getKClass(OpenAIConfig), arrayOf([]), false));
1776
+ var tmp$ret$0 = isInterface(tmp_0, TypeToken) ? tmp_0 : THROW_CCE();
1777
+ var tmp_1 = tmp.n60(tmp$ret$0, null);
1778
+ // Inline function 'org.kodein.di.instance' call
1779
+ var tmp_2 = $this$singleton.o60();
1780
+ // Inline function 'org.kodein.type.generic' call
1781
+ var tmp_3 = typeToken(createKType(getKClass(HttpClient_0), arrayOf([]), false));
1782
+ var tmp$ret$2 = isInterface(tmp_3, TypeToken) ? tmp_3 : THROW_CCE();
1783
+ var tmp$ret$3 = tmp_2.n60(tmp$ret$2, null);
1784
+ return new OpenAIApiImpl(tmp_1, tmp$ret$3);
1785
+ }
1786
+ function aiModule$lambda$lambda_3($this$singleton) {
1787
+ // Inline function 'org.kodein.di.instance' call
1788
+ var tmp = $this$singleton.o60();
1789
+ // Inline function 'org.kodein.type.generic' call
1790
+ var tmp_0 = typeToken(createKType(getKClass(OpenAIApi), arrayOf([]), false));
1791
+ var tmp$ret$0 = isInterface(tmp_0, TypeToken) ? tmp_0 : THROW_CCE();
1792
+ var tmp_1 = tmp.n60(tmp$ret$0, null);
1793
+ // Inline function 'org.kodein.di.instance' call
1794
+ var tmp_2 = $this$singleton.o60();
1795
+ // Inline function 'org.kodein.type.generic' call
1796
+ var tmp_3 = typeToken(createKType(getKClass(BotChatCache), arrayOf([]), false));
1797
+ var tmp$ret$2 = isInterface(tmp_3, TypeToken) ? tmp_3 : THROW_CCE();
1798
+ var tmp$ret$3 = tmp_2.n60(tmp$ret$2, null);
1799
+ return new BotChatRepositoryImpl(tmp_1, tmp$ret$3);
1800
+ }
1801
+ function aiModule$lambda$lambda_4($this$singleton) {
1802
+ // Inline function 'org.kodein.di.instance' call
1803
+ var tmp = $this$singleton.o60();
1804
+ // Inline function 'org.kodein.type.generic' call
1805
+ var tmp_0 = typeToken(createKType(getKClass(BotChatRepository), arrayOf([]), false));
1806
+ var tmp$ret$0 = isInterface(tmp_0, TypeToken) ? tmp_0 : THROW_CCE();
1807
+ var tmp$ret$1 = tmp.n60(tmp$ret$0, null);
1808
+ return new BotChatInteractorImpl(tmp$ret$1);
1809
+ }
1810
+ function aiModule$lambda($config) {
1811
+ return function ($this$Module) {
1812
+ // Inline function 'org.kodein.di.bind' call
1813
+ // Inline function 'org.kodein.type.generic' call
1814
+ var tmp = typeToken(createKType(getKClass(OpenAIConfig), arrayOf([]), false));
1815
+ var tmp$ret$0 = isInterface(tmp, TypeToken) ? tmp : THROW_CCE();
1816
+ var tmp_0 = $this$Module.b5z(tmp$ret$0, null, null);
1817
+ // Inline function 'org.kodein.di.singleton' call
1818
+ var creator = aiModule$lambda$lambda($config);
1819
+ var tmp_1 = $this$Module.g5z();
1820
+ var tmp_2 = $this$Module.e5z();
1821
+ var tmp_3 = $this$Module.f5z();
1822
+ // Inline function 'org.kodein.type.generic' call
1823
+ var tmp_4 = typeToken(createKType(getKClass(OpenAIConfig), arrayOf([]), false));
1824
+ var tmp$ret$2 = isInterface(tmp_4, TypeToken) ? tmp_4 : THROW_CCE();
1825
+ var tmp$ret$3 = new Singleton(tmp_1, tmp_2, tmp_3, tmp$ret$2, null, true, creator);
1826
+ tmp_0.z62(tmp$ret$3);
1827
+ // Inline function 'org.kodein.di.bind' call
1828
+ // Inline function 'org.kodein.type.generic' call
1829
+ var tmp_5 = typeToken(createKType(getKClass(BotChatCache), arrayOf([]), false));
1830
+ var tmp$ret$4 = isInterface(tmp_5, TypeToken) ? tmp_5 : THROW_CCE();
1831
+ var tmp_6 = $this$Module.b5z(tmp$ret$4, null, null);
1832
+ // Inline function 'org.kodein.di.singleton' call
1833
+ var creator_0 = aiModule$lambda$lambda_0;
1834
+ var tmp_7 = $this$Module.g5z();
1835
+ var tmp_8 = $this$Module.e5z();
1836
+ var tmp_9 = $this$Module.f5z();
1837
+ // Inline function 'org.kodein.type.generic' call
1838
+ var tmp_10 = typeToken(createKType(getKClass(InMemoryBotChatCache), arrayOf([]), false));
1839
+ var tmp$ret$6 = isInterface(tmp_10, TypeToken) ? tmp_10 : THROW_CCE();
1840
+ var tmp$ret$7 = new Singleton(tmp_7, tmp_8, tmp_9, tmp$ret$6, null, true, creator_0);
1841
+ tmp_6.z62(tmp$ret$7);
1842
+ // Inline function 'org.kodein.di.bind' call
1843
+ // Inline function 'org.kodein.type.generic' call
1844
+ var tmp_11 = typeToken(createKType(getKClass(HttpClient_0), arrayOf([]), false));
1845
+ var tmp$ret$8 = isInterface(tmp_11, TypeToken) ? tmp_11 : THROW_CCE();
1846
+ var tmp_12 = $this$Module.b5z(tmp$ret$8, null, null);
1847
+ // Inline function 'org.kodein.di.singleton' call
1848
+ var creator_1 = aiModule$lambda$lambda_1;
1849
+ var tmp_13 = $this$Module.g5z();
1850
+ var tmp_14 = $this$Module.e5z();
1851
+ var tmp_15 = $this$Module.f5z();
1852
+ // Inline function 'org.kodein.type.generic' call
1853
+ var tmp_16 = typeToken(createKType(getKClass(HttpClient_0), arrayOf([]), false));
1854
+ var tmp$ret$10 = isInterface(tmp_16, TypeToken) ? tmp_16 : THROW_CCE();
1855
+ var tmp$ret$11 = new Singleton(tmp_13, tmp_14, tmp_15, tmp$ret$10, null, true, creator_1);
1856
+ tmp_12.z62(tmp$ret$11);
1857
+ // Inline function 'org.kodein.di.bind' call
1858
+ // Inline function 'org.kodein.type.generic' call
1859
+ var tmp_17 = typeToken(createKType(getKClass(OpenAIApi), arrayOf([]), false));
1860
+ var tmp$ret$12 = isInterface(tmp_17, TypeToken) ? tmp_17 : THROW_CCE();
1861
+ var tmp_18 = $this$Module.b5z(tmp$ret$12, null, null);
1862
+ // Inline function 'org.kodein.di.singleton' call
1863
+ var creator_2 = aiModule$lambda$lambda_2;
1864
+ var tmp_19 = $this$Module.g5z();
1865
+ var tmp_20 = $this$Module.e5z();
1866
+ var tmp_21 = $this$Module.f5z();
1867
+ // Inline function 'org.kodein.type.generic' call
1868
+ var tmp_22 = typeToken(createKType(getKClass(OpenAIApiImpl), arrayOf([]), false));
1869
+ var tmp$ret$14 = isInterface(tmp_22, TypeToken) ? tmp_22 : THROW_CCE();
1870
+ var tmp$ret$15 = new Singleton(tmp_19, tmp_20, tmp_21, tmp$ret$14, null, true, creator_2);
1871
+ tmp_18.z62(tmp$ret$15);
1872
+ // Inline function 'org.kodein.di.bind' call
1873
+ // Inline function 'org.kodein.type.generic' call
1874
+ var tmp_23 = typeToken(createKType(getKClass(BotChatRepository), arrayOf([]), false));
1875
+ var tmp$ret$16 = isInterface(tmp_23, TypeToken) ? tmp_23 : THROW_CCE();
1876
+ var tmp_24 = $this$Module.b5z(tmp$ret$16, null, null);
1877
+ // Inline function 'org.kodein.di.singleton' call
1878
+ var creator_3 = aiModule$lambda$lambda_3;
1879
+ var tmp_25 = $this$Module.g5z();
1880
+ var tmp_26 = $this$Module.e5z();
1881
+ var tmp_27 = $this$Module.f5z();
1882
+ // Inline function 'org.kodein.type.generic' call
1883
+ var tmp_28 = typeToken(createKType(getKClass(BotChatRepositoryImpl), arrayOf([]), false));
1884
+ var tmp$ret$18 = isInterface(tmp_28, TypeToken) ? tmp_28 : THROW_CCE();
1885
+ var tmp$ret$19 = new Singleton(tmp_25, tmp_26, tmp_27, tmp$ret$18, null, true, creator_3);
1886
+ tmp_24.z62(tmp$ret$19);
1887
+ // Inline function 'org.kodein.di.bind' call
1888
+ // Inline function 'org.kodein.type.generic' call
1889
+ var tmp_29 = typeToken(createKType(getKClass(BotChatInteractor), arrayOf([]), false));
1890
+ var tmp$ret$20 = isInterface(tmp_29, TypeToken) ? tmp_29 : THROW_CCE();
1891
+ var tmp_30 = $this$Module.b5z(tmp$ret$20, null, null);
1892
+ // Inline function 'org.kodein.di.singleton' call
1893
+ var creator_4 = aiModule$lambda$lambda_4;
1894
+ var tmp_31 = $this$Module.g5z();
1895
+ var tmp_32 = $this$Module.e5z();
1896
+ var tmp_33 = $this$Module.f5z();
1897
+ // Inline function 'org.kodein.type.generic' call
1898
+ var tmp_34 = typeToken(createKType(getKClass(BotChatInteractorImpl), arrayOf([]), false));
1899
+ var tmp$ret$22 = isInterface(tmp_34, TypeToken) ? tmp_34 : THROW_CCE();
1900
+ var tmp$ret$23 = new Singleton(tmp_31, tmp_32, tmp_33, tmp$ret$22, null, true, creator_4);
1901
+ tmp_30.z62(tmp$ret$23);
1902
+ return Unit_instance;
1903
+ };
1904
+ }
1905
+ function BotChatInteractor() {
1906
+ }
1907
+ function BotChatInteractorImpl(repository) {
1908
+ this.h6p_1 = repository;
1909
+ }
1910
+ protoOf(BotChatInteractorImpl).s6o = function (playerMessage, context, $completion) {
1911
+ var tmp = this.h6p_1.s6o(playerMessage, context, $completion);
1912
+ if (tmp === get_COROUTINE_SUSPENDED())
1913
+ return tmp;
1914
+ return tmp;
1915
+ };
1916
+ protoOf(BotChatInteractorImpl).t6o = function (context, $completion) {
1917
+ var tmp = this.h6p_1.t6o(context, $completion);
1918
+ if (tmp === get_COROUTINE_SUSPENDED())
1919
+ return tmp;
1920
+ return tmp;
1921
+ };
1922
+ //region block: post-declaration
1923
+ protoOf($serializer).wz = typeParametersSerializers;
1924
+ protoOf($serializer_0).wz = typeParametersSerializers;
1925
+ protoOf($serializer_1).wz = typeParametersSerializers;
1926
+ protoOf($serializer_2).wz = typeParametersSerializers;
1927
+ protoOf($serializer_3).wz = typeParametersSerializers;
1928
+ protoOf($serializer_4).wz = typeParametersSerializers;
1929
+ protoOf($serializer_5).wz = typeParametersSerializers;
1930
+ //endregion
1931
+ //region block: init
1932
+ Companion_instance_4 = new Companion_2();
1933
+ //endregion
1934
+ //region block: exports
1935
+ _.$_$ = _.$_$ || {};
1936
+ _.$_$.a = BotChatContext;
1937
+ _.$_$.b = OpenAIConfig;
1938
+ _.$_$.c = aiModule;
1939
+ _.$_$.d = BotChatInteractor;
1940
+ //endregion
1941
+ return _;
1942
+ }));
1943
+
1944
+ //# sourceMappingURL=Logic_Debertz-ai_module.js.map