odant-work 1.0.112 → 1.0.114
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/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +686 -114
- package/$server/$folder/$class/$structure/handlers/pages/form/system/skills/$handler/class.js +11 -3
- package/$server/$folder/lib/chat-item/chat-item.js +1578 -910
- package/oda/components/layouts/app-layout/app-layout.js +1 -1
- package/package.json +1 -1
- package/sources/client.js +7 -1
- package/sources/modules/agent/resources.js +2 -2
- package/sources/server/access/gateway.js +1 -1
- package/sources/server/chat-threads.js +96 -2
- package/sources/server/class/feed.js +10 -0
- package/sources/server/folder.js +2 -0
|
@@ -1,910 +1,1578 @@
|
|
|
1
|
-
const CHAT_PREVIEW_EXTS = new Set([
|
|
2
|
-
'task', 'call',
|
|
3
|
-
'png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'bmp', 'avif', 'ico',
|
|
4
|
-
'mp4', 'webm', 'ogv', 'mov', 'm4v',
|
|
5
|
-
'mp3', 'wav', 'ogg', 'm4a', 'flac', 'aac', 'opus',
|
|
6
|
-
]);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
:host([
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
overflow: hidden;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
this.
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if (
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
this.
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
this.
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
this.
|
|
879
|
-
this.
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
1
|
+
const CHAT_PREVIEW_EXTS = new Set([
|
|
2
|
+
'task', 'call',
|
|
3
|
+
'png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'bmp', 'avif', 'ico',
|
|
4
|
+
'mp4', 'webm', 'ogv', 'mov', 'm4v',
|
|
5
|
+
'mp3', 'wav', 'ogg', 'm4a', 'flac', 'aac', 'opus',
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'bmp', 'avif', 'ico']);
|
|
9
|
+
const VIDEO_EXTS = new Set(['mp4', 'webm', 'ogv', 'mov', 'm4v']);
|
|
10
|
+
const AUDIO_EXTS = new Set(['mp3', 'wav', 'ogg', 'm4a', 'flac', 'aac', 'opus']);
|
|
11
|
+
|
|
12
|
+
const AUTHOR_COLORS = [
|
|
13
|
+
'#2563eb', '#7c3aed', '#059669', '#d97706', '#dc2626', '#0891b2', '#db2777', '#4f46e5',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
function authorColorFor(id) {
|
|
17
|
+
const s = String(id || '');
|
|
18
|
+
let h = 0;
|
|
19
|
+
for (let i = 0; i < s.length; i++)
|
|
20
|
+
h = ((h << 5) - h + s.charCodeAt(i)) | 0;
|
|
21
|
+
return AUTHOR_COLORS[Math.abs(h) % AUTHOR_COLORS.length];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function extOfPath(p) {
|
|
25
|
+
const base = String(p || '').split('/').pop() || '';
|
|
26
|
+
const idx = base.lastIndexOf('.');
|
|
27
|
+
return idx > -1 ? base.slice(idx + 1).toLowerCase() : '';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function fileUrlOf(p) {
|
|
31
|
+
if (!p) return '';
|
|
32
|
+
const norm = String(p).startsWith('/') ? String(p) : '/' + String(p);
|
|
33
|
+
try {
|
|
34
|
+
return encodeURI((globalThis.location?.origin || '') + norm);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return norm;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
imports: 'oda//button, oda//icon, ~/lib//node-explorer.js',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ODA({is: 'chat-item',
|
|
46
|
+
imports: 'oda//button, oda//icon, ~/lib//node-explorer.js',
|
|
47
|
+
template: /* html */`
|
|
48
|
+
<style>
|
|
49
|
+
:host {
|
|
50
|
+
@apply --horizontal;
|
|
51
|
+
max-height: var(--chat-card-max, none);
|
|
52
|
+
min-height: 0;
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
overflow: visible;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
transition: opacity .16s ease;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
}
|
|
60
|
+
:host([visible]){
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
:host([expanded]){
|
|
64
|
+
position: fixed;
|
|
65
|
+
z-index: 30;
|
|
66
|
+
border-radius: 0px;
|
|
67
|
+
top: 0px;
|
|
68
|
+
left: 0px;
|
|
69
|
+
right: 0px;
|
|
70
|
+
bottom: 0px;
|
|
71
|
+
max-height: none;
|
|
72
|
+
overflow: auto;
|
|
73
|
+
background: var(--content-background, #fff);
|
|
74
|
+
}
|
|
75
|
+
:host([expanded]) .card{
|
|
76
|
+
border-radius: 0px;
|
|
77
|
+
}
|
|
78
|
+
:host([expanded]) .title{
|
|
79
|
+
@apply --accent-invert;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.card {
|
|
83
|
+
min-width: 70px;
|
|
84
|
+
min-height: 0;
|
|
85
|
+
max-height: 100%;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
border-radius: 10px;
|
|
88
|
+
width: min-content;
|
|
89
|
+
}
|
|
90
|
+
.preview {
|
|
91
|
+
min-height: 0;
|
|
92
|
+
overflow: auto;
|
|
93
|
+
width: stretch;
|
|
94
|
+
}
|
|
95
|
+
:host([compact]) {
|
|
96
|
+
width: 100%;
|
|
97
|
+
border-radius: 0;
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
}
|
|
100
|
+
:host([compact]) .card {
|
|
101
|
+
width: 100%;
|
|
102
|
+
border-radius: 0;
|
|
103
|
+
border: 1px solid var(--border-color);
|
|
104
|
+
box-shadow: none;
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
}
|
|
107
|
+
:host([compact]) .preview {
|
|
108
|
+
max-height: 220px;
|
|
109
|
+
border-top: 1px solid var(--border-color);
|
|
110
|
+
}
|
|
111
|
+
.card[raised] {
|
|
112
|
+
border-radius: 0px !important;
|
|
113
|
+
}
|
|
114
|
+
.sender {
|
|
115
|
+
position: sticky;
|
|
116
|
+
bottom: 0px;
|
|
117
|
+
border-radius: 50% !important;
|
|
118
|
+
}
|
|
119
|
+
.body {
|
|
120
|
+
user-select: text;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
}
|
|
123
|
+
.title {
|
|
124
|
+
font-size: xx-small;
|
|
125
|
+
min-height: 26px;
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
transition: background-color .5s;
|
|
128
|
+
}
|
|
129
|
+
.title oda-button {
|
|
130
|
+
scale: .8;
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
}
|
|
133
|
+
.title oda-button:hover {
|
|
134
|
+
@apply --hover;
|
|
135
|
+
}
|
|
136
|
+
item-node{
|
|
137
|
+
padding: 2px 8px;
|
|
138
|
+
font-size: x-small;
|
|
139
|
+
}
|
|
140
|
+
.file-time{
|
|
141
|
+
@apply --no-flex;
|
|
142
|
+
font-size: xx-small;
|
|
143
|
+
opacity: .55;
|
|
144
|
+
margin-left: 6px;
|
|
145
|
+
white-space: nowrap;
|
|
146
|
+
align-self: center;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* --- Пузыри мессенджера --- */
|
|
150
|
+
.avatar-slot {
|
|
151
|
+
display: flex;
|
|
152
|
+
flex-direction: column;
|
|
153
|
+
justify-content: flex-end;
|
|
154
|
+
width: 32px;
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
margin-right: 6px;
|
|
157
|
+
}
|
|
158
|
+
.avatar-slot.hidden-avatar {
|
|
159
|
+
visibility: hidden;
|
|
160
|
+
}
|
|
161
|
+
.bubble-row {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: flex-end;
|
|
164
|
+
gap: 6px;
|
|
165
|
+
min-width: 0;
|
|
166
|
+
max-width: min(76%, 640px);
|
|
167
|
+
position: relative;
|
|
168
|
+
}
|
|
169
|
+
.bubble-row.own {
|
|
170
|
+
flex-direction: row-reverse;
|
|
171
|
+
}
|
|
172
|
+
.bubble {
|
|
173
|
+
position: relative;
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
gap: 4px;
|
|
177
|
+
min-width: 68px;
|
|
178
|
+
max-width: 100%;
|
|
179
|
+
padding: 7px 11px 6px;
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
border-radius: 15px;
|
|
182
|
+
font-size: 14px;
|
|
183
|
+
line-height: 1.42;
|
|
184
|
+
color: var(--content-color, #0f172a);
|
|
185
|
+
background: var(--content-background, #ffffff);
|
|
186
|
+
border: 1px solid color-mix(in oklch, var(--border-color, #cbd5e1) 55%, transparent);
|
|
187
|
+
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
|
|
188
|
+
transition: background-color .15s ease, box-shadow .15s ease;
|
|
189
|
+
}
|
|
190
|
+
.bubble.own {
|
|
191
|
+
background: color-mix(in oklch, var(--accent-color, #4f46e5) 14%, var(--content-background, #ffffff));
|
|
192
|
+
border-color: color-mix(in oklch, var(--accent-color, #4f46e5) 26%, transparent);
|
|
193
|
+
}
|
|
194
|
+
.bubble.peer.grp-last {
|
|
195
|
+
border-bottom-left-radius: 4px;
|
|
196
|
+
}
|
|
197
|
+
.bubble.peer:not(.grp-first) {
|
|
198
|
+
border-top-left-radius: 6px;
|
|
199
|
+
}
|
|
200
|
+
.bubble.own.grp-last {
|
|
201
|
+
border-bottom-right-radius: 4px;
|
|
202
|
+
}
|
|
203
|
+
.bubble.own:not(.grp-first) {
|
|
204
|
+
border-top-right-radius: 6px;
|
|
205
|
+
}
|
|
206
|
+
.bubble.pending {
|
|
207
|
+
opacity: .78;
|
|
208
|
+
}
|
|
209
|
+
.bubble.send-error {
|
|
210
|
+
border-color: var(--error-color, #dc2626);
|
|
211
|
+
background: color-mix(in oklch, var(--error-color, #dc2626) 8%, var(--content-background, #ffffff));
|
|
212
|
+
}
|
|
213
|
+
.bubble-author {
|
|
214
|
+
font-size: 12px;
|
|
215
|
+
font-weight: 700;
|
|
216
|
+
line-height: 1.25;
|
|
217
|
+
margin-bottom: 1px;
|
|
218
|
+
overflow: hidden;
|
|
219
|
+
text-overflow: ellipsis;
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
}
|
|
222
|
+
.reply-quote {
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
gap: 1px;
|
|
226
|
+
padding: 4px 8px;
|
|
227
|
+
border-radius: 8px;
|
|
228
|
+
border-left: 3px solid var(--accent-color, #4f46e5);
|
|
229
|
+
background: color-mix(in oklch, var(--accent-color, #4f46e5) 9%, transparent);
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
font-size: 12px;
|
|
232
|
+
line-height: 1.3;
|
|
233
|
+
max-width: 100%;
|
|
234
|
+
box-sizing: border-box;
|
|
235
|
+
}
|
|
236
|
+
.reply-quote:hover {
|
|
237
|
+
background: color-mix(in oklch, var(--accent-color, #4f46e5) 15%, transparent);
|
|
238
|
+
}
|
|
239
|
+
.reply-quote-author {
|
|
240
|
+
font-weight: 700;
|
|
241
|
+
color: var(--accent-color, #4f46e5);
|
|
242
|
+
overflow: hidden;
|
|
243
|
+
text-overflow: ellipsis;
|
|
244
|
+
white-space: nowrap;
|
|
245
|
+
}
|
|
246
|
+
.reply-quote-text {
|
|
247
|
+
opacity: .8;
|
|
248
|
+
overflow: hidden;
|
|
249
|
+
text-overflow: ellipsis;
|
|
250
|
+
white-space: nowrap;
|
|
251
|
+
}
|
|
252
|
+
.bubble-atts {
|
|
253
|
+
display: flex;
|
|
254
|
+
flex-direction: column;
|
|
255
|
+
gap: 6px;
|
|
256
|
+
margin: 2px 0;
|
|
257
|
+
}
|
|
258
|
+
.att-img {
|
|
259
|
+
display: block;
|
|
260
|
+
max-width: min(320px, 100%);
|
|
261
|
+
max-height: 280px;
|
|
262
|
+
border-radius: 10px;
|
|
263
|
+
object-fit: cover;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
background: rgba(0, 0, 0, 0.04);
|
|
266
|
+
}
|
|
267
|
+
.att-video {
|
|
268
|
+
display: block;
|
|
269
|
+
max-width: min(340px, 100%);
|
|
270
|
+
max-height: 240px;
|
|
271
|
+
border-radius: 10px;
|
|
272
|
+
background: #000;
|
|
273
|
+
}
|
|
274
|
+
.att-audio {
|
|
275
|
+
width: min(280px, 100%);
|
|
276
|
+
height: 36px;
|
|
277
|
+
}
|
|
278
|
+
.att-file {
|
|
279
|
+
display: flex;
|
|
280
|
+
align-items: center;
|
|
281
|
+
gap: 8px;
|
|
282
|
+
padding: 6px 8px;
|
|
283
|
+
border-radius: 10px;
|
|
284
|
+
background: color-mix(in oklch, var(--content-background, #fff) 75%, var(--subtle-background, #f1f5f9));
|
|
285
|
+
border: 1px solid color-mix(in oklch, var(--border-color, #cbd5e1) 70%, transparent);
|
|
286
|
+
cursor: pointer;
|
|
287
|
+
min-width: 180px;
|
|
288
|
+
max-width: 340px;
|
|
289
|
+
box-sizing: border-box;
|
|
290
|
+
}
|
|
291
|
+
.att-file:hover {
|
|
292
|
+
border-color: var(--accent-color, #4f46e5);
|
|
293
|
+
}
|
|
294
|
+
.att-file-meta {
|
|
295
|
+
flex: 1 1 auto;
|
|
296
|
+
min-width: 0;
|
|
297
|
+
display: flex;
|
|
298
|
+
flex-direction: column;
|
|
299
|
+
}
|
|
300
|
+
.att-file-name {
|
|
301
|
+
font-size: 13px;
|
|
302
|
+
font-weight: 600;
|
|
303
|
+
overflow: hidden;
|
|
304
|
+
text-overflow: ellipsis;
|
|
305
|
+
white-space: nowrap;
|
|
306
|
+
}
|
|
307
|
+
.att-file-sub {
|
|
308
|
+
font-size: 11px;
|
|
309
|
+
opacity: .6;
|
|
310
|
+
}
|
|
311
|
+
.att-act {
|
|
312
|
+
border-radius: 50%;
|
|
313
|
+
flex-shrink: 0;
|
|
314
|
+
opacity: .72;
|
|
315
|
+
}
|
|
316
|
+
.att-act:hover {
|
|
317
|
+
opacity: 1;
|
|
318
|
+
@apply --hover;
|
|
319
|
+
}
|
|
320
|
+
.bubble-body-line {
|
|
321
|
+
display: flex;
|
|
322
|
+
flex-direction: column;
|
|
323
|
+
min-width: 0;
|
|
324
|
+
}
|
|
325
|
+
.bubble-text {
|
|
326
|
+
white-space: pre-wrap;
|
|
327
|
+
word-break: break-word;
|
|
328
|
+
user-select: text;
|
|
329
|
+
min-width: 0;
|
|
330
|
+
}
|
|
331
|
+
.bubble-meta {
|
|
332
|
+
display: inline-flex;
|
|
333
|
+
align-items: center;
|
|
334
|
+
justify-content: flex-end;
|
|
335
|
+
gap: 4px;
|
|
336
|
+
align-self: flex-end;
|
|
337
|
+
margin-top: 1px;
|
|
338
|
+
font-size: 11px;
|
|
339
|
+
line-height: 1;
|
|
340
|
+
opacity: .68;
|
|
341
|
+
user-select: none;
|
|
342
|
+
white-space: nowrap;
|
|
343
|
+
}
|
|
344
|
+
.bubble.own .bubble-meta {
|
|
345
|
+
opacity: .78;
|
|
346
|
+
}
|
|
347
|
+
.edited-tag {
|
|
348
|
+
font-style: italic;
|
|
349
|
+
font-size: 10.5px;
|
|
350
|
+
}
|
|
351
|
+
.ticks {
|
|
352
|
+
display: inline-flex;
|
|
353
|
+
align-items: center;
|
|
354
|
+
color: currentColor;
|
|
355
|
+
}
|
|
356
|
+
.ticks.read {
|
|
357
|
+
color: var(--accent-color, #2563eb);
|
|
358
|
+
opacity: 1;
|
|
359
|
+
}
|
|
360
|
+
.send-err-box {
|
|
361
|
+
display: flex;
|
|
362
|
+
align-items: center;
|
|
363
|
+
flex-wrap: wrap;
|
|
364
|
+
gap: 6px;
|
|
365
|
+
margin-top: 2px;
|
|
366
|
+
font-size: 12px;
|
|
367
|
+
color: var(--error-color, #dc2626);
|
|
368
|
+
}
|
|
369
|
+
.send-err-btn {
|
|
370
|
+
border: 1px solid currentColor;
|
|
371
|
+
background: transparent;
|
|
372
|
+
color: inherit;
|
|
373
|
+
border-radius: 999px;
|
|
374
|
+
padding: 2px 8px;
|
|
375
|
+
font: inherit;
|
|
376
|
+
font-size: 11px;
|
|
377
|
+
font-weight: 600;
|
|
378
|
+
cursor: pointer;
|
|
379
|
+
}
|
|
380
|
+
.send-err-btn:hover {
|
|
381
|
+
background: color-mix(in oklch, var(--error-color, #dc2626) 12%, transparent);
|
|
382
|
+
}
|
|
383
|
+
.hover-actions {
|
|
384
|
+
display: flex;
|
|
385
|
+
align-items: center;
|
|
386
|
+
gap: 2px;
|
|
387
|
+
opacity: 0;
|
|
388
|
+
pointer-events: none;
|
|
389
|
+
transition: opacity .14s ease;
|
|
390
|
+
flex-shrink: 0;
|
|
391
|
+
align-self: center;
|
|
392
|
+
background: color-mix(in oklch, var(--content-background, #fff) 92%, transparent);
|
|
393
|
+
border: 1px solid color-mix(in oklch, var(--border-color, #cbd5e1) 60%, transparent);
|
|
394
|
+
border-radius: 999px;
|
|
395
|
+
padding: 1px 3px;
|
|
396
|
+
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
|
|
397
|
+
}
|
|
398
|
+
.bubble-row:hover .hover-actions,
|
|
399
|
+
.bubble-row:focus-within .hover-actions {
|
|
400
|
+
opacity: 1;
|
|
401
|
+
pointer-events: auto;
|
|
402
|
+
}
|
|
403
|
+
.hover-btn {
|
|
404
|
+
border: none;
|
|
405
|
+
background: transparent;
|
|
406
|
+
color: var(--content-color, #334155);
|
|
407
|
+
width: 24px;
|
|
408
|
+
height: 24px;
|
|
409
|
+
border-radius: 50%;
|
|
410
|
+
display: inline-flex;
|
|
411
|
+
align-items: center;
|
|
412
|
+
justify-content: center;
|
|
413
|
+
cursor: pointer;
|
|
414
|
+
padding: 0;
|
|
415
|
+
}
|
|
416
|
+
.hover-btn:hover {
|
|
417
|
+
background: color-mix(in oklch, var(--accent-color, #4f46e5) 14%, transparent);
|
|
418
|
+
color: var(--accent-color, #4f46e5);
|
|
419
|
+
}
|
|
420
|
+
@media (max-width: 768px) {
|
|
421
|
+
.bubble-row {
|
|
422
|
+
max-width: min(88%, 640px);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
</style>
|
|
426
|
+
|
|
427
|
+
<!-- Режим пузыря мессенджера -->
|
|
428
|
+
<div class="avatar-slot" ~if="isBubble && !isSender && !isDm && hasSenderAvatar" ~class="{'hidden-avatar': !groupLast}">
|
|
429
|
+
<item-icon class="sender" icon-size="28" :$item="sender" :icon="isAgentSender ? 'bootstrap:robot' : ''" :title="isAgentSender ? agentSenderTitle : ''" :default="isAgentSender ? 'bootstrap:robot' : ''"></item-icon>
|
|
430
|
+
</div>
|
|
431
|
+
<div class="bubble-row" ~if="isBubble" ~class="{ own: isSender, peer: !isSender }" ~style="cardLayoutStyle">
|
|
432
|
+
<div class="bubble" ~class="{ own: isSender, peer: !isSender, 'grp-first': groupFirst, 'grp-last': groupLast, pending: isPending, 'send-error': Boolean(sendError) }" @contextmenu.prevent.stop="openMessageMenu($event)">
|
|
433
|
+
<div class="bubble-author" ~if="!isDm && !isSender && groupFirst && senderDisplayName" ~style="{ color: authorColor }">{{senderDisplayName}}</div>
|
|
434
|
+
<div class="reply-quote" ~if="replyInfo" @tap.stop="scrollToReply($event)">
|
|
435
|
+
<div class="reply-quote-author">{{replyInfo.senderLabel || replyInfo.sender || 'Сообщение'}}</div>
|
|
436
|
+
<div class="reply-quote-text">{{replyInfo.preview}}</div>
|
|
437
|
+
</div>
|
|
438
|
+
<div class="bubble-atts" ~if="attachmentItems.length">
|
|
439
|
+
<div ~for="attachmentItems" style="display: contents;">
|
|
440
|
+
<img ~if="$for.item.isImage" class="att-img" loading="lazy" :src="$for.item.url" :alt="$for.item.name" @tap.stop="openAttachment($for.item, $event)" @contextmenu.prevent.stop="openAttachmentMenu($for.item, $event)">
|
|
441
|
+
<video ~if="$for.item.isVideo" class="att-video" controls preload="metadata" :src="$for.item.url" @contextmenu.prevent.stop="openAttachmentMenu($for.item, $event)"></video>
|
|
442
|
+
<audio ~if="$for.item.isAudio" class="att-audio" controls preload="metadata" :src="$for.item.url" @contextmenu.prevent.stop="openAttachmentMenu($for.item, $event)"></audio>
|
|
443
|
+
<div ~if="!$for.item.isImage && !$for.item.isVideo && !$for.item.isAudio" class="att-file" @tap.stop="openAttachment($for.item, $event)" @contextmenu.prevent.stop="openAttachmentMenu($for.item, $event)">
|
|
444
|
+
<item-icon :$item="$for.item.item" icon="icons:insert-drive-file" icon-size="24"></item-icon>
|
|
445
|
+
<div class="att-file-meta">
|
|
446
|
+
<div class="att-file-name" :title="$for.item.name">{{$for.item.name}}</div>
|
|
447
|
+
<div class="att-file-sub" ~if="$for.item.ext">{{$for.item.ext.toUpperCase()}}</div>
|
|
448
|
+
</div>
|
|
449
|
+
<oda-button class="att-act" icon="icons:file-download" :icon-size="16" title="Скачать" @down.stop @tap.stop="downloadAttachment($for.item, $event)"></oda-button>
|
|
450
|
+
<oda-button class="att-act" icon="icons:more-vert" :icon-size="16" title="Меню файла" @down.stop @tap.stop="openAttachmentMenu($for.item, $event)"></oda-button>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
453
|
+
</div>
|
|
454
|
+
<div class="bubble-body-line" ~if="logContent">
|
|
455
|
+
<div class="bubble-text">{{logContent}}</div>
|
|
456
|
+
</div>
|
|
457
|
+
<div class="approval-box" ~if="log?.chatMessage?.kind === 'approval'" horizontal style="align-items: center; gap: 8px; padding: 4px 0 2px;">
|
|
458
|
+
<span ~if="approvalStatus === 'approved'" style="font-size: 12px; font-weight: 700; color: #059669;">✓ Утверждено</span>
|
|
459
|
+
<span ~if="approvalStatus === 'rejected'" style="font-size: 12px; font-weight: 700; color: #dc2626;">✕ Отклонено</span>
|
|
460
|
+
<oda-button ~if="approvalStatus === 'pending'" icon="icons:check" info-invert label="Утвердить" @down.stop @tap.stop="_resolveChatApproval('approve')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
|
|
461
|
+
<oda-button ~if="approvalStatus === 'pending'" icon="icons:close" label="Отклонить" @down.stop @tap.stop="_resolveChatApproval('reject')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
|
|
462
|
+
</div>
|
|
463
|
+
<div class="send-err-box" ~if="sendError">
|
|
464
|
+
<span>Не отправлено</span>
|
|
465
|
+
<button type="button" class="send-err-btn" @tap.stop="_retryFailedSend($event)">Повторить</button>
|
|
466
|
+
<button type="button" class="send-err-btn" @tap.stop="_dismissFailedSend($event)">Убрать</button>
|
|
467
|
+
</div>
|
|
468
|
+
<div class="bubble-meta" ~if="shortTime || isSender">
|
|
469
|
+
<span class="edited-tag" ~if="isEdited">изм.</span>
|
|
470
|
+
<span class="msg-time" ~if="shortTime">{{shortTime}}</span>
|
|
471
|
+
<span ~if="isSender && sendError" class="ticks" style="color: var(--error-color, #dc2626);" :title="sendError">!</span>
|
|
472
|
+
<span ~if="isSender && !sendError && isPending" class="ticks" title="Отправляется…">
|
|
473
|
+
<oda-icon icon="icons:schedule" :icon-size="12"></oda-icon>
|
|
474
|
+
</span>
|
|
475
|
+
<span ~if="isSender && !sendError && !isPending && isReadByPeer" class="ticks read" title="Прочитано">
|
|
476
|
+
<svg width="16" height="11" viewBox="0 0 16 11" fill="none" aria-hidden="true"><path d="M1 5.5L4.2 8.7L10.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M5.5 8.7L14.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
477
|
+
</span>
|
|
478
|
+
<span ~if="isSender && !sendError && !isPending && !isReadByPeer && cmId > 0" class="ticks sent" title="Отправлено">
|
|
479
|
+
<svg width="12" height="11" viewBox="0 0 12 11" fill="none" aria-hidden="true"><path d="M1 5.5L4.2 8.7L10.5 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
480
|
+
</span>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
<div class="hover-actions" ~if="!isPending && !sendError">
|
|
484
|
+
<button type="button" class="hover-btn" title="Ответить" @down.stop @tap.stop="_replyAction($event)">
|
|
485
|
+
<oda-icon icon="icons:reply" :icon-size="15"></oda-icon>
|
|
486
|
+
</button>
|
|
487
|
+
<button type="button" class="hover-btn" title="Действия" @down.stop @tap.stop="openMessageMenu($event)">
|
|
488
|
+
<oda-icon icon="icons:more-vert" :icon-size="15"></oda-icon>
|
|
489
|
+
</button>
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
<!-- Режим карточки (задачи .task, звонки, операции, missingTargetPath, compact, history, expanded) -->
|
|
494
|
+
<div class="card" ~if="!isBubble" shadow :flex="expanded || compact" vertical ~style="cardLayoutStyle" @tap="onCardTap($event)">
|
|
495
|
+
<div class="title" no-flex light horizontal ~if="!(expanded && bodyHeader)" style="justify-content: space-between; align-items: center;">
|
|
496
|
+
<item-node auto-run :icon-size :$item="activeCardFile" :label="fileLabel" :hide-icon="isText || !!missingTargetPath" hide-history-time>
|
|
497
|
+
<span class="file-time" ~if="fileTime">{{fileTime}}</span>
|
|
498
|
+
</item-node>
|
|
499
|
+
<oda-button ~if="!compact && !isOperationLog && !missingTargetPath && (hasPreview || _expandedFile)" :icon-size :icon="expanderIcon" :error="expanded" @tap="expanded = !expanded"></oda-button>
|
|
500
|
+
</div>
|
|
501
|
+
<div class="preview missing-file-box" ~if="!expanded && missingTargetPath" horizontal style="align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px;">
|
|
502
|
+
<div horizontal style="align-items: center; gap: 8px; min-width: 0; color: var(--error-color, #dc2626);">
|
|
503
|
+
<oda-icon icon="icons:warning" :icon-size="18" style="flex-shrink: 0;"></oda-icon>
|
|
504
|
+
<span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" :title="missingTargetPath">
|
|
505
|
+
Такого файла нет: <b>{{missingTargetLabel}}</b>
|
|
506
|
+
</span>
|
|
507
|
+
</div>
|
|
508
|
+
<oda-button ~if="isAdminRole" class="delete-log-btn" error-invert icon="icons:delete" :icon-size="16" label="Удалить лог" title="Удалить запись лога об отсутствующем файле" @down.stop @tap.stop="deleteMissingLog($event)" style="border-radius: 6px; padding: 3px 10px; scale: 1; flex-shrink: 0;"></oda-button>
|
|
509
|
+
</div>
|
|
510
|
+
<div class="preview" ~if="!compact && !expanded && !missingTargetPath && hasPreview && $file" ~is="previewTag" flex :$item="$file" :log="log" :log-content="logContent" style="user-select: text;" @expand-card.stop="expanded = true"></div>
|
|
511
|
+
<div class="preview" ~if="!compact && !expanded && !missingTargetPath && !$file && !hasTargetFilePath && logContent" flex style="padding: 6px 12px; white-space: pre-wrap; user-select: text;">{{logContent}}</div>
|
|
512
|
+
<div class="approval-box" ~if="!compact && !expanded && log?.chatMessage?.kind === 'approval'" horizontal style="align-items: center; gap: 8px; padding: 4px 12px 8px;">
|
|
513
|
+
<span ~if="approvalStatus === 'approved'" style="font-size: 12px; font-weight: 700; color: #059669;">✓ Утверждено</span>
|
|
514
|
+
<span ~if="approvalStatus === 'rejected'" style="font-size: 12px; font-weight: 700; color: #dc2626;">✕ Отклонено</span>
|
|
515
|
+
<oda-button ~if="approvalStatus === 'pending'" icon="icons:check" info-invert label="Утвердить" @down.stop @tap.stop="_resolveChatApproval('approve')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
|
|
516
|
+
<oda-button ~if="approvalStatus === 'pending'" icon="icons:close" label="Отклонить" @down.stop @tap.stop="_resolveChatApproval('reject')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
|
|
517
|
+
</div>
|
|
518
|
+
<div header ~if="!expanded && !missingTargetPath && includeFiles?.length" vertical style="padding: 8px; gap: 8px;">
|
|
519
|
+
<chat-item ~for="includeFiles" visible history compact :$file="$for.item"></chat-item>
|
|
520
|
+
</div>
|
|
521
|
+
<div class="body" flex vertical ~if="expanded && !missingTargetPath">
|
|
522
|
+
<div ~is="formTag" flex :$item="activeCardFile" @own-header="bodyHeader = true" @close-view="expanded = false"></div>
|
|
523
|
+
</div>
|
|
524
|
+
</div>
|
|
525
|
+
`,
|
|
526
|
+
isDm: false,
|
|
527
|
+
groupFirst: true,
|
|
528
|
+
groupLast: true,
|
|
529
|
+
peerLastReadId: 0,
|
|
530
|
+
_expandedFile: null,
|
|
531
|
+
get activeCardFile() {
|
|
532
|
+
return this._expandedFile || this.$file;
|
|
533
|
+
},
|
|
534
|
+
get isCall() {
|
|
535
|
+
const ext = String(this.ext || this.log?.ext || this.$file?.ext || '').toLowerCase();
|
|
536
|
+
return ext === 'call';
|
|
537
|
+
},
|
|
538
|
+
get isBubble() {
|
|
539
|
+
if (this.compact || this.expanded || this.history || this.isTask || this.isCall || this.isOperationLog || this.missingTargetPath)
|
|
540
|
+
return false;
|
|
541
|
+
return true;
|
|
542
|
+
},
|
|
543
|
+
get cmId() {
|
|
544
|
+
return Number(this.log?.chatMessage?.id) || 0;
|
|
545
|
+
},
|
|
546
|
+
get isPending() {
|
|
547
|
+
return Boolean(this.log?.chatMessage?.meta?.pending);
|
|
548
|
+
},
|
|
549
|
+
get sendError() {
|
|
550
|
+
return String(this.log?.chatMessage?.meta?.sendError || '');
|
|
551
|
+
},
|
|
552
|
+
get isEdited() {
|
|
553
|
+
return Boolean(this.log?.chatMessage?.meta?.editedAt);
|
|
554
|
+
},
|
|
555
|
+
get isReadByPeer() {
|
|
556
|
+
return Boolean(this.cmId > 0 && Number(this.peerLastReadId) >= this.cmId);
|
|
557
|
+
},
|
|
558
|
+
get authorColor() {
|
|
559
|
+
return authorColorFor(this.senderId || this.log?.sender || 'user');
|
|
560
|
+
},
|
|
561
|
+
get senderDisplayName() {
|
|
562
|
+
if (this.isAgentSender)
|
|
563
|
+
return this.agentSenderTitle;
|
|
564
|
+
const resolved = this._resolvedSenderObj;
|
|
565
|
+
if (resolved)
|
|
566
|
+
return resolved.DATA?.label || resolved.label || resolved.id || this.senderId || '';
|
|
567
|
+
return this.log?.chatMessage?.senderLabel || this.senderId || this.log?.sender || '';
|
|
568
|
+
},
|
|
569
|
+
flashHighlight() {
|
|
570
|
+
const b = this.$?.('.bubble') || this.$?.('.card');
|
|
571
|
+
if (!b) return;
|
|
572
|
+
b.style.transition = 'box-shadow .25s ease';
|
|
573
|
+
b.style.boxShadow = '0 0 0 3px var(--accent-color, #4f46e5)';
|
|
574
|
+
setTimeout(() => {
|
|
575
|
+
if (b) b.style.boxShadow = '';
|
|
576
|
+
}, 1400);
|
|
577
|
+
},
|
|
578
|
+
get replyInfo() {
|
|
579
|
+
const rp = this.log?.chatMessage?.meta?.replyPreview;
|
|
580
|
+
if (!rp || (!rp.id && !rp.content))
|
|
581
|
+
return null;
|
|
582
|
+
const preview = String(rp.content || '').trim() || (rp.attachmentsCount ? `Вложение (${rp.attachmentsCount})` : 'Сообщение');
|
|
583
|
+
let senderLabel = rp.senderLabel || '';
|
|
584
|
+
if (!senderLabel && rp.sender) {
|
|
585
|
+
if (rp.sender === '$twin')
|
|
586
|
+
senderLabel = 'Цифровой двойник';
|
|
587
|
+
else if (rp.sender === WORK.uid)
|
|
588
|
+
senderLabel = WORK.USER?.DATA?.label || WORK.USER?.label || WORK.uid;
|
|
589
|
+
else
|
|
590
|
+
senderLabel = rp.sender;
|
|
591
|
+
}
|
|
592
|
+
return { ...rp, senderLabel, preview };
|
|
593
|
+
},
|
|
594
|
+
get shortTime() {
|
|
595
|
+
const ms = +(this.log?.time || this.log?.chatMessage?.created || 0);
|
|
596
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
597
|
+
return '';
|
|
598
|
+
const d = new Date(ms);
|
|
599
|
+
if (isNaN(d))
|
|
600
|
+
return '';
|
|
601
|
+
return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
602
|
+
},
|
|
603
|
+
get attachmentItems() {
|
|
604
|
+
const list = [];
|
|
605
|
+
const seen = new Set();
|
|
606
|
+
const add = (path, name = '') => {
|
|
607
|
+
const raw = String(path || '').trim();
|
|
608
|
+
if (!raw || raw.endsWith('.logs') || raw.endsWith('.task') || raw.endsWith('.call'))
|
|
609
|
+
return;
|
|
610
|
+
const norm = raw.startsWith('/') ? raw : '/' + raw;
|
|
611
|
+
if (seen.has(norm))
|
|
612
|
+
return;
|
|
613
|
+
seen.add(norm);
|
|
614
|
+
const fname = name || norm.split('/').pop() || 'file';
|
|
615
|
+
const ext = extOfPath(norm);
|
|
616
|
+
const cached = this._attCache?.[norm] || null;
|
|
617
|
+
list.push({
|
|
618
|
+
path: norm,
|
|
619
|
+
name: cached?.DATA?.label || cached?.label || fname,
|
|
620
|
+
ext,
|
|
621
|
+
isImage: IMAGE_EXTS.has(ext),
|
|
622
|
+
isVideo: VIDEO_EXTS.has(ext),
|
|
623
|
+
isAudio: AUDIO_EXTS.has(ext),
|
|
624
|
+
url: cached?.url || fileUrlOf(norm),
|
|
625
|
+
item: cached,
|
|
626
|
+
});
|
|
627
|
+
if (!cached && !this._attLoading?.[norm] && typeof WORK?.get_item === 'function') {
|
|
628
|
+
(this._attLoading ??= {})[norm] = true;
|
|
629
|
+
WORK.get_item(norm, 'info').then(it => {
|
|
630
|
+
if (it && (it.path || it.id || it.type)) {
|
|
631
|
+
(this._attCache ??= {})[norm] = it;
|
|
632
|
+
this.invalidate?.('attachmentItems');
|
|
633
|
+
this.render?.();
|
|
634
|
+
}
|
|
635
|
+
}).catch(() => {});
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
for (const a of (this.log?.chatMessage?.attachments || [])) {
|
|
639
|
+
if (a?.path) add(a.path, a.name);
|
|
640
|
+
}
|
|
641
|
+
const inc = this.log?.includes;
|
|
642
|
+
if (Array.isArray(inc)) {
|
|
643
|
+
for (const p of inc) add(p);
|
|
644
|
+
}
|
|
645
|
+
else if (typeof inc === 'string' && inc.trim()) {
|
|
646
|
+
const s = inc.trim();
|
|
647
|
+
let parsed = [s];
|
|
648
|
+
if (s[0] === '[') {
|
|
649
|
+
try { const arr = JSON.parse(s); if (Array.isArray(arr)) parsed = arr; } catch {}
|
|
650
|
+
}
|
|
651
|
+
else if (s.includes(',/')) parsed = s.split(',');
|
|
652
|
+
for (const p of parsed) add(p);
|
|
653
|
+
}
|
|
654
|
+
if (this.hasTargetFilePath && this.log?.path)
|
|
655
|
+
add(this.log.path);
|
|
656
|
+
return list;
|
|
657
|
+
},
|
|
658
|
+
async _ensureAttItem(att) {
|
|
659
|
+
if (att?.item) return att.item;
|
|
660
|
+
if (!att?.path || typeof WORK?.get_item !== 'function') return null;
|
|
661
|
+
const it = await WORK.get_item(att.path, 'info').catch(() => null);
|
|
662
|
+
if (it) {
|
|
663
|
+
(this._attCache ??= {})[att.path] = it;
|
|
664
|
+
att.item = it;
|
|
665
|
+
}
|
|
666
|
+
return it;
|
|
667
|
+
},
|
|
668
|
+
async openAttachment(att, e) {
|
|
669
|
+
e?.stopPropagation?.();
|
|
670
|
+
const item = await this._ensureAttItem(att);
|
|
671
|
+
if (!item) {
|
|
672
|
+
if (att?.url) window.open(att.url, '_blank');
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
this._expandedFile = item;
|
|
676
|
+
this.expanded = true;
|
|
677
|
+
},
|
|
678
|
+
async downloadAttachment(att, e) {
|
|
679
|
+
e?.stopPropagation?.();
|
|
680
|
+
const item = await this._ensureAttItem(att);
|
|
681
|
+
if (item && typeof item.download === 'function') {
|
|
682
|
+
item.download();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
if (att?.url) {
|
|
686
|
+
const a = document.createElement('a');
|
|
687
|
+
a.href = att.url + (att.url.includes('?') ? '&' : '?') + 'download=1';
|
|
688
|
+
a.download = att.name || 'file';
|
|
689
|
+
a.click();
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
async openAttachmentMenu(att, e) {
|
|
693
|
+
e?.preventDefault?.();
|
|
694
|
+
e?.stopPropagation?.();
|
|
695
|
+
const item = await this._ensureAttItem(att);
|
|
696
|
+
const tools = [
|
|
697
|
+
{ label: 'Открыть', icon: 'icons:open-in-new', execute: () => this.openAttachment(att) },
|
|
698
|
+
{ label: 'Скачать', icon: 'icons:file-download', execute: () => this.downloadAttachment(att) },
|
|
699
|
+
];
|
|
700
|
+
if (item && typeof item.execute === 'function') {
|
|
701
|
+
tools.push({ label: 'Открыть в отдельной вкладке', icon: 'icons:launch', execute: () => item.execute() });
|
|
702
|
+
}
|
|
703
|
+
if (typeof WORK?.showMenu === 'function') {
|
|
704
|
+
WORK.showMenu({
|
|
705
|
+
...(item ? { $item: item, mode: 'both' } : { mode: 'tools' }),
|
|
706
|
+
customTools: tools,
|
|
707
|
+
}, e);
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
_messageActionDetail() {
|
|
711
|
+
return {
|
|
712
|
+
message: this.log?.chatMessage || null,
|
|
713
|
+
log: this.log,
|
|
714
|
+
senderId: this.senderId || this.log?.sender || '',
|
|
715
|
+
senderLabel: this.senderDisplayName || (this.isSender ? (WORK.USER?.DATA?.label || WORK.USER?.label || 'Вы') : 'Собеседник'),
|
|
716
|
+
content: this.logContent || '',
|
|
717
|
+
attachments: this.attachmentItems || [],
|
|
718
|
+
};
|
|
719
|
+
},
|
|
720
|
+
_replyAction(e) {
|
|
721
|
+
e?.stopPropagation?.();
|
|
722
|
+
this.dispatchEvent(new CustomEvent('chat-reply', {
|
|
723
|
+
bubbles: true,
|
|
724
|
+
composed: true,
|
|
725
|
+
detail: this._messageActionDetail(),
|
|
726
|
+
}));
|
|
727
|
+
},
|
|
728
|
+
openMessageMenu(e) {
|
|
729
|
+
const sel = typeof window?.getSelection === 'function' ? String(window.getSelection() || '').trim() : '';
|
|
730
|
+
if (e?.type === 'contextmenu' && sel)
|
|
731
|
+
return; // при выделении текста не мешаем стандартному копированию
|
|
732
|
+
e?.preventDefault?.();
|
|
733
|
+
e?.stopPropagation?.();
|
|
734
|
+
const cm = this.log?.chatMessage;
|
|
735
|
+
const tools = [];
|
|
736
|
+
if (cm?.id) {
|
|
737
|
+
tools.push({
|
|
738
|
+
label: 'Ответить',
|
|
739
|
+
icon: 'icons:reply',
|
|
740
|
+
execute: () => this._replyAction(),
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
if (this.logContent) {
|
|
744
|
+
tools.push({
|
|
745
|
+
label: 'Копировать текст',
|
|
746
|
+
icon: 'icons:content-copy',
|
|
747
|
+
execute: async () => {
|
|
748
|
+
try {
|
|
749
|
+
await navigator.clipboard?.writeText?.(this.logContent);
|
|
750
|
+
ODA.showMessage?.('Скопировано');
|
|
751
|
+
} catch { /* ignore */ }
|
|
752
|
+
},
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
if (cm?.id && this.isSender && (!cm.kind || ['text', 'dm', 'twin'].includes(cm.kind)) && !this.isPending && !this.sendError) {
|
|
756
|
+
tools.push({
|
|
757
|
+
label: 'Редактировать',
|
|
758
|
+
icon: 'icons:edit',
|
|
759
|
+
execute: () => this.dispatchEvent(new CustomEvent('chat-edit', {
|
|
760
|
+
bubbles: true,
|
|
761
|
+
composed: true,
|
|
762
|
+
detail: this._messageActionDetail(),
|
|
763
|
+
})),
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
if (cm?.id && this.isSender) {
|
|
767
|
+
tools.push({
|
|
768
|
+
label: 'Удалить',
|
|
769
|
+
icon: 'icons:delete',
|
|
770
|
+
execute: () => this.dispatchEvent(new CustomEvent('chat-delete', {
|
|
771
|
+
bubbles: true,
|
|
772
|
+
composed: true,
|
|
773
|
+
detail: this._messageActionDetail(),
|
|
774
|
+
})),
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
if (tools.length && typeof WORK?.showMenu === 'function') {
|
|
778
|
+
WORK.showMenu({ mode: 'tools', customTools: tools }, e);
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
scrollToReply(e) {
|
|
782
|
+
e?.stopPropagation?.();
|
|
783
|
+
const id = Number(this.replyInfo?.id || this.log?.chatMessage?.replyTo || 0);
|
|
784
|
+
if (!id) return;
|
|
785
|
+
this.dispatchEvent(new CustomEvent('chat-scroll-to-message', {
|
|
786
|
+
bubbles: true,
|
|
787
|
+
composed: true,
|
|
788
|
+
detail: { messageId: id },
|
|
789
|
+
}));
|
|
790
|
+
},
|
|
791
|
+
_retryFailedSend(e) {
|
|
792
|
+
e?.stopPropagation?.();
|
|
793
|
+
this.dispatchEvent(new CustomEvent('chat-retry-send', {
|
|
794
|
+
bubbles: true,
|
|
795
|
+
composed: true,
|
|
796
|
+
detail: this._messageActionDetail(),
|
|
797
|
+
}));
|
|
798
|
+
},
|
|
799
|
+
_dismissFailedSend(e) {
|
|
800
|
+
e?.stopPropagation?.();
|
|
801
|
+
this.dispatchEvent(new CustomEvent('chat-dismiss-send', {
|
|
802
|
+
bubbles: true,
|
|
803
|
+
composed: true,
|
|
804
|
+
detail: this._messageActionDetail(),
|
|
805
|
+
}));
|
|
806
|
+
},
|
|
807
|
+
get formTag() {
|
|
808
|
+
return Promise.resolve(this.activeCardFile).then(async file => {
|
|
809
|
+
if (!file)
|
|
810
|
+
return 'item-node';
|
|
811
|
+
const name = file.form || 'file';
|
|
812
|
+
const view = await file.get_item('/~/handlers//form/' + name);
|
|
813
|
+
const ext = String(file.ext || '').toLowerCase();
|
|
814
|
+
const is = ext ? `item-${name}-${ext}` : `item-${name}`;
|
|
815
|
+
await view?.importView?.(is);
|
|
816
|
+
if (!customElements.get(is)) {
|
|
817
|
+
console.error(`[chat-item] вид '${name}' не зарегистрирован как <${is}>`);
|
|
818
|
+
return 'item-node';
|
|
819
|
+
}
|
|
820
|
+
return is;
|
|
821
|
+
});
|
|
822
|
+
},
|
|
823
|
+
get includeFiles() {
|
|
824
|
+
// карточка задачи показывает все файлы сама (превью .task: вложения + созданное агентом) — вложения записи журнала не дублируем
|
|
825
|
+
if (String(this.$file?.ext || '').toLowerCase() === 'task')
|
|
826
|
+
return [];
|
|
827
|
+
const raw = this.log?.includes;
|
|
828
|
+
let paths = raw;
|
|
829
|
+
if (!Array.isArray(paths)) {
|
|
830
|
+
if (typeof raw !== 'string' || !raw.trim())
|
|
831
|
+
return [];
|
|
832
|
+
const s = raw.trim();
|
|
833
|
+
if (s[0] === '[') {
|
|
834
|
+
try {
|
|
835
|
+
const parsed = JSON.parse(s);
|
|
836
|
+
paths = Array.isArray(parsed) ? parsed : [s];
|
|
837
|
+
} catch {
|
|
838
|
+
paths = s.includes(',/') ? s.split(',') : [s];
|
|
839
|
+
}
|
|
840
|
+
} else
|
|
841
|
+
paths = s.includes(',/') ? s.split(',') : [s];
|
|
842
|
+
}
|
|
843
|
+
if (!paths.length)
|
|
844
|
+
return [];
|
|
845
|
+
return Promise.all(paths.map(p => {
|
|
846
|
+
p = String(p ?? '').trim();
|
|
847
|
+
if (!p)
|
|
848
|
+
return null;
|
|
849
|
+
return WORK.get_item(p.startsWith('/') ? p : '/' + p, 'info');
|
|
850
|
+
})).then(items => items.filter(Boolean));
|
|
851
|
+
},
|
|
852
|
+
/** Развёрнутое представление со своей шапкой (событие own-header) — своя полоса title не нужна; закрытие — close-view. */
|
|
853
|
+
bodyHeader: false,
|
|
854
|
+
get expanderIcon(){
|
|
855
|
+
return this.expanded?'icons:close':'box:i-expand';
|
|
856
|
+
},
|
|
857
|
+
expanded: {
|
|
858
|
+
$attr: true,
|
|
859
|
+
$def: false,
|
|
860
|
+
set(n) {
|
|
861
|
+
try {
|
|
862
|
+
this.dispatchEvent(new CustomEvent('chat-item-expanded', {
|
|
863
|
+
bubbles: true,
|
|
864
|
+
composed: true,
|
|
865
|
+
detail: { expanded: Boolean(n), card: this },
|
|
866
|
+
}));
|
|
867
|
+
}
|
|
868
|
+
catch { /* ignore */ }
|
|
869
|
+
if (n) {
|
|
870
|
+
const root = this.parentElement?.parentElement?.parentElement || this.getRootNode?.()?.host;
|
|
871
|
+
const allCards = root?.$$ ? root.$$('chat-item') : (this.parentElement?.querySelectorAll?.('chat-item') || []);
|
|
872
|
+
for (const other of allCards) {
|
|
873
|
+
if (other && other !== this && other.expanded)
|
|
874
|
+
other.expanded = false;
|
|
875
|
+
}
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
this._expandedFile = null;
|
|
879
|
+
if (!this._rebindClosing) {
|
|
880
|
+
let p = this.parentElement || this.host || this.getRootNode?.()?.host;
|
|
881
|
+
while (p && p.localName !== 'chat-day')
|
|
882
|
+
p = p.parentElement || p.host || p.getRootNode?.()?.host;
|
|
883
|
+
const myId = this._currentItemIdentity || '';
|
|
884
|
+
if (p && p._expandedTaskKey && myId === 'task:' + p._expandedTaskKey)
|
|
885
|
+
p._expandedTaskKey = '';
|
|
886
|
+
}
|
|
887
|
+
this.bodyHeader = false;
|
|
888
|
+
this._resetBodyCache();
|
|
889
|
+
},
|
|
890
|
+
},
|
|
891
|
+
get isAgentSender() {
|
|
892
|
+
if (this.log?.sender === '$twin' || this.log?.chatMessage?.sender === '$twin')
|
|
893
|
+
return true;
|
|
894
|
+
if (this.log?.sender === 'WORK')
|
|
895
|
+
return true;
|
|
896
|
+
const act = String(this.log?.actor || '');
|
|
897
|
+
if (act === 'AI' || act.startsWith('/MODULES/Модели/'))
|
|
898
|
+
return true;
|
|
899
|
+
if (Array.isArray(this.log?.receivers) && this.log?.receivers.length === 1 && this.log.receivers[0] === this.log?.sender && !this.log?.path)
|
|
900
|
+
return true;
|
|
901
|
+
return false;
|
|
902
|
+
},
|
|
903
|
+
get agentSenderTitle() {
|
|
904
|
+
if (this.log?.sender === '$twin' || this.log?.chatMessage?.sender === '$twin') {
|
|
905
|
+
const nl = this.log?.chatMessage?.nodeLabel;
|
|
906
|
+
return nl ? `Цифровой двойник «${nl}»` : 'Цифровой двойник узла';
|
|
907
|
+
}
|
|
908
|
+
if (this.log?.sender === 'WORK')
|
|
909
|
+
return 'Система WORK';
|
|
910
|
+
const act = String(this.log?.actor || '');
|
|
911
|
+
if (this.log?.actorLabel)
|
|
912
|
+
return String(this.log.actorLabel);
|
|
913
|
+
if (act.startsWith('/MODULES/Модели/'))
|
|
914
|
+
return 'ИИ-агент (' + act.split('/').pop() + ')';
|
|
915
|
+
return 'ИИ-агент WORK';
|
|
916
|
+
},
|
|
917
|
+
get approvalStatus() {
|
|
918
|
+
return this.log?.chatMessage?.meta?.status || 'pending';
|
|
919
|
+
},
|
|
920
|
+
async _resolveChatApproval(action) {
|
|
921
|
+
const cm = this.log?.chatMessage;
|
|
922
|
+
if (!cm?.id || !cm?.threadId)
|
|
923
|
+
return;
|
|
924
|
+
const owner = this._resolveFeedOwner();
|
|
925
|
+
if (!owner?.fetch)
|
|
926
|
+
return;
|
|
927
|
+
try {
|
|
928
|
+
const res = await owner.fetch('chat_action', { threadId: cm.threadId, messageId: cm.id, action });
|
|
929
|
+
if (res?.meta) {
|
|
930
|
+
this.log = {
|
|
931
|
+
...this.log,
|
|
932
|
+
chatMessage: { ...cm, meta: res.meta },
|
|
933
|
+
};
|
|
934
|
+
this.render?.();
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
catch (err) {
|
|
938
|
+
console.warn('[chat-item] chat_action:', err);
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
get isSender(){
|
|
942
|
+
if (this.isAgentSender)
|
|
943
|
+
return false;
|
|
944
|
+
return this.senderId === WORK.uid;
|
|
945
|
+
},
|
|
946
|
+
get isTask() {
|
|
947
|
+
const ext = String(this.ext || this.log?.ext || this.$file?.ext || '').toLowerCase();
|
|
948
|
+
if (ext === 'task')
|
|
949
|
+
return true;
|
|
950
|
+
const p = String(this.log?.path || this.$item?.path || this.$item?.id || '');
|
|
951
|
+
return p.endsWith('.task');
|
|
952
|
+
},
|
|
953
|
+
get isOperationLog() {
|
|
954
|
+
const ext = String(this.log?.ext || '').toLowerCase();
|
|
955
|
+
return ext === 'operation' || ext === 'object';
|
|
956
|
+
},
|
|
957
|
+
/**
|
|
958
|
+
* Раскладка на ленте чата:
|
|
959
|
+
* - исходящие от текущего пользователя (isSender && !isTask) — справа;
|
|
960
|
+
* - входящие от других пользователей / двойника (!isSender && !isTask) — слева;
|
|
961
|
+
* - задачи ИИ (isTask) — по центру с отступом слева и справа.
|
|
962
|
+
*/
|
|
963
|
+
get cardLayoutStyle() {
|
|
964
|
+
if (this.expanded || this.compact) {
|
|
965
|
+
return { order: 1 };
|
|
966
|
+
}
|
|
967
|
+
if (this.isTask) {
|
|
968
|
+
return {
|
|
969
|
+
order: 1,
|
|
970
|
+
marginLeft: 'auto',
|
|
971
|
+
marginRight: 'auto',
|
|
972
|
+
width: '100%',
|
|
973
|
+
maxWidth: 'min(820px, 100%)',
|
|
974
|
+
boxSizing: 'border-box',
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
if (this.isSender) {
|
|
978
|
+
return {
|
|
979
|
+
order: 1,
|
|
980
|
+
marginLeft: 'auto',
|
|
981
|
+
marginRight: '0px',
|
|
982
|
+
maxWidth: '78%',
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
return {
|
|
986
|
+
order: 1,
|
|
987
|
+
marginLeft: '0px',
|
|
988
|
+
marginRight: 'auto',
|
|
989
|
+
maxWidth: '78%',
|
|
990
|
+
};
|
|
991
|
+
},
|
|
992
|
+
async onCardTap(e) {
|
|
993
|
+
if (!this.isOperationLog || !this.log)
|
|
994
|
+
return;
|
|
995
|
+
e?.stopPropagation?.();
|
|
996
|
+
const rawPath = String(this.log.path || '');
|
|
997
|
+
const classPath = this.log.classPath || rawPath.split('/').slice(0, -1).join('/');
|
|
998
|
+
const objectId = this.log.objectId || rawPath.split('/').pop();
|
|
999
|
+
if (!classPath || !objectId)
|
|
1000
|
+
return;
|
|
1001
|
+
const clsItem = await WORK.get_item(classPath).catch(() => null);
|
|
1002
|
+
if (!clsItem)
|
|
1003
|
+
return;
|
|
1004
|
+
const wf = document.querySelector?.('pages-form')?.$?.('work-form') || this.domHost?.domHost;
|
|
1005
|
+
if (wf && typeof wf.openFormTab === 'function')
|
|
1006
|
+
await wf.openFormTab(clsItem, { view: 'objects/object', objectId });
|
|
1007
|
+
else if (typeof window.top?.execute === 'function')
|
|
1008
|
+
window.top.execute(clsItem, { view: 'objects/object', objectId });
|
|
1009
|
+
},
|
|
1010
|
+
colorMode: {
|
|
1011
|
+
$def: 'light',
|
|
1012
|
+
set(n) {
|
|
1013
|
+
const targets = [this.$('.card'), this.$('.body')].filter(Boolean);
|
|
1014
|
+
if (this._color) {
|
|
1015
|
+
for (const el of targets)
|
|
1016
|
+
el.removeAttribute(this._color);
|
|
1017
|
+
}
|
|
1018
|
+
this._color = n || '';
|
|
1019
|
+
if (this._color) {
|
|
1020
|
+
for (const el of targets)
|
|
1021
|
+
el.setAttribute(this._color, '');
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
},
|
|
1025
|
+
attached() {
|
|
1026
|
+
this.async(() => {
|
|
1027
|
+
this.colorMode = this._color || 'light';
|
|
1028
|
+
});
|
|
1029
|
+
this._watchLog();
|
|
1030
|
+
this._revealIfReady();
|
|
1031
|
+
},
|
|
1032
|
+
history: {
|
|
1033
|
+
$attr: true,
|
|
1034
|
+
$def: false,
|
|
1035
|
+
set(n) {
|
|
1036
|
+
if (n)
|
|
1037
|
+
this.applyHistoryFile();
|
|
1038
|
+
}
|
|
1039
|
+
},
|
|
1040
|
+
compact: {
|
|
1041
|
+
$attr: true,
|
|
1042
|
+
$def: false,
|
|
1043
|
+
},
|
|
1044
|
+
visible:{
|
|
1045
|
+
$def: false,
|
|
1046
|
+
$attr: true,
|
|
1047
|
+
},
|
|
1048
|
+
previewIsReady: false,
|
|
1049
|
+
senderIsReady: false,
|
|
1050
|
+
_senderFromRef(ref) {
|
|
1051
|
+
if (!ref) return '';
|
|
1052
|
+
const path = ref.path;
|
|
1053
|
+
if (path) {
|
|
1054
|
+
const parsed = CORE.$file.parseHistoryEntryPath(path);
|
|
1055
|
+
if (parsed?.userId) return parsed.userId;
|
|
1056
|
+
}
|
|
1057
|
+
const id = ref.id || (path ? String(path).split('/').pop() : '') || '';
|
|
1058
|
+
const extDot = id.lastIndexOf('.');
|
|
1059
|
+
const name = extDot > 0 ? id.slice(0, extDot) : id;
|
|
1060
|
+
const nameParts = name.split('.');
|
|
1061
|
+
if (nameParts.length > 1 && /^\d+$/.test(nameParts[0]))
|
|
1062
|
+
return nameParts.slice(1).join('.');
|
|
1063
|
+
return '';
|
|
1064
|
+
},
|
|
1065
|
+
_applySenderFromRef(ref) {
|
|
1066
|
+
const uid = this._senderFromRef(ref);
|
|
1067
|
+
if (uid)
|
|
1068
|
+
this.senderId = uid;
|
|
1069
|
+
else if (!ref)
|
|
1070
|
+
this._markSenderReady();
|
|
1071
|
+
},
|
|
1072
|
+
_markSenderReady() {
|
|
1073
|
+
this.senderIsReady = true;
|
|
1074
|
+
this._revealIfReady();
|
|
1075
|
+
},
|
|
1076
|
+
_revealIfReady() {
|
|
1077
|
+
if (this.senderIsReady)
|
|
1078
|
+
this.visible = true;
|
|
1079
|
+
},
|
|
1080
|
+
previewTag: 'item-node',
|
|
1081
|
+
hasPreview: false,
|
|
1082
|
+
missingTargetPath: '',
|
|
1083
|
+
get hasTargetFilePath() {
|
|
1084
|
+
const p = String(this.log?.path || '').trim();
|
|
1085
|
+
const ext = String(this.log?.ext || '').toLowerCase();
|
|
1086
|
+
return Boolean(p && !p.endsWith('.logs') && ext !== 'operation' && ext !== 'object');
|
|
1087
|
+
},
|
|
1088
|
+
get missingTargetLabel() {
|
|
1089
|
+
const p = String(this.missingTargetPath || '').trim();
|
|
1090
|
+
if (!p)
|
|
1091
|
+
return '';
|
|
1092
|
+
return p.split('/').filter(Boolean).pop() || p;
|
|
1093
|
+
},
|
|
1094
|
+
_resolveFeedOwner() {
|
|
1095
|
+
let p = this.parentElement || this.host || this.getRootNode?.()?.host;
|
|
1096
|
+
while (p) {
|
|
1097
|
+
const candidate = p.$item;
|
|
1098
|
+
if (candidate && candidate !== this.$item && typeof candidate.fetch === 'function')
|
|
1099
|
+
return candidate;
|
|
1100
|
+
p = p.parentElement || p.host || p.getRootNode?.()?.host;
|
|
1101
|
+
}
|
|
1102
|
+
const wf = typeof document !== 'undefined' ? document.querySelector?.('pages-form')?.$?.('work-form') : null;
|
|
1103
|
+
if (wf?.currentItem && typeof wf.currentItem.fetch === 'function')
|
|
1104
|
+
return wf.currentItem;
|
|
1105
|
+
if (typeof window !== 'undefined' && window.$context && typeof window.$context.fetch === 'function')
|
|
1106
|
+
return window.$context;
|
|
1107
|
+
return globalThis.WORK;
|
|
1108
|
+
},
|
|
1109
|
+
get isAdminRole() {
|
|
1110
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
1111
|
+
return true;
|
|
1112
|
+
const owner = this._resolveFeedOwner();
|
|
1113
|
+
if (owner?.type === '$user')
|
|
1114
|
+
return true;
|
|
1115
|
+
if (this.log?.sender && globalThis.WORK?.uid && this.log.sender === globalThis.WORK.uid)
|
|
1116
|
+
return true;
|
|
1117
|
+
const pdpRole = owner?.role;
|
|
1118
|
+
if (pdpRole)
|
|
1119
|
+
return pdpRole === 'BOSS';
|
|
1120
|
+
const wf = typeof document !== 'undefined' ? document.querySelector?.('pages-form')?.$?.('work-form') : null;
|
|
1121
|
+
if (wf?.activeRole)
|
|
1122
|
+
return wf.activeRole === 'BOSS';
|
|
1123
|
+
return true;
|
|
1124
|
+
},
|
|
1125
|
+
async deleteMissingLog(e) {
|
|
1126
|
+
e?.stopPropagation?.();
|
|
1127
|
+
e?.preventDefault?.();
|
|
1128
|
+
const owner = this._resolveFeedOwner();
|
|
1129
|
+
if (!owner || typeof owner.fetch !== 'function')
|
|
1130
|
+
return;
|
|
1131
|
+
const payload = {
|
|
1132
|
+
stubPath: this.log?.logsFilePath || this.$item?.path || '',
|
|
1133
|
+
path: this.missingTargetPath || this.log?.path || '',
|
|
1134
|
+
time: this.log?.time || 0,
|
|
1135
|
+
sender: this.log?.sender || '',
|
|
1136
|
+
};
|
|
1137
|
+
try {
|
|
1138
|
+
await owner.fetch('delete_log_entry', { ...payload, role: 'BOSS' });
|
|
1139
|
+
let p = this.parentElement || this.host || this.getRootNode?.()?.host;
|
|
1140
|
+
while (p && p.localName !== 'chat-day')
|
|
1141
|
+
p = p.parentElement || p.host || p.getRootNode?.()?.host;
|
|
1142
|
+
this.style.display = 'none';
|
|
1143
|
+
if (p && Array.isArray(p.logItems)) {
|
|
1144
|
+
const curId = this.$item?.id;
|
|
1145
|
+
const targetPath = this.missingTargetPath || this.log?.path || '';
|
|
1146
|
+
if (curId && p._wrappedById instanceof Map)
|
|
1147
|
+
p._wrappedById.delete(curId);
|
|
1148
|
+
p.logItems = p.logItems.filter(it => {
|
|
1149
|
+
if (it === this.$item)
|
|
1150
|
+
return false;
|
|
1151
|
+
if (curId && it?.id === curId)
|
|
1152
|
+
return false;
|
|
1153
|
+
if (targetPath && (it?.path === targetPath || it?.logRow?.path === targetPath))
|
|
1154
|
+
return false;
|
|
1155
|
+
return true;
|
|
1156
|
+
});
|
|
1157
|
+
p.invalidate?.('logs');
|
|
1158
|
+
p.render?.();
|
|
1159
|
+
}
|
|
1160
|
+
this.remove?.();
|
|
1161
|
+
}
|
|
1162
|
+
catch (err) {
|
|
1163
|
+
console.warn('[chat-item] delete_log_entry:', err);
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
_bodyCacheKeys: ['itemBody', 'fileLabel', 'fileTime', 'shortTime', 'sender', 'senderDisplayName', 'log', 'logContent', 'isText', 'hideAvatar', 'attachmentItems', 'replyInfo', 'isBubble'],
|
|
1167
|
+
_resetBodyCache() {
|
|
1168
|
+
this.invalidate(...this._bodyCacheKeys);
|
|
1169
|
+
},
|
|
1170
|
+
log: null,
|
|
1171
|
+
get logContent() {
|
|
1172
|
+
return this.log?.content ?? '';
|
|
1173
|
+
},
|
|
1174
|
+
get isText() {
|
|
1175
|
+
return this.ext === 'txt' || this.ext === 'md';
|
|
1176
|
+
},
|
|
1177
|
+
get fileTime() {
|
|
1178
|
+
if (this.compact)
|
|
1179
|
+
return '';
|
|
1180
|
+
return Promise.resolve(this.itemBody).then(body => {
|
|
1181
|
+
const ms = +(body?.time || this.log?.time);
|
|
1182
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
1183
|
+
return '';
|
|
1184
|
+
const d = new Date(ms);
|
|
1185
|
+
if (isNaN(d))
|
|
1186
|
+
return '';
|
|
1187
|
+
const time = d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
1188
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
1189
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
1190
|
+
return dd + '.' + mm + ' ' + time;
|
|
1191
|
+
});
|
|
1192
|
+
},
|
|
1193
|
+
get ext() {
|
|
1194
|
+
if (this._includeFile?.ext)
|
|
1195
|
+
return this._includeFile.ext;
|
|
1196
|
+
const path = this.log?.path || this._includeFile?.path || '';
|
|
1197
|
+
const id = String(path).split('/').pop() || '';
|
|
1198
|
+
const idx = id.lastIndexOf('.');
|
|
1199
|
+
return idx > -1 ? id.slice(idx + 1) : '';
|
|
1200
|
+
},
|
|
1201
|
+
async buildHistoryBody($file) {
|
|
1202
|
+
$file = await Promise.resolve($file);
|
|
1203
|
+
if (!$file?.path)
|
|
1204
|
+
return null;
|
|
1205
|
+
const parsed = CORE.$file.parseHistoryEntryPath($file.path) || {};
|
|
1206
|
+
return {
|
|
1207
|
+
path: $file.path,
|
|
1208
|
+
time: +parsed.timestamp || 0,
|
|
1209
|
+
sender: parsed.userId || '',
|
|
1210
|
+
type: '$file',
|
|
1211
|
+
ext: this.ext,
|
|
1212
|
+
};
|
|
1213
|
+
},
|
|
1214
|
+
isHistoryFile($file = this._includeFile) {
|
|
1215
|
+
return !!$file?.path?.includes('/history/');
|
|
1216
|
+
},
|
|
1217
|
+
async applyHistoryFile() {
|
|
1218
|
+
if (!this.history || !this._includeFile)
|
|
1219
|
+
return null;
|
|
1220
|
+
const body = await this.buildHistoryBody(this._includeFile);
|
|
1221
|
+
if (!body)
|
|
1222
|
+
return null;
|
|
1223
|
+
this._historyBody = body;
|
|
1224
|
+
if (body.sender)
|
|
1225
|
+
this.senderId = body.sender;
|
|
1226
|
+
else
|
|
1227
|
+
this._markSenderReady();
|
|
1228
|
+
this.log = body;
|
|
1229
|
+
this.previewIsReady = true;
|
|
1230
|
+
this.render();
|
|
1231
|
+
return body;
|
|
1232
|
+
},
|
|
1233
|
+
get itemBody() {
|
|
1234
|
+
if (this.log?.time)
|
|
1235
|
+
return Promise.resolve(this.log);
|
|
1236
|
+
if (this.history && this._includeFile) {
|
|
1237
|
+
if (this._historyBody)
|
|
1238
|
+
return Promise.resolve(this._historyBody);
|
|
1239
|
+
return this.applyHistoryFile().catch(e => {
|
|
1240
|
+
console.warn('[chat-item] history', e);
|
|
1241
|
+
return null;
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
return Promise.resolve(this.$item).then(item => {
|
|
1245
|
+
if (!item)
|
|
1246
|
+
return null;
|
|
1247
|
+
if (typeof item.load !== 'function')
|
|
1248
|
+
return null;
|
|
1249
|
+
return item.load().then(raw => {
|
|
1250
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1251
|
+
if (!data.path && item.path && item.ext !== 'logs')
|
|
1252
|
+
data.path = item.path;
|
|
1253
|
+
// сам .task-файл (карточка принята в ленту напрямую): время — из имени файла <мс>.<uid>.task, как у записи журнала
|
|
1254
|
+
if (!data.time && item.ext === 'task') {
|
|
1255
|
+
const ts = parseInt(String(item.id || '').split('.')[0], 10);
|
|
1256
|
+
if (ts > 0)
|
|
1257
|
+
data.time = ts;
|
|
1258
|
+
}
|
|
1259
|
+
if (data.sender && !this.senderIsReady)
|
|
1260
|
+
this.senderId = data.sender;
|
|
1261
|
+
else if (!this.senderIsReady)
|
|
1262
|
+
this._markSenderReady();
|
|
1263
|
+
this.previewIsReady = true;
|
|
1264
|
+
this.log = data;
|
|
1265
|
+
this.render();
|
|
1266
|
+
return data;
|
|
1267
|
+
}).catch(e => {
|
|
1268
|
+
console.warn('[chat-item] load', e);
|
|
1269
|
+
return null;
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1272
|
+
},
|
|
1273
|
+
get fileLabel() {
|
|
1274
|
+
if (this._expandedFile?.path)
|
|
1275
|
+
return this._labelForItem(this._expandedFile.path, this._expandedFile);
|
|
1276
|
+
if (this._includeFile?.path)
|
|
1277
|
+
return this._labelForItem(this._includeFile.path, this._includeFile);
|
|
1278
|
+
return Promise.resolve(this.itemBody).then(body => this._labelForLog(body));
|
|
1279
|
+
},
|
|
1280
|
+
_labelForItem(path, file) {
|
|
1281
|
+
if (String(path || '').includes('/history/'))
|
|
1282
|
+
return CORE.historyEntryLabel(path);
|
|
1283
|
+
const ext = String(file?.ext || this.ext || '').toLowerCase();
|
|
1284
|
+
if (this.compact && !['task', 'ics', 'eml'].includes(ext))
|
|
1285
|
+
return file?.DATA?.label || file?.id || String(path || '').split('/').pop() || '';
|
|
1286
|
+
return this._nameFromDataFile(file);
|
|
1287
|
+
},
|
|
1288
|
+
async _labelForLog(body) {
|
|
1289
|
+
if (!body)
|
|
1290
|
+
return '';
|
|
1291
|
+
if (body.chatMessage) {
|
|
1292
|
+
if (body.chatMessage.kind === 'approval')
|
|
1293
|
+
return 'Запрос подтверждения';
|
|
1294
|
+
return body.chatMessage.sender === '$twin' ? (body.chatMessage.nodeLabel ? `Двойник «${body.chatMessage.nodeLabel}»` : 'Цифровой двойник') : '';
|
|
1295
|
+
}
|
|
1296
|
+
if (String(body.path || '').includes('/history/'))
|
|
1297
|
+
return CORE.historyEntryLabel(body.path);
|
|
1298
|
+
try {
|
|
1299
|
+
const raw = body.content;
|
|
1300
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1301
|
+
if (data?.name)
|
|
1302
|
+
return data.name;
|
|
1303
|
+
} catch { /* content не JSON точки */ }
|
|
1304
|
+
return (await this._nameFromDataFile(await this.$file)) || body.ext || '';
|
|
1305
|
+
},
|
|
1306
|
+
async _nameFromDataFile(file) {
|
|
1307
|
+
const ext = String(file?.ext || '').toLowerCase();
|
|
1308
|
+
if (!['task', 'ics', 'eml'].includes(ext))
|
|
1309
|
+
return file?.DATA?.label || file?.id || file?.ext || '';
|
|
1310
|
+
if (!file?.load)
|
|
1311
|
+
return file?.ext || '';
|
|
1312
|
+
try {
|
|
1313
|
+
const raw = await file.load();
|
|
1314
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1315
|
+
if (data?.name)
|
|
1316
|
+
return data.name;
|
|
1317
|
+
} catch { /* не JSON */ }
|
|
1318
|
+
return file.ext || '';
|
|
1319
|
+
},
|
|
1320
|
+
async loadPreview($file) {
|
|
1321
|
+
if (!$file) {
|
|
1322
|
+
this.hasPreview = !this.compact;
|
|
1323
|
+
this.previewIsReady = true;
|
|
1324
|
+
this.render();
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const ext = String($file?.ext || this.ext || '').toLowerCase();
|
|
1328
|
+
if (this.compact || !CHAT_PREVIEW_EXTS.has(ext)) {
|
|
1329
|
+
this.hasPreview = false;
|
|
1330
|
+
this.previewTag = 'item-node';
|
|
1331
|
+
this.previousElementSibling?.invalidate?.('hideAvatar');
|
|
1332
|
+
this.previewIsReady = true;
|
|
1333
|
+
this.render();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
try {
|
|
1337
|
+
this.hasPreview = await CORE.$file.loadPreview($file);
|
|
1338
|
+
if (this.hasPreview)
|
|
1339
|
+
this.previewTag = ($file?.ext || 'file') + '-preview';
|
|
1340
|
+
else
|
|
1341
|
+
this.previewTag = 'item-node';
|
|
1342
|
+
}
|
|
1343
|
+
catch (e) {
|
|
1344
|
+
console.warn('[chat-item] loadPreview error:', e.message);
|
|
1345
|
+
this.hasPreview = false;
|
|
1346
|
+
this.previewTag = 'item-node';
|
|
1347
|
+
}
|
|
1348
|
+
finally {
|
|
1349
|
+
// соседа DOM реактивность не видит — hideAvatar предыдущей карточки сбрасываем явно
|
|
1350
|
+
this.previousElementSibling?.invalidate?.('hideAvatar');
|
|
1351
|
+
this.previewIsReady = true;
|
|
1352
|
+
this.render();
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
$file: {
|
|
1356
|
+
get() {
|
|
1357
|
+
if (this._includeFile)
|
|
1358
|
+
return this._includeFile;
|
|
1359
|
+
if (this.history || (!this.$item && !this.log?.path))
|
|
1360
|
+
return null;
|
|
1361
|
+
// Если $item уже является самим файлом .task (принят через adoptTask), используем его напрямую без ожидания itemBody
|
|
1362
|
+
if (this.$item && !this.$item.logRow && (this.$item.ext === 'task' || String(this.$item.id || '').endsWith('.task'))) {
|
|
1363
|
+
const taskFile = this.$item;
|
|
1364
|
+
this.missingTargetPath = '';
|
|
1365
|
+
return this.loadPreview(taskFile).then(() => taskFile);
|
|
1366
|
+
}
|
|
1367
|
+
return Promise.resolve(this.itemBody).then(async body => {
|
|
1368
|
+
if (body?.chatMessage)
|
|
1369
|
+
return null;
|
|
1370
|
+
if (!body?.path || String(body.path).endsWith('.logs') || body?.ext === 'operation' || body?.ext === 'object') {
|
|
1371
|
+
if (body?.ext === 'operation' || body?.ext === 'object')
|
|
1372
|
+
this.hasPreview = true;
|
|
1373
|
+
return null;
|
|
1374
|
+
}
|
|
1375
|
+
let $file = null;
|
|
1376
|
+
try {
|
|
1377
|
+
$file = await WORK.get_item(body.path, 'info');
|
|
1378
|
+
}
|
|
1379
|
+
catch {
|
|
1380
|
+
$file = null;
|
|
1381
|
+
}
|
|
1382
|
+
if (!$file || (typeof $file === 'object' && !$file.path && !$file.id && !$file.type)) {
|
|
1383
|
+
this.missingTargetPath = String(body.path);
|
|
1384
|
+
this.hasPreview = false;
|
|
1385
|
+
this.previewIsReady = true;
|
|
1386
|
+
this.render();
|
|
1387
|
+
return null;
|
|
1388
|
+
}
|
|
1389
|
+
this.missingTargetPath = '';
|
|
1390
|
+
if ($file && !$file.id && $file.path) {
|
|
1391
|
+
$file.DATA ??= {};
|
|
1392
|
+
$file.DATA.id = $file.path.split('/').pop();
|
|
1393
|
+
}
|
|
1394
|
+
await this.loadPreview($file);
|
|
1395
|
+
return $file;
|
|
1396
|
+
})
|
|
1397
|
+
},
|
|
1398
|
+
set($file) {
|
|
1399
|
+
const run = async (file) => {
|
|
1400
|
+
if (file && this._includeFile === file && (this.previewIsReady || this._loadingIncludeFile === file))
|
|
1401
|
+
return;
|
|
1402
|
+
this._loadingIncludeFile = file;
|
|
1403
|
+
this._includeFile = file;
|
|
1404
|
+
this._historyBody = null;
|
|
1405
|
+
this._resetBodyCache();
|
|
1406
|
+
if (this[R]?.cache)
|
|
1407
|
+
this[R].cache.$file = file;
|
|
1408
|
+
this.previewIsReady = false;
|
|
1409
|
+
this.senderIsReady = false;
|
|
1410
|
+
this._applySenderFromRef(file);
|
|
1411
|
+
await this.loadPreview(file);
|
|
1412
|
+
if (this.history) {
|
|
1413
|
+
await this.applyHistoryFile();
|
|
1414
|
+
}
|
|
1415
|
+
else if (this.log?.time) {
|
|
1416
|
+
this.previewIsReady = true;
|
|
1417
|
+
this.render();
|
|
1418
|
+
}
|
|
1419
|
+
if (this[R]?.cache && this._includeFile === file)
|
|
1420
|
+
this[R].cache.$file = file;
|
|
1421
|
+
};
|
|
1422
|
+
if ($file != null && typeof $file.then === 'function')
|
|
1423
|
+
$file.then(run).catch(() => {});
|
|
1424
|
+
else
|
|
1425
|
+
run($file).catch(() => {});
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
_identityOfItem(item) {
|
|
1429
|
+
if (!item)
|
|
1430
|
+
return '';
|
|
1431
|
+
const targetPath = String(item.logRow?.path || item.DATA?.logRow?.path || item.path || '');
|
|
1432
|
+
const taskMatch = targetPath.match(/([^/\\]+\.task)$/i) || String(item.id || '').match(/([^/\\]+\.task)$/i);
|
|
1433
|
+
if (taskMatch)
|
|
1434
|
+
return 'task:' + taskMatch[1];
|
|
1435
|
+
const logsTask = String(item.id || '').replace(/\.logs$/i, '.task');
|
|
1436
|
+
if (logsTask.endsWith('.task') && (item.logRow?.ext === 'task' || item.DATA?.logRow?.ext === 'task'))
|
|
1437
|
+
return 'task:' + logsTask;
|
|
1438
|
+
return String(item.path || item.id || '');
|
|
1439
|
+
},
|
|
1440
|
+
$item: {
|
|
1441
|
+
$def: null,
|
|
1442
|
+
set(n) {
|
|
1443
|
+
const nextKey = n ? String(n.path || n.id || '') : '';
|
|
1444
|
+
const nextIdentity = this._identityOfItem(n);
|
|
1445
|
+
if (this._currentItemIdentity && nextIdentity !== this._currentItemIdentity && this.expanded) {
|
|
1446
|
+
this._rebindClosing = true;
|
|
1447
|
+
try {
|
|
1448
|
+
this.expanded = false;
|
|
1449
|
+
}
|
|
1450
|
+
finally {
|
|
1451
|
+
this._rebindClosing = false;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
this._currentItemIdentity = nextIdentity;
|
|
1455
|
+
if (nextKey && this._currentItemKey === nextKey && this.log) {
|
|
1456
|
+
const nextRow = n?.logRow || n?.DATA?.logRow;
|
|
1457
|
+
if (nextRow && typeof nextRow === 'object' && typeof nextRow.then !== 'function') {
|
|
1458
|
+
this.log = { ...nextRow };
|
|
1459
|
+
this.invalidate('sender', 'isAgentSender', 'isTask', 'isCall', 'fileLabel', 'fileTime', 'shortTime', 'logContent', 'attachmentItems', 'replyInfo', 'isPending', 'sendError', 'isEdited', 'isReadByPeer', 'cmId', 'isBubble');
|
|
1460
|
+
this.render?.();
|
|
1461
|
+
}
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
this._currentItemKey = nextKey;
|
|
1465
|
+
this.missingTargetPath = '';
|
|
1466
|
+
this._attCache = null;
|
|
1467
|
+
this._attLoading = null;
|
|
1468
|
+
this._resolvedSenderObj = null;
|
|
1469
|
+
this._hasResolvedSender = false;
|
|
1470
|
+
this._resetBodyCache();
|
|
1471
|
+
this.previewIsReady = false;
|
|
1472
|
+
this.senderIsReady = false;
|
|
1473
|
+
this._includeFile = null;
|
|
1474
|
+
this.log = null;
|
|
1475
|
+
this._unwatchLog();
|
|
1476
|
+
this._applySenderFromRef(n);
|
|
1477
|
+
const logRow = n?.logRow || n?.DATA?.logRow;
|
|
1478
|
+
if (logRow && typeof logRow === 'object' && typeof logRow.then !== 'function') {
|
|
1479
|
+
const data = { ...logRow };
|
|
1480
|
+
this.log = data;
|
|
1481
|
+
this.invalidate('sender', 'isAgentSender', 'isTask', 'isCall', 'fileLabel', 'fileTime', 'shortTime', 'logContent', 'attachmentItems', 'replyInfo', 'isPending', 'sendError', 'isEdited', 'isReadByPeer', 'cmId', 'isBubble');
|
|
1482
|
+
if (data.sender && !this.senderIsReady)
|
|
1483
|
+
this.senderId = data.sender;
|
|
1484
|
+
else if (!this.senderIsReady)
|
|
1485
|
+
this._markSenderReady();
|
|
1486
|
+
this.previewIsReady = true;
|
|
1487
|
+
this.render();
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
if (n?.listen && n?.id?.endsWith?.('.logs')) {
|
|
1491
|
+
const applyLog = raw => {
|
|
1492
|
+
const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
1493
|
+
if (!data?.time)
|
|
1494
|
+
return;
|
|
1495
|
+
this.log = { ...data };
|
|
1496
|
+
this.invalidate('sender', 'isAgentSender', 'isTask', 'isCall', 'fileLabel', 'fileTime', 'shortTime', 'logContent', 'attachmentItems', 'replyInfo', 'isPending', 'sendError', 'isEdited', 'isReadByPeer', 'cmId', 'isBubble');
|
|
1497
|
+
if (data.sender && !this.senderIsReady)
|
|
1498
|
+
this.senderId = data.sender;
|
|
1499
|
+
else if (!this.senderIsReady)
|
|
1500
|
+
this._markSenderReady();
|
|
1501
|
+
this.render();
|
|
1502
|
+
};
|
|
1503
|
+
if (typeof n.load === 'function') {
|
|
1504
|
+
n.load().then(applyLog).catch(() => {});
|
|
1505
|
+
}
|
|
1506
|
+
this._watched = { item: n, fn: () => n.load().then(applyLog).catch(() => {}) };
|
|
1507
|
+
this._watchLog();
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
/** Подписка на изменения записи: ровно одна, снимается при смене элемента и уходе из DOM. */
|
|
1512
|
+
_watchLog() {
|
|
1513
|
+
const w = this._watched;
|
|
1514
|
+
if (w && !w.on) {
|
|
1515
|
+
w.item.listen('changed', w.fn);
|
|
1516
|
+
w.on = true;
|
|
1517
|
+
}
|
|
1518
|
+
},
|
|
1519
|
+
_unwatchLog() {
|
|
1520
|
+
const w = this._watched;
|
|
1521
|
+
if (w?.on)
|
|
1522
|
+
w.item.unlisten('changed', w.fn);
|
|
1523
|
+
this._watched = null;
|
|
1524
|
+
},
|
|
1525
|
+
detached() {
|
|
1526
|
+
const w = this._watched;
|
|
1527
|
+
if (w?.on) {
|
|
1528
|
+
w.item.unlisten('changed', w.fn);
|
|
1529
|
+
w.on = false;
|
|
1530
|
+
}
|
|
1531
|
+
try {
|
|
1532
|
+
this.dispatchEvent(new CustomEvent('chat-item-expanded', {
|
|
1533
|
+
bubbles: true,
|
|
1534
|
+
composed: true,
|
|
1535
|
+
detail: { expanded: false, card: this },
|
|
1536
|
+
}));
|
|
1537
|
+
}
|
|
1538
|
+
catch { /* ignore */ }
|
|
1539
|
+
},
|
|
1540
|
+
senderId: {
|
|
1541
|
+
$type: String,
|
|
1542
|
+
set(n) {
|
|
1543
|
+
this.senderIsReady = true;
|
|
1544
|
+
this._revealIfReady();
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
_hasResolvedSender: false,
|
|
1548
|
+
get hasSenderAvatar() {
|
|
1549
|
+
return Boolean(this.isAgentSender || this._hasResolvedSender);
|
|
1550
|
+
},
|
|
1551
|
+
get sender() {
|
|
1552
|
+
return Promise.resolve(this.itemBody).then(async body => {
|
|
1553
|
+
if (this.isAgentSender) {
|
|
1554
|
+
this._hasResolvedSender = false;
|
|
1555
|
+
if (!this.senderIsReady)
|
|
1556
|
+
this._markSenderReady();
|
|
1557
|
+
return null;
|
|
1558
|
+
}
|
|
1559
|
+
if (!body?.sender) {
|
|
1560
|
+
this._hasResolvedSender = false;
|
|
1561
|
+
if (!this.senderIsReady)
|
|
1562
|
+
this._markSenderReady();
|
|
1563
|
+
return null;
|
|
1564
|
+
}
|
|
1565
|
+
let users = await WORK.users;
|
|
1566
|
+
const found = users.find(u => u.id === body.sender) || null;
|
|
1567
|
+
this._resolvedSenderObj = found;
|
|
1568
|
+
this._hasResolvedSender = Boolean(found);
|
|
1569
|
+
this.senderId = body.sender;
|
|
1570
|
+
this.invalidate?.('hasSenderAvatar', 'senderDisplayName');
|
|
1571
|
+
this.render?.();
|
|
1572
|
+
return found;
|
|
1573
|
+
})
|
|
1574
|
+
},
|
|
1575
|
+
get hideAvatar() {
|
|
1576
|
+
return this.isTask;
|
|
1577
|
+
},
|
|
1578
|
+
})
|