@epam/ai-dial-chat-hooks 1.1.0-dev.378 → 1.1.0-dev.389

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 (319) hide show
  1. package/api-error-DuLNy43N.js +45 -0
  2. package/attachment-types-AAoN9E95.js +7760 -0
  3. package/{attachment/useAttachmentValidation/useAttachmentValidation.d.ts → attachments.d.ts} +88 -44
  4. package/attachments.js +2 -0
  5. package/browser-Btsa0Lmr.js +607 -0
  6. package/catalog.d.ts +946 -0
  7. package/catalog.js +3 -0
  8. package/{conversation-sources/useConversationSources/useConversationSources.d.ts → conversation-sources.d.ts} +25 -20
  9. package/conversation-sources.js +2 -0
  10. package/conversation-transfer.d.ts +189 -0
  11. package/conversation-transfer.js +3 -0
  12. package/conversation.d.ts +907 -0
  13. package/conversation.js +2 -0
  14. package/cron-weekday-B4w29eAC.js +4 -0
  15. package/date-BeuD8G79.js +4 -0
  16. package/deployment-id-CxWgJTs9.js +6 -0
  17. package/file-manager.d.ts +1344 -0
  18. package/file-manager.js +4 -0
  19. package/formatting-CZyyxBG3.js +4 -0
  20. package/index.d.ts +4945 -126
  21. package/index.js +27 -19152
  22. package/oauth.d.ts +440 -0
  23. package/oauth.js +3 -0
  24. package/package.json +142 -21
  25. package/prompt-resource-Bt1I-8ri.js +41 -0
  26. package/scheduled-task-trigger-D9RZCk52.js +145 -0
  27. package/{scheduled-task/scheduled-task-trigger.d.ts → scheduled-tasks.d.ts} +51 -27
  28. package/scheduled-tasks.js +2 -0
  29. package/{conversation/useConversationScroll/useConversationScroll.d.ts → scroll-anchoring.d.ts} +50 -46
  30. package/scroll-anchoring.js +2 -0
  31. package/{useShareRecipientsCount/useShareRecipientsCount.d.ts → sharing.d.ts} +65 -36
  32. package/sharing.js +3 -0
  33. package/skill-editor.d.ts +503 -0
  34. package/skill-editor.js +3 -0
  35. package/skill-manifest-CCX8s4nn.js +4035 -0
  36. package/{skill/useSkillsState/useSkillsState.d.ts → skills-state.d.ts} +40 -35
  37. package/skills-state.js +2 -0
  38. package/string-utils-iBi2Y55C.js +10 -0
  39. package/toolset-id-CkxRHyU0.js +10 -0
  40. package/useAttachmentValidation-CkMTd5lA.js +102 -0
  41. package/useConversationImport-C2h1GBY4.js +807 -0
  42. package/useConversationScroll-CliIMnjP.js +122 -0
  43. package/useConversationSources-DKaKvjXZ.js +47 -0
  44. package/useDialFileManagerTabConfig-DGQw8H8H.js +2289 -0
  45. package/usePanelMaxWidth-BEZYuqF9.js +44 -0
  46. package/useShareLink-xkiaxATt.js +44 -0
  47. package/useShareRecipientsCount-BgwCLKY0.js +37 -0
  48. package/useSkillFileActions-BU5PzZ_8.js +373 -0
  49. package/useSkillFilePreview-BYfZUJhr.js +1005 -0
  50. package/useSkillsState-BoLlwmzb.js +52 -0
  51. package/useToolsMenu-BXdahO0i.js +1874 -0
  52. package/useToolsetLogin-GhFtKs4D.js +276 -0
  53. package/useUsageData-D7BxloKZ.js +201 -0
  54. package/utils.d.ts +373 -0
  55. package/utils.js +7 -0
  56. package/{usePageFileDrag/usePageFileDrag.d.ts → viewport-layout.d.ts} +27 -16
  57. package/viewport-layout.js +2 -0
  58. package/api-error/api-error.d.ts +0 -18
  59. package/api-error/api-error.d.ts.map +0 -1
  60. package/api-transport/create-csrf-middleware.d.ts +0 -15
  61. package/api-transport/create-csrf-middleware.d.ts.map +0 -1
  62. package/api-transport/create-unauthorized-middleware.d.ts +0 -40
  63. package/api-transport/create-unauthorized-middleware.d.ts.map +0 -1
  64. package/attachment/useAttachmentAction/useAttachmentAction.d.ts +0 -32
  65. package/attachment/useAttachmentAction/useAttachmentAction.d.ts.map +0 -1
  66. package/attachment/useAttachmentValidation/useAttachmentValidation.d.ts.map +0 -1
  67. package/catalog/catalog-derivations.d.ts +0 -27
  68. package/catalog/catalog-derivations.d.ts.map +0 -1
  69. package/catalog/catalog-primary-action.d.ts +0 -47
  70. package/catalog/catalog-primary-action.d.ts.map +0 -1
  71. package/catalog/create-publish-api.d.ts +0 -32
  72. package/catalog/create-publish-api.d.ts.map +0 -1
  73. package/catalog/deployment-endpoint-url.d.ts +0 -19
  74. package/catalog/deployment-endpoint-url.d.ts.map +0 -1
  75. package/catalog/deployment-id.d.ts +0 -21
  76. package/catalog/deployment-id.d.ts.map +0 -1
  77. package/catalog/entity-details.d.ts +0 -132
  78. package/catalog/entity-details.d.ts.map +0 -1
  79. package/catalog/map-deployment-limits-to-catalog.d.ts +0 -33
  80. package/catalog/map-deployment-limits-to-catalog.d.ts.map +0 -1
  81. package/catalog/map-deployment-limits-to-input.d.ts +0 -15
  82. package/catalog/map-deployment-limits-to-input.d.ts.map +0 -1
  83. package/catalog/map-deployment-to-catalog-item.d.ts +0 -60
  84. package/catalog/map-deployment-to-catalog-item.d.ts.map +0 -1
  85. package/catalog/map-entity-details-to-catalog.d.ts +0 -23
  86. package/catalog/map-entity-details-to-catalog.d.ts.map +0 -1
  87. package/catalog/map-prompt-to-catalog-item.d.ts +0 -43
  88. package/catalog/map-prompt-to-catalog-item.d.ts.map +0 -1
  89. package/catalog/map-skill-to-catalog-item.d.ts +0 -87
  90. package/catalog/map-skill-to-catalog-item.d.ts.map +0 -1
  91. package/catalog/mcp-endpoint-url.d.ts +0 -18
  92. package/catalog/mcp-endpoint-url.d.ts.map +0 -1
  93. package/catalog/publish.d.ts +0 -17
  94. package/catalog/publish.d.ts.map +0 -1
  95. package/catalog/useCatalogItemDetails.d.ts +0 -73
  96. package/catalog/useCatalogItemDetails.d.ts.map +0 -1
  97. package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.d.ts +0 -37
  98. package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.d.ts.map +0 -1
  99. package/catalog/usePublishFolders/usePublishFolders.d.ts +0 -73
  100. package/catalog/usePublishFolders/usePublishFolders.d.ts.map +0 -1
  101. package/conversation/announcement-message.d.ts +0 -34
  102. package/conversation/announcement-message.d.ts.map +0 -1
  103. package/conversation/conversation-transfer/async.d.ts +0 -10
  104. package/conversation/conversation-transfer/async.d.ts.map +0 -1
  105. package/conversation/conversation-transfer/attachment-refs.d.ts +0 -12
  106. package/conversation/conversation-transfer/attachment-refs.d.ts.map +0 -1
  107. package/conversation/conversation-transfer/build-upload-path.d.ts +0 -40
  108. package/conversation/conversation-transfer/build-upload-path.d.ts.map +0 -1
  109. package/conversation/conversation-transfer/date.d.ts +0 -5
  110. package/conversation/conversation-transfer/date.d.ts.map +0 -1
  111. package/conversation/conversation-transfer/dial-file-resolve.d.ts +0 -10
  112. package/conversation/conversation-transfer/dial-file-resolve.d.ts.map +0 -1
  113. package/conversation/conversation-transfer/export-conversation.d.ts +0 -8
  114. package/conversation/conversation-transfer/export-conversation.d.ts.map +0 -1
  115. package/conversation/conversation-transfer/import-conversation.d.ts +0 -82
  116. package/conversation/conversation-transfer/import-conversation.d.ts.map +0 -1
  117. package/conversation/conversation-transfer/progress.d.ts +0 -60
  118. package/conversation/conversation-transfer/progress.d.ts.map +0 -1
  119. package/conversation/conversation-transfer/queue.d.ts +0 -54
  120. package/conversation/conversation-transfer/queue.d.ts.map +0 -1
  121. package/conversation/conversation-transfer/types.d.ts +0 -36
  122. package/conversation/conversation-transfer/types.d.ts.map +0 -1
  123. package/conversation/conversation-transfer/zip-export.d.ts +0 -31
  124. package/conversation/conversation-transfer/zip-export.d.ts.map +0 -1
  125. package/conversation/conversation-transfer/zip-import.d.ts +0 -17
  126. package/conversation/conversation-transfer/zip-import.d.ts.map +0 -1
  127. package/conversation/create-chat-stream-api.d.ts +0 -38
  128. package/conversation/create-chat-stream-api.d.ts.map +0 -1
  129. package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.d.ts +0 -39
  130. package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.d.ts.map +0 -1
  131. package/conversation/display-name-watch.d.ts +0 -4
  132. package/conversation/display-name-watch.d.ts.map +0 -1
  133. package/conversation/footer-message.d.ts +0 -10
  134. package/conversation/footer-message.d.ts.map +0 -1
  135. package/conversation/get-model-id-from-conversation-id.d.ts +0 -27
  136. package/conversation/get-model-id-from-conversation-id.d.ts.map +0 -1
  137. package/conversation/greeting.d.ts +0 -18
  138. package/conversation/greeting.d.ts.map +0 -1
  139. package/conversation/message-factory.d.ts +0 -7
  140. package/conversation/message-factory.d.ts.map +0 -1
  141. package/conversation/message-utils.d.ts +0 -27
  142. package/conversation/message-utils.d.ts.map +0 -1
  143. package/conversation/overlay-messages.d.ts +0 -5
  144. package/conversation/overlay-messages.d.ts.map +0 -1
  145. package/conversation/quick-app-conversation-starters.d.ts +0 -10
  146. package/conversation/quick-app-conversation-starters.d.ts.map +0 -1
  147. package/conversation/starter-option.d.ts +0 -21
  148. package/conversation/starter-option.d.ts.map +0 -1
  149. package/conversation/useActiveConversationSync/useActiveConversationSync.d.ts +0 -34
  150. package/conversation/useActiveConversationSync/useActiveConversationSync.d.ts.map +0 -1
  151. package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.d.ts +0 -46
  152. package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.d.ts.map +0 -1
  153. package/conversation/useAttachmentUpload/useAttachmentUpload.d.ts +0 -26
  154. package/conversation/useAttachmentUpload/useAttachmentUpload.d.ts.map +0 -1
  155. package/conversation/useConversationExport/useConversationExport.d.ts +0 -72
  156. package/conversation/useConversationExport/useConversationExport.d.ts.map +0 -1
  157. package/conversation/useConversationHandlers/attachment-to-dto.d.ts +0 -7
  158. package/conversation/useConversationHandlers/attachment-to-dto.d.ts.map +0 -1
  159. package/conversation/useConversationHandlers/message-factory.d.ts +0 -9
  160. package/conversation/useConversationHandlers/message-factory.d.ts.map +0 -1
  161. package/conversation/useConversationHandlers/message-utils.d.ts +0 -14
  162. package/conversation/useConversationHandlers/message-utils.d.ts.map +0 -1
  163. package/conversation/useConversationHandlers/starter-option.d.ts +0 -14
  164. package/conversation/useConversationHandlers/starter-option.d.ts.map +0 -1
  165. package/conversation/useConversationHandlers/useConversationHandlers.d.ts +0 -66
  166. package/conversation/useConversationHandlers/useConversationHandlers.d.ts.map +0 -1
  167. package/conversation/useConversationImport/useConversationImport.d.ts +0 -53
  168. package/conversation/useConversationImport/useConversationImport.d.ts.map +0 -1
  169. package/conversation/useConversationLookupMaps/useConversationLookupMaps.d.ts +0 -24
  170. package/conversation/useConversationLookupMaps/useConversationLookupMaps.d.ts.map +0 -1
  171. package/conversation/useConversationPanelItems/useConversationPanelItems.d.ts +0 -58
  172. package/conversation/useConversationPanelItems/useConversationPanelItems.d.ts.map +0 -1
  173. package/conversation/useConversationScroll/useConversationScroll.d.ts.map +0 -1
  174. package/conversation/useConversationStream/apply-chunk.d.ts +0 -20
  175. package/conversation/useConversationStream/apply-chunk.d.ts.map +0 -1
  176. package/conversation/useConversationStream/buffered-generation.d.ts +0 -15
  177. package/conversation/useConversationStream/buffered-generation.d.ts.map +0 -1
  178. package/conversation/useConversationStream/conversation-path.d.ts +0 -7
  179. package/conversation/useConversationStream/conversation-path.d.ts.map +0 -1
  180. package/conversation/useConversationStream/generation-resume.d.ts +0 -39
  181. package/conversation/useConversationStream/generation-resume.d.ts.map +0 -1
  182. package/conversation/useConversationStream/useConversationStream.d.ts +0 -92
  183. package/conversation/useConversationStream/useConversationStream.d.ts.map +0 -1
  184. package/conversation/useImportFilePicker/useImportFilePicker.d.ts +0 -32
  185. package/conversation/useImportFilePicker/useImportFilePicker.d.ts.map +0 -1
  186. package/conversation-sources/useConversationSources/useConversationSources.d.ts.map +0 -1
  187. package/files/annotation.d.ts +0 -10
  188. package/files/annotation.d.ts.map +0 -1
  189. package/files/attachment-canvas.d.ts +0 -104
  190. package/files/attachment-canvas.d.ts.map +0 -1
  191. package/files/attachment-dto-to-display.d.ts +0 -10
  192. package/files/attachment-dto-to-display.d.ts.map +0 -1
  193. package/files/attachment-types.d.ts +0 -14
  194. package/files/attachment-types.d.ts.map +0 -1
  195. package/files/create-files-api.d.ts +0 -52
  196. package/files/create-files-api.d.ts.map +0 -1
  197. package/files/create-upload-file-with-progress.d.ts +0 -24
  198. package/files/create-upload-file-with-progress.d.ts.map +0 -1
  199. package/files/dial-file-manager-copy-move.util.d.ts +0 -15
  200. package/files/dial-file-manager-copy-move.util.d.ts.map +0 -1
  201. package/files/dial-file-manager-mapping.util.d.ts +0 -35
  202. package/files/dial-file-manager-mapping.util.d.ts.map +0 -1
  203. package/files/dial-file-manager-path.util.d.ts +0 -39
  204. package/files/dial-file-manager-path.util.d.ts.map +0 -1
  205. package/files/dial-file-manager.model.d.ts +0 -26
  206. package/files/dial-file-manager.model.d.ts.map +0 -1
  207. package/files/dial-file-manager.types.d.ts +0 -317
  208. package/files/dial-file-manager.types.d.ts.map +0 -1
  209. package/files/dial-file-to-attachment.d.ts +0 -26
  210. package/files/dial-file-to-attachment.d.ts.map +0 -1
  211. package/files/dial-file.d.ts +0 -17
  212. package/files/dial-file.d.ts.map +0 -1
  213. package/files/dial-files-api.d.ts +0 -71
  214. package/files/dial-files-api.d.ts.map +0 -1
  215. package/files/download-destination.d.ts +0 -31
  216. package/files/download-destination.d.ts.map +0 -1
  217. package/files/file-manager-variant.d.ts +0 -4
  218. package/files/file-manager-variant.d.ts.map +0 -1
  219. package/files/file-name.d.ts +0 -19
  220. package/files/file-name.d.ts.map +0 -1
  221. package/files/prepare-download-destination.d.ts +0 -8
  222. package/files/prepare-download-destination.d.ts.map +0 -1
  223. package/files/resolve-dial-file-api-path.d.ts +0 -13
  224. package/files/resolve-dial-file-api-path.d.ts.map +0 -1
  225. package/files/useDialFileListing/useDialFileListing.d.ts +0 -73
  226. package/files/useDialFileListing/useDialFileListing.d.ts.map +0 -1
  227. package/files/useDialFileManager/useDialFileManager.d.ts +0 -16
  228. package/files/useDialFileManager/useDialFileManager.d.ts.map +0 -1
  229. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.d.ts +0 -14
  230. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.d.ts.map +0 -1
  231. package/files/useDialFileMetadata/useDialFileMetadata.d.ts +0 -28
  232. package/files/useDialFileMetadata/useDialFileMetadata.d.ts.map +0 -1
  233. package/files/useDialFileMutations/useDialFileMutations.d.ts +0 -68
  234. package/files/useDialFileMutations/useDialFileMutations.d.ts.map +0 -1
  235. package/files/useDialFileSharing/useDialFileSharing.d.ts +0 -30
  236. package/files/useDialFileSharing/useDialFileSharing.d.ts.map +0 -1
  237. package/files/useDialFileUploadBatch/useDialFileUploadBatch.d.ts +0 -45
  238. package/files/useDialFileUploadBatch/useDialFileUploadBatch.d.ts.map +0 -1
  239. package/index.d.ts.map +0 -1
  240. package/oauth/authorize-url.d.ts +0 -16
  241. package/oauth/authorize-url.d.ts.map +0 -1
  242. package/oauth/handshake.d.ts +0 -30
  243. package/oauth/handshake.d.ts.map +0 -1
  244. package/oauth/models.d.ts +0 -81
  245. package/oauth/models.d.ts.map +0 -1
  246. package/oauth/popup.d.ts +0 -30
  247. package/oauth/popup.d.ts.map +0 -1
  248. package/oauth/toolset-id.d.ts +0 -23
  249. package/oauth/toolset-id.d.ts.map +0 -1
  250. package/oauth/types.d.ts +0 -84
  251. package/oauth/types.d.ts.map +0 -1
  252. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts +0 -54
  253. package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts.map +0 -1
  254. package/oauth/useToolsetLogin/useToolsetLogin.d.ts +0 -79
  255. package/oauth/useToolsetLogin/useToolsetLogin.d.ts.map +0 -1
  256. package/prompt/export-prompt.d.ts +0 -31
  257. package/prompt/export-prompt.d.ts.map +0 -1
  258. package/prompt/prompt-resource.d.ts +0 -30
  259. package/prompt/prompt-resource.d.ts.map +0 -1
  260. package/prompt/prompt.d.ts +0 -34
  261. package/prompt/prompt.d.ts.map +0 -1
  262. package/prompt/usePromptsState/usePromptsState.d.ts +0 -34
  263. package/prompt/usePromptsState/usePromptsState.d.ts.map +0 -1
  264. package/scheduled-task/scheduled-task-mapping.d.ts +0 -19
  265. package/scheduled-task/scheduled-task-mapping.d.ts.map +0 -1
  266. package/scheduled-task/scheduled-task-trigger.d.ts.map +0 -1
  267. package/shared/application-schema.d.ts +0 -10
  268. package/shared/application-schema.d.ts.map +0 -1
  269. package/shared/browser-timezone.d.ts +0 -7
  270. package/shared/browser-timezone.d.ts.map +0 -1
  271. package/shared/cron-weekday.d.ts +0 -5
  272. package/shared/cron-weekday.d.ts.map +0 -1
  273. package/shared/custom-apps.d.ts +0 -7
  274. package/shared/custom-apps.d.ts.map +0 -1
  275. package/shared/external-services.d.ts +0 -16
  276. package/shared/external-services.d.ts.map +0 -1
  277. package/shared/formatting.d.ts +0 -5
  278. package/shared/formatting.d.ts.map +0 -1
  279. package/shared/locale.d.ts +0 -45
  280. package/shared/locale.d.ts.map +0 -1
  281. package/shared/string-utils.d.ts +0 -9
  282. package/shared/string-utils.d.ts.map +0 -1
  283. package/shared/toolset-login-events.d.ts +0 -15
  284. package/shared/toolset-login-events.d.ts.map +0 -1
  285. package/skill/skill-file-batch-validation.d.ts +0 -70
  286. package/skill/skill-file-batch-validation.d.ts.map +0 -1
  287. package/skill/skill-file-preview.d.ts +0 -25
  288. package/skill/skill-file-preview.d.ts.map +0 -1
  289. package/skill/skill-manifest.d.ts +0 -28
  290. package/skill/skill-manifest.d.ts.map +0 -1
  291. package/skill/skill-types.d.ts +0 -42
  292. package/skill/skill-types.d.ts.map +0 -1
  293. package/skill/skill.d.ts +0 -114
  294. package/skill/skill.d.ts.map +0 -1
  295. package/skill/useSkillEditorLoad.d.ts +0 -74
  296. package/skill/useSkillEditorLoad.d.ts.map +0 -1
  297. package/skill/useSkillEditorSubmit.d.ts +0 -105
  298. package/skill/useSkillEditorSubmit.d.ts.map +0 -1
  299. package/skill/useSkillFileActions.d.ts +0 -53
  300. package/skill/useSkillFileActions.d.ts.map +0 -1
  301. package/skill/useSkillFilePreview.d.ts +0 -38
  302. package/skill/useSkillFilePreview.d.ts.map +0 -1
  303. package/skill/useSkillsState/useSkillsState.d.ts.map +0 -1
  304. package/test-setup.d.ts +0 -2
  305. package/test-setup.d.ts.map +0 -1
  306. package/usage/useUsageData/useUsageData.d.ts +0 -20
  307. package/usage/useUsageData/useUsageData.d.ts.map +0 -1
  308. package/useChatSettingsFormConfig/useChatSettingsFormConfig.d.ts +0 -128
  309. package/useChatSettingsFormConfig/useChatSettingsFormConfig.d.ts.map +0 -1
  310. package/usePageFileDrag/usePageFileDrag.d.ts.map +0 -1
  311. package/usePanelMaxWidth/usePanelMaxWidth.d.ts +0 -6
  312. package/usePanelMaxWidth/usePanelMaxWidth.d.ts.map +0 -1
  313. package/useShareLink/useShareLink.d.ts +0 -23
  314. package/useShareLink/useShareLink.d.ts.map +0 -1
  315. package/useShareRecipientsCount/useShareRecipientsCount.d.ts.map +0 -1
  316. package/useToolsMenu/useToolsMenu.d.ts +0 -31
  317. package/useToolsMenu/useToolsMenu.d.ts.map +0 -1
  318. package/useViewportWidth/useViewportWidth.d.ts +0 -3
  319. package/useViewportWidth/useViewportWidth.d.ts.map +0 -1
