var g=["esm.sh","skypack","esm.run","jsdelivr.esm","fastly.jsdelivr.esm","gcore.jsdelivr.esm","testingcf.jsdelivr.esm","jsdelivr.b-cdn.esm","jspm"],f=["jsdelivr","fastly.jsdelivr","unpkg","gcore.jsdelivr","testingcf.jsdelivr","jsdelivr.b-cdn","npmcdn"],h=["jsdelivr.gh","fastly.jsdelivr.gh","statically","gcore.jsdelivr.gh","testingcf.jsdelivr.gh","jsdelivr.b-cdn.gh"],a={getModuleUrl:(e,{isModule:t=!0,defaultCDN:s="esm.sh",external:r}={})=>{e=e.replace(/#nobundle/g,"");let o=i=>!r||!i.includes("https://esm.sh")?i:i.includes("?")?`${i}&external=${r}`:`${i}?external=${r}`,n=u(e,t,s);return n?o(n):t?o("https://esm.sh/"+e):"https://cdn.jsdelivr.net/npm/"+e},getUrl:(e,t)=>e.startsWith("http")||e.startsWith("data:")?e:u(e,!1,t||C())||e,cdnLists:{npm:f,module:g,gh:h},checkCDNs:async(e,t)=>{let s=[t,...a.cdnLists.npm].filter(Boolean);for(let r of s)try{if((await fetch(a.getUrl(e,r),{method:"HEAD"})).ok)return r}catch{}return a.cdnLists.npm[0]}},C=()=>{if(globalThis.appCDN)return globalThis.appCDN;try{return new URL(location.href).searchParams.get("appCDN")||a.cdnLists.npm[0]}catch{return a.cdnLists.npm[0]}},u=(e,t,s)=>{let r=t&&e.startsWith("unpkg:")?"?module":"";e.startsWith("gh:")?e=e.replace("gh",h[0]):e.includes(":")||(e=(s||(t?g[0]:f[0]))+":"+e);for(let o of k){let[n,i]=o;if(n.test(e))return e.replace(n,i)+r}return null},k=[[/^(esm\.sh:)(.+)/i,"https://esm.sh/$2"],[/^(npm:)(.+)/i,"https://esm.sh/$2"],[/^(node:)(.+)/i,"https://esm.sh/$2"],[/^(jsr:)(.+)/i,"https://esm.sh/jsr/$2"],[/^(skypack:)(.+)/i,"https://cdn.skypack.dev/$2"],[/^(jsdelivr:)(.+)/i,"https://cdn.jsdelivr.net/npm/$2"],[/^(fastly\.jsdelivr:)(.+)/i,"https://fastly.jsdelivr.net/npm/$2"],[/^(gcore\.jsdelivr:)(.+)/i,"https://gcore.jsdelivr.net/npm/$2"],[/^(testingcf\.jsdelivr:)(.+)/i,"https://testingcf.jsdelivr.net/npm/$2"],[/^(jsdelivr\.b-cdn:)(.+)/i,"https://jsdelivr.b-cdn.net/npm/$2"],[/^(jsdelivr\.gh:)(.+)/i,"https://cdn.jsdelivr.net/gh/$2"],[/^(fastly\.jsdelivr\.gh:)(.+)/i,"https://fastly.jsdelivr.net/gh/$2"],[/^(gcore\.jsdelivr\.gh:)(.+)/i,"https://gcore.jsdelivr.net/gh/$2"],[/^(testingcf\.jsdelivr\.gh:)(.+)/i,"https://testingcf.jsdelivr.net/gh/$2"],[/^(jsdelivr\.b-cdn\.gh:)(.+)/i,"https://jsdelivr.b-cdn.net/gh/$2"],[/^(statically:)(.+)/i,"https://cdn.statically.io/gh/$2"],[/^(esm\.run:)(.+)/i,"https://esm.run/$2"],[/^(jsdelivr\.esm:)(.+)/i,"https://cdn.jsdelivr.net/npm/$2/+esm"],[/^(fastly\.jsdelivr\.esm:)(.+)/i,"https://fastly.jsdelivr.net/npm/$2/+esm"],[/^(gcore\.jsdelivr\.esm:)(.+)/i,"https://gcore.jsdelivr.net/npm/$2/+esm"],[/^(testingcf\.jsdelivr\.esm:)(.+)/i,"https://testingcf.jsdelivr.net/npm/$2/+esm"],[/^(jsdelivr\.b-cdn\.esm:)(.+)/i,"https://jsdelivr.b-cdn.net/npm/$2/+esm"],[/^(jspm:)(.+)/i,"https://jspm.dev/$2"],[/^(esbuild:)(.+)/i,"https://esbuild.vercel.app/$2"],[/^(bundle\.run:)(.+)/i,"https://bundle.run/$2"],[/^(unpkg:)(.+)/i,"https://unpkg.com/$2"],[/^(npmcdn:)(.+)/i,"https://npmcdn.com/$2"],[/^(bundlejs:)(.+)/i,"https://deno.bundlejs.com/?file&q=$2"],[/^(bundle:)(.+)/i,"https://deno.bundlejs.com/?file&q=$2"],[/^(deno:)(.+)/i,"https://deno.bundlejs.com/?file&q=https://deno.land/x/$2/mod.ts"],[/^(https:\/\/deno\.land\/.+)/i,"https://deno.bundlejs.com/?file&q=$1"],[/^(github:|https:\/\/github\.com\/)(.[^\/]+?)\/(.[^\/]+?)\/(?!releases\/)(?:(?:blob|raw)\/)?(.+?\/.+)/i,"https://deno.bundlejs.com/?file&q=https://cdn.jsdelivr.net/gh/$2/$3@$4"],[/^(gist\.github:)(.+?\/[0-9a-f]+\/raw\/(?:[0-9a-f]+\/)?.+)$/i,"https://gist.githack.com/$2"],[/^(gitlab:|https:\/\/gitlab\.com\/)([^\/]+.*\/[^\/]+)\/(?:raw|blob)\/(.+?)(?:\?.*)?$/i,"https://deno.bundlejs.com/?file&q=https://gl.githack.com/$2/raw/$3"],[/^(bitbucket:|https:\/\/bitbucket\.org\/)([^\/]+\/[^\/]+)\/(?:raw|src)\/(.+?)(?:\?.*)?$/i,"https://deno.bundlejs.com/?file&q=https://bb.githack.com/$2/raw/$3"],[/^(bitbucket:)snippets\/([^\/]+\/[^\/]+)\/revisions\/([^\/\#\?]+)(?:\?[^#]*)?(?:\#file-(.+?))$/i,"https://bb.githack.com/!api/2.0/snippets/$2/$3/files/$4"],[/^(bitbucket:)snippets\/([^\/]+\/[^\/\#\?]+)(?:\?[^#]*)?(?:\#file-(.+?))$/i,"https://bb.githack.com/!api/2.0/snippets/$2/HEAD/files/$3"],[/^(bitbucket:)\!api\/2.0\/snippets\/([^\/]+\/[^\/]+\/[^\/]+)\/files\/(.+?)(?:\?.*)?$/i,"https://bb.githack.com/!api/2.0/snippets/$2/files/$3"],[/^(api\.bitbucket:)2.0\/snippets\/([^\/]+\/[^\/]+\/[^\/]+)\/files\/(.+?)(?:\?.*)?$/i,"https://bb.githack.com/!api/2.0/snippets/$2/files/$3"],[/^(rawgit:)(.+?\/[0-9a-f]+\/raw\/(?:[0-9a-f]+\/)?.+)$/i,"https://gist.githack.com/$2"],[/^(rawgit:|https:\/\/raw\.githubusercontent\.com)(\/[^\/]+\/[^\/]+|[0-9A-Za-z-]+\/[0-9a-f]+\/raw)\/(.+)/i,"https://deno.bundlejs.com/?file&q=https://raw.githack.com/$2/$3"]];var T=e=>!e?.startsWith("http")&&!e?.startsWith("data:"),x=(e,t=document.baseURI)=>T(e)?new URL(e,t).href:e;var b=(e,t)=>new Promise((s,r)=>{if(t&&globalThis[t])return s(globalThis[t]);if(typeof globalThis.importScripts=="function")return globalThis.importScripts(e),t&&globalThis[t]?s(globalThis[t]):s(globalThis);let o=document.createElement("script");o.src=e,o.async=!0;let n=()=>{o.removeEventListener("load",i),o.removeEventListener("error",c)},i=()=>{if(n(),!t)return s("loaded: "+e);let l=setInterval(()=>{if(window[t])return clearInterval(l),s(window[t])},5)},c=()=>{n(),r("failed to load: "+e)};o.addEventListener("load",i),o.addEventListener("error",c),document.head.appendChild(o)});var m=/(import\s+?(?:(?:(?:[\w*\s{},\$]*)\s+from\s+?)|))((?:".*?")|(?:'.*?'))([\s]*?(?:;|$|))/g;var{getUrl:p,getModuleUrl:X}=a;var y=p("requirejs@2.3.6/require.js"),w=p("https://cdn.rescript-lang.org/v9.1.2/compiler.js"),j=p("https://cdn.rescript-lang.org/v9.1.2/%40rescript/react/cmij.js"),U=p("@rescript/std@9.1.3/lib/es6/"),d=p("https://cdn.rescript-lang.org/v11.1.2/"),v=p("@rescript/std@11.1.2/lib/es6/");var $=(e,t)=>e.replace(new RegExp(m),s=>s.replace(new RegExp(m),"$2").replace(/"/g,"").replace(/'/g,"").startsWith("./stdlib/")?s.replace("./stdlib/",t):s),E=async e=>(window.require||(await b(y,"require"),window.requirejs.config({waitSeconds:0})),new Promise((t,s)=>{e==="reason"?window.require([w,j],()=>{window.reason_compiler=window.rescript_compiler,window.rescript_compiler=void 0,window.loadedReasonCompiler=window.reason_compiler.make();let r=window.loadedReasonCompiler;r.setModuleSystem("es6"),r.setFilename("index.bs.js"),t()},s):window.require([d+"compiler.js",d+"compiler-builtins/cmij.js",d+"%40rescript/react/cmij.js",d+"%40rescript/core/cmij.js"],()=>{window.rescript_ocaml_compiler=window.rescript_compiler,window.rescript_compiler=void 0,window.loadedRescriptCompiler=window.rescript_ocaml_compiler.make();let r=window.loadedRescriptCompiler;r.setModuleSystem("es6"),r.setOpenModules(["RescriptCore"]),r.setFilename("index.bs.js"),t()},s)})),re=async(e,{baseUrl:t,language:s})=>{if(!e)return"";let r=s==="reason"?"loadedReasonCompiler":"loadedRescriptCompiler",o=s==="reason"?U:v,n=3;for(;!window[r]&&n>0;)try{await E(s)}catch{console.warn(`Failed to load ${s} compiler. Retrying...`),n--}let c=window[r][s].compile(e);try{return c.type==="success"&&c.js_code?$(c.js_code,x(o,t)):(c.errors?c.errors.forEach(l=>{console.error(l.fullMsg)}):c.msg&&console.warn(c.msg,c.type),"")}catch(l){return console.error(l),""}};export{re as rescriptCompiler};