'use strict';

var runtime = require('@module-federation/runtime');
var sdk = require('@module-federation/sdk');

const getScope = ()=>{
    return runtime.getInstance().options.name;
};
const getPrefetchId = (id)=>sdk.encodeName(`${id}/${sdk.MFPrefetchCommon.identifier}`);
const compatGetPrefetchId = (id)=>sdk.encodeName(`${id}/VmokPrefetch`);
const getSignalFromManifest = (remoteSnapshot)=>{
    if (!remoteSnapshot) {
        return false;
    }
    if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
        return false;
    }
    if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
        return false;
    }
    return true;
};

exports.compatGetPrefetchId = compatGetPrefetchId;
exports.getPrefetchId = getPrefetchId;
exports.getScope = getScope;
exports.getSignalFromManifest = getSignalFromManifest;