@@ -0,0 +1,2289 @@
1
+ import { a as e } from "./attachment-types-AAoN9E95.js";
2
+ import { r as t } from "./api-error-DuLNy43N.js";
3
+ import { n } from "./string-utils-iBi2Y55C.js";
4
+ import { AttachmentContentType as r, AttachmentErrorType as i, getOoxmlMimeType as a, isHtmlPreviewable as o, isOoxmlPreviewable as s, isTextPreviewable as c } from "@epam/ai-dial-attachment-canvas";
5
+ import { AttachmentType as l, DialFileManagerActionProfile as u, DialFileManagerVariant as d, FileExtension as f, FileUploadStatus as p, HIDDEN_FILE as m, MIMEType as h, RequestStatus as g, base64ToBlob as _, getParentFolderPath as v, getUtf8ByteLength as y, messageAttachmentToDisplayAttachment as b, stripUrlQueryAndFragment as x, triggerAnchorDownload as S, truncateToUtf8Bytes as C, tryBase64ToBytes as w } from "@epam/ai-dial-chat-shared";
6
+ import { annotationHighlightId as T, annotationsToPdfHighlights as ee, parsePdfPageReference as E } from "@epam/ai-dial-quotations";
7
+ import { useCallback as D, useEffect as O, useMemo as k, useRef as A, useState as j } from "react";
8
+ import { ArchiveItemDtoNodeTypeEnum as te, CopyItemDtoNodeTypeEnum as M, DeleteItemDtoNodeTypeEnum as N, ListFilesItemDtoNodeTypeEnum as P, MoveItemDtoNodeTypeEnum as F, RenameItemDtoNodeTypeEnum as I } from "@epam/ai-dial-chat-api-client";
9
+ import { DialFileNodeType as L, NOT_ALLOWED_SYMBOLS as R, NOT_ALLOWED_SYMBOLS_REGEXP as ne, NotificationVariant as z } from "@epam/ai-dial-ui-kit";
10
+ import { DialFileManagerActions as B, DialFileManagerTabs as V, DialFileNodeType as H, DialFilePermission as U, FileManagerColumnKey as W } from "@epam/ai-dial-react-file-manager";
11
+ //#region src/files/dial-files-api.ts
12
+ var re = /* @__PURE__ */ function(e) {
13
+ return e.Overwrite = "overwrite", e.CreateOnly = "create-only", e;
14
+ }({}), G = /* @__PURE__ */ function(e) {
15
+ return e.FolderLoadFailed = "folderLoadFailed", e.MetadataLoadFailed = "metadataLoadFailed", e.FolderCreateFailed = "folderCreateFailed", e.DownloadFileFailed = "downloadFileFailed", e.DownloadFilesFailed = "downloadFilesFailed", e.FilesDeleted = "filesDeleted", e.FilesDeletePartiallyFailed = "filesDeletePartiallyFailed", e.DeleteFailed = "deleteFailed", e.RenameFailed = "renameFailed", e.RenamePartiallyFailed = "renamePartiallyFailed", e.MoveFailed = "moveFailed", e.MovePartiallyFailed = "movePartiallyFailed", e.CopyFailed = "copyFailed", e.CopyPartiallyFailed = "copyPartiallyFailed", e.UnshareFailed = "unshareFailed", e.RemoveAccessFailed = "removeAccessFailed", e.UploadFailed = "uploadFailed", e.UploadCompleted = "uploadCompleted", e.UploadArchiveFailed = "uploadArchiveFailed", e.UploadArchivePartiallyFailed = "uploadArchivePartiallyFailed", e.UploadArchiveRequestFailed = "uploadArchiveRequestFailed", e;
16
+ }({}), K = /* @__PURE__ */ function(e) {
17
+ return e.Empty = "empty", e.ForbiddenSymbols = "forbiddenSymbols", e.ReservedName = "reservedName", e.TooLong = "tooLong", e.DuplicateName = "duplicateName", e.LeadingDot = "leadingDot", e;
18
+ }({}), q = /* @__PURE__ */ function(e) {
19
+ return e.FolderCreated = "folderCreated", e.FileRenamed = "fileRenamed", e.FileDownloaded = "fileDownloaded", e.FilesDownloaded = "filesDownloaded", e.FileCopied = "fileCopied", e.FilesCopied = "filesCopied", e.FileMoved = "fileMoved", e.FilesMoved = "filesMoved", e;
20
+ }({}), ie = 3, ae = m, oe = /[/\\]/, se = {
21
+ year: "numeric",
22
+ month: "short",
23
+ day: "2-digit"
24
+ }, ce = [
25
+ W.Name,
26
+ W.UpdatedAt,
27
+ W.Size,
28
+ W.Actions
29
+ ], le = [
30
+ W.Name,
31
+ W.UpdatedAt,
32
+ W.Size,
33
+ W.Author,
34
+ W.Actions
35
+ ], ue = {
36
+ READ: U.READ,
37
+ WRITE: U.WRITE,
38
+ SHARE: U.SHARE
39
+ }, de = (e) => {
40
+ switch (e) {
41
+ case d.Attach: return u.Attach;
42
+ case d.Standalone: return u.Browse;
43
+ case d.FolderPicker: return u.Full;
44
+ }
45
+ }, fe = (e, t) => {
46
+ if (oe.test(e)) return !0;
47
+ if (t == null) return !1;
48
+ t.lastIndex = 0;
49
+ let n = t.test(e);
50
+ return t.lastIndex = 0, n;
51
+ }, J = (e) => e.replace(/\/+$/, "") || "/", Y = (e, t) => {
52
+ let r = e.split("/").filter(Boolean);
53
+ return n(r[r.length - 1] ?? t);
54
+ }, X = (e, t) => J(e || `/${t}`).replace(/^\/+/, "") || t, pe = (e, t) => {
55
+ let n = J(t);
56
+ for (let r of e) {
57
+ if (r.nodeType !== H.FOLDER) continue;
58
+ if (J(r.path) === n) return r;
59
+ let e = pe(r.items ?? [], t);
60
+ if (e) return e;
61
+ }
62
+ }, me = (e) => e?.permissions?.includes(U.WRITE) ?? !1, he = (e, t) => {
63
+ for (let n of e) {
64
+ if (n.path === t || n.id === t) return n;
65
+ let e = he(n.items ?? [], t);
66
+ if (e) return e;
67
+ }
68
+ }, ge = (e) => {
69
+ switch (e) {
70
+ case u.Attach: return !1;
71
+ case u.Browse:
72
+ case u.Full: return !0;
73
+ default: throw Error(`Unhandled actionProfile: ${String(e)}`);
74
+ }
75
+ }, _e = (e) => e === u.Full, ve = (e, t) => {
76
+ let n = e.replace(/\/$/, ""), r = n.lastIndexOf("/");
77
+ if (r <= 0) {
78
+ let e = r === 0 ? n.slice(1) : n;
79
+ return {
80
+ parentVirtualPath: `/${t}`,
81
+ name: e
82
+ };
83
+ }
84
+ return {
85
+ parentVirtualPath: n.slice(0, r),
86
+ name: n.slice(r + 1)
87
+ };
88
+ }, Z = (e, t) => {
89
+ let n = `files/${t}/`;
90
+ return e.startsWith(n) ? e.slice(n.length) : e;
91
+ }, ye = (e, t, r) => {
92
+ let i = e.replace(/\/+$/, "").split("/").filter(Boolean).map(n).join("/"), a = i ? `/${t}/${i}` : `/${t}`;
93
+ return r ? `${a}/` : a;
94
+ }, be = (e, t, n) => {
95
+ if (!e) return {
96
+ bucket: n,
97
+ path: e
98
+ };
99
+ let r = e.indexOf("/"), i = r === -1 ? e : e.slice(0, r), a = t.get(i);
100
+ if (!a) return {
101
+ bucket: n,
102
+ path: e
103
+ };
104
+ let o = Z(a.dialCorePath, a.bucket), s = r === -1 ? "" : e.slice(r + 1);
105
+ return {
106
+ bucket: a.bucket,
107
+ path: o + s
108
+ };
109
+ }, xe = (e) => e.startsWith("files/"), Se = (e, t) => {
110
+ let r = `files/${t}/`;
111
+ if (e.startsWith(r)) return n(e.slice(r.length));
112
+ if (xe(e)) {
113
+ let r = e.slice(6), i = r.indexOf("/");
114
+ if (i >= 0) {
115
+ let e = r.slice(0, i), a = r.slice(i + 1);
116
+ if (e === t) return n(a);
117
+ }
118
+ }
119
+ return e;
120
+ }, Q = (e, t) => {
121
+ let n = `/${t}`, r = `/${t}/`, i = `${t}/`;
122
+ if (e === n || e === `${t}` || e === r || e === i) return "";
123
+ let a;
124
+ if (e.startsWith(r)) a = e.slice(r.length);
125
+ else if (e.startsWith(i)) a = e.slice(i.length);
126
+ else {
127
+ let t = e.replace(/^\//, "");
128
+ a = t.startsWith(i) ? t.slice(i.length) : t;
129
+ }
130
+ let o = a.replace(/\/{2,}/g, "/");
131
+ return o && !o.endsWith("/") ? `${o}/` : o;
132
+ }, Ce = (e, t) => e.startsWith("/") || e === t || e.startsWith(`${t}/`), we = (e, t, n) => {
133
+ let r = e.nodeType === H.FOLDER, i = e.id ? Se(e.id, t) : null, a = i != null && !Ce(i, n) ? i : Q(e.path, n);
134
+ return r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, "");
135
+ }, Te = (e, t, n) => e.map((e) => {
136
+ let r = e.nodeType === H.FOLDER, i = Q(e.sourceUrl, n), a = Q(e.destinationUrl, n), o = Y(e.sourceUrl, i);
137
+ return {
138
+ destinationName: Y(e.destinationUrl, a),
139
+ dto: {
140
+ bucket: t,
141
+ sourcePath: r ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, ""),
142
+ destinationPath: r ? a.endsWith("/") ? a : `${a}/` : a.replace(/\/$/, ""),
143
+ overwrite: e.overwrite === !0,
144
+ nodeType: r ? M.Folder : M.Item,
145
+ name: o
146
+ }
147
+ };
148
+ }), Ee = (e, t, n) => {
149
+ let r = e.map((e) => {
150
+ let t = e.nodeType === H.FOLDER, r = Q(e.sourceUrl, n), i = Q(e.destinationUrl, n), a = Y(e.sourceUrl, r), o = Y(e.destinationUrl, i), s = t ? r.endsWith("/") ? r : `${r}/` : r.replace(/\/$/, ""), c = t ? i.endsWith("/") ? i : `${i}/` : i.replace(/\/$/, "");
151
+ return {
152
+ isFolder: t,
153
+ name: a,
154
+ destinationName: o,
155
+ overwrite: e.overwrite === !0,
156
+ sourcePath: s,
157
+ destinationPath: c,
158
+ sourceParent: v(s),
159
+ destinationParent: v(c)
160
+ };
161
+ });
162
+ return {
163
+ renameDtos: r.filter((e) => e.sourceParent === e.destinationParent).map((e) => ({
164
+ bucket: t,
165
+ sourcePath: e.sourcePath,
166
+ destinationPath: e.destinationPath,
167
+ nodeType: e.isFolder ? I.Folder : I.Item,
168
+ name: e.name
169
+ })),
170
+ preparedMoveItems: r.filter((e) => e.sourceParent !== e.destinationParent).map((e) => ({
171
+ destinationName: e.destinationName,
172
+ dto: {
173
+ bucket: t,
174
+ sourcePath: e.sourcePath,
175
+ destinationPath: e.destinationPath,
176
+ overwrite: e.overwrite,
177
+ nodeType: e.isFolder ? F.Folder : F.Item,
178
+ name: e.name
179
+ }
180
+ }))
181
+ };
182
+ }, De = (e) => {
183
+ if (!e?.length) return;
184
+ let t = e.map((e) => ue[e.toUpperCase()]).filter((e) => e != null);
185
+ return t.length > 0 ? t : void 0;
186
+ }, Oe = (e, t) => {
187
+ let n = t.find((e) => e.success);
188
+ if (n != null) return e.find(({ dto: e }) => e.sourcePath === n.sourcePath && e.destinationPath === n.destinationPath) ?? e.find(({ dto: e }) => e.destinationPath === n.destinationPath) ?? e[0];
189
+ }, ke = (e, t, r, i, a) => {
190
+ let o = e.get(r);
191
+ if (o == null) return [];
192
+ let s = i.replace(/\/$/, "");
193
+ return o.map((o) => {
194
+ let c = o.nodeType === P.Folder, l = n(o.name), u = c ? `${s}/${l}/` : `${s}/${l}`, d = {
195
+ id: o.path,
196
+ name: l,
197
+ path: u,
198
+ url: o.url,
199
+ parentPath: i,
200
+ nodeType: c ? H.FOLDER : H.ITEM,
201
+ folderId: a,
202
+ bucket: o.bucket,
203
+ author: o.author,
204
+ resourceType: o.resourceType,
205
+ contentLength: o.contentLength,
206
+ contentType: o.contentType,
207
+ updatedAt: o.updatedAt ? new Date(o.updatedAt).toISOString() : void 0
208
+ };
209
+ if (c) {
210
+ let n = `${r}${l}/`;
211
+ d.permissions = De(o.permissions) ?? De(t.get(n)), d.items = ke(e, t, n, u, o.path);
212
+ }
213
+ return d;
214
+ });
215
+ }, Ae = (e, t, n, r) => {
216
+ let i = new Map(e), a = [...i.get(t) ?? []], o = {
217
+ name: n.name,
218
+ path: n.path,
219
+ folderId: n.folderId,
220
+ nodeType: P.Folder,
221
+ bucket: n.bucket,
222
+ parentPath: n.parentPath || void 0,
223
+ url: n.path,
224
+ permissions: r
225
+ };
226
+ return a.some((e) => e.name.toLowerCase() === n.name.toLowerCase()) || a.push(o), i.set(t, a), i;
227
+ }, je = (e, t, n) => {
228
+ if (!e) return e;
229
+ let r = typeof n == "string" ? { status: n } : n, i = e.files.map((e, n) => n === t ? {
230
+ ...e,
231
+ ...r
232
+ } : e);
233
+ return {
234
+ ...e,
235
+ files: i
236
+ };
237
+ }, Me = (e, t, n, r, i) => {
238
+ if (t === V.Shared) {
239
+ if (r === "") return e.listSharedFiles({ path: void 0 }).then((e) => ({ items: e.items }));
240
+ let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
241
+ if (a) {
242
+ let n = Z(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1));
243
+ return e.listFiles({
244
+ bucket: a.bucket,
245
+ path: n,
246
+ permissions: !0
247
+ }).then((e) => ({
248
+ items: e.items,
249
+ permissions: e.permissions
250
+ }));
251
+ }
252
+ return Promise.resolve({ items: [] });
253
+ }
254
+ return t === V.Organization ? e.listPublicFiles({ path: r || void 0 }).then((e) => ({ items: e.items })) : e.listFiles({
255
+ bucket: n,
256
+ path: r,
257
+ permissions: !0
258
+ }).then((e) => ({
259
+ items: e.items,
260
+ permissions: e.permissions
261
+ }));
262
+ }, Ne = async (e, t, n, r, i) => {
263
+ if (t === V.Shared) {
264
+ let t = r.indexOf("/"), n = t === -1 ? r : r.slice(0, t), a = i.get(n);
265
+ if (!a) return { items: [] };
266
+ let o = Z(a.dialCorePath, a.bucket) + (t === -1 ? "" : r.slice(t + 1)), { items: s } = await e.listFiles({
267
+ bucket: a.bucket,
268
+ path: o,
269
+ permissions: !0,
270
+ recursive: !0
271
+ });
272
+ return { items: s };
273
+ }
274
+ if (t === V.Organization) {
275
+ let { items: t } = await e.listPublicFiles({
276
+ path: r || void 0,
277
+ recursive: !0
278
+ });
279
+ return { items: t };
280
+ }
281
+ let { items: a } = await e.listFiles({
282
+ bucket: n,
283
+ path: r,
284
+ permissions: !0,
285
+ recursive: !0
286
+ });
287
+ return { items: a };
288
+ }, Pe = (e, t, r) => {
289
+ let i = e.nodeType === P.Folder, a = n(e.name), o = e.bucket ?? t, s = Z(e.url ?? e.path ?? "", o).replace(/\/$/, ""), c = s.lastIndexOf("/"), l = c > 0 ? s.slice(0, c) : "", u = l ? `/${r}/${l}` : `/${r}`, d = i ? `${u}/${a}/` : `${u}/${a}`;
290
+ return {
291
+ id: e.path,
292
+ name: a,
293
+ path: d,
294
+ url: e.url,
295
+ parentPath: u,
296
+ nodeType: i ? H.FOLDER : H.ITEM,
297
+ folderId: e.folderId,
298
+ bucket: o,
299
+ author: e.author,
300
+ contentLength: e.contentLength,
301
+ contentType: e.contentType,
302
+ updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : void 0
303
+ };
304
+ }, Fe = (e, t) => ({
305
+ ...t,
306
+ bucket: e.bucket ?? t.bucket,
307
+ author: e.author,
308
+ contentLength: e.contentLength,
309
+ contentType: e.contentType,
310
+ resourceType: e.resourceType ?? t.resourceType,
311
+ permissions: De(e.permissions) ?? t.permissions,
312
+ updatedAt: e.updatedAt ? new Date(e.updatedAt).toISOString() : t.updatedAt,
313
+ createdAt: e.createdAt ? new Date(e.createdAt).toISOString() : t.createdAt
314
+ }), Ie = (e) => e instanceof AbortSignal ? { signal: e } : e ?? {}, Le = (e, t) => ({
315
+ listPublicFiles: (t) => e.listPublicFiles(t),
316
+ listSharedFiles: (t) => e.listSharedFiles(t),
317
+ listFiles: (t, n) => e.listFiles(t, n ? { signal: n } : void 0),
318
+ uploadFile: (n, r, i, a) => {
319
+ let { signal: o, onProgress: s, uploadMode: c } = Ie(a);
320
+ return s == null ? e.uploadFile({
321
+ bucket: n,
322
+ path: r,
323
+ file: i,
324
+ uploadMode: c
325
+ }, o ? { signal: o } : void 0) : t(n, r, i, {
326
+ signal: o,
327
+ onProgress: s,
328
+ uploadMode: c
329
+ });
330
+ },
331
+ uploadArchive: (t, n, r) => e.uploadArchive({
332
+ file: t,
333
+ bucket: n,
334
+ destinationPath: r
335
+ }),
336
+ getFileMetadata: (t) => e.getFileMetadata(t),
337
+ downloadFile: async (t, n, r) => (await e.downloadFileRaw({
338
+ bucket: t,
339
+ path: n
340
+ }, ...r ? [{ signal: r }] : [])).raw,
341
+ createFolder: (t) => e.createFolder({ createFolderDto: t }),
342
+ deleteFiles: (t) => e.deleteFiles({ deleteFilesDto: { items: t } }),
343
+ renameFiles: (t) => e.renameFiles({ renameFilesDto: { items: t } }),
344
+ copyFiles: (t, n) => e.copyFiles({ copyFilesDto: { items: t } }, n ? { signal: n } : void 0),
345
+ moveFiles: (t, n) => e.moveFiles({ moveFilesDto: { items: t } }, n ? { signal: n } : void 0),
346
+ downloadArchive: async (t) => (await e.downloadArchiveRaw({ downloadArchiveDto: { items: t } })).raw,
347
+ revokeAccess: (t) => e.revokeAccess({ revokeAccessDto: { items: t } }),
348
+ discardShared: (t) => e.discardShared({ discardSharedDto: { items: t } }),
349
+ listSharedByMe: (t) => e.listSharedByMe({ bucket: t })
350
+ }), Re = (e) => {
351
+ let { uploadUrl: t, xhrFactory: n = () => new XMLHttpRequest() } = e;
352
+ return (r, i, a, { signal: o, onProgress: s, uploadMode: c } = {}) => new Promise((l, u) => {
353
+ let d = n();
354
+ d.open("POST", t), d.withCredentials = !0;
355
+ let f = e.getCsrfToken();
356
+ f != null && d.setRequestHeader("X-CSRF-Token", f);
357
+ let p = new FormData();
358
+ if (p.append("file", a), p.append("bucket", r), p.append("path", i), c != null && p.append("uploadMode", c), d.upload.addEventListener("progress", (e) => {
359
+ !s || !e.lengthComputable || e.total <= 0 || s(Math.min(100, Math.round(e.loaded / e.total * 100)));
360
+ }), d.addEventListener("load", () => {
361
+ let n = d.getResponseHeader("x-csrf-token");
362
+ if (n && e.setCsrfToken(n), d.status >= 200 && d.status < 300) {
363
+ try {
364
+ l(JSON.parse(d.responseText));
365
+ } catch {
366
+ u(/* @__PURE__ */ Error("Upload response was not valid JSON"));
367
+ }
368
+ return;
369
+ }
370
+ if (d.status === 401) {
371
+ e.notifyUnauthorized(t), u(e.createUnauthorizedError(t));
372
+ return;
373
+ }
374
+ u(/* @__PURE__ */ Error(`Upload failed with status ${d.status}`));
375
+ }), d.addEventListener("error", () => {
376
+ u(/* @__PURE__ */ Error("Upload failed"));
377
+ }), d.addEventListener("abort", () => {
378
+ u(new DOMException("Upload aborted", "AbortError"));
379
+ }), o != null) {
380
+ if (o.aborted) {
381
+ d.abort();
382
+ return;
383
+ }
384
+ o.addEventListener("abort", () => d.abort(), { once: !0 });
385
+ }
386
+ d.send(p);
387
+ });
388
+ }, ze = (t, n) => {
389
+ let { url: r } = t;
390
+ if (r == null) return;
391
+ let i = r.split("#")[0];
392
+ if (e(i)) {
393
+ let e = n(i);
394
+ if (e == null) return;
395
+ S(e, t.title ?? i.split("/").pop() ?? "");
396
+ } else window.open(r, "_blank", "noopener,noreferrer");
397
+ }, Be = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, Ve = /* @__PURE__ */ new Set(), He = typeof process == "object" && process ? process : {}, Ue = (e, t, n, r) => {
398
+ typeof He.emitWarning == "function" ? He.emitWarning(e, t, n, r) : console.error(`[${n}] ${t}: ${e}`);
399
+ }, We = globalThis.AbortController, Ge = globalThis.AbortSignal;
400
+ /* c8 ignore start */
401
+ if (We === void 0) {
402
+ Ge = class {
403
+ onabort;
404
+ _onabort = [];
405
+ reason;
406
+ aborted = !1;
407
+ addEventListener(e, t) {
408
+ this._onabort.push(t);
409
+ }
410
+ }, We = class {
411
+ constructor() {
412
+ t();
413
+ }
414
+ signal = new Ge();
415
+ abort(e) {
416
+ if (!this.signal.aborted) {
417
+ this.signal.reason = e, this.signal.aborted = !0;
418
+ for (let t of this.signal._onabort) t(e);
419
+ this.signal.onabort?.(e);
420
+ }
421
+ }
422
+ };
423
+ let e = He.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
424
+ e && (e = !1, Ue("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
425
+ };
426
+ }
427
+ /* c8 ignore stop */
428
+ var Ke = (e) => !Ve.has(e), $ = (e) => e && e === Math.floor(e) && e > 0 && isFinite(e), qe = (e) => $(e) ? e <= 2 ** 8 ? Uint8Array : e <= 2 ** 16 ? Uint16Array : e <= 2 ** 32 ? Uint32Array : e <= 2 ** 53 - 1 ? Je : null : null, Je = class extends Array {
429
+ constructor(e) {
430
+ super(e), this.fill(0);
431
+ }
432
+ }, Ye = class e {
433
+ heap;
434
+ length;
435
+ static #e = !1;
436
+ static create(t) {
437
+ let n = qe(t);
438
+ if (!n) return [];
439
+ e.#e = !0;
440
+ let r = new e(t, n);
441
+ return e.#e = !1, r;
442
+ }
443
+ constructor(t, n) {
444
+ /* c8 ignore start */
445
+ if (!e.#e) throw TypeError("instantiate Stack using Stack.create(n)");
446
+ this.heap = new n(t), this.length = 0;
447
+ }
448
+ push(e) {
449
+ this.heap[this.length++] = e;
450
+ }
451
+ pop() {
452
+ return this.heap[--this.length];
453
+ }
454
+ }, Xe = class e {
455
+ #e;
456
+ #t;
457
+ #n;
458
+ #r;
459
+ #i;
460
+ #a;
461
+ ttl;
462
+ ttlResolution;
463
+ ttlAutopurge;
464
+ updateAgeOnGet;
465
+ updateAgeOnHas;
466
+ allowStale;
467
+ noDisposeOnSet;
468
+ noUpdateTTL;
469
+ maxEntrySize;
470
+ sizeCalculation;
471
+ noDeleteOnFetchRejection;
472
+ noDeleteOnStaleGet;
473
+ allowStaleOnFetchAbort;
474
+ allowStaleOnFetchRejection;
475
+ ignoreFetchAbort;
476
+ #o;
477
+ #s;
478
+ #c;
479
+ #l;
480
+ #u;
481
+ #d;
482
+ #f;
483
+ #p;
484
+ #m;
485
+ #h;
486
+ #g;
487
+ #_;
488
+ #v;
489
+ #y;
490
+ #b;
491
+ #x;
492
+ #S;
493
+ static unsafeExposeInternals(e) {
494
+ return {
495
+ starts: e.#v,
496
+ ttls: e.#y,
497
+ sizes: e.#_,
498
+ keyMap: e.#c,
499
+ keyList: e.#l,
500
+ valList: e.#u,
501
+ next: e.#d,
502
+ prev: e.#f,
503
+ get head() {
504
+ return e.#p;
505
+ },
506
+ get tail() {
507
+ return e.#m;
508
+ },
509
+ free: e.#h,
510
+ isBackgroundFetch: (t) => e.#L(t),
511
+ backgroundFetch: (t, n, r, i) => e.#I(t, n, r, i),
512
+ moveToTail: (t) => e.#z(t),
513
+ indexes: (t) => e.#M(t),
514
+ rindexes: (t) => e.#N(t),
515
+ isStale: (t) => e.#D(t)
516
+ };
517
+ }
518
+ get max() {
519
+ return this.#e;
520
+ }
521
+ get maxSize() {
522
+ return this.#t;
523
+ }
524
+ get calculatedSize() {
525
+ return this.#s;
526
+ }
527
+ get size() {
528
+ return this.#o;
529
+ }
530
+ get fetchMethod() {
531
+ return this.#i;
532
+ }
533
+ get memoMethod() {
534
+ return this.#a;
535
+ }
536
+ get dispose() {
537
+ return this.#n;
538
+ }
539
+ get disposeAfter() {
540
+ return this.#r;
541
+ }
542
+ constructor(t) {
543
+ let { max: n = 0, ttl: r, ttlResolution: i = 1, ttlAutopurge: a, updateAgeOnGet: o, updateAgeOnHas: s, allowStale: c, dispose: l, disposeAfter: u, noDisposeOnSet: d, noUpdateTTL: f, maxSize: p = 0, maxEntrySize: m = 0, sizeCalculation: h, fetchMethod: g, memoMethod: _, noDeleteOnFetchRejection: v, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: x, ignoreFetchAbort: S } = t;
544
+ if (n !== 0 && !$(n)) throw TypeError("max option must be a nonnegative integer");
545
+ let C = n ? qe(n) : Array;
546
+ if (!C) throw Error("invalid max value: " + n);
547
+ if (this.#e = n, this.#t = p, this.maxEntrySize = m || this.#t, this.sizeCalculation = h, this.sizeCalculation) {
548
+ if (!this.#t && !this.maxEntrySize) throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
549
+ if (typeof this.sizeCalculation != "function") throw TypeError("sizeCalculation set to non-function");
550
+ }
551
+ if (_ !== void 0 && typeof _ != "function") throw TypeError("memoMethod must be a function if defined");
552
+ if (this.#a = _, g !== void 0 && typeof g != "function") throw TypeError("fetchMethod must be a function if specified");
553
+ if (this.#i = g, this.#x = !!g, this.#c = /* @__PURE__ */ new Map(), this.#l = Array(n).fill(void 0), this.#u = Array(n).fill(void 0), this.#d = new C(n), this.#f = new C(n), this.#p = 0, this.#m = 0, this.#h = Ye.create(n), this.#o = 0, this.#s = 0, typeof l == "function" && (this.#n = l), typeof u == "function" ? (this.#r = u, this.#g = []) : (this.#r = void 0, this.#g = void 0), this.#b = !!this.#n, this.#S = !!this.#r, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!v, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!x, this.ignoreFetchAbort = !!S, this.maxEntrySize !== 0) {
554
+ if (this.#t !== 0 && !$(this.#t)) throw TypeError("maxSize must be a positive integer if specified");
555
+ if (!$(this.maxEntrySize)) throw TypeError("maxEntrySize must be a positive integer if specified");
556
+ this.#O();
557
+ }
558
+ if (this.allowStale = !!c, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!s, this.ttlResolution = $(i) || i === 0 ? i : 1, this.ttlAutopurge = !!a, this.ttl = r || 0, this.ttl) {
559
+ if (!$(this.ttl)) throw TypeError("ttl must be a positive integer if specified");
560
+ this.#C();
561
+ }
562
+ if (this.#e === 0 && this.ttl === 0 && this.#t === 0) throw TypeError("At least one of max, maxSize, or ttl is required");
563
+ if (!this.ttlAutopurge && !this.#e && !this.#t) {
564
+ let t = "LRU_CACHE_UNBOUNDED";
565
+ Ke(t) && (Ve.add(t), Ue("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", t, e));
566
+ }
567
+ }
568
+ getRemainingTTL(e) {
569
+ return this.#c.has(e) ? Infinity : 0;
570
+ }
571
+ #C() {
572
+ let e = new Je(this.#e), t = new Je(this.#e);
573
+ this.#y = e, this.#v = t, this.#E = (n, r, i = Be.now()) => {
574
+ if (t[n] = r === 0 ? 0 : i, e[n] = r, r !== 0 && this.ttlAutopurge) {
575
+ let e = setTimeout(() => {
576
+ this.#D(n) && this.#B(this.#l[n], "expire");
577
+ }, r + 1);
578
+ /* c8 ignore start */
579
+ e.unref && e.unref();
580
+ }
581
+ }, this.#w = (n) => {
582
+ t[n] = e[n] === 0 ? 0 : Be.now();
583
+ }, this.#T = (i, a) => {
584
+ if (e[a]) {
585
+ let o = e[a], s = t[a];
586
+ /* c8 ignore next */
587
+ if (!o || !s) return;
588
+ i.ttl = o, i.start = s, i.now = n || r(), i.remainingTTL = o - (i.now - s);
589
+ }
590
+ };
591
+ let n = 0, r = () => {
592
+ let e = Be.now();
593
+ if (this.ttlResolution > 0) {
594
+ n = e;
595
+ let t = setTimeout(() => n = 0, this.ttlResolution);
596
+ /* c8 ignore start */
597
+ t.unref && t.unref();
598
+ }
599
+ return e;
600
+ };
601
+ this.getRemainingTTL = (i) => {
602
+ let a = this.#c.get(i);
603
+ if (a === void 0) return 0;
604
+ let o = e[a], s = t[a];
605
+ return !o || !s ? Infinity : o - ((n || r()) - s);
606
+ }, this.#D = (i) => {
607
+ let a = t[i], o = e[i];
608
+ return !!o && !!a && (n || r()) - a > o;
609
+ };
610
+ }
611
+ #w = () => {};
612
+ #T = () => {};
613
+ #E = () => {};
614
+ /* c8 ignore stop */
615
+ #D = () => !1;
616
+ #O() {
617
+ let e = new Je(this.#e);
618
+ this.#s = 0, this.#_ = e, this.#k = (t) => {
619
+ this.#s -= e[t], e[t] = 0;
620
+ }, this.#j = (e, t, n, r) => {
621
+ if (this.#L(t)) return 0;
622
+ if (!$(n)) if (r) {
623
+ if (typeof r != "function") throw TypeError("sizeCalculation must be a function");
624
+ if (n = r(t, e), !$(n)) throw TypeError("sizeCalculation return invalid (expect positive integer)");
625
+ } else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
626
+ return n;
627
+ }, this.#A = (t, n, r) => {
628
+ if (e[t] = n, this.#t) {
629
+ let n = this.#t - e[t];
630
+ for (; this.#s > n;) this.#F(!0);
631
+ }
632
+ this.#s += e[t], r && (r.entrySize = n, r.totalCalculatedSize = this.#s);
633
+ };
634
+ }
635
+ #k = (e) => {};
636
+ #A = (e, t, n) => {};
637
+ #j = (e, t, n, r) => {
638
+ if (n || r) throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
639
+ return 0;
640
+ };
641
+ *#M({ allowStale: e = this.allowStale } = {}) {
642
+ if (this.#o) for (let t = this.#m; !(!this.#P(t) || ((e || !this.#D(t)) && (yield t), t === this.#p));) t = this.#f[t];
643
+ }
644
+ *#N({ allowStale: e = this.allowStale } = {}) {
645
+ if (this.#o) for (let t = this.#p; !(!this.#P(t) || ((e || !this.#D(t)) && (yield t), t === this.#m));) t = this.#d[t];
646
+ }
647
+ #P(e) {
648
+ return e !== void 0 && this.#c.get(this.#l[e]) === e;
649
+ }
650
+ *entries() {
651
+ for (let e of this.#M()) this.#u[e] !== void 0 && this.#l[e] !== void 0 && !this.#L(this.#u[e]) && (yield [this.#l[e], this.#u[e]]);
652
+ }
653
+ *rentries() {
654
+ for (let e of this.#N()) this.#u[e] !== void 0 && this.#l[e] !== void 0 && !this.#L(this.#u[e]) && (yield [this.#l[e], this.#u[e]]);
655
+ }
656
+ *keys() {
657
+ for (let e of this.#M()) {
658
+ let t = this.#l[e];
659
+ t !== void 0 && !this.#L(this.#u[e]) && (yield t);
660
+ }
661
+ }
662
+ *rkeys() {
663
+ for (let e of this.#N()) {
664
+ let t = this.#l[e];
665
+ t !== void 0 && !this.#L(this.#u[e]) && (yield t);
666
+ }
667
+ }
668
+ *values() {
669
+ for (let e of this.#M()) this.#u[e] !== void 0 && !this.#L(this.#u[e]) && (yield this.#u[e]);
670
+ }
671
+ *rvalues() {
672
+ for (let e of this.#N()) this.#u[e] !== void 0 && !this.#L(this.#u[e]) && (yield this.#u[e]);
673
+ }
674
+ [Symbol.iterator]() {
675
+ return this.entries();
676
+ }
677
+ [Symbol.toStringTag] = "LRUCache";
678
+ find(e, t = {}) {
679
+ for (let n of this.#M()) {
680
+ let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
681
+ if (i !== void 0 && e(i, this.#l[n], this)) return this.get(this.#l[n], t);
682
+ }
683
+ }
684
+ forEach(e, t = this) {
685
+ for (let n of this.#M()) {
686
+ let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
687
+ i !== void 0 && e.call(t, i, this.#l[n], this);
688
+ }
689
+ }
690
+ rforEach(e, t = this) {
691
+ for (let n of this.#N()) {
692
+ let r = this.#u[n], i = this.#L(r) ? r.__staleWhileFetching : r;
693
+ i !== void 0 && e.call(t, i, this.#l[n], this);
694
+ }
695
+ }
696
+ purgeStale() {
697
+ let e = !1;
698
+ for (let t of this.#N({ allowStale: !0 })) this.#D(t) && (this.#B(this.#l[t], "expire"), e = !0);
699
+ return e;
700
+ }
701
+ info(e) {
702
+ let t = this.#c.get(e);
703
+ if (t === void 0) return;
704
+ let n = this.#u[t], r = this.#L(n) ? n.__staleWhileFetching : n;
705
+ if (r === void 0) return;
706
+ let i = { value: r };
707
+ if (this.#y && this.#v) {
708
+ let e = this.#y[t], n = this.#v[t];
709
+ e && n && (i.ttl = e - (Be.now() - n), i.start = Date.now());
710
+ }
711
+ return this.#_ && (i.size = this.#_[t]), i;
712
+ }
713
+ dump() {
714
+ let e = [];
715
+ for (let t of this.#M({ allowStale: !0 })) {
716
+ let n = this.#l[t], r = this.#u[t], i = this.#L(r) ? r.__staleWhileFetching : r;
717
+ if (i === void 0 || n === void 0) continue;
718
+ let a = { value: i };
719
+ if (this.#y && this.#v) {
720
+ a.ttl = this.#y[t];
721
+ let e = Be.now() - this.#v[t];
722
+ a.start = Math.floor(Date.now() - e);
723
+ }
724
+ this.#_ && (a.size = this.#_[t]), e.unshift([n, a]);
725
+ }
726
+ return e;
727
+ }
728
+ load(e) {
729
+ this.clear();
730
+ for (let [t, n] of e) {
731
+ if (n.start) {
732
+ let e = Date.now() - n.start;
733
+ n.start = Be.now() - e;
734
+ }
735
+ this.set(t, n.value, n);
736
+ }
737
+ }
738
+ set(e, t, n = {}) {
739
+ if (t === void 0) return this.delete(e), this;
740
+ let { ttl: r = this.ttl, start: i, noDisposeOnSet: a = this.noDisposeOnSet, sizeCalculation: o = this.sizeCalculation, status: s } = n, { noUpdateTTL: c = this.noUpdateTTL } = n, l = this.#j(e, t, n.size || 0, o);
741
+ if (this.maxEntrySize && l > this.maxEntrySize) return s && (s.set = "miss", s.maxEntrySizeExceeded = !0), this.#B(e, "set"), this;
742
+ let u = this.#o === 0 ? void 0 : this.#c.get(e);
743
+ if (u === void 0) u = this.#o === 0 ? this.#m : this.#h.length === 0 ? this.#o === this.#e ? this.#F(!1) : this.#o : this.#h.pop(), this.#l[u] = e, this.#u[u] = t, this.#c.set(e, u), this.#d[this.#m] = u, this.#f[u] = this.#m, this.#m = u, this.#o++, this.#A(u, l, s), s && (s.set = "add"), c = !1;
744
+ else {
745
+ this.#z(u);
746
+ let n = this.#u[u];
747
+ if (t !== n) {
748
+ if (this.#x && this.#L(n)) {
749
+ n.__abortController.abort(/* @__PURE__ */ Error("replaced"));
750
+ let { __staleWhileFetching: t } = n;
751
+ t !== void 0 && !a && (this.#b && this.#n?.(t, e, "set"), this.#S && this.#g?.push([
752
+ t,
753
+ e,
754
+ "set"
755
+ ]));
756
+ } else a || (this.#b && this.#n?.(n, e, "set"), this.#S && this.#g?.push([
757
+ n,
758
+ e,
759
+ "set"
760
+ ]));
761
+ if (this.#k(u), this.#A(u, l, s), this.#u[u] = t, s) {
762
+ s.set = "replace";
763
+ let e = n && this.#L(n) ? n.__staleWhileFetching : n;
764
+ e !== void 0 && (s.oldValue = e);
765
+ }
766
+ } else s && (s.set = "update");
767
+ }
768
+ if (r !== 0 && !this.#y && this.#C(), this.#y && (c || this.#E(u, r, i), s && this.#T(s, u)), !a && this.#S && this.#g) {
769
+ let e = this.#g, t;
770
+ for (; t = e?.shift();) this.#r?.(...t);
771
+ }
772
+ return this;
773
+ }
774
+ pop() {
775
+ try {
776
+ for (; this.#o;) {
777
+ let e = this.#u[this.#p];
778
+ if (this.#F(!0), this.#L(e)) {
779
+ if (e.__staleWhileFetching) return e.__staleWhileFetching;
780
+ } else if (e !== void 0) return e;
781
+ }
782
+ } finally {
783
+ if (this.#S && this.#g) {
784
+ let e = this.#g, t;
785
+ for (; t = e?.shift();) this.#r?.(...t);
786
+ }
787
+ }
788
+ }
789
+ #F(e) {
790
+ let t = this.#p, n = this.#l[t], r = this.#u[t];
791
+ return this.#x && this.#L(r) ? r.__abortController.abort(/* @__PURE__ */ Error("evicted")) : (this.#b || this.#S) && (this.#b && this.#n?.(r, n, "evict"), this.#S && this.#g?.push([
792
+ r,
793
+ n,
794
+ "evict"
795
+ ])), this.#k(t), e && (this.#l[t] = void 0, this.#u[t] = void 0, this.#h.push(t)), this.#o === 1 ? (this.#p = this.#m = 0, this.#h.length = 0) : this.#p = this.#d[t], this.#c.delete(n), this.#o--, t;
796
+ }
797
+ has(e, t = {}) {
798
+ let { updateAgeOnHas: n = this.updateAgeOnHas, status: r } = t, i = this.#c.get(e);
799
+ if (i !== void 0) {
800
+ let e = this.#u[i];
801
+ if (this.#L(e) && e.__staleWhileFetching === void 0) return !1;
802
+ if (this.#D(i)) r && (r.has = "stale", this.#T(r, i));
803
+ else return n && this.#w(i), r && (r.has = "hit", this.#T(r, i)), !0;
804
+ } else r && (r.has = "miss");
805
+ return !1;
806
+ }
807
+ peek(e, t = {}) {
808
+ let { allowStale: n = this.allowStale } = t, r = this.#c.get(e);
809
+ if (r === void 0 || !n && this.#D(r)) return;
810
+ let i = this.#u[r];
811
+ return this.#L(i) ? i.__staleWhileFetching : i;
812
+ }
813
+ #I(e, t, n, r) {
814
+ let i = t === void 0 ? void 0 : this.#u[t];
815
+ if (this.#L(i)) return i;
816
+ let a = new We(), { signal: o } = n;
817
+ o?.addEventListener("abort", () => a.abort(o.reason), { signal: a.signal });
818
+ let s = {
819
+ signal: a.signal,
820
+ options: n,
821
+ context: r
822
+ }, c = (r, i = !1) => {
823
+ let { aborted: o } = a.signal, c = n.ignoreFetchAbort && r !== void 0;
824
+ if (n.status && (o && !i ? (n.status.fetchAborted = !0, n.status.fetchError = a.signal.reason, c && (n.status.fetchAbortIgnored = !0)) : n.status.fetchResolved = !0), o && !c && !i) return u(a.signal.reason);
825
+ let l = f;
826
+ return this.#u[t] === f && (r === void 0 ? l.__staleWhileFetching ? this.#u[t] = l.__staleWhileFetching : this.#B(e, "fetch") : (n.status && (n.status.fetchUpdated = !0), this.set(e, r, s.options))), r;
827
+ }, l = (e) => (n.status && (n.status.fetchRejected = !0, n.status.fetchError = e), u(e)), u = (r) => {
828
+ let { aborted: i } = a.signal, o = i && n.allowStaleOnFetchAbort, s = o || n.allowStaleOnFetchRejection, c = s || n.noDeleteOnFetchRejection, l = f;
829
+ if (this.#u[t] === f && (!c || l.__staleWhileFetching === void 0 ? this.#B(e, "fetch") : o || (this.#u[t] = l.__staleWhileFetching)), s) return n.status && l.__staleWhileFetching !== void 0 && (n.status.returnedStale = !0), l.__staleWhileFetching;
830
+ if (l.__returned === l) throw r;
831
+ }, d = (t, r) => {
832
+ let o = this.#i?.(e, i, s);
833
+ o && o instanceof Promise && o.then((e) => t(e === void 0 ? void 0 : e), r), a.signal.addEventListener("abort", () => {
834
+ (!n.ignoreFetchAbort || n.allowStaleOnFetchAbort) && (t(void 0), n.allowStaleOnFetchAbort && (t = (e) => c(e, !0)));
835
+ });
836
+ };
837
+ n.status && (n.status.fetchDispatched = !0);
838
+ let f = new Promise(d).then(c, l), p = Object.assign(f, {
839
+ __abortController: a,
840
+ __staleWhileFetching: i,
841
+ __returned: void 0
842
+ });
843
+ return t === void 0 ? (this.set(e, p, {
844
+ ...s.options,
845
+ status: void 0
846
+ }), t = this.#c.get(e)) : this.#u[t] = p, p;
847
+ }
848
+ #L(e) {
849
+ if (!this.#x) return !1;
850
+ let t = e;
851
+ return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof We;
852
+ }
853
+ async fetch(e, t = {}) {
854
+ let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, ttl: a = this.ttl, noDisposeOnSet: o = this.noDisposeOnSet, size: s = 0, sizeCalculation: c = this.sizeCalculation, noUpdateTTL: l = this.noUpdateTTL, noDeleteOnFetchRejection: u = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: m, forceRefresh: h = !1, status: g, signal: _ } = t;
855
+ if (!this.#x) return g && (g.fetch = "get"), this.get(e, {
856
+ allowStale: n,
857
+ updateAgeOnGet: r,
858
+ noDeleteOnStaleGet: i,
859
+ status: g
860
+ });
861
+ let v = {
862
+ allowStale: n,
863
+ updateAgeOnGet: r,
864
+ noDeleteOnStaleGet: i,
865
+ ttl: a,
866
+ noDisposeOnSet: o,
867
+ size: s,
868
+ sizeCalculation: c,
869
+ noUpdateTTL: l,
870
+ noDeleteOnFetchRejection: u,
871
+ allowStaleOnFetchRejection: d,
872
+ allowStaleOnFetchAbort: p,
873
+ ignoreFetchAbort: f,
874
+ status: g,
875
+ signal: _
876
+ }, y = this.#c.get(e);
877
+ if (y === void 0) {
878
+ g && (g.fetch = "miss");
879
+ let t = this.#I(e, y, v, m);
880
+ return t.__returned = t;
881
+ } else {
882
+ let t = this.#u[y];
883
+ if (this.#L(t)) {
884
+ let e = n && t.__staleWhileFetching !== void 0;
885
+ return g && (g.fetch = "inflight", e && (g.returnedStale = !0)), e ? t.__staleWhileFetching : t.__returned = t;
886
+ }
887
+ let i = this.#D(y);
888
+ if (!h && !i) return g && (g.fetch = "hit"), this.#z(y), r && this.#w(y), g && this.#T(g, y), t;
889
+ let a = this.#I(e, y, v, m), o = a.__staleWhileFetching !== void 0 && n;
890
+ return g && (g.fetch = i ? "stale" : "refresh", o && i && (g.returnedStale = !0)), o ? a.__staleWhileFetching : a.__returned = a;
891
+ }
892
+ }
893
+ async forceFetch(e, t = {}) {
894
+ let n = await this.fetch(e, t);
895
+ if (n === void 0) throw Error("fetch() returned undefined");
896
+ return n;
897
+ }
898
+ memo(e, t = {}) {
899
+ let n = this.#a;
900
+ if (!n) throw Error("no memoMethod provided to constructor");
901
+ let { context: r, forceRefresh: i, ...a } = t, o = this.get(e, a);
902
+ if (!i && o !== void 0) return o;
903
+ let s = n(e, o, {
904
+ options: a,
905
+ context: r
906
+ });
907
+ return this.set(e, s, a), s;
908
+ }
909
+ get(e, t = {}) {
910
+ let { allowStale: n = this.allowStale, updateAgeOnGet: r = this.updateAgeOnGet, noDeleteOnStaleGet: i = this.noDeleteOnStaleGet, status: a } = t, o = this.#c.get(e);
911
+ if (o !== void 0) {
912
+ let t = this.#u[o], s = this.#L(t);
913
+ return a && this.#T(a, o), this.#D(o) ? (a && (a.get = "stale"), s ? (a && n && t.__staleWhileFetching !== void 0 && (a.returnedStale = !0), n ? t.__staleWhileFetching : void 0) : (i || this.#B(e, "expire"), a && n && (a.returnedStale = !0), n ? t : void 0)) : (a && (a.get = "hit"), s ? t.__staleWhileFetching : (this.#z(o), r && this.#w(o), t));
914
+ } else a && (a.get = "miss");
915
+ }
916
+ #R(e, t) {
917
+ this.#f[t] = e, this.#d[e] = t;
918
+ }
919
+ #z(e) {
920
+ e !== this.#m && (e === this.#p ? this.#p = this.#d[e] : this.#R(this.#f[e], this.#d[e]), this.#R(this.#m, e), this.#m = e);
921
+ }
922
+ delete(e) {
923
+ return this.#B(e, "delete");
924
+ }
925
+ #B(e, t) {
926
+ let n = !1;
927
+ if (this.#o !== 0) {
928
+ let r = this.#c.get(e);
929
+ if (r !== void 0) if (n = !0, this.#o === 1) this.#V(t);
930
+ else {
931
+ this.#k(r);
932
+ let n = this.#u[r];
933
+ if (this.#L(n) ? n.__abortController.abort(/* @__PURE__ */ Error("deleted")) : (this.#b || this.#S) && (this.#b && this.#n?.(n, e, t), this.#S && this.#g?.push([
934
+ n,
935
+ e,
936
+ t
937
+ ])), this.#c.delete(e), this.#l[r] = void 0, this.#u[r] = void 0, r === this.#m) this.#m = this.#f[r];
938
+ else if (r === this.#p) this.#p = this.#d[r];
939
+ else {
940
+ let e = this.#f[r];
941
+ this.#d[e] = this.#d[r];
942
+ let t = this.#d[r];
943
+ this.#f[t] = this.#f[r];
944
+ }
945
+ this.#o--, this.#h.push(r);
946
+ }
947
+ }
948
+ if (this.#S && this.#g?.length) {
949
+ let e = this.#g, t;
950
+ for (; t = e?.shift();) this.#r?.(...t);
951
+ }
952
+ return n;
953
+ }
954
+ clear() {
955
+ return this.#V("delete");
956
+ }
957
+ #V(e) {
958
+ for (let t of this.#N({ allowStale: !0 })) {
959
+ let n = this.#u[t];
960
+ if (this.#L(n)) n.__abortController.abort(/* @__PURE__ */ Error("deleted"));
961
+ else {
962
+ let r = this.#l[t];
963
+ this.#b && this.#n?.(n, r, e), this.#S && this.#g?.push([
964
+ n,
965
+ r,
966
+ e
967
+ ]);
968
+ }
969
+ }
970
+ if (this.#c.clear(), this.#u.fill(void 0), this.#l.fill(void 0), this.#y && this.#v && (this.#y.fill(0), this.#v.fill(0)), this.#_ && this.#_.fill(0), this.#p = 0, this.#m = 0, this.#h.length = 0, this.#s = 0, this.#o = 0, this.#S && this.#g) {
971
+ let e = this.#g, t;
972
+ for (; t = e?.shift();) this.#r?.(...t);
973
+ }
974
+ }
975
+ }, Ze = (e, t) => URL.createObjectURL(_(e, t)), Qe = (e) => {
976
+ let t = w(e);
977
+ return t == null ? e : new TextDecoder().decode(t);
978
+ }, $e = (e, t) => ({
979
+ type: r.Error,
980
+ errorType: e === 403 ? i.Forbidden : i.LoadFailed,
981
+ url: t
982
+ }), et = (e) => ({
983
+ type: r.Error,
984
+ errorType: i.LoadFailed,
985
+ url: e
986
+ }), tt = (e) => {
987
+ let t;
988
+ try {
989
+ t = new URL(e).pathname;
990
+ } catch {
991
+ t = x(e);
992
+ }
993
+ let n = t.split("/").filter(Boolean).pop() ?? "";
994
+ try {
995
+ return decodeURIComponent(n);
996
+ } catch {
997
+ return n;
998
+ }
999
+ }, nt = (e) => e.startsWith("image/") || e.startsWith("audio/") || e === h.PDF || s("", e), rt = (e, t) => {
1000
+ if (nt(e)) return e;
1001
+ let n = tt(t), r = n.lastIndexOf(".");
1002
+ return (r === -1 ? "" : n.slice(r + 1).toLowerCase()) === f.PDF ? h.PDF : a(n) ?? e;
1003
+ }, it = (e, t) => {
1004
+ if (nt(rt(e, t))) return !0;
1005
+ let n = tt(t);
1006
+ return c(n) || o(n);
1007
+ }, at = new Xe({ max: 10 }), ot = new Xe({ max: 50 }), st = () => {
1008
+ at.clear(), ot.clear();
1009
+ }, ct = (e) => {
1010
+ let t = at.get(e);
1011
+ return t ?? (t = fetch(e).then((e) => {
1012
+ if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
1013
+ return e.blob();
1014
+ }).catch((t) => {
1015
+ throw at.delete(e), t;
1016
+ }), at.set(e, t)), t;
1017
+ }, lt = (e) => {
1018
+ let t = ot.get(e);
1019
+ return t ?? (t = fetch(e).then((e) => {
1020
+ if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
1021
+ return e.text();
1022
+ }).catch((t) => {
1023
+ throw ot.delete(e), t;
1024
+ }), ot.set(e, t)), t;
1025
+ }, ut = async (e, t) => {
1026
+ if ("file" in e) return URL.createObjectURL(e.file);
1027
+ let n = t.resolveDialUrl(e);
1028
+ if (n != null) try {
1029
+ let e = await ct(n);
1030
+ return URL.createObjectURL(e);
1031
+ } catch (e) {
1032
+ let t = e.status;
1033
+ return t == null ? et(n) : $e(t, n);
1034
+ }
1035
+ if (e.previewUrl != null) return e.previewUrl;
1036
+ if (e.data != null) return Ze(e.data, e.contentType);
1037
+ }, dt = async (e, t) => {
1038
+ if (e.data != null) return Qe(e.data);
1039
+ let n = t.resolveDialUrl(e);
1040
+ if (n != null) try {
1041
+ return await lt(n);
1042
+ } catch (e) {
1043
+ let t = e.status;
1044
+ return t == null ? et(n) : $e(t, n);
1045
+ }
1046
+ if ("file" in e) return e.file.text();
1047
+ }, ft = (e, t) => e.data != null || t.resolveDialUrl(e) != null || "file" in e, pt = (e, t) => {
1048
+ if ("file" in e) return {
1049
+ type: r.Image,
1050
+ url: URL.createObjectURL(e.file)
1051
+ };
1052
+ let n = t.resolveDialUrl(e);
1053
+ return n == null ? e.previewUrl == null ? e.data == null ? null : {
1054
+ type: r.Image,
1055
+ url: Ze(e.data, e.contentType)
1056
+ } : {
1057
+ type: r.Image,
1058
+ url: e.previewUrl
1059
+ } : {
1060
+ type: r.Image,
1061
+ url: n
1062
+ };
1063
+ }, mt = async (e, t) => {
1064
+ let n = await dt(e, t);
1065
+ return n == null ? null : typeof n == "string" ? {
1066
+ type: r.PlainText,
1067
+ text: n
1068
+ } : n;
1069
+ }, ht = async (e, t) => {
1070
+ let n = await dt(e, t);
1071
+ return n == null ? null : typeof n == "string" ? {
1072
+ type: r.Markdown,
1073
+ text: n
1074
+ } : n;
1075
+ }, gt = 1048576, _t = async (e, t, n) => {
1076
+ let i = await dt(e, t);
1077
+ return i == null ? null : typeof i == "string" ? {
1078
+ type: r.Code,
1079
+ text: i,
1080
+ language: n
1081
+ } : i;
1082
+ }, vt = async (e, t) => {
1083
+ let n = await dt(e, t);
1084
+ if (n == null) return null;
1085
+ if (typeof n != "string") return n;
1086
+ if (n.length > gt) return null;
1087
+ let i = t.resolveDialUrl(e) ?? void 0;
1088
+ return {
1089
+ type: r.Html,
1090
+ srcdoc: n,
1091
+ url: i
1092
+ };
1093
+ }, yt = (t, n, i) => {
1094
+ let a = t.body?.source?.attachment;
1095
+ if (a?.type !== h.PDF) return null;
1096
+ let o = e(a.url) ? i.resolveDialFileDownloadUrl(a.url) : a.url;
1097
+ if (o == null) return null;
1098
+ let s = n.find((e) => e.sourceUrl === a.url), c = s?.annotations ?? [t], l = s ? s.annotations.indexOf(t) : 0;
1099
+ return {
1100
+ type: r.Pdf,
1101
+ url: o,
1102
+ highlights: ee(c),
1103
+ selectedHighlightId: T(t, l)
1104
+ };
1105
+ }, bt = (t, n) => {
1106
+ let i = E(t.url);
1107
+ if (i == null) return null;
1108
+ let a = e(i.baseUrl) ? n.resolveDialFileDownloadUrl(i.baseUrl) : i.baseUrl;
1109
+ if (a == null) return null;
1110
+ if (i.page == null) return {
1111
+ type: r.Pdf,
1112
+ url: a
1113
+ };
1114
+ let o = `reference-page-${i.page}`;
1115
+ return {
1116
+ type: r.Pdf,
1117
+ url: a,
1118
+ highlights: [{
1119
+ id: o,
1120
+ bboxes: [{
1121
+ page: i.page,
1122
+ x1: 0,
1123
+ y1: 0,
1124
+ x2: 0,
1125
+ y2: 0
1126
+ }],
1127
+ style: {
1128
+ backgroundColor: "transparent",
1129
+ opacity: 0
1130
+ }
1131
+ }],
1132
+ selectedHighlightId: o
1133
+ };
1134
+ }, xt = (e) => {
1135
+ try {
1136
+ let t = new URL(e).protocol;
1137
+ return t === "http:" || t === "https:" || t === "blob:";
1138
+ } catch {
1139
+ return !1;
1140
+ }
1141
+ }, St = (t) => t.url != null && !e(t.url) && xt(t.url) ? t.url : void 0, Ct = async (e, t) => {
1142
+ let n = await ut(e, t);
1143
+ if (n != null) return typeof n == "string" ? {
1144
+ type: r.Pdf,
1145
+ url: n
1146
+ } : n;
1147
+ let i = St(e);
1148
+ return i == null ? null : {
1149
+ type: r.Pdf,
1150
+ url: i
1151
+ };
1152
+ }, wt = async (e, t, n) => {
1153
+ let i = await ut(e, t);
1154
+ if (i != null) return typeof i == "string" ? {
1155
+ type: r.Ooxml,
1156
+ url: i,
1157
+ format: n
1158
+ } : i;
1159
+ let a = St(e);
1160
+ return a == null ? null : {
1161
+ type: r.Ooxml,
1162
+ url: a,
1163
+ format: n
1164
+ };
1165
+ }, Tt = async (e, t) => {
1166
+ let n = await dt(e, t);
1167
+ if (n == null) return null;
1168
+ if (typeof n != "string") return n;
1169
+ try {
1170
+ let e = JSON.parse(n);
1171
+ return {
1172
+ type: r.Json,
1173
+ value: e
1174
+ };
1175
+ } catch {
1176
+ return {
1177
+ type: r.PlainText,
1178
+ text: n
1179
+ };
1180
+ }
1181
+ }, Et = async (e, t, n, i) => {
1182
+ let a = await dt(e, t);
1183
+ if (a == null || typeof a != "string") return null;
1184
+ let o = {};
1185
+ try {
1186
+ let e = JSON.parse(a);
1187
+ typeof e == "object" && e && (o = e);
1188
+ } catch {}
1189
+ return {
1190
+ type: r.Visualizer,
1191
+ url: n.url,
1192
+ mimeType: e.contentType,
1193
+ data: o,
1194
+ layout: {
1195
+ width: n.width,
1196
+ height: n.height,
1197
+ mobileHeight: n.mobileHeight,
1198
+ themeId: i
1199
+ },
1200
+ visualizerName: n.title,
1201
+ requestTimeout: n.requestTimeout
1202
+ };
1203
+ }, Dt = (e, t) => b(e, t), Ot = (e) => {
1204
+ let t = e.body?.source?.attachment;
1205
+ return t == null ? null : {
1206
+ id: t.url,
1207
+ name: t.url.split("/").pop() ?? t.url,
1208
+ contentType: t.type,
1209
+ type: t.type.startsWith("image/") ? l.Image : l.File,
1210
+ status: g.Idle,
1211
+ url: t.url
1212
+ };
1213
+ }, kt = (e, t) => e?.map((e) => Dt(e, t)) ?? [], At = (t, n) => {
1214
+ let r = t.url ?? t.id;
1215
+ if (r) return e(r) || r.startsWith("http://") || r.startsWith("https://") ? r : `files/${n}/${r.replace(/^\/+/, "")}`;
1216
+ }, jt = (e, t, n) => {
1217
+ if (e.nodeType !== L.ITEM) return null;
1218
+ let r = At(e, t);
1219
+ if (!r) return null;
1220
+ let i = e.contentType ?? "application/octet-stream", a = i.startsWith("image/"), o = a ? n?.resolvePreviewUrl?.(r) : void 0;
1221
+ return {
1222
+ id: r,
1223
+ name: e.name,
1224
+ contentType: i,
1225
+ type: a ? l.Image : l.File,
1226
+ status: g.Idle,
1227
+ url: r,
1228
+ file: new File([], e.name, { type: i }),
1229
+ ...o == null ? {} : { previewUrl: o }
1230
+ };
1231
+ }, Mt = (e, t, n) => e.map((e) => jt(e, t, n)).filter((e) => e != null), Nt = (e) => {
1232
+ let t = n(e.replace(/\/$/, "").split("/").filter(Boolean).pop() ?? "");
1233
+ return {
1234
+ id: e,
1235
+ name: t,
1236
+ contentType: "application/octet-stream",
1237
+ type: l.File,
1238
+ status: g.Idle,
1239
+ url: e,
1240
+ file: new File([], t)
1241
+ };
1242
+ }, Pt = /* @__PURE__ */ function(e) {
1243
+ return e.Blob = "blob", e.Stream = "stream", e.Cancelled = "cancelled", e;
1244
+ }({}), Ft = async (e, t = "application/octet-stream") => {
1245
+ let n = window.showSaveFilePicker;
1246
+ if (n == null) return { type: Pt.Blob };
1247
+ try {
1248
+ let r = e.lastIndexOf("."), i = r >= 0 ? e.slice(r) : void 0, a = await n.call(window, {
1249
+ suggestedName: e,
1250
+ types: [{
1251
+ description: t,
1252
+ accept: { [t]: i == null ? [] : [i] }
1253
+ }]
1254
+ });
1255
+ return {
1256
+ type: Pt.Stream,
1257
+ writable: await a.createWritable()
1258
+ };
1259
+ } catch (e) {
1260
+ if (e instanceof DOMException && e.name === "AbortError") return { type: Pt.Cancelled };
1261
+ throw e;
1262
+ }
1263
+ }, It = (e) => {
1264
+ let t = e.lastIndexOf("."), n = t > 0;
1265
+ return {
1266
+ base: n ? e.slice(0, t) : e,
1267
+ extension: n ? e.slice(t) : ""
1268
+ };
1269
+ }, Lt = (e, t = 255) => {
1270
+ if (y(e) <= t) return e;
1271
+ let { base: n, extension: r } = It(e), i = t - y(r);
1272
+ return i <= 0 ? C(e, t) : `${C(n, i)}${r}`;
1273
+ }, Rt = (e) => {
1274
+ let { base: t, extension: n } = It(e), r = t.replace(new RegExp(ne.source, "g"), "_").replace(/[.\s]+$/, "");
1275
+ return r === "" ? e : Lt(`${r}${n}`);
1276
+ }, zt = ({ filesApi: e, bucket: r, rootLabel: i, activeTab: a, onNotification: o }) => {
1277
+ let [s, c] = j(""), [l, u] = j(() => /* @__PURE__ */ new Map()), d = A(l);
1278
+ O(() => {
1279
+ d.current = l;
1280
+ }, [l]);
1281
+ let [f, p] = j(() => /* @__PURE__ */ new Map()), [m, h] = j(!0), [g, _] = j(null), [y, b] = j(0), [x, S] = j(void 0), [C, w] = j(() => /* @__PURE__ */ new Set()), T = A(/* @__PURE__ */ new Map()), [ee, E] = j(!1), [te, M] = j(null), N = A(null), F = A(null), I = A(/* @__PURE__ */ new Set()), L = A(/* @__PURE__ */ new Set()), [R, ne] = j(() => /* @__PURE__ */ new Set()), [B, U] = j(() => /* @__PURE__ */ new Set()), [W, re] = j(() => /* @__PURE__ */ new Set()), K = A(a);
1282
+ O(() => {
1283
+ K.current !== a && (K.current = a, u(/* @__PURE__ */ new Map()), p(/* @__PURE__ */ new Map()), c(""), S(void 0), T.current = /* @__PURE__ */ new Map(), I.current = /* @__PURE__ */ new Set(), L.current = /* @__PURE__ */ new Set(), U(/* @__PURE__ */ new Set()), re(/* @__PURE__ */ new Set()), N.current != null && (clearTimeout(N.current), N.current = null), F.current?.(), F.current = null, M(null), E(!1), ne(/* @__PURE__ */ new Set()));
1284
+ }, [a]), O(() => () => {
1285
+ N.current != null && clearTimeout(N.current), F.current?.();
1286
+ }, []), O(() => {
1287
+ let o = !1;
1288
+ return h(!0), _(null), Me(e, a, r, s, T.current).then(({ items: e, permissions: t }) => {
1289
+ o || (u((t) => {
1290
+ let n = new Map(t);
1291
+ return n.set(s, e), n;
1292
+ }), p((e) => new Map(e).set(s, t)), a === V.Shared && s === "" && (S(e.map((e) => ye(Z(e.path, e.bucket ?? ""), i, e.nodeType === P.Folder))), T.current = new Map(e.map((e) => [n(e.name), {
1293
+ bucket: e.bucket ?? "",
1294
+ dialCorePath: e.path
1295
+ }]))));
1296
+ }).catch((e) => {
1297
+ if (!o) {
1298
+ if (s !== "" && t(e) === 404) {
1299
+ c(v(s));
1300
+ return;
1301
+ }
1302
+ _("dialFileManager.error");
1303
+ }
1304
+ }).finally(() => {
1305
+ o || h(!1);
1306
+ }), () => {
1307
+ o = !0;
1308
+ };
1309
+ }, [
1310
+ a,
1311
+ r,
1312
+ e,
1313
+ s,
1314
+ y,
1315
+ i
1316
+ ]), O(() => {
1317
+ if (a !== V.MyFiles) {
1318
+ w(/* @__PURE__ */ new Set());
1319
+ return;
1320
+ }
1321
+ let t = !1;
1322
+ return e.listSharedByMe(r).then((e) => {
1323
+ t || w(new Set(e.items.map((e) => ye(Z(e.path, r), i, e.nodeType === P.Folder))));
1324
+ }).catch(() => {
1325
+ t || w(/* @__PURE__ */ new Set());
1326
+ }), () => {
1327
+ t = !0;
1328
+ };
1329
+ }, [
1330
+ a,
1331
+ r,
1332
+ e,
1333
+ y,
1334
+ i
1335
+ ]);
1336
+ let q = k(() => [{
1337
+ id: r,
1338
+ name: i,
1339
+ path: `/${i}`,
1340
+ parentPath: "",
1341
+ nodeType: H.FOLDER,
1342
+ folderId: r,
1343
+ permissions: De(f.get("")),
1344
+ items: ke(l, f, "", `/${i}`, r)
1345
+ }], [
1346
+ l,
1347
+ f,
1348
+ i,
1349
+ r
1350
+ ]), ie = D((e) => {
1351
+ if (e == null) {
1352
+ c("");
1353
+ return;
1354
+ }
1355
+ let t = `/${i}/`, n = `${i}/`;
1356
+ if (e === `/${i}` || e === t || e === i || e === n) {
1357
+ c("");
1358
+ return;
1359
+ }
1360
+ let r;
1361
+ if (e.startsWith(t)) r = e.slice(t.length);
1362
+ else if (e.startsWith(n)) r = e.slice(n.length);
1363
+ else {
1364
+ let t = e.replace(/^\//, "");
1365
+ r = t.startsWith(n) ? t.slice(n.length) : t;
1366
+ }
1367
+ c(r && !r.endsWith("/") ? `${r}/` : r);
1368
+ }, [i]), ae = D(() => {
1369
+ b((e) => e + 1);
1370
+ }, []), oe = ae, se = D((t) => {
1371
+ if (t.length === 0) return;
1372
+ let n = new Set([...R].map((e) => Q(e, i))), c = (e) => e === s || s.startsWith(e) || n.has(e), l = t.filter((e) => !c(e)), d = t.filter((e) => c(e) && e !== s);
1373
+ l.length > 0 && (u((e) => {
1374
+ let t = new Map(e);
1375
+ return l.forEach((e) => t.delete(e)), t;
1376
+ }), p((e) => {
1377
+ let t = new Map(e);
1378
+ return l.forEach((e) => t.delete(e)), t;
1379
+ })), d.forEach((t) => {
1380
+ (async () => {
1381
+ try {
1382
+ let { items: n, permissions: i } = await Me(e, a, r, t, T.current);
1383
+ u((e) => new Map(e).set(t, n)), i != null && p((e) => new Map(e).set(t, i));
1384
+ } catch {
1385
+ o?.({
1386
+ variant: z.Error,
1387
+ reason: G.FolderLoadFailed
1388
+ });
1389
+ }
1390
+ })();
1391
+ });
1392
+ }, [
1393
+ a,
1394
+ r,
1395
+ e,
1396
+ s,
1397
+ R,
1398
+ i,
1399
+ o
1400
+ ]), ce = D((e, t, n) => {
1401
+ u((r) => Ae(r, e, t, n));
1402
+ }, []), le = D((t) => {
1403
+ let n = t == null ? "" : Q(t, i), s = t ?? `/${i}`;
1404
+ if (re((e) => {
1405
+ if (e.has(s)) return e;
1406
+ let t = new Set(e);
1407
+ return t.add(s), t;
1408
+ }), !d.current.has(n)) {
1409
+ if (I.current.has(n)) {
1410
+ U((e) => {
1411
+ let t = new Set(e);
1412
+ return t.add(s), t;
1413
+ });
1414
+ return;
1415
+ }
1416
+ I.current.add(n), U((e) => {
1417
+ let t = new Set(e);
1418
+ return t.add(s), t;
1419
+ }), (async () => {
1420
+ try {
1421
+ let { items: t, permissions: i } = await Me(e, a, r, n, T.current);
1422
+ u((e) => new Map(e).set(n, t)), i != null && p((e) => new Map(e).set(n, i)), L.current.delete(n);
1423
+ } catch {
1424
+ o?.({
1425
+ variant: z.Error,
1426
+ reason: G.FolderLoadFailed
1427
+ });
1428
+ } finally {
1429
+ I.current.delete(n), U((e) => {
1430
+ let t = new Set(e);
1431
+ return t.delete(s), t;
1432
+ });
1433
+ }
1434
+ })();
1435
+ }
1436
+ }, [
1437
+ a,
1438
+ r,
1439
+ e,
1440
+ o,
1441
+ i
1442
+ ]), ue = k(() => {
1443
+ let e = /* @__PURE__ */ new Set(), t = new Set([...R, ...W]);
1444
+ for (let n of t) {
1445
+ let t = Q(n, i);
1446
+ l.has(t) && e.add(n);
1447
+ }
1448
+ return e;
1449
+ }, [
1450
+ R,
1451
+ W,
1452
+ l,
1453
+ i
1454
+ ]), de = D((t) => {
1455
+ R.forEach((e) => {
1456
+ t.has(e) || L.current.delete(Q(e, i));
1457
+ }), ne(t), [...t].filter((e) => {
1458
+ let t = Q(e, i);
1459
+ return !d.current.has(t) && !I.current.has(t) && !L.current.has(t);
1460
+ }).forEach((t) => {
1461
+ let n = Q(t, i);
1462
+ I.current.add(n), (async () => {
1463
+ try {
1464
+ let { items: t, permissions: i } = await Me(e, a, r, n, T.current);
1465
+ u((e) => new Map(e).set(n, t)), i != null && p((e) => new Map(e).set(n, i));
1466
+ } catch {
1467
+ L.current.add(n), o?.({
1468
+ variant: z.Error,
1469
+ reason: G.FolderLoadFailed
1470
+ });
1471
+ } finally {
1472
+ I.current.delete(n), U((e) => {
1473
+ let n = new Set(e);
1474
+ return n.delete(t), n;
1475
+ });
1476
+ }
1477
+ })();
1478
+ });
1479
+ }, [
1480
+ a,
1481
+ r,
1482
+ e,
1483
+ R,
1484
+ o,
1485
+ i
1486
+ ]), fe = D(() => {
1487
+ N.current != null && (clearTimeout(N.current), N.current = null), F.current?.(), F.current = null, M(null), E(!1);
1488
+ }, []), Y = D((t, o) => {
1489
+ if (N.current != null && (clearTimeout(N.current), N.current = null), F.current?.(), F.current = null, !o.trim()) {
1490
+ M(null), E(!1);
1491
+ return;
1492
+ }
1493
+ N.current = setTimeout(() => {
1494
+ N.current = null;
1495
+ let t = o.toLowerCase();
1496
+ if (a === V.Shared && s === "") {
1497
+ F.current?.(), F.current = null, E(!0), M((l.get("") ?? []).filter((e) => n(e.name).toLowerCase().includes(t)).map((e) => Pe(e, e.bucket ?? r, i))), E(!1);
1498
+ return;
1499
+ }
1500
+ let c = !1;
1501
+ F.current = () => {
1502
+ c = !0;
1503
+ }, E(!0), (async () => {
1504
+ try {
1505
+ let { items: o } = await Ne(e, a, r, s, T.current);
1506
+ if (c) return;
1507
+ M(o.filter((e) => n(e.name).toLowerCase().includes(t)).map((e) => Pe(e, e.bucket ?? r, i)));
1508
+ } catch {
1509
+ c || M([]);
1510
+ } finally {
1511
+ c || E(!1);
1512
+ }
1513
+ })();
1514
+ }, 300);
1515
+ }, [
1516
+ a,
1517
+ r,
1518
+ l,
1519
+ e,
1520
+ s,
1521
+ i
1522
+ ]), X = s ? `/${i}/${s}` : `/${i}`, me = k(() => {
1523
+ let e = q[0];
1524
+ if (e) return J(X) === J(`/${i}`) ? e : pe(e.items ?? [], X);
1525
+ }, [
1526
+ q,
1527
+ X,
1528
+ i
1529
+ ]);
1530
+ return {
1531
+ items: q,
1532
+ isLoading: m,
1533
+ error: g,
1534
+ path: X,
1535
+ folderPath: s,
1536
+ onPathChange: ie,
1537
+ retry: ae,
1538
+ onSearchFiles: Y,
1539
+ isSearching: ee,
1540
+ searchResults: te,
1541
+ clearSearchResults: fe,
1542
+ expandedPaths: R,
1543
+ loadedPaths: ue,
1544
+ onExpandedPathsChange: de,
1545
+ onFolderPopupPathChange: le,
1546
+ folderPopupLoadingPaths: B,
1547
+ sharedWithMeIds: k(() => a === V.Shared ? x : void 0, [a, x]),
1548
+ sharedByMePaths: C,
1549
+ currentFolder: me,
1550
+ cache: l,
1551
+ listingPermissionsCache: f,
1552
+ sharedRootMetaRef: T,
1553
+ setFolderPath: c,
1554
+ invalidateFolders: se,
1555
+ mergeCreatedFolder: ce,
1556
+ bumpRetry: oe
1557
+ };
1558
+ }, Bt = ({ filesApi: e, bucket: t, rootLabel: n, onNotification: r }) => {
1559
+ let [i, a] = j(void 0), [o, s] = j(!1);
1560
+ return {
1561
+ fileMetadata: i,
1562
+ isFileMetadataLoading: o,
1563
+ onGetInfo: D((i) => {
1564
+ (async () => {
1565
+ s(!0);
1566
+ try {
1567
+ let r = i.bucket ?? t, o = we(i, r, n);
1568
+ a(Fe(await e.getFileMetadata({
1569
+ bucket: r,
1570
+ path: o
1571
+ }), i));
1572
+ } catch {
1573
+ r?.({
1574
+ variant: z.Error,
1575
+ reason: G.MetadataLoadFailed
1576
+ });
1577
+ } finally {
1578
+ s(!1);
1579
+ }
1580
+ })();
1581
+ }, [
1582
+ t,
1583
+ e,
1584
+ n,
1585
+ r
1586
+ ]),
1587
+ clearMetadata: D(() => {
1588
+ a(void 0), s(!1);
1589
+ }, [])
1590
+ };
1591
+ }, Vt = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, folderPath: i, currentFolder: a, sharedRootMetaRef: o, listingPermissionsCache: s, invalidateFolders: c, bumpRetry: l, mergeCreatedFolder: u, setFolderPath: d, onNotification: f, onOperationSuccess: p, downloadDestination: m, forbiddenSymbolsRegExp: h }) => {
1592
+ let [g, _] = j(!1), [y, b] = j(!1), [x, S] = j(!1), [C, w] = j(!1), [T, ee] = j(!1), [E, O] = j(!1), k = A(null), M = A(null), P = D((e, t) => {
1593
+ let n = null;
1594
+ if (!e || e.trim() === "") n = { reason: K.Empty };
1595
+ else if (fe(e, h)) n = {
1596
+ reason: K.ForbiddenSymbols,
1597
+ symbols: R
1598
+ };
1599
+ else if (e.startsWith(".")) n = { reason: K.LeadingDot };
1600
+ else if (e === ae) n = { reason: K.ReservedName };
1601
+ else if (e.length > 255) n = {
1602
+ reason: K.TooLong,
1603
+ maxLength: 255
1604
+ };
1605
+ else {
1606
+ let r = t.items ?? [], i = e.toLowerCase(), a = r.find((e) => e.name.toLowerCase() === i);
1607
+ a && (n = {
1608
+ reason: K.DuplicateName,
1609
+ existingName: a.name
1610
+ });
1611
+ }
1612
+ return M.current = n, n;
1613
+ }, [h]), F = D(async (c, d, m) => {
1614
+ let { parentVirtualPath: h, name: g } = ve(d, n), v = Q(h, n), y = a && i === v ? a : {
1615
+ id: v,
1616
+ path: v,
1617
+ name: h.split("/").filter(Boolean).pop() ?? "",
1618
+ folderId: v,
1619
+ nodeType: H.FOLDER,
1620
+ items: []
1621
+ }, b = M.current;
1622
+ if (M.current = null, P(g, y) || b) return;
1623
+ _(!0);
1624
+ let { bucket: x, path: S } = r === V.Shared ? be(v, o.current, t) : {
1625
+ bucket: t,
1626
+ path: v
1627
+ };
1628
+ try {
1629
+ u(v, await e.createFolder({
1630
+ bucket: x,
1631
+ parentPath: S || void 0,
1632
+ name: g
1633
+ }), s.get(v)), l(), p?.({
1634
+ kind: q.FolderCreated,
1635
+ name: g
1636
+ });
1637
+ } catch {
1638
+ f?.({
1639
+ variant: z.Error,
1640
+ reason: G.FolderCreateFailed
1641
+ });
1642
+ } finally {
1643
+ _(!1);
1644
+ }
1645
+ }, [
1646
+ r,
1647
+ t,
1648
+ a,
1649
+ e,
1650
+ i,
1651
+ P,
1652
+ n,
1653
+ s,
1654
+ u,
1655
+ l,
1656
+ p,
1657
+ o,
1658
+ f
1659
+ ]), L = D((r) => {
1660
+ (async () => {
1661
+ b(!0);
1662
+ try {
1663
+ let i = r.length === 1 ? r[0].nodeType === H.ITEM ? r[0].name : `${r[0].name}.zip` : "files.zip", a = await m.resolveDestination(i, r.length === 1 && r[0].nodeType === H.ITEM ? r[0].contentType ?? "application/octet-stream" : "application/zip");
1664
+ if (a.type === Pt.Cancelled) return;
1665
+ if (r.length === 1 && r[0].nodeType === H.ITEM) {
1666
+ let t = r[0];
1667
+ if (!t.bucket) throw Error("File is missing bucket");
1668
+ let i = we(t, t.bucket, n), o = await e.downloadFile(t.bucket, i);
1669
+ if (!o.ok) throw Error(`Download failed with status ${o.status}`);
1670
+ let s = await m.triggerDownload(o, t.name, a);
1671
+ p?.({
1672
+ kind: q.FileDownloaded,
1673
+ name: s,
1674
+ count: 1
1675
+ });
1676
+ } else {
1677
+ let o = r.map((e) => ({
1678
+ bucket: e.bucket ?? t,
1679
+ path: we(e, e.bucket ?? t, n),
1680
+ name: e.name,
1681
+ nodeType: e.nodeType === H.FOLDER ? te.Folder : te.Item
1682
+ })), s = await e.downloadArchive(o);
1683
+ if (!s.ok) throw Error(`Download failed with status ${s.status}`);
1684
+ let c = await m.triggerDownload(s, i, a);
1685
+ r.length === 1 ? p?.({
1686
+ kind: q.FileDownloaded,
1687
+ name: c
1688
+ }) : p?.({
1689
+ kind: q.FilesDownloaded,
1690
+ count: r.length
1691
+ });
1692
+ }
1693
+ } catch {
1694
+ f?.({
1695
+ variant: z.Error,
1696
+ reason: r.length === 1 ? G.DownloadFileFailed : G.DownloadFilesFailed
1697
+ });
1698
+ } finally {
1699
+ b(!1);
1700
+ }
1701
+ })();
1702
+ }, [
1703
+ t,
1704
+ n,
1705
+ p,
1706
+ f,
1707
+ e,
1708
+ m
1709
+ ]), ne = D((a, s) => {
1710
+ a.length !== 0 && (async () => {
1711
+ S(!0);
1712
+ let u = a.map((e) => {
1713
+ let i = e.nodeType === H.FOLDER, a = Q(e.sourceUrl, n), s = i ? a : a.replace(/\/$/, ""), c = Y(e.sourceUrl, s), { bucket: l, path: u } = r === V.Shared ? be(s, o.current, t) : {
1714
+ bucket: t,
1715
+ path: s
1716
+ };
1717
+ return {
1718
+ bucket: l,
1719
+ path: u,
1720
+ name: c,
1721
+ nodeType: i ? N.Folder : N.Item
1722
+ };
1723
+ });
1724
+ try {
1725
+ let { results: t } = await e.deleteFiles(u), r = t.filter((e) => !e.success), i = r.length, a = t.length - i, o = t.find((e) => e.success), c = u.find((e) => e.path === o?.path) ?? u[0];
1726
+ if (a > 0 && f?.({
1727
+ variant: z.Success,
1728
+ reason: G.FilesDeleted,
1729
+ count: a,
1730
+ name: c?.name,
1731
+ folder: s || n
1732
+ }), i > 0) {
1733
+ let e = r.slice(0, 3).map((e) => u.find((t) => t.path === e.path)?.name ?? e.path), t = i - e.length;
1734
+ f?.({
1735
+ variant: z.Error,
1736
+ reason: G.FilesDeletePartiallyFailed,
1737
+ names: e,
1738
+ restCount: t
1739
+ });
1740
+ }
1741
+ } catch {
1742
+ f?.({
1743
+ variant: z.Error,
1744
+ reason: G.DeleteFailed
1745
+ });
1746
+ }
1747
+ let p = u.filter((e) => e.nodeType === N.Folder).map((e) => e.path.endsWith("/") ? e.path : `${e.path}/`);
1748
+ c([...new Set(u.map((e) => {
1749
+ if (e.nodeType === N.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
1750
+ let t = e.path.lastIndexOf("/");
1751
+ return t > 0 ? e.path.slice(0, t + 1) : "";
1752
+ }))]), p.some((e) => i === e || i.startsWith(e)) && d((e) => e.replace(/[^/]+\/$/, "")), l(), S(!1);
1753
+ })();
1754
+ }, [
1755
+ r,
1756
+ t,
1757
+ n,
1758
+ i,
1759
+ f,
1760
+ e,
1761
+ o,
1762
+ c,
1763
+ l,
1764
+ d
1765
+ ]), B = D((e, t) => {
1766
+ if (!e || e.trim() === "") return { reason: K.Empty };
1767
+ if (e === ae) return { reason: K.ReservedName };
1768
+ if (fe(e, h)) return {
1769
+ reason: K.ForbiddenSymbols,
1770
+ symbols: R
1771
+ };
1772
+ if (e.length > 255) return {
1773
+ reason: K.TooLong,
1774
+ maxLength: 255
1775
+ };
1776
+ let n = a?.items ?? [], r = e.toLowerCase(), i = n.find((e) => e.path !== t.path && e.name.toLowerCase() === r);
1777
+ return i ? {
1778
+ reason: K.DuplicateName,
1779
+ existingName: i.name
1780
+ } : null;
1781
+ }, [h, a]), U = D((r, i) => {
1782
+ if (r.length === 0 || T || E) return;
1783
+ let a = new AbortController();
1784
+ k.current = a, (async () => {
1785
+ ee(!0);
1786
+ let o = Te(r, t, n), s = o.map(({ dto: e }) => e);
1787
+ try {
1788
+ let { results: t } = await e.copyFiles(s, a.signal), r = t.filter((e) => !e.success).length, c = t.length - r;
1789
+ if (c > 0) {
1790
+ let e = Oe(o, t);
1791
+ p?.({
1792
+ kind: c === 1 ? q.FileCopied : q.FilesCopied,
1793
+ name: e?.destinationName,
1794
+ count: c,
1795
+ destinationFolderName: X(i, n)
1796
+ });
1797
+ }
1798
+ r > 0 && r < t.length ? f?.({
1799
+ variant: z.Error,
1800
+ reason: G.CopyPartiallyFailed,
1801
+ count: r
1802
+ }) : r === t.length && f?.({
1803
+ variant: z.Error,
1804
+ reason: G.CopyFailed
1805
+ });
1806
+ } catch {
1807
+ a.signal.aborted || f?.({
1808
+ variant: z.Error,
1809
+ reason: G.CopyFailed
1810
+ });
1811
+ } finally {
1812
+ c([...new Set(s.flatMap((e) => [v(e.sourcePath), v(e.destinationPath)]))]), l(), ee(!1), k.current = null;
1813
+ }
1814
+ })();
1815
+ }, [
1816
+ t,
1817
+ n,
1818
+ f,
1819
+ p,
1820
+ e,
1821
+ T,
1822
+ E,
1823
+ c,
1824
+ l
1825
+ ]), W = D(() => {
1826
+ k.current?.abort();
1827
+ }, []);
1828
+ return {
1829
+ isCreatingFolder: g,
1830
+ isDownloading: y,
1831
+ isDeleting: x,
1832
+ isRenaming: C,
1833
+ isCopying: T,
1834
+ isMoving: E,
1835
+ onCreateFolder: F,
1836
+ onCreateFolderValidate: P,
1837
+ onDownloadFiles: L,
1838
+ onDeleteFiles: ne,
1839
+ onRenameValidate: B,
1840
+ onMoveToFiles: D((r, a, o) => {
1841
+ if (r.length === 0 || T || E || C) return;
1842
+ let { renameDtos: s, preparedMoveItems: u } = Ee(r, t, n), m = u.map(({ dto: e }) => e), h = new AbortController();
1843
+ m.length > 0 && (k.current = h), (async () => {
1844
+ s.length > 0 && w(!0), m.length > 0 && O(!0);
1845
+ let [t, r] = await Promise.all([(async () => {
1846
+ if (s.length === 0) return {
1847
+ results: [],
1848
+ threw: !1
1849
+ };
1850
+ try {
1851
+ let { results: t } = await e.renameFiles(s);
1852
+ return {
1853
+ results: t,
1854
+ threw: !1
1855
+ };
1856
+ } catch {
1857
+ return {
1858
+ results: [],
1859
+ threw: !0
1860
+ };
1861
+ }
1862
+ })(), (async () => {
1863
+ if (m.length === 0) return {
1864
+ results: [],
1865
+ threw: !1,
1866
+ aborted: !1
1867
+ };
1868
+ try {
1869
+ let { results: t } = await e.moveFiles(m, h.signal);
1870
+ return {
1871
+ results: t,
1872
+ threw: !1,
1873
+ aborted: !1
1874
+ };
1875
+ } catch {
1876
+ return {
1877
+ results: [],
1878
+ threw: !0,
1879
+ aborted: h.signal.aborted
1880
+ };
1881
+ }
1882
+ })()]), a = t.threw ? s.length : t.results.filter((e) => !e.success).length, g = r.threw && r.aborted, _ = g ? 0 : m.length, y = g ? 0 : r.threw ? m.length : r.results.filter((e) => !e.success).length, b = r.threw ? 0 : r.results.filter((e) => e.success).length, x = s.length + _, S = a + y, C = y > 0;
1883
+ if (b > 0) {
1884
+ let e = Oe(u, r.results);
1885
+ p?.({
1886
+ kind: b === 1 ? q.FileMoved : q.FilesMoved,
1887
+ name: e?.destinationName,
1888
+ count: b,
1889
+ destinationFolderName: X(o, n)
1890
+ });
1891
+ }
1892
+ if (s.length === 1 && a === 0) {
1893
+ let [e] = s;
1894
+ p?.({
1895
+ kind: q.FileRenamed,
1896
+ name: Y(e.destinationPath, e.destinationPath),
1897
+ isFolder: e.nodeType === I.Folder
1898
+ });
1899
+ }
1900
+ S > 0 && (S === x ? f?.({
1901
+ variant: z.Error,
1902
+ reason: C ? G.MoveFailed : G.RenameFailed
1903
+ }) : f?.({
1904
+ variant: z.Error,
1905
+ reason: C ? G.MovePartiallyFailed : G.RenamePartiallyFailed,
1906
+ count: S
1907
+ }));
1908
+ let T = s.find((e) => e.nodeType === I.Folder && t.results.some((t) => t.success && t.sourcePath === e.sourcePath));
1909
+ if (T != null) {
1910
+ let e = T.sourcePath.endsWith("/") ? T.sourcePath : `${T.sourcePath}/`;
1911
+ if (i === e || i.startsWith(e)) {
1912
+ let t = T.destinationPath.endsWith("/") ? T.destinationPath : `${T.destinationPath}/`;
1913
+ d(i.replace(e, t));
1914
+ }
1915
+ }
1916
+ c([...new Set([...s, ...m].flatMap((e) => [v(e.sourcePath), v(e.destinationPath)]))]), l(), w(!1), O(!1), m.length > 0 && (k.current = null);
1917
+ })();
1918
+ }, [
1919
+ t,
1920
+ n,
1921
+ i,
1922
+ p,
1923
+ f,
1924
+ e,
1925
+ T,
1926
+ E,
1927
+ C,
1928
+ c,
1929
+ l,
1930
+ d
1931
+ ]),
1932
+ onCopyFiles: U,
1933
+ cancelCopyMove: W
1934
+ };
1935
+ }, Ht = ({ filesApi: e, bucket: t, rootLabel: n, bumpRetry: r, onNotification: i }) => {
1936
+ let [a, o] = j(!1), [s, c] = j(!1);
1937
+ return {
1938
+ isUnsharing: a,
1939
+ isRemovingAccess: s,
1940
+ onUnshareFiles: D((a) => {
1941
+ a.length !== 0 && (async () => {
1942
+ o(!0);
1943
+ let s = a.map((e) => {
1944
+ let r = e.bucket ?? t;
1945
+ return {
1946
+ bucket: r,
1947
+ path: we(e, r, n)
1948
+ };
1949
+ });
1950
+ try {
1951
+ await e.discardShared(s), r();
1952
+ } catch {
1953
+ i?.({
1954
+ variant: z.Error,
1955
+ reason: G.UnshareFailed
1956
+ });
1957
+ } finally {
1958
+ o(!1);
1959
+ }
1960
+ })();
1961
+ }, [
1962
+ t,
1963
+ n,
1964
+ i,
1965
+ e,
1966
+ r
1967
+ ]),
1968
+ onRemoveFilesAccess: D((a) => {
1969
+ a.length !== 0 && (async () => {
1970
+ c(!0);
1971
+ let o = a.map((e) => {
1972
+ let r = e.bucket ?? t;
1973
+ return {
1974
+ bucket: r,
1975
+ path: we(e, r, n)
1976
+ };
1977
+ });
1978
+ try {
1979
+ await e.revokeAccess(o), r();
1980
+ } catch {
1981
+ i?.({
1982
+ variant: z.Error,
1983
+ reason: G.RemoveAccessFailed
1984
+ });
1985
+ } finally {
1986
+ c(!1);
1987
+ }
1988
+ })();
1989
+ }, [
1990
+ t,
1991
+ n,
1992
+ i,
1993
+ e,
1994
+ r
1995
+ ])
1996
+ };
1997
+ }, Ut = 5, Wt = (e) => e.error ? `${e.path} (${e.error})` : e.path, Gt = (e) => {
1998
+ let t = e.slice(0, Ut);
1999
+ return {
2000
+ names: t.map(Wt),
2001
+ restCount: e.length - t.length
2002
+ };
2003
+ }, Kt = (e, t) => `${e}${t}/`, qt = (e) => /\.zip$/i.test(e), Jt = (e) => {
2004
+ let [t] = e;
2005
+ if (!(e.length !== 1 || t == null)) return qt(t.fileContent.name) && !qt(t.name) ? t : void 0;
2006
+ }, Yt = ({ filesApi: e, bucket: t, rootLabel: n, activeTab: r, cache: i, sharedRootMetaRef: a, invalidateFolders: o, bumpRetry: s, onNotification: c }) => {
2007
+ let [l, u] = j(null), d = A(null), f = D((r, i, a) => {
2008
+ let l = Q(a, n);
2009
+ u({
2010
+ files: [{
2011
+ id: `${Date.now()}-archive`,
2012
+ name: i,
2013
+ status: p.Uploading
2014
+ }],
2015
+ isOpen: !0
2016
+ }), (async () => {
2017
+ try {
2018
+ let { results: n } = await e.uploadArchive(r, t, Kt(l, i)), a = n.filter((e) => e.success).length, o = n.filter((e) => !e.success), s = o.length, { names: u, restCount: d } = Gt(o);
2019
+ n.length > 0 && a === 0 ? c?.({
2020
+ variant: z.Error,
2021
+ reason: G.UploadArchiveFailed,
2022
+ names: u,
2023
+ restCount: d
2024
+ }) : s > 0 && c?.({
2025
+ variant: z.Error,
2026
+ reason: G.UploadArchivePartiallyFailed,
2027
+ count: s,
2028
+ names: u,
2029
+ restCount: d
2030
+ });
2031
+ } catch {
2032
+ c?.({
2033
+ variant: z.Error,
2034
+ reason: G.UploadArchiveRequestFailed
2035
+ });
2036
+ } finally {
2037
+ o([l]), s(), u(null);
2038
+ }
2039
+ })();
2040
+ }, [
2041
+ t,
2042
+ n,
2043
+ c,
2044
+ e,
2045
+ o,
2046
+ s
2047
+ ]);
2048
+ return {
2049
+ onUploadFiles: D((l, m) => {
2050
+ if (l.length === 0) return;
2051
+ let h = Jt(l);
2052
+ if (h != null) {
2053
+ f(h.fileContent, h.name, m);
2054
+ return;
2055
+ }
2056
+ let g = new AbortController();
2057
+ d.current = g, u({
2058
+ files: l.map((e, t) => ({
2059
+ id: `${Date.now()}-${t}`,
2060
+ name: e.name,
2061
+ status: p.Queued
2062
+ })),
2063
+ isOpen: !0
2064
+ });
2065
+ let _ = Q(m, n), { bucket: v, path: y } = r === V.Shared ? be(_, a.current, t) : {
2066
+ bucket: t,
2067
+ path: _
2068
+ }, b = new Set((i.get(_) ?? []).map((e) => e.name.toLowerCase()));
2069
+ (async () => {
2070
+ let t = 0, r = 0, i = 0, a = async () => {
2071
+ for (; t < l.length;) {
2072
+ let n = t++, a = l[n];
2073
+ if (g.signal.aborted) {
2074
+ u((e) => je(e, n, p.Cancelled));
2075
+ continue;
2076
+ }
2077
+ u((e) => je(e, n, {
2078
+ status: p.Uploading,
2079
+ percent: 0
2080
+ }));
2081
+ let o = b.has(a.name.toLowerCase()) ? re.Overwrite : re.CreateOnly;
2082
+ try {
2083
+ await e.uploadFile(v, `${y}${a.name}`, a.fileContent, {
2084
+ signal: g.signal,
2085
+ uploadMode: o,
2086
+ onProgress: (e) => {
2087
+ u((t) => je(t, n, {
2088
+ status: p.Uploading,
2089
+ percent: e
2090
+ }));
2091
+ }
2092
+ }), u((e) => je(e, n, {
2093
+ status: p.Completed,
2094
+ percent: 100
2095
+ })), r += 1;
2096
+ } catch {
2097
+ let e = g.signal.aborted ? p.Cancelled : p.Failed;
2098
+ e === p.Failed && (i += 1), u((t) => je(t, n, e));
2099
+ }
2100
+ }
2101
+ };
2102
+ await Promise.all(Array.from({ length: 3 }, () => a())), g.signal.aborted || (r === 0 && i > 0 ? c?.({
2103
+ variant: z.Error,
2104
+ reason: G.UploadFailed
2105
+ }) : c?.({
2106
+ variant: z.Success,
2107
+ reason: G.UploadCompleted,
2108
+ folder: y || n
2109
+ })), o([_]), s(), d.current = null, u(null);
2110
+ })();
2111
+ }, [
2112
+ r,
2113
+ t,
2114
+ i,
2115
+ n,
2116
+ c,
2117
+ e,
2118
+ a,
2119
+ o,
2120
+ s,
2121
+ f
2122
+ ]),
2123
+ onUploadArchive: D((e, t, n) => {
2124
+ f(e, t, n);
2125
+ }, [f]),
2126
+ onValidateUpload: D(async (e, t, n) => {
2127
+ for (let t of e) t.name = Rt(t.name);
2128
+ return { valid: !0 };
2129
+ }, []),
2130
+ uploadBatchState: l,
2131
+ cancelUpload: D(() => {
2132
+ d.current?.abort();
2133
+ }, []),
2134
+ clearUploadBatch: D(() => {
2135
+ u(null);
2136
+ }, [])
2137
+ };
2138
+ }, Xt = ({ filesApi: e, bucket: t, rootLabel: n = "My files", activeTab: r = V.MyFiles, onNotification: i, onOperationSuccess: a, forbiddenSymbolsRegExp: o, variant: s = d.Attach, actionProfile: c, labels: l, locale: f, disabledNewButtonTooltip: p, downloadDestination: m, buildValidationErrorMessage: h }) => {
2139
+ let g = c ?? de(s), _ = zt({
2140
+ filesApi: e,
2141
+ bucket: t,
2142
+ rootLabel: n,
2143
+ activeTab: r,
2144
+ onNotification: i
2145
+ }), v = Yt({
2146
+ filesApi: e,
2147
+ bucket: t,
2148
+ rootLabel: n,
2149
+ activeTab: r,
2150
+ cache: _.cache,
2151
+ sharedRootMetaRef: _.sharedRootMetaRef,
2152
+ invalidateFolders: _.invalidateFolders,
2153
+ bumpRetry: _.bumpRetry,
2154
+ onNotification: i
2155
+ }), y = Vt({
2156
+ filesApi: e,
2157
+ bucket: t,
2158
+ rootLabel: n,
2159
+ activeTab: r,
2160
+ folderPath: _.folderPath,
2161
+ currentFolder: _.currentFolder,
2162
+ sharedRootMetaRef: _.sharedRootMetaRef,
2163
+ listingPermissionsCache: _.listingPermissionsCache,
2164
+ invalidateFolders: _.invalidateFolders,
2165
+ bumpRetry: _.bumpRetry,
2166
+ mergeCreatedFolder: _.mergeCreatedFolder,
2167
+ setFolderPath: _.setFolderPath,
2168
+ onNotification: i,
2169
+ onOperationSuccess: a,
2170
+ downloadDestination: m,
2171
+ forbiddenSymbolsRegExp: o
2172
+ }), b = Ht({
2173
+ filesApi: e,
2174
+ bucket: t,
2175
+ rootLabel: n,
2176
+ bumpRetry: _.bumpRetry,
2177
+ onNotification: i
2178
+ }), x = Bt({
2179
+ filesApi: e,
2180
+ bucket: t,
2181
+ rootLabel: n,
2182
+ onNotification: i
2183
+ }), S = me(_.currentFolder), C = k(() => r === V.Organization || r === V.Shared && _.folderPath === "" ? !1 : S, [
2184
+ r,
2185
+ _.folderPath,
2186
+ S
2187
+ ]), w = k(() => r === V.Shared ? le : ce, [r]), T = k(() => {
2188
+ let e = {}, t = (t) => {
2189
+ let n = l[t];
2190
+ n != null && (e[t] = n);
2191
+ };
2192
+ return t(B.Download), r === V.MyFiles ? (t(B.Delete), C && (t(B.Rename), ge(g) && (t(B.Copy), t(B.Move), t(B.Duplicate))), _e(g) && t(B.RemoveAccess)) : r === V.Shared && _e(g) && t(B.Unshare), g === u.Full && t(B.Info), e;
2193
+ }, [
2194
+ r,
2195
+ C,
2196
+ g,
2197
+ l
2198
+ ]), ee = k(() => y.isCreatingFolder || y.isDownloading || y.isDeleting || y.isRenaming || y.isCopying || y.isMoving || b.isUnsharing || b.isRemovingAccess || v.uploadBatchState != null, [
2199
+ y.isCreatingFolder,
2200
+ y.isDownloading,
2201
+ y.isDeleting,
2202
+ y.isRenaming,
2203
+ y.isCopying,
2204
+ y.isMoving,
2205
+ b.isUnsharing,
2206
+ b.isRemovingAccess,
2207
+ v.uploadBatchState
2208
+ ]), E = D((e, t) => {
2209
+ let n = y.onCreateFolderValidate(e, t);
2210
+ return n ? h(n) : null;
2211
+ }, [y, h]), O = D((e, t) => {
2212
+ let n = y.onRenameValidate(e, t);
2213
+ return n ? h(n, t) : null;
2214
+ }, [y, h]);
2215
+ return {
2216
+ items: _.items,
2217
+ isLoading: _.isLoading,
2218
+ error: _.error,
2219
+ path: _.path,
2220
+ onPathChange: _.onPathChange,
2221
+ retry: _.retry,
2222
+ onSearchFiles: _.onSearchFiles,
2223
+ isSearching: _.isSearching,
2224
+ searchResults: _.searchResults,
2225
+ clearSearchResults: _.clearSearchResults,
2226
+ expandedPaths: _.expandedPaths,
2227
+ loadedPaths: _.loadedPaths,
2228
+ onExpandedPathsChange: _.onExpandedPathsChange,
2229
+ onFolderPopupPathChange: _.onFolderPopupPathChange,
2230
+ folderPopupLoadingPaths: _.folderPopupLoadingPaths,
2231
+ onUploadFiles: v.onUploadFiles,
2232
+ onUploadArchive: v.onUploadArchive,
2233
+ onValidateUpload: v.onValidateUpload,
2234
+ uploadBatchState: v.uploadBatchState,
2235
+ cancelUpload: v.cancelUpload,
2236
+ clearUploadBatch: v.clearUploadBatch,
2237
+ onCreateFolder: y.onCreateFolder,
2238
+ onCreateFolderValidate: E,
2239
+ isCreatingFolder: y.isCreatingFolder,
2240
+ onDownloadFiles: y.onDownloadFiles,
2241
+ isDownloading: y.isDownloading,
2242
+ onDeleteFiles: y.onDeleteFiles,
2243
+ isDeleting: y.isDeleting,
2244
+ onRenameValidate: O,
2245
+ onMoveToFiles: y.onMoveToFiles,
2246
+ isRenaming: y.isRenaming,
2247
+ onCopyFiles: y.onCopyFiles,
2248
+ isCopying: y.isCopying,
2249
+ isMoving: y.isMoving,
2250
+ cancelCopyMove: y.cancelCopyMove,
2251
+ uploadEnabled: C,
2252
+ isNewButtonDisabled: !C,
2253
+ disabledNewButtonTooltip: p,
2254
+ visibleColumns: w,
2255
+ dateLocale: f,
2256
+ dateOptions: se,
2257
+ actionLabels: T,
2258
+ sharedWithMeIds: _.sharedWithMeIds,
2259
+ sharedByMePaths: _.sharedByMePaths,
2260
+ onUnshareFiles: b.onUnshareFiles,
2261
+ isUnsharing: b.isUnsharing,
2262
+ onRemoveFilesAccess: b.onRemoveFilesAccess,
2263
+ isRemovingAccess: b.isRemovingAccess,
2264
+ fileMetadata: x.fileMetadata,
2265
+ isFileMetadataLoading: x.isFileMetadataLoading,
2266
+ onGetInfo: x.onGetInfo,
2267
+ clearMetadata: x.clearMetadata,
2268
+ isAnyOperationInProgress: ee
2269
+ };
2270
+ }, Zt = [
2271
+ V.MyFiles,
2272
+ V.Shared,
2273
+ V.Organization
2274
+ ], Qt = (e, t, n, r) => {
2275
+ let i = D((e) => r == null || r.includes(e), [r]), a = k(() => n?.filter((e) => i(e.id)).flatMap(({ id: e, label: t, disabled: n }) => typeof t == "string" ? [{
2276
+ id: e,
2277
+ label: t,
2278
+ disabled: n
2279
+ }] : []), [n, i]);
2280
+ return O(() => {
2281
+ i(e) || t(Zt.find((e) => i(e)) ?? V.MyFiles);
2282
+ }, [
2283
+ i,
2284
+ e,
2285
+ t
2286
+ ]), { tabs: a };
2287
+ };
2288
+ //#endregion
2289
+ export { Z as $, ht as A, Ne as B, it as C, q as Ct, vt as D, rt as E, ze as F, Ae as G, De as H, Re as I, Ee as J, je as K, Le as L, Ct as M, mt as N, pt as O, Et as P, ye as Q, ke as R, ft as S, K as St, _t as T, Fe as U, Oe as V, Pe as W, we as X, v as Y, Q as Z, Dt as _, se as _t, Vt as a, fe as at, st as b, ie as bt, Rt as c, J as ct, Ft as d, u as dt, he as et, Pt as f, d as ft, Ot as g, ue as gt, Nt as h, le as ht, Ht as i, me as it, wt as j, Tt as k, It as l, ve as lt, Mt as m, ce as mt, Xt as n, X as nt, Bt as o, ge as ot, jt as p, de as pt, Te as q, Yt as r, Y as rt, zt as s, _e as st, Qt as t, pe as tt, Lt as u, be as ut, kt as v, oe as vt, bt as w, re as wt, tt as x, G as xt, yt as y, ae as yt, Me as z };