@effect-ak/tg-bot 1.2.0 → 1.2.4

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
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  BotUpdateHandlersTag: () => BotUpdateHandlersTag,
30
30
  HandleUpdateError: () => HandleUpdateError,
31
31
  createBotContext: () => createBotContext,
32
+ createWebhookHandler: () => createWebhookHandler,
32
33
  defineBot: () => defineBot,
33
34
  extractUpdate: () => extractUpdate,
34
35
  handleEntireBatch: () => handleEntireBatch,
@@ -40,7 +41,7 @@ __export(index_exports, {
40
41
  });
41
42
  module.exports = __toCommonJS(index_exports);
42
43
 
43
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Function.js
44
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Function.js
44
45
  var isFunction = (input) => typeof input === "function";
45
46
  var dual = function(arity, body) {
46
47
  if (typeof arity === "function") {
@@ -139,38 +140,34 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
139
140
  }
140
141
  }
141
142
 
142
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Equivalence.js
143
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equivalence.js
143
144
  var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
144
145
 
145
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/version.js
146
- var moduleVersion = "3.12.0";
147
- var getCurrentVersion = () => moduleVersion;
148
-
149
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/GlobalValue.js
150
- var globalStoreId = /* @__PURE__ */ Symbol.for(`effect/GlobalValue/globalStoreId/${/* @__PURE__ */ getCurrentVersion()}`);
151
- if (!(globalStoreId in globalThis)) {
152
- ;
153
- globalThis[globalStoreId] = /* @__PURE__ */ new Map();
154
- }
155
- var globalStore = globalThis[globalStoreId];
146
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/GlobalValue.js
147
+ var globalStoreId = `effect/GlobalValue`;
148
+ var globalStore;
156
149
  var globalValue = (id, compute) => {
150
+ if (!globalStore) {
151
+ globalThis[globalStoreId] ??= /* @__PURE__ */ new Map();
152
+ globalStore = globalThis[globalStoreId];
153
+ }
157
154
  if (!globalStore.has(id)) {
158
155
  globalStore.set(id, compute());
159
156
  }
160
157
  return globalStore.get(id);
161
158
  };
162
159
 
163
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Predicate.js
160
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Predicate.js
164
161
  var isFunction2 = isFunction;
165
162
  var isRecordOrArray = (input) => typeof input === "object" && input !== null;
166
163
  var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
167
164
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
168
165
  var isTagged = /* @__PURE__ */ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
169
166
 
170
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/errors.js
167
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/errors.js
171
168
  var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
172
169
 
173
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Utils.js
170
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Utils.js
174
171
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
175
172
  var GenKindImpl = class {
176
173
  value;
@@ -280,10 +277,25 @@ var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructur
280
277
  enabled: false,
281
278
  tester: void 0
282
279
  }));
280
+ var standard = {
281
+ effect_internal_function: (body) => {
282
+ return body();
283
+ }
284
+ };
285
+ var forced = {
286
+ effect_internal_function: (body) => {
287
+ try {
288
+ return body();
289
+ } finally {
290
+ }
291
+ }
292
+ };
293
+ var isNotOptimizedAway = /* @__PURE__ */ standard.effect_internal_function(() => new Error().stack)?.includes("effect_internal_function") === true;
294
+ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forced.effect_internal_function;
283
295
  var genConstructor = function* () {
284
296
  }.constructor;
285
297
 
