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