odant-work 1.0.90 → 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/#system/package-manifest.json +275 -246
  2. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  3. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
  4. package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  5. package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
  6. package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
  7. package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
  8. package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
  9. package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
  10. package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
  11. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
  12. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
  13. package/$server/$folder/$class/$data/$register/class.js +8 -0
  14. package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
  15. package/$server/$folder/$class/$data/$struct/class.js +5 -0
  16. package/$server/$folder/$class/$data/class.js +5 -0
  17. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  18. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  19. package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
  20. package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
  21. package/$server/$folder/$class/$domain/readme.md +1 -1
  22. package/$server/$folder/$class/$handler/$method/class.js +4 -0
  23. package/$server/$folder/$class/$handler/$timer/class.js +4 -0
  24. package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
  25. package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
  26. package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
  27. package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
  28. package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
  29. package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
  30. package/$server/$folder/$class/$module/class.js +418 -6
  31. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
  32. package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
  33. package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
  34. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
  35. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
  36. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
  37. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
  38. package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
  39. package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
  40. package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
  41. package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
  42. package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
  43. package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  44. package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
  45. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
  46. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
  47. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
  48. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
  49. package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
  50. package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
  51. package/$server/$folder/$class/$structure/$project/class.js +1 -0
  52. package/$server/$folder/$class/$structure/$project/readme.md +1 -1
  53. package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
  54. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
  55. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
  56. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  57. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  58. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  59. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  60. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
  61. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  62. package/$server/$folder/$class/$structure/class.js +1 -1
  63. package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
  64. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
  65. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
  66. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  67. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  68. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  69. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
  70. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
  71. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
  72. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
  73. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
  74. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  75. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  76. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  77. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
  78. package/$server/$folder/$class/$structure/readme.md +3 -3
  79. package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
  80. package/$server/$folder/$class/$users/class.js +4 -0
  81. package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
  82. package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
  83. package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
  84. package/$server/$folder/$class/ai/agents/readme.md +1 -1
  85. package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
  86. package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
  87. package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
  88. package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
  89. package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
  90. package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
  91. package/$server/$folder/$class/ai/system.md +14 -8
  92. package/$server/$folder/$class/class.js +2 -6
  93. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  94. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  95. package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
  96. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
  97. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  98. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
  99. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
  100. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
  101. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
  102. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
  103. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  104. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  105. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  106. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
  107. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  108. package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
  109. package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
  110. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  111. package/$server/$folder/handlers/readme.md +1 -1
  112. package/$server/$folder/lib/chat-item/chat-item.js +5 -10
  113. package/$server/$folder/lib/consultant/consultant.js +7 -10
  114. package/$server/$folder/lib/explorer/explorer.js +1 -1
  115. package/$server/$folder/lib/icon/icon.js +1 -1
  116. package/$server/$folder/lib/menu/menu.js +3 -2
  117. package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
  118. package/$server/$folder/lib/node/node.js +3 -3
  119. package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
  120. package/$server/$folder/lib/role/role.js +1 -2
  121. package/$server/$folder/lib/security/admin/admin.js +3 -3
  122. package/$server/$folder/lib/security/security.js +4 -4
  123. package/$server/$folder/lib/security/users/users.js +2 -5
  124. package/$server/$folder/lib/site-loc/site-loc.js +3 -3
  125. package/$server/$folder/lib/tree/tree.js +14 -22
  126. package/$server/class.js +1 -0
  127. package/AGENTS.md +21 -13
  128. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
  129. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
  130. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  131. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
  132. package/MODULES/$domain/class.js +85 -4
  133. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
  134. package/MODULES/$domain/readme.md +7 -6
  135. package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
  136. package/MODULES/2GIS/$module/class.js +32 -0
  137. package/MODULES/2GIS/$module/readme.md +57 -0
  138. package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
  139. package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
  140. package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
  141. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
  142. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  143. package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
  144. package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
  145. package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
  146. package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
  147. package/MODULES/Process/$module/readme.md +1 -1
  148. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -6
  149. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -6
  150. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -16
  151. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
  152. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  153. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
  154. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
  155. package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
  156. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
  157. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
  158. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
  159. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
  160. package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
  161. package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
  162. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
  163. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
  164. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
  165. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
  166. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
  167. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
  168. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  169. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
  170. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  171. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
  172. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
  173. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
  174. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
  175. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
  176. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
  177. package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
  178. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
  179. package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
  180. package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
  181. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
  182. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
  183. package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
  184. package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
  185. package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
  186. package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
  187. package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
  188. package/ORGANIZATIONS/$domain/class.js +5 -5
  189. package/oda/components/inputs/link/link.js +1 -1
  190. package/package.json +1 -1
  191. package/readme.md +6 -7
  192. package/scripts/check-architecture.mjs +541 -0
  193. package/scripts/cleanup-storage.mjs +1 -1
  194. package/scripts/demo-seed.mjs +3 -3
  195. package/scripts/import-bis.mjs +33 -15
  196. package/scripts/import-delovaya.mjs +26 -14
  197. package/sources/client/class.js +19 -10
  198. package/sources/client/folder.js +10 -22
  199. package/sources/client/handler.js +75 -33
  200. package/sources/data/api.js +9 -10
  201. package/sources/data/classes.js +85 -9
  202. package/sources/data/db.js +10 -6
  203. package/sources/data/print.js +15 -41
  204. package/sources/data/readme.md +5 -5
  205. package/sources/data/schema.js +206 -118
  206. package/sources/data/sql-inspector.js +7 -7
  207. package/sources/host/auth-methods.js +2 -5
  208. package/sources/host/auto-updater.js +1 -2
  209. package/sources/host/babel-merge.js +174 -129
  210. package/sources/host/prewarm.js +1 -1
  211. package/sources/host/watch.js +1 -1
  212. package/sources/index.html +1 -1
  213. package/sources/modules/agent/extensions.js +48 -38
  214. package/sources/modules/agent/index.js +1 -1
  215. package/sources/modules/agent/node-rules.js +69 -41
  216. package/sources/modules/agent/permissions.js +1 -1
  217. package/sources/modules/agent/plugins.js +11 -11
  218. package/sources/modules/agent/resources.js +96 -52
  219. package/sources/modules/agent/tools/net.js +1 -1
  220. package/sources/modules/agent/tools/services.js +7 -7
  221. package/sources/modules/agent/tools/work/access.js +10 -8
  222. package/sources/modules/agent/tools/work/classes.js +26 -47
  223. package/sources/modules/agent/tools/work/common.js +8 -10
  224. package/sources/modules/agent/tools/work/data.js +4 -4
  225. package/sources/modules/agent/triggers.js +1 -1
  226. package/sources/modules/agent/twin-bus.js +4 -4
  227. package/sources/modules/agent/voice.js +1 -1
  228. package/sources/modules/call/call.js +4 -4
  229. package/sources/modules/kladr/index.js +3 -3
  230. package/sources/modules/lan/register.js +7 -7
  231. package/sources/modules/mcp-marketplaces/ozon.js +1 -1
  232. package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
  233. package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
  234. package/sources/modules/nodes/mount.js +2 -4
  235. package/sources/modules/notify/index.js +18 -18
  236. package/sources/modules/rag/extract.js +9 -2
  237. package/sources/modules/rag/indexer.js +1 -1
  238. package/sources/modules/rag/scope.js +7 -33
  239. package/sources/modules/trainer/dataset.js +2 -2
  240. package/sources/modules/trainer/local-engine.js +1 -1
  241. package/sources/page.html +2 -2
  242. package/sources/readme.md +1 -1
  243. package/sources/server/access/gateway.js +19 -19
  244. package/sources/server/access/invites.js +4 -5
  245. package/sources/server/access/links.js +10 -8
  246. package/sources/server/access/policy.js +65 -39
  247. package/sources/server/access/workplaces.js +20 -14
  248. package/sources/server/chat-threads.js +4 -4
  249. package/sources/server/class/archive.js +15 -15
  250. package/sources/server/class/base-template.js +13 -9
  251. package/sources/server/class/distro.js +3 -4
  252. package/sources/server/class/feed.js +3 -3
  253. package/sources/server/class/mail-calendar.js +9 -8
  254. package/sources/server/class/scaffold.js +110 -60
  255. package/sources/server/class/search.js +2 -2
  256. package/sources/server/class/security.js +76 -94
  257. package/sources/server/class.js +181 -64
  258. package/sources/server/file.js +2 -2
  259. package/sources/server/folder.js +376 -191
  260. package/sources/server/handler.js +52 -13
  261. package/sources/server/logs.js +7 -7
  262. package/sources/server/node.js +12 -43
  263. package/sources/server/server.js +16 -17
  264. package/$server/$folder/$class/$device/class.js +0 -3
  265. package/$server/$folder/$class/$handler/$task/class.js +0 -3
  266. package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
  267. package/$server/$folder/$class/$structure/$base/class.js +0 -10
  268. package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
  269. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  270. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  271. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  272. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
  273. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  274. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  275. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  276. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
  277. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  278. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
  279. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  280. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
  281. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
  282. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
  283. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  284. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  285. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  286. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  287. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  288. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  289. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  290. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
  291. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  292. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  293. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  294. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  295. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  296. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  297. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  298. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
  299. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
  300. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
  301. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
  302. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
  303. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
  304. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  305. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  306. package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
  307. package/SERVICES/$service/class.js +0 -442
  308. package/SERVICES/readme.md +0 -36
  309. /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
  310. /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
  311. /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  312. /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  313. /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  314. /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
  315. /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
  316. /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  317. /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
  318. /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
  319. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
  320. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
  321. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
  322. /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  323. /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
  324. /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
  325. /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
  326. /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/class.js +0 -0
