taglib-wasm 2.2.3 → 2.3.1

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 (630) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +206 -21
  3. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/assertClassBrand.js +7 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/checkPrivateRedeclaration.js +6 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldGet2.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldInitSpec.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldSet2.js +7 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js +12 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPrimitive.js +14 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPropertyKey.js +9 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/typeof.js +11 -0
  12. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/usingCtx.js +57 -0
  13. package/dist/_virtual/_rolldown/runtime.js +13 -0
  14. package/dist/bwf/bext.d.ts.map +1 -0
  15. package/dist/bwf/bext.js +119 -0
  16. package/dist/{src/constants → constants}/additional-properties.d.ts.map +1 -1
  17. package/dist/constants/additional-properties.js +270 -0
  18. package/dist/constants/basic-properties.d.ts.map +1 -0
  19. package/dist/constants/basic-properties.js +128 -0
  20. package/dist/constants/complex-properties.d.ts.map +1 -0
  21. package/dist/constants/complex-properties.js +1 -0
  22. package/dist/constants/format-mappings.d.ts.map +1 -0
  23. package/dist/constants/format-mappings.js +58 -0
  24. package/dist/{src/constants → constants}/general-extended-properties.d.ts.map +1 -1
  25. package/dist/constants/general-extended-properties.js +272 -0
  26. package/dist/constants/index.d.ts.map +1 -0
  27. package/dist/constants/index.js +5 -0
  28. package/dist/{src/constants → constants}/properties.d.ts +1 -1
  29. package/dist/constants/properties.d.ts.map +1 -0
  30. package/dist/constants/properties.js +105 -0
  31. package/dist/constants/property-types.d.ts.map +1 -0
  32. package/dist/constants/property-types.js +1 -0
  33. package/dist/{src/constants → constants}/specialized-properties.d.ts.map +1 -1
  34. package/dist/constants/specialized-properties.js +335 -0
  35. package/dist/{src/constants → constants}/utilities.d.ts +1 -1
  36. package/dist/constants/utilities.d.ts.map +1 -0
  37. package/dist/constants/utilities.js +50 -0
  38. package/dist/constants.d.ts.map +1 -0
  39. package/dist/constants.js +5 -0
  40. package/dist/{src/deno-compile.d.ts → deno-compile.d.ts} +4 -2
  41. package/dist/deno-compile.d.ts.map +1 -0
  42. package/dist/deno-compile.js +109 -0
  43. package/dist/disc-folder.d.ts +4 -4
  44. package/dist/disc-folder.d.ts.map +1 -1
  45. package/dist/disc-folder.js +596 -544
  46. package/dist/errors/base.d.ts +38 -0
  47. package/dist/errors/base.d.ts.map +1 -0
  48. package/dist/errors/base.js +66 -0
  49. package/dist/errors/classes.d.ts.map +1 -0
  50. package/dist/errors/classes.js +164 -0
  51. package/dist/errors/guards.d.ts.map +1 -0
  52. package/dist/errors/guards.js +26 -0
  53. package/dist/errors/index.d.ts.map +1 -0
  54. package/dist/errors/index.js +4 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/errors.js +5 -0
  57. package/dist/file-utils/copy-and-find.d.ts.map +1 -0
  58. package/dist/file-utils/copy-and-find.js +107 -0
  59. package/dist/file-utils/export-operations.d.ts.map +1 -0
  60. package/dist/file-utils/export-operations.js +84 -0
  61. package/dist/file-utils/import-operations.d.ts.map +1 -0
  62. package/dist/file-utils/import-operations.js +109 -0
  63. package/dist/file-utils/index.d.ts.map +1 -0
  64. package/dist/file-utils/index.js +5 -0
  65. package/dist/file-utils/mime-detection.d.ts.map +1 -0
  66. package/dist/file-utils/mime-detection.js +44 -0
  67. package/dist/folder-api/album-corroborate.d.ts.map +1 -0
  68. package/dist/folder-api/album-corroborate.js +35 -0
  69. package/dist/folder-api/album-discs.d.ts.map +1 -0
  70. package/dist/folder-api/album-discs.js +119 -0
  71. package/dist/folder-api/album-grouping.d.ts.map +1 -0
  72. package/dist/folder-api/album-grouping.js +161 -0
  73. package/dist/folder-api/album-identity.d.ts.map +1 -0
  74. package/dist/folder-api/album-identity.js +165 -0
  75. package/dist/folder-api/album-types.d.ts.map +1 -0
  76. package/dist/folder-api/album-types.js +1 -0
  77. package/dist/folder-api/directory-walker.d.ts.map +1 -0
  78. package/dist/folder-api/directory-walker.js +27 -0
  79. package/dist/folder-api/file-processors.d.ts.map +1 -0
  80. package/dist/folder-api/file-processors.js +52 -0
  81. package/dist/folder-api/folder-disc.d.ts.map +1 -0
  82. package/dist/folder-api/folder-disc.js +166 -0
  83. package/dist/folder-api/folder-operations.d.ts.map +1 -0
  84. package/dist/folder-api/folder-operations.js +69 -0
  85. package/dist/folder-api/index.d.ts.map +1 -0
  86. package/dist/{src/folder-api → folder-api}/index.js +1 -8
  87. package/dist/folder-api/scan-for-albums.d.ts.map +1 -0
  88. package/dist/folder-api/scan-for-albums.js +25 -0
  89. package/dist/folder-api/scan-operations.d.ts.map +1 -0
  90. package/dist/folder-api/scan-operations.js +79 -0
  91. package/dist/folder-api/types.d.ts.map +1 -0
  92. package/dist/folder-api/types.js +21 -0
  93. package/dist/folder.d.ts +1 -1
  94. package/dist/folder.d.ts.map +1 -1
  95. package/dist/folder.js +7 -2
  96. package/dist/global.d.js +1 -0
  97. package/dist/index.browser.d.ts +40 -21
  98. package/dist/index.browser.d.ts.map +1 -1
  99. package/dist/index.browser.js +4194 -3656
  100. package/dist/index.d.ts +26 -25
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +40 -183
  103. package/dist/msgpack/decoder.d.ts.map +1 -0
  104. package/dist/msgpack/decoder.js +177 -0
  105. package/dist/msgpack/encoder.d.ts.map +1 -0
  106. package/dist/msgpack/encoder.js +211 -0
  107. package/dist/msgpack/index.d.ts.map +1 -0
  108. package/dist/msgpack/index.js +5 -0
  109. package/dist/{src/msgpack → msgpack}/types.d.ts +1 -1
  110. package/dist/msgpack/types.d.ts.map +1 -0
  111. package/dist/msgpack/types.js +13 -0
  112. package/dist/msgpack/utils.d.ts.map +1 -0
  113. package/dist/msgpack/utils.js +116 -0
  114. package/dist/rating.d.ts +1 -1
  115. package/dist/rating.d.ts.map +1 -1
  116. package/dist/rating.js +2 -2
  117. package/dist/runtime/deno-detect.d.ts.map +1 -0
  118. package/dist/runtime/deno-detect.js +12 -0
  119. package/dist/{src/runtime → runtime}/detector.d.ts +2 -0
  120. package/dist/runtime/detector.d.ts.map +1 -0
  121. package/dist/runtime/detector.js +173 -0
  122. package/dist/runtime/loader-types.d.ts.map +1 -0
  123. package/dist/runtime/loader-types.js +23 -0
  124. package/dist/runtime/module-loader-browser.d.ts.map +1 -0
  125. package/dist/runtime/module-loader-browser.js +33 -0
  126. package/dist/runtime/module-loader.d.ts.map +1 -0
  127. package/dist/runtime/module-loader.js +119 -0
  128. package/dist/runtime/platform-io.d.ts.map +1 -0
  129. package/dist/runtime/platform-io.js +153 -0
  130. package/dist/runtime/unified-loader/index.d.ts.map +1 -0
  131. package/dist/{src/runtime → runtime}/unified-loader/index.js +1 -7
  132. package/dist/runtime/unified-loader/loader.d.ts.map +1 -0
  133. package/dist/runtime/unified-loader/loader.js +64 -0
  134. package/dist/runtime/unified-loader/module-loading.d.ts.map +1 -0
  135. package/dist/runtime/unified-loader/module-loading.js +90 -0
  136. package/dist/runtime/unified-loader/module-selection.d.ts.map +1 -0
  137. package/dist/runtime/unified-loader/module-selection.js +25 -0
  138. package/dist/runtime/unified-loader/types.d.ts.map +1 -0
  139. package/dist/runtime/unified-loader/types.js +24 -0
  140. package/dist/{src/runtime → runtime}/wasi-adapter/adapter.d.ts +13 -1
  141. package/dist/runtime/wasi-adapter/adapter.d.ts.map +1 -0
  142. package/dist/runtime/wasi-adapter/adapter.js +114 -0
  143. package/dist/{src/runtime → runtime}/wasi-adapter/audio-properties.d.ts +4 -1
  144. package/dist/runtime/wasi-adapter/audio-properties.d.ts.map +1 -0
  145. package/dist/runtime/wasi-adapter/audio-properties.js +120 -0
  146. package/dist/runtime/wasi-adapter/file-handle.d.ts.map +1 -0
  147. package/dist/runtime/wasi-adapter/file-handle.js +181 -0
  148. package/dist/runtime/wasi-adapter/handle-state.d.ts.map +1 -0
  149. package/dist/runtime/wasi-adapter/handle-state.js +48 -0
  150. package/dist/runtime/wasi-adapter/index.d.ts.map +1 -0
  151. package/dist/{src/runtime → runtime}/wasi-adapter/index.js +1 -3
  152. package/dist/runtime/wasi-adapter/mp4-items.d.ts.map +1 -0
  153. package/dist/runtime/wasi-adapter/mp4-items.js +97 -0
  154. package/dist/runtime/wasi-adapter/path-open.d.ts +68 -0
  155. package/dist/runtime/wasi-adapter/path-open.d.ts.map +1 -0
  156. package/dist/runtime/wasi-adapter/path-open.js +101 -0
  157. package/dist/runtime/wasi-adapter/property-surface.d.ts.map +1 -0
  158. package/dist/runtime/wasi-adapter/property-surface.js +96 -0
  159. package/dist/runtime/wasi-adapter/structured-fields.d.ts.map +1 -0
  160. package/dist/runtime/wasi-adapter/structured-fields.js +144 -0
  161. package/dist/runtime/wasi-adapter/tag-keys.d.ts.map +1 -0
  162. package/dist/runtime/wasi-adapter/tag-keys.js +65 -0
  163. package/dist/runtime/wasi-adapter/wasm-io.d.ts.map +1 -0
  164. package/dist/runtime/wasi-adapter/wasm-io.js +154 -0
  165. package/dist/runtime/wasi-fs-deno.d.ts.map +1 -0
  166. package/dist/runtime/wasi-fs-deno.js +25 -0
  167. package/dist/runtime/wasi-fs-node.d.ts.map +1 -0
  168. package/dist/runtime/wasi-fs-node.js +58 -0
  169. package/dist/runtime/wasi-fs-provider.d.ts.map +1 -0
  170. package/dist/runtime/wasi-fs-provider.js +1 -0
  171. package/dist/runtime/wasi-host-loader.d.ts.map +1 -0
  172. package/dist/runtime/wasi-host-loader.js +101 -0
  173. package/dist/runtime/wasi-host.d.ts.map +1 -0
  174. package/dist/runtime/wasi-host.js +199 -0
  175. package/dist/runtime/wasi-memory.d.ts.map +1 -0
  176. package/dist/runtime/wasi-memory.js +179 -0
  177. package/dist/{src/runtime → runtime}/wasmer-sdk-loader/types.d.ts +13 -0
  178. package/dist/runtime/wasmer-sdk-loader/types.d.ts.map +1 -0
  179. package/dist/runtime/wasmer-sdk-loader/types.js +15 -0
  180. package/dist/simple/batch-operations.d.ts.map +1 -0
  181. package/dist/simple/batch-operations.js +245 -0
  182. package/dist/simple/checksum-operations.d.ts +25 -0
  183. package/dist/simple/checksum-operations.d.ts.map +1 -0
  184. package/dist/simple/checksum-operations.js +28 -0
  185. package/dist/simple/config.d.ts.map +1 -0
  186. package/dist/simple/config.js +17 -0
  187. package/dist/{src/simple → simple}/index.d.ts +2 -0
  188. package/dist/simple/index.d.ts.map +1 -0
  189. package/dist/simple/index.js +8 -0
  190. package/dist/simple/picture-operations.d.ts.map +1 -0
  191. package/dist/simple/picture-operations.js +132 -0
  192. package/dist/simple/tag-operations.d.ts.map +1 -0
  193. package/dist/simple/tag-operations.js +125 -0
  194. package/dist/simple/with-audio-file.d.ts.map +1 -0
  195. package/dist/simple/with-audio-file.js +28 -0
  196. package/dist/simple.browser.d.ts +2 -2
  197. package/dist/simple.browser.d.ts.map +1 -1
  198. package/dist/simple.browser.js +3462 -3425
  199. package/dist/simple.d.ts +1 -1
  200. package/dist/simple.d.ts.map +1 -1
  201. package/dist/simple.js +8 -2
  202. package/dist/taglib/audio-file-base.d.ts.map +1 -0
  203. package/dist/taglib/audio-file-base.js +166 -0
  204. package/dist/taglib/audio-file-bwf.d.ts.map +1 -0
  205. package/dist/taglib/audio-file-bwf.js +33 -0
  206. package/dist/taglib/audio-file-checksum.d.ts +47 -0
  207. package/dist/taglib/audio-file-checksum.d.ts.map +1 -0
  208. package/dist/taglib/audio-file-checksum.js +90 -0
  209. package/dist/{src/taglib → taglib}/audio-file-impl.d.ts +4 -0
  210. package/dist/taglib/audio-file-impl.d.ts.map +1 -0
  211. package/dist/taglib/audio-file-impl.js +234 -0
  212. package/dist/{src/taglib → taglib}/audio-file-interface.d.ts +17 -0
  213. package/dist/taglib/audio-file-interface.d.ts.map +1 -0
  214. package/dist/taglib/audio-file-interface.js +1 -0
  215. package/dist/taglib/auto-dispose.d.ts.map +1 -0
  216. package/dist/taglib/auto-dispose.js +34 -0
  217. package/dist/taglib/embind-adapter.d.ts.map +1 -0
  218. package/dist/taglib/embind-adapter.js +137 -0
  219. package/dist/taglib/extra-state-registry.d.ts.map +1 -0
  220. package/dist/taglib/extra-state-registry.js +72 -0
  221. package/dist/{src/taglib → taglib}/id3v2-frames.d.ts +0 -1
  222. package/dist/taglib/id3v2-frames.d.ts.map +1 -0
  223. package/dist/taglib/id3v2-frames.js +25 -0
  224. package/dist/taglib/index.d.ts.map +1 -0
  225. package/dist/taglib/index.js +7 -0
  226. package/dist/taglib/load-audio-data.d.ts.map +1 -0
  227. package/dist/taglib/load-audio-data.js +54 -0
  228. package/dist/taglib/media-ranges.d.ts +85 -0
  229. package/dist/taglib/media-ranges.d.ts.map +1 -0
  230. package/dist/taglib/media-ranges.js +309 -0
  231. package/dist/taglib/metadata-extent.d.ts +96 -0
  232. package/dist/taglib/metadata-extent.d.ts.map +1 -0
  233. package/dist/taglib/metadata-extent.js +394 -0
  234. package/dist/taglib/mp4-item-names.d.ts.map +1 -0
  235. package/dist/taglib/mp4-item-names.js +14 -0
  236. package/dist/taglib/mutable-tag-impl.d.ts.map +1 -0
  237. package/dist/taglib/mutable-tag-impl.js +81 -0
  238. package/dist/taglib/mutable-tag.d.ts.map +1 -0
  239. package/dist/taglib/mutable-tag.js +1 -0
  240. package/dist/taglib/save-reconstruct.d.ts.map +1 -0
  241. package/dist/taglib/save-reconstruct.js +53 -0
  242. package/dist/taglib/taglib-class.d.ts.map +1 -0
  243. package/dist/taglib/taglib-class.js +146 -0
  244. package/dist/taglib-wasi.wasm +0 -0
  245. package/dist/taglib-web.wasm +0 -0
  246. package/dist/taglib-wrapper.js +1 -1
  247. package/dist/taglib.d.ts.map +1 -0
  248. package/dist/taglib.js +7 -0
  249. package/dist/types/audio-formats.d.ts.map +1 -0
  250. package/dist/types/audio-formats.js +6 -0
  251. package/dist/types/bwf.d.ts.map +1 -0
  252. package/dist/types/bwf.js +1 -0
  253. package/dist/types/chapters.d.ts.map +1 -0
  254. package/dist/types/chapters.js +1 -0
  255. package/dist/types/config.d.ts.map +1 -0
  256. package/dist/types/config.js +1 -0
  257. package/dist/types/format-property-keys.d.ts.map +1 -0
  258. package/dist/types/format-property-keys.js +1 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/index.js +9 -0
  261. package/dist/types/metadata-mappings.d.ts.map +1 -0
  262. package/dist/types/metadata-mappings.js +323 -0
  263. package/dist/types/pictures.d.ts.map +1 -0
  264. package/dist/types/pictures.js +79 -0
  265. package/dist/types/tags.d.ts.map +1 -0
  266. package/dist/types/tags.js +1 -0
  267. package/dist/types.d.ts.map +1 -0
  268. package/dist/types.js +5 -0
  269. package/dist/utils/file.d.ts.map +1 -0
  270. package/dist/utils/file.js +43 -0
  271. package/dist/utils/mirror-fields.d.ts.map +1 -0
  272. package/dist/utils/mirror-fields.js +107 -0
  273. package/dist/utils/node-fs.d.ts.map +1 -0
  274. package/dist/utils/node-fs.js +36 -0
  275. package/dist/utils/path.d.ts +26 -0
  276. package/dist/utils/path.d.ts.map +1 -0
  277. package/dist/utils/path.js +52 -0
  278. package/dist/utils/rating.d.ts.map +1 -0
  279. package/dist/utils/rating.js +150 -0
  280. package/dist/utils/tag-mapping.d.ts.map +1 -0
  281. package/dist/utils/tag-mapping.js +207 -0
  282. package/dist/utils/write.d.ts.map +1 -0
  283. package/dist/utils/write.js +18 -0
  284. package/dist/version.d.ts +2 -0
  285. package/dist/version.d.ts.map +1 -0
  286. package/dist/version.js +4 -0
  287. package/dist/{src/wasm.d.ts → wasm.d.ts} +9 -0
  288. package/dist/wasm.d.ts.map +1 -0
  289. package/dist/wasm.js +1 -0
  290. package/dist/web-utils/canvas.d.ts.map +1 -0
  291. package/dist/web-utils/canvas.js +97 -0
  292. package/dist/web-utils/data-url.d.ts.map +1 -0
  293. package/dist/web-utils/data-url.js +54 -0
  294. package/dist/web-utils/dom-integration.d.ts.map +1 -0
  295. package/dist/web-utils/dom-integration.js +105 -0
  296. package/dist/web-utils/index.d.ts.map +1 -0
  297. package/dist/web-utils/index.js +4 -0
  298. package/dist/web.browser.d.ts +13 -0
  299. package/dist/web.browser.d.ts.map +1 -0
  300. package/dist/web.browser.js +3387 -0
  301. package/dist/web.d.ts +1 -1
  302. package/dist/web.d.ts.map +1 -1
  303. package/dist/web.js +5 -2
  304. package/package.json +140 -97
  305. package/dist/src/bwf/bext.d.ts.map +0 -1
  306. package/dist/src/bwf/bext.js +0 -126
  307. package/dist/src/constants/additional-properties.js +0 -204
  308. package/dist/src/constants/basic-properties.d.ts.map +0 -1
  309. package/dist/src/constants/basic-properties.js +0 -89
  310. package/dist/src/constants/complex-properties.d.ts.map +0 -1
  311. package/dist/src/constants/complex-properties.js +0 -0
  312. package/dist/src/constants/format-mappings.d.ts.map +0 -1
  313. package/dist/src/constants/format-mappings.js +0 -54
  314. package/dist/src/constants/general-extended-properties.js +0 -254
  315. package/dist/src/constants/index.d.ts.map +0 -1
  316. package/dist/src/constants/index.js +0 -4
  317. package/dist/src/constants/properties.d.ts.map +0 -1
  318. package/dist/src/constants/properties.js +0 -95
  319. package/dist/src/constants/property-types.d.ts.map +0 -1
  320. package/dist/src/constants/property-types.js +0 -0
  321. package/dist/src/constants/specialized-properties.js +0 -223
  322. package/dist/src/constants/utilities.d.ts.map +0 -1
  323. package/dist/src/constants/utilities.js +0 -33
  324. package/dist/src/constants.d.ts.map +0 -1
  325. package/dist/src/constants.js +0 -1
  326. package/dist/src/deno-compile.d.ts.map +0 -1
  327. package/dist/src/deno-compile.js +0 -75
  328. package/dist/src/errors/base.d.ts +0 -23
  329. package/dist/src/errors/base.d.ts.map +0 -1
  330. package/dist/src/errors/base.js +0 -31
  331. package/dist/src/errors/classes.d.ts.map +0 -1
  332. package/dist/src/errors/classes.js +0 -170
  333. package/dist/src/errors/guards.d.ts.map +0 -1
  334. package/dist/src/errors/guards.js +0 -39
  335. package/dist/src/errors/index.d.ts.map +0 -1
  336. package/dist/src/errors/index.js +0 -39
  337. package/dist/src/errors.d.ts.map +0 -1
  338. package/dist/src/errors.js +0 -1
  339. package/dist/src/file-utils/copy-and-find.d.ts.map +0 -1
  340. package/dist/src/file-utils/copy-and-find.js +0 -89
  341. package/dist/src/file-utils/export-operations.d.ts.map +0 -1
  342. package/dist/src/file-utils/export-operations.js +0 -40
  343. package/dist/src/file-utils/import-operations.d.ts.map +0 -1
  344. package/dist/src/file-utils/import-operations.js +0 -42
  345. package/dist/src/file-utils/index.d.ts.map +0 -1
  346. package/dist/src/file-utils/index.js +0 -26
  347. package/dist/src/file-utils/mime-detection.d.ts.map +0 -1
  348. package/dist/src/file-utils/mime-detection.js +0 -45
  349. package/dist/src/folder-api/album-corroborate.d.ts.map +0 -1
  350. package/dist/src/folder-api/album-corroborate.js +0 -36
  351. package/dist/src/folder-api/album-discs.d.ts.map +0 -1
  352. package/dist/src/folder-api/album-discs.js +0 -122
  353. package/dist/src/folder-api/album-grouping.d.ts.map +0 -1
  354. package/dist/src/folder-api/album-grouping.js +0 -118
  355. package/dist/src/folder-api/album-identity.d.ts.map +0 -1
  356. package/dist/src/folder-api/album-identity.js +0 -151
  357. package/dist/src/folder-api/album-types.d.ts.map +0 -1
  358. package/dist/src/folder-api/album-types.js +0 -0
  359. package/dist/src/folder-api/directory-walker.d.ts.map +0 -1
  360. package/dist/src/folder-api/directory-walker.js +0 -35
  361. package/dist/src/folder-api/file-processors.d.ts.map +0 -1
  362. package/dist/src/folder-api/file-processors.js +0 -63
  363. package/dist/src/folder-api/folder-disc.d.ts.map +0 -1
  364. package/dist/src/folder-api/folder-disc.js +0 -169
  365. package/dist/src/folder-api/folder-operations.d.ts.map +0 -1
  366. package/dist/src/folder-api/folder-operations.js +0 -54
  367. package/dist/src/folder-api/index.d.ts.map +0 -1
  368. package/dist/src/folder-api/scan-for-albums.d.ts.map +0 -1
  369. package/dist/src/folder-api/scan-for-albums.js +0 -20
  370. package/dist/src/folder-api/scan-operations.d.ts.map +0 -1
  371. package/dist/src/folder-api/scan-operations.js +0 -77
  372. package/dist/src/folder-api/types.d.ts.map +0 -1
  373. package/dist/src/folder-api/types.js +0 -21
  374. package/dist/src/msgpack/decoder.d.ts.map +0 -1
  375. package/dist/src/msgpack/decoder.js +0 -215
  376. package/dist/src/msgpack/encoder.d.ts.map +0 -1
  377. package/dist/src/msgpack/encoder.js +0 -249
  378. package/dist/src/msgpack/index.d.ts.map +0 -1
  379. package/dist/src/msgpack/index.js +0 -56
  380. package/dist/src/msgpack/types.d.ts.map +0 -1
  381. package/dist/src/msgpack/types.js +0 -12
  382. package/dist/src/msgpack/utils.d.ts.map +0 -1
  383. package/dist/src/msgpack/utils.js +0 -134
  384. package/dist/src/runtime/deno-detect.d.ts.map +0 -1
  385. package/dist/src/runtime/deno-detect.js +0 -6
  386. package/dist/src/runtime/detector.d.ts.map +0 -1
  387. package/dist/src/runtime/detector.js +0 -181
  388. package/dist/src/runtime/loader-types.d.ts.map +0 -1
  389. package/dist/src/runtime/loader-types.js +0 -10
  390. package/dist/src/runtime/module-loader-browser.d.ts.map +0 -1
  391. package/dist/src/runtime/module-loader-browser.js +0 -37
  392. package/dist/src/runtime/module-loader.d.ts.map +0 -1
  393. package/dist/src/runtime/module-loader.js +0 -119
  394. package/dist/src/runtime/platform-io.d.ts.map +0 -1
  395. package/dist/src/runtime/platform-io.js +0 -188
  396. package/dist/src/runtime/unified-loader/index.d.ts.map +0 -1
  397. package/dist/src/runtime/unified-loader/loader.d.ts.map +0 -1
  398. package/dist/src/runtime/unified-loader/loader.js +0 -84
  399. package/dist/src/runtime/unified-loader/module-loading.d.ts.map +0 -1
  400. package/dist/src/runtime/unified-loader/module-loading.js +0 -122
  401. package/dist/src/runtime/unified-loader/module-selection.d.ts.map +0 -1
  402. package/dist/src/runtime/unified-loader/module-selection.js +0 -41
  403. package/dist/src/runtime/unified-loader/types.d.ts.map +0 -1
  404. package/dist/src/runtime/unified-loader/types.js +0 -25
  405. package/dist/src/runtime/wasi-adapter/adapter.d.ts.map +0 -1
  406. package/dist/src/runtime/wasi-adapter/adapter.js +0 -113
  407. package/dist/src/runtime/wasi-adapter/audio-properties.d.ts.map +0 -1
  408. package/dist/src/runtime/wasi-adapter/audio-properties.js +0 -85
  409. package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +0 -1
  410. package/dist/src/runtime/wasi-adapter/file-handle.js +0 -197
  411. package/dist/src/runtime/wasi-adapter/handle-state.d.ts.map +0 -1
  412. package/dist/src/runtime/wasi-adapter/handle-state.js +0 -58
  413. package/dist/src/runtime/wasi-adapter/index.d.ts.map +0 -1
  414. package/dist/src/runtime/wasi-adapter/mp4-items.d.ts.map +0 -1
  415. package/dist/src/runtime/wasi-adapter/mp4-items.js +0 -80
  416. package/dist/src/runtime/wasi-adapter/property-surface.d.ts.map +0 -1
  417. package/dist/src/runtime/wasi-adapter/property-surface.js +0 -104
  418. package/dist/src/runtime/wasi-adapter/structured-fields.d.ts.map +0 -1
  419. package/dist/src/runtime/wasi-adapter/structured-fields.js +0 -139
  420. package/dist/src/runtime/wasi-adapter/tag-keys.d.ts.map +0 -1
  421. package/dist/src/runtime/wasi-adapter/tag-keys.js +0 -46
  422. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +0 -1
  423. package/dist/src/runtime/wasi-adapter/wasm-io.js +0 -249
  424. package/dist/src/runtime/wasi-fs-deno.d.ts.map +0 -1
  425. package/dist/src/runtime/wasi-fs-deno.js +0 -26
  426. package/dist/src/runtime/wasi-fs-node.d.ts.map +0 -1
  427. package/dist/src/runtime/wasi-fs-node.js +0 -66
  428. package/dist/src/runtime/wasi-fs-provider.d.ts.map +0 -1
  429. package/dist/src/runtime/wasi-fs-provider.js +0 -0
  430. package/dist/src/runtime/wasi-host-loader.d.ts.map +0 -1
  431. package/dist/src/runtime/wasi-host-loader.js +0 -109
  432. package/dist/src/runtime/wasi-host.d.ts.map +0 -1
  433. package/dist/src/runtime/wasi-host.js +0 -202
  434. package/dist/src/runtime/wasi-memory.d.ts.map +0 -1
  435. package/dist/src/runtime/wasi-memory.js +0 -197
  436. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +0 -1
  437. package/dist/src/runtime/wasmer-sdk-loader/types.js +0 -12
  438. package/dist/src/simple/batch-operations.d.ts.map +0 -1
  439. package/dist/src/simple/batch-operations.js +0 -186
  440. package/dist/src/simple/config.d.ts.map +0 -1
  441. package/dist/src/simple/config.js +0 -18
  442. package/dist/src/simple/index.d.ts.map +0 -1
  443. package/dist/src/simple/index.js +0 -58
  444. package/dist/src/simple/picture-operations.d.ts.map +0 -1
  445. package/dist/src/simple/picture-operations.js +0 -68
  446. package/dist/src/simple/tag-operations.d.ts.map +0 -1
  447. package/dist/src/simple/tag-operations.js +0 -90
  448. package/dist/src/simple/with-audio-file.d.ts.map +0 -1
  449. package/dist/src/simple/with-audio-file.js +0 -39
  450. package/dist/src/taglib/audio-file-base.d.ts.map +0 -1
  451. package/dist/src/taglib/audio-file-base.js +0 -187
  452. package/dist/src/taglib/audio-file-bwf.d.ts.map +0 -1
  453. package/dist/src/taglib/audio-file-bwf.js +0 -41
  454. package/dist/src/taglib/audio-file-impl.d.ts.map +0 -1
  455. package/dist/src/taglib/audio-file-impl.js +0 -285
  456. package/dist/src/taglib/audio-file-interface.d.ts.map +0 -1
  457. package/dist/src/taglib/audio-file-interface.js +0 -0
  458. package/dist/src/taglib/auto-dispose.d.ts.map +0 -1
  459. package/dist/src/taglib/auto-dispose.js +0 -13
  460. package/dist/src/taglib/embind-adapter.d.ts.map +0 -1
  461. package/dist/src/taglib/embind-adapter.js +0 -141
  462. package/dist/src/taglib/extra-state-registry.d.ts.map +0 -1
  463. package/dist/src/taglib/extra-state-registry.js +0 -78
  464. package/dist/src/taglib/id3v2-frames.d.ts.map +0 -1
  465. package/dist/src/taglib/id3v2-frames.js +0 -42
  466. package/dist/src/taglib/index.d.ts.map +0 -1
  467. package/dist/src/taglib/index.js +0 -41
  468. package/dist/src/taglib/load-audio-data.d.ts.map +0 -1
  469. package/dist/src/taglib/load-audio-data.js +0 -51
  470. package/dist/src/taglib/metadata-extent.d.ts +0 -41
  471. package/dist/src/taglib/metadata-extent.d.ts.map +0 -1
  472. package/dist/src/taglib/metadata-extent.js +0 -171
  473. package/dist/src/taglib/mp4-item-names.d.ts.map +0 -1
  474. package/dist/src/taglib/mp4-item-names.js +0 -4
  475. package/dist/src/taglib/mutable-tag-impl.d.ts.map +0 -1
  476. package/dist/src/taglib/mutable-tag-impl.js +0 -88
  477. package/dist/src/taglib/mutable-tag.d.ts.map +0 -1
  478. package/dist/src/taglib/mutable-tag.js +0 -0
  479. package/dist/src/taglib/save-reconstruct.d.ts.map +0 -1
  480. package/dist/src/taglib/save-reconstruct.js +0 -43
  481. package/dist/src/taglib/taglib-class.d.ts.map +0 -1
  482. package/dist/src/taglib/taglib-class.js +0 -206
  483. package/dist/src/taglib.d.ts.map +0 -1
  484. package/dist/src/taglib.js +0 -1
  485. package/dist/src/types/audio-formats.d.ts.map +0 -1
  486. package/dist/src/types/audio-formats.js +0 -6
  487. package/dist/src/types/bwf.d.ts.map +0 -1
  488. package/dist/src/types/bwf.js +0 -0
  489. package/dist/src/types/chapters.d.ts.map +0 -1
  490. package/dist/src/types/chapters.js +0 -0
  491. package/dist/src/types/config.d.ts.map +0 -1
  492. package/dist/src/types/config.js +0 -0
  493. package/dist/src/types/format-property-keys.d.ts.map +0 -1
  494. package/dist/src/types/format-property-keys.js +0 -0
  495. package/dist/src/types/index.d.ts.map +0 -1
  496. package/dist/src/types/index.js +0 -8
  497. package/dist/src/types/metadata-mappings.d.ts.map +0 -1
  498. package/dist/src/types/metadata-mappings.js +0 -252
  499. package/dist/src/types/pictures.d.ts.map +0 -1
  500. package/dist/src/types/pictures.js +0 -64
  501. package/dist/src/types/tags.d.ts.map +0 -1
  502. package/dist/src/types/tags.js +0 -0
  503. package/dist/src/types.d.ts.map +0 -1
  504. package/dist/src/types.js +0 -1
  505. package/dist/src/utils/file.d.ts.map +0 -1
  506. package/dist/src/utils/file.js +0 -52
  507. package/dist/src/utils/mirror-fields.d.ts.map +0 -1
  508. package/dist/src/utils/mirror-fields.js +0 -75
  509. package/dist/src/utils/node-fs.d.ts.map +0 -1
  510. package/dist/src/utils/node-fs.js +0 -22
  511. package/dist/src/utils/path.d.ts +0 -14
  512. package/dist/src/utils/path.d.ts.map +0 -1
  513. package/dist/src/utils/path.js +0 -17
  514. package/dist/src/utils/rating.d.ts.map +0 -1
  515. package/dist/src/utils/rating.js +0 -73
  516. package/dist/src/utils/tag-mapping.d.ts.map +0 -1
  517. package/dist/src/utils/tag-mapping.js +0 -214
  518. package/dist/src/utils/write.d.ts.map +0 -1
  519. package/dist/src/utils/write.js +0 -17
  520. package/dist/src/version.d.ts +0 -2
  521. package/dist/src/version.d.ts.map +0 -1
  522. package/dist/src/version.js +0 -4
  523. package/dist/src/wasm.d.ts.map +0 -1
  524. package/dist/src/wasm.js +0 -0
  525. package/dist/src/web-utils/canvas.d.ts.map +0 -1
  526. package/dist/src/web-utils/canvas.js +0 -60
  527. package/dist/src/web-utils/data-url.d.ts.map +0 -1
  528. package/dist/src/web-utils/data-url.js +0 -34
  529. package/dist/src/web-utils/dom-integration.d.ts.map +0 -1
  530. package/dist/src/web-utils/dom-integration.js +0 -53
  531. package/dist/src/web-utils/index.d.ts.map +0 -1
  532. package/dist/src/web-utils/index.js +0 -21
  533. /package/dist/{src/bwf → bwf}/bext.d.ts +0 -0
  534. /package/dist/{src/constants → constants}/additional-properties.d.ts +0 -0
  535. /package/dist/{src/constants → constants}/basic-properties.d.ts +0 -0
  536. /package/dist/{src/constants → constants}/complex-properties.d.ts +0 -0
  537. /package/dist/{src/constants → constants}/format-mappings.d.ts +0 -0
  538. /package/dist/{src/constants → constants}/general-extended-properties.d.ts +0 -0
  539. /package/dist/{src/constants → constants}/index.d.ts +0 -0
  540. /package/dist/{src/constants → constants}/property-types.d.ts +0 -0
  541. /package/dist/{src/constants → constants}/specialized-properties.d.ts +0 -0
  542. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  543. /package/dist/{src/errors → errors}/classes.d.ts +0 -0
  544. /package/dist/{src/errors → errors}/guards.d.ts +0 -0
  545. /package/dist/{src/errors → errors}/index.d.ts +0 -0
  546. /package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
  547. /package/dist/{src/file-utils → file-utils}/copy-and-find.d.ts +0 -0
  548. /package/dist/{src/file-utils → file-utils}/export-operations.d.ts +0 -0
  549. /package/dist/{src/file-utils → file-utils}/import-operations.d.ts +0 -0
  550. /package/dist/{src/file-utils → file-utils}/index.d.ts +0 -0
  551. /package/dist/{src/file-utils → file-utils}/mime-detection.d.ts +0 -0
  552. /package/dist/{src/folder-api → folder-api}/album-corroborate.d.ts +0 -0
  553. /package/dist/{src/folder-api → folder-api}/album-discs.d.ts +0 -0
  554. /package/dist/{src/folder-api → folder-api}/album-grouping.d.ts +0 -0
  555. /package/dist/{src/folder-api → folder-api}/album-identity.d.ts +0 -0
  556. /package/dist/{src/folder-api → folder-api}/album-types.d.ts +0 -0
  557. /package/dist/{src/folder-api → folder-api}/directory-walker.d.ts +0 -0
  558. /package/dist/{src/folder-api → folder-api}/file-processors.d.ts +0 -0
  559. /package/dist/{src/folder-api → folder-api}/folder-disc.d.ts +0 -0
  560. /package/dist/{src/folder-api → folder-api}/folder-operations.d.ts +0 -0
  561. /package/dist/{src/folder-api → folder-api}/index.d.ts +0 -0
  562. /package/dist/{src/folder-api → folder-api}/scan-for-albums.d.ts +0 -0
  563. /package/dist/{src/folder-api → folder-api}/scan-operations.d.ts +0 -0
  564. /package/dist/{src/folder-api → folder-api}/types.d.ts +0 -0
  565. /package/dist/{src/msgpack → msgpack}/decoder.d.ts +0 -0
  566. /package/dist/{src/msgpack → msgpack}/encoder.d.ts +0 -0
  567. /package/dist/{src/msgpack → msgpack}/index.d.ts +0 -0
  568. /package/dist/{src/msgpack → msgpack}/utils.d.ts +0 -0
  569. /package/dist/{src/runtime → runtime}/deno-detect.d.ts +0 -0
  570. /package/dist/{src/runtime → runtime}/loader-types.d.ts +0 -0
  571. /package/dist/{src/runtime → runtime}/module-loader-browser.d.ts +0 -0
  572. /package/dist/{src/runtime → runtime}/module-loader.d.ts +0 -0
  573. /package/dist/{src/runtime → runtime}/platform-io.d.ts +0 -0
  574. /package/dist/{src/runtime → runtime}/unified-loader/index.d.ts +0 -0
  575. /package/dist/{src/runtime → runtime}/unified-loader/loader.d.ts +0 -0
  576. /package/dist/{src/runtime → runtime}/unified-loader/module-loading.d.ts +0 -0
  577. /package/dist/{src/runtime → runtime}/unified-loader/module-selection.d.ts +0 -0
  578. /package/dist/{src/runtime → runtime}/unified-loader/types.d.ts +0 -0
  579. /package/dist/{src/runtime → runtime}/wasi-adapter/file-handle.d.ts +0 -0
  580. /package/dist/{src/runtime → runtime}/wasi-adapter/handle-state.d.ts +0 -0
  581. /package/dist/{src/runtime → runtime}/wasi-adapter/index.d.ts +0 -0
  582. /package/dist/{src/runtime → runtime}/wasi-adapter/mp4-items.d.ts +0 -0
  583. /package/dist/{src/runtime → runtime}/wasi-adapter/property-surface.d.ts +0 -0
  584. /package/dist/{src/runtime → runtime}/wasi-adapter/structured-fields.d.ts +0 -0
  585. /package/dist/{src/runtime → runtime}/wasi-adapter/tag-keys.d.ts +0 -0
  586. /package/dist/{src/runtime → runtime}/wasi-adapter/wasm-io.d.ts +0 -0
  587. /package/dist/{src/runtime → runtime}/wasi-fs-deno.d.ts +0 -0
  588. /package/dist/{src/runtime → runtime}/wasi-fs-node.d.ts +0 -0
  589. /package/dist/{src/runtime → runtime}/wasi-fs-provider.d.ts +0 -0
  590. /package/dist/{src/runtime → runtime}/wasi-host-loader.d.ts +0 -0
  591. /package/dist/{src/runtime → runtime}/wasi-host.d.ts +0 -0
  592. /package/dist/{src/runtime → runtime}/wasi-memory.d.ts +0 -0
  593. /package/dist/{src/simple → simple}/batch-operations.d.ts +0 -0
  594. /package/dist/{src/simple → simple}/config.d.ts +0 -0
  595. /package/dist/{src/simple → simple}/picture-operations.d.ts +0 -0
  596. /package/dist/{src/simple → simple}/tag-operations.d.ts +0 -0
  597. /package/dist/{src/simple → simple}/with-audio-file.d.ts +0 -0
  598. /package/dist/{src/taglib → taglib}/audio-file-base.d.ts +0 -0
  599. /package/dist/{src/taglib → taglib}/audio-file-bwf.d.ts +0 -0
  600. /package/dist/{src/taglib → taglib}/auto-dispose.d.ts +0 -0
  601. /package/dist/{src/taglib → taglib}/embind-adapter.d.ts +0 -0
  602. /package/dist/{src/taglib → taglib}/extra-state-registry.d.ts +0 -0
  603. /package/dist/{src/taglib → taglib}/index.d.ts +0 -0
  604. /package/dist/{src/taglib → taglib}/load-audio-data.d.ts +0 -0
  605. /package/dist/{src/taglib → taglib}/mp4-item-names.d.ts +0 -0
  606. /package/dist/{src/taglib → taglib}/mutable-tag-impl.d.ts +0 -0
  607. /package/dist/{src/taglib → taglib}/mutable-tag.d.ts +0 -0
  608. /package/dist/{src/taglib → taglib}/save-reconstruct.d.ts +0 -0
  609. /package/dist/{src/taglib → taglib}/taglib-class.d.ts +0 -0
  610. /package/dist/{src/taglib.d.ts → taglib.d.ts} +0 -0
  611. /package/dist/{src/types → types}/audio-formats.d.ts +0 -0
  612. /package/dist/{src/types → types}/bwf.d.ts +0 -0
  613. /package/dist/{src/types → types}/chapters.d.ts +0 -0
  614. /package/dist/{src/types → types}/config.d.ts +0 -0
  615. /package/dist/{src/types → types}/format-property-keys.d.ts +0 -0
  616. /package/dist/{src/types → types}/index.d.ts +0 -0
  617. /package/dist/{src/types → types}/metadata-mappings.d.ts +0 -0
  618. /package/dist/{src/types → types}/pictures.d.ts +0 -0
  619. /package/dist/{src/types → types}/tags.d.ts +0 -0
  620. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  621. /package/dist/{src/utils → utils}/file.d.ts +0 -0
  622. /package/dist/{src/utils → utils}/mirror-fields.d.ts +0 -0
  623. /package/dist/{src/utils → utils}/node-fs.d.ts +0 -0
  624. /package/dist/{src/utils → utils}/rating.d.ts +0 -0
  625. /package/dist/{src/utils → utils}/tag-mapping.d.ts +0 -0
  626. /package/dist/{src/utils → utils}/write.d.ts +0 -0
  627. /package/dist/{src/web-utils → web-utils}/canvas.d.ts +0 -0
  628. /package/dist/{src/web-utils → web-utils}/data-url.d.ts +0 -0
  629. /package/dist/{src/web-utils → web-utils}/dom-integration.d.ts +0 -0
  630. /package/dist/{src/web-utils → web-utils}/index.d.ts +0 -0
