import { ViewerApi } from './viewer-api.js';

export class ViewerPrefetch {
    static fromLocation(location = window.location) {
        const params = new URLSearchParams(location.search);
        const id = params.get('id');
        if (!id) return;

        const link = document.createElement('link');
        link.rel = 'prefetch';
        link.as = 'fetch';
        link.crossOrigin = 'anonymous';
        link.href = ViewerApi.assetUrl(id);
        document.head.appendChild(link);
    }
}