@@ -1,7 +1,1305 @@
1
- /** Мета хендлера form/email. Визуалка и настройки ящиков — внутри email.js. */
2
- export default {
3
- icon: 'enterprise:email',
4
- label: 'Почта',
5
- order: 4,
6
- roles: ['BOSS', 'USER'],
1
+ const EMPTY_DRAFT = () => ({
2
+ uid: '',
3
+ origTime: 0,
4
+ from: '',
5
+ to: '',
6
+ cc: '',
7
+ subject: '',
8
+ body: '',
9
+ inReplyTo: '',
10
+ attachments: []
11
+ });
12
+ function parseJson(value) {
13
+ if (value && typeof value === 'object') return value;
14
+ if (typeof value !== 'string' || !value) return null;
15
+ try {
16
+ const parsed = JSON.parse(value);
17
+ return parsed && typeof parsed === 'object' ? parsed : null;
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function formatMailShortDate(value) {
23
+ if (!value) return '';
24
+ const d = new Date(value);
25
+ if (isNaN(d.getTime())) return String(value);
26
+ const now = new Date();
27
+ const sameDay = d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate();
28
+ if (sameDay) return d.toLocaleTimeString('ru-RU', {
29
+ hour: '2-digit',
30
+ minute: '2-digit'
31
+ });
32
+ return d.toLocaleDateString('ru-RU', {
33
+ day: '2-digit',
34
+ month: '2-digit'
35
+ });
36
+ }
37
+ function formatMailFullDate(value) {
38
+ if (!value) return '';
39
+ const d = new Date(value);
40
+ if (isNaN(d.getTime())) return String(value);
41
+ return d.toLocaleString('ru-RU', {
42
+ day: '2-digit',
43
+ month: 'short',
44
+ year: 'numeric',
45
+ hour: '2-digit',
46
+ minute: '2-digit'
47
+ });
48
+ }
49
+ function htmlToText(html) {
50
+ try {
51
+ return new DOMParser().parseFromString(html, 'text/html').body?.textContent || '';
52
+ } catch {
53
+ return '';
54
+ }
55
+ }
56
+ function quoteBody(msg) {
57
+ const text = msg.body || htmlToText(msg.html || '');
58
+ const quoted = String(text).split(/\r?\n/).map(line => '> ' + line).join('\n');
59
+ return `\n\n${formatMailFullDate(msg.date)}, ${msg.from || ''} пишет:\n${quoted}`;
7
60
  }
61
+ function htmlDocument(html) {
62
+ return '<!doctype html><html><head><meta charset="utf-8"><base target="_blank">' + '<style>body{margin:0;padding:8px;font-family:sans-serif;font-size:13.5px;line-height:1.45;word-wrap:break-word;}img{max-width:100%;height:auto;}</style>' + '</head><body>' + String(html || '') + '</body></html>';
63
+ }
64
+ function mailboxesToAccounts(mailboxes = {}) {
65
+ return Object.entries(mailboxes).map(([address, box]) => ({
66
+ address,
67
+ smtp: {
68
+ host: '',
69
+ port: 465,
70
+ secure: true,
71
+ ...box.smtp
72
+ },
73
+ imap: {
74
+ host: '',
75
+ port: 993,
76
+ secure: true,
77
+ ...box.imap
78
+ },
79
+ auth: {
80
+ user: address,
81
+ pass: '',
82
+ ...box.auth
83
+ }
84
+ }));
85
+ }
86
+ function accountsToMailboxes(accounts = [], previousMailboxes = {}) {
87
+ const mailboxes = Object.create(null);
88
+ for (const acc of accounts) {
89
+ const address = String(acc.auth?.user || '').trim();
90
+ if (!address) continue;
91
+ const prev = previousMailboxes?.[address] || {};
92
+ mailboxes[address] = {
93
+ ...prev,
94
+ smtp: {
95
+ host: acc.smtp?.host || '',
96
+ port: Number(acc.smtp?.port) || 465,
97
+ secure: acc.smtp?.secure !== false
98
+ },
99
+ imap: {
100
+ host: acc.imap?.host || '',
101
+ port: Number(acc.imap?.port) || 993,
102
+ secure: acc.imap?.secure !== false
103
+ },
104
+ auth: {
105
+ user: address,
106
+ pass: acc.auth?.pass || ''
107
+ }
108
+ };
109
+ }
110
+ return mailboxes;
111
+ }
112
+ async function openEmailSettingsDialog($context) {
113
+ if (openEmailSettingsDialog.opening || !$context) return null;
114
+ openEmailSettingsDialog.opening = true;
115
+ let el, settings;
116
+ try {
117
+ settings = await $context.fetch('read_secret', {
118
+ filename: 'email.json'
119
+ });
120
+ el = ODA.createElement('oda-email-settings', {
121
+ accounts: mailboxesToAccounts(settings?.mailboxes)
122
+ });
123
+ if (!el.accounts.length) el.addAccount();else el.index = 0;
124
+ } catch (e) {
125
+ ODA.showMessage?.(e.message || String(e));
126
+ return null;
127
+ } finally {
128
+ openEmailSettingsDialog.opening = false;
129
+ }
130
+ try {
131
+ await WORK.showDialog(el, {
132
+ TITLE: {
133
+ label: 'Почтовые ящики',
134
+ icon: 'enterprise:email'
135
+ },
136
+ OK: {
137
+ label: 'Сохранить',
138
+ icon: 'icons:save'
139
+ },
140
+ CANCEL: {
141
+ label: 'Отмена',
142
+ icon: 'icons:close'
143
+ }
144
+ });
145
+ } catch {
146
+ return null;
147
+ }
148
+ try {
149
+ el.validate();
150
+ const mailboxes = accountsToMailboxes(el.accounts, settings?.mailboxes);
151
+ await $context.fetch('save_secret', {
152
+ filename: 'email.json'
153
+ }, JSON.stringify({
154
+ mailboxes
155
+ }));
156
+ return mailboxes;
157
+ } catch (e) {
158
+ ODA.showMessage?.(e.message || String(e));
159
+ return null;
160
+ }
161
+ }
162
+ ODA({
163
+ is: 'oda-email-settings',
164
+ imports: 'oda//button, oda//checkbox, oda//icon',
165
+ template: /* html */`
166
+ <style>
167
+ :host {
168
+ @apply --horizontal;
169
+ @apply --flex;
170
+ width: min(680px, calc(100vw - 24px));
171
+ max-width: 100%;
172
+ min-height: min(320px, 50dvh);
173
+ box-sizing: border-box;
174
+ overflow: hidden;
175
+ }
176
+ .accounts {
177
+ width: 220px;
178
+ min-width: 170px;
179
+ flex-shrink: 0;
180
+ @apply --light;
181
+ border-right: 1px solid var(--subtle-border);
182
+ overflow-y: auto;
183
+ }
184
+ @media (max-width: 640px) {
185
+ :host {
186
+ flex-direction: column;
187
+ }
188
+ .accounts {
189
+ width: 100%;
190
+ min-width: 0;
191
+ border-right: none;
192
+ border-bottom: 1px solid var(--subtle-border);
193
+ max-height: 32dvh;
194
+ }
195
+ }
196
+ .accounts-toolbar {
197
+ padding: 6px var(--space-m);
198
+ gap: var(--space-s);
199
+ @apply --header;
200
+ align-items: center;
201
+ }
202
+ .account-item {
203
+ padding: 10px var(--space-m) 10px 12px;
204
+ cursor: pointer;
205
+ border-bottom: 1px solid var(--subtle-border);
206
+ }
207
+ .account-item:not([info-invert]):hover { @apply --hover; }
208
+ .account-title {
209
+ font-weight: 500;
210
+ overflow: hidden;
211
+ text-overflow: ellipsis;
212
+ white-space: nowrap;
213
+ }
214
+ .account-sub { font-size: x-small; @apply --muted; }
215
+ [info-invert] .account-sub { color: inherit; fill: inherit; opacity: .75; }
216
+ .editor {
217
+ padding: 12px var(--space-l);
218
+ gap: var(--space-m);
219
+ overflow: auto;
220
+ }
221
+ fieldset {
222
+ border: 1px solid var(--subtle-border);
223
+ border-radius: var(--radius-s);
224
+ padding: var(--space-s) var(--space-m);
225
+ margin: 0;
226
+ }
227
+ legend { font-size: x-small; padding: 0 var(--space-s); }
228
+ input {
229
+ border: none;
230
+ outline: none;
231
+ background: transparent;
232
+ color: inherit;
233
+ width: 100%;
234
+ padding: var(--space-s) 0;
235
+ box-sizing: border-box;
236
+ font: inherit;
237
+ }
238
+ .row { gap: 12px; align-items: center; }
239
+ .port { max-width: 72px; }
240
+ .empty { padding: var(--space-l); @apply --muted; }
241
+ </style>
242
+ <div class="accounts" vertical>
243
+ <div class="accounts-toolbar" horizontal>
244
+ <span flex>Ящики</span>
245
+ <oda-button icon="icons:add" @tap="addAccount" title="Добавить ящик"></oda-button>
246
+ <oda-button icon="icons:delete" :disabled="!current" @tap="removeAccount" title="Удалить ящик"></oda-button>
247
+ </div>
248
+ <div class="account-item" ~for="accounts"
249
+ :info-invert="index === $for.index"
250
+ @tap="index = $for.index">
251
+ <div class="account-title">{{$for.item.auth.user || 'Новый ящик'}}</div>
252
+ <div class="account-sub">{{$for.item.smtp.host || 'SMTP не задан'}}</div>
253
+ </div>
254
+ <div ~if="!accounts.length" class="empty">Нажмите «+» чтобы добавить ящик</div>
255
+ </div>
256
+ <div class="editor" vertical flex ~if="current">
257
+ <fieldset>
258
+ <legend>Учётная запись</legend>
259
+ <input placeholder="user@example.com" ::value="current.auth.user">
260
+ <input type="password" placeholder="Пароль или пароль приложения" ::value="current.auth.pass">
261
+ </fieldset>
262
+ <fieldset>
263
+ <legend>Исходящая почта (SMTP)</legend>
264
+ <div class="row" horizontal>
265
+ <input flex placeholder="smtp.yandex.ru" ::value="current.smtp.host">
266
+ <input class="port" type="number" placeholder="465" ::value="current.smtp.port">
267
+ <oda-checkbox ::value="current.smtp.secure"></oda-checkbox><span>TLS</span>
268
+ </div>
269
+ </fieldset>
270
+ <fieldset>
271
+ <legend>Входящая почта (IMAP)</legend>
272
+ <div class="row" horizontal>
273
+ <input flex placeholder="imap.yandex.ru" ::value="current.imap.host">
274
+ <input class="port" type="number" placeholder="993" ::value="current.imap.port">
275
+ <oda-checkbox ::value="current.imap.secure"></oda-checkbox><span>TLS</span>
276
+ </div>
277
+ </fieldset>
278
+ </div>
279
+ <div ~if="!current" class="empty" flex>Выберите или добавьте ящик</div>
280
+ `,
281
+ accounts: [],
282
+ index: -1,
283
+ get current() {
284
+ return this.accounts[this.index] ?? null;
285
+ },
286
+ addAccount() {
287
+ this.accounts = [...this.accounts, {
288
+ address: '',
289
+ smtp: {
290
+ host: '',
291
+ port: 465,
292
+ secure: true
293
+ },
294
+ imap: {
295
+ host: '',
296
+ port: 993,
297
+ secure: true
298
+ },
299
+ auth: {
300
+ user: '',
301
+ pass: ''
302
+ }
303
+ }];
304
+ this.index = this.accounts.length - 1;
305
+ },
306
+ removeAccount() {
307
+ if (this.index < 0) return;
308
+ const next = [...this.accounts];
309
+ next.splice(this.index, 1);
310
+ this.accounts = next;
311
+ this.index = next.length ? Math.min(this.index, next.length - 1) : -1;
312
+ },
313
+ validate() {
314
+ const seen = new Set();
315
+ for (const acc of this.accounts) {
316
+ const addr = String(acc.auth?.user || '').trim();
317
+ if (!addr) throw new Error('Укажите адрес (логин) для каждого ящика');
318
+ if (seen.has(addr)) throw new Error('Повторяющийся ящик: ' + addr);
319
+ seen.add(addr);
320
+ }
321
+ }
322
+ });
323
+ export default {
324
+ icon: 'enterprise:email',
325
+ label: 'Почта',
326
+ order: 4,
327
+ allowExternal: false,
328
+ component: {
329
+ imports: 'oda//button, oda//icon',
330
+ template: /* html */`
331
+ <style>
332
+ :host {
333
+ @apply --horizontal;
334
+ @apply --flex;
335
+ overflow: hidden;
336
+ background: var(--content-background, #ffffff);
337
+ color: var(--content-color, #1e293b);
338
+ font-size: 13px;
339
+ }
340
+ .mail-sidebar {
341
+ @apply --vertical;
342
+ width: 212px;
343
+ flex-shrink: 0;
344
+ padding: 12px 10px;
345
+ gap: 6px;
346
+ border-right: 1px solid var(--subtle-border, #e2e8f0);
347
+ background: var(--subtle-background, #f8fafc);
348
+ overflow-y: auto;
349
+ }
350
+ .compose-btn {
351
+ @apply --horizontal;
352
+ align-items: center;
353
+ justify-content: center;
354
+ gap: 7px;
355
+ padding: 9px 14px;
356
+ border-radius: 9px;
357
+ border: none;
358
+ background: var(--accent-color, #2563eb);
359
+ color: var(--accent-back, #ffffff);
360
+ font: inherit;
361
+ font-size: 13.5px;
362
+ font-weight: 600;
363
+ cursor: pointer;
364
+ margin-bottom: 6px;
365
+ box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
366
+ }
367
+ .compose-btn:hover { filter: brightness(1.06); }
368
+ .nav-btn {
369
+ @apply --horizontal;
370
+ align-items: center;
371
+ gap: 9px;
372
+ width: 100%;
373
+ padding: 8px 11px;
374
+ border-radius: 8px;
375
+ border: 1px solid transparent;
376
+ background: transparent;
377
+ color: inherit;
378
+ font: inherit;
379
+ font-size: 13.5px;
380
+ font-weight: 500;
381
+ text-align: left;
382
+ cursor: pointer;
383
+ user-select: none;
384
+ }
385
+ .nav-btn:hover {
386
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 6%, transparent);
387
+ }
388
+ .nav-btn.active {
389
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
390
+ border-color: color-mix(in srgb, var(--accent-color, #2563eb) 50%, transparent);
391
+ color: var(--accent-color, #2563eb);
392
+ font-weight: 600;
393
+ }
394
+ .nav-badge {
395
+ margin-left: auto;
396
+ padding: 1px 7px;
397
+ border-radius: 999px;
398
+ font-size: 11px;
399
+ font-weight: 700;
400
+ background: var(--accent-color, #2563eb);
401
+ color: #ffffff;
402
+ }
403
+ .nav-count {
404
+ margin-left: auto;
405
+ font-size: 11.5px;
406
+ color: var(--muted-color, #64748b);
407
+ }
408
+ .side-sep {
409
+ height: 1px;
410
+ margin: 4px 6px;
411
+ background: var(--subtle-border, #e2e8f0);
412
+ }
413
+ .side-label {
414
+ padding: 2px 10px;
415
+ font-size: 11px;
416
+ font-weight: 700;
417
+ text-transform: uppercase;
418
+ letter-spacing: 0.04em;
419
+ color: var(--muted-color, #64748b);
420
+ }
421
+ .acc-pill {
422
+ font-size: 12.5px;
423
+ padding: 6px 10px;
424
+ overflow: hidden;
425
+ text-overflow: ellipsis;
426
+ white-space: nowrap;
427
+ }
428
+ .mail-list-pane {
429
+ @apply --vertical;
430
+ width: 335px;
431
+ min-width: 260px;
432
+ flex-shrink: 0;
433
+ border-right: 1px solid var(--subtle-border, #e2e8f0);
434
+ background: var(--content-background, #ffffff);
435
+ overflow: hidden;
436
+ }
437
+ .list-toolbar {
438
+ @apply --horizontal;
439
+ align-items: center;
440
+ gap: 6px;
441
+ padding: 10px 10px 8px;
442
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
443
+ background: var(--content-background, #ffffff);
444
+ }
445
+ .search-input {
446
+ @apply --flex;
447
+ min-width: 0;
448
+ padding: 6px 10px;
449
+ border-radius: 7px;
450
+ border: 1px solid var(--subtle-border, #cbd5e1);
451
+ background: var(--subtle-background, #f8fafc);
452
+ color: inherit;
453
+ font: inherit;
454
+ font-size: 12.5px;
455
+ outline: none;
456
+ }
457
+ .search-input:focus {
458
+ border-color: var(--accent-color, #2563eb);
459
+ background: var(--content-background, #ffffff);
460
+ }
461
+ .icon-btn {
462
+ @apply --horizontal;
463
+ align-items: center;
464
+ justify-content: center;
465
+ padding: 6px 8px;
466
+ border-radius: 7px;
467
+ border: 1px solid var(--subtle-border, #cbd5e1);
468
+ background: var(--content-background, #ffffff);
469
+ color: inherit;
470
+ cursor: pointer;
471
+ font-size: 12px;
472
+ }
473
+ .icon-btn:hover { background: var(--accent-soft); }
474
+ .icon-btn.active {
475
+ border-color: var(--accent-color, #2563eb);
476
+ color: var(--accent-color, #2563eb);
477
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
478
+ font-weight: 600;
479
+ }
480
+ .msg-scroll {
481
+ @apply --vertical;
482
+ @apply --flex;
483
+ overflow-y: auto;
484
+ }
485
+ .msg-row {
486
+ display: flex;
487
+ flex-direction: column;
488
+ gap: 3px;
489
+ padding: 10px 12px;
490
+ border-bottom: 1px solid var(--subtle-border, #f1f5f9);
491
+ cursor: pointer;
492
+ position: relative;
493
+ transition: background 0.1s ease;
494
+ }
495
+ .msg-row:hover {
496
+ background: var(--subtle-background, #f8fafc);
497
+ }
498
+ .msg-row.selected {
499
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
500
+ border-left: 3px solid var(--accent-color, #2563eb);
501
+ padding-left: 9px;
502
+ }
503
+ .msg-row.unread .msg-peer,
504
+ .msg-row.unread .msg-subj {
505
+ font-weight: 700;
506
+ }
507
+ .msg-top {
508
+ display: flex;
509
+ align-items: center;
510
+ gap: 6px;
511
+ min-width: 0;
512
+ }
513
+ .unread-dot {
514
+ width: 7px;
515
+ height: 7px;
516
+ border-radius: 50%;
517
+ background: var(--accent-color, #2563eb);
518
+ flex-shrink: 0;
519
+ }
520
+ .msg-peer {
521
+ flex: 1;
522
+ min-width: 0;
523
+ overflow: hidden;
524
+ text-overflow: ellipsis;
525
+ white-space: nowrap;
526
+ font-size: 13px;
527
+ font-weight: 500;
528
+ }
529
+ .msg-time {
530
+ font-size: 11px;
531
+ color: var(--muted-color, #64748b);
532
+ white-space: nowrap;
533
+ }
534
+ .msg-subj {
535
+ font-size: 12.5px;
536
+ overflow: hidden;
537
+ text-overflow: ellipsis;
538
+ white-space: nowrap;
539
+ display: flex;
540
+ align-items: center;
541
+ gap: 5px;
542
+ }
543
+ .msg-snip {
544
+ font-size: 11.5px;
545
+ color: var(--muted-color, #64748b);
546
+ overflow: hidden;
547
+ text-overflow: ellipsis;
548
+ white-space: nowrap;
549
+ }
550
+ .status-tag {
551
+ font-size: 10.5px;
552
+ padding: 1px 6px;
553
+ border-radius: 999px;
554
+ background: var(--subtle-background, #f1f5f9);
555
+ color: var(--muted-color, #64748b);
556
+ }
557
+ .status-tag.err { background: #fef2f2; color: #dc2626; }
558
+ .status-tag.draft { background: #fffbeb; color: #b45309; }
559
+ .mail-view-pane {
560
+ @apply --vertical;
561
+ @apply --flex;
562
+ min-width: 0;
563
+ overflow: hidden;
564
+ background: var(--content-background, #ffffff);
565
+ }
566
+ .empty-pane {
567
+ @apply --vertical;
568
+ @apply --flex;
569
+ align-items: center;
570
+ justify-content: center;
571
+ gap: 10px;
572
+ color: var(--muted-color, #64748b);
573
+ padding: 24px;
574
+ text-align: center;
575
+ }
576
+ .view-actions {
577
+ @apply --horizontal;
578
+ align-items: center;
579
+ gap: 6px;
580
+ padding: 10px 16px;
581
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
582
+ background: var(--subtle-background, #f8fafc);
583
+ flex-wrap: wrap;
584
+ }
585
+ .view-head {
586
+ @apply --vertical;
587
+ gap: 4px;
588
+ padding: 14px 18px 10px;
589
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
590
+ }
591
+ .view-subject {
592
+ font-size: 17px;
593
+ font-weight: 700;
594
+ }
595
+ .view-meta {
596
+ font-size: 12.5px;
597
+ color: var(--muted-color, #475569);
598
+ }
599
+ .att-bar {
600
+ display: flex;
601
+ flex-wrap: wrap;
602
+ gap: 6px;
603
+ padding: 8px 18px;
604
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
605
+ background: var(--subtle-background, #f8fafc);
606
+ }
607
+ .att-chip {
608
+ @apply --horizontal;
609
+ align-items: center;
610
+ gap: 5px;
611
+ padding: 4px 10px;
612
+ border-radius: 6px;
613
+ border: 1px solid var(--subtle-border, #cbd5e1);
614
+ background: var(--content-background, #ffffff);
615
+ font-size: 12px;
616
+ cursor: pointer;
617
+ }
618
+ .view-body {
619
+ @apply --flex;
620
+ overflow: auto;
621
+ padding: 16px 18px;
622
+ white-space: pre-wrap;
623
+ line-height: 1.5;
624
+ user-select: text;
625
+ }
626
+ .view-iframe {
627
+ @apply --flex;
628
+ width: 100%;
629
+ border: none;
630
+ background: #ffffff;
631
+ }
632
+ .compose-wrap {
633
+ @apply --vertical;
634
+ @apply --flex;
635
+ padding: 14px 18px;
636
+ gap: 10px;
637
+ overflow-y: auto;
638
+ }
639
+ .compose-field {
640
+ display: flex;
641
+ align-items: center;
642
+ gap: 8px;
643
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
644
+ padding: 4px 0;
645
+ }
646
+ .compose-field label {
647
+ width: 68px;
648
+ font-size: 12.5px;
649
+ color: var(--muted-color, #64748b);
650
+ flex-shrink: 0;
651
+ }
652
+ .compose-field input,
653
+ .compose-field select {
654
+ flex: 1;
655
+ border: none;
656
+ outline: none;
657
+ background: transparent;
658
+ color: inherit;
659
+ font: inherit;
660
+ padding: 4px 0;
661
+ }
662
+ .compose-body {
663
+ @apply --flex;
664
+ min-height: 180px;
665
+ border: 1px solid var(--subtle-border, #e2e8f0);
666
+ border-radius: 8px;
667
+ padding: 10px 12px;
668
+ outline: none;
669
+ background: var(--content-background, #ffffff);
670
+ color: inherit;
671
+ font: inherit;
672
+ line-height: 1.5;
673
+ resize: none;
674
+ }
675
+ .compose-footer {
676
+ @apply --horizontal;
677
+ align-items: center;
678
+ flex-wrap: wrap;
679
+ gap: 8px;
680
+ padding-top: 4px;
681
+ }
682
+ .mail-back-btn {
683
+ display: none;
684
+ }
685
+ @media (max-width: 960px) {
686
+ .mail-sidebar {
687
+ width: 176px;
688
+ }
689
+ .mail-list-pane {
690
+ width: 270px;
691
+ min-width: 210px;
692
+ }
693
+ }
694
+ @media (max-width: 768px) {
695
+ :host {
696
+ flex-direction: column;
697
+ }
698
+ .mail-sidebar {
699
+ width: 100%;
700
+ flex-direction: row;
701
+ align-items: center;
702
+ overflow-x: auto;
703
+ overflow-y: hidden;
704
+ border-right: none;
705
+ border-bottom: 1px solid var(--subtle-border, #e2e8f0);
706
+ padding: 6px 8px;
707
+ gap: 6px;
708
+ box-sizing: border-box;
709
+ }
710
+ .compose-btn {
711
+ margin-bottom: 0;
712
+ padding: 7px 11px;
713
+ white-space: nowrap;
714
+ flex-shrink: 0;
715
+ }
716
+ .nav-btn {
717
+ width: auto;
718
+ white-space: nowrap;
719
+ flex-shrink: 0;
720
+ padding: 6px 10px;
721
+ }
722
+ .side-sep, .side-label, .mail-side-spacer {
723
+ display: none;
724
+ }
725
+ .mail-list-pane {
726
+ width: 100%;
727
+ min-width: 0;
728
+ flex: 1 1 auto;
729
+ border-right: none;
730
+ }
731
+ .mail-list-pane.mobile-hidden {
732
+ display: none;
733
+ }
734
+ .mail-view-pane {
735
+ width: 100%;
736
+ flex: 1 1 auto;
737
+ min-height: 0;
738
+ }
739
+ .mail-view-pane.mobile-hidden {
740
+ display: none;
741
+ }
742
+ .mail-back-btn {
743
+ display: inline-flex;
744
+ }
745
+ .view-head, .view-body, .compose-wrap {
746
+ padding-left: 12px;
747
+ padding-right: 12px;
748
+ }
749
+ }
750
+ </style>
751
+
752
+ <aside class="mail-sidebar">
753
+ <button type="button" class="compose-btn" @tap="createEmail()">
754
+ <oda-icon icon="icons:add" icon-size="16"></oda-icon>
755
+ <span>Написать</span>
756
+ </button>
757
+
758
+ <button type="button" class="nav-btn" ~for="folders"
759
+ ~class="{ active: activeBox === $for.item.id }"
760
+ @tap="selectBox($for.item.id)">
761
+ <oda-icon :icon="$for.item.icon" icon-size="16"></oda-icon>
762
+ <span>{{$for.item.label}}</span>
763
+ <span ~if="badgeOf($for.item.id) > 0" class="nav-badge">{{badgeOf($for.item.id)}}</span>
764
+ <span ~if="badgeOf($for.item.id) === 0 && countOf($for.item.id) > 0" class="nav-count">{{countOf($for.item.id)}}</span>
765
+ </button>
766
+
767
+ <div class="side-sep" ~if="accounts.length"></div>
768
+ <div class="side-label" ~if="accounts.length">Ящики</div>
769
+ <button type="button" class="nav-btn acc-pill" ~if="accounts.length > 1"
770
+ ~class="{ active: !selectedAccount }"
771
+ @tap="selectAccount('')">Все ящики</button>
772
+ <button type="button" class="nav-btn acc-pill" ~for="accounts"
773
+ ~class="{ active: selectedAccount === $for.item.address }"
774
+ @tap="selectAccount($for.item.address)"
775
+ :title="$for.item.address">
776
+ <span>{{$for.item.address}}</span>
777
+ </button>
778
+
779
+ <div class="mail-side-spacer" style="flex: 1;"></div>
780
+ <div class="side-sep" ~if="canConfigure"></div>
781
+ <label ~if="canConfigure && accounts.length" style="display:flex;align-items:center;gap:6px;padding:4px 8px;font-size:12px;cursor:pointer;white-space:nowrap;flex-shrink:0;">
782
+ <input type="checkbox" :checked="autoRefresh" @change="toggleAutoRefresh($event.target.checked)">
783
+ <span>Автопроверка почты</span>
784
+ </label>
785
+ <button type="button" class="nav-btn" ~if="canConfigure" @tap="openSettings()">
786
+ <oda-icon icon="icons:settings" icon-size="16"></oda-icon>
787
+ <span>Настройка ящиков</span>
788
+ </button>
789
+ </aside>
790
+
791
+ <section class="mail-list-pane" ~class="{ 'mobile-hidden': mode !== 'idle' }">
792
+ <div class="list-toolbar">
793
+ <input class="search-input" type="search" placeholder="Поиск писем…" :value="searchQuery" @input="onSearchInput($event)">
794
+ <button type="button" class="icon-btn" ~class="{ active: unreadOnly }" @tap="toggleUnreadOnly()" title="Только непрочитанные">●</button>
795
+ <button type="button" class="icon-btn" @tap="fetchRefresh()" :disabled="refreshing" title="Проверить почту с сервера">
796
+ <oda-icon :icon="refreshing ? 'spinners:8-dots-rotate' : 'icons:refresh'" icon-size="15"></oda-icon>
797
+ </button>
798
+ </div>
799
+
800
+ <div class="msg-scroll">
801
+ <div ~if="loading && !messages.length" class="empty-pane">Загрузка писем…</div>
802
+ <div ~if="!loading && !messages.length" class="empty-pane">
803
+ <span>В папке «{{activeBoxLabel}}» писем нет</span>
804
+ </div>
805
+ <div ~for="messages" class="msg-row"
806
+ ~class="{ selected: selected?.path === $for.item.path, unread: !$for.item.read }"
807
+ @tap="selectMessage($for.item)">
808
+ <div class="msg-top">
809
+ <span ~if="!$for.item.read" class="unread-dot"></span>
810
+ <span class="msg-peer">{{peerLabel($for.item)}}</span>
811
+ <span class="msg-time">{{shortDate($for.item.date || $for.item.sortTime)}}</span>
812
+ </div>
813
+ <div class="msg-subj">
814
+ <span style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{$for.item.subject || '(без темы)'}}</span>
815
+ <oda-icon ~if="$for.item.attachmentsCount > 0" icon="editor:attach-file" icon-size="13"></oda-icon>
816
+ <span ~if="$for.item.status === 'failed'" class="status-tag err">ошибка</span>
817
+ <span ~if="$for.item.status === 'draft'" class="status-tag draft">черновик</span>
818
+ </div>
819
+ <div ~if="$for.item.snippet" class="msg-snip">{{$for.item.snippet}}</div>
820
+ </div>
821
+ </div>
822
+ </section>
823
+
824
+ <main class="mail-view-pane" ~class="{ 'mobile-hidden': mode === 'idle' }">
825
+ <div ~if="mode === 'idle'" class="empty-pane">
826
+ <oda-icon icon="enterprise:email" icon-size="40" style="opacity:0.35;"></oda-icon>
827
+ <div style="font-size:14px;font-weight:600;">Выберите письмо для просмотра</div>
828
+ <div ~if="!accounts.length && canConfigure" style="font-size:12.5px;">
829
+ Почтовый ящик для этого узла ещё не настроен.
830
+ <div style="margin-top:8px;">
831
+ <button type="button" class="compose-btn" @tap="openSettings()">Подключить ящик</button>
832
+ </div>
833
+ </div>
834
+ </div>
835
+
836
+ <div ~if="mode === 'view' && selected" style="display:flex;flex-direction:column;flex:1;min-height:0;">
837
+ <div class="view-actions">
838
+ <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
839
+ <oda-button ~if="selected.box === 'drafts'" icon="editor:mode-edit" info-invert @tap="editDraft(selected)">Продолжить черновик</oda-button>
840
+ <oda-button ~if="selected.box !== 'drafts'" icon="icons:reply" @tap="reply(false)">Ответить</oda-button>
841
+ <oda-button ~if="selected.box !== 'drafts' && (selected.cc || (selected.to || '').includes(','))" icon="icons:reply-all" @tap="reply(true)">Ответить всем</oda-button>
842
+ <oda-button icon="icons:forward" @tap="forward()">Переслать</oda-button>
843
+ <oda-button ~if="selected.box === 'inbox'" :icon="selected.read ? 'icons:markunread' : 'icons:drafts'" @tap="toggleRead(selected)">
844
+ {{selected.read ? 'Непрочитано' : 'Прочитано'}}
845
+ </oda-button>
846
+ <div style="flex:1;"></div>
847
+ <oda-button ~if="selected.box !== 'trash'" icon="icons:delete" @tap="moveToTrash(selected)">В корзину</oda-button>
848
+ <oda-button ~if="selected.box === 'trash'" icon="icons:restore" @tap="restoreFromTrash(selected)">Восстановить</oda-button>
849
+ <oda-button ~if="selected.box === 'trash'" icon="icons:delete-forever" error @tap="deleteForever(selected)">Удалить навсегда</oda-button>
850
+ </div>
851
+
852
+ <div class="view-head">
853
+ <div class="view-subject">{{selected.subject || '(без темы)'}}</div>
854
+ <div class="view-meta"><b>От:</b> {{selected.from || '—'}} · <b>Дата:</b> {{fullDate(selected.date)}}</div>
855
+ <div class="view-meta"><b>Кому:</b> {{selected.to || '—'}} <span ~if="selected.cc">· <b>Копия:</b> {{selected.cc}}</span></div>
856
+ <div ~if="selected.error" style="font-size:12.5px;color:#dc2626;font-weight:600;">Ошибка доставки: {{selected.error}}</div>
857
+ </div>
858
+
859
+ <div ~if="selected.attachments?.length" class="att-bar">
860
+ <div ~for="selected.attachments" class="att-chip" @tap="openAttachment($for.item)">
861
+ <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
862
+ <span>{{$for.item.name || 'Вложение'}}</span>
863
+ </div>
864
+ </div>
865
+
866
+ <iframe ~if="selected.html" class="view-iframe" sandbox="allow-popups allow-popups-to-escape-sandbox" :srcdoc="htmlDoc"></iframe>
867
+ <div ~if="!selected.html" class="view-body">{{selected.body || ''}}</div>
868
+ </div>
869
+
870
+ <div ~if="mode === 'compose'" class="compose-wrap">
871
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;">
872
+ <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
873
+ <span style="font-size:15px;font-weight:700;">{{draft.uid ? 'Редактирование черновика' : 'Новое письмо'}}</span>
874
+ </div>
875
+
876
+ <div class="compose-field">
877
+ <label>От:</label>
878
+ <select @change="draft.from = $event.target.value">
879
+ <option ~for="accounts" :value="$for.item.address" :selected="$for.item.address === draft.from">{{$for.item.address}}</option>
880
+ </select>
881
+ </div>
882
+ <div class="compose-field">
883
+ <label>Кому:</label>
884
+ <input placeholder="recipient@example.com" :value="draft.to" @input="draft.to = $event.target.value">
885
+ </div>
886
+ <div class="compose-field">
887
+ <label>Копия:</label>
888
+ <input placeholder="cc@example.com (необязательно)" :value="draft.cc" @input="draft.cc = $event.target.value">
889
+ </div>
890
+ <div class="compose-field">
891
+ <label>Тема:</label>
892
+ <input placeholder="Тема письма" :value="draft.subject" @input="draft.subject = $event.target.value">
893
+ </div>
894
+
895
+ <div class="att-bar" style="padding:6px 0;border:none;background:transparent;" ~if="draft.attachments?.length">
896
+ <div ~for="draft.attachments" class="att-chip">
897
+ <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
898
+ <span>{{$for.item.name}}</span>
899
+ <oda-icon icon="icons:close" icon-size="13" style="cursor:pointer;" @tap.stop="removeDraftAttachment($for.index)"></oda-icon>
900
+ </div>
901
+ </div>
902
+
903
+ <textarea class="compose-body" placeholder="Текст письма…" :value="draft.body" @input="draft.body = $event.target.value"></textarea>
904
+
905
+ <div class="compose-footer">
906
+ <oda-button icon="icons:send" info-invert @tap="sendDraft()">Отправить</oda-button>
907
+ <oda-button icon="icons:save" @tap="saveDraft()">Сохранить черновик</oda-button>
908
+ <label class="icon-btn" style="cursor:pointer;">
909
+ <oda-icon icon="editor:attach-file" icon-size="15"></oda-icon>
910
+ <span>Прикрепить</span>
911
+ <input type="file" multiple hidden @change="onAttachFiles($event)">
912
+ </label>
913
+ <div style="flex:1;"></div>
914
+ <oda-button icon="icons:close" @tap="mode = selected ? 'view' : 'idle'">Отмена</oda-button>
915
+ </div>
916
+ </div>
917
+ </main>
918
+ `,
919
+ $item: {
920
+ $def: null,
921
+ set(n, o) {
922
+ if (o && this._onChanged) o.unlisten?.('changed', this._onChanged);
923
+ if (n) {
924
+ this._onChanged ??= () => this.debounce('mail-reload', () => this.reload(), 200);
925
+ n.listen?.('changed', this._onChanged);
926
+ this.initLoad();
927
+ }
928
+ }
929
+ },
930
+ folders: [{
931
+ id: 'inbox',
932
+ label: 'Входящие',
933
+ icon: 'icons:inbox'
934
+ }, {
935
+ id: 'drafts',
936
+ label: 'Черновики',
937
+ icon: 'editor:insert-drive-file'
938
+ }, {
939
+ id: 'outbox',
940
+ label: 'Исходящие',
941
+ icon: 'iconoir:send-mail'
942
+ }, {
943
+ id: 'trash',
944
+ label: 'Корзина',
945
+ icon: 'icons:delete'
946
+ }],
947
+ activeBox: 'inbox',
948
+ selectedAccount: '',
949
+ searchQuery: '',
950
+ unreadOnly: false,
951
+ loading: false,
952
+ refreshing: false,
953
+ accounts: [],
954
+ canConfigure: false,
955
+ autoRefresh: true,
956
+ messages: [],
957
+ countsByBox: {
958
+ inbox: 0,
959
+ drafts: 0,
960
+ outbox: 0,
961
+ trash: 0
962
+ },
963
+ unreadByBox: {
964
+ inbox: 0,
965
+ drafts: 0,
966
+ outbox: 0,
967
+ trash: 0
968
+ },
969
+ selected: null,
970
+ mode: 'idle',
971
+ draft: EMPTY_DRAFT(),
972
+ get activeBoxLabel() {
973
+ return this.folders.find(f => f.id === this.activeBox)?.label || 'Входящие';
974
+ },
975
+ get htmlDoc() {
976
+ return htmlDocument(this.selected?.html);
977
+ },
978
+ attached() {
979
+ if (this.$item && this._loadedFor !== this.$item) this.initLoad();
980
+ },
981
+ detached() {
982
+ this.$item?.unlisten?.('changed', this._onChanged);
983
+ },
984
+ async initLoad() {
985
+ const cur = this.$item;
986
+ if (!cur) return;
987
+ this._loadedFor = cur;
988
+ this.selected = null;
989
+ this.mode = 'idle';
990
+ await this.loadAccounts();
991
+ await this.reload();
992
+ },
993
+ async loadAccounts() {
994
+ if (!this.$item?.fetch) return;
995
+ try {
996
+ const res = await this.$item.fetch('mail_accounts');
997
+ this.accounts = Array.isArray(res?.accounts) ? res.accounts : [];
998
+ this.canConfigure = Boolean(res?.canConfigure);
999
+ this.autoRefresh = res?.autoRefresh !== false;
1000
+ } catch {
1001
+ this.accounts = [];
1002
+ this.canConfigure = false;
1003
+ }
1004
+ },
1005
+ async reload() {
1006
+ if (!this.$item?.fetch) return;
1007
+ this.loading = true;
1008
+ try {
1009
+ const res = await this.$item.fetch('mail_list', {}, JSON.stringify({
1010
+ box: this.activeBox,
1011
+ address: this.selectedAccount,
1012
+ q: this.searchQuery,
1013
+ unreadOnly: this.unreadOnly,
1014
+ limit: 200
1015
+ }));
1016
+ this.messages = Array.isArray(res?.messages) ? res.messages : [];
1017
+ if (res?.countsByBox) this.countsByBox = res.countsByBox;
1018
+ if (res?.unreadByBox) this.unreadByBox = res.unreadByBox;
1019
+ } catch (e) {
1020
+ this.messages = [];
1021
+ } finally {
1022
+ this.loading = false;
1023
+ }
1024
+ },
1025
+ badgeOf(boxId) {
1026
+ return boxId === 'inbox' ? Number(this.unreadByBox?.[boxId]) || 0 : 0;
1027
+ },
1028
+ countOf(boxId) {
1029
+ return boxId === 'drafts' ? Number(this.countsByBox?.[boxId]) || 0 : 0;
1030
+ },
1031
+ peerLabel(msg) {
1032
+ if (this.activeBox === 'outbox' || this.activeBox === 'drafts') return msg.to || '(без получателя)';
1033
+ return msg.from || '(неизвестный отправитель)';
1034
+ },
1035
+ shortDate(v) {
1036
+ return formatMailShortDate(v);
1037
+ },
1038
+ fullDate(v) {
1039
+ return formatMailFullDate(v);
1040
+ },
1041
+ selectBox(boxId) {
1042
+ this.activeBox = boxId;
1043
+ this.selected = null;
1044
+ if (this.mode === 'view') this.mode = 'idle';
1045
+ this.reload();
1046
+ },
1047
+ selectAccount(addr) {
1048
+ this.selectedAccount = addr || '';
1049
+ this.reload();
1050
+ },
1051
+ onSearchInput(e) {
1052
+ this.searchQuery = e.target.value || '';
1053
+ this.debounce('mail-search', () => this.reload(), 200);
1054
+ },
1055
+ toggleUnreadOnly() {
1056
+ this.unreadOnly = !this.unreadOnly;
1057
+ this.reload();
1058
+ },
1059
+ async fetchRefresh() {
1060
+ if (!this.$item?.fetch || this.refreshing) return;
1061
+ this.refreshing = true;
1062
+ try {
1063
+ await this.$item.fetch('mail_refresh');
1064
+ } catch (e) {
1065
+ ODA.showMessage?.(e?.message || String(e));
1066
+ } finally {
1067
+ this.refreshing = false;
1068
+ }
1069
+ await this.loadAccounts();
1070
+ await this.reload();
1071
+ },
1072
+ async selectMessage(msg) {
1073
+ if (!msg?.path || !this.$item?.fetch) return;
1074
+ this.selected = msg;
1075
+ this.mode = 'view';
1076
+ try {
1077
+ const full = await this.$item.fetch('mail_read', {}, JSON.stringify({
1078
+ path: msg.path,
1079
+ uid: msg.uid,
1080
+ markRead: true
1081
+ }));
1082
+ this.selected = full;
1083
+ if (!msg.read && full.read) {
1084
+ msg.read = true;
1085
+ this.messages = [...this.messages];
1086
+ if (this.unreadByBox.inbox > 0) {
1087
+ this.unreadByBox = {
1088
+ ...this.unreadByBox,
1089
+ inbox: this.unreadByBox.inbox - 1
1090
+ };
1091
+ }
1092
+ }
1093
+ } catch (e) {
1094
+ ODA.showMessage?.(e?.message || String(e));
1095
+ }
1096
+ },
1097
+ async toggleRead(msg) {
1098
+ if (!msg?.path || !this.$item?.fetch) return;
1099
+ try {
1100
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1101
+ path: msg.path,
1102
+ uid: msg.uid,
1103
+ read: !msg.read
1104
+ }));
1105
+ await this.reload();
1106
+ if (this.selected?.path === msg.path) this.selected = {
1107
+ ...this.selected,
1108
+ read: !msg.read
1109
+ };
1110
+ } catch (e) {
1111
+ ODA.showMessage?.(e?.message || String(e));
1112
+ }
1113
+ },
1114
+ async moveToTrash(msg) {
1115
+ if (!msg?.path || !this.$item?.fetch) return;
1116
+ try {
1117
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1118
+ path: msg.path,
1119
+ uid: msg.uid,
1120
+ box: 'trash'
1121
+ }));
1122
+ this.selected = null;
1123
+ this.mode = 'idle';
1124
+ await this.reload();
1125
+ } catch (e) {
1126
+ ODA.showMessage?.(e?.message || String(e));
1127
+ }
1128
+ },
1129
+ async restoreFromTrash(msg) {
1130
+ if (!msg?.path || !this.$item?.fetch) return;
1131
+ try {
1132
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1133
+ path: msg.path,
1134
+ uid: msg.uid,
1135
+ restore: true
1136
+ }));
1137
+ this.selected = null;
1138
+ this.mode = 'idle';
1139
+ await this.reload();
1140
+ } catch (e) {
1141
+ ODA.showMessage?.(e?.message || String(e));
1142
+ }
1143
+ },
1144
+ async deleteForever(msg) {
1145
+ if (!msg?.path || !this.$item?.fetch) return;
1146
+ try {
1147
+ await this.$item.fetch('mail_state', {}, JSON.stringify({
1148
+ path: msg.path,
1149
+ uid: msg.uid,
1150
+ deletePermanent: true
1151
+ }));
1152
+ this.selected = null;
1153
+ this.mode = 'idle';
1154
+ await this.reload();
1155
+ } catch (e) {
1156
+ ODA.showMessage?.(e?.message || String(e));
1157
+ }
1158
+ },
1159
+ async createEmail(init = {}) {
1160
+ if (!this.accounts.length) await this.loadAccounts();
1161
+ if (!this.accounts.length) {
1162
+ ODA.showMessage?.('Сначала настройте почтовый ящик');
1163
+ return;
1164
+ }
1165
+ this.draft = {
1166
+ ...EMPTY_DRAFT(),
1167
+ from: this.selectedAccount || this.accounts[0]?.address || '',
1168
+ ...init
1169
+ };
1170
+ this.mode = 'compose';
1171
+ },
1172
+ editDraft(msg) {
1173
+ this.createEmail({
1174
+ uid: msg.uid || '',
1175
+ origTime: msg.origTime || 0,
1176
+ from: msg.address || msg.from || this.accounts[0]?.address || '',
1177
+ to: msg.to || '',
1178
+ cc: msg.cc || '',
1179
+ subject: msg.subject === '(без темы)' ? '' : msg.subject || '',
1180
+ body: msg.body || '',
1181
+ attachments: Array.isArray(msg.attachments) ? [...msg.attachments] : []
1182
+ });
1183
+ },
1184
+ reply(replyAll = false) {
1185
+ const src = this.selected;
1186
+ if (!src) return;
1187
+ const subject = /^re:/i.test(src.subject || '') ? src.subject : 'Re: ' + (src.subject || '');
1188
+ const to = src.box === 'outbox' ? src.to : src.from;
1189
+ const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1190
+ this.createEmail({
1191
+ to,
1192
+ cc: replyAll ? src.cc || '' : '',
1193
+ subject,
1194
+ body: quoteBody(src),
1195
+ inReplyTo: src.messageId || '',
1196
+ ...(from ? {
1197
+ from
1198
+ } : {})
1199
+ });
1200
+ },
1201
+ forward() {
1202
+ const src = this.selected;
1203
+ if (!src) return;
1204
+ const subject = /^fwd?:/i.test(src.subject || '') ? src.subject : 'Fwd: ' + (src.subject || '');
1205
+ const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1206
+ this.createEmail({
1207
+ to: '',
1208
+ subject,
1209
+ body: `\n\n---------- Пересылаемое сообщение ----------\nОт: ${src.from}\nКому: ${src.to}\nТема: ${src.subject}\n\n${src.body || htmlToText(src.html || '')}`,
1210
+ attachments: Array.isArray(src.attachments) ? src.attachments.filter(a => a.path) : [],
1211
+ ...(from ? {
1212
+ from
1213
+ } : {})
1214
+ });
1215
+ },
1216
+ async onAttachFiles(e) {
1217
+ const files = [...(e.target?.files || [])];
1218
+ e.target.value = '';
1219
+ if (!files.length || !this.$item?.save_files) return;
1220
+ try {
1221
+ const fd = new FormData();
1222
+ for (const f of files) fd.append('file', f, f.name);
1223
+ const saved = await this.$item.save_files(fd, {
1224
+ ignore_save_logs: true
1225
+ });
1226
+ const arr = Array.isArray(saved) ? saved : saved ? [saved] : [];
1227
+ const nextAtts = [...(this.draft.attachments || [])];
1228
+ for (let i = 0; i < arr.length; i++) {
1229
+ const s = arr[i];
1230
+ const p = s?.path || s?.logFullPath || '';
1231
+ if (p) nextAtts.push({
1232
+ name: files[i]?.name || p.split('/').pop(),
1233
+ path: p
1234
+ });
1235
+ }
1236
+ this.draft = {
1237
+ ...this.draft,
1238
+ attachments: nextAtts
1239
+ };
1240
+ } catch (err) {
1241
+ ODA.showMessage?.(err?.message || String(err));
1242
+ }
1243
+ },
1244
+ removeDraftAttachment(idx) {
1245
+ const next = [...(this.draft.attachments || [])];
1246
+ next.splice(idx, 1);
1247
+ this.draft = {
1248
+ ...this.draft,
1249
+ attachments: next
1250
+ };
1251
+ },
1252
+ async saveDraft() {
1253
+ if (!this.$item?.fetch) return;
1254
+ try {
1255
+ const res = await this.$item.fetch('mail_draft_save', {}, JSON.stringify(this.draft));
1256
+ this.draft = {
1257
+ ...this.draft,
1258
+ uid: res?.uid || this.draft.uid
1259
+ };
1260
+ ODA.showMessage?.('Черновик сохранён');
1261
+ await this.reload();
1262
+ } catch (e) {
1263
+ ODA.showMessage?.(e?.message || String(e));
1264
+ }
1265
+ },
1266
+ async sendDraft() {
1267
+ if (!this.$item?.fetch) return;
1268
+ try {
1269
+ await this.$item.fetch('mail_send', {}, JSON.stringify({
1270
+ ...this.draft,
1271
+ draftUid: this.draft.uid || undefined
1272
+ }));
1273
+ this.draft = EMPTY_DRAFT();
1274
+ this.mode = 'idle';
1275
+ this.activeBox = 'outbox';
1276
+ await this.reload();
1277
+ } catch (e) {
1278
+ ODA.showMessage?.(e?.message || String(e));
1279
+ }
1280
+ },
1281
+ async openAttachment(att) {
1282
+ if (!att?.path) {
1283
+ ODA.showMessage?.(`Вложение «${att?.name || 'файл'}»`);
1284
+ return;
1285
+ }
1286
+ const item = await globalThis.WORK?.get_item?.(att.path).catch(() => null);
1287
+ if (item && typeof window?.execute === 'function') window.execute(item);
1288
+ },
1289
+ async openSettings() {
1290
+ const res = await openEmailSettingsDialog(this.$item);
1291
+ if (res) {
1292
+ await this.loadAccounts();
1293
+ await this.reload();
1294
+ }
1295
+ },
1296
+ async toggleAutoRefresh(val) {
1297
+ this.autoRefresh = Boolean(val);
1298
+ try {
1299
+ await this.$item?.save?.({
1300
+ mailAutoRefresh: this.autoRefresh
1301
+ });
1302
+ } catch {/* ignore */}
1303
+ }
1304
+ }
1305
+ };