/**
 * Runs pattern-ui pages with no build step. Load it with a classic `<script src>` in `<head>` and
 * write the page in `<script type="text/tsx">` blocks. It loads the two scripts next to it:
 *
 * - `play-cdn-tsx.js` compiles each `text/tsx` block with Sucrase and loads its bare imports from
 *   esm.sh
 * - `play-cdn-tailwind.js` compiles pattern-ui's styles with Tailwind and rebuilds as classes appear
 *   on the page
 *
 * In a Claude artifact, use `play-cdn-claude.js` instead.
 */
const scriptUrl = new URL(
  document.currentScript instanceof HTMLScriptElement ? document.currentScript.src : location.href,
)

for (const name of ['play-cdn-tailwind.js', 'play-cdn-tsx.js']) {
  const url = new URL(name, scriptUrl)
  // esm.sh serves this package's files unchanged only with this script's `?raw`.
  url.search = scriptUrl.search
  void import(url.href)
}
