import { combine } from '@hiberworld/code-kit-utils';
/**
 * Add an Interactive Media Asset (IMA)
 * @example
 * ```ts
  const img = getImage({ src: 'https://cdn.hibervr.com/demo/img/Lunch.jpg', ratio: 1000 / 750, p: [0, 0, 5] });
  addInteractiveMediaAsset(img, {
    header: 'Lunch atop a Skyscraper',
    body: 'Lunch atop a Skyscraper is a black-and-white photograph taken on September 20, 1932',
    url: 'https://en.wikipedia.org/wiki/Lunch_atop_a_Skyscraper',
    openInNewTab: false,
  });
  addTo(world, img);
 * ```
 */
export const addInteractiveMediaAsset = (target, opt = {}) => {
    const { header = 'My Header', preBody = '', body = '', url = 'https://hiber.mv', openInNewTab = false, } = opt;
    const isOpenInOverlayEnabled = !openInNewTab;
    const openUrlInNewTab = openInNewTab;
    const infoPanel = {
        header,
        preBody,
        body: body.substring(0, 79),
        url,
        openUrlInNewTab,
        isOpenInOverlayEnabled,
    };
    const { videoUrl, startPlayingAfter, emissiveStrength } = opt;
    const videoTexture = videoUrl
        ? {
            url: videoUrl,
            startPlayingAfter,
            emissiveStrength,
        }
        : undefined;
    const signalId = Math.floor(Math.random() * 100000000).toString();
    const signalSource = {
        id: signalId,
        lookAtSensor: true,
    };
    const { minDistance = 0, maxDistance = 10 } = opt;
    const lookAtSensor = {
        minDistance,
        maxDistance,
    };
    const { musicId: id, volume = 1 } = opt;
    const playMusicOnSignal = id
        ? {
            id,
            volume,
            solo: true,
            ...opt,
        }
        : undefined;
    const props = {
        infoPanel,
        videoTexture,
        signalSource,
        signalListener: {
            target: signalId,
            playMusicOnSignal,
        },
    };
    combine(target, props);
    return target;
};
//# sourceMappingURL=addInteractiveMediaAsset.js.map