@fmsim/board 2.0.0-beta.7 → 2.0.0-beta.70

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 (68) hide show
  1. package/custom-elements.json +3381 -1419
  2. package/demo/index-modeller.html +1 -1
  3. package/demo/index-player.html +2 -2
  4. package/demo/index-viewer.html +2 -2
  5. package/demo/index.html +2 -2
  6. package/dist/src/component/etc.js +35 -0
  7. package/dist/src/component/etc.js.map +1 -1
  8. package/dist/src/component/index.d.ts +1 -0
  9. package/dist/src/component/index.js +1 -0
  10. package/dist/src/component/index.js.map +1 -1
  11. package/dist/src/component/restful-property-editor-backdrop-faces.d.ts +50 -0
  12. package/dist/src/component/restful-property-editor-backdrop-faces.js +524 -0
  13. package/dist/src/component/restful-property-editor-backdrop-faces.js.map +1 -0
  14. package/dist/src/data-storage/board-model-cache.d.ts +13 -0
  15. package/dist/src/data-storage/board-model-cache.js +66 -0
  16. package/dist/src/data-storage/board-model-cache.js.map +1 -0
  17. package/dist/src/index.d.ts +3 -0
  18. package/dist/src/index.js +2 -0
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/layers/movement-layer.js +2 -4
  21. package/dist/src/layers/movement-layer.js.map +1 -1
  22. package/dist/src/modeller/edit-toolbar-style.js +43 -3
  23. package/dist/src/modeller/edit-toolbar-style.js.map +1 -1
  24. package/dist/src/modeller/edit-toolbar.d.ts +8 -14
  25. package/dist/src/modeller/edit-toolbar.js +208 -211
  26. package/dist/src/modeller/edit-toolbar.js.map +1 -1
  27. package/dist/src/modeller/property-sidebar/abstract-property.js +10 -2
  28. package/dist/src/modeller/property-sidebar/abstract-property.js.map +1 -1
  29. package/dist/src/modeller/property-sidebar/shapes/shapes.js +31 -0
  30. package/dist/src/modeller/property-sidebar/shapes/shapes.js.map +1 -1
  31. package/dist/src/modeller/property-sidebar/specifics/specifics.d.ts +1 -0
  32. package/dist/src/modeller/property-sidebar/specifics/specifics.js +10 -0
  33. package/dist/src/modeller/property-sidebar/specifics/specifics.js.map +1 -1
  34. package/dist/src/modeller/scene-viewer/ox-scene-viewer.d.ts +2 -1
  35. package/dist/src/modeller/scene-viewer/ox-scene-viewer.js +5 -1
  36. package/dist/src/modeller/scene-viewer/ox-scene-viewer.js.map +1 -1
  37. package/dist/src/ox-board-component-info.d.ts +1 -0
  38. package/dist/src/ox-board-component-info.js +5 -1
  39. package/dist/src/ox-board-component-info.js.map +1 -1
  40. package/dist/src/ox-board-list.js +2 -2
  41. package/dist/src/ox-board-list.js.map +1 -1
  42. package/dist/src/ox-board-modeller.d.ts +5 -2
  43. package/dist/src/ox-board-modeller.js +14 -4
  44. package/dist/src/ox-board-modeller.js.map +1 -1
  45. package/dist/src/ox-board-viewer.d.ts +60 -13
  46. package/dist/src/ox-board-viewer.js +439 -86
  47. package/dist/src/ox-board-viewer.js.map +1 -1
  48. package/dist/src/ox-editor-board-selector.d.ts +3 -0
  49. package/dist/src/ox-editor-board-selector.js +38 -9
  50. package/dist/src/ox-editor-board-selector.js.map +1 -1
  51. package/dist/src/ox-playback-controls.d.ts +154 -0
  52. package/dist/src/ox-playback-controls.js +947 -0
  53. package/dist/src/ox-playback-controls.js.map +1 -0
  54. package/dist/src/playback/playback-engine.d.ts +106 -0
  55. package/dist/src/playback/playback-engine.js +395 -0
  56. package/dist/src/playback/playback-engine.js.map +1 -0
  57. package/dist/src/selector/board-creation-popup.js +2 -2
  58. package/dist/src/selector/board-creation-popup.js.map +1 -1
  59. package/dist/src/selector/board-thumbnail-card.js +6 -6
  60. package/dist/src/selector/board-thumbnail-card.js.map +1 -1
  61. package/dist/src/selector/ox-board-creation-card.js +2 -2
  62. package/dist/src/selector/ox-board-creation-card.js.map +1 -1
  63. package/dist/src/selector/ox-board-selector.js +21 -10
  64. package/dist/src/selector/ox-board-selector.js.map +1 -1
  65. package/dist/tsconfig.tsbuildinfo +1 -1
  66. package/icons/components/text.png +0 -0
  67. package/icons/icon-htoolbar.png +0 -0
  68. package/package.json +8 -4
