import '../components/devvit-blocks-webview.js';
import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
import { nothing } from 'lit';
import { defaultClasses, defaultStyles, onWebViewAction } from '../attributes.js';
import { classMap } from './util.js';
export function renderWebViewBlock(block, ctx) {
    const { html, styleMap } = getTemplateRenderingStrategy();
    if (!block.config?.webviewConfig) {
        console.error('Invalid block: WebView missing WebViewConfig');
        return nothing;
    }
    const { url, state } = block.config.webviewConfig;
    const classes = {
        ...defaultClasses(block, ctx),
    };
    const styles = {
        ...defaultStyles(block, ctx),
    };
    const onWebView = onWebViewAction(block, ctx);
    const resolvedURL = ctx.resolveWebviewUrl?.(url);
    return html `<devvit-blocks-webview
    src="${resolvedURL}"
    class="${classMap(classes)}"
    style="${styleMap(styles)}"
    .state="${state}"
    data-debug-block-type="webview"
    @message="${onWebView}"
  ></devvit-blocks-webview>`;
}
//# sourceMappingURL=renderWebViewBlock.js.map