| 3036 | return On(e) ? e : dn.loader(e); |
| 3037 | } |
| 3038 | async function In(t, n, r = {}) { |
| 3039 | let i, o; |
| 3040 | e.isString(n) |
| 3041 | ? ((o = An(r.loader)), (i = JSON.parse(await o.load(n)))) |
| 3042 | : (i = n); |
| 3043 | const a = (function (t) { |
| 3044 | const n = t.usermeta?.embedOptions ?? {}; |
| 3045 | return (e.isString(n.defaultStyle) && (n.defaultStyle = !1), n); |
| 3046 | })(i), |
| 3047 | s = a.loader; |
| 3048 | (o && !s) || (o = An(r.loader ?? s)); |
| 3049 | const l = await xn(a, o), |
| 3050 | c = await xn(r, o), |
| 3051 | f = { |
| 3052 | ...ln(c, l), |
| 3053 | config: e.mergeConfig(c.config ?? {}, l.config ?? {}), |
| 3054 | }; |
| 3055 | return await (async function (t, n, r = {}, i) { |
| 3056 | const o = r.theme ? e.mergeConfig(Wt[r.theme], r.config ?? {}) : r.config, |
| 3057 | a = e.isBoolean(r.actions) ? r.actions : ln({}, hn, r.actions ?? {}), |
| 3058 | s = { ...gn, ...r.i18n }, |
| 3059 | l = r.renderer ?? "canvas", |
| 3060 | c = r.logLevel ?? dn.Warn, |
| 3061 | f = r.downloadFileName ?? "visualization", |
| 3062 | d = "string" == typeof t ? document.querySelector(t) : t; |
| 3063 | if (!d) throw new Error(`${t} does not exist`); |
| 3064 | if (!1 !== r.defaultStyle) { |
| 3065 | const e = "vega-embed-style", |
| 3066 | { root: t, rootContainer: n } = (function (e) { |
| 3067 | const t = e.getRootNode ? e.getRootNode() : document; |
| 3068 | return t instanceof ShadowRoot |
| 3069 | ? { root: t, rootContainer: t } |
| 3070 | : { |
| 3071 | root: document, |
| 3072 | rootContainer: document.head ?? document.body, |
| 3073 | }; |
| 3074 | })(d); |
| 3075 | if (!t.getElementById(e)) { |
| 3076 | const t = document.createElement("style"); |
| 3077 | ((t.id = e), |
| 3078 | (t.innerHTML = |
| 3079 | void 0 === r.defaultStyle || !0 === r.defaultStyle |
| 3080 | ? sn.toString() |
| 3081 | : r.defaultStyle), |
| 3082 | n.appendChild(t)); |
| 3083 | } |
| 3084 | } |
| 3085 | const p = (function (e, t) { |
| 3086 | if (e.$schema) { |
| 3087 | const n = je(e.$schema); |
| 3088 | t && |
| 3089 | t !== n.library && |
| 3090 | console.warn( |
| 3091 | `The given visualization spec is written in ${mn[n.library]}, but mode argument sets ${mn[t] ?? t}.`, |
| 3092 | ); |
| 3093 | const r = n.library; |
| 3094 | return ( |
| 3095 | $e(En[r], `^${n.version.slice(1)}`) || |