@@ -0,0 +1,947 @@
1
+ var PlaybackControls_1;
2
+ import { __decorate } from "tslib";
3
+ import '@material/web/icon/icon.js';
4
+ import '@material/web/iconbutton/icon-button.js';
5
+ import { css, html, LitElement } from 'lit';
6
+ import { customElement, property, state } from 'lit/decorators.js';
7
+ /**
8
+ * Window-length presets shown in the range dropdown. Values are durations
9
+ * in milliseconds; `'Range'` is the sentinel for "user picks both bounds
10
+ * directly". The fixed presets cap at 2H — same as the explicit Range
11
+ * mode max gap — so any preset switch produces a window already inside
12
+ * the allowed envelope.
13
+ */
14
+ const RANGE_DURATIONS = {
15
+ '10m': 10 * 60 * 1000,
16
+ '30m': 30 * 60 * 1000,
17
+ '1H': 60 * 60 * 1000,
18
+ '2H': 2 * 60 * 60 * 1000
19
+ };
20
+ const ONE_HOUR = RANGE_DURATIONS['1H'];
21
+ const MAX_GAP_MS = RANGE_DURATIONS['2H']; // 2H upper bound on (to − from)
22
+ const MIN_GAP_MS = RANGE_DURATIONS['10m']; // 10m lower bound (prevents reversal / zero-window)
23
+ /**
24
+ * 플레이백 컨트롤 오버레이 바 (2행 구조)
25
+ *
26
+ * 1행 (config): Range 선택 (10m / 30m / 1H / 2H / Range) + ←/→ shift
27
+ * + FROM/TO datetime 입력 (date 캘린더 + time 키인) + Apply 버튼
28
+ * + 배속 (×1 ×2 ×4)
29
+ *
30
+ * - Fixed presets: TO 가 anchor (←/→ 로 shift), FROM = TO − range.
31
+ * 입력 disabled. 초기 TO = 현재시간.
32
+ * - Range mode: 양쪽 직접 입력. 2H cap, 10m min, future clamp,
33
+ * 마지막 편집한 쪽이 anchor.
34
+ * - 상단 변경은 PENDING tier 만 갱신 — Apply 누르기 전에는 하단
35
+ * 슬라이더/엔진에 영향 없음.
36
+ *
37
+ * 2행 (control): play / pause / 시크바 (적용된 range 만큼 span) /
38
+ * 현재 재생 시각 / 닫기.
39
+ *
40
+ * @fires playback-start - 플레이백 시작 요청 { fromTime, toTime, speed }
41
+ * toTime 은 window END — 엔진이 chunked fetch 의 상한으로 사용.
42
+ * @fires playback-pause - 일시정지 요청
43
+ * @fires playback-resume - 재개 요청
44
+ * @fires playback-stop - 중지 요청
45
+ * @fires playback-seek - 드래그 릴리즈 시 시크 요청 { toTime }
46
+ * @fires playback-seek-start - 드래그 첫 input 시 즉시 발행 (엔진 타이머·애니메이션 정지 신호, detail 없음)
47
+ * @fires playback-seek-preview - 드래그 중 throttle (leading+trailing, 200ms) 된 스크러빙 요청 { toTime }
48
+ * @fires playback-speed - 배속 변경 요청 { speed }
49
+ */
50
+ let PlaybackControls = PlaybackControls_1 = class PlaybackControls extends LitElement {
51
+ constructor() {
52
+ super(...arguments);
53
+ this.playbackState = 'idle';
54
+ this.speed = 1;
55
+ this.currentTime = '';
56
+ this.bufferedRanges = [];
57
+ /** 외부에서 전달받은 초기 시간 범위 (from만 사용, to는 from+1h로 자동 계산) */
58
+ this.timeRange = {
59
+ from: new Date(Date.now() - ONE_HOUR),
60
+ to: new Date()
61
+ };
62
+ /**
63
+ * Two-tier state model:
64
+ *
65
+ * PENDING (`_pendingRange`, `_pendingFrom`, `_pendingTo`)
66
+ * The upper bar's draft. User edits these via the range dropdown,
67
+ * ←/→ shift, or direct date/time inputs (Range mode only). The
68
+ * lower seekbar is NOT driven by these — they only become live
69
+ * when the user clicks "적용".
70
+ *
71
+ * APPLIED (`_appliedFrom`, `_appliedTo`)
72
+ * The window the seekbar visualizes and the engine fetches data
73
+ * for. Updated only by `_onApply()`, which mirrors pending values
74
+ * here and dispatches a `playback-start` to refresh the engine
75
+ * with the new window (when playing/paused).
76
+ *
77
+ * Splitting these prevents mid-edit churn: typing into the time input
78
+ * doesn't refetch on every keystroke, and the slider doesn't jiggle
79
+ * while the user picks a date.
80
+ */
81
+ this._pendingRange = '1H';
82
+ this._pendingFrom = new Date(Date.now() - ONE_HOUR);
83
+ this._pendingTo = new Date();
84
+ /**
85
+ * Which side did the user touch most recently in Range mode? Anchors
86
+ * the auto-adjust when the resulting gap violates min/max — the
87
+ * unedited side is what gets pushed to a legal value, so the user's
88
+ * latest intent is preserved.
89
+ */
90
+ this._lastEdited = 'to';
91
+ this._appliedFrom = new Date(Date.now() - ONE_HOUR);
92
+ this._appliedTo = new Date();
93
+ this._seeking = false;
94
+ this._seekPreviewTime = null;
95
+ this._speeds = [1, 2, 4];
96
+ /** 드래그 중 가장 최근 seekbar 위치 시각 */
97
+ this._latestPreviewTime = null;
98
+ /** 가장 최근에 실제 emit 한 preview 시각 (dedupe 용) */
99
+ this._lastEmittedPreviewTime = null;
100
+ }
101
+ connectedCallback() {
102
+ super.connectedCallback();
103
+ // Initialize both pending and applied from the incoming timeRange.
104
+ // Default range = 1H (matches the previous fixed-window behavior),
105
+ // so the seekbar covers a 1H window from the start.
106
+ const initFrom = new Date(this.timeRange.from);
107
+ const initTo = new Date(this.timeRange.to);
108
+ this._appliedFrom = initFrom;
109
+ this._appliedTo = initTo;
110
+ this._pendingFrom = new Date(initFrom);
111
+ this._pendingTo = new Date(initTo);
112
+ this._pendingRange = this._inferRangeKey(initTo.getTime() - initFrom.getTime());
113
+ this._seekValue = 0;
114
+ this._currentPlayTime = null;
115
+ }
116
+ disconnectedCallback() {
117
+ super.disconnectedCallback();
118
+ this._cancelPreviewThrottle();
119
+ }
120
+ updated(changes) {
121
+ if (changes.has('timeRange') && this.timeRange) {
122
+ // Resync both tiers from the externally-supplied window.
123
+ this._appliedFrom = new Date(this.timeRange.from);
124
+ this._appliedTo = new Date(this.timeRange.to);
125
+ this._pendingFrom = new Date(this._appliedFrom);
126
+ this._pendingTo = new Date(this._appliedTo);
127
+ this._pendingRange = this._inferRangeKey(this._appliedTo.getTime() - this._appliedFrom.getTime());
128
+ }
129
+ // 엔진 프레임(currentTime 프로프 변경)이 유일한 시간 소스.
130
+ // drag 중에는 _seeking 가 true 이므로 엔진 업데이트 무시 (스크러빙 중 UI 튐 방지).
131
+ if (changes.has('currentTime') && this.currentTime && !this._seeking) {
132
+ this._syncFromEngine();
133
+ }
134
+ }
135
+ /**
136
+ * Map a millisecond gap to the matching preset key, or `'Range'` if
137
+ * the gap doesn't match any preset (custom window already in effect).
138
+ */
139
+ _inferRangeKey(gapMs) {
140
+ for (const k of ['10m', '30m', '1H', '2H']) {
141
+ if (RANGE_DURATIONS[k] === gapMs)
142
+ return k;
143
+ }
144
+ return 'Range';
145
+ }
146
+ render() {
147
+ const isPlaying = this.playbackState === 'playing';
148
+ const isPaused = this.playbackState === 'paused';
149
+ const isActive = isPlaying || isPaused;
150
+ const isRangeMode = this._pendingRange === 'Range';
151
+ const isDirty = this._pendingFrom.getTime() !== this._appliedFrom.getTime() ||
152
+ this._pendingTo.getTime() !== this._appliedTo.getTime();
153
+ return html `
154
+ <div class="control-bar">
155
+ <!-- 1행 (config): Range 선택 + ←/→ shift + datetime 입력 + Apply -->
156
+ <div class="row-time">
157
+ <select class="range-select" .value=${this._pendingRange} @change=${this._onRangeChange}>
158
+ ${['10m', '30m', '1H', '2H', 'Range'].map(k => html `<option value=${k} ?selected=${this._pendingRange === k}>${k}</option>`)}
159
+ </select>
160
+
161
+ <button
162
+ class="shift-btn"
163
+ @click=${this._shiftPending(-1)}
164
+ ?disabled=${isRangeMode}
165
+ title="이전 ${this._pendingRange}"
166
+ >
167
+ <md-icon>chevron_left</md-icon>
168
+ </button>
169
+ <button
170
+ class="shift-btn"
171
+ @click=${this._shiftPending(1)}
172
+ ?disabled=${isRangeMode}
173
+ title="다음 ${this._pendingRange}"
174
+ >
175
+ <md-icon>chevron_right</md-icon>
176
+ </button>
177
+
178
+ <!-- FROM datetime — single compact widget (date via calendar
179
+ popup, time via key-in, browser-native). In Fixed mode
180
+ disabled (derived from to − range); in Range mode editable. -->
181
+ <input
182
+ type="datetime-local"
183
+ step="1"
184
+ lang="ko-KR"
185
+ class="datetime-input"
186
+ .value=${this._toDatetimeLocalString(this._pendingFrom)}
187
+ ?disabled=${!isRangeMode}
188
+ @change=${(e) => this._onPendingDatetimeChange('from', e)}
189
+ />
190
+
191
+ <span class="time-label">~</span>
192
+
193
+ <!-- TO datetime. In Fixed mode disabled (←/→ moves it).
194
+ In Range mode editable. -->
195
+ <input
196
+ type="datetime-local"
197
+ step="1"
198
+ lang="ko-KR"
199
+ class="datetime-input"
200
+ .value=${this._toDatetimeLocalString(this._pendingTo)}
201
+ ?disabled=${!isRangeMode}
202
+ @change=${(e) => this._onPendingDatetimeChange('to', e)}
203
+ />
204
+
205
+ <button class="apply-btn ${isDirty ? 'dirty' : ''}" ?disabled=${!isDirty} @click=${this._onApply}>
206
+ 적용
207
+ </button>
208
+
209
+ <span class="spacer"></span>
210
+ </div>
211
+
212
+ <!-- 2행: 재생 제어 + 시크바 + 배속 + 닫기 -->
213
+ <div class="row-seek">
214
+ <md-icon-button class="primary" @click=${isActive ? this._onTogglePlayPause : this._onStart}>
215
+ <md-icon>${isPlaying ? 'pause' : 'play_arrow'}</md-icon>
216
+ </md-icon-button>
217
+
218
+ <div class="timeline">
219
+ <div class="seek-track">
220
+ <div class="seek-rail"></div>
221
+ ${this._renderBufferBars()}
222
+ <input
223
+ type="range"
224
+ class="seek-bar"
225
+ min="0"
226
+ max="1000"
227
+ .value=${String(this._seekValue)}
228
+ @input=${this._onSeekInput}
229
+ @change=${this._onSeekChange}
230
+ />
231
+ </div>
232
+ <div class="seek-labels">
233
+ <span>${this._formatTime(this._appliedFrom)}</span>
234
+ <span>${this._formatTime(this._appliedTo)}</span>
235
+ </div>
236
+ </div>
237
+
238
+ <span class="current-time">
239
+ ${this._seeking && this._seekPreviewTime
240
+ ? this._formatTime(this._seekPreviewTime)
241
+ : this._currentPlayTime ? this._formatTime(this._currentPlayTime) : '--:--:--'}
242
+ </span>
243
+
244
+ <div class="speed-group">
245
+ ${this._speeds.map(s => html `
246
+ <button class="speed-btn ${this.speed === s ? 'active' : ''}" @click=${() => this._onSpeedChange(s)}>
247
+ ×${s}
248
+ </button>
249
+ `)}
250
+ </div>
251
+
252
+ <md-icon-button @click=${this._onStop}>
253
+ <md-icon>close</md-icon>
254
+ </md-icon-button>
255
+ </div>
256
+ </div>
257
+ `;
258
+ }
259
+ _formatTime(date) {
260
+ return date.toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false });
261
+ }
262
+ _toDateString(date) {
263
+ const pad = (n) => String(n).padStart(2, '0');
264
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
265
+ }
266
+ /** "HH:MM:SS" — what `<input type="time" step="1">` reads/writes. */
267
+ _toTimeString(date) {
268
+ const pad = (n) => String(n).padStart(2, '0');
269
+ return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
270
+ }
271
+ /**
272
+ * "YYYY-MM-DDTHH:MM:SS" — what `<input type="datetime-local" step="1">`
273
+ * reads/writes. Local time (no Z suffix), matches the input element's
274
+ * own convention.
275
+ */
276
+ _toDatetimeLocalString(date) {
277
+ return `${this._toDateString(date)}T${this._toTimeString(date)}`;
278
+ }
279
+ /**
280
+ * 엔진 프레임(currentTime 프로프) 을 유일한 시간 소스로 사용하여
281
+ * _currentPlayTime 및 _seekValue 동기화.
282
+ */
283
+ _syncFromEngine() {
284
+ if (!this.currentTime || this._seeking)
285
+ return;
286
+ const currentMs = new Date(this.currentTime).getTime();
287
+ if (!Number.isFinite(currentMs))
288
+ return;
289
+ this._currentPlayTime = new Date(currentMs);
290
+ const from = this._appliedFrom.getTime();
291
+ const to = this._appliedTo.getTime();
292
+ const range = to - from;
293
+ if (range <= 0)
294
+ return;
295
+ this._seekValue = Math.max(0, Math.min(1000, Math.round(((currentMs - from) / range) * 1000)));
296
+ }
297
+ // ── Pending-tier handlers (upper config bar) ──────────────────────
298
+ _onRangeChange(e) {
299
+ const newKey = e.target.value;
300
+ this._pendingRange = newKey;
301
+ if (newKey === 'Range') {
302
+ // Switching to Range: keep current pending bounds, just unlock the
303
+ // inputs. Auto-adjust will kick in when the user edits one side.
304
+ return;
305
+ }
306
+ // Fixed preset: end stays where it is (clamped to now), start = end − range.
307
+ const dur = RANGE_DURATIONS[newKey];
308
+ const now = Date.now();
309
+ const newTo = Math.min(this._pendingTo.getTime(), now);
310
+ this._pendingTo = new Date(newTo);
311
+ this._pendingFrom = new Date(newTo - dur);
312
+ this._lastEdited = 'to';
313
+ }
314
+ _shiftPending(direction) {
315
+ return () => {
316
+ // Only meaningful in Fixed mode — Range mode disables the buttons.
317
+ if (this._pendingRange === 'Range')
318
+ return;
319
+ const dur = RANGE_DURATIONS[this._pendingRange];
320
+ const now = Date.now();
321
+ let newToMs = this._pendingTo.getTime() + direction * dur;
322
+ newToMs = Math.min(newToMs, now); // future clamp on forward shift
323
+ this._pendingTo = new Date(newToMs);
324
+ this._pendingFrom = new Date(newToMs - dur);
325
+ this._lastEdited = 'to';
326
+ };
327
+ }
328
+ _onPendingDatetimeChange(side, e) {
329
+ // value is "YYYY-MM-DDTHH:MM:SS" (datetime-local with step=1).
330
+ // Parsed as LOCAL time — `new Date(...)` on this format is local
331
+ // (intentional, user picks wall-clock time, not UTC).
332
+ const value = e.target.value;
333
+ if (!value)
334
+ return;
335
+ const next = new Date(value);
336
+ if (Number.isNaN(next.getTime()))
337
+ return;
338
+ this._writePendingSide(side, next);
339
+ }
340
+ /**
341
+ * Commit a side's new value, then enforce the gap envelope.
342
+ *
343
+ * Rules (per spec):
344
+ * - `to` clamped to now (no future).
345
+ * - `to − from ≥ 10m` (no zero/negative window).
346
+ * - `to − from ≤ 2h`.
347
+ * - The side just edited (`side`) is the anchor; the OTHER side
348
+ * gets pushed to satisfy the envelope.
349
+ * - If anchoring `from` would push `to` past now, fall back to
350
+ * anchoring `to = now` and shrink `from`.
351
+ */
352
+ _writePendingSide(side, next) {
353
+ this._lastEdited = side;
354
+ const now = Date.now();
355
+ if (side === 'to') {
356
+ const toMs = Math.min(next.getTime(), now);
357
+ this._pendingTo = new Date(toMs);
358
+ const fromMs = this._pendingFrom.getTime();
359
+ const gap = toMs - fromMs;
360
+ if (gap < MIN_GAP_MS)
361
+ this._pendingFrom = new Date(toMs - MIN_GAP_MS);
362
+ else if (gap > MAX_GAP_MS)
363
+ this._pendingFrom = new Date(toMs - MAX_GAP_MS);
364
+ }
365
+ else {
366
+ const fromMs = next.getTime();
367
+ this._pendingFrom = new Date(fromMs);
368
+ const toMs = this._pendingTo.getTime();
369
+ const gap = toMs - fromMs;
370
+ if (gap < MIN_GAP_MS) {
371
+ let adj = fromMs + MIN_GAP_MS;
372
+ if (adj > now) {
373
+ // Pushing `to` would land in the future — re-anchor on `to=now`
374
+ // and shrink `from` instead.
375
+ adj = now;
376
+ this._pendingFrom = new Date(adj - MIN_GAP_MS);
377
+ }
378
+ this._pendingTo = new Date(adj);
379
+ }
380
+ else if (gap > MAX_GAP_MS) {
381
+ let adj = fromMs + MAX_GAP_MS;
382
+ if (adj > now) {
383
+ adj = now;
384
+ this._pendingFrom = new Date(adj - MAX_GAP_MS);
385
+ }
386
+ this._pendingTo = new Date(adj);
387
+ }
388
+ }
389
+ }
390
+ /**
391
+ * "적용" — copy pending → applied, reset seek to window start, and
392
+ * (re)start the engine so it refetches data for the new window.
393
+ *
394
+ * Behavior by prior state:
395
+ * - playing: dispatch `playback-start` → engine restarts in new window.
396
+ * - paused : same — engine refetches; we leave the user in 'playing'
397
+ * state because the alternative (carry "paused" through a window
398
+ * change) ends up showing stale buffered data while the new fetch
399
+ * completes, which reads as a stuck UI.
400
+ * - idle : window updated silently; no engine activity until user
401
+ * presses play.
402
+ */
403
+ _onApply() {
404
+ this._appliedFrom = new Date(this._pendingFrom);
405
+ this._appliedTo = new Date(this._pendingTo);
406
+ this._seekValue = 0;
407
+ this._currentPlayTime = new Date(this._appliedFrom);
408
+ this._seekPreviewTime = null;
409
+ if (this.playbackState === 'playing' || this.playbackState === 'paused') {
410
+ this._onStart();
411
+ }
412
+ }
413
+ _onStart() {
414
+ // 현재 seekbar 위치에서 재생 시작 (_seekValue 가 유일한 슬라이더 위치 소스)
415
+ const ratio = this._seekValue / 1000;
416
+ const from = this._appliedFrom.getTime();
417
+ const to = this._appliedTo.getTime();
418
+ const fromTime = new Date(from + (to - from) * ratio);
419
+ const toTime = new Date(to);
420
+ this._currentPlayTime = fromTime;
421
+ this.playbackState = 'playing';
422
+ // toTime is the window END (= _appliedTo), NOT a hardcoded
423
+ // fromTime + 1h. The engine uses it as the chunked-fetch upper
424
+ // bound — without it, variable ranges (10m / 30m / Range mode)
425
+ // would silently overshoot the user-selected window.
426
+ this.dispatchEvent(new CustomEvent('playback-start', {
427
+ detail: { fromTime, toTime, speed: this.speed },
428
+ bubbles: true,
429
+ composed: true
430
+ }));
431
+ }
432
+ _onTogglePlayPause() {
433
+ if (this.playbackState === 'playing') {
434
+ this.playbackState = 'paused';
435
+ this.dispatchEvent(new CustomEvent('playback-pause', { bubbles: true, composed: true }));
436
+ }
437
+ else {
438
+ this.playbackState = 'playing';
439
+ this.dispatchEvent(new CustomEvent('playback-resume', { bubbles: true, composed: true }));
440
+ }
441
+ }
442
+ _onStop() {
443
+ this._cancelPreviewThrottle();
444
+ this._currentPlayTime = null;
445
+ this._seekValue = 0;
446
+ this.playbackState = 'idle';
447
+ this.dispatchEvent(new CustomEvent('playback-stop', { bubbles: true, composed: true }));
448
+ }
449
+ _onSeekInput(e) {
450
+ // 드래그 시작(첫 input) 탐지
451
+ const justStartedDrag = !this._seeking;
452
+ this._seeking = true;
453
+ this._seekValue = Number(e.target.value);
454
+ // 드래그 중 preview 시간 계산 + UI 표시
455
+ const ratio = this._seekValue / 1000;
456
+ const from = this._appliedFrom.getTime();
457
+ const to = this._appliedTo.getTime();
458
+ const previewTime = new Date(from + (to - from) * ratio);
459
+ this._seekPreviewTime = previewTime;
460
+ this._latestPreviewTime = previewTime;
461
+ if (justStartedDrag) {
462
+ // 즉시 이벤트 — 재생 타이머 정지
463
+ this.dispatchEvent(new CustomEvent('playback-seek-start', {
464
+ bubbles: true,
465
+ composed: true
466
+ }));
467
+ }
468
+ // throttle: leading-edge 에서 즉시 emit, 이후 200ms 내 input 은 latest 만 갱신.
469
+ // throttle 만료 시점에 latest 가 마지막 emit 과 다르면 trailing emit.
470
+ if (this._previewThrottle === undefined) {
471
+ // leading emit
472
+ this._emitPreview();
473
+ // trailing 예약
474
+ this._previewThrottle = window.setTimeout(() => {
475
+ var _a;
476
+ this._previewThrottle = undefined;
477
+ // 드래그가 끝났거나 (_seeking=false) 새 throttle 이 이미 있으면 스킵
478
+ if (!this._seeking)
479
+ return;
480
+ // latest 가 마지막 emit 과 같으면 중복 skip
481
+ const latest = this._latestPreviewTime;
482
+ if (latest && latest.getTime() !== ((_a = this._lastEmittedPreviewTime) === null || _a === void 0 ? void 0 : _a.getTime())) {
483
+ this._emitPreview();
484
+ }
485
+ }, PlaybackControls_1.PREVIEW_THROTTLE_MS);
486
+ }
487
+ // else: 이미 throttle 진행 중 → _latestPreviewTime 만 업데이트됨 (위에서 처리됨)
488
+ }
489
+ /** latest 위치 시각으로 playback-seek-preview 를 발행 (dedupe). */
490
+ _emitPreview() {
491
+ var _a;
492
+ const time = this._latestPreviewTime;
493
+ if (!time)
494
+ return;
495
+ if (((_a = this._lastEmittedPreviewTime) === null || _a === void 0 ? void 0 : _a.getTime()) === time.getTime())
496
+ return;
497
+ this._lastEmittedPreviewTime = time;
498
+ this.dispatchEvent(new CustomEvent('playback-seek-preview', {
499
+ detail: { toTime: time },
500
+ bubbles: true,
501
+ composed: true
502
+ }));
503
+ }
504
+ _onSeekChange(e) {
505
+ this._seeking = false;
506
+ this._cancelPreviewThrottle();
507
+ const ratio = Number(e.target.value) / 1000;
508
+ const from = this._appliedFrom.getTime();
509
+ const to = this._appliedTo.getTime();
510
+ const targetTime = new Date(from + (to - from) * ratio);
511
+ this._seekPreviewTime = null;
512
+ this._currentPlayTime = targetTime;
513
+ this.dispatchEvent(new CustomEvent('playback-seek', {
514
+ detail: { toTime: targetTime },
515
+ bubbles: true,
516
+ composed: true
517
+ }));
518
+ }
519
+ _cancelPreviewThrottle() {
520
+ if (this._previewThrottle != null) {
521
+ clearTimeout(this._previewThrottle);
522
+ this._previewThrottle = undefined;
523
+ }
524
+ this._latestPreviewTime = null;
525
+ this._lastEmittedPreviewTime = null;
526
+ }
527
+ _renderBufferBars() {
528
+ var _a;
529
+ if (!((_a = this.bufferedRanges) === null || _a === void 0 ? void 0 : _a.length))
530
+ return '';
531
+ const from = this._appliedFrom.getTime();
532
+ const to = this._appliedTo.getTime();
533
+ const range = to - from;
534
+ if (range <= 0)
535
+ return '';
536
+ return this.bufferedRanges.map(r => {
537
+ const left = Math.max(0, (r.from - from) / range) * 100;
538
+ const right = Math.min(1, (r.to - from) / range) * 100;
539
+ const width = right - left;
540
+ return html `<div class="buffer-bar" style="left:${left}%;width:${width}%"></div>`;
541
+ });
542
+ }
543
+ _onSpeedChange(speed) {
544
+ this.speed = speed;
545
+ this.dispatchEvent(new CustomEvent('playback-speed', {
546
+ detail: { speed },
547
+ bubbles: true,
548
+ composed: true
549
+ }));
550
+ }
551
+ };
552
+ PlaybackControls.styles = css `
553
+ :host {
554
+ display: flex;
555
+ justify-content: center;
556
+ position: absolute;
557
+ bottom: 0;
558
+ left: 0;
559
+ right: 0;
560
+ z-index: 1001;
561
+ pointer-events: none;
562
+ }
563
+
564
+ .control-bar {
565
+ display: flex;
566
+ flex-direction: column;
567
+ gap: 6px;
568
+ padding: 10px 16px;
569
+ margin: 12px;
570
+ max-width: 560px;
571
+ width: 100%;
572
+ background: rgba(0, 0, 0, 0.75);
573
+ backdrop-filter: blur(8px);
574
+ border-radius: 12px;
575
+ color: #fff;
576
+ pointer-events: auto;
577
+ font-size: 13px;
578
+ box-sizing: border-box;
579
+ }
580
+
581
+ /* 1행: 시점 설정 + 배속 */
582
+ .row-time {
583
+ display: flex;
584
+ align-items: center;
585
+ gap: 6px;
586
+ }
587
+
588
+ md-icon-button {
589
+ --md-icon-button-icon-color: #fff;
590
+ --md-icon-button-hover-icon-color: #fff;
591
+ --md-icon-button-pressed-icon-color: #fff;
592
+ --md-icon-button-focus-icon-color: #fff;
593
+ --md-icon-button-state-layer-color: rgba(255, 255, 255, 0.2);
594
+ }
595
+
596
+ md-icon-button:hover {
597
+ background: rgba(255, 255, 255, 0.15);
598
+ border-radius: 50%;
599
+ }
600
+
601
+ /*
602
+ * shift 버튼 (←/→) — Material Web 의 md-icon-button 은 shadow DOM
603
+ * 내 ripple/focus-ring/touch-target 영역이 visible 32px 컨테이너
604
+ * 너머로 hit area 를 확장해서 인접 버튼끼리 호버 영역이 겹친다.
605
+ * (사용자 보고: > 의 hover 가 < 의 오른쪽 영역까지 침범) plain
606
+ * <button> 으로 교체해 hit area 를 정확히 32×32px 로 한정.
607
+ */
608
+ .shift-btn {
609
+ width: 22px;
610
+ height: 28px;
611
+ padding: 0;
612
+ border: none;
613
+ background: transparent;
614
+ cursor: pointer;
615
+ display: inline-flex;
616
+ align-items: center;
617
+ justify-content: center;
618
+ color: #fff;
619
+ flex-shrink: 0;
620
+ }
621
+
622
+ /*
623
+ * shift 버튼 묶음 — 두 chevron 이 시각적으로 한 쌍으로 보이도록
624
+ * 사이 여백을 완전히 제거 (row-time 의 6px gap 전체를 negative
625
+ * margin 으로 상쇄). 양쪽 인접 요소와의 간격은 row gap 으로 유지.
626
+ */
627
+ .shift-btn + .shift-btn {
628
+ margin-left: -6px;
629
+ }
630
+
631
+ .shift-btn md-icon {
632
+ font-size: 16px;
633
+ width: 16px;
634
+ height: 16px;
635
+ }
636
+
637
+ .shift-btn:hover:not(:disabled) {
638
+ color: #ffb766;
639
+ }
640
+
641
+ .shift-btn:disabled {
642
+ opacity: 0.4;
643
+ cursor: not-allowed;
644
+ }
645
+
646
+ .date-input {
647
+ background: rgba(255, 255, 255, 0.15);
648
+ border: 1px solid rgba(255, 255, 255, 0.3);
649
+ border-radius: 6px;
650
+ color: #fff;
651
+ font-size: 13px;
652
+ padding: 4px 8px;
653
+ outline: none;
654
+ color-scheme: dark;
655
+ width: 130px;
656
+ }
657
+
658
+ .date-input:focus {
659
+ border-color: rgba(255, 255, 255, 0.6);
660
+ }
661
+
662
+ .hour-select,
663
+ .range-select {
664
+ background: rgba(255, 255, 255, 0.15);
665
+ border: 1px solid rgba(255, 255, 255, 0.3);
666
+ border-radius: 6px;
667
+ color: #fff;
668
+ font-size: 13px;
669
+ padding: 4px 6px;
670
+ outline: none;
671
+ color-scheme: dark;
672
+ cursor: pointer;
673
+ }
674
+
675
+ .hour-select:focus,
676
+ .range-select:focus {
677
+ border-color: rgba(255, 255, 255, 0.6);
678
+ }
679
+
680
+ .range-select {
681
+ min-width: 64px;
682
+ }
683
+
684
+ .datetime-input {
685
+ background: rgba(255, 255, 255, 0.15);
686
+ border: 1px solid rgba(255, 255, 255, 0.3);
687
+ border-radius: 6px;
688
+ color: #fff;
689
+ font-size: 12px;
690
+ padding: 4px 6px;
691
+ outline: none;
692
+ color-scheme: dark;
693
+ font-family: inherit;
694
+ /*
695
+ * 브라우저 기본 너비가 컨텐츠 (YYYY-MM-DD HH:MM:SS + 캘린더
696
+ * 아이콘) 보다 넓게 잡혀서 우측에 빈 공간이 생긴다. content
697
+ * 폭에 거의 fit 시키는 명시 너비. 12px 폰트 기준 19자 + 캘린더
698
+ * 아이콘 공간 ≈ 170px (실측 기준).
699
+ */
700
+ width: 170px;
701
+ box-sizing: border-box;
702
+ }
703
+
704
+ /*
705
+ * inner sub-fields (YYYY/MM/DD/HH/MM/SS) 사이 spacing 도 일부
706
+ * Chromium 빌드에서 과하게 잡혀 있어 0으로 줄여 합본 시각적
707
+ * 폭을 더 줄임. 다른 엔진은 selector 무시.
708
+ */
709
+ .datetime-input::-webkit-datetime-edit-fields-wrapper {
710
+ padding: 0;
711
+ }
712
+ .datetime-input::-webkit-datetime-edit-text {
713
+ padding: 0 1px;
714
+ }
715
+
716
+ .datetime-input:focus {
717
+ border-color: rgba(255, 255, 255, 0.6);
718
+ }
719
+
720
+ /*
721
+ * 24시간제 강제 — lang="ko-KR" 만으로 안 먹는 브라우저(Chrome/Edge 일부
722
+ * 버전, OS locale 우선) 대비, AM/PM 필드를 CSS 레벨에서 비표시.
723
+ * Chromium/WebKit 의 -webkit-datetime-edit shadow DOM 만 이름이
724
+ * 노출되어 있어 다른 엔진은 자동으로 무시 (no-op).
725
+ */
726
+ .datetime-input::-webkit-datetime-edit-ampm-field {
727
+ display: none;
728
+ }
729
+
730
+ .datetime-input:disabled,
731
+ .date-input:disabled {
732
+ opacity: 0.5;
733
+ cursor: not-allowed;
734
+ }
735
+
736
+ .apply-btn {
737
+ padding: 4px 12px;
738
+ border: 1px solid rgba(255, 255, 255, 0.3);
739
+ border-radius: 4px;
740
+ background: transparent;
741
+ color: #fff;
742
+ font-size: 12px;
743
+ cursor: pointer;
744
+ white-space: nowrap;
745
+ }
746
+
747
+ .apply-btn.dirty {
748
+ background: rgba(255, 165, 0, 0.4);
749
+ border-color: rgba(255, 165, 0, 0.8);
750
+ }
751
+
752
+ .apply-btn:hover:not(:disabled) {
753
+ background: rgba(255, 255, 255, 0.2);
754
+ }
755
+
756
+ .apply-btn:disabled {
757
+ opacity: 0.4;
758
+ cursor: not-allowed;
759
+ }
760
+
761
+ .time-label {
762
+ font-size: 12px;
763
+ opacity: 0.7;
764
+ white-space: nowrap;
765
+ }
766
+
767
+ .spacer {
768
+ flex: 1;
769
+ }
770
+
771
+ .speed-group {
772
+ display: flex;
773
+ gap: 2px;
774
+ }
775
+
776
+ .speed-btn {
777
+ padding: 4px 8px;
778
+ border: 1px solid rgba(255, 255, 255, 0.3);
779
+ border-radius: 4px;
780
+ background: transparent;
781
+ color: #fff;
782
+ font-size: 12px;
783
+ cursor: pointer;
784
+ white-space: nowrap;
785
+ }
786
+
787
+ .speed-btn:hover {
788
+ background: rgba(255, 255, 255, 0.15);
789
+ }
790
+
791
+ .speed-btn.active {
792
+ background: rgba(255, 255, 255, 0.3);
793
+ border-color: #fff;
794
+ }
795
+
796
+ /* 2행: 재생 제어 + 시크바 */
797
+ .row-seek {
798
+ display: flex;
799
+ align-items: center;
800
+ gap: 8px;
801
+ }
802
+
803
+ .row-seek md-icon-button {
804
+ --md-icon-button-icon-size: 20px;
805
+ --md-icon-button-container-width: 36px;
806
+ --md-icon-button-container-height: 36px;
807
+ }
808
+
809
+ .row-seek md-icon-button.primary {
810
+ --md-icon-button-icon-size: 24px;
811
+ --md-icon-button-container-width: 40px;
812
+ --md-icon-button-container-height: 40px;
813
+ }
814
+
815
+ .row-seek md-icon {
816
+ font-variation-settings: 'FILL' 1;
817
+ }
818
+
819
+ .timeline {
820
+ flex: 1;
821
+ display: flex;
822
+ flex-direction: column;
823
+ gap: 2px;
824
+ min-width: 0;
825
+ }
826
+
827
+ .seek-track {
828
+ position: relative;
829
+ width: 100%;
830
+ height: 12px;
831
+ }
832
+
833
+ .seek-rail {
834
+ position: absolute;
835
+ top: 4px;
836
+ left: 0;
837
+ right: 0;
838
+ height: 4px;
839
+ background: rgba(255, 255, 255, 0.15);
840
+ border-radius: 2px;
841
+ }
842
+
843
+ .buffer-bar {
844
+ position: absolute;
845
+ top: 4px;
846
+ height: 4px;
847
+ background: rgba(255, 255, 255, 0.4);
848
+ border-radius: 2px;
849
+ pointer-events: none;
850
+ z-index: 1;
851
+ }
852
+
853
+ .seek-bar {
854
+ position: absolute;
855
+ top: 0;
856
+ left: 0;
857
+ width: 100%;
858
+ height: 12px;
859
+ -webkit-appearance: none;
860
+ appearance: none;
861
+ background: transparent;
862
+ outline: none;
863
+ cursor: pointer;
864
+ z-index: 2;
865
+ margin: 0;
866
+ }
867
+
868
+ .seek-bar::-webkit-slider-runnable-track {
869
+ height: 12px;
870
+ background: transparent;
871
+ }
872
+
873
+ .seek-bar::-webkit-slider-thumb {
874
+ -webkit-appearance: none;
875
+ width: 12px;
876
+ height: 12px;
877
+ border-radius: 50%;
878
+ background: #fff;
879
+ cursor: pointer;
880
+ }
881
+
882
+ .seek-labels {
883
+ display: flex;
884
+ justify-content: space-between;
885
+ font-size: 11px;
886
+ opacity: 0.8;
887
+ }
888
+
889
+ .current-time {
890
+ font-size: 12px;
891
+ opacity: 0.9;
892
+ white-space: nowrap;
893
+ min-width: 60px;
894
+ text-align: center;
895
+ }
896
+ `;
897
+ PlaybackControls.PREVIEW_THROTTLE_MS = 200;
898
+ __decorate([
899
+ property({ type: String })
900
+ ], PlaybackControls.prototype, "playbackState", void 0);
901
+ __decorate([
902
+ property({ type: Number })
903
+ ], PlaybackControls.prototype, "speed", void 0);
904
+ __decorate([
905
+ property({ type: String })
906
+ ], PlaybackControls.prototype, "currentTime", void 0);
907
+ __decorate([
908
+ property({ type: Array })
909
+ ], PlaybackControls.prototype, "bufferedRanges", void 0);
910
+ __decorate([
911
+ property({ type: Object })
912
+ ], PlaybackControls.prototype, "timeRange", void 0);
913
+ __decorate([
914
+ state()
915
+ ], PlaybackControls.prototype, "_pendingRange", void 0);
916
+ __decorate([
917
+ state()
918
+ ], PlaybackControls.prototype, "_pendingFrom", void 0);
919
+ __decorate([
920
+ state()
921
+ ], PlaybackControls.prototype, "_pendingTo", void 0);
922
+ __decorate([
923
+ state()
924
+ ], PlaybackControls.prototype, "_lastEdited", void 0);
925
+ __decorate([
926
+ state()
927
+ ], PlaybackControls.prototype, "_appliedFrom", void 0);
928
+ __decorate([
929
+ state()
930
+ ], PlaybackControls.prototype, "_appliedTo", void 0);
931
+ __decorate([
932
+ state()
933
+ ], PlaybackControls.prototype, "_seekValue", void 0);
934
+ __decorate([
935
+ state()
936
+ ], PlaybackControls.prototype, "_currentPlayTime", void 0);
937
+ __decorate([
938
+ state()
939
+ ], PlaybackControls.prototype, "_seeking", void 0);
940
+ __decorate([
941
+ state()
942
+ ], PlaybackControls.prototype, "_seekPreviewTime", void 0);
943
+ PlaybackControls = PlaybackControls_1 = __decorate([
944
+ customElement('ox-playback-controls')
945
+ ], PlaybackControls);
946
+ export { PlaybackControls };
947
+ //# sourceMappingURL=ox-playback-controls.js.map