| 687 | const MAX_BUNDLE_PREVIEW_PARTS = 32; |
| 688 | |
| 689 | async function openBundlePreview(groupRecord) { |
| 690 | const children = groupRecord?.children || []; |
| 691 | const previewable = children.filter((child) => child?.filePath && isPreviewableModelPath(child.filePath)); |
| 692 | if (!previewable.length) { |
| 693 | alert('No STL or 3MF models in this bundle to preview.'); |
| 694 | return; |
| 695 | } |
| 696 | |
| 697 | const sorted = [...previewable].sort((a, b) => |
| 698 | String(a.fileName || '').localeCompare(String(b.fileName || ''), undefined, { sensitivity: 'base' }) |
| 699 | ); |
| 700 | const toLoad = sorted.slice(0, MAX_BUNDLE_PREVIEW_PARTS); |
| 701 | const truncated = previewable.length > MAX_BUNDLE_PREVIEW_PARTS; |
| 702 | |
| 703 | currentFilePath = null; |
| 704 | const loadToken = ++previewLoadToken; |
| 705 | const dialog = document.getElementById('preview-dialog'); |
| 706 | if (!dialog) { |
| 707 | console.error('[Preview] preview-dialog element not found!'); |
| 708 | return; |
| 709 | } |
| 710 | |
| 711 | currentBundleGroupRecord = groupRecord; |