286
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Hash.js
298
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Hash.js
287
299
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
288
300
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
289
301
  var hash = (self) => {
@@ -308,7 +320,12 @@ var hash = (self) => {
308
320
  if (self === null) {
309
321
  return string("null");
310
322
  } else if (self instanceof Date) {
323
+ if (Number.isNaN(self.getTime())) {
324
+ return string("Invalid Date");
325
+ }
311
326
  return hash(self.toISOString());
327
+ } else if (self instanceof URL) {
328
+ return hash(self.href);
312
329
  } else if (isHash(self)) {
313
330
  return self[symbol]();
314
331
  } else {
@@ -387,7 +404,7 @@ var cached = function() {
387
404
  return hash2;
388
405
  };
389
406
 
390
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Equal.js
407
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equal.js
391
408
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
392
409
  function equals() {
393
410
  if (arguments.length === 1) {
@@ -412,7 +429,11 @@ function compareBoth(self, that) {
412
429
  return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
413
430
  }
414
431
  } else if (self instanceof Date && that instanceof Date) {
415
- return self.toISOString() === that.toISOString();
432
+ const t1 = self.getTime();
433
+ const t2 = that.getTime();
434
+ return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
435
+ } else if (self instanceof URL && that instanceof URL) {
436
+ return self.href === that.href;
416
437
  }
417
438
  }
418
439
  if (structuralRegionState.enabled) {
@@ -438,7 +459,7 @@ function compareBoth(self, that) {
438
459
  }
439
460
  var isEqual = (u) => hasProperty(u, symbol2);
440
461
 
441
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Inspectable.js
462
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Inspectable.js
442
463
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
443
464
  var toJSON = (x) => {
444
465
  try {
@@ -447,7 +468,7 @@ var toJSON = (x) => {
447
468
  } else if (Array.isArray(x)) {
448
469
  return x.map(toJSON);
449
470
  }
450
- } catch (_) {
471
+ } catch {
451
472
  return {};
452
473
  }
453
474
  return redact(x);
@@ -484,7 +505,7 @@ var toStringUnknown = (u, whitespace = 2) => {
484
505
  }
485
506
  try {
486
507
  return typeof u === "object" ? stringifyCircular(u, whitespace) : String(u);
487
- } catch (_) {
508
+ } catch {
488
509
  return String(u);
489
510
  }
490
511
  };
@@ -506,7 +527,7 @@ var redact = (u) => {
506
527
  return u;
507
528
  };
508
529
 
509
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Pipeable.js
530
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Pipeable.js
510
531
  var pipeArguments = (self, args2) => {
511
532
  switch (args2.length) {
512
533
  case 0:
@@ -539,12 +560,16 @@ var pipeArguments = (self, args2) => {
539
560
  }
540
561
  };
541
562
 
542
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/opCodes/effect.js
563
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/effect.js
543
564
  var OP_COMMIT = "Commit";
544
565
  var OP_FAILURE = "Failure";
545
566
  var OP_WITH_RUNTIME = "WithRuntime";
546
567
 
547
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/effectable.js
568
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/version.js
569
+ var moduleVersion = "3.19.13";
570
+ var getCurrentVersion = () => moduleVersion;
571
+
572
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/effectable.js
548
573
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
549
574
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
550
575
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -631,7 +656,7 @@ var StructuralCommitPrototype = {
631
656
  ...StructuralPrototype
632
657
  };
633
658
 
634
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/option.js
659
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/option.js
635
660
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
636
661
  var CommonProto = {
637
662
  ...EffectPrototype,
@@ -689,7 +714,7 @@ var some = (value) => {
689
714
  return a;
690
715
  };
691
716
 
692
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/either.js
717
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/either.js
693
718
  var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
694
719
  var CommonProto2 = {
695
720
  ...EffectPrototype,
@@ -751,11 +776,11 @@ var right = (right3) => {
751
776
  return a;
752
777
  };
753
778
 
754
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Either.js
779
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Either.js
755
780
  var right2 = right;
756
781
  var left2 = left;
757
782
 
758
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Option.js
783
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Option.js
759
784
  var none2 = () => none;
760
785
  var some2 = some;
761
786
  var isNone2 = isNone;
@@ -763,13 +788,13 @@ var isSome2 = isSome;
763
788
  var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
764
789
  var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
765
790
 
766
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Array.js
791
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Array.js
767
792
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
768
793
  var isArray = Array.isArray;
769
794
  var reverse = (self) => Array.from(self).reverse();
770
795
  var reduce = /* @__PURE__ */ dual(3, (self, b, f) => fromIterable(self).reduce((b2, a, i) => f(b2, a, i), b));
771
796
 
772
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Chunk.js
797
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Chunk.js
773
798
  var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Chunk");
774
799
  function copy(src, srcPos, dest, destPos, len) {
775
800
  for (let i = srcPos; i < Math.min(src.length, srcPos + len); i++) {
@@ -866,15 +891,12 @@ var _empty = /* @__PURE__ */ makeChunk({
866
891
  _tag: "IEmpty"
867
892
  });
868
893
  var empty = () => _empty;
869
- var make2 = (...as2) => as2.length === 1 ? of(as2[0]) : unsafeFromNonEmptyArray(as2);
894
+ var make2 = (...as2) => unsafeFromNonEmptyArray(as2);
870
895
  var of = (a) => makeChunk({
871
896
  _tag: "ISingleton",
872
897
  a
873
898
  });
874
- var fromIterable2 = (self) => isChunk(self) ? self : makeChunk({
875
- _tag: "IArray",
876
- array: fromIterable(self)
877
- });
899
+ var fromIterable2 = (self) => isChunk(self) ? self : unsafeFromArray(fromIterable(self));
878
900
  var copyToArray = (self, array2, initial) => {
879
901
  switch (self.backing._tag) {
880
902
  case "IArray": {
@@ -948,7 +970,7 @@ var reverseChunk = (self) => {
948
970
  }
949
971
  };
950
972
  var reverse2 = reverseChunk;
951
- var unsafeFromArray = (self) => makeChunk({
973
+ var unsafeFromArray = (self) => self.length === 0 ? empty() : self.length === 1 ? of(self[0]) : makeChunk({
952
974
  _tag: "IArray",
953
975
  array: self
954
976
  });
@@ -1068,7 +1090,7 @@ var isNonEmpty = (self) => self.length > 0;
1068
1090
  var unsafeHead = (self) => unsafeGet(self, 0);
1069
1091
  var headNonEmpty = unsafeHead;
1070
1092
 
1071
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/context.js
1093
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/context.js
1072
1094
  var TagTypeId = /* @__PURE__ */ Symbol.for("effect/Context/Tag");
1073
1095
  var ReferenceTypeId = /* @__PURE__ */ Symbol.for("effect/Context/Reference");
1074
1096
  var STMSymbolKey = "effect/STM";
@@ -1232,7 +1254,7 @@ var merge = /* @__PURE__ */ dual(2, (self, that) => {
1232
1254
  return makeContext(map7);
1233
1255
  });
1234
1256
 
1235
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Context.js
1257
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Context.js
1236
1258
  var make4 = make3;
1237
1259
  var add2 = add;
1238
1260
  var unsafeGet3 = unsafeGet2;
@@ -1240,14 +1262,14 @@ var merge2 = merge;
1240
1262
  var Tag2 = Tag;
1241
1263
  var Reference2 = Reference;
1242
1264
 
1243
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/config.js
1265
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/config.js
1244
1266
  var SIZE = 5;
1245
1267
  var BUCKET_SIZE = /* @__PURE__ */ Math.pow(2, SIZE);
1246
1268
  var MASK = BUCKET_SIZE - 1;
1247
1269
  var MAX_INDEX_NODE = BUCKET_SIZE / 2;
1248
1270
  var MIN_ARRAY_NODE = BUCKET_SIZE / 4;
1249
1271
 
1250
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
1272
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
1251
1273
  function popcount(x) {
1252
1274
  x -= x >> 1 & 1431655765;
1253
1275
  x = (x & 858993459) + (x >> 2 & 858993459);
@@ -1266,13 +1288,13 @@ function fromBitmap(bitmap, bit) {
1266
1288
  return popcount(bitmap & bit - 1);
1267
1289
  }
1268
1290
 
1269
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/stack.js
1291
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/stack.js
1270
1292
  var make5 = (value, previous) => ({
1271
1293
  value,
1272
1294
  previous
1273
1295
  });
1274
1296
 
1275
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/array.js
1297
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/array.js
1276
1298
  function arrayUpdate(mutate2, at, v, arr) {
1277
1299
  let out = arr;
1278
1300
  if (!mutate2) {
@@ -1294,7 +1316,6 @@ function arraySpliceOut(mutate2, at, arr) {
1294
1316
  out = new Array(newLen);
1295
1317
  while (i < at) out[g++] = arr[i++];
1296
1318
  }
1297
- ;
1298
1319
  ++i;
1299
1320
  while (i <= newLen) out[g++] = arr[i++];
1300
1321
  if (mutate2) {
@@ -1318,7 +1339,7 @@ function arraySpliceIn(mutate2, at, v, arr) {
1318
1339
  return out;
1319
1340
  }
1320
1341
 
1321
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/node.js
1342
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/node.js
1322
1343
  var EmptyNode = class _EmptyNode {
1323
1344
  _tag = "EmptyNode";
1324
1345
  modify(edit, _shift, f, hash2, key, size4) {
@@ -1354,7 +1375,6 @@ var LeafNode = class _LeafNode {
1354
1375
  const v2 = f(this.value);
1355
1376
  if (v2 === this.value) return this;
1356
1377
  else if (isNone2(v2)) {
1357
- ;
1358
1378
  --size4.value;
1359
1379
  return new EmptyNode();
1360
1380
  }
@@ -1401,7 +1421,6 @@ var CollisionNode = class _CollisionNode {
1401
1421
  const newValue2 = f(value);
1402
1422
  if (newValue2 === value) return list;
1403
1423
  if (isNone2(newValue2)) {
1404
- ;
1405
1424
  --size4.value;
1406
1425
  return arraySpliceOut(mutate2, i, list);
1407
1426
  }
@@ -1480,11 +1499,9 @@ var ArrayNode = class _ArrayNode {
1480
1499
  const canEdit = canEditNode(this, edit);
1481
1500
  let newChildren;
1482
1501
  if (isEmptyNode(child) && !isEmptyNode(newChild)) {
1483
- ;
1484
1502
  ++count;
1485
1503
  newChildren = arrayUpdate(canEdit, frag, newChild, children);
1486
1504
  } else if (!isEmptyNode(child) && isEmptyNode(newChild)) {
1487
- ;
1488
1505
  --count;
1489
1506
  if (count <= MIN_ARRAY_NODE) {
1490
1507
  return pack(edit, count, frag, children);
@@ -1557,7 +1574,7 @@ function mergeLeaves(edit, shift, h1, n1, h2, n2) {
1557
1574
  }
1558
1575
  }
1559
1576
 
1560
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap.js
1577
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap.js
1561
1578
  var HashMapSymbolKey = "effect/HashMap";
1562
1579
  var HashMapTypeId = /* @__PURE__ */ Symbol.for(HashMapSymbolKey);
1563
1580
  var HashMapProto = {
@@ -1769,7 +1786,7 @@ var reduce2 = /* @__PURE__ */ dual(3, (self, zero, f) => {
1769
1786
  return zero;
1770
1787
  });
1771
1788
 
1772
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashSet.js
1789
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashSet.js
1773
1790
  var HashSetSymbolKey = "effect/HashSet";
1774
1791
  var HashSetTypeId = /* @__PURE__ */ Symbol.for(HashSetSymbolKey);
1775
1792
  var HashSetProto = {
@@ -1831,13 +1848,13 @@ var union2 = /* @__PURE__ */ dual(2, (self, that) => mutate(empty4(), (set2) =>
1831
1848
  }));
1832
1849
  var forEach2 = /* @__PURE__ */ dual(2, (self, f) => forEach(self._keyMap, (_, k) => f(k)));
1833
1850
 
1834
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/HashSet.js
1851
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/HashSet.js
1835
1852
  var empty5 = empty4;
1836
1853
  var size3 = size2;
1837
1854
  var add4 = add3;
1838
1855
  var union3 = union2;
1839
1856
 
1840
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/data.js
1857
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/data.js
1841
1858
  var ArrayProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Array.prototype), {
1842
1859
  [symbol]() {
1843
1860
  return cached(this, array(this));
@@ -1860,7 +1877,7 @@ var Structural = /* @__PURE__ */ function() {
1860
1877
  return Structural2;
1861
1878
  }();
1862
1879
 
1863
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/opCodes/cause.js
1880
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/cause.js
1864
1881
  var OP_DIE = "Die";
1865
1882
  var OP_EMPTY = "Empty";
1866
1883
  var OP_FAIL = "Fail";
@@ -1868,7 +1885,7 @@ var OP_INTERRUPT = "Interrupt";
1868
1885
  var OP_PARALLEL = "Parallel";
1869
1886
  var OP_SEQUENTIAL = "Sequential";
1870
1887
 
1871
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/cause.js
1888
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/cause.js
1872
1889
  var CauseSymbolKey = "effect/Cause";
1873
1890
  var CauseTypeId = /* @__PURE__ */ Symbol.for(CauseSymbolKey);
1874
1891
  var variance = {
@@ -2245,11 +2262,14 @@ var prettyErrorStack = (message, stack, span) => {
2245
2262
  const out = [message];
2246
2263
  const lines = stack.startsWith(message) ? stack.slice(message.length).split("\n") : stack.split("\n");
2247
2264
  for (let i = 1; i < lines.length; i++) {
2265
+ if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
2266
+ i++;
2267
+ continue;
2268
+ }
2248
2269
  if (lines[i].includes("Generator.next")) {
2249
2270
  break;
2250
2271
  }
2251
2272
  if (lines[i].includes("effect_internal_function")) {
2252
- out.pop();
2253
2273
  break;
2254
2274
  }
2255
2275
  out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>"));
@@ -2297,7 +2317,7 @@ var prettyErrors = (cause) => reduceWithContext(cause, void 0, {
2297
2317
  sequentialCase: (_, l, r) => [...l, ...r]
2298
2318
  });
2299
2319
 
2300
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/singleShotGen.js
2320
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/singleShotGen.js
2301
2321
  var SingleShotGen2 = class _SingleShotGen {
2302
2322
  self;
2303
2323
  called = false;
@@ -2327,7 +2347,7 @@ var SingleShotGen2 = class _SingleShotGen {
2327
2347
  }
2328
2348
  };
2329
2349
 
2330
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/core.js
2350
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/core.js
2331
2351
  var EffectTypeId2 = /* @__PURE__ */ Symbol.for("effect/Effect");
2332
2352
  var EffectPrimitive = class {
2333
2353
  _op;
@@ -2467,16 +2487,15 @@ var withFiberRuntime = (withRuntime) => {
2467
2487
  effect.effect_instruction_i0 = withRuntime;
2468
2488
  return effect;
2469
2489
  };
2470
- var spanSymbol2 = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
2471
2490
  var originalSymbol = /* @__PURE__ */ Symbol.for("effect/OriginalAnnotation");
2472
2491
  var capture = (obj, span) => {
2473
2492
  if (isSome2(span)) {
2474
2493
  return new Proxy(obj, {
2475
2494
  has(target, p) {
2476
- return p === spanSymbol2 || p === originalSymbol || p in target;
2495
+ return p === spanSymbol || p === originalSymbol || p in target;
2477
2496
  },
2478
2497
  get(target, p) {
2479
- if (p === spanSymbol2) {
2498
+ if (p === spanSymbol) {
2480
2499
  return span.value;
2481
2500
  }
2482
2501
  if (p === originalSymbol) {
@@ -2488,7 +2507,7 @@ var capture = (obj, span) => {
2488
2507
  }
2489
2508
  return obj;
2490
2509
  };
2491
- var fail2 = (error) => isObject(error) && !(spanSymbol2 in error) ? withFiberRuntime((fiber) => failCause(fail(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail(error));
2510
+ var fail2 = (error) => isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber) => failCause(fail(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail(error));
2492
2511
  var failCause = (cause) => {
2493
2512
  const effect = new EffectPrimitiveFailure(OP_FAILURE);
2494
2513
  effect.effect_instruction_i0 = cause;
@@ -2548,9 +2567,12 @@ var YieldableError = /* @__PURE__ */ function() {
2548
2567
  return fail2(this);
2549
2568
  }
2550
2569
  toJSON() {
2551
- return {
2570
+ const obj = {
2552
2571
  ...this
2553
2572
  };
2573
+ if (this.message) obj.message = this.message;
2574
+ if (this.cause) obj.cause = this.cause;
2575
+ return obj;
2554
2576
  }
2555
2577
  [NodeInspectSymbol]() {
2556
2578
  if (this.toString !== globalThis.Error.prototype.toString) {
@@ -2609,7 +2631,7 @@ var currentSpanFromFiber = (fiber) => {
2609
2631
  return span !== void 0 && span._tag === "Span" ? some2(span) : none2();
2610
2632
  };
2611
2633
 
2612
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Data.js
2634
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Data.js
2613
2635
  var Class2 = Structural;
2614
2636
  var TaggedClass = (tag) => {
2615
2637
  class Base2 extends Class2 {
@@ -2619,34 +2641,38 @@ var TaggedClass = (tag) => {
2619
2641
  };
2620
2642
  var Error2 = /* @__PURE__ */ function() {
2621
2643
  const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
2622
- return class Base extends YieldableError {
2623
- constructor(args2) {
2624
- super(args2?.message, args2?.cause ? {
2625
- cause: args2.cause
2626
- } : void 0);
2627
- if (args2) {
2628
- Object.assign(this, args2);
2629
- Object.defineProperty(this, plainArgsSymbol, {
2630
- value: args2,
2631
- enumerable: false
2632
- });
2644
+ const O = {
2645
+ BaseEffectError: class extends YieldableError {
2646
+ constructor(args2) {
2647
+ super(args2?.message, args2?.cause ? {
2648
+ cause: args2.cause
2649
+ } : void 0);
2650
+ if (args2) {
2651
+ Object.assign(this, args2);
2652
+ Object.defineProperty(this, plainArgsSymbol, {
2653
+ value: args2,
2654
+ enumerable: false
2655
+ });
2656
+ }
2657
+ }
2658
+ toJSON() {
2659
+ return {
2660
+ ...this[plainArgsSymbol],
2661
+ ...this
2662
+ };
2633
2663
  }
2634
- }
2635
- toJSON() {
2636
- return {
2637
- ...this[plainArgsSymbol],
2638
- ...this
2639
- };
2640
2664
  }
2641
2665
  };
2666
+ return O.BaseEffectError;
2642
2667
  }();
2643
2668
  var TaggedError = (tag) => {
2644
- class Base2 extends Error2 {
2645
- _tag = tag;
2646
- }
2647
- ;
2648
- Base2.prototype.name = tag;
2649
- return Base2;
2669
+ const O = {
2670
+ BaseEffectError: class extends Error2 {
2671
+ _tag = tag;
2672
+ }
2673
+ };
2674
+ O.BaseEffectError.prototype.name = tag;
2675
+ return O.BaseEffectError;
2650
2676
  };
2651
2677
 
2652
2678
  // src/internal/bot-response.ts
@@ -2677,10 +2703,10 @@ var createBotContext = (update) => {
2677
2703
  };
2678
2704
  };
2679
2705
 
2680
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Effectable.js
2706
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Effectable.js
2681
2707
  var EffectPrototype2 = EffectPrototype;
2682
2708
 
2683
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Micro.js
2709
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Micro.js
2684
2710
  var TypeId5 = /* @__PURE__ */ Symbol.for("effect/Micro");
2685
2711
  var MicroExitTypeId = /* @__PURE__ */ Symbol.for("effect/Micro/MicroExit");
2686
2712
  var isMicro = (u) => typeof u === "object" && u !== null && TypeId5 in u;
@@ -3961,6 +3987,91 @@ var defineBot = (input) => {
3961
3987
  console.warn("No handlers are defined for bot");
3962
3988
  return input;
3963
3989
  };
3990
+
3991
+ // src/webhook.ts
3992
+ var import_tg_bot_client3 = require("@effect-ak/tg-bot-client");
3993
+ var isGuardedHandler2 = (handler) => typeof handler === "object" && handler !== null && "handle" in handler;
3994
+ var executeSingleGuard2 = async (guard, update, ctx) => {
3995
+ const input = { update, ctx };
3996
+ if (guard.match) {
3997
+ const matched = await guard.match(input);
3998
+ if (!matched) return null;
3999
+ }
4000
+ return await guard.handle(input);
4001
+ };
4002
+ var executeGuards2 = async (guards, update, ctx) => {
4003
+ for (const guard of guards) {
4004
+ const result = await executeSingleGuard2(guard, update, ctx);
4005
+ if (result !== null) return result;
4006
+ }
4007
+ return BotResponse.ignore;
4008
+ };
4009
+ var executeHandler2 = async (handler, update, ctx) => {
4010
+ if (typeof handler === "function") {
4011
+ return await handler(update);
4012
+ }
4013
+ if (Array.isArray(handler)) {
4014
+ return await executeGuards2(handler, update, ctx);
4015
+ }
4016
+ if (isGuardedHandler2(handler)) {
4017
+ const result = await executeSingleGuard2(handler, update, ctx);
4018
+ return result ?? BotResponse.ignore;
4019
+ }
4020
+ return BotResponse.ignore;
4021
+ };
4022
+ var extractUpdate2 = (input) => {
4023
+ for (const [field, value] of Object.entries(input)) {
4024
+ if (field === "update_id") continue;
4025
+ return { type: field, ...value };
4026
+ }
4027
+ return void 0;
4028
+ };
4029
+ var processUpdate = async (updateObject, handlers, client) => {
4030
+ const update = extractUpdate2(updateObject);
4031
+ if (!update) {
4032
+ console.warn("Unknown update format", updateObject);
4033
+ return;
4034
+ }
4035
+ const handlerKey = `on_${update.type}`;
4036
+ const handler = handlers[handlerKey];
4037
+ if (!handler) {
4038
+ return;
4039
+ }
4040
+ const ctx = createBotContext(update);
4041
+ try {
4042
+ const result = await executeHandler2(handler, update, ctx);
4043
+ if (result.response && "chat" in update) {
4044
+ const responsePayload = result.response;
4045
+ await client.execute(`send_${responsePayload.type}`, {
4046
+ ...responsePayload,
4047
+ chat_id: update.chat.id
4048
+ });
4049
+ }
4050
+ } catch (error) {
4051
+ console.error("Error handling update", {
4052
+ updateId: updateObject.update_id,
4053
+ error: error instanceof Error ? error.message : error
4054
+ });
4055
+ }
4056
+ };
4057
+ var createWebhookHandler = (config) => {
4058
+ const client = (0, import_tg_bot_client3.makeTgBotClient)({ bot_token: config.bot_token });
4059
+ const handleUpdate = async (update) => {
4060
+ await processUpdate(update, config, client);
4061
+ };
4062
+ const handler = async (request) => {
4063
+ try {
4064
+ const update = await request.json();
4065
+ await handleUpdate(update);
4066
+ return new Response("ok", { status: 200 });
4067
+ } catch (error) {
4068
+ console.error("Webhook error", error);
4069
+ return new Response("error", { status: 500 });
4070
+ }
4071
+ };
4072
+ handler.handleUpdate = handleUpdate;
4073
+ return handler;
4074
+ };
3964
4075
  // Annotate the CommonJS export names for ESM import in node:
3965
4076
  0 && (module.exports = {
3966
4077
  BatchUpdateResult,
@@ -3972,6 +4083,7 @@ var defineBot = (input) => {
3972
4083
  BotUpdateHandlersTag,
3973
4084
  HandleUpdateError,
3974
4085
  createBotContext,
4086
+ createWebhookHandler,
3975
4087
  defineBot,
3976
4088
  extractUpdate,
3977
4089
  handleEntireBatch,
package/dist/index.d.ts CHANGED
@@ -137,4 +137,13 @@ declare const runTgChatBot: (input: RunBotInput) => Promise<{
137
137
  }>;
138
138
  declare const defineBot: (input: BotUpdatesHandlers) => BotUpdatesHandlers;
139
139
 
140
- export { type AvailableUpdateTypes, BatchUpdateResult, type BotBatchMode, type BotContext, type BotInstance, type BotMode, BotPollSettings, BotPollSettingsTag, BotResponse, BotRunService, type BotSingleMode, BotTgClientTag, BotUpdateHandlersTag, type BotUpdatesHandlers, type ExtractedUpdate, type GuardedHandler, type HandleBatchUpdateFunction, HandleUpdateError, type HandleUpdateFunction, type HandlerInput, type PollSettings, type RunBotInput, type RunBotInputBatch, type RunBotInputSingle, type UpdateHandler, createBotContext, defineBot, extractUpdate, handleEntireBatch, handleOneByOne, handleOneUpdate, handleUpdates, launchBot, runTgChatBot };
140
+ interface WebhookBotConfig extends BotUpdatesHandlers {
141
+ bot_token: string;
142
+ }
143
+ interface WebhookHandler {
144
+ (request: Request): Promise<Response>;
145
+ handleUpdate: (update: Update) => Promise<void>;
146
+ }
147
+ declare const createWebhookHandler: (config: WebhookBotConfig) => WebhookHandler;
148
+
149
+ export { type AvailableUpdateTypes, BatchUpdateResult, type BotBatchMode, type BotContext, type BotInstance, type BotMode, BotPollSettings, BotPollSettingsTag, BotResponse, BotRunService, type BotSingleMode, BotTgClientTag, BotUpdateHandlersTag, type BotUpdatesHandlers, type ExtractedUpdate, type GuardedHandler, type HandleBatchUpdateFunction, HandleUpdateError, type HandleUpdateFunction, type HandlerInput, type PollSettings, type RunBotInput, type RunBotInputBatch, type RunBotInputSingle, type UpdateHandler, type WebhookBotConfig, type WebhookHandler, createBotContext, createWebhookHandler, defineBot, extractUpdate, handleEntireBatch, handleOneByOne, handleOneUpdate, handleUpdates, launchBot, runTgChatBot };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Function.js
1
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Function.js
2
2
  var isFunction = (input) => typeof input === "function";
3
3
  var dual = function(arity, body) {
4
4
  if (typeof arity === "function") {
@@ -97,38 +97,34 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
97
97
  }
98
98
  }
99
99
 
100
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Equivalence.js
100
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equivalence.js
101
101
  var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
102
102
 
103
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/version.js
104
- var moduleVersion = "3.12.0";
105
- var getCurrentVersion = () => moduleVersion;
106
-
107
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/GlobalValue.js
108
- var globalStoreId = /* @__PURE__ */ Symbol.for(`effect/GlobalValue/globalStoreId/${/* @__PURE__ */ getCurrentVersion()}`);
109
- if (!(globalStoreId in globalThis)) {
110
- ;
111
- globalThis[globalStoreId] = /* @__PURE__ */ new Map();
112
- }
113
- var globalStore = globalThis[globalStoreId];
103
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/GlobalValue.js
104
+ var globalStoreId = `effect/GlobalValue`;
105
+ var globalStore;
114
106
  var globalValue = (id, compute) => {
107
+ if (!globalStore) {
108
+ globalThis[globalStoreId] ??= /* @__PURE__ */ new Map();
109
+ globalStore = globalThis[globalStoreId];
110
+ }
115
111
  if (!globalStore.has(id)) {
116
112
  globalStore.set(id, compute());
117
113
  }
118
114
  return globalStore.get(id);
119
115
  };
120
116
 
121
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Predicate.js
117
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Predicate.js
122
118
  var isFunction2 = isFunction;
123
119
  var isRecordOrArray = (input) => typeof input === "object" && input !== null;
124
120
  var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
125
121
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
126
122
  var isTagged = /* @__PURE__ */ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
127
123
 
128
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/errors.js
124
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/errors.js
129
125
  var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
130
126
 
131
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Utils.js
127
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Utils.js
132
128
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
133
129
  var GenKindImpl = class {
134
130
  value;
@@ -238,10 +234,25 @@ var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructur
238
234
  enabled: false,
239
235
  tester: void 0
240
236
  }));
237
+ var standard = {
238
+ effect_internal_function: (body) => {
239
+ return body();
240
+ }
241
+ };
242
+ var forced = {
243
+ effect_internal_function: (body) => {
244
+ try {
245
+ return body();
246
+ } finally {
247
+ }
248
+ }
249
+ };
250
+ var isNotOptimizedAway = /* @__PURE__ */ standard.effect_internal_function(() => new Error().stack)?.includes("effect_internal_function") === true;
251
+ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forced.effect_internal_function;
241
252
  var genConstructor = function* () {
242
253
  }.constructor;
243
254
 
244
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Hash.js
255
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Hash.js
245
256
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
246
257
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
247
258
  var hash = (self) => {
@@ -266,7 +277,12 @@ var hash = (self) => {
266
277
  if (self === null) {
267
278
  return string("null");
268
279
  } else if (self instanceof Date) {
280
+ if (Number.isNaN(self.getTime())) {
281
+ return string("Invalid Date");
282
+ }
269
283
  return hash(self.toISOString());
284
+ } else if (self instanceof URL) {
285
+ return hash(self.href);
270
286
  } else if (isHash(self)) {
271
287
  return self[symbol]();
272
288
  } else {
@@ -345,7 +361,7 @@ var cached = function() {
345
361
  return hash2;
346
362
  };
347
363
 
348
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Equal.js
364
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equal.js
349
365
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
350
366
  function equals() {
351
367
  if (arguments.length === 1) {
@@ -370,7 +386,11 @@ function compareBoth(self, that) {
370
386
  return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
371
387
  }
372
388
  } else if (self instanceof Date && that instanceof Date) {
373
- return self.toISOString() === that.toISOString();
389
+ const t1 = self.getTime();
390
+ const t2 = that.getTime();
391
+ return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
392
+ } else if (self instanceof URL && that instanceof URL) {
393
+ return self.href === that.href;
374
394
  }
375
395
  }
376
396
  if (structuralRegionState.enabled) {
@@ -396,7 +416,7 @@ function compareBoth(self, that) {
396
416
  }
397
417
  var isEqual = (u) => hasProperty(u, symbol2);
398
418
 
399
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Inspectable.js
419
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Inspectable.js
400
420
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
401
421
  var toJSON = (x) => {
402
422
  try {
@@ -405,7 +425,7 @@ var toJSON = (x) => {
405
425
  } else if (Array.isArray(x)) {
406
426
  return x.map(toJSON);
407
427
  }
408
- } catch (_) {
428
+ } catch {
409
429
  return {};
410
430
  }
411
431
  return redact(x);
@@ -442,7 +462,7 @@ var toStringUnknown = (u, whitespace = 2) => {
442
462
  }
443
463
  try {
444
464
  return typeof u === "object" ? stringifyCircular(u, whitespace) : String(u);
445
- } catch (_) {
465
+ } catch {
446
466
  return String(u);
447
467
  }
448
468
  };
@@ -464,7 +484,7 @@ var redact = (u) => {
464
484
  return u;
465
485
  };
466
486
 
467
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Pipeable.js
487
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Pipeable.js
468
488
  var pipeArguments = (self, args2) => {
469
489
  switch (args2.length) {
470
490
  case 0:
@@ -497,12 +517,16 @@ var pipeArguments = (self, args2) => {
497
517
  }
498
518
  };
499
519
 
500
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/opCodes/effect.js
520
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/effect.js
501
521
  var OP_COMMIT = "Commit";
502
522
  var OP_FAILURE = "Failure";
503
523
  var OP_WITH_RUNTIME = "WithRuntime";
504
524
 
505
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/effectable.js
525
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/version.js
526
+ var moduleVersion = "3.19.13";
527
+ var getCurrentVersion = () => moduleVersion;
528
+
529
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/effectable.js
506
530
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
507
531
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
508
532
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -589,7 +613,7 @@ var StructuralCommitPrototype = {
589
613
  ...StructuralPrototype
590
614
  };
591
615
 
592
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/option.js
616
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/option.js
593
617
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
594
618
  var CommonProto = {
595
619
  ...EffectPrototype,
@@ -647,7 +671,7 @@ var some = (value) => {
647
671
  return a;
648
672
  };
649
673
 
650
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/either.js
674
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/either.js
651
675
  var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
652
676
  var CommonProto2 = {
653
677
  ...EffectPrototype,
@@ -709,11 +733,11 @@ var right = (right3) => {
709
733
  return a;
710
734
  };
711
735
 
712
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Either.js
736
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Either.js
713
737
  var right2 = right;
714
738
  var left2 = left;
715
739
 
716
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Option.js
740
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Option.js
717
741
  var none2 = () => none;
718
742
  var some2 = some;
719
743
  var isNone2 = isNone;
@@ -721,13 +745,13 @@ var isSome2 = isSome;
721
745
  var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
722
746
  var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
723
747
 
724
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Array.js
748
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Array.js
725
749
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
726
750
  var isArray = Array.isArray;
727
751
  var reverse = (self) => Array.from(self).reverse();
728
752
  var reduce = /* @__PURE__ */ dual(3, (self, b, f) => fromIterable(self).reduce((b2, a, i) => f(b2, a, i), b));
729
753
 
730
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Chunk.js
754
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Chunk.js
731
755
  var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Chunk");
732
756
  function copy(src, srcPos, dest, destPos, len) {
733
757
  for (let i = srcPos; i < Math.min(src.length, srcPos + len); i++) {
@@ -824,15 +848,12 @@ var _empty = /* @__PURE__ */ makeChunk({
824
848
  _tag: "IEmpty"
825
849
  });
826
850
  var empty = () => _empty;
827
- var make2 = (...as2) => as2.length === 1 ? of(as2[0]) : unsafeFromNonEmptyArray(as2);
851
+ var make2 = (...as2) => unsafeFromNonEmptyArray(as2);
828
852
  var of = (a) => makeChunk({
829
853
  _tag: "ISingleton",
830
854
  a
831
855
  });
832
- var fromIterable2 = (self) => isChunk(self) ? self : makeChunk({
833
- _tag: "IArray",
834
- array: fromIterable(self)
835
- });
856
+ var fromIterable2 = (self) => isChunk(self) ? self : unsafeFromArray(fromIterable(self));
836
857
  var copyToArray = (self, array2, initial) => {
837
858
  switch (self.backing._tag) {
838
859
  case "IArray": {
@@ -906,7 +927,7 @@ var reverseChunk = (self) => {
906
927
  }
907
928
  };
908
929
  var reverse2 = reverseChunk;
909
- var unsafeFromArray = (self) => makeChunk({
930
+ var unsafeFromArray = (self) => self.length === 0 ? empty() : self.length === 1 ? of(self[0]) : makeChunk({
910
931
  _tag: "IArray",
911
932
  array: self
912
933
  });
@@ -1026,7 +1047,7 @@ var isNonEmpty = (self) => self.length > 0;
1026
1047
  var unsafeHead = (self) => unsafeGet(self, 0);
1027
1048
  var headNonEmpty = unsafeHead;
1028
1049
 
1029
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/context.js
1050
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/context.js
1030
1051
  var TagTypeId = /* @__PURE__ */ Symbol.for("effect/Context/Tag");
1031
1052
  var ReferenceTypeId = /* @__PURE__ */ Symbol.for("effect/Context/Reference");
1032
1053
  var STMSymbolKey = "effect/STM";
@@ -1190,7 +1211,7 @@ var merge = /* @__PURE__ */ dual(2, (self, that) => {
1190
1211
  return makeContext(map7);
1191
1212
  });
1192
1213
 
1193
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Context.js
1214
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Context.js
1194
1215
  var make4 = make3;
1195
1216
  var add2 = add;
1196
1217
  var unsafeGet3 = unsafeGet2;
@@ -1198,14 +1219,14 @@ var merge2 = merge;
1198
1219
  var Tag2 = Tag;
1199
1220
  var Reference2 = Reference;
1200
1221
 
1201
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/config.js
1222
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/config.js
1202
1223
  var SIZE = 5;
1203
1224
  var BUCKET_SIZE = /* @__PURE__ */ Math.pow(2, SIZE);
1204
1225
  var MASK = BUCKET_SIZE - 1;
1205
1226
  var MAX_INDEX_NODE = BUCKET_SIZE / 2;
1206
1227
  var MIN_ARRAY_NODE = BUCKET_SIZE / 4;
1207
1228
 
1208
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
1229
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
1209
1230
  function popcount(x) {
1210
1231
  x -= x >> 1 & 1431655765;
1211
1232
  x = (x & 858993459) + (x >> 2 & 858993459);
@@ -1224,13 +1245,13 @@ function fromBitmap(bitmap, bit) {
1224
1245
  return popcount(bitmap & bit - 1);
1225
1246
  }
1226
1247
 
1227
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/stack.js
1248
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/stack.js
1228
1249
  var make5 = (value, previous) => ({
1229
1250
  value,
1230
1251
  previous
1231
1252
  });
1232
1253
 
1233
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/array.js
1254
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/array.js
1234
1255
  function arrayUpdate(mutate2, at, v, arr) {
1235
1256
  let out = arr;
1236
1257
  if (!mutate2) {
@@ -1252,7 +1273,6 @@ function arraySpliceOut(mutate2, at, arr) {
1252
1273
  out = new Array(newLen);
1253
1274
  while (i < at) out[g++] = arr[i++];
1254
1275
  }
1255
- ;
1256
1276
  ++i;
1257
1277
  while (i <= newLen) out[g++] = arr[i++];
1258
1278
  if (mutate2) {
@@ -1276,7 +1296,7 @@ function arraySpliceIn(mutate2, at, v, arr) {
1276
1296
  return out;
1277
1297
  }
1278
1298
 
1279
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap/node.js
1299
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/node.js
1280
1300
  var EmptyNode = class _EmptyNode {
1281
1301
  _tag = "EmptyNode";
1282
1302
  modify(edit, _shift, f, hash2, key, size4) {
@@ -1312,7 +1332,6 @@ var LeafNode = class _LeafNode {
1312
1332
  const v2 = f(this.value);
1313
1333
  if (v2 === this.value) return this;
1314
1334
  else if (isNone2(v2)) {
1315
- ;
1316
1335
  --size4.value;
1317
1336
  return new EmptyNode();
1318
1337
  }
@@ -1359,7 +1378,6 @@ var CollisionNode = class _CollisionNode {
1359
1378
  const newValue2 = f(value);
1360
1379
  if (newValue2 === value) return list;
1361
1380
  if (isNone2(newValue2)) {
1362
- ;
1363
1381
  --size4.value;
1364
1382
  return arraySpliceOut(mutate2, i, list);
1365
1383
  }
@@ -1438,11 +1456,9 @@ var ArrayNode = class _ArrayNode {
1438
1456
  const canEdit = canEditNode(this, edit);
1439
1457
  let newChildren;
1440
1458
  if (isEmptyNode(child) && !isEmptyNode(newChild)) {
1441
- ;
1442
1459
  ++count;
1443
1460
  newChildren = arrayUpdate(canEdit, frag, newChild, children);
1444
1461
  } else if (!isEmptyNode(child) && isEmptyNode(newChild)) {
1445
- ;
1446
1462
  --count;
1447
1463
  if (count <= MIN_ARRAY_NODE) {
1448
1464
  return pack(edit, count, frag, children);
@@ -1515,7 +1531,7 @@ function mergeLeaves(edit, shift, h1, n1, h2, n2) {
1515
1531
  }
1516
1532
  }
1517
1533
 
1518
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashMap.js
1534
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap.js
1519
1535
  var HashMapSymbolKey = "effect/HashMap";
1520
1536
  var HashMapTypeId = /* @__PURE__ */ Symbol.for(HashMapSymbolKey);
1521
1537
  var HashMapProto = {
@@ -1727,7 +1743,7 @@ var reduce2 = /* @__PURE__ */ dual(3, (self, zero, f) => {
1727
1743
  return zero;
1728
1744
  });
1729
1745
 
1730
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/hashSet.js
1746
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashSet.js
1731
1747
  var HashSetSymbolKey = "effect/HashSet";
1732
1748
  var HashSetTypeId = /* @__PURE__ */ Symbol.for(HashSetSymbolKey);
1733
1749
  var HashSetProto = {
@@ -1789,13 +1805,13 @@ var union2 = /* @__PURE__ */ dual(2, (self, that) => mutate(empty4(), (set2) =>
1789
1805
  }));
1790
1806
  var forEach2 = /* @__PURE__ */ dual(2, (self, f) => forEach(self._keyMap, (_, k) => f(k)));
1791
1807
 
1792
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/HashSet.js
1808
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/HashSet.js
1793
1809
  var empty5 = empty4;
1794
1810
  var size3 = size2;
1795
1811
  var add4 = add3;
1796
1812
  var union3 = union2;
1797
1813
 
1798
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/data.js
1814
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/data.js
1799
1815
  var ArrayProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Array.prototype), {
1800
1816
  [symbol]() {
1801
1817
  return cached(this, array(this));
@@ -1818,7 +1834,7 @@ var Structural = /* @__PURE__ */ function() {
1818
1834
  return Structural2;
1819
1835
  }();
1820
1836
 
1821
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/opCodes/cause.js
1837
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/cause.js
1822
1838
  var OP_DIE = "Die";
1823
1839
  var OP_EMPTY = "Empty";
1824
1840
  var OP_FAIL = "Fail";
@@ -1826,7 +1842,7 @@ var OP_INTERRUPT = "Interrupt";
1826
1842
  var OP_PARALLEL = "Parallel";
1827
1843
  var OP_SEQUENTIAL = "Sequential";
1828
1844
 
1829
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/cause.js
1845
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/cause.js
1830
1846
  var CauseSymbolKey = "effect/Cause";
1831
1847
  var CauseTypeId = /* @__PURE__ */ Symbol.for(CauseSymbolKey);
1832
1848
  var variance = {
@@ -2203,11 +2219,14 @@ var prettyErrorStack = (message, stack, span) => {
2203
2219
  const out = [message];
2204
2220
  const lines = stack.startsWith(message) ? stack.slice(message.length).split("\n") : stack.split("\n");
2205
2221
  for (let i = 1; i < lines.length; i++) {
2222
+ if (lines[i].includes(" at new BaseEffectError") || lines[i].includes(" at new YieldableError")) {
2223
+ i++;
2224
+ continue;
2225
+ }
2206
2226
  if (lines[i].includes("Generator.next")) {
2207
2227
  break;
2208
2228
  }
2209
2229
  if (lines[i].includes("effect_internal_function")) {
2210
- out.pop();
2211
2230
  break;
2212
2231
  }
2213
2232
  out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>"));
@@ -2255,7 +2274,7 @@ var prettyErrors = (cause) => reduceWithContext(cause, void 0, {
2255
2274
  sequentialCase: (_, l, r) => [...l, ...r]
2256
2275
  });
2257
2276
 
2258
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/singleShotGen.js
2277
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/singleShotGen.js
2259
2278
  var SingleShotGen2 = class _SingleShotGen {
2260
2279
  self;
2261
2280
  called = false;
@@ -2285,7 +2304,7 @@ var SingleShotGen2 = class _SingleShotGen {
2285
2304
  }
2286
2305
  };
2287
2306
 
2288
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/internal/core.js
2307
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/core.js
2289
2308
  var EffectTypeId2 = /* @__PURE__ */ Symbol.for("effect/Effect");
2290
2309
  var EffectPrimitive = class {
2291
2310
  _op;
@@ -2425,16 +2444,15 @@ var withFiberRuntime = (withRuntime) => {
2425
2444
  effect.effect_instruction_i0 = withRuntime;
2426
2445
  return effect;
2427
2446
  };
2428
- var spanSymbol2 = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
2429
2447
  var originalSymbol = /* @__PURE__ */ Symbol.for("effect/OriginalAnnotation");
2430
2448
  var capture = (obj, span) => {
2431
2449
  if (isSome2(span)) {
2432
2450
  return new Proxy(obj, {
2433
2451
  has(target, p) {
2434
- return p === spanSymbol2 || p === originalSymbol || p in target;
2452
+ return p === spanSymbol || p === originalSymbol || p in target;
2435
2453
  },
2436
2454
  get(target, p) {
2437
- if (p === spanSymbol2) {
2455
+ if (p === spanSymbol) {
2438
2456
  return span.value;
2439
2457
  }
2440
2458
  if (p === originalSymbol) {
@@ -2446,7 +2464,7 @@ var capture = (obj, span) => {
2446
2464
  }
2447
2465
  return obj;
2448
2466
  };
2449
- var fail2 = (error) => isObject(error) && !(spanSymbol2 in error) ? withFiberRuntime((fiber) => failCause(fail(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail(error));
2467
+ var fail2 = (error) => isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber) => failCause(fail(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail(error));
2450
2468
  var failCause = (cause) => {
2451
2469
  const effect = new EffectPrimitiveFailure(OP_FAILURE);
2452
2470
  effect.effect_instruction_i0 = cause;
@@ -2506,9 +2524,12 @@ var YieldableError = /* @__PURE__ */ function() {
2506
2524
  return fail2(this);
2507
2525
  }
2508
2526
  toJSON() {
2509
- return {
2527
+ const obj = {
2510
2528
  ...this
2511
2529
  };
2530
+ if (this.message) obj.message = this.message;
2531
+ if (this.cause) obj.cause = this.cause;
2532
+ return obj;
2512
2533
  }
2513
2534
  [NodeInspectSymbol]() {
2514
2535
  if (this.toString !== globalThis.Error.prototype.toString) {
@@ -2567,7 +2588,7 @@ var currentSpanFromFiber = (fiber) => {
2567
2588
  return span !== void 0 && span._tag === "Span" ? some2(span) : none2();
2568
2589
  };
2569
2590
 
2570
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Data.js
2591
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Data.js
2571
2592
  var Class2 = Structural;
2572
2593
  var TaggedClass = (tag) => {
2573
2594
  class Base2 extends Class2 {
@@ -2577,34 +2598,38 @@ var TaggedClass = (tag) => {
2577
2598
  };
2578
2599
  var Error2 = /* @__PURE__ */ function() {
2579
2600
  const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
2580
- return class Base extends YieldableError {
2581
- constructor(args2) {
2582
- super(args2?.message, args2?.cause ? {
2583
- cause: args2.cause
2584
- } : void 0);
2585
- if (args2) {
2586
- Object.assign(this, args2);
2587
- Object.defineProperty(this, plainArgsSymbol, {
2588
- value: args2,
2589
- enumerable: false
2590
- });
2601
+ const O = {
2602
+ BaseEffectError: class extends YieldableError {
2603
+ constructor(args2) {
2604
+ super(args2?.message, args2?.cause ? {
2605
+ cause: args2.cause
2606
+ } : void 0);
2607
+ if (args2) {
2608
+ Object.assign(this, args2);
2609
+ Object.defineProperty(this, plainArgsSymbol, {
2610
+ value: args2,
2611
+ enumerable: false
2612
+ });
2613
+ }
2614
+ }
2615
+ toJSON() {
2616
+ return {
2617
+ ...this[plainArgsSymbol],
2618
+ ...this
2619
+ };
2591
2620
  }
2592
- }
2593
- toJSON() {
2594
- return {
2595
- ...this[plainArgsSymbol],
2596
- ...this
2597
- };
2598
2621
  }
2599
2622
  };
2623
+ return O.BaseEffectError;
2600
2624
  }();
2601
2625
  var TaggedError = (tag) => {
2602
- class Base2 extends Error2 {
2603
- _tag = tag;
2604
- }
2605
- ;
2606
- Base2.prototype.name = tag;
2607
- return Base2;
2626
+ const O = {
2627
+ BaseEffectError: class extends Error2 {
2628
+ _tag = tag;
2629
+ }
2630
+ };
2631
+ O.BaseEffectError.prototype.name = tag;
2632
+ return O.BaseEffectError;
2608
2633
  };
2609
2634
 
2610
2635
  // src/internal/bot-response.ts
@@ -2635,10 +2660,10 @@ var createBotContext = (update) => {
2635
2660
  };
2636
2661
  };
2637
2662
 
2638
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Effectable.js
2663
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Effectable.js
2639
2664
  var EffectPrototype2 = EffectPrototype;
2640
2665
 
2641
- // ../../node_modules/.pnpm/effect@3.12.0/node_modules/effect/dist/esm/Micro.js
2666
+ // ../../node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Micro.js
2642
2667
  var TypeId5 = /* @__PURE__ */ Symbol.for("effect/Micro");
2643
2668
  var MicroExitTypeId = /* @__PURE__ */ Symbol.for("effect/Micro/MicroExit");
2644
2669
  var isMicro = (u) => typeof u === "object" && u !== null && TypeId5 in u;
@@ -3919,6 +3944,91 @@ var defineBot = (input) => {
3919
3944
  console.warn("No handlers are defined for bot");
3920
3945
  return input;
3921
3946
  };
3947
+
3948
+ // src/webhook.ts
3949
+ import { makeTgBotClient as makeTgBotClient2 } from "@effect-ak/tg-bot-client";
3950
+ var isGuardedHandler2 = (handler) => typeof handler === "object" && handler !== null && "handle" in handler;
3951
+ var executeSingleGuard2 = async (guard, update, ctx) => {
3952
+ const input = { update, ctx };
3953
+ if (guard.match) {
3954
+ const matched = await guard.match(input);
3955
+ if (!matched) return null;
3956
+ }
3957
+ return await guard.handle(input);
3958
+ };
3959
+ var executeGuards2 = async (guards, update, ctx) => {
3960
+ for (const guard of guards) {
3961
+ const result = await executeSingleGuard2(guard, update, ctx);
3962
+ if (result !== null) return result;
3963
+ }
3964
+ return BotResponse.ignore;
3965
+ };
3966
+ var executeHandler2 = async (handler, update, ctx) => {
3967
+ if (typeof handler === "function") {
3968
+ return await handler(update);
3969
+ }
3970
+ if (Array.isArray(handler)) {
3971
+ return await executeGuards2(handler, update, ctx);
3972
+ }
3973
+ if (isGuardedHandler2(handler)) {
3974
+ const result = await executeSingleGuard2(handler, update, ctx);
3975
+ return result ?? BotResponse.ignore;
3976
+ }
3977
+ return BotResponse.ignore;
3978
+ };
3979
+ var extractUpdate2 = (input) => {
3980
+ for (const [field, value] of Object.entries(input)) {
3981
+ if (field === "update_id") continue;
3982
+ return { type: field, ...value };
3983
+ }
3984
+ return void 0;
3985
+ };
3986
+ var processUpdate = async (updateObject, handlers, client) => {
3987
+ const update = extractUpdate2(updateObject);
3988
+ if (!update) {
3989
+ console.warn("Unknown update format", updateObject);
3990
+ return;
3991
+ }
3992
+ const handlerKey = `on_${update.type}`;
3993
+ const handler = handlers[handlerKey];
3994
+ if (!handler) {
3995
+ return;
3996
+ }
3997
+ const ctx = createBotContext(update);
3998
+ try {
3999
+ const result = await executeHandler2(handler, update, ctx);
4000
+ if (result.response && "chat" in update) {
4001
+ const responsePayload = result.response;
4002
+ await client.execute(`send_${responsePayload.type}`, {
4003
+ ...responsePayload,
4004
+ chat_id: update.chat.id
4005
+ });
4006
+ }
4007
+ } catch (error) {
4008
+ console.error("Error handling update", {
4009
+ updateId: updateObject.update_id,
4010
+ error: error instanceof Error ? error.message : error
4011
+ });
4012
+ }
4013
+ };
4014
+ var createWebhookHandler = (config) => {
4015
+ const client = makeTgBotClient2({ bot_token: config.bot_token });
4016
+ const handleUpdate = async (update) => {
4017
+ await processUpdate(update, config, client);
4018
+ };
4019
+ const handler = async (request) => {
4020
+ try {
4021
+ const update = await request.json();
4022
+ await handleUpdate(update);
4023
+ return new Response("ok", { status: 200 });
4024
+ } catch (error) {
4025
+ console.error("Webhook error", error);
4026
+ return new Response("error", { status: 500 });
4027
+ }
4028
+ };
4029
+ handler.handleUpdate = handleUpdate;
4030
+ return handler;
4031
+ };
3922
4032
  export {
3923
4033
  BatchUpdateResult,
3924
4034
  BotPollSettings,
@@ -3929,6 +4039,7 @@ export {
3929
4039
  BotUpdateHandlersTag,
3930
4040
  HandleUpdateError,
3931
4041
  createBotContext,
4042
+ createWebhookHandler,
3932
4043
  defineBot,
3933
4044
  extractUpdate,
3934
4045
  handleEntireBatch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-ak/tg-bot",
3
- "version": "1.2.0",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "description": "Telegram Bot runner",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/effect-ak/tg-bot-client",
13
+ "url": "https://github.com/kondaurovDev/tg-bot-client",
14
14
  "directory": "packages/bot"
15
15
  },
16
16
  "bugs": {
@@ -34,8 +34,8 @@
34
34
  "dist/*.d.ts"
35
35
  ],
36
36
  "dependencies": {
37
- "@effect-ak/tg-bot-client": "^1.1.0",
38
- "@effect-ak/tg-bot-api": "0.9.2"
37
+ "@effect-ak/tg-bot-client": "^1.3.4",
38
+ "@effect-ak/tg-bot-api": "^1.3.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "effect": "^3.12.7"