snice 3.6.0 → 3.8.0

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 (80) hide show
  1. package/README.md +2 -2
  2. package/bin/snice.js +4 -5
  3. package/bin/templates/CLAUDE.md +25 -3
  4. package/bin/templates/pwa/README.md +188 -0
  5. package/bin/templates/pwa/global.d.ts +10 -0
  6. package/bin/templates/pwa/index.html +16 -0
  7. package/bin/templates/pwa/package.json +32 -0
  8. package/bin/templates/pwa/public/icons/.gitkeep +6 -0
  9. package/bin/templates/pwa/src/daemons/notifications.ts +148 -0
  10. package/bin/templates/pwa/src/fetcher.ts +15 -0
  11. package/bin/templates/pwa/src/guards/auth.ts +12 -0
  12. package/bin/templates/pwa/src/main.ts +42 -0
  13. package/bin/templates/pwa/src/middleware/auth.ts +16 -0
  14. package/bin/templates/pwa/src/middleware/error.ts +36 -0
  15. package/bin/templates/pwa/src/middleware/retry.ts +31 -0
  16. package/bin/templates/pwa/src/pages/dashboard.ts +143 -0
  17. package/bin/templates/pwa/src/pages/login.ts +161 -0
  18. package/bin/templates/pwa/src/pages/notifications.ts +156 -0
  19. package/bin/templates/pwa/src/pages/profile.ts +164 -0
  20. package/bin/templates/pwa/src/router.ts +20 -0
  21. package/bin/templates/pwa/src/services/auth.ts +48 -0
  22. package/bin/templates/pwa/src/services/jwt.ts +35 -0
  23. package/bin/templates/pwa/src/services/storage.ts +24 -0
  24. package/bin/templates/pwa/src/styles/global.css +55 -0
  25. package/bin/templates/pwa/src/types/auth.ts +21 -0
  26. package/bin/templates/pwa/src/types/notifications.ts +9 -0
  27. package/bin/templates/pwa/tests/helpers/test-utils.ts +84 -0
  28. package/bin/templates/pwa/tests/middleware/auth.test.ts +67 -0
  29. package/bin/templates/pwa/tests/middleware/error.test.ts +105 -0
  30. package/bin/templates/pwa/tests/middleware/retry.test.ts +103 -0
  31. package/bin/templates/pwa/tests/services/auth.test.ts +89 -0
  32. package/bin/templates/pwa/tests/services/jwt.test.ts +76 -0
  33. package/bin/templates/pwa/tests/services/storage.test.ts +69 -0
  34. package/bin/templates/{social → pwa}/tsconfig.json +11 -10
  35. package/bin/templates/pwa/vite.config.ts +94 -0
  36. package/bin/templates/{social/vite.config.ts → pwa/vitest.config.ts} +12 -17
  37. package/dist/components/music-player/snice-music-player.d.ts +72 -0
  38. package/dist/components/music-player/snice-music-player.js +730 -0
  39. package/dist/components/music-player/snice-music-player.js.map +1 -0
  40. package/dist/components/music-player/snice-music-player.types.d.ts +43 -0
  41. package/dist/components/timer/snice-timer.d.ts +27 -0
  42. package/dist/components/timer/snice-timer.js +197 -0
  43. package/dist/components/timer/snice-timer.js.map +1 -0
  44. package/dist/components/timer/snice-timer.types.d.ts +10 -0
  45. package/dist/fetcher.d.ts +65 -0
  46. package/dist/index.cjs +92 -3
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.ts +2 -0
  49. package/dist/index.esm.js +92 -4
  50. package/dist/index.esm.js.map +1 -1
  51. package/dist/index.iife.js +92 -3
  52. package/dist/index.iife.js.map +1 -1
  53. package/dist/symbols.cjs +1 -1
  54. package/dist/symbols.esm.js +1 -1
  55. package/dist/transitions.cjs +1 -1
  56. package/dist/transitions.esm.js +1 -1
  57. package/dist/types/context.d.ts +7 -1
  58. package/dist/types/router-options.d.ts +6 -0
  59. package/docs/ai/api.md +33 -1
  60. package/docs/ai/components/music-player.md +134 -0
  61. package/docs/ai/components/timer.md +43 -0
  62. package/docs/ai/patterns.md +48 -1
  63. package/docs/components/music-player.md +314 -0
  64. package/docs/components/timer.md +143 -0
  65. package/docs/fetcher.md +447 -0
  66. package/docs/routing.md +11 -8
  67. package/package.json +2 -1
  68. package/bin/templates/social/README.md +0 -42
  69. package/bin/templates/social/global.d.ts +0 -14
  70. package/bin/templates/social/index.html +0 -13
  71. package/bin/templates/social/package.json +0 -21
  72. package/bin/templates/social/src/main.ts +0 -33
  73. package/bin/templates/social/src/pages/feed-page.ts +0 -111
  74. package/bin/templates/social/src/pages/messages-page.ts +0 -102
  75. package/bin/templates/social/src/pages/not-found-page.ts +0 -46
  76. package/bin/templates/social/src/pages/profile-page.ts +0 -99
  77. package/bin/templates/social/src/pages/settings-page.ts +0 -119
  78. package/bin/templates/social/src/router.ts +0 -9
  79. package/bin/templates/social/src/styles/global.css +0 -156
  80. /package/bin/templates/{social → pwa}/public/vite.svg +0 -0
