---
/**
 * TravelpayoutsWidgetBody — the widget wrapper both TravelpayoutsWidget variants render: the loader script, or for
 * `isolate` the same script inside a sandboxed `srcdoc` iframe. Internal; not exported.
 */
interface Props {
  src: string;
  isolate: boolean;
  wrapperClass: string;
  iframeTitle: string;
  marker?: string;
}

const { src, isolate, wrapperClass, iframeTitle, marker } = Astro.props;
const widgetDoc = `<!doctype html><html><head><meta charset="utf-8" /></head><body style="margin:0"><script async src="${src}" charset="utf-8"></script></body></html>`;
---
{isolate ? (
  <div class={wrapperClass} data-affiliate-widget={marker}>
    <iframe
      srcdoc={widgetDoc}
      sandbox="allow-scripts allow-same-origin allow-popups allow-forms"
      loading="lazy"
      title={iframeTitle}
      class="w-full h-[478px] sm:h-[430px] border-0 block"
    />
  </div>
) : (
  <div class={wrapperClass} data-affiliate-widget={marker}>
    <script async src={src} charset="utf-8" is:inline />
  </div>
)}