@@ -0,0 +1,3387 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __esmMin = (fn, res, err) => () => {
4
+ if (err) throw err[0];
5
+ try {
6
+ return fn && (res = fn(fn = 0)), res;
7
+ } catch (e) {
8
+ throw err = [e], e;
9
+ }
10
+ };
11
+ var __exportAll = (all, no_symbols) => {
12
+ let target = {};
13
+ for (var name in all) __defProp(target, name, {
14
+ get: all[name],
15
+ enumerable: true
16
+ });
17
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ return target;
19
+ };
20
+ //#endregion
21
+ //#region src/errors/base.ts
22
+ var SUPPORTED_FORMATS, TagLibError;
23
+ var init_base = __esmMin((() => {
24
+ SUPPORTED_FORMATS = [
25
+ "MP3",
26
+ "AAC",
27
+ "MP4",
28
+ "M4A",
29
+ "FLAC",
30
+ "OGG",
31
+ "OPUS",
32
+ "OggFLAC",
33
+ "SPEEX",
34
+ "WAV",
35
+ "AIFF",
36
+ "ASF",
37
+ "APE",
38
+ "DSF",
39
+ "DSDIFF",
40
+ "WV",
41
+ "MPC",
42
+ "TTA",
43
+ "SHN",
44
+ "MOD",
45
+ "S3M",
46
+ "IT",
47
+ "XM",
48
+ "MATROSKA",
49
+ "MKA"
50
+ ];
51
+ TagLibError = class TagLibError extends Error {
52
+ constructor(code, message, details) {
53
+ super(message);
54
+ this.code = code;
55
+ this.details = details;
56
+ this.name = "TagLibError";
57
+ Object.setPrototypeOf(this, TagLibError.prototype);
58
+ }
59
+ };
60
+ }));
61
+ //#endregion
62
+ //#region src/errors/classes.ts
63
+ function errorMessage(error) {
64
+ return error instanceof Error ? error.message : String(error);
65
+ }
66
+ function createErrorMessage(prefix, details) {
67
+ return `${prefix}: ${details}`;
68
+ }
69
+ function formatFileSize(bytes) {
70
+ if (bytes < 1024) return `${bytes} bytes`;
71
+ if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
72
+ return `${(bytes / 1048576).toFixed(1)} MB`;
73
+ }
74
+ var TagLibInitializationError, InvalidFormatError, UnsupportedFormatError, FileOperationError, MetadataError, MemoryError, EnvironmentError;
75
+ var init_classes = __esmMin((() => {
76
+ init_base();
77
+ TagLibInitializationError = class TagLibInitializationError extends TagLibError {
78
+ constructor(message, details) {
79
+ super("INITIALIZATION", createErrorMessage("Failed to initialize TagLib Wasm module", message), details);
80
+ this.name = "TagLibInitializationError";
81
+ Object.setPrototypeOf(this, TagLibInitializationError.prototype);
82
+ }
83
+ };
84
+ InvalidFormatError = class InvalidFormatError extends TagLibError {
85
+ constructor(message, bufferSize, details) {
86
+ const errorDetails = [`Invalid audio file format: ${message}`];
87
+ if (bufferSize !== void 0) {
88
+ errorDetails.push(`Buffer size: ${formatFileSize(bufferSize)}`);
89
+ if (bufferSize < 1024) errorDetails.push("Audio files must be at least 1KB to contain valid headers.");
90
+ }
91
+ super("INVALID_FORMAT", errorDetails.join(". "), {
92
+ ...details,
93
+ bufferSize
94
+ });
95
+ this.bufferSize = bufferSize;
96
+ this.name = "InvalidFormatError";
97
+ Object.setPrototypeOf(this, InvalidFormatError.prototype);
98
+ }
99
+ };
100
+ UnsupportedFormatError = class UnsupportedFormatError extends TagLibError {
101
+ constructor(format, supportedFormats = SUPPORTED_FORMATS, details) {
102
+ super("UNSUPPORTED_FORMAT", `Unsupported audio format: ${format}. Supported formats: ${supportedFormats.join(", ")}`, {
103
+ ...details,
104
+ format,
105
+ supportedFormats
106
+ });
107
+ this.format = format;
108
+ this.supportedFormats = supportedFormats;
109
+ this.name = "UnsupportedFormatError";
110
+ Object.setPrototypeOf(this, UnsupportedFormatError.prototype);
111
+ }
112
+ };
113
+ FileOperationError = class FileOperationError extends TagLibError {
114
+ constructor(operation, message, path, details) {
115
+ const errorDetails = [`Failed to ${operation} file`];
116
+ if (path) errorDetails.push(`Path: ${path}`);
117
+ errorDetails.push(message);
118
+ super("FILE_OPERATION", errorDetails.join(". "), {
119
+ ...details,
120
+ operation,
121
+ path
122
+ });
123
+ this.operation = operation;
124
+ this.path = path;
125
+ this.name = "FileOperationError";
126
+ Object.setPrototypeOf(this, FileOperationError.prototype);
127
+ }
128
+ };
129
+ MetadataError = class MetadataError extends TagLibError {
130
+ constructor(operation, message, field, details) {
131
+ const errorDetails = [`Failed to ${operation} metadata`];
132
+ if (field) errorDetails.push(`Field: ${field}`);
133
+ errorDetails.push(message);
134
+ super("METADATA", errorDetails.join(". "), {
135
+ ...details,
136
+ operation,
137
+ field
138
+ });
139
+ this.operation = operation;
140
+ this.field = field;
141
+ this.name = "MetadataError";
142
+ Object.setPrototypeOf(this, MetadataError.prototype);
143
+ }
144
+ };
145
+ MemoryError = class MemoryError extends TagLibError {
146
+ constructor(message, details) {
147
+ super("MEMORY", createErrorMessage("Memory allocation failed", message), details);
148
+ this.name = "MemoryError";
149
+ Object.setPrototypeOf(this, MemoryError.prototype);
150
+ }
151
+ };
152
+ EnvironmentError = class EnvironmentError extends TagLibError {
153
+ constructor(environment, reason, requiredFeature) {
154
+ const message = requiredFeature ? `Environment '${environment}' ${reason}. Required feature: ${requiredFeature}.` : `Environment '${environment}' ${reason}.`;
155
+ super("ENVIRONMENT", message);
156
+ this.environment = environment;
157
+ this.reason = reason;
158
+ this.requiredFeature = requiredFeature;
159
+ this.name = "EnvironmentError";
160
+ Object.setPrototypeOf(this, EnvironmentError.prototype);
161
+ }
162
+ };
163
+ }));
164
+ //#endregion
165
+ //#region src/web-utils/data-url.ts
166
+ init_classes();
167
+ function pictureToDataURL(picture) {
168
+ const data = picture.data;
169
+ const CHUNK = 32768;
170
+ let binary = "";
171
+ for (let i = 0; i < data.length; i += CHUNK) binary += String.fromCharCode(...data.subarray(i, i + CHUNK));
172
+ const base64 = btoa(binary);
173
+ return `data:${picture.mimeType};base64,${base64}`;
174
+ }
175
+ function dataURLToPicture(dataURL, type = "FrontCover", description) {
176
+ const matches = /^data:([^;]+);base64,(.+)$/.exec(dataURL);
177
+ if (!matches) throw new InvalidFormatError("Invalid data URL format");
178
+ const [, mimeType, base64] = matches;
179
+ const binaryString = atob(base64);
180
+ const data = new Uint8Array(binaryString.length);
181
+ for (let i = 0; i < binaryString.length; i++) data[i] = binaryString.codePointAt(i);
182
+ return {
183
+ mimeType,
184
+ data,
185
+ type,
186
+ ...description !== void 0 ? { description } : {}
187
+ };
188
+ }
189
+ //#endregion
190
+ //#region src/types/audio-formats.ts
191
+ function isNamedAudioInput(input) {
192
+ return typeof input === "object" && input !== null && "name" in input && "data" in input && !(input instanceof File) && !(input instanceof Uint8Array) && !(input instanceof ArrayBuffer);
193
+ }
194
+ var init_audio_formats = __esmMin((() => {}));
195
+ //#endregion
196
+ //#region src/types/tags.ts
197
+ var init_tags = __esmMin((() => {}));
198
+ //#endregion
199
+ //#region src/types/metadata-mappings.ts
200
+ var init_metadata_mappings = __esmMin((() => {}));
201
+ //#endregion
202
+ //#region src/types/pictures.ts
203
+ var PICTURE_TYPE_VALUES, PICTURE_TYPE_NAMES;
204
+ var init_pictures = __esmMin((() => {
205
+ PICTURE_TYPE_VALUES = {
206
+ Other: 0,
207
+ FileIcon: 1,
208
+ OtherFileIcon: 2,
209
+ FrontCover: 3,
210
+ BackCover: 4,
211
+ LeafletPage: 5,
212
+ Media: 6,
213
+ LeadArtist: 7,
214
+ Artist: 8,
215
+ Conductor: 9,
216
+ Band: 10,
217
+ Composer: 11,
218
+ Lyricist: 12,
219
+ RecordingLocation: 13,
220
+ DuringRecording: 14,
221
+ DuringPerformance: 15,
222
+ MovieScreenCapture: 16,
223
+ ColouredFish: 17,
224
+ Illustration: 18,
225
+ BandLogo: 19,
226
+ PublisherLogo: 20
227
+ };
228
+ PICTURE_TYPE_NAMES = {
229
+ 0: "Other",
230
+ 1: "FileIcon",
231
+ 2: "OtherFileIcon",
232
+ 3: "FrontCover",
233
+ 4: "BackCover",
234
+ 5: "LeafletPage",
235
+ 6: "Media",
236
+ 7: "LeadArtist",
237
+ 8: "Artist",
238
+ 9: "Conductor",
239
+ 10: "Band",
240
+ 11: "Composer",
241
+ 12: "Lyricist",
242
+ 13: "RecordingLocation",
243
+ 14: "DuringRecording",
244
+ 15: "DuringPerformance",
245
+ 16: "MovieScreenCapture",
246
+ 17: "ColouredFish",
247
+ 18: "Illustration",
248
+ 19: "BandLogo",
249
+ 20: "PublisherLogo"
250
+ };
251
+ }));
252
+ //#endregion
253
+ //#region src/types/chapters.ts
254
+ var init_chapters = __esmMin((() => {}));
255
+ //#endregion
256
+ //#region src/types/bwf.ts
257
+ var init_bwf = __esmMin((() => {}));
258
+ //#endregion
259
+ //#region src/types/config.ts
260
+ var init_config = __esmMin((() => {}));
261
+ //#endregion
262
+ //#region src/types/format-property-keys.ts
263
+ var init_format_property_keys = __esmMin((() => {}));
264
+ //#endregion
265
+ //#region src/types/index.ts
266
+ var init_types$1 = __esmMin((() => {
267
+ init_audio_formats();
268
+ init_tags();
269
+ init_metadata_mappings();
270
+ init_pictures();
271
+ init_chapters();
272
+ init_bwf();
273
+ init_config();
274
+ init_format_property_keys();
275
+ }));
276
+ //#endregion
277
+ //#region src/types.ts
278
+ var init_types = __esmMin((() => {
279
+ init_types$1();
280
+ }));
281
+ //#endregion
282
+ //#region src/bwf/bext.ts
283
+ function readFixedString(bytes, offset, len) {
284
+ let end = offset;
285
+ const max = Math.min(offset + len, bytes.length);
286
+ while (end < max && bytes[end] !== 0) end++;
287
+ let s = "";
288
+ for (let i = offset; i < end; i++) s += String.fromCharCode(bytes[i]);
289
+ return s;
290
+ }
291
+ function writeFixedString(bytes, offset, len, value) {
292
+ for (let i = 0; i < len; i++) bytes[offset + i] = i < value.length ? value.charCodeAt(i) & 255 : 0;
293
+ }
294
+ function clampInt16(n) {
295
+ return Math.max(-32768, Math.min(32767, Math.round(n)));
296
+ }
297
+ function loudnessRaw(v) {
298
+ return v === void 0 ? LOUDNESS_UNSET : clampInt16(v * 100);
299
+ }
300
+ function loudnessFromRaw(raw) {
301
+ return raw === LOUDNESS_UNSET ? void 0 : raw / 100;
302
+ }
303
+ function bytesToHex(bytes) {
304
+ let s = "";
305
+ for (const b of bytes) s += b.toString(16).padStart(2, "0");
306
+ return s;
307
+ }
308
+ function hexToBytes(hex, outLen) {
309
+ const clean = hex.replace(/[^0-9a-fA-F]/g, "");
310
+ const out = new Uint8Array(outLen);
311
+ for (let i = 0; i + 1 < clean.length + 1 && i / 2 < outLen; i += 2) {
312
+ const pair = clean.slice(i, i + 2);
313
+ if (pair.length === 2) out[i / 2] = parseInt(pair, 16);
314
+ }
315
+ return out;
316
+ }
317
+ function decodeBext(bytes) {
318
+ if (bytes.length < 348) return void 0;
319
+ const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
320
+ const timeRefLow = dv.getUint32(338, true);
321
+ const timeRefHigh = dv.getUint32(342, true);
322
+ const version = dv.getUint16(VERSION_OFFSET, true);
323
+ const result = {
324
+ description: readFixedString(bytes, 0, 256),
325
+ originator: readFixedString(bytes, 256, 32),
326
+ originatorReference: readFixedString(bytes, 288, 32),
327
+ originationDate: readFixedString(bytes, 320, 10),
328
+ originationTime: readFixedString(bytes, 330, 8),
329
+ timeReferenceSamples: BigInt(timeRefHigh) << 32n | BigInt(timeRefLow),
330
+ version,
331
+ codingHistory: bytes.length > FIXED_PREFIX_LEN ? readFixedString(bytes, FIXED_PREFIX_LEN, bytes.length - FIXED_PREFIX_LEN) : ""
332
+ };
333
+ if (version >= 1 && bytes.length >= 412) result.umid = bytesToHex(bytes.subarray(UMID_OFFSET, 412));
334
+ if (version >= 2 && bytes.length >= 422) {
335
+ const lv = loudnessFromRaw(dv.getInt16(LOUDNESS_OFFSET, true));
336
+ const lr = loudnessFromRaw(dv.getInt16(414, true));
337
+ const mtp = loudnessFromRaw(dv.getInt16(416, true));
338
+ const mml = loudnessFromRaw(dv.getInt16(418, true));
339
+ const msl = loudnessFromRaw(dv.getInt16(420, true));
340
+ if (lv !== void 0) result.loudnessValueDb = lv;
341
+ if (lr !== void 0) result.loudnessRangeDb = lr;
342
+ if (mtp !== void 0) result.maxTruePeakLevelDbtp = mtp;
343
+ if (mml !== void 0) result.maxMomentaryLoudnessDb = mml;
344
+ if (msl !== void 0) result.maxShortTermLoudnessDb = msl;
345
+ }
346
+ return result;
347
+ }
348
+ function encodeBext(b) {
349
+ const codingHistory = b.codingHistory ?? "";
350
+ const bytes = new Uint8Array(FIXED_PREFIX_LEN + codingHistory.length);
351
+ const dv = new DataView(bytes.buffer);
352
+ const hasLoudness = b.loudnessValueDb !== void 0 || b.loudnessRangeDb !== void 0 || b.maxTruePeakLevelDbtp !== void 0 || b.maxMomentaryLoudnessDb !== void 0 || b.maxShortTermLoudnessDb !== void 0;
353
+ const version = Number.isInteger(b.version) ? b.version : hasLoudness ? 2 : b.umid ? 1 : 0;
354
+ writeFixedString(bytes, 0, 256, b.description ?? "");
355
+ writeFixedString(bytes, 256, 32, b.originator ?? "");
356
+ writeFixedString(bytes, 288, 32, b.originatorReference ?? "");
357
+ writeFixedString(bytes, 320, 10, b.originationDate ?? "");
358
+ writeFixedString(bytes, 330, 8, b.originationTime ?? "");
359
+ const tr = b.timeReferenceSamples ?? 0n;
360
+ dv.setUint32(338, Number(tr & 4294967295n), true);
361
+ dv.setUint32(342, Number(tr >> 32n & 4294967295n), true);
362
+ dv.setUint16(VERSION_OFFSET, version, true);
363
+ if (version >= 1 && b.umid) bytes.set(hexToBytes(b.umid, UMID_LEN), UMID_OFFSET);
364
+ if (version >= 2) {
365
+ dv.setInt16(LOUDNESS_OFFSET, loudnessRaw(b.loudnessValueDb), true);
366
+ dv.setInt16(414, loudnessRaw(b.loudnessRangeDb), true);
367
+ dv.setInt16(416, loudnessRaw(b.maxTruePeakLevelDbtp), true);
368
+ dv.setInt16(418, loudnessRaw(b.maxMomentaryLoudnessDb), true);
369
+ dv.setInt16(420, loudnessRaw(b.maxShortTermLoudnessDb), true);
370
+ }
371
+ writeFixedString(bytes, FIXED_PREFIX_LEN, codingHistory.length, codingHistory);
372
+ return bytes;
373
+ }
374
+ var FIXED_PREFIX_LEN, VERSION_OFFSET, UMID_OFFSET, UMID_LEN, LOUDNESS_OFFSET, LOUDNESS_UNSET;
375
+ var init_bext = __esmMin((() => {
376
+ FIXED_PREFIX_LEN = 602;
377
+ VERSION_OFFSET = 346;
378
+ UMID_OFFSET = 348;
379
+ UMID_LEN = 64;
380
+ LOUDNESS_OFFSET = 412;
381
+ LOUDNESS_UNSET = 32767;
382
+ }));
383
+ //#endregion
384
+ //#region src/errors/guards.ts
385
+ function isTagLibError(error) {
386
+ return error instanceof TagLibError;
387
+ }
388
+ function isInvalidFormatError(error) {
389
+ return error instanceof InvalidFormatError;
390
+ }
391
+ function isUnsupportedFormatError(error) {
392
+ return error instanceof UnsupportedFormatError;
393
+ }
394
+ function isFileOperationError(error) {
395
+ return error instanceof FileOperationError;
396
+ }
397
+ function isMetadataError(error) {
398
+ return error instanceof MetadataError;
399
+ }
400
+ function isMemoryError(error) {
401
+ return error instanceof MemoryError;
402
+ }
403
+ function isEnvironmentError(error) {
404
+ return error instanceof EnvironmentError;
405
+ }
406
+ var init_guards = __esmMin((() => {
407
+ init_base();
408
+ init_classes();
409
+ }));
410
+ //#endregion
411
+ //#region src/errors/index.ts
412
+ var init_errors$1 = __esmMin((() => {
413
+ init_base();
414
+ init_classes();
415
+ init_guards();
416
+ }));
417
+ //#endregion
418
+ //#region src/errors.ts
419
+ var init_errors = __esmMin((() => {
420
+ init_errors$1();
421
+ }));
422
+ //#endregion
423
+ //#region src/taglib/audio-file-bwf.ts
424
+ function requireBwf(format) {
425
+ if (!BWF_FORMATS.has(format)) throw new UnsupportedFormatError(format, ["WAV", "FLAC"], { operation: "BWF metadata" });
426
+ }
427
+ function getBextData(handle) {
428
+ const raw = handle.getBextData();
429
+ return raw && raw.length > 0 ? raw : void 0;
430
+ }
431
+ function setBextData(handle, format, data) {
432
+ requireBwf(format);
433
+ handle.setBextData(data);
434
+ }
435
+ function getBext(handle) {
436
+ const raw = handle.getBextData();
437
+ return raw && raw.length > 0 ? decodeBext(raw) : void 0;
438
+ }
439
+ function setBext(handle, format, bext) {
440
+ requireBwf(format);
441
+ handle.setBextData(encodeBext(bext));
442
+ }
443
+ function getIxml(handle) {
444
+ return handle.getIxml();
445
+ }
446
+ function setIxml(handle, format, data) {
447
+ requireBwf(format);
448
+ handle.setIxml(data);
449
+ }
450
+ var BWF_FORMATS;
451
+ var init_audio_file_bwf = __esmMin((() => {
452
+ init_bext();
453
+ init_errors();
454
+ BWF_FORMATS = /* @__PURE__ */ new Set(["WAV", "FLAC"]);
455
+ }));
456
+ //#endregion
457
+ //#region src/taglib/id3v2-frames.ts
458
+ function assertMp3(format) {
459
+ if (format !== "MP3" && format !== "AAC") throw new UnsupportedFormatError(format, ["MP3", "AAC"], { operation: "id3v2Frames" });
460
+ }
461
+ function assertFrameId(id, operation) {
462
+ if (!FRAME_ID_PATTERN.test(id)) throw new MetadataError(operation, `Invalid ID3v2 frame ID: "${id}". Frame IDs must match [A-Z0-9]{4}`, id);
463
+ }
464
+ function assertFrameBodies(id, data) {
465
+ for (const body of data) if (body.length === 0) throw new MetadataError("write", "Frame data must not be empty: zero-size ID3v2 frames are invalid", id);
466
+ }
467
+ function toPublicFrame(frame) {
468
+ return {
469
+ id: frame.id,
470
+ data: frame.data,
471
+ ...frame.flags ? { flags: frame.flags } : {}
472
+ };
473
+ }
474
+ var FRAME_ID_PATTERN;
475
+ var init_id3v2_frames = __esmMin((() => {
476
+ init_classes();
477
+ FRAME_ID_PATTERN = /^[A-Z0-9]{4}$/;
478
+ }));
479
+ //#endregion
480
+ //#region \0taglib:platform-io-stub
481
+ function getPlatformIO() {
482
+ throw new Error("Filesystem operations are not available in the browser.");
483
+ }
484
+ var init__taglib_platform_io_stub = __esmMin((() => {}));
485
+ //#endregion
486
+ //#region src/utils/write.ts
487
+ async function writeFileData(path, data) {
488
+ try {
489
+ await getPlatformIO().writeFile(path, data);
490
+ } catch (error) {
491
+ if (error instanceof EnvironmentError) throw error;
492
+ throw new FileOperationError("write", error.message, path);
493
+ }
494
+ }
495
+ var init_write = __esmMin((() => {
496
+ init_errors();
497
+ init__taglib_platform_io_stub();
498
+ }));
499
+ //#endregion
500
+ //#region \0taglib:node-fs-stub
501
+ function getNodeFsSync() {
502
+ return null;
503
+ }
504
+ var init__taglib_node_fs_stub = __esmMin((() => {}));
505
+ //#endregion
506
+ //#region src/utils/rating.ts
507
+ function normalized(value) {
508
+ return value;
509
+ }
510
+ var init_rating = __esmMin((() => {}));
511
+ //#endregion
512
+ //#region src/runtime/detector.ts
513
+ function isDeno() {
514
+ return g.Deno !== void 0;
515
+ }
516
+ var g;
517
+ var init_detector = __esmMin((() => {
518
+ g = globalThis;
519
+ new Uint8Array([
520
+ 0,
521
+ 97,
522
+ 115,
523
+ 109,
524
+ 1,
525
+ 0,
526
+ 0,
527
+ 0,
528
+ 6,
529
+ 6,
530
+ 1,
531
+ 105,
532
+ 0,
533
+ 208,
534
+ 105,
535
+ 11
536
+ ]);
537
+ }));
538
+ //#endregion
539
+ //#region src/constants/additional-properties.ts
540
+ var ADDITIONAL_PROPERTIES;
541
+ var init_additional_properties = __esmMin((() => {
542
+ ADDITIONAL_PROPERTIES = {
543
+ albumArtistSort: {
544
+ key: "ALBUMARTISTSORT",
545
+ description: "Sort name for album artist (for alphabetization)",
546
+ type: "string",
547
+ supportedFormats: [
548
+ "ID3v2",
549
+ "MP4",
550
+ "Vorbis"
551
+ ],
552
+ mappings: {
553
+ id3v2: { frame: "TSO2" },
554
+ vorbis: "ALBUMARTISTSORT",
555
+ mp4: "soaa"
556
+ }
557
+ },
558
+ composerSort: {
559
+ key: "COMPOSERSORT",
560
+ description: "Sort name for composer (for alphabetization)",
561
+ type: "string",
562
+ supportedFormats: [
563
+ "ID3v2",
564
+ "MP4",
565
+ "Vorbis"
566
+ ],
567
+ mappings: {
568
+ id3v2: { frame: "TSOC" },
569
+ vorbis: "COMPOSERSORT",
570
+ mp4: "soco"
571
+ }
572
+ },
573
+ subtitle: {
574
+ key: "SUBTITLE",
575
+ description: "Subtitle or description refinement",
576
+ type: "string",
577
+ supportedFormats: [
578
+ "ID3v2",
579
+ "MP4",
580
+ "Vorbis"
581
+ ],
582
+ mappings: {
583
+ id3v2: { frame: "TIT3" },
584
+ vorbis: "SUBTITLE",
585
+ mp4: "----:com.apple.iTunes:SUBTITLE"
586
+ }
587
+ },
588
+ label: {
589
+ key: "LABEL",
590
+ description: "Record label name",
591
+ type: "string",
592
+ supportedFormats: [
593
+ "ID3v2",
594
+ "MP4",
595
+ "Vorbis",
596
+ "WAV"
597
+ ],
598
+ mappings: {
599
+ id3v2: { frame: "TPUB" },
600
+ vorbis: "LABEL",
601
+ mp4: "----:com.apple.iTunes:LABEL",
602
+ wav: "IPUB"
603
+ }
604
+ },
605
+ producer: {
606
+ key: "PRODUCER",
607
+ description: "Producer of the recording",
608
+ type: "string",
609
+ supportedFormats: [
610
+ "ID3v2",
611
+ "MP4",
612
+ "Vorbis"
613
+ ],
614
+ mappings: {
615
+ id3v2: {
616
+ frame: "TXXX",
617
+ description: "PRODUCER"
618
+ },
619
+ vorbis: "PRODUCER",
620
+ mp4: "----:com.apple.iTunes:PRODUCER"
621
+ }
622
+ },
623
+ radioStationOwner: {
624
+ key: "RADIOSTATIONOWNER",
625
+ description: "Owner of the radio station",
626
+ type: "string",
627
+ supportedFormats: ["ID3v2"],
628
+ mappings: { id3v2: { frame: "TRSO" } }
629
+ },
630
+ asin: {
631
+ key: "ASIN",
632
+ description: "Amazon Standard Identification Number",
633
+ type: "string",
634
+ supportedFormats: [
635
+ "ID3v2",
636
+ "MP4",
637
+ "Vorbis"
638
+ ],
639
+ mappings: {
640
+ id3v2: {
641
+ frame: "TXXX",
642
+ description: "ASIN"
643
+ },
644
+ vorbis: "ASIN",
645
+ mp4: "----:com.apple.iTunes:ASIN"
646
+ }
647
+ },
648
+ musicbrainzReleaseArtistId: {
649
+ key: "MUSICBRAINZ_ALBUMARTISTID",
650
+ description: "MusicBrainz Release Artist ID (UUID)",
651
+ type: "string",
652
+ supportedFormats: [
653
+ "ID3v2",
654
+ "MP4",
655
+ "Vorbis"
656
+ ],
657
+ mappings: {
658
+ id3v2: {
659
+ frame: "TXXX",
660
+ description: "MusicBrainz Album Artist Id"
661
+ },
662
+ vorbis: "MUSICBRAINZ_ALBUMARTISTID",
663
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Artist Id"
664
+ }
665
+ },
666
+ musicbrainzWorkId: {
667
+ key: "MUSICBRAINZ_WORKID",
668
+ description: "MusicBrainz Work ID (UUID)",
669
+ type: "string",
670
+ supportedFormats: [
671
+ "ID3v2",
672
+ "MP4",
673
+ "Vorbis"
674
+ ],
675
+ mappings: {
676
+ id3v2: {
677
+ frame: "TXXX",
678
+ description: "MusicBrainz Work Id"
679
+ },
680
+ vorbis: "MUSICBRAINZ_WORKID",
681
+ mp4: "----:com.apple.iTunes:MusicBrainz Work Id"
682
+ }
683
+ },
684
+ musicbrainzReleaseTrackId: {
685
+ key: "MUSICBRAINZ_RELEASETRACKID",
686
+ description: "MusicBrainz Release Track ID (UUID)",
687
+ type: "string",
688
+ supportedFormats: [
689
+ "ID3v2",
690
+ "MP4",
691
+ "Vorbis"
692
+ ],
693
+ mappings: {
694
+ id3v2: {
695
+ frame: "TXXX",
696
+ description: "MusicBrainz Release Track Id"
697
+ },
698
+ vorbis: "MUSICBRAINZ_RELEASETRACKID",
699
+ mp4: "----:com.apple.iTunes:MusicBrainz Release Track Id"
700
+ }
701
+ },
702
+ podcastId: {
703
+ key: "PODCASTID",
704
+ description: "Podcast episode identifier",
705
+ type: "string",
706
+ supportedFormats: [
707
+ "ID3v2",
708
+ "MP4",
709
+ "Vorbis"
710
+ ],
711
+ mappings: {
712
+ id3v2: { frame: "TGID" },
713
+ vorbis: "PODCASTID",
714
+ mp4: "egid"
715
+ }
716
+ },
717
+ podcastUrl: {
718
+ key: "PODCASTURL",
719
+ description: "Podcast feed URL",
720
+ type: "string",
721
+ supportedFormats: [
722
+ "ID3v2",
723
+ "MP4",
724
+ "Vorbis"
725
+ ],
726
+ mappings: {
727
+ id3v2: { frame: "WFED" },
728
+ vorbis: "PODCASTURL",
729
+ mp4: "purl"
730
+ }
731
+ },
732
+ originalArtist: {
733
+ key: "ORIGINALARTIST",
734
+ description: "Original artist of a cover or remix",
735
+ type: "string",
736
+ supportedFormats: ["ID3v2", "Vorbis"],
737
+ mappings: {
738
+ id3v2: { frame: "TOPE" },
739
+ vorbis: "ORIGINALARTIST"
740
+ }
741
+ },
742
+ originalAlbum: {
743
+ key: "ORIGINALALBUM",
744
+ description: "Original album of a cover or remix",
745
+ type: "string",
746
+ supportedFormats: ["ID3v2", "Vorbis"],
747
+ mappings: {
748
+ id3v2: { frame: "TOAL" },
749
+ vorbis: "ORIGINALALBUM"
750
+ }
751
+ },
752
+ originalDate: {
753
+ key: "ORIGINALDATE",
754
+ description: "Original release date",
755
+ type: "string",
756
+ supportedFormats: [
757
+ "ID3v2",
758
+ "MP4",
759
+ "Vorbis"
760
+ ],
761
+ mappings: {
762
+ id3v2: { frame: "TDOR" },
763
+ vorbis: "ORIGINALDATE",
764
+ mp4: "----:com.apple.iTunes:ORIGINALDATE"
765
+ }
766
+ },
767
+ script: {
768
+ key: "SCRIPT",
769
+ description: "Writing script used for text (e.g., Latn, Jpan)",
770
+ type: "string",
771
+ supportedFormats: ["MP4", "Vorbis"],
772
+ mappings: {
773
+ vorbis: "SCRIPT",
774
+ mp4: "----:com.apple.iTunes:SCRIPT"
775
+ }
776
+ },
777
+ involvedPeople: {
778
+ key: "INVOLVEDPEOPLE",
779
+ description: "List of involved people and their roles",
780
+ type: "string",
781
+ supportedFormats: ["ID3v2"],
782
+ mappings: { id3v2: { frame: "TIPL" } }
783
+ },
784
+ encoding: {
785
+ key: "ENCODING",
786
+ description: "Encoding software or settings",
787
+ type: "string",
788
+ supportedFormats: [
789
+ "ID3v2",
790
+ "MP4",
791
+ "Vorbis",
792
+ "WAV"
793
+ ],
794
+ mappings: {
795
+ id3v2: { frame: "TSSE" },
796
+ vorbis: "ENCODING",
797
+ mp4: "©too",
798
+ wav: "ISFT"
799
+ }
800
+ }
801
+ };
802
+ }));
803
+ //#endregion
804
+ //#region src/constants/basic-properties.ts
805
+ var BASIC_PROPERTIES;
806
+ var init_basic_properties = __esmMin((() => {
807
+ BASIC_PROPERTIES = {
808
+ title: {
809
+ key: "TITLE",
810
+ description: "The title of the track",
811
+ type: "string",
812
+ supportedFormats: [
813
+ "ID3v2",
814
+ "MP4",
815
+ "Vorbis",
816
+ "WAV"
817
+ ],
818
+ mappings: {
819
+ id3v2: { frame: "TIT2" },
820
+ vorbis: "TITLE",
821
+ mp4: "©nam",
822
+ wav: "INAM"
823
+ }
824
+ },
825
+ artist: {
826
+ key: "ARTIST",
827
+ description: "The primary performer(s) of the track",
828
+ type: "string",
829
+ supportedFormats: [
830
+ "ID3v2",
831
+ "MP4",
832
+ "Vorbis",
833
+ "WAV"
834
+ ],
835
+ mappings: {
836
+ id3v2: { frame: "TPE1" },
837
+ vorbis: "ARTIST",
838
+ mp4: "©ART",
839
+ wav: "IART"
840
+ }
841
+ },
842
+ album: {
843
+ key: "ALBUM",
844
+ description: "The album/collection name",
845
+ type: "string",
846
+ supportedFormats: [
847
+ "ID3v2",
848
+ "MP4",
849
+ "Vorbis",
850
+ "WAV"
851
+ ],
852
+ mappings: {
853
+ id3v2: { frame: "TALB" },
854
+ vorbis: "ALBUM",
855
+ mp4: "©alb",
856
+ wav: "IPRD"
857
+ }
858
+ },
859
+ date: {
860
+ key: "DATE",
861
+ description: "The date of recording (typically year)",
862
+ type: "string",
863
+ supportedFormats: [
864
+ "ID3v2",
865
+ "MP4",
866
+ "Vorbis",
867
+ "WAV"
868
+ ],
869
+ mappings: {
870
+ id3v2: { frame: "TDRC" },
871
+ vorbis: "DATE",
872
+ mp4: "©day",
873
+ wav: "ICRD"
874
+ }
875
+ },
876
+ trackNumber: {
877
+ key: "TRACKNUMBER",
878
+ description: "The track number within the album",
879
+ type: "string",
880
+ supportedFormats: [
881
+ "ID3v2",
882
+ "MP4",
883
+ "Vorbis",
884
+ "WAV"
885
+ ],
886
+ mappings: {
887
+ id3v2: { frame: "TRCK" },
888
+ vorbis: "TRACKNUMBER",
889
+ mp4: "trkn",
890
+ wav: "ITRK"
891
+ }
892
+ },
893
+ genre: {
894
+ key: "GENRE",
895
+ description: "The musical genre",
896
+ type: "string",
897
+ supportedFormats: [
898
+ "ID3v2",
899
+ "MP4",
900
+ "Vorbis",
901
+ "WAV"
902
+ ],
903
+ mappings: {
904
+ id3v2: { frame: "TCON" },
905
+ vorbis: "GENRE",
906
+ mp4: "©gen",
907
+ wav: "IGNR"
908
+ }
909
+ },
910
+ comment: {
911
+ key: "COMMENT",
912
+ description: "Comments or notes about the track",
913
+ type: "string",
914
+ supportedFormats: [
915
+ "ID3v2",
916
+ "MP4",
917
+ "Vorbis",
918
+ "WAV"
919
+ ],
920
+ mappings: {
921
+ id3v2: { frame: "COMM" },
922
+ vorbis: "COMMENT",
923
+ mp4: "©cmt",
924
+ wav: "ICMT"
925
+ }
926
+ }
927
+ };
928
+ }));
929
+ //#endregion
930
+ //#region src/constants/general-extended-properties.ts
931
+ var GENERAL_EXTENDED_PROPERTIES;
932
+ var init_general_extended_properties = __esmMin((() => {
933
+ GENERAL_EXTENDED_PROPERTIES = {
934
+ albumArtist: {
935
+ key: "ALBUMARTIST",
936
+ description: "The album artist (band/orchestra/ensemble)",
937
+ type: "string",
938
+ supportedFormats: [
939
+ "ID3v2",
940
+ "MP4",
941
+ "Vorbis"
942
+ ],
943
+ mappings: {
944
+ id3v2: { frame: "TPE2" },
945
+ vorbis: "ALBUMARTIST",
946
+ mp4: "aART"
947
+ }
948
+ },
949
+ composer: {
950
+ key: "COMPOSER",
951
+ description: "The original composer(s) of the track",
952
+ type: "string",
953
+ supportedFormats: [
954
+ "ID3v2",
955
+ "MP4",
956
+ "Vorbis"
957
+ ],
958
+ mappings: {
959
+ id3v2: { frame: "TCOM" },
960
+ vorbis: "COMPOSER",
961
+ mp4: "©wrt"
962
+ }
963
+ },
964
+ copyright: {
965
+ key: "COPYRIGHT",
966
+ description: "Copyright information",
967
+ type: "string",
968
+ supportedFormats: ["ID3v2", "Vorbis"],
969
+ mappings: { vorbis: "COPYRIGHT" }
970
+ },
971
+ encodedBy: {
972
+ key: "ENCODEDBY",
973
+ description: "The encoding software or person",
974
+ type: "string",
975
+ supportedFormats: ["ID3v2", "Vorbis"],
976
+ mappings: { vorbis: "ENCODEDBY" }
977
+ },
978
+ discNumber: {
979
+ key: "DISCNUMBER",
980
+ description: "The disc number for multi-disc sets",
981
+ type: "string",
982
+ supportedFormats: [
983
+ "ID3v2",
984
+ "MP4",
985
+ "Vorbis"
986
+ ],
987
+ mappings: {
988
+ id3v2: { frame: "TPOS" },
989
+ vorbis: "DISCNUMBER",
990
+ mp4: "disk"
991
+ }
992
+ },
993
+ bpm: {
994
+ key: "BPM",
995
+ description: "Beats per minute",
996
+ type: "string",
997
+ supportedFormats: [
998
+ "ID3v2",
999
+ "MP4",
1000
+ "Vorbis"
1001
+ ],
1002
+ mappings: {
1003
+ id3v2: { frame: "TBPM" },
1004
+ vorbis: "BPM",
1005
+ mp4: "tmpo"
1006
+ }
1007
+ },
1008
+ totalTracks: {
1009
+ key: "TRACKTOTAL",
1010
+ description: "Total number of tracks on the album",
1011
+ type: "string",
1012
+ supportedFormats: [
1013
+ "ID3v2",
1014
+ "MP4",
1015
+ "Vorbis"
1016
+ ],
1017
+ mappings: {
1018
+ id3v2: { frame: "TRCK" },
1019
+ vorbis: "TRACKTOTAL",
1020
+ mp4: "trkn"
1021
+ }
1022
+ },
1023
+ totalDiscs: {
1024
+ key: "DISCTOTAL",
1025
+ description: "Total number of discs in the set",
1026
+ type: "string",
1027
+ supportedFormats: [
1028
+ "ID3v2",
1029
+ "MP4",
1030
+ "Vorbis"
1031
+ ],
1032
+ mappings: {
1033
+ id3v2: { frame: "TPOS" },
1034
+ vorbis: "DISCTOTAL",
1035
+ mp4: "disk"
1036
+ }
1037
+ },
1038
+ compilation: {
1039
+ key: "COMPILATION",
1040
+ description: "Whether the album is a compilation (various artists)",
1041
+ type: "boolean",
1042
+ supportedFormats: [
1043
+ "ID3v2",
1044
+ "MP4",
1045
+ "Vorbis"
1046
+ ],
1047
+ mappings: {
1048
+ id3v2: { frame: "TCMP" },
1049
+ vorbis: "COMPILATION",
1050
+ mp4: "cpil"
1051
+ }
1052
+ },
1053
+ titleSort: {
1054
+ key: "TITLESORT",
1055
+ description: "Sort name for title (for alphabetization)",
1056
+ type: "string",
1057
+ supportedFormats: [
1058
+ "ID3v2",
1059
+ "MP4",
1060
+ "Vorbis"
1061
+ ],
1062
+ mappings: {
1063
+ id3v2: { frame: "TSOT" },
1064
+ vorbis: "TITLESORT",
1065
+ mp4: "sonm"
1066
+ }
1067
+ },
1068
+ artistSort: {
1069
+ key: "ARTISTSORT",
1070
+ description: "Sort name for artist (for alphabetization)",
1071
+ type: "string",
1072
+ supportedFormats: [
1073
+ "ID3v2",
1074
+ "MP4",
1075
+ "Vorbis"
1076
+ ],
1077
+ mappings: {
1078
+ id3v2: { frame: "TSOP" },
1079
+ vorbis: "ARTISTSORT",
1080
+ mp4: "soar"
1081
+ }
1082
+ },
1083
+ albumSort: {
1084
+ key: "ALBUMSORT",
1085
+ description: "Sort name for album (for alphabetization)",
1086
+ type: "string",
1087
+ supportedFormats: [
1088
+ "ID3v2",
1089
+ "MP4",
1090
+ "Vorbis"
1091
+ ],
1092
+ mappings: {
1093
+ id3v2: { frame: "TSOA" },
1094
+ vorbis: "ALBUMSORT",
1095
+ mp4: "soal"
1096
+ }
1097
+ },
1098
+ lyricist: {
1099
+ key: "LYRICIST",
1100
+ description: "The lyrics/text writer(s)",
1101
+ type: "string",
1102
+ supportedFormats: ["Vorbis"],
1103
+ mappings: { vorbis: "LYRICIST" }
1104
+ },
1105
+ conductor: {
1106
+ key: "CONDUCTOR",
1107
+ description: "The conductor",
1108
+ type: "string",
1109
+ supportedFormats: ["Vorbis"],
1110
+ mappings: { vorbis: "CONDUCTOR" }
1111
+ },
1112
+ remixedBy: {
1113
+ key: "REMIXER",
1114
+ description: "Person who remixed the track",
1115
+ type: "string",
1116
+ supportedFormats: [
1117
+ "ID3v2",
1118
+ "MP4",
1119
+ "Vorbis"
1120
+ ],
1121
+ mappings: {
1122
+ id3v2: { frame: "TPE4" },
1123
+ vorbis: "REMIXER",
1124
+ mp4: "----:com.apple.iTunes:REMIXER"
1125
+ }
1126
+ },
1127
+ language: {
1128
+ key: "LANGUAGE",
1129
+ description: "Language of vocals/lyrics",
1130
+ type: "string",
1131
+ supportedFormats: ["Vorbis"],
1132
+ mappings: { vorbis: "LANGUAGE" }
1133
+ },
1134
+ publisher: {
1135
+ key: "PUBLISHER",
1136
+ description: "The publisher",
1137
+ type: "string",
1138
+ supportedFormats: ["Vorbis"],
1139
+ mappings: { vorbis: "PUBLISHER" }
1140
+ },
1141
+ mood: {
1142
+ key: "MOOD",
1143
+ description: "The mood/atmosphere of the track",
1144
+ type: "string",
1145
+ supportedFormats: ["Vorbis"],
1146
+ mappings: { vorbis: "MOOD" }
1147
+ },
1148
+ media: {
1149
+ key: "MEDIA",
1150
+ description: "Media type (CD, vinyl, etc.)",
1151
+ type: "string",
1152
+ supportedFormats: ["Vorbis"],
1153
+ mappings: { vorbis: "MEDIA" }
1154
+ },
1155
+ grouping: {
1156
+ key: "GROUPING",
1157
+ description: "Content group/work",
1158
+ type: "string",
1159
+ supportedFormats: ["Vorbis"],
1160
+ mappings: { vorbis: "GROUPING" }
1161
+ },
1162
+ work: {
1163
+ key: "WORK",
1164
+ description: "Work name",
1165
+ type: "string",
1166
+ supportedFormats: ["Vorbis"],
1167
+ mappings: { vorbis: "WORK" }
1168
+ },
1169
+ lyrics: {
1170
+ key: "LYRICS",
1171
+ description: "Lyrics content",
1172
+ type: "string",
1173
+ supportedFormats: ["Vorbis"],
1174
+ mappings: { vorbis: "LYRICS" }
1175
+ },
1176
+ isrc: {
1177
+ key: "ISRC",
1178
+ description: "International Standard Recording Code",
1179
+ type: "string",
1180
+ supportedFormats: ["Vorbis"],
1181
+ mappings: { vorbis: "ISRC" }
1182
+ },
1183
+ catalogNumber: {
1184
+ key: "CATALOGNUMBER",
1185
+ description: "Catalog number",
1186
+ type: "string",
1187
+ supportedFormats: ["Vorbis"],
1188
+ mappings: { vorbis: "CATALOGNUMBER" }
1189
+ },
1190
+ barcode: {
1191
+ key: "BARCODE",
1192
+ description: "Barcode (EAN/UPC)",
1193
+ type: "string",
1194
+ supportedFormats: ["Vorbis"],
1195
+ mappings: { vorbis: "BARCODE" }
1196
+ }
1197
+ };
1198
+ }));
1199
+ //#endregion
1200
+ //#region src/constants/specialized-properties.ts
1201
+ var SPECIALIZED_PROPERTIES;
1202
+ var init_specialized_properties = __esmMin((() => {
1203
+ SPECIALIZED_PROPERTIES = {
1204
+ musicbrainzArtistId: {
1205
+ key: "MUSICBRAINZ_ARTISTID",
1206
+ description: "MusicBrainz Artist ID (UUID)",
1207
+ type: "string",
1208
+ supportedFormats: [
1209
+ "ID3v2",
1210
+ "MP4",
1211
+ "Vorbis"
1212
+ ],
1213
+ mappings: {
1214
+ id3v2: {
1215
+ frame: "TXXX",
1216
+ description: "MusicBrainz Artist Id"
1217
+ },
1218
+ vorbis: "MUSICBRAINZ_ARTISTID",
1219
+ mp4: "----:com.apple.iTunes:MusicBrainz Artist Id"
1220
+ }
1221
+ },
1222
+ musicbrainzReleaseId: {
1223
+ key: "MUSICBRAINZ_ALBUMID",
1224
+ description: "MusicBrainz Release ID (UUID)",
1225
+ type: "string",
1226
+ supportedFormats: [
1227
+ "ID3v2",
1228
+ "MP4",
1229
+ "Vorbis"
1230
+ ],
1231
+ mappings: {
1232
+ id3v2: {
1233
+ frame: "TXXX",
1234
+ description: "MusicBrainz Album Id"
1235
+ },
1236
+ vorbis: "MUSICBRAINZ_ALBUMID",
1237
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Id"
1238
+ }
1239
+ },
1240
+ musicbrainzTrackId: {
1241
+ key: "MUSICBRAINZ_TRACKID",
1242
+ description: "MusicBrainz Recording ID (UUID)",
1243
+ type: "string",
1244
+ supportedFormats: [
1245
+ "ID3v2",
1246
+ "MP4",
1247
+ "Vorbis"
1248
+ ],
1249
+ mappings: {
1250
+ id3v2: {
1251
+ frame: "UFID",
1252
+ description: "http://musicbrainz.org"
1253
+ },
1254
+ vorbis: "MUSICBRAINZ_TRACKID",
1255
+ mp4: "----:com.apple.iTunes:MusicBrainz Track Id"
1256
+ }
1257
+ },
1258
+ musicbrainzReleaseGroupId: {
1259
+ key: "MUSICBRAINZ_RELEASEGROUPID",
1260
+ description: "MusicBrainz Release Group ID (UUID)",
1261
+ type: "string",
1262
+ supportedFormats: [
1263
+ "ID3v2",
1264
+ "MP4",
1265
+ "Vorbis"
1266
+ ],
1267
+ mappings: {
1268
+ id3v2: {
1269
+ frame: "TXXX",
1270
+ description: "MusicBrainz Release Group Id"
1271
+ },
1272
+ vorbis: "MUSICBRAINZ_RELEASEGROUPID",
1273
+ mp4: "----:com.apple.iTunes:MusicBrainz Release Group Id"
1274
+ }
1275
+ },
1276
+ releaseType: {
1277
+ key: "RELEASETYPE",
1278
+ description: "Release type (album, single, EP, compilation, ...). Multi-value (e.g. 'album' + 'EP'). TagLib 2.3.2 translates the RELEASETYPE key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM TYPE' (TagLib's description casing), MP4 freeform atom, APEv2 MUSICBRAINZ_ALBUMTYPE, ASF 'MusicBrainz/Album Type', Vorbis/Matroska raw RELEASETYPE",
1279
+ type: "string",
1280
+ supportedFormats: [
1281
+ "ID3v2",
1282
+ "MP4",
1283
+ "Vorbis",
1284
+ "APE",
1285
+ "ASF",
1286
+ "Matroska"
1287
+ ],
1288
+ mappings: {
1289
+ id3v2: {
1290
+ frame: "TXXX",
1291
+ description: "MusicBrainz Album Type"
1292
+ },
1293
+ vorbis: "RELEASETYPE",
1294
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Type"
1295
+ }
1296
+ },
1297
+ releaseCountry: {
1298
+ key: "RELEASECOUNTRY",
1299
+ description: "Release country (ISO 3166-1 code, e.g. 'US'). TagLib 2.3.2 translates the RELEASECOUNTRY key per format: ID3v2 TXXX 'MUSICBRAINZ ALBUM RELEASE COUNTRY' (TagLib's description casing; an uppercase TXXX:RELEASECOUNTRY description also reads back), MP4 freeform atom 'MusicBrainz Album Release Country', APEv2 raw RELEASECOUNTRY, ASF 'MusicBrainz/Album Release Country', WAV ICNT, Vorbis/Matroska raw RELEASECOUNTRY",
1300
+ type: "string",
1301
+ supportedFormats: [
1302
+ "ID3v2",
1303
+ "MP4",
1304
+ "Vorbis",
1305
+ "APE",
1306
+ "ASF",
1307
+ "Matroska",
1308
+ "WAV"
1309
+ ],
1310
+ mappings: {
1311
+ id3v2: {
1312
+ frame: "TXXX",
1313
+ description: "MusicBrainz Album Release Country"
1314
+ },
1315
+ vorbis: "RELEASECOUNTRY",
1316
+ mp4: "----:com.apple.iTunes:MusicBrainz Album Release Country"
1317
+ }
1318
+ },
1319
+ itunesAdvisory: {
1320
+ key: "ITUNESADVISORY",
1321
+ description: "Content advisory in the ITUNESADVISORY convention ('1' = explicit, '2' = clean, '0' = unspecified). On MP4 the value is stored in the native rtng atom and surfaced here. The typed tri-state lives on ExtendedTag.advisory; aliases CONTENTADVISORY and EXPLICIT resolve here",
1322
+ type: "string",
1323
+ supportedFormats: [
1324
+ "ID3v2",
1325
+ "MP4",
1326
+ "Vorbis",
1327
+ "APE",
1328
+ "ASF"
1329
+ ],
1330
+ mappings: {
1331
+ id3v2: {
1332
+ frame: "TXXX",
1333
+ description: "ITUNESADVISORY"
1334
+ },
1335
+ vorbis: "ITUNESADVISORY",
1336
+ mp4: "----:com.apple.iTunes:ITUNESADVISORY"
1337
+ }
1338
+ },
1339
+ replayGainTrackGain: {
1340
+ key: "REPLAYGAIN_TRACK_GAIN",
1341
+ description: "ReplayGain track gain in dB (e.g., '-6.54 dB')",
1342
+ type: "string",
1343
+ supportedFormats: [
1344
+ "ID3v2",
1345
+ "MP4",
1346
+ "Vorbis"
1347
+ ],
1348
+ mappings: {
1349
+ id3v2: {
1350
+ frame: "TXXX",
1351
+ description: "ReplayGain_Track_Gain"
1352
+ },
1353
+ vorbis: "REPLAYGAIN_TRACK_GAIN",
1354
+ mp4: "----:com.apple.iTunes:replaygain_track_gain"
1355
+ }
1356
+ },
1357
+ replayGainTrackPeak: {
1358
+ key: "REPLAYGAIN_TRACK_PEAK",
1359
+ description: "ReplayGain track peak value (0.0-1.0)",
1360
+ type: "string",
1361
+ supportedFormats: [
1362
+ "ID3v2",
1363
+ "MP4",
1364
+ "Vorbis"
1365
+ ],
1366
+ mappings: {
1367
+ id3v2: {
1368
+ frame: "TXXX",
1369
+ description: "ReplayGain_Track_Peak"
1370
+ },
1371
+ vorbis: "REPLAYGAIN_TRACK_PEAK",
1372
+ mp4: "----:com.apple.iTunes:replaygain_track_peak"
1373
+ }
1374
+ },
1375
+ replayGainAlbumGain: {
1376
+ key: "REPLAYGAIN_ALBUM_GAIN",
1377
+ description: "ReplayGain album gain in dB",
1378
+ type: "string",
1379
+ supportedFormats: [
1380
+ "ID3v2",
1381
+ "MP4",
1382
+ "Vorbis"
1383
+ ],
1384
+ mappings: {
1385
+ id3v2: {
1386
+ frame: "TXXX",
1387
+ description: "ReplayGain_Album_Gain"
1388
+ },
1389
+ vorbis: "REPLAYGAIN_ALBUM_GAIN",
1390
+ mp4: "----:com.apple.iTunes:replaygain_album_gain"
1391
+ }
1392
+ },
1393
+ replayGainAlbumPeak: {
1394
+ key: "REPLAYGAIN_ALBUM_PEAK",
1395
+ description: "ReplayGain album peak value (0.0-1.0)",
1396
+ type: "string",
1397
+ supportedFormats: [
1398
+ "ID3v2",
1399
+ "MP4",
1400
+ "Vorbis"
1401
+ ],
1402
+ mappings: {
1403
+ id3v2: {
1404
+ frame: "TXXX",
1405
+ description: "ReplayGain_Album_Peak"
1406
+ },
1407
+ vorbis: "REPLAYGAIN_ALBUM_PEAK",
1408
+ mp4: "----:com.apple.iTunes:replaygain_album_peak"
1409
+ }
1410
+ },
1411
+ r128TrackGain: {
1412
+ key: "R128_TRACK_GAIN",
1413
+ description: "EBU R128 track loudness gain (RFC 7845), raw wire value: signed Q7.8 integer (dB x 256, e.g. '-573' = -2.23828125 dB). readTags() converts to a decibel number (see ExtendedTag.r128TrackGain)",
1414
+ type: "string",
1415
+ supportedFormats: [
1416
+ "ID3v2",
1417
+ "MP4",
1418
+ "Vorbis",
1419
+ "ASF"
1420
+ ],
1421
+ mappings: {
1422
+ id3v2: {
1423
+ frame: "TXXX",
1424
+ description: "R128_TRACK_GAIN"
1425
+ },
1426
+ vorbis: "R128_TRACK_GAIN",
1427
+ mp4: "----:com.apple.iTunes:R128_TRACK_GAIN"
1428
+ }
1429
+ },
1430
+ r128AlbumGain: {
1431
+ key: "R128_ALBUM_GAIN",
1432
+ description: "EBU R128 album loudness gain (RFC 7845), raw wire value: signed Q7.8 integer (dB x 256). readTags() converts to a decibel number",
1433
+ type: "string",
1434
+ supportedFormats: [
1435
+ "ID3v2",
1436
+ "MP4",
1437
+ "Vorbis",
1438
+ "ASF"
1439
+ ],
1440
+ mappings: {
1441
+ id3v2: {
1442
+ frame: "TXXX",
1443
+ description: "R128_ALBUM_GAIN"
1444
+ },
1445
+ vorbis: "R128_ALBUM_GAIN",
1446
+ mp4: "----:com.apple.iTunes:R128_ALBUM_GAIN"
1447
+ }
1448
+ },
1449
+ acoustidFingerprint: {
1450
+ key: "ACOUSTID_FINGERPRINT",
1451
+ description: "AcoustID fingerprint (Chromaprint)",
1452
+ type: "string",
1453
+ supportedFormats: [
1454
+ "ID3v2",
1455
+ "MP4",
1456
+ "Vorbis"
1457
+ ],
1458
+ mappings: {
1459
+ id3v2: {
1460
+ frame: "TXXX",
1461
+ description: "Acoustid Fingerprint"
1462
+ },
1463
+ vorbis: "ACOUSTID_FINGERPRINT",
1464
+ mp4: "----:com.apple.iTunes:Acoustid Fingerprint"
1465
+ }
1466
+ },
1467
+ acoustidId: {
1468
+ key: "ACOUSTID_ID",
1469
+ description: "AcoustID UUID",
1470
+ type: "string",
1471
+ supportedFormats: [
1472
+ "ID3v2",
1473
+ "MP4",
1474
+ "Vorbis"
1475
+ ],
1476
+ mappings: {
1477
+ id3v2: {
1478
+ frame: "TXXX",
1479
+ description: "Acoustid Id"
1480
+ },
1481
+ vorbis: "ACOUSTID_ID",
1482
+ mp4: "----:com.apple.iTunes:Acoustid Id"
1483
+ }
1484
+ },
1485
+ appleSoundCheck: {
1486
+ key: "ITUNNORM",
1487
+ description: "Apple Sound Check normalization data",
1488
+ type: "string",
1489
+ supportedFormats: [
1490
+ "ID3v2",
1491
+ "MP4",
1492
+ "Vorbis"
1493
+ ],
1494
+ mappings: {
1495
+ id3v2: {
1496
+ frame: "TXXX",
1497
+ description: "iTunNORM"
1498
+ },
1499
+ vorbis: "ITUNNORM",
1500
+ mp4: "----:com.apple.iTunes:iTunNORM"
1501
+ }
1502
+ },
1503
+ appleGaplessInfo: {
1504
+ key: "ITUNSMPB",
1505
+ description: "Apple gapless playback data (encoder delay and padding)",
1506
+ type: "string",
1507
+ supportedFormats: [
1508
+ "ID3v2",
1509
+ "MP4",
1510
+ "Vorbis"
1511
+ ],
1512
+ mappings: {
1513
+ id3v2: {
1514
+ frame: "TXXX",
1515
+ description: "iTunSMPB"
1516
+ },
1517
+ vorbis: "ITUNSMPB",
1518
+ mp4: "----:com.apple.iTunes:iTunSMPB"
1519
+ }
1520
+ }
1521
+ };
1522
+ }));
1523
+ //#endregion
1524
+ //#region src/constants/properties.ts
1525
+ function toTagLibKey(key) {
1526
+ return _toTagLib[key] ?? key;
1527
+ }
1528
+ function mp4AtomWireKey(atom) {
1529
+ return _mp4AtomToWireKey[atom];
1530
+ }
1531
+ function mp4FreeformAtomNames(wireKeys) {
1532
+ const names = [];
1533
+ for (const key of wireKeys) {
1534
+ const atom = _mp4FreeformAtoms[key];
1535
+ if (atom !== void 0) names.push(atom);
1536
+ }
1537
+ return names;
1538
+ }
1539
+ function fromTagLibKey(key) {
1540
+ return _fromTagLib[key] ?? key;
1541
+ }
1542
+ function remapKeysFromTagLib(obj) {
1543
+ const result = {};
1544
+ for (const [key, value] of Object.entries(obj)) {
1545
+ const canonical = READ_ALIASES[key];
1546
+ if (canonical !== void 0 && canonical in obj) continue;
1547
+ result[fromTagLibKey(key)] = value;
1548
+ }
1549
+ return result;
1550
+ }
1551
+ var PROPERTIES, _toTagLib, _fromTagLib, READ_ALIASES, _mp4FreeformAtoms, _mp4AtomToWireKey;
1552
+ var init_properties = __esmMin((() => {
1553
+ init_additional_properties();
1554
+ init_basic_properties();
1555
+ init_general_extended_properties();
1556
+ init_specialized_properties();
1557
+ PROPERTIES = {
1558
+ ...BASIC_PROPERTIES,
1559
+ ...GENERAL_EXTENDED_PROPERTIES,
1560
+ ...SPECIALIZED_PROPERTIES,
1561
+ ...ADDITIONAL_PROPERTIES
1562
+ };
1563
+ _toTagLib = {};
1564
+ _fromTagLib = {};
1565
+ for (const [camelKey, meta] of Object.entries(PROPERTIES)) {
1566
+ const wireKey = meta.key;
1567
+ _toTagLib[camelKey] = wireKey;
1568
+ _fromTagLib[wireKey] = camelKey;
1569
+ }
1570
+ _toTagLib["year"] = "DATE";
1571
+ _toTagLib["track"] = "TRACKNUMBER";
1572
+ _fromTagLib["disc"] = "discNumber";
1573
+ READ_ALIASES = {
1574
+ "ALBUM ARTIST": "ALBUMARTIST",
1575
+ ALBUM_ARTIST: "ALBUMARTIST",
1576
+ ORGANIZATION: "LABEL",
1577
+ PUBLISHER: "LABEL",
1578
+ UPC: "BARCODE",
1579
+ EAN: "BARCODE",
1580
+ GTIN: "BARCODE",
1581
+ TOTALTRACKS: "TRACKTOTAL",
1582
+ TOTALDISCS: "DISCTOTAL",
1583
+ MUSICBRAINZ_ALBUMTYPE: "RELEASETYPE",
1584
+ "MusicBrainz Album Type": "RELEASETYPE",
1585
+ CONTENTADVISORY: "ITUNESADVISORY",
1586
+ EXPLICIT: "ITUNESADVISORY"
1587
+ };
1588
+ for (const [alias, canonical] of Object.entries(READ_ALIASES)) if (_fromTagLib[alias] === void 0) _fromTagLib[alias] = _fromTagLib[canonical];
1589
+ _mp4FreeformAtoms = {};
1590
+ for (const meta of Object.values(PROPERTIES)) {
1591
+ const { key, mappings } = meta;
1592
+ const atom = mappings?.mp4;
1593
+ if (typeof atom !== "string" || !atom.startsWith("----:")) continue;
1594
+ const bare = atom.slice(atom.lastIndexOf(":") + 1);
1595
+ if (bare === bare.toUpperCase()) continue;
1596
+ _mp4FreeformAtoms[key] = atom;
1597
+ const readKey = bare.toUpperCase();
1598
+ const camel = _fromTagLib[key];
1599
+ if (camel !== void 0 && _fromTagLib[readKey] === void 0) _fromTagLib[readKey] = camel;
1600
+ }
1601
+ _mp4AtomToWireKey = {};
1602
+ for (const meta of Object.values(PROPERTIES)) {
1603
+ const { key, mappings } = meta;
1604
+ const atom = mappings?.mp4;
1605
+ if (typeof atom !== "string" || atom.startsWith("----:")) continue;
1606
+ if (_mp4AtomToWireKey[atom] === void 0) _mp4AtomToWireKey[atom] = key;
1607
+ }
1608
+ }));
1609
+ //#endregion
1610
+ //#region src/taglib/mp4-item-names.ts
1611
+ var MP4_ITEM_NAMES_KEY;
1612
+ var init_mp4_item_names = __esmMin((() => {
1613
+ MP4_ITEM_NAMES_KEY = "_mp4ItemNames";
1614
+ }));
1615
+ //#endregion
1616
+ //#region src/taglib/mutable-tag-impl.ts
1617
+ function buildMutableTag(handle) {
1618
+ let data = handle.getTagData();
1619
+ const tag = {
1620
+ get title() {
1621
+ return data.title;
1622
+ },
1623
+ get artist() {
1624
+ return data.artist;
1625
+ },
1626
+ get album() {
1627
+ return data.album;
1628
+ },
1629
+ get comment() {
1630
+ return data.comment;
1631
+ },
1632
+ get genre() {
1633
+ return data.genre;
1634
+ },
1635
+ get year() {
1636
+ return data.year;
1637
+ },
1638
+ get track() {
1639
+ return data.track;
1640
+ },
1641
+ get date() {
1642
+ return handle.getProperty("DATE") || void 0;
1643
+ },
1644
+ setTitle: (value) => {
1645
+ handle.setTagData({ title: value });
1646
+ data = handle.getTagData();
1647
+ return tag;
1648
+ },
1649
+ setArtist: (value) => {
1650
+ handle.setTagData({ artist: value });
1651
+ data = handle.getTagData();
1652
+ return tag;
1653
+ },
1654
+ setAlbum: (value) => {
1655
+ handle.setTagData({ album: value });
1656
+ data = handle.getTagData();
1657
+ return tag;
1658
+ },
1659
+ setComment: (value) => {
1660
+ handle.setTagData({ comment: value });
1661
+ data = handle.getTagData();
1662
+ return tag;
1663
+ },
1664
+ setGenre: (value) => {
1665
+ handle.setTagData({ genre: value });
1666
+ data = handle.getTagData();
1667
+ return tag;
1668
+ },
1669
+ setYear: (value) => {
1670
+ handle.setTagData({ year: value });
1671
+ data = handle.getTagData();
1672
+ return tag;
1673
+ },
1674
+ setTrack: (value) => {
1675
+ const existing = value > 0 ? handle.getProperty(RAW_TRACK_WIRE_KEY) : "";
1676
+ const slash = existing.indexOf("/");
1677
+ if (slash !== -1) handle.setProperty(RAW_TRACK_WIRE_KEY, `${value}${existing.slice(slash)}`);
1678
+ else handle.setTagData({ track: value });
1679
+ data = handle.getTagData();
1680
+ return tag;
1681
+ },
1682
+ setDate: (value) => {
1683
+ if (value === "") handle.setTagData({ year: 0 });
1684
+ else handle.setProperty("DATE", value);
1685
+ data = handle.getTagData();
1686
+ return tag;
1687
+ }
1688
+ };
1689
+ return tag;
1690
+ }
1691
+ var RAW_TRACK_WIRE_KEY;
1692
+ var init_mutable_tag_impl = __esmMin((() => {
1693
+ init_properties();
1694
+ RAW_TRACK_WIRE_KEY = toTagLibKey("trackNumber");
1695
+ }));
1696
+ //#endregion
1697
+ //#region src/taglib/auto-dispose.ts
1698
+ function registerAutoDispose(target, handle) {
1699
+ registry.register(target, handle, target);
1700
+ }
1701
+ function unregisterAutoDispose(target) {
1702
+ registry.unregister(target);
1703
+ }
1704
+ var registry;
1705
+ var init_auto_dispose = __esmMin((() => {
1706
+ registry = new FinalizationRegistry((handle) => {
1707
+ handle.destroy();
1708
+ });
1709
+ }));
1710
+ //#endregion
1711
+ //#region \0@oxc-project+runtime@0.152.0/helpers/esm/typeof.js
1712
+ function _typeof(o) {
1713
+ "@babel/helpers - typeof";
1714
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1715
+ return typeof o;
1716
+ } : function(o) {
1717
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1718
+ }, _typeof(o);
1719
+ }
1720
+ var init_typeof = __esmMin((() => {}));
1721
+ //#endregion
1722
+ //#region \0@oxc-project+runtime@0.152.0/helpers/esm/toPrimitive.js
1723
+ function toPrimitive(t, r) {
1724
+ if ("object" != _typeof(t) || !t) return t;
1725
+ var e = t[Symbol.toPrimitive];
1726
+ if (void 0 !== e) {
1727
+ var i = e.call(t, r || "default");
1728
+ if ("object" != _typeof(i)) return i;
1729
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1730
+ }
1731
+ return ("string" === r ? String : Number)(t);
1732
+ }
1733
+ var init_toPrimitive = __esmMin((() => {
1734
+ init_typeof();
1735
+ }));
1736
+ //#endregion
1737
+ //#region \0@oxc-project+runtime@0.152.0/helpers/esm/toPropertyKey.js
1738
+ function toPropertyKey(t) {
1739
+ var i = toPrimitive(t, "string");
1740
+ return "symbol" == _typeof(i) ? i : i + "";
1741
+ }
1742
+ var init_toPropertyKey = __esmMin((() => {
1743
+ init_typeof();
1744
+ init_toPrimitive();
1745
+ }));
1746
+ //#endregion
1747
+ //#region \0@oxc-project+runtime@0.152.0/helpers/esm/defineProperty.js
1748
+ function _defineProperty(e, r, t) {
1749
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1750
+ value: t,
1751
+ enumerable: !0,
1752
+ configurable: !0,
1753
+ writable: !0
1754
+ }) : e[r] = t, e;
1755
+ }
1756
+ var init_defineProperty = __esmMin((() => {
1757
+ init_toPropertyKey();
1758
+ }));
1759
+ //#endregion
1760
+ //#region src/taglib/audio-file-base.ts
1761
+ var _Symbol$dispose, LYRICS_PROPERTY_KEY, LYRICS_WIRE_KEY, EMPTY_KEY_SET, BaseAudioFileImpl;
1762
+ var init_audio_file_base = __esmMin((() => {
1763
+ init_properties();
1764
+ init_errors();
1765
+ init_mp4_item_names();
1766
+ init_mutable_tag_impl();
1767
+ init_auto_dispose();
1768
+ init_defineProperty();
1769
+ LYRICS_PROPERTY_KEY = "lyrics";
1770
+ LYRICS_WIRE_KEY = toTagLibKey(LYRICS_PROPERTY_KEY);
1771
+ EMPTY_KEY_SET = /* @__PURE__ */ new Set();
1772
+ _Symbol$dispose = Symbol.dispose;
1773
+ BaseAudioFileImpl = class {
1774
+ constructor(module, fileHandle, sourcePath, originalSource, isPartiallyLoaded = false, partialLoadOptions) {
1775
+ this.module = module;
1776
+ _defineProperty(this, "fileHandle", void 0);
1777
+ _defineProperty(this, "cachedAudioProperties", null);
1778
+ _defineProperty(this, "sourcePath", void 0);
1779
+ _defineProperty(this, "originalSource", void 0);
1780
+ _defineProperty(this, "isPartiallyLoaded", false);
1781
+ _defineProperty(this, "partialLoadOptions", void 0);
1782
+ _defineProperty(this, "partialKeysAtLoad", void 0);
1783
+ this.fileHandle = fileHandle;
1784
+ this.sourcePath = sourcePath;
1785
+ this.originalSource = originalSource;
1786
+ this.isPartiallyLoaded = isPartiallyLoaded;
1787
+ this.partialLoadOptions = partialLoadOptions;
1788
+ this.partialKeysAtLoad = isPartiallyLoaded ? new Set(Object.keys(fileHandle.getProperties())) : void 0;
1789
+ registerAutoDispose(this, fileHandle);
1790
+ }
1791
+ partialDeletedPropertyKeys() {
1792
+ if (!this.partialKeysAtLoad) return EMPTY_KEY_SET;
1793
+ const current = new Set(Object.keys(this.handle.getProperties()));
1794
+ const deleted = /* @__PURE__ */ new Set();
1795
+ for (const key of this.partialKeysAtLoad) if (key !== LYRICS_WIRE_KEY && !current.has(key)) deleted.add(key);
1796
+ return deleted;
1797
+ }
1798
+ get handle() {
1799
+ if (!this.fileHandle) throw new MetadataError("read", "File handle has been disposed");
1800
+ return this.fileHandle;
1801
+ }
1802
+ getFormat() {
1803
+ return this.handle.getFormat();
1804
+ }
1805
+ isFormat(format) {
1806
+ return this.getFormat() === format;
1807
+ }
1808
+ tag() {
1809
+ return buildMutableTag(this.handle);
1810
+ }
1811
+ audioProperties() {
1812
+ if (!this.cachedAudioProperties) this.cachedAudioProperties = this.handle.getAudioProperties() ?? null;
1813
+ return this.cachedAudioProperties ?? void 0;
1814
+ }
1815
+ properties() {
1816
+ const remapped = remapKeysFromTagLib(this.handle.getProperties());
1817
+ delete remapped[LYRICS_PROPERTY_KEY];
1818
+ return remapped;
1819
+ }
1820
+ setProperties(properties) {
1821
+ const translated = {};
1822
+ for (const [key, values] of Object.entries(properties)) if (values !== void 0) translated[toTagLibKey(fromTagLibKey(key))] = values;
1823
+ if (!(LYRICS_WIRE_KEY in translated)) {
1824
+ const existing = this.handle.getProperties()[LYRICS_WIRE_KEY];
1825
+ if (existing !== void 0) translated[LYRICS_WIRE_KEY] = existing;
1826
+ }
1827
+ const atomNames = mp4FreeformAtomNames(Object.keys(translated));
1828
+ if (atomNames.length > 0) translated[MP4_ITEM_NAMES_KEY] = atomNames;
1829
+ this.handle.setProperties(translated);
1830
+ }
1831
+ getProperty(key) {
1832
+ const wireKey = toTagLibKey(fromTagLibKey(key));
1833
+ const values = this.handle.getProperties()[wireKey]?.filter((v) => v !== "");
1834
+ if (values !== void 0 && values.length > 0) return values;
1835
+ if (!this.isMP4()) return void 0;
1836
+ const remapped = this.properties()[key]?.filter((v) => v !== "");
1837
+ return remapped !== void 0 && remapped.length > 0 ? remapped : void 0;
1838
+ }
1839
+ setProperty(key, value) {
1840
+ const wireKey = toTagLibKey(fromTagLibKey(key));
1841
+ const atomNames = mp4FreeformAtomNames([wireKey]);
1842
+ if (atomNames.length > 0 && this.isMP4()) {
1843
+ if (value === "") {
1844
+ const prior = this.handle.getMp4ItemRemovals?.() ?? [];
1845
+ this.handle.setMp4ItemRemovals?.([.../* @__PURE__ */ new Set([...prior, ...atomNames])]);
1846
+ if (this.module.isWasi) this.handle.setProperties({
1847
+ ...this.handle.getProperties(),
1848
+ [wireKey]: []
1849
+ });
1850
+ else {
1851
+ const rest = { ...this.handle.getProperties() };
1852
+ delete rest[wireKey];
1853
+ this.handle.setProperties(rest);
1854
+ }
1855
+ return;
1856
+ }
1857
+ this.handle.setProperties({
1858
+ ...this.handle.getProperties(),
1859
+ [wireKey]: [value],
1860
+ [MP4_ITEM_NAMES_KEY]: atomNames
1861
+ });
1862
+ return;
1863
+ }
1864
+ this.handle.setProperty(wireKey, value);
1865
+ }
1866
+ removeProperty(key) {
1867
+ this.setProperty(key, "");
1868
+ }
1869
+ isMP4() {
1870
+ return this.handle.isMP4();
1871
+ }
1872
+ getMP4Item(key) {
1873
+ if (!this.isMP4()) throw new UnsupportedFormatError(this.getFormat(), ["MP4", "M4A"]);
1874
+ const wireKey = mp4AtomWireKey(key);
1875
+ const value = wireKey !== void 0 ? this.handle.getProperty(wireKey) : this.handle.getMP4Item(key);
1876
+ return value === "" ? void 0 : value;
1877
+ }
1878
+ setMP4Item(key, value) {
1879
+ if (!this.isMP4()) throw new UnsupportedFormatError(this.getFormat(), ["MP4", "M4A"]);
1880
+ const wireKey = mp4AtomWireKey(key);
1881
+ if (wireKey !== void 0) {
1882
+ this.handle.setProperty(wireKey, value);
1883
+ return;
1884
+ }
1885
+ this.handle.setMP4Item(key, value);
1886
+ }
1887
+ removeMP4Item(key) {
1888
+ if (!this.isMP4()) throw new UnsupportedFormatError(this.getFormat(), ["MP4", "M4A"]);
1889
+ this.handle.removeMP4Item(key);
1890
+ }
1891
+ isValid() {
1892
+ return this.handle.isValid();
1893
+ }
1894
+ dispose() {
1895
+ unregisterAutoDispose(this);
1896
+ if (this.fileHandle) {
1897
+ this.fileHandle.destroy();
1898
+ this.fileHandle = null;
1899
+ this.cachedAudioProperties = null;
1900
+ }
1901
+ }
1902
+ [_Symbol$dispose]() {
1903
+ this.dispose();
1904
+ }
1905
+ };
1906
+ }));
1907
+ //#endregion
1908
+ //#region src/taglib/metadata-extent.ts
1909
+ function be32(b, offset) {
1910
+ return (b[offset] << 24 | b[offset + 1] << 16 | b[offset + 2] << 8 | b[offset + 3]) >>> 0;
1911
+ }
1912
+ function startsWith(bytes, magic, at = 0) {
1913
+ if (bytes.length < at + magic.length) return false;
1914
+ for (let i = 0; i < magic.length; i++) if (bytes[at + i] !== magic.charCodeAt(i)) return false;
1915
+ return true;
1916
+ }
1917
+ function id3v2End(bytes) {
1918
+ if (!startsWith(bytes, "ID3") || bytes.length < 10) return void 0;
1919
+ const size = bytes[6] << 21 | bytes[7] << 14 | bytes[8] << 7 | bytes[9];
1920
+ const hasFooter = (bytes[5] & 16) !== 0;
1921
+ return 10 + size + (hasFooter ? 10 : 0);
1922
+ }
1923
+ function flacEnd(bytes, limit, start) {
1924
+ let offset = start + 4;
1925
+ for (;;) {
1926
+ if (offset + 4 > bytes.length) return void 0;
1927
+ const isLast = (bytes[offset] & 128) !== 0;
1928
+ const length = bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3];
1929
+ offset += 4 + length;
1930
+ if (offset > limit) return offset;
1931
+ if (isLast) return offset;
1932
+ }
1933
+ }
1934
+ function flacMarkerOffset(bytes) {
1935
+ const at = startsWith(bytes, "ID3") ? id3v2End(bytes) : 0;
1936
+ if (at === void 0) return void 0;
1937
+ return startsWith(bytes, "fLaC", at) ? at : void 0;
1938
+ }
1939
+ function flacAudioStart(bytes) {
1940
+ const at = flacMarkerOffset(bytes);
1941
+ if (at === void 0) return void 0;
1942
+ return flacEnd(bytes, bytes.length, at);
1943
+ }
1944
+ function mp4MoovEnd(bytes, limit, start) {
1945
+ let offset = start;
1946
+ const readable = Math.min(bytes.length, limit);
1947
+ while (offset + 8 <= readable) {
1948
+ const size = be32(bytes, offset);
1949
+ const type = String.fromCharCode(bytes[offset + 4], bytes[offset + 5], bytes[offset + 6], bytes[offset + 7]);
1950
+ if (size < 8) return void 0;
1951
+ if (type === "moov") return offset + size;
1952
+ offset += size;
1953
+ }
1954
+ }
1955
+ function oggMetadataEnd(bytes, limit, start) {
1956
+ let offset = start;
1957
+ let packetsCompleted = 0;
1958
+ let first = true;
1959
+ for (;;) {
1960
+ if (offset + 27 > bytes.length || !startsWith(bytes, "OggS", offset)) return;
1961
+ const segmentCount = bytes[offset + 26];
1962
+ const tableStart = offset + 27;
1963
+ if (tableStart + segmentCount > bytes.length) return void 0;
1964
+ let payload = 0;
1965
+ for (let i = 0; i < segmentCount; i++) {
1966
+ const segment = bytes[tableStart + i];
1967
+ payload += segment;
1968
+ if (segment < 255) packetsCompleted++;
1969
+ }
1970
+ if (first) {
1971
+ const payloadStart = tableStart + segmentCount;
1972
+ if (payloadStart + 5 > bytes.length) return void 0;
1973
+ if (bytes[payloadStart] === 127 && startsWith(bytes, "FLAC", payloadStart + 1)) return;
1974
+ first = false;
1975
+ }
1976
+ offset = tableStart + segmentCount + payload;
1977
+ if (packetsCompleted >= 2 || offset > limit) return offset;
1978
+ }
1979
+ }
1980
+ function mpegFrameLength(bytes, at) {
1981
+ if (bytes.length < at + 4) return 0;
1982
+ if (bytes[at] !== 255 || (bytes[at + 1] & 224) !== 224) return 0;
1983
+ const version = bytes[at + 1] >> 3 & 3;
1984
+ const layer = bytes[at + 1] >> 1 & 3;
1985
+ if (version === 1 || layer === 0) return 0;
1986
+ const bitrateIndex = bytes[at + 2] >> 4 & 15;
1987
+ const sampleRateIndex = bytes[at + 2] >> 2 & 3;
1988
+ if (bitrateIndex === 0 || bitrateIndex === 15 || sampleRateIndex === 3) return 0;
1989
+ const mpeg1 = version === 3;
1990
+ const layerIndex = layer ^ 3;
1991
+ const bitrate = MPEG_BITRATES[mpeg1 ? 0 : 1][layerIndex][bitrateIndex];
1992
+ const sampleRate = MPEG_SAMPLE_RATES[mpeg1 ? 0 : version === 2 ? 1 : 2][sampleRateIndex];
1993
+ let frameLength = Math.floor((layerIndex === 2 ? mpeg1 ? 1152 : 576 : layerIndex === 1 ? 1152 : 384) * bitrate * 125 / sampleRate);
1994
+ if ((bytes[at + 2] & 2) !== 0) frameLength += layerIndex === 0 ? 4 : 1;
1995
+ return frameLength === 0 ? 0 : frameLength;
1996
+ }
1997
+ function isMpegFrameSync(bytes, at = 0) {
1998
+ const frameLength = mpegFrameLength(bytes, at);
1999
+ if (frameLength === 0) return false;
2000
+ const next = at + frameLength;
2001
+ if (bytes.length < next + 4) return false;
2002
+ const mask = 4294839296;
2003
+ return ((bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0 & mask) >>> 0 === ((bytes[next] << 24 | bytes[next + 1] << 16 | bytes[next + 2] << 8 | bytes[next + 3]) >>> 0 & mask) >>> 0;
2004
+ }
2005
+ function containerEnd(bytes, at, limit) {
2006
+ if (at >= bytes.length) return bytes.length < limit ? null : void 0;
2007
+ if (at + 8 > bytes.length) return void 0;
2008
+ if (startsWith(bytes, "fLaC", at)) return flacEnd(bytes, limit, at);
2009
+ if (startsWith(bytes, "ftyp", at + 4)) return mp4MoovEnd(bytes, limit, at);
2010
+ if (startsWith(bytes, "OggS", at)) return oggMetadataEnd(bytes, limit, at);
2011
+ return null;
2012
+ }
2013
+ function metadataFitsInHeader(header, limit) {
2014
+ let end;
2015
+ if (startsWith(header, "ID3")) {
2016
+ const tagEnd = id3v2End(header);
2017
+ if (tagEnd === void 0) return false;
2018
+ end = tagEnd;
2019
+ if (tagEnd <= limit) {
2020
+ const behind = containerEnd(header, tagEnd, limit);
2021
+ if (behind === void 0) return false;
2022
+ if (behind !== null) end = behind;
2023
+ }
2024
+ } else {
2025
+ const container = containerEnd(header, 0, limit);
2026
+ if (container === null) end = isMpegFrameSync(header) ? 0 : void 0;
2027
+ else end = container;
2028
+ }
2029
+ if (end === void 0 || end > header.length) return false;
2030
+ return end <= limit;
2031
+ }
2032
+ function trailerFitsInFooter(tail, footerSize) {
2033
+ if (tail.length < Math.min(footerSize, 32)) return false;
2034
+ for (const offsetFromEnd of [32, 160]) {
2035
+ const at = tail.length - offsetFromEnd;
2036
+ if (at < 0 || !startsWith(tail, "APETAGEX", at)) continue;
2037
+ const size = (tail[at + 12] | tail[at + 13] << 8 | tail[at + 14] << 16 | tail[at + 15] << 24) >>> 0;
2038
+ const trailing = offsetFromEnd === 32 ? 0 : 128;
2039
+ if (size + 32 + trailing > footerSize) return false;
2040
+ }
2041
+ return true;
2042
+ }
2043
+ var MPEG_BITRATES, MPEG_SAMPLE_RATES;
2044
+ var init_metadata_extent = __esmMin((() => {
2045
+ MPEG_BITRATES = [[
2046
+ [
2047
+ 0,
2048
+ 32,
2049
+ 64,
2050
+ 96,
2051
+ 128,
2052
+ 160,
2053
+ 192,
2054
+ 224,
2055
+ 256,
2056
+ 288,
2057
+ 320,
2058
+ 352,
2059
+ 384,
2060
+ 416,
2061
+ 448,
2062
+ 0
2063
+ ],
2064
+ [
2065
+ 0,
2066
+ 32,
2067
+ 48,
2068
+ 56,
2069
+ 64,
2070
+ 80,
2071
+ 96,
2072
+ 112,
2073
+ 128,
2074
+ 160,
2075
+ 192,
2076
+ 224,
2077
+ 256,
2078
+ 320,
2079
+ 384,
2080
+ 0
2081
+ ],
2082
+ [
2083
+ 0,
2084
+ 32,
2085
+ 40,
2086
+ 48,
2087
+ 56,
2088
+ 64,
2089
+ 80,
2090
+ 96,
2091
+ 112,
2092
+ 128,
2093
+ 160,
2094
+ 192,
2095
+ 224,
2096
+ 256,
2097
+ 320,
2098
+ 0
2099
+ ]
2100
+ ], [
2101
+ [
2102
+ 0,
2103
+ 32,
2104
+ 48,
2105
+ 56,
2106
+ 64,
2107
+ 80,
2108
+ 96,
2109
+ 112,
2110
+ 128,
2111
+ 144,
2112
+ 160,
2113
+ 176,
2114
+ 192,
2115
+ 224,
2116
+ 256,
2117
+ 0
2118
+ ],
2119
+ [
2120
+ 0,
2121
+ 8,
2122
+ 16,
2123
+ 24,
2124
+ 32,
2125
+ 40,
2126
+ 48,
2127
+ 56,
2128
+ 64,
2129
+ 80,
2130
+ 96,
2131
+ 112,
2132
+ 128,
2133
+ 144,
2134
+ 160,
2135
+ 0
2136
+ ],
2137
+ [
2138
+ 0,
2139
+ 8,
2140
+ 16,
2141
+ 24,
2142
+ 32,
2143
+ 40,
2144
+ 48,
2145
+ 56,
2146
+ 64,
2147
+ 80,
2148
+ 96,
2149
+ 112,
2150
+ 128,
2151
+ 144,
2152
+ 160,
2153
+ 0
2154
+ ]
2155
+ ]];
2156
+ MPEG_SAMPLE_RATES = [
2157
+ [
2158
+ 44100,
2159
+ 48e3,
2160
+ 32e3
2161
+ ],
2162
+ [
2163
+ 22050,
2164
+ 24e3,
2165
+ 16e3
2166
+ ],
2167
+ [
2168
+ 11025,
2169
+ 12e3,
2170
+ 8e3
2171
+ ]
2172
+ ];
2173
+ }));
2174
+ //#endregion
2175
+ //#region src/taglib/media-ranges.ts
2176
+ function adtsFrameLength(bytes, at) {
2177
+ if (bytes.length < at + 7) return 0;
2178
+ if (bytes[at] !== 255 || (bytes[at + 1] & 246) !== 240) return 0;
2179
+ const length = (bytes[at + 3] & 3) << 11 | bytes[at + 4] << 3 | bytes[at + 5] >> 5;
2180
+ return length >= 7 ? length : 0;
2181
+ }
2182
+ function trailingTagStart(bytes, end = bytes.length) {
2183
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
2184
+ let at = Math.max(0, Math.min(end, bytes.length));
2185
+ for (;;) {
2186
+ if (at >= 128 && text(bytes, at - 128, 3) === "TAG") {
2187
+ at -= 128;
2188
+ continue;
2189
+ }
2190
+ if (at >= 32 && text(bytes, at - 32, 8) === "APETAGEX") {
2191
+ const size = view.getUint32(at - 32 + 12, true);
2192
+ const flags = view.getUint32(at - 32 + 20, true);
2193
+ const start = at - size - ((flags & 2147483648) !== 0 ? 32 : 0);
2194
+ if (start < 0 || start >= at) return at;
2195
+ at = start;
2196
+ continue;
2197
+ }
2198
+ return at;
2199
+ }
2200
+ }
2201
+ function firstFrame(bytes) {
2202
+ const from = id3v2End(bytes) ?? 0;
2203
+ const limit = Math.min(bytes.length - 6, from + MPEG_SCAN_LIMIT);
2204
+ for (let o = from; o < limit; o++) {
2205
+ const len = frameLengthAt(bytes, o);
2206
+ if (len > 0 && frameLengthAt(bytes, o + len) > 0) return o;
2207
+ }
2208
+ return -1;
2209
+ }
2210
+ function forwardLastFrame(bytes, from, end) {
2211
+ let o = from;
2212
+ let start = -1;
2213
+ let length = 0;
2214
+ let frames = 0;
2215
+ while (o + 6 <= end) {
2216
+ const len = frameLengthAt(bytes, o);
2217
+ if (len === 0 || o + len > end) break;
2218
+ start = o;
2219
+ length = len;
2220
+ frames++;
2221
+ o += len;
2222
+ }
2223
+ return {
2224
+ start,
2225
+ length,
2226
+ frames
2227
+ };
2228
+ }
2229
+ function walkMpeg(bytes) {
2230
+ const from = firstFrame(bytes);
2231
+ if (from < 0) return fallback("no valid first frame");
2232
+ const last = forwardLastFrame(bytes, from, trailingTagStart(bytes));
2233
+ if (last.start < 0) return fallback("no valid frames");
2234
+ return {
2235
+ kind: "ranges",
2236
+ ranges: [{
2237
+ offset: from,
2238
+ length: last.start + last.length - from
2239
+ }],
2240
+ detail: `first=${from} last=${last.start}+${last.length} frames=${last.frames}`
2241
+ };
2242
+ }
2243
+ function flacStreamInfoMd5(bytes) {
2244
+ const marker = flacMarkerOffset(bytes);
2245
+ if (marker === void 0) return void 0;
2246
+ const header = marker + 4;
2247
+ if (header + 4 > bytes.length) return void 0;
2248
+ if ((bytes[header] & 127) !== 0) return void 0;
2249
+ if ((bytes[header + 1] << 16 | bytes[header + 2] << 8 | bytes[header + 3]) < 34) return void 0;
2250
+ const payload = header + 4;
2251
+ if (payload + 34 > bytes.length) return void 0;
2252
+ let hex = "";
2253
+ for (const byte of bytes.subarray(payload + 18, payload + 34)) hex += byte.toString(16).padStart(2, "0");
2254
+ return hex;
2255
+ }
2256
+ function walkFlac(bytes) {
2257
+ const start = flacAudioStart(bytes);
2258
+ if (start === void 0) return fallback("no fLaC marker");
2259
+ const end = trailingTagStart(bytes);
2260
+ if (end <= start) return fallback("no audio bytes");
2261
+ return {
2262
+ kind: "ranges",
2263
+ ranges: [{
2264
+ offset: start,
2265
+ length: end - start
2266
+ }],
2267
+ detail: `audioStart=${start} end=${end}`
2268
+ };
2269
+ }
2270
+ function atomLength(bytes, view, o) {
2271
+ const size = view.getUint32(o, false);
2272
+ if (size === 0) return {
2273
+ length: bytes.length - o,
2274
+ headerSize: 8
2275
+ };
2276
+ if (size === 1) {
2277
+ if (o + 16 > bytes.length) return void 0;
2278
+ const big = view.getBigUint64(o + 8, false);
2279
+ if (big > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
2280
+ return {
2281
+ length: Number(big),
2282
+ headerSize: 16
2283
+ };
2284
+ }
2285
+ return {
2286
+ length: size,
2287
+ headerSize: 8
2288
+ };
2289
+ }
2290
+ function walkMp4(bytes) {
2291
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
2292
+ const ranges = [];
2293
+ let o = 0;
2294
+ while (o + 8 <= bytes.length) {
2295
+ const type = text(bytes, o + 4, 4);
2296
+ const atom = atomLength(bytes, view, o);
2297
+ if (atom === void 0) return fallback(`malformed ${type} size`);
2298
+ if (atom.length < atom.headerSize) return fallback(`malformed ${type} size`);
2299
+ if (o + atom.length > bytes.length) return fallback(`oversized ${type}`);
2300
+ if (type === "mdat" && atom.length > atom.headerSize) ranges.push({
2301
+ offset: o + atom.headerSize,
2302
+ length: atom.length - atom.headerSize
2303
+ });
2304
+ o += atom.length;
2305
+ }
2306
+ if (o !== bytes.length) return fallback("trailing bytes after the last atom");
2307
+ if (ranges.length === 0) return fallback("no non-empty mdat");
2308
+ return {
2309
+ kind: "ranges",
2310
+ ranges,
2311
+ detail: `${ranges.length} mdat(s)`
2312
+ };
2313
+ }
2314
+ function walkWav(bytes) {
2315
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
2316
+ if (text(bytes, 0, 4) !== "RIFF") return fallback("not RIFF");
2317
+ if (text(bytes, 8, 4) !== "WAVE") return fallback("not WAVE");
2318
+ const ranges = [];
2319
+ let o = 12;
2320
+ while (o + 8 <= bytes.length) {
2321
+ const id = text(bytes, o, 4);
2322
+ const size = view.getUint32(o + 4, true);
2323
+ const dataStart = o + 8;
2324
+ if (dataStart + size > bytes.length) return fallback(`truncated ${id}`);
2325
+ if (id === "data" && size > 0) ranges.push({
2326
+ offset: dataStart,
2327
+ length: size
2328
+ });
2329
+ o = dataStart + size + size % 2;
2330
+ }
2331
+ if (ranges.length === 0) return fallback("no data chunk");
2332
+ return {
2333
+ kind: "ranges",
2334
+ ranges,
2335
+ detail: `${ranges.length} data chunk(s)`
2336
+ };
2337
+ }
2338
+ function mediaRanges(format, bytes) {
2339
+ const walked = (() => {
2340
+ switch (format.toUpperCase()) {
2341
+ case "MP3":
2342
+ case "AAC": return walkMpeg(bytes);
2343
+ case "FLAC": return walkFlac(bytes);
2344
+ case "MP4":
2345
+ case "M4A": return walkMp4(bytes);
2346
+ case "WAV": return walkWav(bytes);
2347
+ default: return {
2348
+ kind: "fallback",
2349
+ ranges: [],
2350
+ detail: "format not covered"
2351
+ };
2352
+ }
2353
+ })();
2354
+ if (walked.kind === "fallback") return {
2355
+ kind: "fallback",
2356
+ ranges: [{
2357
+ offset: 0,
2358
+ length: bytes.length
2359
+ }],
2360
+ detail: `${walked.detail} → whole file`
2361
+ };
2362
+ return walked;
2363
+ }
2364
+ var decoder, text, fallback, frameLengthAt, MPEG_SCAN_LIMIT;
2365
+ var init_media_ranges = __esmMin((() => {
2366
+ init_metadata_extent();
2367
+ decoder = new TextDecoder();
2368
+ text = (b, o, n) => decoder.decode(b.subarray(o, o + n));
2369
+ fallback = (detail) => ({
2370
+ kind: "fallback",
2371
+ ranges: [],
2372
+ detail
2373
+ });
2374
+ frameLengthAt = (bytes, at) => mpegFrameLength(bytes, at) || adtsFrameLength(bytes, at);
2375
+ MPEG_SCAN_LIMIT = 65536;
2376
+ }));
2377
+ //#endregion
2378
+ //#region src/taglib/audio-file-checksum.ts
2379
+ async function fileBytes(source, io) {
2380
+ if (source.path) return await io.readFile(source.path);
2381
+ if (source.blob) return new Uint8Array(await source.blob.arrayBuffer());
2382
+ if (!source.partiallyLoaded && source.bytes.length > 0) return source.bytes;
2383
+ throw new MetadataError("read", "the handle holds no file bytes and has no readable source; a partial handle that has been saved drops its source — checksum the saved path instead");
2384
+ }
2385
+ function joinRanges(bytes, ranges) {
2386
+ const total = ranges.reduce((n, r) => n + r.length, 0);
2387
+ const overrun = ranges.find((r) => r.offset + r.length > bytes.length);
2388
+ if (overrun || total > bytes.length) throw new MetadataError("read", `range walk overran the buffer (${overrun ? `range ${overrun.offset}+${overrun.length}` : `${total} bytes`} past the ${bytes.length}-byte buffer)`);
2389
+ if (ranges.length === 1) {
2390
+ const only = ranges[0];
2391
+ const view = bytes.subarray(only.offset, only.offset + only.length);
2392
+ return view.buffer instanceof ArrayBuffer ? view : new Uint8Array(view);
2393
+ }
2394
+ const out = new Uint8Array(total);
2395
+ let at = 0;
2396
+ for (const r of ranges) {
2397
+ out.set(bytes.subarray(r.offset, r.offset + r.length), at);
2398
+ at += r.length;
2399
+ }
2400
+ return out;
2401
+ }
2402
+ async function mediaChecksum(source, format, io, options = {}) {
2403
+ if (options.basis === "pcm") {
2404
+ if (format.toUpperCase() !== "FLAC") throw new UnsupportedFormatError(format, ["FLAC"], { operation: "media checksum (basis: pcm)" });
2405
+ const windowed = source.bytes.length > 0 ? source.bytes : source.path && io.readPartial ? await io.readPartial(source.path, STREAMINFO_WINDOW, 0) : void 0;
2406
+ let md5 = windowed === void 0 ? void 0 : flacStreamInfoMd5(windowed);
2407
+ if (md5 === void 0 && windowed !== source.bytes) md5 = flacStreamInfoMd5(await fileBytes(source, io));
2408
+ if (md5 === void 0) throw new MetadataError("read", "STREAMINFO digest unavailable");
2409
+ return {
2410
+ source: "flac-streaminfo-md5",
2411
+ algorithm: "md5",
2412
+ hex: md5,
2413
+ bytesHashed: 16
2414
+ };
2415
+ }
2416
+ const bytes = await fileBytes(source, io);
2417
+ const walk = mediaRanges(format, bytes);
2418
+ const payload = joinRanges(bytes, walk.ranges);
2419
+ const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", payload));
2420
+ let hex = "";
2421
+ for (const byte of digest) hex += byte.toString(16).padStart(2, "0");
2422
+ return {
2423
+ source: walk.kind === "ranges" ? "audio-payload" : "file",
2424
+ algorithm: "sha256",
2425
+ hex,
2426
+ bytesHashed: payload.length
2427
+ };
2428
+ }
2429
+ var STREAMINFO_WINDOW;
2430
+ var init_audio_file_checksum = __esmMin((() => {
2431
+ init_media_ranges();
2432
+ init_errors();
2433
+ STREAMINFO_WINDOW = 65536;
2434
+ }));
2435
+ //#endregion
2436
+ //#region src/utils/file.ts
2437
+ async function readFileData(file) {
2438
+ if (file instanceof Uint8Array) return file;
2439
+ if (file instanceof ArrayBuffer) return new Uint8Array(file);
2440
+ if (typeof File !== "undefined" && file instanceof File) return new Uint8Array(await file.arrayBuffer());
2441
+ if (typeof file === "string") try {
2442
+ return await getPlatformIO().readFile(file);
2443
+ } catch (error) {
2444
+ if (error instanceof EnvironmentError) throw error;
2445
+ throw new FileOperationError("read", error.message, file);
2446
+ }
2447
+ const inputType = Object.prototype.toString.call(file);
2448
+ throw new FileOperationError("read", `Invalid file input type: ${inputType}. Expected string path, Uint8Array, ArrayBuffer, or File object.`);
2449
+ }
2450
+ async function getFileSize(path) {
2451
+ try {
2452
+ return (await getPlatformIO().stat(path)).size;
2453
+ } catch (error) {
2454
+ if (error instanceof EnvironmentError) throw error;
2455
+ throw new FileOperationError("stat", error.message, path);
2456
+ }
2457
+ }
2458
+ async function readPartialFileData(path, headerSize, footerSize) {
2459
+ const io = getPlatformIO();
2460
+ if (!io.readPartial) throw new EnvironmentError("current runtime", "does not support partial file reading", "filesystem access with seek support");
2461
+ try {
2462
+ return await io.readPartial(path, headerSize, footerSize);
2463
+ } catch (error) {
2464
+ if (error instanceof EnvironmentError) throw error;
2465
+ throw new FileOperationError("read", error.message, path);
2466
+ }
2467
+ }
2468
+ var init_file = __esmMin((() => {
2469
+ init_errors();
2470
+ init__taglib_platform_io_stub();
2471
+ }));
2472
+ //#endregion
2473
+ //#region src/taglib/embind-adapter.ts
2474
+ function isValidBitrateMode(value) {
2475
+ return value === "CBR" || value === "VBR" || value === "ABR";
2476
+ }
2477
+ function wrapEmbindHandle(raw) {
2478
+ const stagedId3v2Frames = {};
2479
+ let destroyed = false;
2480
+ const overrides = {
2481
+ getTagData() {
2482
+ const tw = raw.getTag();
2483
+ return {
2484
+ title: tw.title(),
2485
+ artist: tw.artist(),
2486
+ album: tw.album(),
2487
+ comment: tw.comment(),
2488
+ genre: tw.genre(),
2489
+ year: tw.year(),
2490
+ track: tw.track()
2491
+ };
2492
+ },
2493
+ setTagData(data) {
2494
+ const tw = raw.getTag();
2495
+ if (data.title !== void 0) tw.setTitle(data.title);
2496
+ if (data.artist !== void 0) tw.setArtist(data.artist);
2497
+ if (data.album !== void 0) tw.setAlbum(data.album);
2498
+ if (data.comment !== void 0) tw.setComment(data.comment);
2499
+ if (data.genre !== void 0) tw.setGenre(data.genre);
2500
+ if (data.year !== void 0) tw.setYear(data.year);
2501
+ if (data.track !== void 0) tw.setTrack(data.track);
2502
+ },
2503
+ getBextData() {
2504
+ const v = raw.getBextData();
2505
+ if (v === void 0 || v === null) return void 0;
2506
+ const u8 = v instanceof Uint8Array ? v : new Uint8Array(v);
2507
+ return u8.length > 0 ? u8 : void 0;
2508
+ },
2509
+ setBextData(data) {
2510
+ raw.setBextData(data ?? null);
2511
+ },
2512
+ getIxml() {
2513
+ const v = raw.getIxml();
2514
+ return typeof v === "string" && v.length > 0 ? v : void 0;
2515
+ },
2516
+ setIxml(data) {
2517
+ raw.setIxml(data ?? null);
2518
+ },
2519
+ getLyrics() {
2520
+ return (raw.getProperties()["LYRICS"] ?? []).map((text) => ({
2521
+ text,
2522
+ description: "",
2523
+ language: ""
2524
+ }));
2525
+ },
2526
+ setLyrics(lyrics) {
2527
+ const handle = raw;
2528
+ const props = handle.getProperties();
2529
+ if (lyrics.length > 0) props["LYRICS"] = lyrics.map((l) => l.text);
2530
+ else delete props["LYRICS"];
2531
+ handle.setProperties(props);
2532
+ },
2533
+ setId3v2Frames(id, data) {
2534
+ stagedId3v2Frames[id] = data.map((d) => new Uint8Array(d));
2535
+ raw.setId3v2Frames(id, data);
2536
+ },
2537
+ removeId3v2Frames(id) {
2538
+ stagedId3v2Frames[id] = [];
2539
+ raw.removeId3v2Frames(id);
2540
+ },
2541
+ getStagedId3v2Frames() {
2542
+ return Object.keys(stagedId3v2Frames).length > 0 ? { ...stagedId3v2Frames } : void 0;
2543
+ },
2544
+ hasId3Tags() {
2545
+ const v = raw.hasId3Tags();
2546
+ if (!v || typeof v !== "object") return {
2547
+ v1: false,
2548
+ v2: false
2549
+ };
2550
+ const o = v;
2551
+ return {
2552
+ v1: o.v1 === true,
2553
+ v2: o.v2 === true
2554
+ };
2555
+ },
2556
+ stripId3Tags(opts) {
2557
+ raw.stripId3Tags(opts);
2558
+ },
2559
+ destroy() {
2560
+ if (destroyed) return;
2561
+ destroyed = true;
2562
+ raw.destroy();
2563
+ },
2564
+ get destroyed() {
2565
+ return destroyed;
2566
+ },
2567
+ setMp4ItemRemovals(removals) {
2568
+ const handle = raw;
2569
+ for (const name of removals) handle.removeMP4Item(name);
2570
+ },
2571
+ getAudioProperties() {
2572
+ const pw = raw.getAudioProperties();
2573
+ if (!pw) return null;
2574
+ const containerFormat = pw.containerFormat() || "unknown";
2575
+ const codec = pw.codec() || "unknown";
2576
+ const mpegVersion = pw.mpegVersion();
2577
+ const formatVersion = pw.formatVersion();
2578
+ const bitrateMode = pw.bitrateMode();
2579
+ return {
2580
+ duration: pw.lengthInSeconds(),
2581
+ durationMs: pw.lengthInMilliseconds(),
2582
+ bitrate: pw.bitrate(),
2583
+ sampleRate: pw.sampleRate(),
2584
+ channels: pw.channels(),
2585
+ bitsPerSample: pw.bitsPerSample(),
2586
+ codec,
2587
+ containerFormat,
2588
+ isLossless: pw.isLossless(),
2589
+ ...mpegVersion > 0 ? {
2590
+ mpegVersion,
2591
+ mpegLayer: pw.mpegLayer()
2592
+ } : {},
2593
+ ...containerFormat === "MP4" || containerFormat === "ASF" ? { isEncrypted: pw.isEncrypted() } : {},
2594
+ ...formatVersion > 0 ? { formatVersion } : {},
2595
+ ...isValidBitrateMode(bitrateMode) ? { bitrateMode } : {},
2596
+ ...containerFormat === "OGG" && codec === "Opus" ? { outputGainDb: pw.outputGainDb() } : {}
2597
+ };
2598
+ }
2599
+ };
2600
+ return new Proxy(raw, { get(target, prop, receiver) {
2601
+ if (prop in overrides) return overrides[prop];
2602
+ const value = Reflect.get(target, prop, receiver);
2603
+ return typeof value === "function" ? value.bind(target) : value;
2604
+ } });
2605
+ }
2606
+ var init_embind_adapter = __esmMin((() => {}));
2607
+ //#endregion
2608
+ //#region src/taglib/extra-state-registry.ts
2609
+ function chapterStyle(chapters) {
2610
+ const s = chapters[0]?.source;
2611
+ return s === "nero" || s === "both" ? s : "quicktime";
2612
+ }
2613
+ function copyExtraState(target, source, sourceComplete) {
2614
+ for (const field of EXTRA_FIELDS) field.copy(target, source, sourceComplete);
2615
+ }
2616
+ var EXTRA_FIELDS;
2617
+ var init_extra_state_registry = __esmMin((() => {
2618
+ EXTRA_FIELDS = [
2619
+ {
2620
+ name: "pictures",
2621
+ copy(target, source, complete) {
2622
+ const v = source.getPictures();
2623
+ if (complete || v.length > 0) target.setPictures(v);
2624
+ }
2625
+ },
2626
+ {
2627
+ name: "ratings",
2628
+ copy(target, source, complete) {
2629
+ const v = source.getRatings();
2630
+ if (complete || v.length > 0) target.setRatings(v);
2631
+ }
2632
+ },
2633
+ {
2634
+ name: "lyrics",
2635
+ copy(target, source, complete) {
2636
+ const v = source.getLyrics();
2637
+ if (complete || v.length > 0) target.setLyrics(v);
2638
+ }
2639
+ },
2640
+ {
2641
+ name: "chapters",
2642
+ copy(target, source, complete) {
2643
+ const v = source.getChapters();
2644
+ if (complete || v.length > 0) target.setChapters(v, chapterStyle(v));
2645
+ }
2646
+ },
2647
+ {
2648
+ name: "bextData",
2649
+ copy(target, source, complete) {
2650
+ const v = source.getBextData();
2651
+ if (v !== void 0) target.setBextData(v);
2652
+ else if (complete) target.setBextData(null);
2653
+ }
2654
+ },
2655
+ {
2656
+ name: "ixml",
2657
+ copy(target, source, complete) {
2658
+ const v = source.getIxml();
2659
+ if (v !== void 0) target.setIxml(v);
2660
+ else if (complete) target.setIxml(null);
2661
+ }
2662
+ },
2663
+ {
2664
+ name: "_mp4ItemRemovals",
2665
+ copy(target, source, complete) {
2666
+ const v = source.getMp4ItemRemovals?.();
2667
+ if (complete || v !== void 0 && v.length > 0) target.setMp4ItemRemovals?.(v ?? []);
2668
+ }
2669
+ },
2670
+ {
2671
+ name: "id3v2Frames",
2672
+ copy(target, source) {
2673
+ const staged = source.getStagedId3v2Frames?.();
2674
+ if (!staged) return;
2675
+ for (const [id, bodies] of Object.entries(staged)) target.setId3v2Frames(id, bodies);
2676
+ }
2677
+ }
2678
+ ];
2679
+ }));
2680
+ //#endregion
2681
+ //#region src/taglib/save-reconstruct.ts
2682
+ function copyEditedState(target, source, sourceComplete, deletedKeys) {
2683
+ target.setTagData(source.getTagData());
2684
+ const merged = sourceComplete ? source.getProperties() : {
2685
+ ...target.getProperties(),
2686
+ ...source.getProperties()
2687
+ };
2688
+ for (const key of deletedKeys) delete merged[key];
2689
+ const atomNames = mp4FreeformAtomNames(Object.keys(merged));
2690
+ if (atomNames.length > 0) merged[MP4_ITEM_NAMES_KEY] = atomNames;
2691
+ target.setProperties(merged);
2692
+ copyExtraState(target, source, sourceComplete);
2693
+ }
2694
+ async function saveViaFreshHandle(module, editing, source, targetPath, sourceComplete, deletedKeys = /* @__PURE__ */ new Set()) {
2695
+ const rawFullHandle = module.createFileHandle();
2696
+ const fullFileHandle = module.isWasi ? rawFullHandle : wrapEmbindHandle(rawFullHandle);
2697
+ try {
2698
+ {
2699
+ const data = await readFileData(source);
2700
+ if (!fullFileHandle.loadFromBuffer(data)) throw new InvalidFormatError("Failed to load full audio file for saving");
2701
+ }
2702
+ copyEditedState(fullFileHandle, editing, sourceComplete, deletedKeys);
2703
+ if (!fullFileHandle.save()) throw new FileOperationError("save", "Failed to save changes to full file");
2704
+ await writeFileData(targetPath, fullFileHandle.getBuffer());
2705
+ } finally {
2706
+ fullFileHandle.destroy();
2707
+ }
2708
+ }
2709
+ var init_save_reconstruct = __esmMin((() => {
2710
+ init_errors();
2711
+ init_file();
2712
+ init_write();
2713
+ init_embind_adapter();
2714
+ init_extra_state_registry();
2715
+ init_properties();
2716
+ init_mp4_item_names();
2717
+ }));
2718
+ //#endregion
2719
+ //#region src/taglib/audio-file-impl.ts
2720
+ function sortChapters(list) {
2721
+ return [...list].sort((a, b) => a.startTimeMs - b.startTimeMs);
2722
+ }
2723
+ function inferEndTimeMs(sorted, index, trackEndMs) {
2724
+ const own = sorted[index].endTimeMs;
2725
+ if (own !== void 0) return own;
2726
+ const next = sorted[index + 1];
2727
+ return next ? next.startTimeMs : trackEndMs;
2728
+ }
2729
+ function readFileSync(path) {
2730
+ if (isDeno()) return Deno.readFileSync(path);
2731
+ const fs = getNodeFsSync();
2732
+ if (fs) return new Uint8Array(fs.readFileSync(path));
2733
+ throw new FileOperationError("read", "node:fs is unavailable in this runtime: cannot read file data from disk", path);
2734
+ }
2735
+ var AudioFileImpl;
2736
+ var init_audio_file_impl = __esmMin((() => {
2737
+ init_types();
2738
+ init_audio_file_bwf();
2739
+ init_id3v2_frames();
2740
+ init_errors();
2741
+ init_write();
2742
+ init__taglib_node_fs_stub();
2743
+ init_rating();
2744
+ init_detector();
2745
+ init_audio_file_base();
2746
+ init_audio_file_checksum();
2747
+ init__taglib_platform_io_stub();
2748
+ init_save_reconstruct();
2749
+ init_defineProperty();
2750
+ AudioFileImpl = class extends BaseAudioFileImpl {
2751
+ constructor(module, fileHandle, sourcePath, originalSource, isPartiallyLoaded = false, partialLoadOptions) {
2752
+ super(module, fileHandle, sourcePath, originalSource, isPartiallyLoaded, partialLoadOptions);
2753
+ _defineProperty(this, "pathModeBuffer", null);
2754
+ _defineProperty(this, "partiallyLoadedAtConstruction", void 0);
2755
+ this.partiallyLoadedAtConstruction = isPartiallyLoaded;
2756
+ }
2757
+ save() {
2758
+ if (this.isPartiallyLoaded && this.originalSource) throw new FileOperationError("save", "Cannot save partially loaded file directly. Use saveToFile() instead");
2759
+ this.cachedAudioProperties = null;
2760
+ this.pathModeBuffer = null;
2761
+ return this.handle.save();
2762
+ }
2763
+ getFileBuffer() {
2764
+ const buffer = this.handle.getBuffer();
2765
+ if (buffer.length > 0) return buffer;
2766
+ if (this.pathModeBuffer) return this.pathModeBuffer;
2767
+ if (this.sourcePath) try {
2768
+ this.pathModeBuffer = readFileSync(this.sourcePath);
2769
+ return this.pathModeBuffer;
2770
+ } catch (error) {
2771
+ if (error instanceof FileOperationError) throw error;
2772
+ throw new FileOperationError("read", `Cannot return file data: ${errorMessage(error)}`, this.sourcePath, { cause: error });
2773
+ }
2774
+ throw new FileOperationError("read", "No file data available: in-memory buffer is empty and no source path is set");
2775
+ }
2776
+ mediaChecksum(options) {
2777
+ return mediaChecksum({
2778
+ bytes: this.handle.getBuffer(),
2779
+ ...this.sourcePath !== void 0 ? { path: this.sourcePath } : {},
2780
+ ...this.originalSource instanceof Blob ? { blob: this.originalSource } : {},
2781
+ partiallyLoaded: this.partiallyLoadedAtConstruction
2782
+ }, this.getFormat(), getPlatformIO(), options);
2783
+ }
2784
+ async saveToFile(path) {
2785
+ const targetPath = path ?? this.sourcePath;
2786
+ if (!targetPath) throw new FileOperationError("save", "No file path available. Provide a path or open the file from a path");
2787
+ if (this.isPartiallyLoaded && this.originalSource) {
2788
+ await saveViaFreshHandle(this.module, this.handle, this.originalSource, targetPath, false, this.partialDeletedPropertyKeys());
2789
+ this.isPartiallyLoaded = false;
2790
+ this.originalSource = void 0;
2791
+ } else if (this.module.isWasi && this.sourcePath && targetPath !== this.sourcePath) await saveViaFreshHandle(this.module, this.handle, this.sourcePath, targetPath, true);
2792
+ else {
2793
+ if (!this.save()) throw new FileOperationError("save", "Failed to save changes to in-memory buffer");
2794
+ const buffer = this.handle.getBuffer();
2795
+ if (buffer.length > 0) await writeFileData(targetPath, buffer);
2796
+ }
2797
+ this.pathModeBuffer = null;
2798
+ }
2799
+ getPictures() {
2800
+ return this.handle.getPictures().map((pic) => ({
2801
+ mimeType: pic.mimeType,
2802
+ data: pic.data,
2803
+ type: PICTURE_TYPE_NAMES[pic.type] ?? "Other",
2804
+ ...pic.description !== void 0 ? { description: pic.description } : {}
2805
+ }));
2806
+ }
2807
+ setPictures(pictures) {
2808
+ this.handle.setPictures(pictures.map((pic) => ({
2809
+ mimeType: pic.mimeType,
2810
+ data: pic.data,
2811
+ type: PICTURE_TYPE_VALUES[pic.type] ?? 0,
2812
+ description: pic.description ?? ""
2813
+ })));
2814
+ }
2815
+ addPicture(picture) {
2816
+ this.handle.addPicture({
2817
+ mimeType: picture.mimeType,
2818
+ data: picture.data,
2819
+ type: PICTURE_TYPE_VALUES[picture.type] ?? 0,
2820
+ description: picture.description ?? ""
2821
+ });
2822
+ }
2823
+ removePictures() {
2824
+ this.handle.removePictures();
2825
+ }
2826
+ getChapters() {
2827
+ const sorted = sortChapters(this.handle.getChapters());
2828
+ const trackEndMs = this.audioProperties()?.durationMs;
2829
+ return sorted.map((c, i) => {
2830
+ const endTimeMs = inferEndTimeMs(sorted, i, trackEndMs);
2831
+ return {
2832
+ startTimeMs: c.startTimeMs,
2833
+ ...endTimeMs !== void 0 ? { endTimeMs } : {},
2834
+ ...c.title ? { title: c.title } : {},
2835
+ ...c.id ? { id: c.id } : {},
2836
+ ...c.source !== void 0 ? { source: c.source } : {}
2837
+ };
2838
+ });
2839
+ }
2840
+ setChapters(chapters, options) {
2841
+ const fmt = this.getFormat();
2842
+ if (fmt !== "MP3" && fmt !== "AAC" && fmt !== "MP4") throw new UnsupportedFormatError(fmt, [
2843
+ "MP3",
2844
+ "AAC",
2845
+ "MP4"
2846
+ ], { operation: "setChapters" });
2847
+ const sorted = sortChapters(chapters);
2848
+ const trackEndMs = this.audioProperties()?.durationMs;
2849
+ const style = options?.mp4ChapterStyle ?? "quicktime";
2850
+ const source = fmt === "MP4" ? style : "id3";
2851
+ const raw = sorted.map((c, i) => ({
2852
+ ...c.id !== void 0 ? { id: c.id } : {},
2853
+ startTimeMs: c.startTimeMs,
2854
+ endTimeMs: inferEndTimeMs(sorted, i, trackEndMs) ?? c.startTimeMs,
2855
+ ...c.title !== void 0 ? { title: c.title } : {},
2856
+ source
2857
+ }));
2858
+ this.handle.setChapters(raw, style);
2859
+ }
2860
+ getBext() {
2861
+ return getBext(this.handle);
2862
+ }
2863
+ setBext(bext) {
2864
+ setBext(this.handle, this.getFormat(), bext);
2865
+ }
2866
+ getBextData() {
2867
+ return getBextData(this.handle);
2868
+ }
2869
+ setBextData(data) {
2870
+ setBextData(this.handle, this.getFormat(), data);
2871
+ }
2872
+ getIxml() {
2873
+ return getIxml(this.handle);
2874
+ }
2875
+ setIxml(data) {
2876
+ setIxml(this.handle, this.getFormat(), data);
2877
+ }
2878
+ getRatings() {
2879
+ return this.handle.getRatings().map((r) => ({
2880
+ rating: r.rating,
2881
+ ...r.email !== void 0 && r.email !== "" ? { email: r.email } : {},
2882
+ ...r.counter !== 0 ? { counter: r.counter } : {}
2883
+ }));
2884
+ }
2885
+ setRatings(ratings) {
2886
+ this.handle.setRatings(ratings.map((r) => ({
2887
+ rating: r.rating,
2888
+ email: r.email ?? "",
2889
+ counter: r.counter ?? 0
2890
+ })));
2891
+ }
2892
+ getLyrics() {
2893
+ return this.handle.getLyrics().map((l) => {
2894
+ const out = { text: l.text };
2895
+ if (l.description) out.description = l.description;
2896
+ if (l.language) out.language = l.language;
2897
+ return out;
2898
+ });
2899
+ }
2900
+ setLyrics(lyrics) {
2901
+ this.handle.setLyrics(lyrics.map((l) => ({
2902
+ text: l.text,
2903
+ description: l.description ?? "",
2904
+ language: l.language ?? ""
2905
+ })));
2906
+ }
2907
+ getRating() {
2908
+ const ratings = this.getRatings();
2909
+ return ratings.length > 0 ? normalized(ratings[0].rating) : void 0;
2910
+ }
2911
+ setRating(rating, email) {
2912
+ this.setRatings([{
2913
+ rating,
2914
+ ...email !== void 0 ? { email } : {},
2915
+ counter: 0
2916
+ }]);
2917
+ }
2918
+ getId3v2Frames(id) {
2919
+ assertMp3(this.getFormat());
2920
+ if (id !== void 0) assertFrameId(id, "read");
2921
+ return this.handle.getId3v2Frames(id ?? "").map(toPublicFrame);
2922
+ }
2923
+ setId3v2Frames(id, data) {
2924
+ assertMp3(this.getFormat());
2925
+ assertFrameId(id, "write");
2926
+ assertFrameBodies(id, data);
2927
+ this.handle.setId3v2Frames(id, data);
2928
+ }
2929
+ removeId3v2Frames(id) {
2930
+ assertMp3(this.getFormat());
2931
+ assertFrameId(id, "write");
2932
+ this.handle.removeId3v2Frames(id);
2933
+ }
2934
+ hasId3Tags() {
2935
+ return this.handle.hasId3Tags();
2936
+ }
2937
+ stripId3Tags(opts) {
2938
+ this.handle.stripId3Tags({
2939
+ v1: opts?.v1 ?? true,
2940
+ v2: opts?.v2 ?? true
2941
+ });
2942
+ }
2943
+ };
2944
+ }));
2945
+ //#endregion
2946
+ //#region src/taglib/load-audio-data.ts
2947
+ async function loadAudioData(input, opts) {
2948
+ if (opts.partial && typeof File !== "undefined" && input instanceof File) {
2949
+ const headerSize = Math.min(opts.maxHeaderSize, input.size);
2950
+ const footerSize = Math.min(opts.maxFooterSize, input.size);
2951
+ if (input.size <= headerSize + footerSize) return {
2952
+ data: await readFileData(input),
2953
+ isPartiallyLoaded: false
2954
+ };
2955
+ const header = new Uint8Array(await input.slice(0, headerSize).arrayBuffer());
2956
+ if (!metadataFitsInHeader(header, headerSize)) return {
2957
+ data: await readFileData(input),
2958
+ isPartiallyLoaded: false
2959
+ };
2960
+ const footerStart = Math.max(0, input.size - footerSize);
2961
+ const footer = new Uint8Array(await input.slice(footerStart).arrayBuffer());
2962
+ if (!trailerFitsInFooter(footer, footerSize)) return {
2963
+ data: await readFileData(input),
2964
+ isPartiallyLoaded: false
2965
+ };
2966
+ const combined = new Uint8Array(header.byteLength + footer.byteLength);
2967
+ combined.set(header, 0);
2968
+ combined.set(footer, header.byteLength);
2969
+ return {
2970
+ data: combined,
2971
+ isPartiallyLoaded: true
2972
+ };
2973
+ }
2974
+ if (opts.partial && typeof input === "string") {
2975
+ if (await getFileSize(input) > opts.maxHeaderSize + opts.maxFooterSize) {
2976
+ const data = await readPartialFileData(input, opts.maxHeaderSize, opts.maxFooterSize);
2977
+ if (metadataFitsInHeader(data, opts.maxHeaderSize) && trailerFitsInFooter(data, opts.maxFooterSize)) return {
2978
+ data,
2979
+ isPartiallyLoaded: true
2980
+ };
2981
+ }
2982
+ return {
2983
+ data: await readFileData(input),
2984
+ isPartiallyLoaded: false
2985
+ };
2986
+ }
2987
+ return {
2988
+ data: await readFileData(input),
2989
+ isPartiallyLoaded: false
2990
+ };
2991
+ }
2992
+ var init_load_audio_data = __esmMin((() => {
2993
+ init_file();
2994
+ init_metadata_extent();
2995
+ }));
2996
+ //#endregion
2997
+ //#region src/utils/tag-mapping.ts
2998
+ function mergeTagUpdatesInto(currentProps, tags) {
2999
+ const newProps = normalizeTagInput(tags);
3000
+ reconcilePairFields(currentProps, newProps, tags);
3001
+ if (newProps.date !== void 0 || newProps.year !== void 0) currentProps.YEAR = [];
3002
+ return {
3003
+ ...currentProps,
3004
+ ...newProps
3005
+ };
3006
+ }
3007
+ function mergeTagUpdates(file, tags) {
3008
+ file.setProperties(mergeTagUpdatesInto(file.properties(), tags));
3009
+ }
3010
+ function reconcilePairFields(currentProps, newProps, input) {
3011
+ for (const [rawKey, totalKey, numericKey] of [[
3012
+ "trackNumber",
3013
+ "totalTracks",
3014
+ "track"
3015
+ ], [
3016
+ "discNumber",
3017
+ "totalDiscs",
3018
+ "discNumber"
3019
+ ]]) {
3020
+ const incoming = newProps[rawKey]?.[0];
3021
+ if (incoming?.includes("/")) {
3022
+ newProps[totalKey] = [];
3023
+ continue;
3024
+ }
3025
+ if (!(input[numericKey] !== void 0 && input[rawKey] === void 0) || incoming === void 0) continue;
3026
+ const existing = currentProps[rawKey]?.[0];
3027
+ const slash = existing?.indexOf("/") ?? -1;
3028
+ if (existing !== void 0 && slash !== -1) newProps[rawKey] = [`${incoming}${existing.slice(slash)}`];
3029
+ }
3030
+ }
3031
+ function normalizeTagInput(input) {
3032
+ const props = {};
3033
+ for (const field of [
3034
+ "title",
3035
+ "artist",
3036
+ "album",
3037
+ "comment",
3038
+ "genre"
3039
+ ]) {
3040
+ const val = input[field];
3041
+ if (val === void 0) continue;
3042
+ props[field] = Array.isArray(val) ? val : [val];
3043
+ }
3044
+ if (input.year !== void 0) props.date = [String(input.year)];
3045
+ if (input.date !== void 0) props.date = Array.isArray(input.date) ? input.date : [input.date];
3046
+ if (input.track !== void 0) props.trackNumber = [String(input.track)];
3047
+ if (input.trackNumber !== void 0) props.trackNumber = Array.isArray(input.trackNumber) ? input.trackNumber : [input.trackNumber];
3048
+ for (const [field, val] of Object.entries(input)) {
3049
+ if (BASIC_FIELDS.has(field) || val === void 0) continue;
3050
+ if (field === "extraProperties") continue;
3051
+ if (field === "compilation") props[field] = [val ? "1" : "0"];
3052
+ else if (field === "advisory") {
3053
+ if (val === "explicit") props.itunesAdvisory = ["1"];
3054
+ else if (val === "clean") props.itunesAdvisory = ["2"];
3055
+ else if (val === "unspecified") props.itunesAdvisory = [];
3056
+ } else if (field === "bpm") props[field] = [String(Math.trunc(val))];
3057
+ else if (NUMERIC_FIELDS.has(field)) props[field] = [String(val)];
3058
+ else if (field === "r128TrackGain" || field === "r128AlbumGain") props[field] = Array.isArray(val) ? val : [String(Math.round(val * 256))];
3059
+ else if (typeof val === "string") props[field] = [val];
3060
+ else if (Array.isArray(val)) props[field] = val;
3061
+ }
3062
+ for (const [rawField, totalField] of [["trackNumber", "totalTracks"], ["discNumber", "totalDiscs"]]) if (props[rawField]?.[0]?.includes("/")) delete props[totalField];
3063
+ return props;
3064
+ }
3065
+ var BASIC_FIELDS, NUMERIC_FIELDS;
3066
+ var init_tag_mapping = __esmMin((() => {
3067
+ BASIC_FIELDS = /* @__PURE__ */ new Set([
3068
+ "title",
3069
+ "artist",
3070
+ "album",
3071
+ "comment",
3072
+ "genre",
3073
+ "year",
3074
+ "date",
3075
+ "track",
3076
+ "trackNumber"
3077
+ ]);
3078
+ NUMERIC_FIELDS = /* @__PURE__ */ new Set([
3079
+ "year",
3080
+ "track",
3081
+ "discNumber",
3082
+ "totalTracks",
3083
+ "totalDiscs",
3084
+ "bpm"
3085
+ ]);
3086
+ }));
3087
+ //#endregion
3088
+ //#region src/version.ts
3089
+ var VERSION;
3090
+ var init_version = __esmMin((() => {
3091
+ VERSION = "2.3.1";
3092
+ }));
3093
+ //#endregion
3094
+ //#region src/runtime/module-loader-browser.ts
3095
+ var module_loader_browser_exports = /* @__PURE__ */ __exportAll({ loadTagLibModule: () => loadTagLibModule });
3096
+ async function loadTagLibModule(options) {
3097
+ let createTagLibModule;
3098
+ try {
3099
+ createTagLibModule = (await import("./taglib-wrapper.js")).default;
3100
+ } catch {
3101
+ try {
3102
+ createTagLibModule = (await import("./taglib-wrapper.js")).default;
3103
+ } catch {
3104
+ throw new TagLibInitializationError("Could not load taglib-wrapper.js. Ensure it is co-located with the browser bundle.");
3105
+ }
3106
+ }
3107
+ const moduleConfig = {};
3108
+ if (options?.wasmBinary) moduleConfig.wasmBinary = options.wasmBinary;
3109
+ if (options?.wasmUrl) moduleConfig.locateFile = (path) => {
3110
+ if (path.endsWith(".wasm")) return options.wasmUrl;
3111
+ return path;
3112
+ };
3113
+ else if (!options?.wasmBinary) {
3114
+ const wasmUrl = new URL("./taglib-web.wasm", import.meta.url);
3115
+ moduleConfig.locateFile = (path) => path.endsWith(".wasm") ? wasmUrl.href : path;
3116
+ }
3117
+ return await createTagLibModule(moduleConfig);
3118
+ }
3119
+ var init_module_loader_browser = __esmMin((() => {
3120
+ init_classes();
3121
+ }));
3122
+ //#endregion
3123
+ //#region src/taglib/taglib-class.ts
3124
+ function toWasiPath(osPath) {
3125
+ if (osPath.startsWith("\\\\") || osPath.startsWith("//")) throw new FileOperationError("read", `UNC paths are not supported. Path: ${osPath}`);
3126
+ let p = osPath;
3127
+ if (!p.startsWith("/") && !/^[A-Za-z]:/.test(p)) {
3128
+ const g = globalThis;
3129
+ const cwd = isDeno() ? Deno.cwd() : g.process?.cwd?.();
3130
+ if (cwd) p = cwd.replace(/[/\\]+$/, "") + "/" + p;
3131
+ }
3132
+ p = p.replaceAll("\\", "/");
3133
+ const driveMatch = p.match(/^([A-Za-z]):\//);
3134
+ if (driveMatch) p = `/${driveMatch[1].toUpperCase()}${p.slice(2)}`;
3135
+ p = p.replace(/\/\.\//g, "/").replace(/\/+/g, "/");
3136
+ if (!p.startsWith("/")) p = "/" + p;
3137
+ return p;
3138
+ }
3139
+ async function createTagLib(module) {
3140
+ return new TagLib(module);
3141
+ }
3142
+ var TagLib;
3143
+ var init_taglib_class = __esmMin((() => {
3144
+ init_audio_formats();
3145
+ init_errors();
3146
+ init_detector();
3147
+ init_audio_file_impl();
3148
+ init_load_audio_data();
3149
+ init_tag_mapping();
3150
+ init_version();
3151
+ init_embind_adapter();
3152
+ init_defineProperty();
3153
+ TagLib = class TagLib {
3154
+ constructor(module) {
3155
+ _defineProperty(this, "module", void 0);
3156
+ this.module = module;
3157
+ }
3158
+ static async initialize(options) {
3159
+ const { loadTagLibModule } = await Promise.resolve().then(() => (init_module_loader_browser(), module_loader_browser_exports));
3160
+ const module = await loadTagLibModule(options);
3161
+ return new TagLib(module);
3162
+ }
3163
+ async open(input, options) {
3164
+ if (!this.module.createFileHandle) throw new TagLibInitializationError("TagLib module not properly initialized: createFileHandle not found. Make sure the module is fully loaded before calling open.");
3165
+ const actualInput = isNamedAudioInput(input) ? input.data : input;
3166
+ const sourcePath = typeof actualInput === "string" ? actualInput : void 0;
3167
+ if (typeof actualInput === "string" && this.module.isWasi) {
3168
+ const wasiPath = toWasiPath(actualInput);
3169
+ if (this.module.loadAudioPath) {
3170
+ const fileHandle = await this.module.loadAudioPath(wasiPath, actualInput);
3171
+ return new AudioFileImpl(this.module, fileHandle, sourcePath, actualInput, false);
3172
+ }
3173
+ }
3174
+ const opts = {
3175
+ partial: true,
3176
+ maxHeaderSize: 1048576,
3177
+ maxFooterSize: 131072,
3178
+ ...options
3179
+ };
3180
+ const { data: audioData, isPartiallyLoaded } = await loadAudioData(actualInput, opts);
3181
+ const uint8Array = actualInput instanceof Uint8Array && audioData.buffer === actualInput.buffer ? new Uint8Array(audioData.buffer.slice(audioData.byteOffset, audioData.byteOffset + audioData.byteLength)) : audioData;
3182
+ const rawHandle = this.module.createFileHandle();
3183
+ const fileHandle = this.module.isWasi ? rawHandle : wrapEmbindHandle(rawHandle);
3184
+ try {
3185
+ if (!fileHandle.loadFromBuffer(uint8Array)) throw new InvalidFormatError("Failed to load audio file. File may be corrupted or in an unsupported format", uint8Array.byteLength);
3186
+ return new AudioFileImpl(this.module, fileHandle, sourcePath, actualInput, isPartiallyLoaded, opts);
3187
+ } catch (error) {
3188
+ if (typeof fileHandle.destroy === "function") fileHandle.destroy();
3189
+ throw error;
3190
+ }
3191
+ }
3192
+ async edit(input, fn) {
3193
+ const file = await this.open(input);
3194
+ try {
3195
+ await fn(file);
3196
+ if (typeof input === "string") await file.saveToFile();
3197
+ else {
3198
+ file.save();
3199
+ return file.getFileBuffer();
3200
+ }
3201
+ } finally {
3202
+ file.dispose();
3203
+ }
3204
+ }
3205
+ async updateFile(path, tags) {
3206
+ const file = await this.open(path);
3207
+ try {
3208
+ mergeTagUpdates(file, tags);
3209
+ await file.saveToFile();
3210
+ } finally {
3211
+ file.dispose();
3212
+ }
3213
+ }
3214
+ async copyWithTags(sourcePath, destPath, tags) {
3215
+ const file = await this.open(sourcePath);
3216
+ try {
3217
+ mergeTagUpdates(file, tags);
3218
+ await file.saveToFile(destPath);
3219
+ } finally {
3220
+ file.dispose();
3221
+ }
3222
+ }
3223
+ version() {
3224
+ return `${VERSION} (TagLib ${this.taglibVersion()})`;
3225
+ }
3226
+ taglibVersion() {
3227
+ if (this.module.getVersion) return this.module.getVersion();
3228
+ if (this.module.version) return this.module.version();
3229
+ return "unknown";
3230
+ }
3231
+ };
3232
+ }));
3233
+ //#endregion
3234
+ //#region src/taglib/index.ts
3235
+ var init_taglib$1 = __esmMin((() => {
3236
+ init_audio_file_impl();
3237
+ init_taglib_class();
3238
+ init_errors();
3239
+ }));
3240
+ //#endregion
3241
+ //#region src/taglib.ts
3242
+ var taglib_exports = /* @__PURE__ */ __exportAll({
3243
+ AudioFileImpl: () => AudioFileImpl,
3244
+ EnvironmentError: () => EnvironmentError,
3245
+ FileOperationError: () => FileOperationError,
3246
+ InvalidFormatError: () => InvalidFormatError,
3247
+ MemoryError: () => MemoryError,
3248
+ MetadataError: () => MetadataError,
3249
+ SUPPORTED_FORMATS: () => SUPPORTED_FORMATS,
3250
+ TagLib: () => TagLib,
3251
+ TagLibError: () => TagLibError,
3252
+ TagLibInitializationError: () => TagLibInitializationError,
3253
+ UnsupportedFormatError: () => UnsupportedFormatError,
3254
+ createTagLib: () => createTagLib,
3255
+ isEnvironmentError: () => isEnvironmentError,
3256
+ isFileOperationError: () => isFileOperationError,
3257
+ isInvalidFormatError: () => isInvalidFormatError,
3258
+ isMemoryError: () => isMemoryError,
3259
+ isMetadataError: () => isMetadataError,
3260
+ isTagLibError: () => isTagLibError,
3261
+ isUnsupportedFormatError: () => isUnsupportedFormatError
3262
+ });
3263
+ var init_taglib = __esmMin((() => {
3264
+ init_taglib$1();
3265
+ }));
3266
+ //#endregion
3267
+ //#region src/simple/config.ts
3268
+ let cachedTagLib = null;
3269
+ async function getTagLib() {
3270
+ if (!cachedTagLib) {
3271
+ const { TagLib } = await Promise.resolve().then(() => (init_taglib(), taglib_exports));
3272
+ cachedTagLib = await TagLib.initialize(void 0);
3273
+ }
3274
+ return cachedTagLib;
3275
+ }
3276
+ //#endregion
3277
+ //#region src/simple/with-audio-file.ts
3278
+ init_errors();
3279
+ async function withAudioFile(file, fn, options) {
3280
+ const audioFile = await (await getTagLib()).open(file, options);
3281
+ try {
3282
+ if (!audioFile.isValid()) throw new InvalidFormatError("File may be corrupted or in an unsupported format");
3283
+ return await fn(audioFile);
3284
+ } finally {
3285
+ audioFile.dispose();
3286
+ }
3287
+ }
3288
+ async function withAudioFileSave(file, fn) {
3289
+ return withAudioFile(file, (audioFile) => {
3290
+ fn(audioFile);
3291
+ if (!audioFile.save()) throw new FileOperationError("save", "Failed to save metadata changes. The file may be read-only or corrupted.");
3292
+ return audioFile.getFileBuffer();
3293
+ }, { partial: false });
3294
+ }
3295
+ //#endregion
3296
+ //#region src/simple/picture-operations.ts
3297
+ async function readPictures(file) {
3298
+ return withAudioFile(file, (audioFile) => audioFile.getPictures());
3299
+ }
3300
+ async function applyPictures(file, pictures) {
3301
+ return withAudioFileSave(file, (audioFile) => {
3302
+ audioFile.setPictures(pictures);
3303
+ });
3304
+ }
3305
+ //#endregion
3306
+ //#region src/web-utils/canvas.ts
3307
+ async function setCoverArtFromCanvas(file, canvas, options = {}) {
3308
+ const { format = "image/jpeg", quality = .92, type = "FrontCover", description = "Front Cover" } = options;
3309
+ return applyPictures(file, [dataURLToPicture(canvas.toDataURL(format, quality), type, description)]);
3310
+ }
3311
+ async function canvasToPicture(canvas, options = {}) {
3312
+ const { format = "image/jpeg", quality = .92, type = "FrontCover", description } = options;
3313
+ return new Promise((resolve, reject) => {
3314
+ canvas.toBlob((blob) => {
3315
+ if (!blob) {
3316
+ reject(/* @__PURE__ */ new Error("Failed to convert canvas to blob"));
3317
+ return;
3318
+ }
3319
+ blob.arrayBuffer().then((arrayBuffer) => {
3320
+ const data = new Uint8Array(arrayBuffer);
3321
+ resolve({
3322
+ mimeType: format,
3323
+ data,
3324
+ type,
3325
+ ...description !== void 0 ? { description } : {}
3326
+ });
3327
+ }, reject);
3328
+ }, format, quality);
3329
+ });
3330
+ }
3331
+ async function imageFileToPicture(file, type = "FrontCover", description) {
3332
+ const arrayBuffer = await file.arrayBuffer();
3333
+ const data = new Uint8Array(arrayBuffer);
3334
+ return {
3335
+ mimeType: file.type,
3336
+ data,
3337
+ type,
3338
+ description: description ?? file.name
3339
+ };
3340
+ }
3341
+ //#endregion
3342
+ //#region src/web-utils/dom-integration.ts
3343
+ function ensureArrayBufferBacked(data) {
3344
+ if (data.buffer instanceof ArrayBuffer) return data;
3345
+ const copy = new Uint8Array(data.length);
3346
+ copy.set(data);
3347
+ return copy;
3348
+ }
3349
+ function displayPicture(picture, imgElement) {
3350
+ if (imgElement.src.startsWith("blob:")) URL.revokeObjectURL(imgElement.src);
3351
+ const data = ensureArrayBufferBacked(picture.data);
3352
+ const blob = new Blob([data], { type: picture.mimeType });
3353
+ const objectURL = URL.createObjectURL(blob);
3354
+ imgElement.src = objectURL;
3355
+ imgElement.addEventListener("load", () => {
3356
+ setTimeout(() => URL.revokeObjectURL(objectURL), 100);
3357
+ }, { once: true });
3358
+ }
3359
+ function createPictureDownloadURL(picture, filename = "cover") {
3360
+ const data = ensureArrayBufferBacked(picture.data);
3361
+ const blob = new Blob([data], { type: picture.mimeType });
3362
+ return URL.createObjectURL(blob);
3363
+ }
3364
+ async function createPictureGallery(file, container, options = {}) {
3365
+ const pictures = await readPictures(file);
3366
+ container.innerHTML = "";
3367
+ pictures.forEach((picture, index) => {
3368
+ const wrapper = document.createElement("div");
3369
+ wrapper.className = options.className ?? "picture-item";
3370
+ const img = document.createElement("img");
3371
+ displayPicture(picture, img);
3372
+ img.alt = picture.description ?? `Picture ${index + 1}`;
3373
+ if (options.onClick) {
3374
+ img.style.cursor = "pointer";
3375
+ img.addEventListener("click", () => options.onClick(picture, index));
3376
+ }
3377
+ wrapper.appendChild(img);
3378
+ if (options.includeDescription && picture.description) {
3379
+ const caption = document.createElement("p");
3380
+ caption.textContent = picture.description;
3381
+ wrapper.appendChild(caption);
3382
+ }
3383
+ container.appendChild(wrapper);
3384
+ });
3385
+ }
3386
+ //#endregion
3387
+ export { canvasToPicture, createPictureDownloadURL, createPictureGallery, dataURLToPicture, displayPicture, imageFileToPicture, pictureToDataURL, setCoverArtFromCanvas };