import { getInstance } from '@module-federation/runtime';
import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';

const getScope = ()=>{
    return getInstance().options.name;
};
const getPrefetchId = (id)=>encodeName(`${id}/${MFPrefetchCommon.identifier}`);
const compatGetPrefetchId = (id)=>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;
};

export { getSignalFromManifest as a, getPrefetchId as b, compatGetPrefetchId as c, getScope as g };
