@putkoff/abstract-utilities 0.0.3

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 (298) hide show
  1. package/dist/cjs/config.d.ts +5 -0
  2. package/dist/cjs/file_utils/imports.d.ts +4 -0
  3. package/dist/cjs/file_utils/index.d.ts +1 -0
  4. package/dist/cjs/file_utils/src/delete_utils/imports.d.ts +1 -0
  5. package/dist/cjs/file_utils/src/delete_utils/index.d.ts +1 -0
  6. package/dist/cjs/file_utils/src/delete_utils/src/delete_row.d.ts +2 -0
  7. package/dist/cjs/file_utils/src/delete_utils/src/delete_select.d.ts +1 -0
  8. package/dist/cjs/file_utils/src/delete_utils/src/delete_selected.d.ts +2 -0
  9. package/dist/cjs/file_utils/src/delete_utils/src/index.d.ts +3 -0
  10. package/dist/cjs/file_utils/src/download_utils/imports.d.ts +2 -0
  11. package/dist/cjs/file_utils/src/download_utils/index.d.ts +1 -0
  12. package/dist/cjs/file_utils/src/download_utils/src/direct_download.d.ts +2 -0
  13. package/dist/cjs/file_utils/src/download_utils/src/download_file.d.ts +2 -0
  14. package/dist/cjs/file_utils/src/download_utils/src/download_select.d.ts +1 -0
  15. package/dist/cjs/file_utils/src/download_utils/src/index.d.ts +5 -0
  16. package/dist/cjs/file_utils/src/download_utils/src/target_downloads.d.ts +4 -0
  17. package/dist/cjs/file_utils/src/download_utils/src/trigger_download.d.ts +2 -0
  18. package/dist/cjs/file_utils/src/imports.d.ts +2 -0
  19. package/dist/cjs/file_utils/src/index.d.ts +6 -0
  20. package/dist/cjs/file_utils/src/list_utils/imports.d.ts +2 -0
  21. package/dist/cjs/file_utils/src/list_utils/index.d.ts +1 -0
  22. package/dist/cjs/file_utils/src/list_utils/src/index.d.ts +1 -0
  23. package/dist/cjs/file_utils/src/list_utils/src/list_utils.d.ts +2 -0
  24. package/dist/cjs/file_utils/src/select_utils/index.d.ts +1 -0
  25. package/dist/cjs/file_utils/src/select_utils/src/index.d.ts +3 -0
  26. package/dist/cjs/file_utils/src/select_utils/src/init_select_all.d.ts +2 -0
  27. package/dist/cjs/file_utils/src/select_utils/src/sync_header_checkbox.d.ts +5 -0
  28. package/dist/cjs/file_utils/src/select_utils/src/toggle_checkboxes.d.ts +2 -0
  29. package/dist/cjs/file_utils/src/share_utils/imports.d.ts +2 -0
  30. package/dist/cjs/file_utils/src/share_utils/index.d.ts +1 -0
  31. package/dist/cjs/file_utils/src/share_utils/src/index.d.ts +1 -0
  32. package/dist/cjs/file_utils/src/share_utils/src/share_utils.d.ts +7 -0
  33. package/dist/cjs/file_utils/src/upload_utils/imports.d.ts +1 -0
  34. package/dist/cjs/file_utils/src/upload_utils/index.d.ts +1 -0
  35. package/dist/cjs/file_utils/src/upload_utils/src/index.d.ts +3 -0
  36. package/dist/cjs/file_utils/src/upload_utils/src/patch_file_settings.d.ts +2 -0
  37. package/dist/cjs/file_utils/src/upload_utils/src/upload_file.d.ts +2 -0
  38. package/dist/cjs/file_utils/src/upload_utils/src/upload_files.d.ts +5 -0
  39. package/dist/cjs/functions/auth_utils/imports.d.ts +1 -0
  40. package/dist/cjs/functions/auth_utils/index.d.ts +1 -0
  41. package/dist/cjs/functions/auth_utils/src/index.d.ts +1 -0
  42. package/dist/cjs/functions/auth_utils/src/token_utils.d.ts +28 -0
  43. package/dist/cjs/functions/constants_utils/index.d.ts +1 -0
  44. package/dist/cjs/functions/constants_utils/src/constants.d.ts +7 -0
  45. package/dist/cjs/functions/constants_utils/src/index.d.ts +1 -0
  46. package/dist/cjs/functions/env_utils/imports.d.ts +1 -0
  47. package/dist/cjs/functions/env_utils/index.d.ts +1 -0
  48. package/dist/cjs/functions/env_utils/src/index.d.ts +1 -0
  49. package/dist/cjs/functions/env_utils/src/window_utils.d.ts +4 -0
  50. package/dist/cjs/functions/fetch_utils/imports.d.ts +7 -0
  51. package/dist/cjs/functions/fetch_utils/index.d.ts +1 -0
  52. package/dist/cjs/functions/fetch_utils/src/fetchIt_utils.d.ts +14 -0
  53. package/dist/cjs/functions/fetch_utils/src/index.d.ts +1 -0
  54. package/dist/cjs/functions/fetch_utils/src/utils.d.ts +18 -0
  55. package/dist/cjs/functions/index.d.ts +9 -0
  56. package/dist/cjs/functions/path_utils/imports.d.ts +20 -0
  57. package/dist/cjs/functions/path_utils/index.d.ts +1 -0
  58. package/dist/cjs/functions/path_utils/src/base_dirs.d.ts +4 -0
  59. package/dist/cjs/functions/path_utils/src/function_dirs.d.ts +10 -0
  60. package/dist/cjs/functions/path_utils/src/index.d.ts +6 -0
  61. package/dist/cjs/functions/path_utils/src/misc_dirs.d.ts +4 -0
  62. package/dist/cjs/functions/path_utils/src/path_utils.d.ts +17 -0
  63. package/dist/cjs/functions/path_utils/src/paths.d.ts +5 -0
  64. package/dist/cjs/functions/path_utils/src/src_dirs.d.ts +6 -0
  65. package/dist/cjs/functions/rndm_utils/index.d.ts +1 -0
  66. package/dist/cjs/functions/rndm_utils/src/index.d.ts +1 -0
  67. package/dist/cjs/functions/rndm_utils/src/utils.d.ts +1 -0
  68. package/dist/cjs/functions/string_utils/index.d.ts +1 -0
  69. package/dist/cjs/functions/string_utils/src/index.d.ts +1 -0
  70. package/dist/cjs/functions/string_utils/src/string_utils.d.ts +39 -0
  71. package/dist/cjs/functions/type_utils/index.d.ts +1 -0
  72. package/dist/cjs/functions/type_utils/src/index.d.ts +1 -0
  73. package/dist/cjs/functions/type_utils/src/type_utils.d.ts +1 -0
  74. package/dist/cjs/functions/ui_utils/imports.d.ts +6 -0
  75. package/dist/cjs/functions/ui_utils/index.d.ts +1 -0
  76. package/dist/cjs/functions/ui_utils/src/button.d.ts +4 -0
  77. package/dist/cjs/functions/ui_utils/src/checkbox.d.ts +4 -0
  78. package/dist/cjs/functions/ui_utils/src/index.d.ts +4 -0
  79. package/dist/cjs/functions/ui_utils/src/input.d.ts +5 -0
  80. package/dist/cjs/functions/ui_utils/src/spinner.d.ts +1 -0
  81. package/dist/cjs/hooks/index.d.ts +1 -0
  82. package/dist/cjs/hooks/useFiles/imports.d.ts +6 -0
  83. package/dist/cjs/hooks/useFiles/index.d.ts +1 -0
  84. package/dist/cjs/hooks/useFiles/src/deleteFile.d.ts +5 -0
  85. package/dist/cjs/hooks/useFiles/src/index.d.ts +5 -0
  86. package/dist/cjs/hooks/useFiles/src/load.d.ts +5 -0
  87. package/dist/cjs/hooks/useFiles/src/patchShareSettings.d.ts +9 -0
  88. package/dist/cjs/hooks/useFiles/src/toggleShare.d.ts +5 -0
  89. package/dist/cjs/hooks/useFiles/src/useFiles.d.ts +13 -0
  90. package/dist/cjs/index.d.ts +5 -0
  91. package/dist/cjs/index.js +1776 -0
  92. package/dist/cjs/index.js.map +1 -0
  93. package/dist/cjs/types/index.d.ts +1 -0
  94. package/dist/cjs/types/src/ChangePassword.d.ts +16 -0
  95. package/dist/cjs/types/src/Files.d.ts +27 -0
  96. package/dist/cjs/types/src/index.d.ts +5 -0
  97. package/dist/cjs/types/src/login.d.ts +12 -0
  98. package/dist/cjs/types/src/logout.d.ts +4 -0
  99. package/dist/cjs/types/src/utils.d.ts +25 -0
  100. package/dist/config.d.ts +5 -0
  101. package/dist/esm/config.d.ts +5 -0
  102. package/dist/esm/file_utils/imports.d.ts +4 -0
  103. package/dist/esm/file_utils/index.d.ts +1 -0
  104. package/dist/esm/file_utils/src/delete_utils/imports.d.ts +1 -0
  105. package/dist/esm/file_utils/src/delete_utils/index.d.ts +1 -0
  106. package/dist/esm/file_utils/src/delete_utils/src/delete_row.d.ts +2 -0
  107. package/dist/esm/file_utils/src/delete_utils/src/delete_select.d.ts +1 -0
  108. package/dist/esm/file_utils/src/delete_utils/src/delete_selected.d.ts +2 -0
  109. package/dist/esm/file_utils/src/delete_utils/src/index.d.ts +3 -0
  110. package/dist/esm/file_utils/src/download_utils/imports.d.ts +2 -0
  111. package/dist/esm/file_utils/src/download_utils/index.d.ts +1 -0
  112. package/dist/esm/file_utils/src/download_utils/src/direct_download.d.ts +2 -0
  113. package/dist/esm/file_utils/src/download_utils/src/download_file.d.ts +2 -0
  114. package/dist/esm/file_utils/src/download_utils/src/download_select.d.ts +1 -0
  115. package/dist/esm/file_utils/src/download_utils/src/index.d.ts +5 -0
  116. package/dist/esm/file_utils/src/download_utils/src/target_downloads.d.ts +4 -0
  117. package/dist/esm/file_utils/src/download_utils/src/trigger_download.d.ts +2 -0
  118. package/dist/esm/file_utils/src/imports.d.ts +2 -0
  119. package/dist/esm/file_utils/src/index.d.ts +6 -0
  120. package/dist/esm/file_utils/src/list_utils/imports.d.ts +2 -0
  121. package/dist/esm/file_utils/src/list_utils/index.d.ts +1 -0
  122. package/dist/esm/file_utils/src/list_utils/src/index.d.ts +1 -0
  123. package/dist/esm/file_utils/src/list_utils/src/list_utils.d.ts +2 -0
  124. package/dist/esm/file_utils/src/select_utils/index.d.ts +1 -0
  125. package/dist/esm/file_utils/src/select_utils/src/index.d.ts +3 -0
  126. package/dist/esm/file_utils/src/select_utils/src/init_select_all.d.ts +2 -0
  127. package/dist/esm/file_utils/src/select_utils/src/sync_header_checkbox.d.ts +5 -0
  128. package/dist/esm/file_utils/src/select_utils/src/toggle_checkboxes.d.ts +2 -0
  129. package/dist/esm/file_utils/src/share_utils/imports.d.ts +2 -0
  130. package/dist/esm/file_utils/src/share_utils/index.d.ts +1 -0
  131. package/dist/esm/file_utils/src/share_utils/src/index.d.ts +1 -0
  132. package/dist/esm/file_utils/src/share_utils/src/share_utils.d.ts +7 -0
  133. package/dist/esm/file_utils/src/upload_utils/imports.d.ts +1 -0
  134. package/dist/esm/file_utils/src/upload_utils/index.d.ts +1 -0
  135. package/dist/esm/file_utils/src/upload_utils/src/index.d.ts +3 -0
  136. package/dist/esm/file_utils/src/upload_utils/src/patch_file_settings.d.ts +2 -0
  137. package/dist/esm/file_utils/src/upload_utils/src/upload_file.d.ts +2 -0
  138. package/dist/esm/file_utils/src/upload_utils/src/upload_files.d.ts +5 -0
  139. package/dist/esm/functions/auth_utils/imports.d.ts +1 -0
  140. package/dist/esm/functions/auth_utils/index.d.ts +1 -0
  141. package/dist/esm/functions/auth_utils/src/index.d.ts +1 -0
  142. package/dist/esm/functions/auth_utils/src/token_utils.d.ts +28 -0
  143. package/dist/esm/functions/constants_utils/index.d.ts +1 -0
  144. package/dist/esm/functions/constants_utils/src/constants.d.ts +7 -0
  145. package/dist/esm/functions/constants_utils/src/index.d.ts +1 -0
  146. package/dist/esm/functions/env_utils/imports.d.ts +1 -0
  147. package/dist/esm/functions/env_utils/index.d.ts +1 -0
  148. package/dist/esm/functions/env_utils/src/index.d.ts +1 -0
  149. package/dist/esm/functions/env_utils/src/window_utils.d.ts +4 -0
  150. package/dist/esm/functions/fetch_utils/imports.d.ts +7 -0
  151. package/dist/esm/functions/fetch_utils/index.d.ts +1 -0
  152. package/dist/esm/functions/fetch_utils/src/fetchIt_utils.d.ts +14 -0
  153. package/dist/esm/functions/fetch_utils/src/index.d.ts +1 -0
  154. package/dist/esm/functions/fetch_utils/src/utils.d.ts +18 -0
  155. package/dist/esm/functions/index.d.ts +9 -0
  156. package/dist/esm/functions/path_utils/imports.d.ts +20 -0
  157. package/dist/esm/functions/path_utils/index.d.ts +1 -0
  158. package/dist/esm/functions/path_utils/src/base_dirs.d.ts +4 -0
  159. package/dist/esm/functions/path_utils/src/function_dirs.d.ts +10 -0
  160. package/dist/esm/functions/path_utils/src/index.d.ts +6 -0
  161. package/dist/esm/functions/path_utils/src/misc_dirs.d.ts +4 -0
  162. package/dist/esm/functions/path_utils/src/path_utils.d.ts +17 -0
  163. package/dist/esm/functions/path_utils/src/paths.d.ts +5 -0
  164. package/dist/esm/functions/path_utils/src/src_dirs.d.ts +6 -0
  165. package/dist/esm/functions/rndm_utils/index.d.ts +1 -0
  166. package/dist/esm/functions/rndm_utils/src/index.d.ts +1 -0
  167. package/dist/esm/functions/rndm_utils/src/utils.d.ts +1 -0
  168. package/dist/esm/functions/string_utils/index.d.ts +1 -0
  169. package/dist/esm/functions/string_utils/src/index.d.ts +1 -0
  170. package/dist/esm/functions/string_utils/src/string_utils.d.ts +39 -0
  171. package/dist/esm/functions/type_utils/index.d.ts +1 -0
  172. package/dist/esm/functions/type_utils/src/index.d.ts +1 -0
  173. package/dist/esm/functions/type_utils/src/type_utils.d.ts +1 -0
  174. package/dist/esm/functions/ui_utils/imports.d.ts +6 -0
  175. package/dist/esm/functions/ui_utils/index.d.ts +1 -0
  176. package/dist/esm/functions/ui_utils/src/button.d.ts +4 -0
  177. package/dist/esm/functions/ui_utils/src/checkbox.d.ts +4 -0
  178. package/dist/esm/functions/ui_utils/src/index.d.ts +4 -0
  179. package/dist/esm/functions/ui_utils/src/input.d.ts +5 -0
  180. package/dist/esm/functions/ui_utils/src/spinner.d.ts +1 -0
  181. package/dist/esm/hooks/index.d.ts +1 -0
  182. package/dist/esm/hooks/useFiles/imports.d.ts +6 -0
  183. package/dist/esm/hooks/useFiles/index.d.ts +1 -0
  184. package/dist/esm/hooks/useFiles/src/deleteFile.d.ts +5 -0
  185. package/dist/esm/hooks/useFiles/src/index.d.ts +5 -0
  186. package/dist/esm/hooks/useFiles/src/load.d.ts +5 -0
  187. package/dist/esm/hooks/useFiles/src/patchShareSettings.d.ts +9 -0
  188. package/dist/esm/hooks/useFiles/src/toggleShare.d.ts +5 -0
  189. package/dist/esm/hooks/useFiles/src/useFiles.d.ts +13 -0
  190. package/dist/esm/index.d.ts +5 -0
  191. package/dist/esm/index.js +1678 -0
  192. package/dist/esm/index.js.map +1 -0
  193. package/dist/esm/types/index.d.ts +1 -0
  194. package/dist/esm/types/src/ChangePassword.d.ts +16 -0
  195. package/dist/esm/types/src/Files.d.ts +27 -0
  196. package/dist/esm/types/src/index.d.ts +5 -0
  197. package/dist/esm/types/src/login.d.ts +12 -0
  198. package/dist/esm/types/src/logout.d.ts +4 -0
  199. package/dist/esm/types/src/utils.d.ts +25 -0
  200. package/dist/file_utils/imports.d.ts +4 -0
  201. package/dist/file_utils/index.d.ts +1 -0
  202. package/dist/file_utils/src/delete_utils/imports.d.ts +1 -0
  203. package/dist/file_utils/src/delete_utils/index.d.ts +1 -0
  204. package/dist/file_utils/src/delete_utils/src/delete_row.d.ts +2 -0
  205. package/dist/file_utils/src/delete_utils/src/delete_select.d.ts +1 -0
  206. package/dist/file_utils/src/delete_utils/src/delete_selected.d.ts +2 -0
  207. package/dist/file_utils/src/delete_utils/src/index.d.ts +3 -0
  208. package/dist/file_utils/src/download_utils/imports.d.ts +2 -0
  209. package/dist/file_utils/src/download_utils/index.d.ts +1 -0
  210. package/dist/file_utils/src/download_utils/src/direct_download.d.ts +2 -0
  211. package/dist/file_utils/src/download_utils/src/download_file.d.ts +2 -0
  212. package/dist/file_utils/src/download_utils/src/download_select.d.ts +1 -0
  213. package/dist/file_utils/src/download_utils/src/index.d.ts +5 -0
  214. package/dist/file_utils/src/download_utils/src/target_downloads.d.ts +4 -0
  215. package/dist/file_utils/src/download_utils/src/trigger_download.d.ts +2 -0
  216. package/dist/file_utils/src/imports.d.ts +2 -0
  217. package/dist/file_utils/src/index.d.ts +6 -0
  218. package/dist/file_utils/src/list_utils/imports.d.ts +2 -0
  219. package/dist/file_utils/src/list_utils/index.d.ts +1 -0
  220. package/dist/file_utils/src/list_utils/src/index.d.ts +1 -0
  221. package/dist/file_utils/src/list_utils/src/list_utils.d.ts +2 -0
  222. package/dist/file_utils/src/select_utils/index.d.ts +1 -0
  223. package/dist/file_utils/src/select_utils/src/index.d.ts +3 -0
  224. package/dist/file_utils/src/select_utils/src/init_select_all.d.ts +2 -0
  225. package/dist/file_utils/src/select_utils/src/sync_header_checkbox.d.ts +5 -0
  226. package/dist/file_utils/src/select_utils/src/toggle_checkboxes.d.ts +2 -0
  227. package/dist/file_utils/src/share_utils/imports.d.ts +2 -0
  228. package/dist/file_utils/src/share_utils/index.d.ts +1 -0
  229. package/dist/file_utils/src/share_utils/src/index.d.ts +1 -0
  230. package/dist/file_utils/src/share_utils/src/share_utils.d.ts +7 -0
  231. package/dist/file_utils/src/upload_utils/imports.d.ts +1 -0
  232. package/dist/file_utils/src/upload_utils/index.d.ts +1 -0
  233. package/dist/file_utils/src/upload_utils/src/index.d.ts +3 -0
  234. package/dist/file_utils/src/upload_utils/src/patch_file_settings.d.ts +2 -0
  235. package/dist/file_utils/src/upload_utils/src/upload_file.d.ts +2 -0
  236. package/dist/file_utils/src/upload_utils/src/upload_files.d.ts +5 -0
  237. package/dist/functions/auth_utils/imports.d.ts +1 -0
  238. package/dist/functions/auth_utils/index.d.ts +1 -0
  239. package/dist/functions/auth_utils/src/index.d.ts +1 -0
  240. package/dist/functions/auth_utils/src/token_utils.d.ts +28 -0
  241. package/dist/functions/constants_utils/index.d.ts +1 -0
  242. package/dist/functions/constants_utils/src/constants.d.ts +7 -0
  243. package/dist/functions/constants_utils/src/index.d.ts +1 -0
  244. package/dist/functions/env_utils/imports.d.ts +1 -0
  245. package/dist/functions/env_utils/index.d.ts +1 -0
  246. package/dist/functions/env_utils/src/index.d.ts +1 -0
  247. package/dist/functions/env_utils/src/window_utils.d.ts +4 -0
  248. package/dist/functions/fetch_utils/imports.d.ts +7 -0
  249. package/dist/functions/fetch_utils/index.d.ts +1 -0
  250. package/dist/functions/fetch_utils/src/fetchIt_utils.d.ts +14 -0
  251. package/dist/functions/fetch_utils/src/index.d.ts +1 -0
  252. package/dist/functions/fetch_utils/src/utils.d.ts +18 -0
  253. package/dist/functions/index.d.ts +9 -0
  254. package/dist/functions/path_utils/imports.d.ts +20 -0
  255. package/dist/functions/path_utils/index.d.ts +1 -0
  256. package/dist/functions/path_utils/src/base_dirs.d.ts +4 -0
  257. package/dist/functions/path_utils/src/function_dirs.d.ts +10 -0
  258. package/dist/functions/path_utils/src/index.d.ts +6 -0
  259. package/dist/functions/path_utils/src/misc_dirs.d.ts +4 -0
  260. package/dist/functions/path_utils/src/path_utils.d.ts +17 -0
  261. package/dist/functions/path_utils/src/paths.d.ts +5 -0
  262. package/dist/functions/path_utils/src/src_dirs.d.ts +6 -0
  263. package/dist/functions/rndm_utils/imports.d.ts +0 -0
  264. package/dist/functions/rndm_utils/index.d.ts +1 -0
  265. package/dist/functions/rndm_utils/src/index.d.ts +1 -0
  266. package/dist/functions/rndm_utils/src/utils.d.ts +1 -0
  267. package/dist/functions/string_utils/index.d.ts +1 -0
  268. package/dist/functions/string_utils/src/index.d.ts +1 -0
  269. package/dist/functions/string_utils/src/string_utils.d.ts +39 -0
  270. package/dist/functions/type_utils/imports.d.ts +0 -0
  271. package/dist/functions/type_utils/index.d.ts +1 -0
  272. package/dist/functions/type_utils/src/index.d.ts +1 -0
  273. package/dist/functions/type_utils/src/type_utils.d.ts +1 -0
  274. package/dist/functions/ui_utils/imports.d.ts +6 -0
  275. package/dist/functions/ui_utils/index.d.ts +1 -0
  276. package/dist/functions/ui_utils/src/button.d.ts +4 -0
  277. package/dist/functions/ui_utils/src/checkbox.d.ts +4 -0
  278. package/dist/functions/ui_utils/src/index.d.ts +4 -0
  279. package/dist/functions/ui_utils/src/input.d.ts +5 -0
  280. package/dist/functions/ui_utils/src/spinner.d.ts +1 -0
  281. package/dist/hooks/index.d.ts +1 -0
  282. package/dist/hooks/useFiles/imports.d.ts +6 -0
  283. package/dist/hooks/useFiles/index.d.ts +1 -0
  284. package/dist/hooks/useFiles/src/deleteFile.d.ts +5 -0
  285. package/dist/hooks/useFiles/src/index.d.ts +5 -0
  286. package/dist/hooks/useFiles/src/load.d.ts +5 -0
  287. package/dist/hooks/useFiles/src/patchShareSettings.d.ts +9 -0
  288. package/dist/hooks/useFiles/src/toggleShare.d.ts +5 -0
  289. package/dist/hooks/useFiles/src/useFiles.d.ts +13 -0
  290. package/dist/index.d.ts +360 -0
  291. package/dist/types/index.d.ts +1 -0
  292. package/dist/types/src/ChangePassword.d.ts +16 -0
  293. package/dist/types/src/Files.d.ts +27 -0
  294. package/dist/types/src/index.d.ts +5 -0
  295. package/dist/types/src/login.d.ts +12 -0
  296. package/dist/types/src/logout.d.ts +4 -0
  297. package/dist/types/src/utils.d.ts +25 -0
  298. package/package.json +1 -0
