import { Signal, useSignalEffect } from "@preact/signals"
import { Address } from "$/apps/source";
import { memo, useEffect } from "preact/compat";

export const Browser = memo(function Browser({ source, title, contentReady }: Browser.Props) {
    useEffect(() => {
        contentReady.value = true
    }, [])

    useSignalEffect(() => {
        title.value = `${source.value.link} - internet exploder`;
    })

    return <iframe src={source.value.link.toString()} allowFullScreen={ source.value.link.hostname.includes("youtube.com") } height="40vh" width="40vw"/>
})

namespace Browser {
    export type Props = {
        source: Signal<Address>,
        title: Signal<string | undefined>,
        contentReady: Signal<boolean>
    }
}