@@ -0,0 +1,730 @@
1
+ import { __esDecorate, __runInitializers } from 'tslib';
2
+ import { element, property, query, styles, ready, dispose, watch, render, dispatch, css, html } from 'snice';
3
+
4
+ var playerStyles = ":host{display:block;font-family:var(--snice-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);contain:layout style paint}.player-container{background:var(--snice-color-background,rgb(255 255 255));border:1px solid var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-lg,.5rem);padding:var(--snice-spacing-lg,1.5rem);box-shadow:var(--snice-shadow-md,0 4px 6px -1px rgb(0 0 0 / .1),0 2px 4px -2px rgb(0 0 0 / .1))}.player-info{display:flex;align-items:center;gap:var(--snice-spacing-md,1rem);margin-bottom:var(--snice-spacing-lg,1.5rem)}.player-artwork{flex-shrink:0;width:5rem;height:5rem;border-radius:var(--snice-border-radius-md,.25rem);overflow:hidden;background:var(--snice-color-background-secondary,rgb(250 250 250));display:flex;align-items:center;justify-content:center}.player-artwork img{width:100%;height:100%;object-fit:cover}.player-artwork-placeholder{color:var(--snice-color-text-tertiary,rgb(115 115 115))}.player-track-info{flex:1;min-width:0}.player-track-title{font-size:var(--snice-font-size-lg, 1.125rem);font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-text,rgb(23 23 23));margin-bottom:var(--snice-spacing-3xs,.125rem);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-track-artist{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text-secondary,rgb(82 82 82));margin-bottom:var(--snice-spacing-3xs,.125rem);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-track-album{font-size:var(--snice-font-size-xs, .75rem);color:var(--snice-color-text-tertiary,rgb(115 115 115));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-controls{margin-bottom:var(--snice-spacing-md,1rem);overflow:visible}.player-control-buttons{display:flex;align-items:center;justify-content:center;gap:var(--snice-spacing-sm,.75rem);margin-bottom:var(--snice-spacing-md,1rem)}.player-btn{background:0 0;border:none;cursor:pointer;padding:var(--snice-spacing-xs,.5rem);border-radius:var(--snice-border-radius-md,.25rem);color:var(--snice-color-text,rgb(23 23 23));display:inline-flex;align-items:center;justify-content:center;transition:background-color var(--snice-transition-fast, 150ms) ease}.player-btn:hover:not(:disabled){background:var(--snice-color-background-hover,rgb(241 241 241))}.player-btn:active:not(:disabled){background:var(--snice-color-background-active,rgb(226 226 226))}.player-btn:disabled{opacity:.5;cursor:not-allowed}.player-btn.active{color:var(--snice-color-primary,rgb(37 99 235))}.player-btn-play-pause{background:var(--snice-color-primary,rgb(37 99 235));color:var(--snice-color-text-inverse,rgb(250 250 250));padding:var(--snice-spacing-md,1rem);border-radius:var(--snice-border-radius-circle,50%)}.player-btn-play-pause:active:not(:disabled),.player-btn-play-pause:hover:not(:disabled){background:var(--snice-color-primary-hover,rgb(29 78 216))}.player-progress-container{display:flex;align-items:center;gap:var(--snice-spacing-sm,.75rem);position:relative}.player-time{font-size:var(--snice-font-size-xs, .75rem);font-variant-numeric:tabular-nums;color:var(--snice-color-text-secondary,rgb(82 82 82));min-width:2.5rem}.player-time-current{text-align:right}.player-progress{flex:1;height:.375rem;background:var(--snice-color-background-secondary,rgb(250 250 250));border-radius:var(--snice-border-radius-pill,9999px);cursor:pointer;position:relative;overflow:hidden}.player-progress:hover{background:var(--snice-color-background-tertiary,rgb(241 241 241))}.player-progress-bar{height:100%;background:var(--snice-color-primary,rgb(37 99 235));border-radius:var(--snice-border-radius-pill,9999px);transition:width .1s linear}.player-volume{display:flex;align-items:center;gap:var(--snice-spacing-xs,.5rem);margin-left:var(--snice-spacing-sm,.75rem)}.player-btn-volume{flex-shrink:0}.player-volume-slider-container{display:flex;align-items:center}.player-volume-slider{-webkit-appearance:none;appearance:none;width:5rem;height:.375rem;background:linear-gradient(to right,var(--snice-color-primary,rgb(37 99 235)) 0,var(--snice-color-primary,rgb(37 99 235)) var(--volume-percent,100%),var(--snice-color-background-secondary,rgb(250 250 250)) var(--volume-percent,100%),var(--snice-color-background-secondary,rgb(250 250 250)) 100%);border-radius:var(--snice-border-radius-pill,9999px);outline:0;cursor:pointer}.player-volume-slider::-webkit-slider-runnable-track{width:100%;height:.375rem;background:0 0;border-radius:var(--snice-border-radius-pill,9999px)}.player-volume-slider::-moz-range-track{width:100%;height:.375rem;background:var(--snice-color-background-secondary,rgb(250 250 250));border-radius:var(--snice-border-radius-pill,9999px)}.player-volume-slider::-moz-range-progress{height:.375rem;background:var(--snice-color-primary,rgb(37 99 235));border-radius:var(--snice-border-radius-pill,9999px)}.player-volume-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:.875rem;height:.875rem;background:var(--snice-color-primary,rgb(37 99 235));border-radius:var(--snice-border-radius-circle,50%);cursor:pointer;transition:transform var(--snice-transition-fast, 150ms) ease;margin-top:-.25rem}.player-volume-slider::-webkit-slider-thumb:hover{transform:scale(1.15)}.player-volume-slider::-moz-range-thumb{width:.875rem;height:.875rem;background:var(--snice-color-primary,rgb(37 99 235));border:none;border-radius:var(--snice-border-radius-circle,50%);cursor:pointer;transition:transform var(--snice-transition-fast, 150ms) ease}.player-volume-slider::-moz-range-thumb:hover{transform:scale(1.15)}.player-playlist{border-top:1px solid var(--snice-color-border,rgb(226 226 226));padding-top:var(--snice-spacing-md,1rem);margin-top:var(--snice-spacing-md,1rem)}.player-playlist-header{font-size:var(--snice-font-size-sm, .875rem);font-weight:var(--snice-font-weight-semibold,600);color:var(--snice-color-text,rgb(23 23 23));margin-bottom:var(--snice-spacing-sm,.75rem)}.player-playlist-items{display:flex;flex-direction:column;gap:var(--snice-spacing-2xs,.25rem);max-height:15rem;overflow-y:auto}.player-playlist-item{display:flex;align-items:center;gap:var(--snice-spacing-sm,.75rem);padding:var(--snice-spacing-sm,.75rem);border-radius:var(--snice-border-radius-md,.25rem);cursor:pointer;transition:background-color var(--snice-transition-fast, 150ms) ease}.player-playlist-item:hover{background:var(--snice-color-background-hover,rgb(241 241 241))}.player-playlist-item.active{background:var(--snice-color-primary-subtle,rgb(239 246 255))}.player-playlist-item.active .player-playlist-item-title{color:var(--snice-color-primary,rgb(37 99 235));font-weight:var(--snice-font-weight-medium,500)}.player-playlist-item-number{font-size:var(--snice-font-size-xs, .75rem);font-variant-numeric:tabular-nums;color:var(--snice-color-text-tertiary,rgb(115 115 115));width:1.5rem;text-align:center;flex-shrink:0}.player-playlist-item-artwork{width:2.5rem;height:2.5rem;border-radius:var(--snice-border-radius-sm,.125rem);object-fit:cover;flex-shrink:0}.player-playlist-item-info{flex:1;min-width:0}.player-playlist-item-title{font-size:var(--snice-font-size-sm, .875rem);color:var(--snice-color-text,rgb(23 23 23));margin-bottom:var(--snice-spacing-3xs,.125rem);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-playlist-item-artist{font-size:var(--snice-font-size-xs, .75rem);color:var(--snice-color-text-secondary,rgb(82 82 82));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.player-playlist-item-duration{font-size:var(--snice-font-size-xs, .75rem);font-variant-numeric:tabular-nums;color:var(--snice-color-text-tertiary,rgb(115 115 115));flex-shrink:0}.player-playlist-items::-webkit-scrollbar{width:.5rem}.player-playlist-items::-webkit-scrollbar-track{background:var(--snice-color-background-secondary,rgb(250 250 250));border-radius:var(--snice-border-radius-pill,9999px)}.player-playlist-items::-webkit-scrollbar-thumb{background:var(--snice-color-border,rgb(226 226 226));border-radius:var(--snice-border-radius-pill,9999px)}.player-playlist-items::-webkit-scrollbar-thumb:hover{background:var(--snice-color-border-hover,rgb(204 204 204))}.player-container--compact{padding:var(--snice-spacing-sm,.75rem);display:flex;align-items:center;gap:var(--snice-spacing-md,1rem)}.player-container--compact .player-info{gap:var(--snice-spacing-sm,.75rem);margin-bottom:0;flex-shrink:0}.player-container--compact .player-artwork{width:3rem;height:3rem}.player-container--compact .player-track-title{font-size:var(--snice-font-size-sm, .875rem)}.player-container--compact .player-track-artist{font-size:var(--snice-font-size-xs, .75rem)}.player-container--compact .player-track-album{display:none}.player-container--compact .player-controls{flex:1;margin-bottom:0;display:flex;align-items:center;gap:var(--snice-spacing-sm,.75rem)}.player-container--compact .player-control-buttons{gap:var(--snice-spacing-xs,.5rem);margin-bottom:0}.player-container--compact .player-btn{padding:var(--snice-spacing-2xs,.25rem)}.player-container--compact .player-btn svg{width:1.25rem;height:1.25rem}.player-container--compact .player-btn-play-pause{padding:var(--snice-spacing-xs,.5rem)}.player-container--compact .player-btn-play-pause svg{width:1.5rem;height:1.5rem}.player-container--compact .player-progress-container{flex:1}.player-container--compact .player-time{font-size:var(--snice-font-size-2xs, .625rem);min-width:2rem}";
5
+
6
+ let SniceMusicPlayer = (() => {
7
+ let _classDecorators = [element('snice-music-player')];
8
+ let _classDescriptor;
9
+ let _classExtraInitializers = [];
10
+ let _classThis;
11
+ let _classSuper = HTMLElement;
12
+ let _instanceExtraInitializers = [];
13
+ let _tracks_decorators;
14
+ let _tracks_initializers = [];
15
+ let _tracks_extraInitializers = [];
16
+ let _currentTrackIndex_decorators;
17
+ let _currentTrackIndex_initializers = [];
18
+ let _currentTrackIndex_extraInitializers = [];
19
+ let _currentTrack_decorators;
20
+ let _currentTrack_initializers = [];
21
+ let _currentTrack_extraInitializers = [];
22
+ let _volume_decorators;
23
+ let _volume_initializers = [];
24
+ let _volume_extraInitializers = [];
25
+ let _muted_decorators;
26
+ let _muted_initializers = [];
27
+ let _muted_extraInitializers = [];
28
+ let _shuffle_decorators;
29
+ let _shuffle_initializers = [];
30
+ let _shuffle_extraInitializers = [];
31
+ let _repeat_decorators;
32
+ let _repeat_initializers = [];
33
+ let _repeat_extraInitializers = [];
34
+ let _state_decorators;
35
+ let _state_initializers = [];
36
+ let _state_extraInitializers = [];
37
+ let _autoplay_decorators;
38
+ let _autoplay_initializers = [];
39
+ let _autoplay_extraInitializers = [];
40
+ let _showPlaylist_decorators;
41
+ let _showPlaylist_initializers = [];
42
+ let _showPlaylist_extraInitializers = [];
43
+ let _showControls_decorators;
44
+ let _showControls_initializers = [];
45
+ let _showControls_extraInitializers = [];
46
+ let _showVolume_decorators;
47
+ let _showVolume_initializers = [];
48
+ let _showVolume_extraInitializers = [];
49
+ let _showArtwork_decorators;
50
+ let _showArtwork_initializers = [];
51
+ let _showArtwork_extraInitializers = [];
52
+ let _showTrackInfo_decorators;
53
+ let _showTrackInfo_initializers = [];
54
+ let _showTrackInfo_extraInitializers = [];
55
+ let _compact_decorators;
56
+ let _compact_initializers = [];
57
+ let _compact_extraInitializers = [];
58
+ let _showVolumeSlider_decorators;
59
+ let _showVolumeSlider_initializers = [];
60
+ let _showVolumeSlider_extraInitializers = [];
61
+ let _progressElement_decorators;
62
+ let _progressElement_initializers = [];
63
+ let _progressElement_extraInitializers = [];
64
+ let _volumeSlider_decorators;
65
+ let _volumeSlider_initializers = [];
66
+ let _volumeSlider_extraInitializers = [];
67
+ let _componentStyles_decorators;
68
+ let _init_decorators;
69
+ let _cleanup_decorators;
70
+ let _handleTracksChange_decorators;
71
+ let _handleCurrentTrackChange_decorators;
72
+ let _handleVolumeChange_decorators;
73
+ let _handleMutedChange_decorators;
74
+ let _renderPlayer_decorators;
75
+ let _emitPlay_decorators;
76
+ let _emitPause_decorators;
77
+ let _emitStop_decorators;
78
+ let _emitTrackChange_decorators;
79
+ let _emitTrackEnded_decorators;
80
+ let _emitSeek_decorators;
81
+ let _emitVolumeChange_decorators;
82
+ let _emitShuffleChange_decorators;
83
+ let _emitRepeatChange_decorators;
84
+ let _emitError_decorators;
85
+ (class extends _classSuper {
86
+ static { _classThis = this; }
87
+ static {
88
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
89
+ _tracks_decorators = [property({ type: Array })];
90
+ _currentTrackIndex_decorators = [property({ type: Number, attribute: 'current-track-index' })];
91
+ _currentTrack_decorators = [property({ type: String, attribute: 'current-track' })];
92
+ _volume_decorators = [property({ type: Number })];
93
+ _muted_decorators = [property({ type: Boolean })];
94
+ _shuffle_decorators = [property({ type: Boolean })];
95
+ _repeat_decorators = [property({ type: String })];
96
+ _state_decorators = [property({ type: String })];
97
+ _autoplay_decorators = [property({ type: Boolean })];
98
+ _showPlaylist_decorators = [property({ type: Boolean, attribute: 'show-playlist' })];
99
+ _showControls_decorators = [property({ type: Boolean, attribute: 'show-controls' })];
100
+ _showVolume_decorators = [property({ type: Boolean, attribute: 'show-volume' })];
101
+ _showArtwork_decorators = [property({ type: Boolean, attribute: 'show-artwork' })];
102
+ _showTrackInfo_decorators = [property({ type: Boolean, attribute: 'show-track-info' })];
103
+ _compact_decorators = [property({ type: Boolean })];
104
+ _showVolumeSlider_decorators = [property({ type: Boolean, attribute: 'show-volume-slider' })];
105
+ _progressElement_decorators = [query('.player-progress')];
106
+ _volumeSlider_decorators = [query('.player-volume-slider')];
107
+ _componentStyles_decorators = [styles()];
108
+ _init_decorators = [ready()];
109
+ _cleanup_decorators = [dispose()];
110
+ _handleTracksChange_decorators = [watch('tracks')];
111
+ _handleCurrentTrackChange_decorators = [watch('currentTrack')];
112
+ _handleVolumeChange_decorators = [watch('volume')];
113
+ _handleMutedChange_decorators = [watch('muted')];
114
+ _renderPlayer_decorators = [render()];
115
+ _emitPlay_decorators = [dispatch('@snice/player-play', { bubbles: true, composed: true })];
116
+ _emitPause_decorators = [dispatch('@snice/player-pause', { bubbles: true, composed: true })];
117
+ _emitStop_decorators = [dispatch('@snice/player-stop', { bubbles: true, composed: true })];
118
+ _emitTrackChange_decorators = [dispatch('@snice/player-track-change', { bubbles: true, composed: true })];
119
+ _emitTrackEnded_decorators = [dispatch('@snice/player-track-ended', { bubbles: true, composed: true })];
120
+ _emitSeek_decorators = [dispatch('@snice/player-seek', { bubbles: true, composed: true })];
121
+ _emitVolumeChange_decorators = [dispatch('@snice/player-volume-change', { bubbles: true, composed: true })];
122
+ _emitShuffleChange_decorators = [dispatch('@snice/player-shuffle-change', { bubbles: true, composed: true })];
123
+ _emitRepeatChange_decorators = [dispatch('@snice/player-repeat-change', { bubbles: true, composed: true })];
124
+ _emitError_decorators = [dispatch('@snice/player-error', { bubbles: true, composed: true })];
125
+ __esDecorate(this, null, _componentStyles_decorators, { kind: "method", name: "componentStyles", static: false, private: false, access: { has: obj => "componentStyles" in obj, get: obj => obj.componentStyles }, metadata: _metadata }, null, _instanceExtraInitializers);
126
+ __esDecorate(this, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: obj => "init" in obj, get: obj => obj.init }, metadata: _metadata }, null, _instanceExtraInitializers);
127
+ __esDecorate(this, null, _cleanup_decorators, { kind: "method", name: "cleanup", static: false, private: false, access: { has: obj => "cleanup" in obj, get: obj => obj.cleanup }, metadata: _metadata }, null, _instanceExtraInitializers);
128
+ __esDecorate(this, null, _handleTracksChange_decorators, { kind: "method", name: "handleTracksChange", static: false, private: false, access: { has: obj => "handleTracksChange" in obj, get: obj => obj.handleTracksChange }, metadata: _metadata }, null, _instanceExtraInitializers);
129
+ __esDecorate(this, null, _handleCurrentTrackChange_decorators, { kind: "method", name: "handleCurrentTrackChange", static: false, private: false, access: { has: obj => "handleCurrentTrackChange" in obj, get: obj => obj.handleCurrentTrackChange }, metadata: _metadata }, null, _instanceExtraInitializers);
130
+ __esDecorate(this, null, _handleVolumeChange_decorators, { kind: "method", name: "handleVolumeChange", static: false, private: false, access: { has: obj => "handleVolumeChange" in obj, get: obj => obj.handleVolumeChange }, metadata: _metadata }, null, _instanceExtraInitializers);
131
+ __esDecorate(this, null, _handleMutedChange_decorators, { kind: "method", name: "handleMutedChange", static: false, private: false, access: { has: obj => "handleMutedChange" in obj, get: obj => obj.handleMutedChange }, metadata: _metadata }, null, _instanceExtraInitializers);
132
+ __esDecorate(this, null, _renderPlayer_decorators, { kind: "method", name: "renderPlayer", static: false, private: false, access: { has: obj => "renderPlayer" in obj, get: obj => obj.renderPlayer }, metadata: _metadata }, null, _instanceExtraInitializers);
133
+ __esDecorate(this, null, _emitPlay_decorators, { kind: "method", name: "emitPlay", static: false, private: false, access: { has: obj => "emitPlay" in obj, get: obj => obj.emitPlay }, metadata: _metadata }, null, _instanceExtraInitializers);
134
+ __esDecorate(this, null, _emitPause_decorators, { kind: "method", name: "emitPause", static: false, private: false, access: { has: obj => "emitPause" in obj, get: obj => obj.emitPause }, metadata: _metadata }, null, _instanceExtraInitializers);
135
+ __esDecorate(this, null, _emitStop_decorators, { kind: "method", name: "emitStop", static: false, private: false, access: { has: obj => "emitStop" in obj, get: obj => obj.emitStop }, metadata: _metadata }, null, _instanceExtraInitializers);
136
+ __esDecorate(this, null, _emitTrackChange_decorators, { kind: "method", name: "emitTrackChange", static: false, private: false, access: { has: obj => "emitTrackChange" in obj, get: obj => obj.emitTrackChange }, metadata: _metadata }, null, _instanceExtraInitializers);
137
+ __esDecorate(this, null, _emitTrackEnded_decorators, { kind: "method", name: "emitTrackEnded", static: false, private: false, access: { has: obj => "emitTrackEnded" in obj, get: obj => obj.emitTrackEnded }, metadata: _metadata }, null, _instanceExtraInitializers);
138
+ __esDecorate(this, null, _emitSeek_decorators, { kind: "method", name: "emitSeek", static: false, private: false, access: { has: obj => "emitSeek" in obj, get: obj => obj.emitSeek }, metadata: _metadata }, null, _instanceExtraInitializers);
139
+ __esDecorate(this, null, _emitVolumeChange_decorators, { kind: "method", name: "emitVolumeChange", static: false, private: false, access: { has: obj => "emitVolumeChange" in obj, get: obj => obj.emitVolumeChange }, metadata: _metadata }, null, _instanceExtraInitializers);
140
+ __esDecorate(this, null, _emitShuffleChange_decorators, { kind: "method", name: "emitShuffleChange", static: false, private: false, access: { has: obj => "emitShuffleChange" in obj, get: obj => obj.emitShuffleChange }, metadata: _metadata }, null, _instanceExtraInitializers);
141
+ __esDecorate(this, null, _emitRepeatChange_decorators, { kind: "method", name: "emitRepeatChange", static: false, private: false, access: { has: obj => "emitRepeatChange" in obj, get: obj => obj.emitRepeatChange }, metadata: _metadata }, null, _instanceExtraInitializers);
142
+ __esDecorate(this, null, _emitError_decorators, { kind: "method", name: "emitError", static: false, private: false, access: { has: obj => "emitError" in obj, get: obj => obj.emitError }, metadata: _metadata }, null, _instanceExtraInitializers);
143
+ __esDecorate(null, null, _tracks_decorators, { kind: "field", name: "tracks", static: false, private: false, access: { has: obj => "tracks" in obj, get: obj => obj.tracks, set: (obj, value) => { obj.tracks = value; } }, metadata: _metadata }, _tracks_initializers, _tracks_extraInitializers);
144
+ __esDecorate(null, null, _currentTrackIndex_decorators, { kind: "field", name: "currentTrackIndex", static: false, private: false, access: { has: obj => "currentTrackIndex" in obj, get: obj => obj.currentTrackIndex, set: (obj, value) => { obj.currentTrackIndex = value; } }, metadata: _metadata }, _currentTrackIndex_initializers, _currentTrackIndex_extraInitializers);
145
+ __esDecorate(null, null, _currentTrack_decorators, { kind: "field", name: "currentTrack", static: false, private: false, access: { has: obj => "currentTrack" in obj, get: obj => obj.currentTrack, set: (obj, value) => { obj.currentTrack = value; } }, metadata: _metadata }, _currentTrack_initializers, _currentTrack_extraInitializers);
146
+ __esDecorate(null, null, _volume_decorators, { kind: "field", name: "volume", static: false, private: false, access: { has: obj => "volume" in obj, get: obj => obj.volume, set: (obj, value) => { obj.volume = value; } }, metadata: _metadata }, _volume_initializers, _volume_extraInitializers);
147
+ __esDecorate(null, null, _muted_decorators, { kind: "field", name: "muted", static: false, private: false, access: { has: obj => "muted" in obj, get: obj => obj.muted, set: (obj, value) => { obj.muted = value; } }, metadata: _metadata }, _muted_initializers, _muted_extraInitializers);
148
+ __esDecorate(null, null, _shuffle_decorators, { kind: "field", name: "shuffle", static: false, private: false, access: { has: obj => "shuffle" in obj, get: obj => obj.shuffle, set: (obj, value) => { obj.shuffle = value; } }, metadata: _metadata }, _shuffle_initializers, _shuffle_extraInitializers);
149
+ __esDecorate(null, null, _repeat_decorators, { kind: "field", name: "repeat", static: false, private: false, access: { has: obj => "repeat" in obj, get: obj => obj.repeat, set: (obj, value) => { obj.repeat = value; } }, metadata: _metadata }, _repeat_initializers, _repeat_extraInitializers);
150
+ __esDecorate(null, null, _state_decorators, { kind: "field", name: "state", static: false, private: false, access: { has: obj => "state" in obj, get: obj => obj.state, set: (obj, value) => { obj.state = value; } }, metadata: _metadata }, _state_initializers, _state_extraInitializers);
151
+ __esDecorate(null, null, _autoplay_decorators, { kind: "field", name: "autoplay", static: false, private: false, access: { has: obj => "autoplay" in obj, get: obj => obj.autoplay, set: (obj, value) => { obj.autoplay = value; } }, metadata: _metadata }, _autoplay_initializers, _autoplay_extraInitializers);
152
+ __esDecorate(null, null, _showPlaylist_decorators, { kind: "field", name: "showPlaylist", static: false, private: false, access: { has: obj => "showPlaylist" in obj, get: obj => obj.showPlaylist, set: (obj, value) => { obj.showPlaylist = value; } }, metadata: _metadata }, _showPlaylist_initializers, _showPlaylist_extraInitializers);
153
+ __esDecorate(null, null, _showControls_decorators, { kind: "field", name: "showControls", static: false, private: false, access: { has: obj => "showControls" in obj, get: obj => obj.showControls, set: (obj, value) => { obj.showControls = value; } }, metadata: _metadata }, _showControls_initializers, _showControls_extraInitializers);
154
+ __esDecorate(null, null, _showVolume_decorators, { kind: "field", name: "showVolume", static: false, private: false, access: { has: obj => "showVolume" in obj, get: obj => obj.showVolume, set: (obj, value) => { obj.showVolume = value; } }, metadata: _metadata }, _showVolume_initializers, _showVolume_extraInitializers);
155
+ __esDecorate(null, null, _showArtwork_decorators, { kind: "field", name: "showArtwork", static: false, private: false, access: { has: obj => "showArtwork" in obj, get: obj => obj.showArtwork, set: (obj, value) => { obj.showArtwork = value; } }, metadata: _metadata }, _showArtwork_initializers, _showArtwork_extraInitializers);
156
+ __esDecorate(null, null, _showTrackInfo_decorators, { kind: "field", name: "showTrackInfo", static: false, private: false, access: { has: obj => "showTrackInfo" in obj, get: obj => obj.showTrackInfo, set: (obj, value) => { obj.showTrackInfo = value; } }, metadata: _metadata }, _showTrackInfo_initializers, _showTrackInfo_extraInitializers);
157
+ __esDecorate(null, null, _compact_decorators, { kind: "field", name: "compact", static: false, private: false, access: { has: obj => "compact" in obj, get: obj => obj.compact, set: (obj, value) => { obj.compact = value; } }, metadata: _metadata }, _compact_initializers, _compact_extraInitializers);
158
+ __esDecorate(null, null, _showVolumeSlider_decorators, { kind: "field", name: "showVolumeSlider", static: false, private: false, access: { has: obj => "showVolumeSlider" in obj, get: obj => obj.showVolumeSlider, set: (obj, value) => { obj.showVolumeSlider = value; } }, metadata: _metadata }, _showVolumeSlider_initializers, _showVolumeSlider_extraInitializers);
159
+ __esDecorate(null, null, _progressElement_decorators, { kind: "field", name: "progressElement", static: false, private: false, access: { has: obj => "progressElement" in obj, get: obj => obj.progressElement, set: (obj, value) => { obj.progressElement = value; } }, metadata: _metadata }, _progressElement_initializers, _progressElement_extraInitializers);
160
+ __esDecorate(null, null, _volumeSlider_decorators, { kind: "field", name: "volumeSlider", static: false, private: false, access: { has: obj => "volumeSlider" in obj, get: obj => obj.volumeSlider, set: (obj, value) => { obj.volumeSlider = value; } }, metadata: _metadata }, _volumeSlider_initializers, _volumeSlider_extraInitializers);
161
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
162
+ _classThis = _classDescriptor.value;
163
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
164
+ __runInitializers(_classThis, _classExtraInitializers);
165
+ }
166
+ componentStyles() {
167
+ return css /*css*/ `${playerStyles}`;
168
+ }
169
+ init() {
170
+ this.audioElement = new Audio();
171
+ this.audioElement.volume = this.volume;
172
+ this.audioElement.muted = this.muted;
173
+ // Set up audio event listeners
174
+ this.audioElement.addEventListener('loadedmetadata', () => {
175
+ this.duration = this.audioElement.duration;
176
+ this.state = this.state === 'loading' ? 'paused' : this.state;
177
+ });
178
+ this.audioElement.addEventListener('play', () => {
179
+ this.state = 'playing';
180
+ this.startUpdateInterval();
181
+ });
182
+ this.audioElement.addEventListener('pause', () => {
183
+ if (!this.audioElement.ended) {
184
+ this.state = 'paused';
185
+ }
186
+ this.stopUpdateInterval();
187
+ });
188
+ this.audioElement.addEventListener('ended', () => {
189
+ this.handleTrackEnded();
190
+ });
191
+ this.audioElement.addEventListener('error', () => {
192
+ this.state = 'error';
193
+ this.emitError(new Error('Failed to load track'));
194
+ });
195
+ this.audioElement.addEventListener('timeupdate', () => {
196
+ this.currentTime = this.audioElement.currentTime;
197
+ });
198
+ // Load first track if available
199
+ if (this.tracks.length > 0) {
200
+ this.loadTrack(this.currentTrackIndex);
201
+ }
202
+ }
203
+ cleanup() {
204
+ this.stop();
205
+ this.stopUpdateInterval();
206
+ if (this.audioElement) {
207
+ this.audioElement.pause();
208
+ this.audioElement.src = '';
209
+ this.audioElement = null;
210
+ }
211
+ }
212
+ handleTracksChange() {
213
+ if (this.tracks.length > 0 && this.currentTrackIndex >= this.tracks.length) {
214
+ this.currentTrackIndex = 0;
215
+ }
216
+ // Reset shuffle queue when tracks change
217
+ if (this.shuffle) {
218
+ this.shuffleQueue = [];
219
+ }
220
+ if (this.tracks.length > 0 && this.audioElement && !this.audioElement.src) {
221
+ this.loadTrack(this.currentTrackIndex);
222
+ }
223
+ }
224
+ handleCurrentTrackChange(oldVal, newVal) {
225
+ if (!newVal || newVal === oldVal)
226
+ return;
227
+ // Find track by ID and load it
228
+ const index = this.tracks.findIndex(t => t.id === newVal);
229
+ if (index >= 0 && index !== this.currentTrackIndex) {
230
+ this.loadTrack(index);
231
+ }
232
+ }
233
+ handleVolumeChange(oldVal, newVal) {
234
+ if (this.audioElement && newVal >= 0 && newVal <= 1) {
235
+ this.audioElement.volume = newVal;
236
+ }
237
+ // Update volume slider fill
238
+ if (this.volumeSlider) {
239
+ this.volumeSlider.style.setProperty('--volume-percent', `${newVal * 100}%`);
240
+ }
241
+ }
242
+ handleMutedChange(oldVal, newVal) {
243
+ if (this.audioElement) {
244
+ this.audioElement.muted = newVal;
245
+ }
246
+ }
247
+ renderPlayer() {
248
+ const currentTrack = this.getCurrentTrack();
249
+ const progress = this.duration > 0 ? (this.currentTime / this.duration) * 100 : 0;
250
+ return html /*html*/ `
251
+ <div class="player-container ${this.compact ? 'player-container--compact' : ''}">
252
+ <if ${this.showArtwork || this.showTrackInfo}>
253
+ <div class="player-info">
254
+ <if ${this.showArtwork}>
255
+ <div class="player-artwork">
256
+ <if ${currentTrack?.artwork}>
257
+ <img src="${currentTrack?.artwork}" alt="${currentTrack?.title || 'Track artwork'}" />
258
+ </if>
259
+ <if ${!currentTrack?.artwork}>
260
+ <div class="player-artwork-placeholder">
261
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
262
+ <circle cx="12" cy="12" r="10"></circle>
263
+ <circle cx="12" cy="12" r="3"></circle>
264
+ </svg>
265
+ </div>
266
+ </if>
267
+ </div>
268
+ </if>
269
+
270
+ <if ${this.showTrackInfo}>
271
+ <div class="player-track-info">
272
+ <div class="player-track-title">${currentTrack?.title || 'No track loaded'}</div>
273
+ <if ${currentTrack?.artist}>
274
+ <div class="player-track-artist">${currentTrack?.artist}</div>
275
+ </if>
276
+ <if ${currentTrack?.album}>
277
+ <div class="player-track-album">${currentTrack?.album}</div>
278
+ </if>
279
+ </div>
280
+ </if>
281
+ </div>
282
+ </if>
283
+
284
+ <if ${this.showControls}>
285
+ <div class="player-controls">
286
+ <div class="player-control-buttons">
287
+ <button
288
+ class="player-btn player-btn-shuffle ${this.shuffle ? 'active' : ''}"
289
+ @click=${() => this.toggleShuffle()}
290
+ title="Shuffle"
291
+ >
292
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
293
+ <path d="M16 3h5v5M4 20L21 3M21 16v5h-5M15 15l6 6M4 4l5 5"/>
294
+ </svg>
295
+ </button>
296
+
297
+ <button
298
+ class="player-btn player-btn-prev"
299
+ @click=${() => this.previous()}
300
+ title="Previous"
301
+ ?disabled=${this.tracks.length === 0}
302
+ >
303
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
304
+ <path d="M6 6h2v12H6zm3.5 6l8.5 6V6z"/>
305
+ </svg>
306
+ </button>
307
+
308
+ <button
309
+ class="player-btn player-btn-play-pause ${this.state === 'playing' ? 'playing' : ''}"
310
+ @click=${() => this.state === 'playing' ? this.pause() : this.play()}
311
+ title="${this.state === 'playing' ? 'Pause' : 'Play'}"
312
+ ?disabled=${this.tracks.length === 0}
313
+ >
314
+ <if ${this.state === 'playing'}>
315
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="currentColor">
316
+ <rect x="6" y="4" width="4" height="16"></rect>
317
+ <rect x="14" y="4" width="4" height="16"></rect>
318
+ </svg>
319
+ </if>
320
+ <if ${this.state !== 'playing'}>
321
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="currentColor">
322
+ <path d="M8 5v14l11-7z"/>
323
+ </svg>
324
+ </if>
325
+ </button>
326
+
327
+ <button
328
+ class="player-btn player-btn-next"
329
+ @click=${() => this.next()}
330
+ title="Next"
331
+ ?disabled=${this.tracks.length === 0}
332
+ >
333
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
334
+ <path d="M16 18h2V6h-2zM6 18l8.5-6L6 6z"/>
335
+ </svg>
336
+ </button>
337
+
338
+ <button
339
+ class="player-btn player-btn-repeat ${this.repeat !== 'off' ? 'active' : ''}"
340
+ @click=${() => this.cycleRepeat()}
341
+ title="Repeat ${this.repeat}"
342
+ >
343
+ <if ${this.repeat === 'one'}>
344
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
345
+ <path d="M17 1l4 4-4 4"/>
346
+ <path d="M3 11V9a4 4 0 0 1 4-4h14"/>
347
+ <path d="M7 23l-4-4 4-4"/>
348
+ <path d="M21 13v2a4 4 0 0 1-4 4H3"/>
349
+ <text x="12" y="15" font-size="8" text-anchor="middle" fill="currentColor">1</text>
350
+ </svg>
351
+ </if>
352
+ <if ${this.repeat !== 'one'}>
353
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
354
+ <path d="M17 1l4 4-4 4"/>
355
+ <path d="M3 11V9a4 4 0 0 1 4-4h14"/>
356
+ <path d="M7 23l-4-4 4-4"/>
357
+ <path d="M21 13v2a4 4 0 0 1-4 4H3"/>
358
+ </svg>
359
+ </if>
360
+ </button>
361
+ </div>
362
+
363
+ <div class="player-progress-container">
364
+ <span class="player-time player-time-current">${this.formatTime(this.currentTime)}</span>
365
+ <div class="player-progress" @click=${(e) => this.handleSeek(e)}>
366
+ <div class="player-progress-bar" style="width: ${progress}%"></div>
367
+ </div>
368
+ <span class="player-time player-time-duration">${this.formatTime(this.duration)}</span>
369
+ <if ${this.showVolume}>
370
+ <div class="player-volume">
371
+ <button
372
+ class="player-btn player-btn-volume"
373
+ @click=${() => this.toggleVolumeSlider()}
374
+ title="Volume"
375
+ >
376
+ <if ${this.muted || this.volume === 0}>
377
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
378
+ <path d="M11 5L6 9H2v6h4l5 4V5z"/>
379
+ <line x1="23" y1="9" x2="17" y2="15"/>
380
+ <line x1="17" y1="9" x2="23" y2="15"/>
381
+ </svg>
382
+ </if>
383
+ <if ${!this.muted && this.volume > 0.5}>
384
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
385
+ <path d="M11 5L6 9H2v6h4l5 4V5z"/>
386
+ <path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"/>
387
+ </svg>
388
+ </if>
389
+ <if ${!this.muted && this.volume > 0 && this.volume <= 0.5}>
390
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
391
+ <path d="M11 5L6 9H2v6h4l5 4V5z"/>
392
+ <path d="M15.54 8.46a5 5 0 0 1 0 7.07"/>
393
+ </svg>
394
+ </if>
395
+ </button>
396
+ <if ${this.showVolumeSlider}>
397
+ <div class="player-volume-slider-container">
398
+ <input
399
+ class="player-volume-slider"
400
+ type="range"
401
+ min="0"
402
+ max="1"
403
+ step="0.01"
404
+ .value=${this.volume.toString()}
405
+ style="--volume-percent: ${this.volume * 100}%"
406
+ @input=${(e) => this.handleVolumeSlider(e)}
407
+ />
408
+ </div>
409
+ </if>
410
+ </div>
411
+ </if>
412
+ </div>
413
+ </div>
414
+ </if>
415
+
416
+ <if ${this.showPlaylist && this.tracks.length > 0}>
417
+ <div class="player-playlist">
418
+ <div class="player-playlist-header">Playlist</div>
419
+ <div class="player-playlist-items">
420
+ ${this.tracks.map((track, index) => html /*html*/ `
421
+ <div
422
+ class="player-playlist-item ${index === this.currentTrackIndex ? 'active' : ''}"
423
+ @click=${() => this.loadTrack(index)}
424
+ key=${track.id}
425
+ >
426
+ <div class="player-playlist-item-number">${index + 1}</div>
427
+ <if ${track.artwork}>
428
+ <img class="player-playlist-item-artwork" src="${track.artwork}" alt="${track.title}" />
429
+ </if>
430
+ <div class="player-playlist-item-info">
431
+ <div class="player-playlist-item-title">${track.title}</div>
432
+ <if ${track.artist}>
433
+ <div class="player-playlist-item-artist">${track.artist}</div>
434
+ </if>
435
+ </div>
436
+ <if ${track.duration}>
437
+ <div class="player-playlist-item-duration">${this.formatTime(track.duration || 0)}</div>
438
+ </if>
439
+ </div>
440
+ `)}
441
+ </div>
442
+ </div>
443
+ </if>
444
+ </div>
445
+ `;
446
+ }
447
+ async play() {
448
+ if (!this.audioElement || this.tracks.length === 0) {
449
+ return;
450
+ }
451
+ try {
452
+ await this.audioElement.play();
453
+ this.emitPlay();
454
+ }
455
+ catch (error) {
456
+ this.state = 'error';
457
+ this.emitError(error);
458
+ }
459
+ }
460
+ pause() {
461
+ if (!this.audioElement) {
462
+ return;
463
+ }
464
+ this.audioElement.pause();
465
+ this.emitPause();
466
+ }
467
+ stop() {
468
+ if (!this.audioElement) {
469
+ return;
470
+ }
471
+ this.audioElement.pause();
472
+ this.audioElement.currentTime = 0;
473
+ this.currentTime = 0;
474
+ this.state = 'stopped';
475
+ this.emitStop();
476
+ }
477
+ next() {
478
+ if (this.tracks.length === 0) {
479
+ return;
480
+ }
481
+ let nextIndex;
482
+ if (this.shuffle) {
483
+ nextIndex = this.getNextShuffleIndex();
484
+ }
485
+ else {
486
+ nextIndex = this.currentTrackIndex + 1;
487
+ if (nextIndex >= this.tracks.length) {
488
+ nextIndex = 0;
489
+ }
490
+ }
491
+ this.loadTrack(nextIndex);
492
+ if (this.state === 'playing') {
493
+ this.play();
494
+ }
495
+ }
496
+ previous() {
497
+ if (this.tracks.length === 0) {
498
+ return;
499
+ }
500
+ // If we're more than 3 seconds into the track, restart it
501
+ if (this.currentTime > 3) {
502
+ this.seek(0);
503
+ return;
504
+ }
505
+ let prevIndex;
506
+ if (this.shuffle && this.shuffleHistory.length > 0) {
507
+ prevIndex = this.shuffleHistory.pop();
508
+ }
509
+ else {
510
+ prevIndex = this.currentTrackIndex - 1;
511
+ if (prevIndex < 0) {
512
+ prevIndex = this.tracks.length - 1;
513
+ }
514
+ }
515
+ this.loadTrack(prevIndex);
516
+ if (this.state === 'playing') {
517
+ this.play();
518
+ }
519
+ }
520
+ seek(time) {
521
+ if (!this.audioElement) {
522
+ return;
523
+ }
524
+ this.audioElement.currentTime = time;
525
+ this.currentTime = time;
526
+ this.emitSeek(time);
527
+ }
528
+ setVolume(volume) {
529
+ if (volume < 0 || volume > 1) {
530
+ throw new Error('Volume must be between 0 and 1');
531
+ }
532
+ this.volume = volume;
533
+ if (this.volume > 0 && this.muted) {
534
+ this.muted = false;
535
+ }
536
+ this.emitVolumeChange(volume);
537
+ }
538
+ toggleShuffle() {
539
+ this.shuffle = !this.shuffle;
540
+ if (!this.shuffle) {
541
+ this.shuffleHistory = [];
542
+ this.shuffleQueue = [];
543
+ }
544
+ else {
545
+ this.initializeShuffleQueue();
546
+ }
547
+ this.emitShuffleChange(this.shuffle);
548
+ }
549
+ setRepeat(mode) {
550
+ this.repeat = mode;
551
+ this.emitRepeatChange(mode);
552
+ }
553
+ async loadTrack(index) {
554
+ if (index < 0 || index >= this.tracks.length) {
555
+ throw new Error('Invalid track index');
556
+ }
557
+ const wasPlaying = this.state === 'playing';
558
+ this.state = 'loading';
559
+ this.currentTrackIndex = index;
560
+ const track = this.tracks[index];
561
+ this.currentTrack = track.id;
562
+ if (this.audioElement) {
563
+ this.audioElement.src = track.src;
564
+ this.audioElement.load();
565
+ this.currentTime = 0;
566
+ if (wasPlaying || this.autoplay) {
567
+ await this.play();
568
+ }
569
+ }
570
+ this.emitTrackChange(track);
571
+ }
572
+ getCurrentTrack() {
573
+ if (this.currentTrackIndex >= 0 && this.currentTrackIndex < this.tracks.length) {
574
+ return this.tracks[this.currentTrackIndex];
575
+ }
576
+ return null;
577
+ }
578
+ toggleMute() {
579
+ this.muted = !this.muted;
580
+ }
581
+ toggleVolumeSlider() {
582
+ this.showVolumeSlider = !this.showVolumeSlider;
583
+ }
584
+ cycleRepeat() {
585
+ const modes = ['off', 'all', 'one'];
586
+ const currentIndex = modes.indexOf(this.repeat);
587
+ const nextIndex = (currentIndex + 1) % modes.length;
588
+ this.setRepeat(modes[nextIndex]);
589
+ }
590
+ handleSeek(e) {
591
+ if (!this.progressElement || this.duration === 0) {
592
+ return;
593
+ }
594
+ const rect = this.progressElement.getBoundingClientRect();
595
+ const percent = (e.clientX - rect.left) / rect.width;
596
+ const seekTime = percent * this.duration;
597
+ this.seek(seekTime);
598
+ }
599
+ handleVolumeSlider(e) {
600
+ const input = e.target;
601
+ const volume = parseFloat(input.value);
602
+ // Update visual immediately
603
+ input.style.setProperty('--volume-percent', `${volume * 100}%`);
604
+ this.setVolume(volume);
605
+ }
606
+ handleTrackEnded() {
607
+ if (this.repeat === 'one') {
608
+ this.seek(0);
609
+ this.play();
610
+ }
611
+ else if (this.repeat === 'all' || this.currentTrackIndex < this.tracks.length - 1) {
612
+ this.next();
613
+ this.play();
614
+ }
615
+ else {
616
+ this.state = 'stopped';
617
+ this.currentTime = 0;
618
+ }
619
+ this.emitTrackEnded();
620
+ }
621
+ getNextShuffleIndex() {
622
+ if (this.tracks.length === 1) {
623
+ return 0;
624
+ }
625
+ // If queue is empty, create new shuffled queue excluding current track
626
+ if (this.shuffleQueue.length === 0) {
627
+ this.initializeShuffleQueue();
628
+ }
629
+ // Pop next track from queue
630
+ this.shuffleHistory.push(this.currentTrackIndex);
631
+ return this.shuffleQueue.shift();
632
+ }
633
+ initializeShuffleQueue() {
634
+ // Create array of all indices except current track
635
+ const indices = [];
636
+ for (let i = 0; i < this.tracks.length; i++) {
637
+ if (i !== this.currentTrackIndex) {
638
+ indices.push(i);
639
+ }
640
+ }
641
+ // Fisher-Yates shuffle
642
+ for (let i = indices.length - 1; i > 0; i--) {
643
+ const j = Math.floor(Math.random() * (i + 1));
644
+ [indices[i], indices[j]] = [indices[j], indices[i]];
645
+ }
646
+ this.shuffleQueue = indices;
647
+ }
648
+ startUpdateInterval() {
649
+ this.updateInterval = window.setInterval(() => {
650
+ // Progress is updated via timeupdate event
651
+ }, 100);
652
+ }
653
+ stopUpdateInterval() {
654
+ if (this.updateInterval !== null) {
655
+ clearInterval(this.updateInterval);
656
+ this.updateInterval = null;
657
+ }
658
+ }
659
+ formatTime(seconds) {
660
+ if (isNaN(seconds) || seconds === Infinity) {
661
+ return '0:00';
662
+ }
663
+ const mins = Math.floor(seconds / 60);
664
+ const secs = Math.floor(seconds % 60);
665
+ return `${mins}:${secs.toString().padStart(2, '0')}`;
666
+ }
667
+ emitPlay() {
668
+ return { player: this, track: this.getCurrentTrack() };
669
+ }
670
+ emitPause() {
671
+ return { player: this, track: this.getCurrentTrack() };
672
+ }
673
+ emitStop() {
674
+ return { player: this };
675
+ }
676
+ emitTrackChange(track) {
677
+ return { player: this, track };
678
+ }
679
+ emitTrackEnded() {
680
+ return { player: this, track: this.getCurrentTrack() };
681
+ }
682
+ emitSeek(time) {
683
+ return { player: this, time };
684
+ }
685
+ emitVolumeChange(volume) {
686
+ return { player: this, volume };
687
+ }
688
+ emitShuffleChange(shuffle) {
689
+ return { player: this, shuffle };
690
+ }
691
+ emitRepeatChange(repeat) {
692
+ return { player: this, repeat };
693
+ }
694
+ emitError(error) {
695
+ return { player: this, error };
696
+ }
697
+ constructor() {
698
+ super(...arguments);
699
+ this.tracks = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _tracks_initializers, []));
700
+ this.currentTrackIndex = (__runInitializers(this, _tracks_extraInitializers), __runInitializers(this, _currentTrackIndex_initializers, 0));
701
+ this.currentTrack = (__runInitializers(this, _currentTrackIndex_extraInitializers), __runInitializers(this, _currentTrack_initializers, ''));
702
+ this.currentTime = (__runInitializers(this, _currentTrack_extraInitializers), 0);
703
+ this.duration = 0;
704
+ this.volume = __runInitializers(this, _volume_initializers, 1);
705
+ this.muted = (__runInitializers(this, _volume_extraInitializers), __runInitializers(this, _muted_initializers, false));
706
+ this.shuffle = (__runInitializers(this, _muted_extraInitializers), __runInitializers(this, _shuffle_initializers, false));
707
+ this.repeat = (__runInitializers(this, _shuffle_extraInitializers), __runInitializers(this, _repeat_initializers, 'off'));
708
+ this.state = (__runInitializers(this, _repeat_extraInitializers), __runInitializers(this, _state_initializers, 'stopped'));
709
+ this.autoplay = (__runInitializers(this, _state_extraInitializers), __runInitializers(this, _autoplay_initializers, false));
710
+ this.showPlaylist = (__runInitializers(this, _autoplay_extraInitializers), __runInitializers(this, _showPlaylist_initializers, true));
711
+ this.showControls = (__runInitializers(this, _showPlaylist_extraInitializers), __runInitializers(this, _showControls_initializers, true));
712
+ this.showVolume = (__runInitializers(this, _showControls_extraInitializers), __runInitializers(this, _showVolume_initializers, true));
713
+ this.showArtwork = (__runInitializers(this, _showVolume_extraInitializers), __runInitializers(this, _showArtwork_initializers, true));
714
+ this.showTrackInfo = (__runInitializers(this, _showArtwork_extraInitializers), __runInitializers(this, _showTrackInfo_initializers, true));
715
+ this.compact = (__runInitializers(this, _showTrackInfo_extraInitializers), __runInitializers(this, _compact_initializers, false));
716
+ this.showVolumeSlider = (__runInitializers(this, _compact_extraInitializers), __runInitializers(this, _showVolumeSlider_initializers, false));
717
+ this.audioElement = (__runInitializers(this, _showVolumeSlider_extraInitializers), null);
718
+ this.updateInterval = null;
719
+ this.shuffleHistory = [];
720
+ this.shuffleQueue = [];
721
+ this.progressElement = __runInitializers(this, _progressElement_initializers, void 0);
722
+ this.volumeSlider = (__runInitializers(this, _progressElement_extraInitializers), __runInitializers(this, _volumeSlider_initializers, void 0));
723
+ __runInitializers(this, _volumeSlider_extraInitializers);
724
+ }
725
+ });
726
+ return _classThis;
727
+ })();
728
+
729
+ export { SniceMusicPlayer };
730
+ //# sourceMappingURL=snice-music-player.js.map