playlist-data-engine 1.7.0 → 1.7.2

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.
@@ -11,10 +11,10 @@ class n {
11
11
  * 7. multimedia_url (Alternative media field)
12
12
  */
13
13
  static extractAudioUrl(t) {
14
- const e = ["mp3_url", "mp3Url", "lossy_audio", "lossyAudio", "audio_url", "audioUrl", "audio", "lossless_audio", "losslessAudio", "animation_url", "animationUrl", "multimedia_url", "multimediaUrl"];
15
- for (const r of e)
16
- if (t[r] && typeof t[r] == "string")
17
- return t[r];
14
+ const r = ["mp3_url", "mp3Url", "lossy_audio", "lossyAudio", "audio_url", "audioUrl", "audio", "lossless_audio", "losslessAudio", "animation_url", "animationUrl", "multimedia_url", "multimediaUrl"];
15
+ for (const e of r)
16
+ if (t[e] && typeof t[e] == "string")
17
+ return t[e];
18
18
  return null;
19
19
  }
20
20
  /**
@@ -23,10 +23,10 @@ class n {
23
23
  * that back rather than null.
24
24
  */
25
25
  static extractAudioUrlLossless(t) {
26
- const e = ["lossless_audio", "losslessAudio", "wav_url", "wavUrl", "flac_url", "flacUrl", "audio_url", "audioUrl"];
27
- for (const r of e)
28
- if (t[r] && typeof t[r] == "string")
29
- return t[r];
26
+ const r = ["lossless_audio", "losslessAudio", "wav_url", "wavUrl", "flac_url", "flacUrl", "audio_url", "audioUrl"];
27
+ for (const e of r)
28
+ if (t[e] && typeof t[e] == "string")
29
+ return t[e];
30
30
  return null;
31
31
  }
32
32
  /**
@@ -47,16 +47,16 @@ class n {
47
47
  * 10. primaryMedia.uri (Primary media field)
48
48
  */
49
49
  static extractImageUrl(t) {
50
- const e = ["image_small", "imageSmall", "image", "image_large", "imageLarge", "image_thumb", "imageThumb", "image_url", "imageUrl", "image_uri", "imageUri", "image_preview", "imagePreview"];
51
- for (const s of e)
50
+ const r = ["image_small", "imageSmall", "image", "image_large", "imageLarge", "image_thumb", "imageThumb", "image_url", "imageUrl", "image_uri", "imageUri", "image_preview", "imagePreview"];
51
+ for (const s of r)
52
52
  if (t[s] && typeof t[s] == "string")
53
53
  return t[s];
54
- const r = [
54
+ const e = [
55
55
  this.extractNestedUri(t, "artwork", "uri"),
56
56
  this.extractNestedUri(t, "project", "artwork", "uri"),
57
57
  this.extractNestedUri(t, "primaryMedia", "uri")
58
58
  ];
59
- for (const s of r)
59
+ for (const s of e)
60
60
  if (s) return s;
61
61
  return null;
62
62
  }
@@ -84,16 +84,16 @@ class n {
84
84
  * 4. OpenSea-style attributes array with trait_type "Artist"
85
85
  */
86
86
  static extractArtist(t) {
87
- const e = ["artist", "artist_name", "artistName", "album_artist", "albumArtist", "created_by", "createdBy", "minter"];
88
- for (const r of e)
89
- if (t[r] && typeof t[r] == "string")
90
- return t[r];
87
+ const r = ["artist", "artist_name", "artistName", "album_artist", "albumArtist", "created_by", "createdBy", "minter"];
88
+ for (const e of r)
89
+ if (t[e] && typeof t[e] == "string")
90
+ return t[e];
91
91
  if (Array.isArray(t.attributes)) {
92
- const r = t.attributes.find(
92
+ const e = t.attributes.find(
93
93
  (s) => s.trait_type?.toLowerCase() === "artist" && s.value !== void 0
94
94
  );
95
- if (r && typeof r.value == "string")
96
- return r.value;
95
+ if (e && typeof e.value == "string")
96
+ return e.value;
97
97
  }
98
98
  return null;
99
99
  }
@@ -108,11 +108,11 @@ class n {
108
108
  return t;
109
109
  if (typeof t == "string")
110
110
  try {
111
- const e = JSON.parse(t);
112
- if (typeof e == "object" && !Array.isArray(e))
113
- return e;
114
- } catch (e) {
115
- return console.warn("Failed to parse metadata:", e), null;
111
+ const r = JSON.parse(t);
112
+ if (typeof r == "object" && !Array.isArray(r))
113
+ return r;
114
+ } catch (r) {
115
+ return console.warn("Failed to parse metadata:", r), null;
116
116
  }
117
117
  return null;
118
118
  }
@@ -131,33 +131,33 @@ class n {
131
131
  if (typeof t.genre == "string")
132
132
  return t.genre;
133
133
  if (Array.isArray(t.genre) && t.genre.length > 0) {
134
- const r = t.genre[0];
135
- return typeof r == "string" ? r : "";
134
+ const e = t.genre[0];
135
+ return typeof e == "string" ? e : "";
136
136
  }
137
137
  if (Array.isArray(t.attributes)) {
138
- const r = t.attributes.find(
138
+ const e = t.attributes.find(
139
139
  (s) => s.trait_type?.toLowerCase() === "genre" && s.value !== void 0
140
140
  );
141
- if (r) {
142
- if (typeof r.value == "string")
143
- return r.value;
144
- if (Array.isArray(r.value) && r.value.length > 0) {
145
- const s = r.value[0];
141
+ if (e) {
142
+ if (typeof e.value == "string")
143
+ return e.value;
144
+ if (Array.isArray(e.value) && e.value.length > 0) {
145
+ const s = e.value[0];
146
146
  return typeof s == "string" ? s : "";
147
147
  }
148
148
  }
149
149
  }
150
150
  if (t.attributes && typeof t.attributes == "object" && !Array.isArray(t.attributes)) {
151
- const r = t.attributes;
152
- for (const s of Object.keys(r))
153
- if (s.toLowerCase() === "genre" && typeof r[s] == "string")
154
- return r[s];
151
+ const e = t.attributes;
152
+ for (const s of Object.keys(e))
153
+ if (s.toLowerCase() === "genre" && typeof e[s] == "string")
154
+ return e[s];
155
155
  }
156
- const e = t["attribute "];
157
- if (e && typeof e == "object" && !Array.isArray(e)) {
158
- const r = e.genre;
159
- if (typeof r == "string")
160
- return r;
156
+ const r = t["attribute "];
157
+ if (r && typeof r == "object" && !Array.isArray(r)) {
158
+ const e = r.genre;
159
+ if (typeof e == "string")
160
+ return e;
161
161
  }
162
162
  return "";
163
163
  }
@@ -171,29 +171,29 @@ class n {
171
171
  * - `attributes` as an object keyed by trait name (e.g. `attributes.Tags`)
172
172
  */
173
173
  static extractTags(t) {
174
- const e = [];
175
- if (Array.isArray(t.tags) ? e.push(...t.tags) : typeof t.tags == "string" && e.push(...t.tags.split(",")), t.properties && typeof t.properties == "object" && !Array.isArray(t.properties)) {
176
- const r = t.properties.tags;
177
- Array.isArray(r) ? e.push(...r) : typeof r == "string" && e.push(...r.split(","));
174
+ const r = [];
175
+ if (Array.isArray(t.tags) ? r.push(...t.tags) : typeof t.tags == "string" && r.push(...t.tags.split(",")), t.properties && typeof t.properties == "object" && !Array.isArray(t.properties)) {
176
+ const e = t.properties.tags;
177
+ Array.isArray(e) ? r.push(...e) : typeof e == "string" && r.push(...e.split(","));
178
178
  }
179
179
  if (Array.isArray(t.attributes))
180
- for (const r of t.attributes) {
181
- if (!r || typeof r != "object") continue;
182
- const s = r.trait_type;
180
+ for (const e of t.attributes) {
181
+ if (!e || typeof e != "object") continue;
182
+ const s = e.trait_type;
183
183
  if (typeof s == "string" && s.toLowerCase().match(/^tags?$/)) {
184
- const o = r.value;
185
- Array.isArray(o) ? e.push(...o) : typeof o == "string" && e.push(...o.split(","));
184
+ const a = e.value;
185
+ Array.isArray(a) ? r.push(...a) : typeof a == "string" && r.push(...a.split(","));
186
186
  }
187
187
  }
188
188
  else if (t.attributes && typeof t.attributes == "object") {
189
- const r = t.attributes;
190
- for (const s of Object.keys(r))
189
+ const e = t.attributes;
190
+ for (const s of Object.keys(e))
191
191
  if (s.toLowerCase().match(/^tags?$/)) {
192
- const o = r[s];
193
- Array.isArray(o) ? e.push(...o) : typeof o == "string" && e.push(...o.split(","));
192
+ const a = e[s];
193
+ Array.isArray(a) ? r.push(...a) : typeof a == "string" && r.push(...a.split(","));
194
194
  }
195
195
  }
196
- return n.normalizeTags(e);
196
+ return n.normalizeTags(r);
197
197
  }
198
198
  /**
199
199
  * Extract track description with priority:
@@ -213,16 +213,16 @@ class n {
213
213
  * descriptions, not the track's.
214
214
  */
215
215
  static extractDescription(t) {
216
- const e = ["description", "track_description", "trackDescription", "description_text", "descriptionText", "desc", "blurb"];
217
- for (const r of e)
218
- if (t[r] && typeof t[r] == "string")
219
- return t[r];
216
+ const r = ["description", "track_description", "trackDescription", "description_text", "descriptionText", "desc", "blurb"];
217
+ for (const e of r)
218
+ if (t[e] && typeof t[e] == "string")
219
+ return t[e];
220
220
  if (Array.isArray(t.attributes)) {
221
- const r = t.attributes.find(
221
+ const e = t.attributes.find(
222
222
  (s) => s.trait_type?.toLowerCase() === "description" && typeof s.value == "string"
223
223
  );
224
- if (r && typeof r.value == "string")
225
- return r.value;
224
+ if (e && typeof e.value == "string")
225
+ return e.value;
226
226
  }
227
227
  return n.deepFindString(t, /description/i);
228
228
  }
@@ -240,12 +240,12 @@ class n {
240
240
  * the track's own description to the album.
241
241
  */
242
242
  static extractAlbumDescription(t) {
243
- const e = ["album_description", "albumDescription"];
244
- for (const s of e)
243
+ const r = ["album_description", "albumDescription"];
244
+ for (const s of r)
245
245
  if (t[s] && typeof t[s] == "string")
246
246
  return t[s];
247
- const r = t.album;
248
- return r && typeof r == "object" && !Array.isArray(r) ? n.deepFindString(r, /description|liner|notes/i) : null;
247
+ const e = t.album;
248
+ return e && typeof e == "object" && !Array.isArray(e) ? n.deepFindString(e, /description|liner|notes/i) : null;
249
249
  }
250
250
  /**
251
251
  * Extract artist description — one of the bonus flavors. Priority:
@@ -262,12 +262,12 @@ class n {
262
262
  * track's own description to the artist.
263
263
  */
264
264
  static extractArtistDescription(t) {
265
- const e = ["artist_description", "artistDescription", "artist_bio", "artistBio"];
266
- for (const s of e)
265
+ const r = ["artist_description", "artistDescription", "artist_bio", "artistBio"];
266
+ for (const s of r)
267
267
  if (t[s] && typeof t[s] == "string")
268
268
  return t[s];
269
- const r = t.artist;
270
- return r && typeof r == "object" && !Array.isArray(r) ? n.deepFindString(r, /description|bio|about/i) : null;
269
+ const e = t.artist;
270
+ return e && typeof e == "object" && !Array.isArray(e) ? n.deepFindString(e, /description|bio|about/i) : null;
271
271
  }
272
272
  /**
273
273
  * Breadth-first search for the shallowest string value whose key matches
@@ -275,19 +275,19 @@ class n {
275
275
  * then key order. Objects are descended (arrays skipped), depth-capped so
276
276
  * pathological metadata blobs stay cheap.
277
277
  */
278
- static deepFindString(t, e, r = 5) {
279
- const s = /* @__PURE__ */ new Set(), o = [{ node: t, depth: 0 }];
280
- for (; o.length > 0; ) {
281
- const { node: u, depth: c } = o.shift();
282
- for (const a of Object.keys(u)) {
283
- const f = u[a];
284
- if (typeof f == "string" && f && e.test(a))
285
- return f;
278
+ static deepFindString(t, r, e = 5) {
279
+ const s = /* @__PURE__ */ new Set(), a = [{ node: t, depth: 0 }];
280
+ for (; a.length > 0; ) {
281
+ const { node: u, depth: c } = a.shift();
282
+ for (const f of Object.keys(u)) {
283
+ const o = u[f];
284
+ if (typeof o == "string" && o && r.test(f))
285
+ return o;
286
286
  }
287
- if (!(c >= r))
288
- for (const a of Object.keys(u)) {
289
- const f = u[a];
290
- f && typeof f == "object" && !Array.isArray(f) && !s.has(f) && (s.add(f), o.push({ node: f, depth: c + 1 }));
287
+ if (!(c >= e))
288
+ for (const f of Object.keys(u)) {
289
+ const o = u[f];
290
+ o && typeof o == "object" && !Array.isArray(o) && !s.has(o) && (s.add(o), a.push({ node: o, depth: c + 1 }));
291
291
  }
292
292
  }
293
293
  return null;
@@ -297,37 +297,37 @@ class n {
297
297
  * trimmed string[] with empties removed.
298
298
  */
299
299
  static normalizeTags(t) {
300
- const e = /* @__PURE__ */ new Set();
301
- for (const r of t) {
302
- if (r == null) continue;
303
- const s = String(r).trim().toLowerCase();
304
- s && e.add(s);
300
+ const r = /* @__PURE__ */ new Set();
301
+ for (const e of t) {
302
+ if (e == null) continue;
303
+ const s = String(e).trim().toLowerCase();
304
+ s && r.add(s);
305
305
  }
306
- return Array.from(e);
306
+ return Array.from(r);
307
307
  }
308
308
  static convertAttributes(t) {
309
309
  if (!Array.isArray(t))
310
310
  return null;
311
- const e = {};
312
- for (const r of t)
313
- r.trait_type && r.value !== void 0 && (e[r.trait_type] = r.value);
314
- return Object.keys(e).length > 0 ? e : null;
311
+ const r = {};
312
+ for (const e of t)
313
+ e.trait_type && e.value !== void 0 && (r[e.trait_type] = e.value);
314
+ return Object.keys(r).length > 0 ? r : null;
315
315
  }
316
316
  /**
317
317
  * Safely extract a URI string from a nested object path.
318
318
  * e.g. extractNestedUri(data, 'project', 'artwork', 'uri') => data.project.artwork.uri
319
319
  */
320
- static extractNestedUri(t, ...e) {
321
- let r = t;
322
- for (const s of e)
323
- if (r && typeof r == "object" && !Array.isArray(r))
324
- r = r[s];
320
+ static extractNestedUri(t, ...r) {
321
+ let e = t;
322
+ for (const s of r)
323
+ if (e && typeof e == "object" && !Array.isArray(e))
324
+ e = e[s];
325
325
  else
326
326
  return null;
327
- return typeof r == "string" ? r : null;
327
+ return typeof e == "string" ? e : null;
328
328
  }
329
329
  }
330
- function m(i) {
330
+ function _(i) {
331
331
  if ("audio_url" in i && typeof i.audio_url == "string")
332
332
  return i.audio_url;
333
333
  if ("metadata" in i) {
@@ -337,7 +337,7 @@ function m(i) {
337
337
  }
338
338
  return null;
339
339
  }
340
- function h(i) {
340
+ function A(i) {
341
341
  if ("audio_url_lossless" in i && typeof i.audio_url_lossless == "string")
342
342
  return i.audio_url_lossless;
343
343
  if ("metadata" in i) {
@@ -359,7 +359,7 @@ function g(i) {
359
359
  }
360
360
  return null;
361
361
  }
362
- function d(i) {
362
+ function y(i) {
363
363
  if ("image_thumb_url" in i && typeof i.image_thumb_url == "string")
364
364
  return i.image_thumb_url;
365
365
  if ("metadata" in i) {
@@ -369,7 +369,7 @@ function d(i) {
369
369
  }
370
370
  return null;
371
371
  }
372
- function _(i) {
372
+ function h(i) {
373
373
  if ("metadata" in i) {
374
374
  const t = n.parseMetadata(i.metadata);
375
375
  if (t && typeof t.vrm == "string" && t.vrm)
@@ -377,201 +377,205 @@ function _(i) {
377
377
  }
378
378
  return "extras" in i && i.extras && typeof i.extras.vrm == "string" && i.extras.vrm || null;
379
379
  }
380
- function x(i) {
380
+ function M(i) {
381
381
  const t = [];
382
- for (const e of i.tracks) {
383
- const r = m(e);
384
- r && t.push(r);
382
+ for (const r of i.tracks) {
383
+ const e = _(r);
384
+ e && t.push(e);
385
385
  }
386
386
  return t;
387
387
  }
388
- function v(i) {
388
+ function j(i) {
389
389
  const t = [];
390
- for (const e of i.tracks) {
391
- const r = g(e);
392
- r && t.push(r);
390
+ for (const r of i.tracks) {
391
+ const e = g(r);
392
+ e && t.push(e);
393
393
  }
394
394
  return t;
395
395
  }
396
- function T(i) {
396
+ function F(i) {
397
397
  const t = [];
398
- for (const e of i.tracks) {
399
- if ("title" in e && typeof e.title == "string") {
400
- t.push(e.title);
398
+ for (const r of i.tracks) {
399
+ if ("title" in r && typeof r.title == "string") {
400
+ t.push(r.title);
401
401
  continue;
402
402
  }
403
- if ("metadata" in e) {
404
- const r = n.parseMetadata(e.metadata);
405
- if (r) {
406
- const s = n.extractTitle(r);
403
+ if ("metadata" in r) {
404
+ const e = n.parseMetadata(r.metadata);
405
+ if (e) {
406
+ const s = n.extractTitle(e);
407
407
  s && t.push(s);
408
408
  }
409
409
  }
410
410
  }
411
411
  return t;
412
412
  }
413
- function U(i) {
413
+ function $(i) {
414
414
  const t = [];
415
- for (const e of i.tracks) {
416
- if ("artist" in e && typeof e.artist == "string") {
417
- t.push(e.artist);
415
+ for (const r of i.tracks) {
416
+ if ("artist" in r && typeof r.artist == "string") {
417
+ t.push(r.artist);
418
418
  continue;
419
419
  }
420
- if ("metadata" in e) {
421
- const r = n.parseMetadata(e.metadata);
422
- if (r) {
423
- const s = n.extractArtist(r);
420
+ if ("metadata" in r) {
421
+ const e = n.parseMetadata(r.metadata);
422
+ if (e) {
423
+ const s = n.extractArtist(e);
424
424
  s && t.push(s);
425
425
  }
426
426
  }
427
427
  }
428
428
  return t;
429
429
  }
430
- function S(i) {
430
+ function D(i) {
431
431
  const t = /* @__PURE__ */ new Set();
432
- for (const e of i.tracks) {
433
- if ("genre" in e && typeof e.genre == "string" && e.genre) {
434
- t.add(e.genre);
432
+ for (const r of i.tracks) {
433
+ if ("genre" in r && typeof r.genre == "string" && r.genre) {
434
+ t.add(r.genre);
435
435
  continue;
436
436
  }
437
- if ("metadata" in e) {
438
- const r = n.parseMetadata(e.metadata);
439
- r && typeof r.genre == "string" && r.genre && t.add(r.genre);
437
+ if ("metadata" in r) {
438
+ const e = n.parseMetadata(r.metadata);
439
+ e && typeof e.genre == "string" && e.genre && t.add(e.genre);
440
440
  }
441
441
  }
442
442
  return Array.from(t).sort();
443
443
  }
444
- function L(i) {
444
+ function I(i) {
445
445
  const t = /* @__PURE__ */ new Set();
446
- for (const e of i.tracks) {
447
- if ("tags" in e && Array.isArray(e.tags)) {
448
- for (const r of e.tags)
449
- r && t.add(r.toLowerCase());
446
+ for (const r of i.tracks) {
447
+ if ("tags" in r && Array.isArray(r.tags)) {
448
+ for (const e of r.tags)
449
+ e && t.add(e.toLowerCase());
450
450
  continue;
451
451
  }
452
- if ("metadata" in e) {
453
- const r = n.parseMetadata(e.metadata);
454
- if (r && Array.isArray(r.tags))
455
- for (const s of r.tags)
452
+ if ("metadata" in r) {
453
+ const e = n.parseMetadata(r.metadata);
454
+ if (e && Array.isArray(e.tags))
455
+ for (const s of e.tags)
456
456
  s && t.add(String(s).toLowerCase());
457
457
  }
458
458
  }
459
459
  return Array.from(t).sort();
460
460
  }
461
- function F(i) {
461
+ function C(i) {
462
462
  let t = 0;
463
- for (const e of i.tracks) {
464
- if ("duration" in e && typeof e.duration == "number") {
465
- t += e.duration;
463
+ for (const r of i.tracks) {
464
+ if ("duration" in r && typeof r.duration == "number") {
465
+ t += r.duration;
466
466
  continue;
467
467
  }
468
- if ("metadata" in e) {
469
- const r = n.parseMetadata(e.metadata);
470
- r && typeof r.duration == "number" && (t += r.duration);
468
+ if ("metadata" in r) {
469
+ const e = n.parseMetadata(r.metadata);
470
+ e && typeof e.duration == "number" && (t += e.duration);
471
471
  }
472
472
  }
473
473
  return t;
474
474
  }
475
- function j(i) {
475
+ function H(i) {
476
476
  return i.tracks.length;
477
477
  }
478
- function M(i) {
478
+ function P(i) {
479
479
  const t = [];
480
- for (const e of i.tracks) {
481
- const r = m(e), s = g(e), o = d(e);
482
- let u = "", c = "";
483
- if ("title" in e)
484
- u = e.title || "", c = e.artist || "";
485
- else if ("metadata" in e) {
486
- const a = n.parseMetadata(e.metadata);
487
- a && (u = n.extractTitle(a) || "", c = n.extractArtist(a) || "");
480
+ for (const r of i.tracks) {
481
+ const e = _(r), s = g(r), a = y(r);
482
+ let u = "", c = "", f;
483
+ if ("title" in r)
484
+ u = r.title || "", c = r.artist || "", f = r.description || void 0;
485
+ else if ("metadata" in r) {
486
+ const o = n.parseMetadata(r.metadata);
487
+ o && (u = n.extractTitle(o) || "", c = n.extractArtist(o) || "", f = n.extractDescription(o) || void 0);
488
488
  }
489
- if (r) {
490
- const a = {
489
+ if (e) {
490
+ const o = {
491
491
  title: u,
492
492
  artist: c,
493
- audio_url: r,
493
+ audio_url: e,
494
494
  image_url: s || ""
495
- }, f = h(e);
496
- f && f !== r && (a.audio_url_lossless = f), o && (a.image_thumb_url = o), "audio_ipfs_hash" in e && typeof e.audio_ipfs_hash == "string" && (a.audio_ipfs_hash = e.audio_ipfs_hash), "artwork_ipfs_hash" in e && typeof e.artwork_ipfs_hash == "string" && (a.artwork_ipfs_hash = e.artwork_ipfs_hash), t.push(a);
495
+ }, l = A(r);
496
+ l && l !== e && (o.audio_url_lossless = l), a && (o.image_thumb_url = a), f && (o.description = f), "audio_ipfs_hash" in r && typeof r.audio_ipfs_hash == "string" && (o.audio_ipfs_hash = r.audio_ipfs_hash), "artwork_ipfs_hash" in r && typeof r.artwork_ipfs_hash == "string" && (o.artwork_ipfs_hash = r.artwork_ipfs_hash), "mint_function" in r && typeof r.mint_function == "string" && (o.mint_function = r.mint_function), "mint_price" in r && typeof r.mint_price == "string" && (o.mint_price = r.mint_price), "mint_snapshot_time" in r && typeof r.mint_snapshot_time == "number" && (o.mint_snapshot_time = r.mint_snapshot_time), "mint_token" in r && typeof r.mint_token == "string" && (o.mint_token = r.mint_token), t.push(o);
497
497
  }
498
498
  }
499
499
  return t;
500
500
  }
501
- function I(i) {
501
+ function W(i) {
502
502
  const t = [];
503
- for (const e of i.tracks) {
504
- if ("audio_url" in e) {
505
- t.push({ ...e });
503
+ for (const r of i.tracks) {
504
+ if ("audio_url" in r) {
505
+ t.push({ ...r });
506
506
  continue;
507
507
  }
508
- if ("metadata" in e) {
509
- const r = n.parseMetadata(e.metadata);
510
- if (r) {
511
- const s = n.extractAudioUrlLossless(r), o = n.extractAudioUrl(r);
508
+ if ("metadata" in r) {
509
+ const e = n.parseMetadata(r.metadata);
510
+ if (e) {
511
+ const s = n.extractAudioUrlLossless(e), a = n.extractAudioUrl(e);
512
512
  t.push({
513
- id: e.chain_name === "AR" ? `AR-${e.tx_id}` : `${e.chain_name}-${e.token_address}-${e.token_id}`,
514
- chain_name: e.chain_name,
515
- token_address: e.token_address,
516
- token_id: e.token_id,
517
- tx_id: e.tx_id,
518
- platform: e.platform,
519
- title: n.extractTitle(r),
520
- artist: n.extractArtist(r),
521
- audio_url: o,
522
- image_url: n.extractImageUrl(r),
523
- image_thumb_url: n.extractImageThumbUrl(r),
524
- duration: r.duration,
525
- genre: r.genre,
526
- tags: r.tags,
527
- bpm: r.bpm,
528
- key: r.key,
529
- album: r.album,
530
- description: r.description,
531
- attributes: n.convertAttributes(r.attributes),
532
- ...s && s !== o ? { audio_url_lossless: s } : {},
533
- // v0.4 IPFS hash fields from raw track (mint fields live only in metadata interior)
534
- ...e.audio_ipfs_hash ? { audio_ipfs_hash: e.audio_ipfs_hash } : {},
535
- ...e.artwork_ipfs_hash ? { artwork_ipfs_hash: e.artwork_ipfs_hash } : {}
513
+ id: r.chain_name === "AR" ? `AR-${r.tx_id}` : `${r.chain_name}-${r.token_address}-${r.token_id}`,
514
+ chain_name: r.chain_name,
515
+ token_address: r.token_address,
516
+ token_id: r.token_id,
517
+ tx_id: r.tx_id,
518
+ platform: r.platform,
519
+ title: n.extractTitle(e),
520
+ artist: n.extractArtist(e),
521
+ audio_url: a,
522
+ image_url: n.extractImageUrl(e),
523
+ image_thumb_url: n.extractImageThumbUrl(e),
524
+ duration: e.duration,
525
+ genre: e.genre,
526
+ tags: e.tags,
527
+ bpm: e.bpm,
528
+ key: e.key,
529
+ album: e.album,
530
+ description: n.extractDescription(e),
531
+ attributes: n.convertAttributes(e.attributes),
532
+ ...s && s !== a ? { audio_url_lossless: s } : {},
533
+ // v0.4 IPFS hash + mint fields from the raw track wrapper
534
+ ...r.audio_ipfs_hash ? { audio_ipfs_hash: r.audio_ipfs_hash } : {},
535
+ ...r.artwork_ipfs_hash ? { artwork_ipfs_hash: r.artwork_ipfs_hash } : {},
536
+ ...r.mint_function ? { mint_function: r.mint_function } : {},
537
+ ...r.mint_price ? { mint_price: r.mint_price } : {},
538
+ ...r.mint_snapshot_time ? { mint_snapshot_time: r.mint_snapshot_time } : {},
539
+ ...r.mint_token ? { mint_token: r.mint_token } : {}
536
540
  });
537
541
  }
538
542
  }
539
543
  }
540
544
  return t;
541
545
  }
542
- function $(i) {
546
+ function E(i) {
543
547
  const t = [];
544
- for (const e of i.tracks) {
545
- const r = _(e);
546
- r && t.push(r);
548
+ for (const r of i.tracks) {
549
+ const e = h(r);
550
+ e && t.push(e);
547
551
  }
548
552
  return t;
549
553
  }
550
- function W(i) {
554
+ function N(i) {
551
555
  const t = [];
552
- for (const e of i.tracks) {
553
- const r = _(e);
554
- if (!r) continue;
555
- const s = m(e), o = g(e), u = d(e);
556
- let c = "", a = "";
557
- if ("title" in e)
558
- c = e.title || "", a = e.artist || "";
559
- else if ("metadata" in e) {
560
- const l = n.parseMetadata(e.metadata);
561
- l && (c = n.extractTitle(l) || "", a = n.extractArtist(l) || "");
556
+ for (const r of i.tracks) {
557
+ const e = h(r);
558
+ if (!e) continue;
559
+ const s = _(r), a = g(r), u = y(r);
560
+ let c = "", f = "", o;
561
+ if ("title" in r)
562
+ c = r.title || "", f = r.artist || "", o = r.description || void 0;
563
+ else if ("metadata" in r) {
564
+ const p = n.parseMetadata(r.metadata);
565
+ p && (c = n.extractTitle(p) || "", f = n.extractArtist(p) || "", o = n.extractDescription(p) || void 0);
562
566
  }
563
- const f = {
567
+ const l = {
564
568
  title: c,
565
- artist: a,
569
+ artist: f,
566
570
  audio_url: s || "",
567
- image_url: o || "",
568
- vrm: r
571
+ image_url: a || "",
572
+ vrm: e
569
573
  };
570
- u && (f.image_thumb_url = u), t.push(f);
574
+ u && (l.image_thumb_url = u), o && (l.description = o), t.push(l);
571
575
  }
572
576
  return t;
573
577
  }
574
- const y = [
578
+ const d = [
575
579
  "ipfs.io",
576
580
  "cloudflare-ipfs.com",
577
581
  "dweb.link",
@@ -585,78 +589,93 @@ const y = [
585
589
  "spinamp.mypinata.cloud",
586
590
  "catalogworks.b-cdn.net",
587
591
  "www.heds.cloud"
588
- ], A = "ipfs.io", p = "/ipfs/";
592
+ ], k = "ipfs.io", m = "/ipfs/", w = /^Qm[1-9A-HJ-NP-Za-km-z]{44}$/, x = /^b[a-z2-7]{55,}$/;
593
+ function v(i) {
594
+ return w.test(i) || x.test(i);
595
+ }
596
+ const T = /^ipfs_[a-z]+$/;
589
597
  function b(i) {
598
+ const t = i.split("/").filter(Boolean);
599
+ for (let r = 0; r < t.length - 1; r++)
600
+ if (T.test(t[r]) && v(t[r + 1])) {
601
+ const e = t[r + 1], s = t.slice(r + 2);
602
+ return s.length > 0 ? `${e}/${s.join("/")}` : e;
603
+ }
604
+ return null;
605
+ }
606
+ function U(i) {
590
607
  if (!i || typeof i != "string") return null;
591
608
  if (i.startsWith("ipfs://ipfs/"))
592
609
  return i.slice(12);
593
610
  if (i.startsWith("ipfs://"))
594
611
  return i.slice(7);
595
612
  try {
596
- const t = new URL(i), { hostname: e, pathname: r } = t, s = e.match(/^([A-Za-z0-9]+)\.ipfs\.dweb\.link$/);
613
+ const t = new URL(i), { hostname: r, pathname: e } = t, s = r.match(/^([A-Za-z0-9]+)\.ipfs\.dweb\.link$/);
597
614
  if (s)
598
- return `${s[1]}${r}`;
599
- if (y.some(
600
- (u) => e === u || e.endsWith("." + u)
601
- ) && r.startsWith(p))
602
- return r.slice(p.length);
615
+ return `${s[1]}${e}`;
616
+ if (d.some(
617
+ (c) => r === c || r.endsWith("." + c)
618
+ ) && e.startsWith(m))
619
+ return e.slice(m.length);
620
+ const u = b(e);
621
+ if (u) return u;
603
622
  } catch {
604
623
  }
605
624
  return null;
606
625
  }
607
- function H(i) {
626
+ function R(i) {
608
627
  if (!i || typeof i != "string") return !1;
609
628
  if (i.startsWith("ipfs://")) return !0;
610
629
  try {
611
- const t = new URL(i), { hostname: e, pathname: r } = t;
612
- if (/^[A-Za-z0-9]+\.ipfs\.dweb\.link$/.test(e) || y.some(
613
- (o) => e === o || e.endsWith("." + o)
614
- ) && r.startsWith(p)) return !0;
630
+ const t = new URL(i), { hostname: r, pathname: e } = t;
631
+ if (/^[A-Za-z0-9]+\.ipfs\.dweb\.link$/.test(r) || d.some(
632
+ (a) => r === a || r.endsWith("." + a)
633
+ ) && e.startsWith(m) || b(e)) return !0;
615
634
  } catch {
616
635
  }
617
636
  return !1;
618
637
  }
619
- function k(i) {
638
+ function S(i) {
620
639
  if (!(!i || i.startsWith("ipfs://")))
621
640
  try {
622
641
  const { hostname: t } = new URL(i);
623
- return y.some(
624
- (r) => t === r || t.endsWith("." + r)
642
+ return d.some(
643
+ (e) => t === e || t.endsWith("." + e)
625
644
  ) ? t : void 0;
626
645
  } catch {
627
646
  return;
628
647
  }
629
648
  }
630
- function P(i, t = {}) {
649
+ function G(i, t = {}) {
631
650
  if (!i) return i;
632
- const e = typeof t == "string" ? { gatewayHost: t } : t, { gatewayHost: r = A, preserveOriginalGateway: s = !1 } = e, o = b(i);
633
- if (o) {
651
+ const r = typeof t == "string" ? { gatewayHost: t } : t, { gatewayHost: e = k, preserveOriginalGateway: s = !1 } = r, a = U(i);
652
+ if (a) {
634
653
  if (s) {
635
- const u = k(i);
654
+ const u = S(i);
636
655
  if (u)
637
- return `https://${u}/ipfs/${o}`;
656
+ return `https://${u}/ipfs/${a}`;
638
657
  }
639
- return `https://${r}/ipfs/${o}`;
658
+ return `https://${e}/ipfs/${a}`;
640
659
  }
641
660
  return i;
642
661
  }
643
662
  export {
644
- A as D,
645
- y as K,
663
+ k as D,
664
+ d as K,
646
665
  n as M,
647
- x as a,
648
- I as b,
649
- S as c,
650
- v as d,
651
- b as e,
652
- L as f,
653
- U as g,
654
- F as h,
655
- j as i,
656
- T as j,
657
- M as k,
658
- W as l,
659
- $ as m,
660
- H as n,
661
- P as r
666
+ M as a,
667
+ W as b,
668
+ D as c,
669
+ j as d,
670
+ U as e,
671
+ I as f,
672
+ $ as g,
673
+ C as h,
674
+ H as i,
675
+ F as j,
676
+ P as k,
677
+ N as l,
678
+ E as m,
679
+ R as n,
680
+ G as r
662
681
  };