@@ -0,0 +1,1678 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useCallback, useState, useEffect } from 'react';
3
+
4
+ /******************************************************************************
5
+ Copyright (c) Microsoft Corporation.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
17
+ ***************************************************************************** */
18
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
19
+
20
+
21
+ function __rest(s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ }
32
+
33
+ function __awaiter(thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
+ }
42
+
43
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
44
+ var e = new Error(message);
45
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46
+ };
47
+
48
+ let AppConfig;
49
+ function loadConfig() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const base = (process.env.PUBLIC_URL || "").replace(/\/+$/, "");
52
+ const url = `${base}/config.json`;
53
+ const res = yield fetch(url);
54
+ if (!res.ok)
55
+ throw new Error(`Failed to load ${url}: ${res.status}`);
56
+ AppConfig = yield res.json();
57
+ });
58
+ }
59
+
60
+ /** Helper function to trigger file download */
61
+ function triggerDownload(blob, filename) {
62
+ const url = URL.createObjectURL(blob);
63
+ const a = Object.assign(document.createElement("a"), {
64
+ href: url,
65
+ download: filename,
66
+ });
67
+ document.body.appendChild(a);
68
+ a.click();
69
+ a.remove();
70
+ URL.revokeObjectURL(url);
71
+ console.log(`✅ Successfully downloaded: ${filename}`);
72
+ }
73
+
74
+ /** Non-React “direct download” used by some old links (kept for parity) */
75
+ function directDownload(relPath, filename) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const token = localStorage.getItem("token");
78
+ if (!token)
79
+ throw new Error("No auth token found");
80
+ const res = yield fetch("/secure-files/download", {
81
+ method: "POST",
82
+ headers: {
83
+ Authorization: `Bearer ${token}`,
84
+ "Content-Type": "application/json",
85
+ Accept: "application/octet-stream",
86
+ },
87
+ body: JSON.stringify({ rel_path: relPath }),
88
+ });
89
+ if (!res.ok)
90
+ throw new Error(`Download failed: ${res.status}`);
91
+ const blob = yield res.blob();
92
+ triggerDownload(blob, filename);
93
+ });
94
+ }
95
+
96
+ /**
97
+ ***Changes**:
98
+ *- Updated import path for `InputProps` to `../../types/interfaces`.
99
+ *
100
+ *3. **Token Utilities** (`src/functions/auth/token_utils.ts`):
101
+ * Copy from `/var/www/abstractendeavors/my-login-app/src/functions/auth_utils/token_utils.ts`.
102
+ *
103
+ */
104
+ function isLoggedIn() {
105
+ const tok = localStorage.getItem("token");
106
+ return !!tok && !isTokenExpired(tok !== null && tok !== void 0 ? tok : "");
107
+ }
108
+ /** Read raw JWT from LocalStorage (or null if absent) */
109
+ function getToken() {
110
+ return localStorage.getItem("token");
111
+ }
112
+ /**
113
+ * Add a Bearer Authorization header.
114
+ * A shallow copy of headers is returned so callers can keep chaining.
115
+ */
116
+ function getAuthorizationHeader(headers = {}, token = null) {
117
+ token = token !== null && token !== void 0 ? token : getToken();
118
+ headers = headers || {};
119
+ if (token)
120
+ headers["Authorization"] = `Bearer ${token}`;
121
+ return Object.assign({}, headers);
122
+ }
123
+ /** Throw + redirect if there’s no valid token; otherwise return it. */
124
+ function requireToken() {
125
+ const tok = getToken();
126
+ if (!tok || isTokenExpired(tok)) {
127
+ console.warn("→ No token or expired token, redirecting to login…");
128
+ localStorage.removeItem("token");
129
+ window.location.href = '/login';
130
+ throw new Error("Redirecting to login…");
131
+ }
132
+ return tok;
133
+ }
134
+ /** True if token is structurally bad or its exp ≤ now. */
135
+ function isTokenExpired(token) {
136
+ try {
137
+ const payload = decodeJwt(token);
138
+ return Date.now() / 1000 >= payload.exp;
139
+ }
140
+ catch (_a) {
141
+ return true; // treat malformed token as expired
142
+ }
143
+ }
144
+ /** Convenience wrapper: return username from the JWT (or null). */
145
+ function currentUsername() {
146
+ const tok = getToken();
147
+ if (!tok)
148
+ return null;
149
+ try {
150
+ const { username } = decodeJwt(tok);
151
+ return username !== null && username !== void 0 ? username : null;
152
+ }
153
+ catch (_a) {
154
+ return null;
155
+ }
156
+ }
157
+ function currentUsernames() {
158
+ var _a;
159
+ const tok = localStorage.getItem("token");
160
+ if (!tok)
161
+ return null;
162
+ try {
163
+ const parts = tok.split(".");
164
+ if (parts.length !== 3)
165
+ return null;
166
+ let b64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
167
+ b64 = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
168
+ const jsonText = atob(b64);
169
+ const payload = JSON.parse(jsonText);
170
+ return (_a = payload.username) !== null && _a !== void 0 ? _a : null;
171
+ }
172
+ catch (_b) {
173
+ return null;
174
+ }
175
+ }
176
+ /* ------------------------------------------------------------------ */
177
+ /* internals */
178
+ /* ------------------------------------------------------------------ */
179
+ function decodeJwt(token) {
180
+ const [header, payload, signature] = token.split(".");
181
+ if (!header || !payload || !signature) {
182
+ throw new Error("Malformed JWT");
183
+ }
184
+ // Handle URL-safe Base64
185
+ let b64 = payload.replace(/-/g, "+").replace(/_/g, "/");
186
+ // Add padding if necessary
187
+ b64 = b64.padEnd(Math.ceil(b64.length / 4) * 4, "=");
188
+ const jsonText = atob(b64);
189
+ return JSON.parse(jsonText);
190
+ }
191
+
192
+ function assertPath(path) {
193
+ if (typeof path !== 'string') {
194
+ throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
195
+ }
196
+ }
197
+
198
+ // Resolves . and .. elements in a path with directory names
199
+ function normalizeStringPosix(path, allowAboveRoot) {
200
+ var res = '';
201
+ var lastSegmentLength = 0;
202
+ var lastSlash = -1;
203
+ var dots = 0;
204
+ var code;
205
+ for (var i = 0; i <= path.length; ++i) {
206
+ if (i < path.length)
207
+ code = path.charCodeAt(i);
208
+ else if (code === 47 /*/*/)
209
+ break;
210
+ else
211
+ code = 47 /*/*/;
212
+ if (code === 47 /*/*/) {
213
+ if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
214
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
215
+ if (res.length > 2) {
216
+ var lastSlashIndex = res.lastIndexOf('/');
217
+ if (lastSlashIndex !== res.length - 1) {
218
+ if (lastSlashIndex === -1) {
219
+ res = '';
220
+ lastSegmentLength = 0;
221
+ } else {
222
+ res = res.slice(0, lastSlashIndex);
223
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
224
+ }
225
+ lastSlash = i;
226
+ dots = 0;
227
+ continue;
228
+ }
229
+ } else if (res.length === 2 || res.length === 1) {
230
+ res = '';
231
+ lastSegmentLength = 0;
232
+ lastSlash = i;
233
+ dots = 0;
234
+ continue;
235
+ }
236
+ }
237
+ if (allowAboveRoot) {
238
+ if (res.length > 0)
239
+ res += '/..';
240
+ else
241
+ res = '..';
242
+ lastSegmentLength = 2;
243
+ }
244
+ } else {
245
+ if (res.length > 0)
246
+ res += '/' + path.slice(lastSlash + 1, i);
247
+ else
248
+ res = path.slice(lastSlash + 1, i);
249
+ lastSegmentLength = i - lastSlash - 1;
250
+ }
251
+ lastSlash = i;
252
+ dots = 0;
253
+ } else if (code === 46 /*.*/ && dots !== -1) {
254
+ ++dots;
255
+ } else {
256
+ dots = -1;
257
+ }
258
+ }
259
+ return res;
260
+ }
261
+
262
+ function _format(sep, pathObject) {
263
+ var dir = pathObject.dir || pathObject.root;
264
+ var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
265
+ if (!dir) {
266
+ return base;
267
+ }
268
+ if (dir === pathObject.root) {
269
+ return dir + base;
270
+ }
271
+ return dir + sep + base;
272
+ }
273
+
274
+ var posix = {
275
+ // path.resolve([from ...], to)
276
+ resolve: function resolve() {
277
+ var resolvedPath = '';
278
+ var resolvedAbsolute = false;
279
+ var cwd;
280
+
281
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
282
+ var path;
283
+ if (i >= 0)
284
+ path = arguments[i];
285
+ else {
286
+ if (cwd === undefined)
287
+ cwd = process.cwd();
288
+ path = cwd;
289
+ }
290
+
291
+ assertPath(path);
292
+
293
+ // Skip empty entries
294
+ if (path.length === 0) {
295
+ continue;
296
+ }
297
+
298
+ resolvedPath = path + '/' + resolvedPath;
299
+ resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
300
+ }
301
+
302
+ // At this point the path should be resolved to a full absolute path, but
303
+ // handle relative paths to be safe (might happen when process.cwd() fails)
304
+
305
+ // Normalize the path
306
+ resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
307
+
308
+ if (resolvedAbsolute) {
309
+ if (resolvedPath.length > 0)
310
+ return '/' + resolvedPath;
311
+ else
312
+ return '/';
313
+ } else if (resolvedPath.length > 0) {
314
+ return resolvedPath;
315
+ } else {
316
+ return '.';
317
+ }
318
+ },
319
+
320
+ normalize: function normalize(path) {
321
+ assertPath(path);
322
+
323
+ if (path.length === 0) return '.';
324
+
325
+ var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
326
+ var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
327
+
328
+ // Normalize the path
329
+ path = normalizeStringPosix(path, !isAbsolute);
330
+
331
+ if (path.length === 0 && !isAbsolute) path = '.';
332
+ if (path.length > 0 && trailingSeparator) path += '/';
333
+
334
+ if (isAbsolute) return '/' + path;
335
+ return path;
336
+ },
337
+
338
+ isAbsolute: function isAbsolute(path) {
339
+ assertPath(path);
340
+ return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
341
+ },
342
+
343
+ join: function join() {
344
+ if (arguments.length === 0)
345
+ return '.';
346
+ var joined;
347
+ for (var i = 0; i < arguments.length; ++i) {
348
+ var arg = arguments[i];
349
+ assertPath(arg);
350
+ if (arg.length > 0) {
351
+ if (joined === undefined)
352
+ joined = arg;
353
+ else
354
+ joined += '/' + arg;
355
+ }
356
+ }
357
+ if (joined === undefined)
358
+ return '.';
359
+ return posix.normalize(joined);
360
+ },
361
+
362
+ relative: function relative(from, to) {
363
+ assertPath(from);
364
+ assertPath(to);
365
+
366
+ if (from === to) return '';
367
+
368
+ from = posix.resolve(from);
369
+ to = posix.resolve(to);
370
+
371
+ if (from === to) return '';
372
+
373
+ // Trim any leading backslashes
374
+ var fromStart = 1;
375
+ for (; fromStart < from.length; ++fromStart) {
376
+ if (from.charCodeAt(fromStart) !== 47 /*/*/)
377
+ break;
378
+ }
379
+ var fromEnd = from.length;
380
+ var fromLen = fromEnd - fromStart;
381
+
382
+ // Trim any leading backslashes
383
+ var toStart = 1;
384
+ for (; toStart < to.length; ++toStart) {
385
+ if (to.charCodeAt(toStart) !== 47 /*/*/)
386
+ break;
387
+ }
388
+ var toEnd = to.length;
389
+ var toLen = toEnd - toStart;
390
+
391
+ // Compare paths to find the longest common path from root
392
+ var length = fromLen < toLen ? fromLen : toLen;
393
+ var lastCommonSep = -1;
394
+ var i = 0;
395
+ for (; i <= length; ++i) {
396
+ if (i === length) {
397
+ if (toLen > length) {
398
+ if (to.charCodeAt(toStart + i) === 47 /*/*/) {
399
+ // We get here if `from` is the exact base path for `to`.
400
+ // For example: from='/foo/bar'; to='/foo/bar/baz'
401
+ return to.slice(toStart + i + 1);
402
+ } else if (i === 0) {
403
+ // We get here if `from` is the root
404
+ // For example: from='/'; to='/foo'
405
+ return to.slice(toStart + i);
406
+ }
407
+ } else if (fromLen > length) {
408
+ if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
409
+ // We get here if `to` is the exact base path for `from`.
410
+ // For example: from='/foo/bar/baz'; to='/foo/bar'
411
+ lastCommonSep = i;
412
+ } else if (i === 0) {
413
+ // We get here if `to` is the root.
414
+ // For example: from='/foo'; to='/'
415
+ lastCommonSep = 0;
416
+ }
417
+ }
418
+ break;
419
+ }
420
+ var fromCode = from.charCodeAt(fromStart + i);
421
+ var toCode = to.charCodeAt(toStart + i);
422
+ if (fromCode !== toCode)
423
+ break;
424
+ else if (fromCode === 47 /*/*/)
425
+ lastCommonSep = i;
426
+ }
427
+
428
+ var out = '';
429
+ // Generate the relative path based on the path difference between `to`
430
+ // and `from`
431
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
432
+ if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
433
+ if (out.length === 0)
434
+ out += '..';
435
+ else
436
+ out += '/..';
437
+ }
438
+ }
439
+
440
+ // Lastly, append the rest of the destination (`to`) path that comes after
441
+ // the common path parts
442
+ if (out.length > 0)
443
+ return out + to.slice(toStart + lastCommonSep);
444
+ else {
445
+ toStart += lastCommonSep;
446
+ if (to.charCodeAt(toStart) === 47 /*/*/)
447
+ ++toStart;
448
+ return to.slice(toStart);
449
+ }
450
+ },
451
+
452
+ _makeLong: function _makeLong(path) {
453
+ return path;
454
+ },
455
+
456
+ dirname: function dirname(path) {
457
+ assertPath(path);
458
+ if (path.length === 0) return '.';
459
+ var code = path.charCodeAt(0);
460
+ var hasRoot = code === 47 /*/*/;
461
+ var end = -1;
462
+ var matchedSlash = true;
463
+ for (var i = path.length - 1; i >= 1; --i) {
464
+ code = path.charCodeAt(i);
465
+ if (code === 47 /*/*/) {
466
+ if (!matchedSlash) {
467
+ end = i;
468
+ break;
469
+ }
470
+ } else {
471
+ // We saw the first non-path separator
472
+ matchedSlash = false;
473
+ }
474
+ }
475
+
476
+ if (end === -1) return hasRoot ? '/' : '.';
477
+ if (hasRoot && end === 1) return '//';
478
+ return path.slice(0, end);
479
+ },
480
+
481
+ basename: function basename(path, ext) {
482
+ if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
483
+ assertPath(path);
484
+
485
+ var start = 0;
486
+ var end = -1;
487
+ var matchedSlash = true;
488
+ var i;
489
+
490
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
491
+ if (ext.length === path.length && ext === path) return '';
492
+ var extIdx = ext.length - 1;
493
+ var firstNonSlashEnd = -1;
494
+ for (i = path.length - 1; i >= 0; --i) {
495
+ var code = path.charCodeAt(i);
496
+ if (code === 47 /*/*/) {
497
+ // If we reached a path separator that was not part of a set of path
498
+ // separators at the end of the string, stop now
499
+ if (!matchedSlash) {
500
+ start = i + 1;
501
+ break;
502
+ }
503
+ } else {
504
+ if (firstNonSlashEnd === -1) {
505
+ // We saw the first non-path separator, remember this index in case
506
+ // we need it if the extension ends up not matching
507
+ matchedSlash = false;
508
+ firstNonSlashEnd = i + 1;
509
+ }
510
+ if (extIdx >= 0) {
511
+ // Try to match the explicit extension
512
+ if (code === ext.charCodeAt(extIdx)) {
513
+ if (--extIdx === -1) {
514
+ // We matched the extension, so mark this as the end of our path
515
+ // component
516
+ end = i;
517
+ }
518
+ } else {
519
+ // Extension does not match, so our result is the entire path
520
+ // component
521
+ extIdx = -1;
522
+ end = firstNonSlashEnd;
523
+ }
524
+ }
525
+ }
526
+ }
527
+
528
+ if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
529
+ return path.slice(start, end);
530
+ } else {
531
+ for (i = path.length - 1; i >= 0; --i) {
532
+ if (path.charCodeAt(i) === 47 /*/*/) {
533
+ // If we reached a path separator that was not part of a set of path
534
+ // separators at the end of the string, stop now
535
+ if (!matchedSlash) {
536
+ start = i + 1;
537
+ break;
538
+ }
539
+ } else if (end === -1) {
540
+ // We saw the first non-path separator, mark this as the end of our
541
+ // path component
542
+ matchedSlash = false;
543
+ end = i + 1;
544
+ }
545
+ }
546
+
547
+ if (end === -1) return '';
548
+ return path.slice(start, end);
549
+ }
550
+ },
551
+
552
+ extname: function extname(path) {
553
+ assertPath(path);
554
+ var startDot = -1;
555
+ var startPart = 0;
556
+ var end = -1;
557
+ var matchedSlash = true;
558
+ // Track the state of characters (if any) we see before our first dot and
559
+ // after any path separator we find
560
+ var preDotState = 0;
561
+ for (var i = path.length - 1; i >= 0; --i) {
562
+ var code = path.charCodeAt(i);
563
+ if (code === 47 /*/*/) {
564
+ // If we reached a path separator that was not part of a set of path
565
+ // separators at the end of the string, stop now
566
+ if (!matchedSlash) {
567
+ startPart = i + 1;
568
+ break;
569
+ }
570
+ continue;
571
+ }
572
+ if (end === -1) {
573
+ // We saw the first non-path separator, mark this as the end of our
574
+ // extension
575
+ matchedSlash = false;
576
+ end = i + 1;
577
+ }
578
+ if (code === 46 /*.*/) {
579
+ // If this is our first dot, mark it as the start of our extension
580
+ if (startDot === -1)
581
+ startDot = i;
582
+ else if (preDotState !== 1)
583
+ preDotState = 1;
584
+ } else if (startDot !== -1) {
585
+ // We saw a non-dot and non-path separator before our dot, so we should
586
+ // have a good chance at having a non-empty extension
587
+ preDotState = -1;
588
+ }
589
+ }
590
+
591
+ if (startDot === -1 || end === -1 ||
592
+ // We saw a non-dot character immediately before the dot
593
+ preDotState === 0 ||
594
+ // The (right-most) trimmed path component is exactly '..'
595
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
596
+ return '';
597
+ }
598
+ return path.slice(startDot, end);
599
+ },
600
+
601
+ format: function format(pathObject) {
602
+ if (pathObject === null || typeof pathObject !== 'object') {
603
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
604
+ }
605
+ return _format('/', pathObject);
606
+ },
607
+
608
+ parse: function parse(path) {
609
+ assertPath(path);
610
+
611
+ var ret = { root: '', dir: '', base: '', ext: '', name: '' };
612
+ if (path.length === 0) return ret;
613
+ var code = path.charCodeAt(0);
614
+ var isAbsolute = code === 47 /*/*/;
615
+ var start;
616
+ if (isAbsolute) {
617
+ ret.root = '/';
618
+ start = 1;
619
+ } else {
620
+ start = 0;
621
+ }
622
+ var startDot = -1;
623
+ var startPart = 0;
624
+ var end = -1;
625
+ var matchedSlash = true;
626
+ var i = path.length - 1;
627
+
628
+ // Track the state of characters (if any) we see before our first dot and
629
+ // after any path separator we find
630
+ var preDotState = 0;
631
+
632
+ // Get non-dir info
633
+ for (; i >= start; --i) {
634
+ code = path.charCodeAt(i);
635
+ if (code === 47 /*/*/) {
636
+ // If we reached a path separator that was not part of a set of path
637
+ // separators at the end of the string, stop now
638
+ if (!matchedSlash) {
639
+ startPart = i + 1;
640
+ break;
641
+ }
642
+ continue;
643
+ }
644
+ if (end === -1) {
645
+ // We saw the first non-path separator, mark this as the end of our
646
+ // extension
647
+ matchedSlash = false;
648
+ end = i + 1;
649
+ }
650
+ if (code === 46 /*.*/) {
651
+ // If this is our first dot, mark it as the start of our extension
652
+ if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
653
+ } else if (startDot !== -1) {
654
+ // We saw a non-dot and non-path separator before our dot, so we should
655
+ // have a good chance at having a non-empty extension
656
+ preDotState = -1;
657
+ }
658
+ }
659
+
660
+ if (startDot === -1 || end === -1 ||
661
+ // We saw a non-dot character immediately before the dot
662
+ preDotState === 0 ||
663
+ // The (right-most) trimmed path component is exactly '..'
664
+ preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
665
+ if (end !== -1) {
666
+ if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
667
+ }
668
+ } else {
669
+ if (startPart === 0 && isAbsolute) {
670
+ ret.name = path.slice(1, startDot);
671
+ ret.base = path.slice(1, end);
672
+ } else {
673
+ ret.name = path.slice(startPart, startDot);
674
+ ret.base = path.slice(startPart, end);
675
+ }
676
+ ret.ext = path.slice(startDot, end);
677
+ }
678
+
679
+ if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
680
+
681
+ return ret;
682
+ },
683
+
684
+ sep: '/',
685
+ delimiter: ':',
686
+ win32: null,
687
+ posix: null
688
+ };
689
+
690
+ posix.posix = posix;
691
+
692
+ var pathBrowserify = posix;
693
+
694
+ function getSubstring(obj, maxLength = null, minLength = null) {
695
+ const objLength = obj.length;
696
+ const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
697
+ const effectiveMinLength = minLength !== null && minLength !== void 0 ? minLength : 0;
698
+ // Ensure bounds are valid
699
+ const clampedMaxLength = Math.min(Math.max(effectiveMaxLength, 0), objLength);
700
+ const clampedMinLength = Math.min(Math.max(effectiveMinLength, 0), objLength);
701
+ // If minLength exceeds maxLength, return empty string or adjust logic as needed
702
+ if (clampedMinLength >= clampedMaxLength) {
703
+ return '';
704
+ }
705
+ return obj.substring(clampedMinLength, clampedMaxLength);
706
+ }
707
+ function truncateString(obj, maxLength = 20) {
708
+ const objLength = obj.length;
709
+ if (objLength > maxLength && maxLength) {
710
+ obj = getSubstring(obj, maxLength) + '...';
711
+ }
712
+ return obj;
713
+ }
714
+ /**
715
+ * Remove *every* occurrence of any prefix in `bases` from the *beginning*
716
+ * of `str`, looping until no prefix matches.
717
+ *
718
+ * @example
719
+ * stripPrefixes('/site/site/docs', ['/site', '/static']);
720
+ * // → '/docs'
721
+ */
722
+ function stripPrefixes(str, bases = []) {
723
+ // normalise to a non-empty array of strings
724
+ const prefixes = (Array.isArray(bases) ? bases : [bases])
725
+ .filter(Boolean)
726
+ // longest first ⇒ '/site/files' is checked before '/site'
727
+ .sort((a, b) => b.length - a.length);
728
+ let changed = true;
729
+ while (changed) {
730
+ changed = false;
731
+ for (const prefix of prefixes) {
732
+ if (str.startsWith(prefix)) {
733
+ str = str.slice(prefix.length);
734
+ changed = true; // start the loop again
735
+ break; // restart prefix scan from the longest one
736
+ }
737
+ }
738
+ }
739
+ return str;
740
+ }
741
+ /**
742
+ * Removes characters from the beginning of the string
743
+ * if they are found in the list of characters.
744
+ *
745
+ * @param str - The input string.
746
+ * @param listObjects - A string or an array of characters to remove.
747
+ * @returns The modified string.
748
+ */
749
+ function eatInner(str, listObjects) {
750
+ if (!Array.isArray(listObjects)) {
751
+ listObjects = [listObjects];
752
+ }
753
+ // Ensure str is a string
754
+ str = String(str);
755
+ // Remove characters from the beginning while they are in listObjects
756
+ while (str.length > 0 && listObjects.includes(str[0])) {
757
+ str = str.slice(1);
758
+ }
759
+ return str;
760
+ }
761
+ /**
762
+ * Removes characters from the end of the string
763
+ * if they are found in the list of characters.
764
+ *
765
+ * @param str - The input string.
766
+ * @param listObjects - A string or an array of characters to remove.
767
+ * @returns The modified string.
768
+ */
769
+ function eatOuter(str, listObjects) {
770
+ if (!Array.isArray(listObjects)) {
771
+ listObjects = [listObjects];
772
+ }
773
+ // Ensure str is a string
774
+ str = String(str);
775
+ // Remove characters from the end while they are in listObjects
776
+ while (str.length > 0 && listObjects.includes(str[str.length - 1])) {
777
+ str = str.slice(0, -1);
778
+ }
779
+ return str;
780
+ }
781
+ /**
782
+ * Removes characters from both the beginning and the end of the string
783
+ * if they are found in the list of characters.
784
+ *
785
+ * @param str - The input string.
786
+ * @param listObjects - A string or an array of characters to remove.
787
+ * @returns The modified string.
788
+ */
789
+ function eatAll(str, listObjects) {
790
+ return eatOuter(eatInner(str, listObjects), listObjects);
791
+ }
792
+ function eatEnd(obj, endings = ['/']) {
793
+ let result = obj;
794
+ let modified = true;
795
+ while (modified) {
796
+ modified = false;
797
+ for (const ending of endings) {
798
+ if (result.endsWith(ending)) {
799
+ result = result.slice(0, -ending.length);
800
+ modified = true;
801
+ break;
802
+ }
803
+ }
804
+ }
805
+ return result;
806
+ }
807
+
808
+ function ensure_list(obj) {
809
+ const objArray = Array.isArray(obj) ? obj : [obj];
810
+ return objArray;
811
+ }
812
+
813
+ /**
814
+ * In the browser we already have a WHATWG URL constructor on window.
815
+ * Here we re-export it as “url” so other modules can import it.
816
+ */
817
+ /**
818
+ * Minimal fileURLToPath implementation for browser-side code.
819
+ * If you only ever need to strip off “file://” in development, this is enough.
820
+ */
821
+ function fileURLToPath(fileUrl) {
822
+ // e.g. fileUrl = "file:///Users/foo/bar.txt"
823
+ try {
824
+ const u = new URL(fileUrl);
825
+ return u.pathname;
826
+ }
827
+ catch (_a) {
828
+ // fallback: just strip file://
829
+ return fileUrl.replace(/^file:\/\//, '');
830
+ }
831
+ }
832
+ function getAbsolutePath() {
833
+ return fileURLToPath(import.meta.url);
834
+ }
835
+
836
+ function get_dirname(filePath) {
837
+ if (!filePath)
838
+ return '';
839
+ return pathBrowserify.dirname(filePath);
840
+ }
841
+ function get_basename(filePath) {
842
+ if (!filePath)
843
+ return '';
844
+ return pathBrowserify.basename(filePath);
845
+ }
846
+ function get_filename(file_path) {
847
+ const ext = pathBrowserify.extname(file_path);
848
+ return pathBrowserify.basename(file_path, ext);
849
+ }
850
+ function get_extname(filePath) {
851
+ if (!filePath)
852
+ return '';
853
+ return pathBrowserify.extname(filePath);
854
+ }
855
+ function get_splitext(filePath) {
856
+ if (!filePath)
857
+ return { filename: '', extname: '' };
858
+ const ext = pathBrowserify.extname(filePath);
859
+ // Get the basename without the extension
860
+ const filename = pathBrowserify.basename(filePath, ext);
861
+ return { filename, ext };
862
+ }
863
+ function make_path(...segments) {
864
+ const list = ensure_list(segments);
865
+ let real_path = '';
866
+ for (let i = 0; i < list.length; i++) {
867
+ let segment = list[i]; // renamed, no shadowing
868
+ if (i === 0) {
869
+ real_path = segment;
870
+ }
871
+ else {
872
+ segment = eatInner(segment, ['/']);
873
+ real_path = eatOuter(real_path, ['/']);
874
+ real_path = `${real_path}/${segment}`;
875
+ }
876
+ }
877
+ return real_path || '';
878
+ }
879
+ function sanitizeFilename(filename) {
880
+ return filename
881
+ .toLowerCase()
882
+ .replace(/\s+|-/g, '-') // Replace spaces and hyphens with single hyphen
883
+ .replace(/_/g, '-') // Replace underscores with hyphens
884
+ .replace(/[^a-z0-9-.]/g, '') // Remove all non-alphanumeric chars except hyphen and dot
885
+ .replace(/-+/g, '-') // Collapse multiple hyphens into one
886
+ .replace(/^-|-$/, ''); // Remove leading/trailing hyphens
887
+ }
888
+ function make_sanitized_path(...paths) {
889
+ let real_path = '';
890
+ for (let i = 0; i < paths.length; i++) {
891
+ const sanitized = sanitizeFilename(eatInner(paths[i], ['/']));
892
+ if (i === 0) {
893
+ real_path = sanitized;
894
+ }
895
+ else if (sanitized) { // Only append if there's a non-empty segment
896
+ real_path = `${real_path}/${sanitized}`;
897
+ }
898
+ }
899
+ return real_path || '';
900
+ }
901
+ function normalizeUrl(base, p) {
902
+ if (!p)
903
+ return base;
904
+ const cleanBase = base.replace(/\/+$/, ''); // regex literal
905
+ const cleanPath = p.replace(/^\/+/, '');
906
+ // collapse multiple “//” into one, but keep the “://” after protocol
907
+ return `${cleanBase}/${cleanPath}`.replace(/([^:])\/{2,}/g, '$1/');
908
+ }
909
+
910
+ /**
911
+ * Returns the absolute path of the current file.
912
+ */
913
+ function getAbsDir() {
914
+ return get_dirname(getAbsolutePath());
915
+ }
916
+ function getAbsPath(subPath) {
917
+ return make_path(getAbsDir(), subPath);
918
+ }
919
+
920
+ function getFunctionsDir() {
921
+ return get_dirname(getAbsDir());
922
+ }
923
+ function geAuthsUtilsDirectory() {
924
+ return make_path(getFunctionsDir(), 'auths');
925
+ }
926
+ function geBackupsUtilsDirectory() {
927
+ return make_path(getFunctionsDir(), 'backups');
928
+ }
929
+ function geConstantsUtilsDirectory() {
930
+ return make_path(getFunctionsDir(), 'constants');
931
+ }
932
+ function geEnvUtilsDirectory() {
933
+ return make_path(getFunctionsDir(), 'env_utils');
934
+ }
935
+ function geFetchUtilsDirectory() {
936
+ return make_path(getFunctionsDir(), 'fetch_utils');
937
+ }
938
+ function geFileUtilsDirectory() {
939
+ return make_path(getFunctionsDir(), 'file_utils');
940
+ }
941
+ function gePathUtilsDirectory() {
942
+ return make_path(getFunctionsDir(), 'path_utils');
943
+ }
944
+ function geStringUtilsDirectory() {
945
+ return make_path(getFunctionsDir(), 'string_utils');
946
+ }
947
+ function geTypeUtilsDirectory() {
948
+ return make_path(getFunctionsDir(), 'type_utils');
949
+ }
950
+
951
+ function getSrcDir() {
952
+ return get_dirname(getFunctionsDir());
953
+ }
954
+ function geStaticDirectory() {
955
+ return make_path(getSrcDir(), 'static');
956
+ }
957
+ function getLibUtilsDirectory() {
958
+ return make_path(getSrcDir(), 'lib');
959
+ }
960
+ function getHooksUtilsDirectory() {
961
+ return make_path(getSrcDir(), 'hooks');
962
+ }
963
+ function getFunctionsUtilsDirectory() {
964
+ return make_path(getSrcDir(), 'functions');
965
+ }
966
+ function getComponentsUtilsDirectory() {
967
+ return make_path(getSrcDir(), 'components');
968
+ }
969
+
970
+ function getBaseDir() {
971
+ return get_dirname(getSrcDir());
972
+ }
973
+ function getPublicDir() {
974
+ return make_path(getBaseDir(), 'public');
975
+ }
976
+ function getDistDir() {
977
+ return make_path(getBaseDir(), 'dist');
978
+ }
979
+ function getEnvDir() {
980
+ return make_path(getBaseDir(), '.env');
981
+ }
982
+
983
+ function getEnvPath(string = '.env') {
984
+ return make_path(getEnvDir(), string);
985
+ }
986
+ function getDbConfigsPath() {
987
+ return make_path(getBaseDir(), 'dbConfigs');
988
+ }
989
+ function getSchemasPath() {
990
+ return make_path(getDbConfigsPath(), 'schemas');
991
+ }
992
+ function getSchemasDirPath(subPath) {
993
+ return make_path(getSchemasPath(), subPath);
994
+ }
995
+
996
+ // src/functions/rndm_utils/utils.ts
997
+ function alertit(obj = null) {
998
+ let msg;
999
+ try {
1000
+ msg = JSON.stringify(obj);
1001
+ }
1002
+ catch (_a) {
1003
+ // If JSON.stringify fails (circular refs, etc.), fall back to a simple string
1004
+ msg = String(obj);
1005
+ }
1006
+ alert(msg);
1007
+ }
1008
+
1009
+ function ensureAbstractUrl(endpoint, slices = []) {
1010
+ // 1) build a prefix string like "api/v1/"
1011
+ const prefix = slices.map((s) => `${s}/`).join("");
1012
+ // 2) normalize the list you’ll use for stripping
1013
+ const normalized = ["/", ...ensure_list(slices)];
1014
+ // 3) remove any inner “/” duplicates from prefix
1015
+ const target = eatInner(prefix, ["/"]);
1016
+ // 4) drop any of those prefixes off the endpoint
1017
+ const strippedEndpoint = stripPrefixes(endpoint, normalized);
1018
+ // 5) hand it back to make_path to join “target” + “strippedEndpoint”
1019
+ return make_path(target, strippedEndpoint);
1020
+ }
1021
+ /** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
1022
+ function getRawConfigUrl() {
1023
+ var _a;
1024
+ // Now AppConfig[key] is allowed because of the index signature
1025
+ const rawBase = (_a = AppConfig.API_BASE_URL) !== null && _a !== void 0 ? _a : "";
1026
+ return rawBase.replace(/\/+$/, "");
1027
+ }
1028
+ // Constructs API URL from endpoint
1029
+ function api(endpoint) {
1030
+ return ensureAbstractUrl(endpoint);
1031
+ }
1032
+ // Checks if response is OK, handles 401/403 by redirecting to login
1033
+ function checkResponse(res) {
1034
+ if (!res.ok) {
1035
+ if (res.status === 401 || res.status === 403) {
1036
+ alert('Session expired. Please log in again.');
1037
+ localStorage.removeItem('token');
1038
+ window.location.href = '/secure-files/login';
1039
+ }
1040
+ }
1041
+ return res;
1042
+ }
1043
+ // Parses JSON response and handles specific response shapes
1044
+ function parseResult(res) {
1045
+ return __awaiter(this, void 0, void 0, function* () {
1046
+ res = checkResponse(res);
1047
+ try {
1048
+ const data = yield res.json();
1049
+ if ((data === null || data === void 0 ? void 0 : data.success) === true && Array.isArray(data.result)) {
1050
+ return data.result;
1051
+ }
1052
+ if ((data === null || data === void 0 ? void 0 : data.message) && typeof data.message === 'string') {
1053
+ alert(`Error: ${data.message}`);
1054
+ }
1055
+ return data;
1056
+ }
1057
+ catch (err) {
1058
+ throw new Error('Server returned invalid JSON');
1059
+ }
1060
+ });
1061
+ }
1062
+ // Determines HTTP method, defaults to GET or POST based on body
1063
+ function getMethod(method = null, body = null) {
1064
+ const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'PULL'];
1065
+ method = (method || '').toUpperCase();
1066
+ if (!validMethods.includes(method)) {
1067
+ method = body ? 'POST' : 'GET';
1068
+ }
1069
+ return method;
1070
+ }
1071
+ // Gets headers, skips JSON headers when body is FormData
1072
+ function getHeaders(headers = {}, method = null, body = null) {
1073
+ const result = Object.assign({}, headers);
1074
+ // inject auth if missing
1075
+ if (!result.Authorization) {
1076
+ const token = localStorage.getItem('token');
1077
+ Object.assign(result, getAuthorizationHeader(result, token));
1078
+ }
1079
+ method = getMethod(method, body);
1080
+ // if it’s a multipart FormData, let the browser set the boundary header
1081
+ if (body instanceof FormData) {
1082
+ return result;
1083
+ }
1084
+ // otherwise for POST/PUT/PATCH default to JSON
1085
+ if (['POST', 'PUT', 'PATCH'].includes(method) && !result['Content-Type']) {
1086
+ result['Content-Type'] = 'application/json';
1087
+ }
1088
+ return result;
1089
+ }
1090
+ // Prepares request body, serializes to JSON for non-GET requests
1091
+ function getBody(body = null, method = null) {
1092
+ method = getMethod(method, body);
1093
+ if (method === 'GET') {
1094
+ return undefined;
1095
+ }
1096
+ if (body) {
1097
+ try {
1098
+ return JSON.stringify(body);
1099
+ }
1100
+ catch (err) {
1101
+ return body;
1102
+ }
1103
+ }
1104
+ return undefined;
1105
+ }
1106
+ // Prepares fetch variables, passes FormData intact
1107
+ function getFetchVars(headers = null, method = null, body = null) {
1108
+ method = getMethod(method, body);
1109
+ headers = getHeaders(headers || {}, method, body);
1110
+ // only JSON-stringify non-FormData bodies
1111
+ if (!(body instanceof FormData)) {
1112
+ body = getBody(body, method);
1113
+ }
1114
+ return { method, headers, body };
1115
+ }
1116
+
1117
+ /**
1118
+
1119
+ ***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
1120
+ *
1121
+ *4. **secureFetchIt** (`src/functions/fetch/secureFetchIt.ts`):
1122
+ * Since `secureFetchIt` isn’t provided, we’ll create a minimal implementation based on its usage in `Login` and `uploadFiles`. It’s assumed to be a wrapper around `fetch` that handles authentication and JSON parsing.
1123
+ *
1124
+ */
1125
+ /** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
1126
+ // src/functions/fetch/secureFetchIt.ts
1127
+ // --- fetch_utils/src/fetch_utils.ts ----------------------------
1128
+ function fetchIt(endpoint_1) {
1129
+ return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, headers = null, blob = null, no_api = false, requireAuth = true) {
1130
+ const vars = getFetchVars(headers, method, body);
1131
+ const url = no_api ? endpoint : api(endpoint);
1132
+ const res = yield fetch(url, vars);
1133
+ return blob ? (checkResponse(res), res.blob()) : yield parseResult(res);
1134
+ });
1135
+ }
1136
+ function secureFetchIt(endpoint_1) {
1137
+ return __awaiter(this, arguments, void 0, function* (endpoint, body = null, method = null, customHeaders = null, blob = false, noApi = false, withCredentials = true, returnJson = true) {
1138
+ // strip leading slashes off the endpoint
1139
+ method = method || "GET";
1140
+ const cleanEndpoint = endpoint.replace(/^\/+/, "");
1141
+ // decide whether to build off your API_BASE_URL or not
1142
+ const rawBase = getRawConfigUrl();
1143
+ const baseSlices = noApi
1144
+ ? []
1145
+ : rawBase.split("/").filter(Boolean);
1146
+ // build final URL
1147
+ const url = ensureAbstractUrl(cleanEndpoint, baseSlices);
1148
+ // headers: JSON by default, plus any auth + overrides
1149
+ const headers = Object.assign(Object.assign(Object.assign({}, (body instanceof FormData ? {} : { "Content-Type": "application/json" })), getAuthorizationHeader()), customHeaders);
1150
+ const opts = {
1151
+ method: method.toUpperCase(),
1152
+ credentials: withCredentials ? "include" : "same-origin",
1153
+ headers,
1154
+ body: body instanceof FormData
1155
+ ? body
1156
+ : body != null && method.toUpperCase() !== "GET"
1157
+ ? JSON.stringify(body)
1158
+ : undefined,
1159
+ };
1160
+ console.debug("➡️ secureFetchIt →", url, opts);
1161
+ const res = yield fetch(url, opts);
1162
+ if (!res.ok) {
1163
+ const err = yield res.text();
1164
+ throw new Error(`HTTP ${res.status}: ${err}`);
1165
+ }
1166
+ if (blob)
1167
+ return res.blob();
1168
+ if (returnJson)
1169
+ return res.json();
1170
+ return res;
1171
+ });
1172
+ }
1173
+ // Performs PATCH request
1174
+ function requestPatch(url_1) {
1175
+ return __awaiter(this, arguments, void 0, function* (url, body = null) {
1176
+ const variables = getFetchVars(null, 'PATCH', body);
1177
+ return yield fetch(api(url), variables);
1178
+ });
1179
+ }
1180
+ // Performs PATCH request for file sharing
1181
+ function fetchSharePatch(file) {
1182
+ return __awaiter(this, void 0, void 0, function* () {
1183
+ const base = getRawConfigUrl();
1184
+ const url = `${base}/files/share`;
1185
+ const token = localStorage.getItem('token');
1186
+ const resp = yield fetch(url, {
1187
+ method: 'PATCH',
1188
+ headers: {
1189
+ 'Content-Type': 'application/json',
1190
+ 'Authorization': `Bearer ${token}`,
1191
+ },
1192
+ body: JSON.stringify(file),
1193
+ });
1194
+ if (!resp.ok) {
1195
+ console.error('Error from server', yield resp.text());
1196
+ }
1197
+ else {
1198
+ const data = yield resp.json();
1199
+ console.log('Success!', data);
1200
+ }
1201
+ });
1202
+ }
1203
+
1204
+ function downloadFile(item) {
1205
+ return __awaiter(this, void 0, void 0, function* () {
1206
+ const token = requireToken();
1207
+ const { filepath, filename } = item;
1208
+ const body = { rel_path: filepath };
1209
+ const headers = {
1210
+ Authorization: `Bearer ${token}`,
1211
+ Accept: "application/octet-stream",
1212
+ "Content-Type": "application/json"
1213
+ };
1214
+ const blob = yield secureFetchIt("download", body, "POST", headers, true, true);
1215
+ if (!blob || blob.size === 0) {
1216
+ throw new Error(`Received empty file data for “${filename}”`);
1217
+ }
1218
+ triggerDownload(blob, filename);
1219
+ });
1220
+ }
1221
+
1222
+ function downloadSelect(relPath, filename) {
1223
+ return __awaiter(this, void 0, void 0, function* () {
1224
+ const token = requireToken();
1225
+ const body = { rel_path: relPath };
1226
+ const headers = {
1227
+ Authorization: `Bearer ${token}`,
1228
+ Accept: "application/octet-stream",
1229
+ "Content-Type": "application/json"
1230
+ };
1231
+ const blob = yield secureFetchIt("download", body, "POST", headers, true, true);
1232
+ if (!blob || blob.size === 0) {
1233
+ throw new Error(`Received empty file data for “${filename}”`);
1234
+ }
1235
+ triggerDownload(blob, filename);
1236
+ });
1237
+ }
1238
+
1239
+ /** Given a checkbox inside a table-row → download that row’s file. */
1240
+ function downloadRow(cb) {
1241
+ return __awaiter(this, void 0, void 0, function* () {
1242
+ var _a, _b;
1243
+ const row = cb.closest("tr");
1244
+ const relPath = cb.value;
1245
+ const filename = ((_b = (_a = row === null || row === void 0 ? void 0 : row.children[1]) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || "downloaded_file";
1246
+ if (relPath)
1247
+ yield downloadSelect(relPath, filename);
1248
+ });
1249
+ }
1250
+ /** Bulk download: pass a NodeList or array of checkboxes. */
1251
+ function downloadSelected(checkboxes) {
1252
+ return __awaiter(this, void 0, void 0, function* () {
1253
+ const list = Array.from(checkboxes);
1254
+ if (!list.length) {
1255
+ alert("No files selected.");
1256
+ return;
1257
+ }
1258
+ for (const cb of list) {
1259
+ yield downloadRow(cb);
1260
+ }
1261
+ });
1262
+ }
1263
+
1264
+ /**
1265
+ * Classic “select all rows” logic (still handy in non-React views
1266
+ * such as the admin dashboard).
1267
+ */
1268
+ function syncHeaderCheckbox() {
1269
+ const all = document.querySelectorAll(".file-checkbox");
1270
+ const checked = document.querySelectorAll(".file-checkbox:checked");
1271
+ const header = document.getElementById("select-all-checkbox");
1272
+ header.indeterminate =
1273
+ checked.length > 0 && checked.length < all.length;
1274
+ header.checked = checked.length === all.length;
1275
+ }
1276
+
1277
+ /** Wire up header + row checkboxes once the table is in the DOM. */
1278
+ function initSelectAll() {
1279
+ const header = document.getElementById("select-all-checkbox");
1280
+ const btn = document.getElementById("select-all");
1281
+ // 1) header → toggle all
1282
+ header.addEventListener("change", (e) => {
1283
+ const on = e.target.checked;
1284
+ document
1285
+ .querySelectorAll(".file-checkbox")
1286
+ .forEach((cb) => (cb.checked = on));
1287
+ });
1288
+ // 2) button → toggle all
1289
+ btn.addEventListener("click", () => {
1290
+ const cbs = Array.from(document.querySelectorAll(".file-checkbox"));
1291
+ if (!cbs.length) {
1292
+ alert("No files to select.");
1293
+ return;
1294
+ }
1295
+ const anyUnchecked = cbs.some((cb) => !cb.checked);
1296
+ cbs.forEach((cb) => (cb.checked = anyUnchecked));
1297
+ syncHeaderCheckbox();
1298
+ });
1299
+ // 3) row boxes → keep header state
1300
+ document
1301
+ .querySelectorAll(".file-checkbox")
1302
+ .forEach((cb) => cb.addEventListener("change", syncHeaderCheckbox));
1303
+ syncHeaderCheckbox();
1304
+ }
1305
+
1306
+ /** Utility for other screens: toggle a list of checkboxes on/off. */
1307
+ function toggleCheckboxes(cbs) {
1308
+ if (!cbs.length) {
1309
+ alert("No files to select.");
1310
+ return;
1311
+ }
1312
+ const anyUnchecked = cbs.some((cb) => !cb.checked);
1313
+ cbs.forEach((cb) => (cb.checked = anyUnchecked));
1314
+ syncHeaderCheckbox();
1315
+ }
1316
+
1317
+ /** Generic PATCH helper kept for other admin forms */
1318
+ function patchFileSetting(fileId, field, value) {
1319
+ return __awaiter(this, void 0, void 0, function* () {
1320
+ const res = yield fetch(`/files/${fileId}/settings/${field}`, {
1321
+ method: "PATCH",
1322
+ headers: { "Content-Type": "application/json" },
1323
+ body: JSON.stringify({ value }),
1324
+ });
1325
+ if (!res.ok) {
1326
+ const err = yield res.json();
1327
+ throw new Error(err.error || res.statusText);
1328
+ }
1329
+ return (yield res.json());
1330
+ });
1331
+ }
1332
+
1333
+ /** Classic file-upload for the fallback HTML page. */
1334
+ function uploadFile(file, subdir) {
1335
+ return __awaiter(this, void 0, void 0, function* () {
1336
+ var _a, _b;
1337
+ const fileInput = file || document.getElementById("file-browser");
1338
+ const subdirInput = subdir || document.getElementById("subdir");
1339
+ const banner = document.getElementById("banner");
1340
+ if (!((_a = fileInput.files) === null || _a === void 0 ? void 0 : _a.length)) {
1341
+ alert("No file selected.");
1342
+ return;
1343
+ }
1344
+ const formData = new FormData();
1345
+ formData.append("file", fileInput.files[0]);
1346
+ formData.append("subdir", subdirInput.value.trim());
1347
+ try {
1348
+ const json = yield secureFetchIt("upload", formData, "POST", null, false, true);
1349
+ banner.textContent = `Uploaded: ${json.filepath}`;
1350
+ fileInput.value = "";
1351
+ subdirInput.value = "";
1352
+ window.location.reload(); // no-op in React view
1353
+ }
1354
+ catch (err) {
1355
+ console.error("Upload failed", err);
1356
+ alert((_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : "Upload failed.");
1357
+ }
1358
+ });
1359
+ }
1360
+
1361
+ function uploadFiles(file_1) {
1362
+ return __awaiter(this, arguments, void 0, function* (file, subdir = '') {
1363
+ var _a;
1364
+ if (!(file instanceof File)) {
1365
+ throw new Error('Invalid file: Must be a File object.');
1366
+ }
1367
+ if (typeof subdir !== 'string') {
1368
+ throw new Error('Invalid subdir: Must be a string.');
1369
+ }
1370
+ const formData = new FormData();
1371
+ formData.append('file', file);
1372
+ formData.append('subdir', subdir.trim());
1373
+ try {
1374
+ const json = yield secureFetchIt('upload', formData, 'POST', null, false, true);
1375
+ if (!json || typeof json !== 'object') {
1376
+ throw new Error('Invalid response from server.');
1377
+ }
1378
+ if (!('filepath' in json) || typeof json.filepath !== 'string' || !json.filepath) {
1379
+ throw new Error('Server response missing or invalid filepath.');
1380
+ }
1381
+ return { filepath: json.filepath };
1382
+ }
1383
+ catch (err) {
1384
+ throw new Error(`Upload failed: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`);
1385
+ }
1386
+ });
1387
+ }
1388
+
1389
+ function removeFile(item) {
1390
+ return __awaiter(this, void 0, void 0, function* () {
1391
+ const token = requireToken();
1392
+ const body = item;
1393
+ const headers = {
1394
+ Authorization: `Bearer ${token}`,
1395
+ Accept: "application/octet-stream",
1396
+ "Content-Type": "application/json"
1397
+ };
1398
+ const resp = yield secureFetchIt("remove", body, "POST", headers, false, true);
1399
+ if (!resp || resp === false || (resp === null || resp === void 0 ? void 0 : resp.result) === false) {
1400
+ throw new Error(`could not delete data: “${item.filename}”`);
1401
+ }
1402
+ });
1403
+ }
1404
+
1405
+ /** Bulk download: pass a NodeList or array of checkboxes. */
1406
+ function removeSelected(checkboxes) {
1407
+ return __awaiter(this, void 0, void 0, function* () {
1408
+ const list = Array.from(checkboxes);
1409
+ if (!list.length) {
1410
+ alert("No files selected.");
1411
+ return;
1412
+ }
1413
+ for (const cb of list) {
1414
+ yield removeFile(cb);
1415
+ }
1416
+ });
1417
+ }
1418
+
1419
+ /** Given a checkbox inside a table-row → download that row’s file. */
1420
+ function removeRow(cb) {
1421
+ return __awaiter(this, void 0, void 0, function* () {
1422
+ const row = cb.closest("tr");
1423
+ alertit(row);
1424
+ if (row && (row === null || row === void 0 ? void 0 : row.id))
1425
+ yield removeFile(row);
1426
+ });
1427
+ }
1428
+
1429
+ /** GET /secure-list */
1430
+ function listFiles() {
1431
+ return __awaiter(this, arguments, void 0, function* (setFiles = null) {
1432
+ /** ← your request already returns the raw array */
1433
+ const apiRows = yield secureFetchIt("list", null, "GET", null, false, true);
1434
+ /** map API → UI ------------------------------------------------ */
1435
+ const rows = apiRows.map((r) => ({
1436
+ id: r.id,
1437
+ filename: r.filename,
1438
+ uploader_id: r.uploader_id,
1439
+ filepath: r.filepath,
1440
+ created_at: r.created_at,
1441
+ download_count: r.download_count,
1442
+ download_limit: r.download_limit,
1443
+ shareable: Boolean(r.shareable),
1444
+ needsPassword: !!r.share_password,
1445
+ share_password: r.share_password,
1446
+ }));
1447
+ setFiles(rows);
1448
+ });
1449
+ }
1450
+
1451
+ function getToggleShare(file) {
1452
+ if (file == true || (file === null || file === void 0 ? void 0 : file.shareable) == true) {
1453
+ return false;
1454
+ }
1455
+ return false;
1456
+ }
1457
+ function updateFileShare(file) {
1458
+ let updated = file;
1459
+ const boolIt = getToggleShare(updated);
1460
+ updated = Object.assign(Object.assign({}, file), { shareable: boolIt });
1461
+ return updated;
1462
+ }
1463
+ /**
1464
+ * Custom hook to toggle share settings on a file item
1465
+ */
1466
+ function toggleShare(file) {
1467
+ return __awaiter(this, void 0, void 0, function* () {
1468
+ const updated = updateFileShare(file);
1469
+ try {
1470
+ const resp = yield fetchSharePatch(updated);
1471
+ }
1472
+ catch (err) {
1473
+ console.error('Failed to toggle share settings', err);
1474
+ // Optionally revert UI state or show an error message
1475
+ }
1476
+ });
1477
+ }
1478
+
1479
+ const PROTOCOL = 'https://';
1480
+ const DOMAIN_NAME = 'abstractendeavors';
1481
+ const BASE_URL = `${PROTOCOL}${DOMAIN_NAME}.com`;
1482
+ const SUB_DIR = 'secure-files';
1483
+ const PROD_PREFIX = `/${SUB_DIR}/`;
1484
+ const API_PREFIX = `/${SUB_DIR}/api`;
1485
+ const DEV_PREFIX = `/${SUB_DIR}-dev/`;
1486
+
1487
+ function get_window() {
1488
+ try {
1489
+ if (typeof window !== 'undefined') {
1490
+ return window;
1491
+ }
1492
+ }
1493
+ catch (err) {
1494
+ alert(err);
1495
+ }
1496
+ return null;
1497
+ }
1498
+ function get_window_location() {
1499
+ try {
1500
+ const Window = get_window();
1501
+ if (!Window) {
1502
+ return BASE_URL;
1503
+ }
1504
+ return Window.location;
1505
+ }
1506
+ catch (err) {
1507
+ alert(err);
1508
+ }
1509
+ return null;
1510
+ }
1511
+ function get_window_pathname() {
1512
+ try {
1513
+ const Window = get_window();
1514
+ if (!Window) {
1515
+ return DEV_PREFIX;
1516
+ }
1517
+ return Window.location.pathname;
1518
+ }
1519
+ catch (err) {
1520
+ alert(err);
1521
+ }
1522
+ return null;
1523
+ }
1524
+ function get_window_parts() {
1525
+ try {
1526
+ return get_window_location();
1527
+ }
1528
+ catch (err) {
1529
+ alert(err);
1530
+ }
1531
+ return null;
1532
+ }
1533
+
1534
+ function Button(_a) {
1535
+ var { children, color = 'gray' } = _a, rest = __rest(_a, ["children", "color"]);
1536
+ const base = 'rounded px-3 py-1 text-sm';
1537
+ const palette = color === 'green' ? 'bg-green-600 text-white hover:bg-green-700' : 'bg-gray-200 hover:bg-gray-300';
1538
+ return jsx("button", Object.assign({ className: `${base} ${palette}` }, rest, { children: children }));
1539
+ }
1540
+
1541
+ function Checkbox(_a) {
1542
+ var { label } = _a, rest = __rest(_a, ["label"]);
1543
+ return (jsxs("label", { className: 'flex items-center gap-2 mb-4', children: [jsx("input", Object.assign({ type: 'checkbox' }, rest)), jsx("span", { children: label })] }));
1544
+ }
1545
+
1546
+ function Input(_a) {
1547
+ var { label, trailing } = _a, rest = __rest(_a, ["label", "trailing"]);
1548
+ return (jsxs("label", { className: 'mb-4 block', children: [jsx("span", { className: 'block text-sm font-medium mb-1', children: label }), jsxs("div", { className: 'flex gap-2', children: [jsx("input", Object.assign({ className: 'flex-1 rounded border px-2 py-1 disabled:bg-gray-100' }, rest)), trailing] })] }));
1549
+ }
1550
+
1551
+ function Spinner() {
1552
+ return (jsx("p", { className: 'animate-pulse', children: "Loading\u2026" }));
1553
+ }
1554
+
1555
+ /**
1556
+ * Custom hook that returns a memoized loadFiles callback
1557
+ */
1558
+ const useLoadFiles = (setLoading, setError, setFiles) => {
1559
+ return useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
1560
+ setLoading(true);
1561
+ setError(null);
1562
+ try {
1563
+ /** ← your request already returns the raw array */
1564
+ const apiRows = yield secureFetchIt("list", null, "GET", null, false, true);
1565
+ /** map API → UI ------------------------------------------------ */
1566
+ const rows = apiRows.map((r) => ({
1567
+ id: r.id,
1568
+ filename: r.filename,
1569
+ uploader_id: r.uploader_id,
1570
+ filepath: r.filepath,
1571
+ created_at: r.created_at,
1572
+ download_count: r.download_count,
1573
+ download_limit: r.download_limit,
1574
+ shareable: Boolean(r.shareable),
1575
+ needsPassword: !!r.share_password,
1576
+ share_password: r.share_password,
1577
+ }));
1578
+ setFiles(rows);
1579
+ }
1580
+ catch (err) {
1581
+ setError(err instanceof Error ? err
1582
+ : new Error("Unknown error loading files"));
1583
+ }
1584
+ finally {
1585
+ setLoading(false);
1586
+ }
1587
+ }), [setLoading, setError, setFiles]);
1588
+ };
1589
+
1590
+ /**
1591
+ * Custom hook to toggle share settings on a file item
1592
+ */
1593
+ const useToggleShare = (setFiles) => {
1594
+ return useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
1595
+ const updated = Object.assign(Object.assign({}, file), { shareable: !file.shareable });
1596
+ if (!updated.shareable) {
1597
+ updated.needsPassword = false;
1598
+ updated.share_password = null;
1599
+ updated.download_limit = null;
1600
+ }
1601
+ try {
1602
+ yield fetchSharePatch(updated);
1603
+ setFiles((curr) => curr.map((f) => (f.id === file.id ? updated : f)));
1604
+ }
1605
+ catch (err) {
1606
+ console.error('Failed to toggle share settings', err);
1607
+ // Optionally revert UI state or show an error message
1608
+ }
1609
+ }), [setFiles]);
1610
+ };
1611
+
1612
+ /**
1613
+ * Custom hook for optimistic share-setting patch updates
1614
+ */
1615
+ /**
1616
+ * Custom hook to toggle share settings on a file item
1617
+ */
1618
+ const usePatchShareSettings = (setFiles) => {
1619
+ return useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
1620
+ if (!file.shareable) {
1621
+ file.needsPassword = false;
1622
+ file.share_password = null;
1623
+ file.download_limit = null;
1624
+ }
1625
+ try {
1626
+ yield fetchSharePatch(file);
1627
+ setFiles((curr) => curr.map((f) => (f.id === file.id ? file : f)));
1628
+ }
1629
+ catch (err) {
1630
+ console.error('Failed to toggle share settings', err);
1631
+ // Optionally revert UI state or show an error message
1632
+ }
1633
+ }), [setFiles]);
1634
+ };
1635
+
1636
+ /**
1637
+ * Custom hook to toggle share settings on a file item
1638
+ */
1639
+ const useDeleteFile = (setFiles) => {
1640
+ return useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
1641
+ try {
1642
+ yield removeFile(file);
1643
+ window.location.reload();
1644
+ }
1645
+ catch (err) {
1646
+ console.error('Failed to toggle share settings', err);
1647
+ // Optionally revert UI state or show an error message
1648
+ }
1649
+ }), [setFiles]);
1650
+ };
1651
+
1652
+ function useFiles() {
1653
+ const [files, setFiles] = useState([]);
1654
+ const [loading, setLoading] = useState(false);
1655
+ const [error, setError] = useState(null);
1656
+ const loadCallback = useLoadFiles(setLoading, setError, setFiles);
1657
+ const toggleShareCallback = useToggleShare(setFiles);
1658
+ const patchShareSettingsCallback = usePatchShareSettings(setFiles);
1659
+ const deleteFileCallback = useDeleteFile(setFiles);
1660
+ useEffect(() => {
1661
+ loadCallback();
1662
+ }, [loadCallback]);
1663
+ return {
1664
+ files,
1665
+ loading,
1666
+ error,
1667
+ load: loadCallback,
1668
+ toggleShare: toggleShareCallback,
1669
+ patchShareSettings: patchShareSettingsCallback,
1670
+ deleteFile: deleteFileCallback,
1671
+ setFiles,
1672
+ setLoading,
1673
+ setError,
1674
+ };
1675
+ }
1676
+
1677
+ export { API_PREFIX, AppConfig, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, directDownload, downloadFile, downloadRow, downloadSelect, downloadSelected, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToggleShare, getToken, get_basename, get_dirname, get_extname, get_filename, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, initSelectAll, isLoggedIn, isTokenExpired, listFiles, loadConfig, make_path, make_sanitized_path, normalizeUrl, patchFileSetting, removeFile, removeRow, removeSelected, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, syncHeaderCheckbox, toggleCheckboxes, toggleShare, triggerDownload, truncateString, updateFileShare, uploadFile, uploadFiles, useDeleteFile, useFiles, useLoadFiles, usePatchShareSettings, useToggleShare };
1678
+ //# sourceMappingURL=index.js.map