"); const i = ee ? ee.createHTML(e) : e; if (ot === nt) try { t = (new C).parseFromString(i, ut) } catch (e) { } if (!t || !t.documentElement) { t = ce.createDocument(ot, "template", null); try { t.documentElement.innerHTML = it ? se : i } catch (e) { } } const r = t.body || t.documentElement; return e && n && r.insertBefore(o.createTextNode(n), r.childNodes[0] || null), ot === nt ? me.call(t, ze ? "html" : "body")[0] : ze ? t.documentElement : r }, At = function (e) { return ue.call(e.ownerDocument || e, e, p.SHOW_ELEMENT | p.SHOW_COMMENT | p.SHOW_TEXT | p.SHOW_PROCESSING_INSTRUCTION | p.SHOW_CDATA_SECTION, null) }, Et = function (e) { return e instanceof L && ("string" != typeof e.nodeName || "string" != typeof e.textContent || "function" != typeof e.removeChild || !(e.attributes instanceof O) || "function" != typeof e.removeAttribute || "function" != typeof e.setAttribute || "string" != typeof e.namespaceURI || "function" != typeof e.insertBefore || "function" != typeof e.hasChildNodes) }, bt = function (e) { return "function" == typeof u && e instanceof u }; function St(e, t, o) { f(e, e => { e.call(n, t, o, pt) }) } const xt = function (e) { let t = null; if (St(fe.beforeSanitizeElements, e, null), Et(e)) return _t(e), !0; const o = mt(e.nodeName); if (St(fe.uponSanitizeElement, e, { tagName: o, allowedTags: be }), e.hasChildNodes() && !bt(e.firstElementChild) && x(/<[/\w]/g, e.innerHTML) && x(/<[/\w]/g, e.textContent)) return _t(e), !0; if (e.nodeType === ie) return _t(e), !0; if (Ie && e.nodeType === re && x(/<[/\w]/g, e.data)) return _t(e), !0; if (!be[o] || Le[o]) { if (!Le[o] && Ot(o)) { if (Oe.tagNameCheck instanceof RegExp && x(Oe.tagNameCheck, o)) return !1; if (Oe.tagNameCheck instanceof Function && Oe.tagNameCheck(o)) return !1 } if (qe && !Xe[o]) { const t = Z(e) || e.parentNode, n = K(e) || e.childNodes; if (n && t) { for (let o = n.length - 1; o >= 0; --o) { const i = $(n[o], !0); i.__removalCount = (e.__removalCount || 0) + 1, t.insertBefore(i, J(e)) } } } return _t(e), !0 } return e instanceof m && !function (e) { let t = Z(e); t && t.tagName || (t = { namespaceURI: ot, tagName: "template" }); const n = _(e.tagName), o = _(t.tagName); return !!rt[e.namespaceURI] && (e.namespaceURI === tt ? t.namespaceURI === nt ? "svg" === n : t.namespaceURI === et ? "svg" === n && ("annotation-xml" === o || lt[o]) : Boolean(yt[n]) : e.namespaceURI === et ? t.namespaceURI === nt ? "math" === n : t.namespaceURI === tt ? "math" === n && st[o] : Boolean(wt[n]) : e.namespaceURI === nt ? !(t.namespaceURI === tt && !st[o]) && !(t.namespaceURI === et && !lt[o]) && !wt[n] && (ct[n] || !yt[n]) : !("application/xhtml+xml" !== ut || !rt[e.namespaceURI])) }(e) ? (_t(e), !0) : "noscript" !== o && "noembed" !== o && "noframes" !== o || !x(/<\/no(script|embed|frames)/i, e.innerHTML) ? (De && e.nodeType === oe && (t = e.textContent, f([he, ge, ye], e => { t = A(t, e, " ") }), e.textContent !== t && (y(n.removed, { element: e.cloneNode() }), e.textContent = t)), St(fe.afterSanitizeElements, e, null), !1) : (_t(e), !0) }, Nt = function (e, t, n) { if (Ge && ("id" === t || "name" === t) && (n in o || n in ft)) return !1; if (Me && !Re[t] && x(we, t)); else if (Ce && x(_e, t)); else if (!xe[t] || Re[t]) { if (!(Ot(e) && (Oe.tagNameCheck instanceof RegExp && x(Oe.tagNameCheck, e) || Oe.tagNameCheck instanceof Function && Oe.tagNameCheck(e)) && (Oe.attributeNameCheck instanceof RegExp && x(Oe.attributeNameCheck, t) || Oe.attributeNameCheck instanceof Function && Oe.attributeNameCheck(t)) || "is" === t && Oe.allowCustomizedBuiltInElements && (Oe.tagNameCheck instanceof RegExp && x(Oe.tagNameCheck, n) || Oe.tagNameCheck instanceof Function && Oe.tagNameCheck(n)))) return !1 } else if (Ze[t]); else if (x(Ee, A(n, Te, ""))); else if ("src" !== t && "xlink:href" !== t && "href" !== t || "script" === e || 0 !== E(n, "data:") || !Ve[e]) { if (Fe && !x(ve, A(n, Te, ""))); else if (n) return !1 } else; return !0 }, Ot = function (e) { return "annotation-xml" !== e && T(e, Ae) }, Lt = function (e) { St(fe.beforeSanitizeAttributes, e, null); const { attributes: t } = e; if (!t || Et(e)) return; const o = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: xe, forceKeepAttr: void 0 }; let i = t.length; for (; i--;) { const r = t[i], { name: a, namespaceURI: l, value: s } = r, c = mt(a); let u = "value" === a ? s : b(s); if (o.attrName = c, o.attrValue = u, o.keepAttr = !0, o.forceKeepAttr = void 0, St(fe.uponSanitizeAttribute, e, o), u = o.attrValue, !je || "id" !== c && "name" !== c || (vt(a, e), u = "user-content-" + u), Ie && x(/((--!?|])>)|<\/(style|title)/i, u)) { vt(a, e); continue } if (o.forceKeepAttr) continue; if (vt(a, e), !o.keepAttr) continue; if (!ke && x(/\/>/i, u)) { vt(a, e); continue } De && f([he, ge, ye], e => { u = A(u, e, " ") }); const d = mt(e.nodeName); if (Nt(d, c, u)) { if (ee && "object" == typeof q && "function" == typeof q.getAttributeType) if (l); else switch (q.getAttributeType(d, c)) { case "TrustedHTML": u = ee.createHTML(u); break; case "TrustedScriptURL": u = ee.createScriptURL(u) }try { l ? e.setAttributeNS(l, a, u) : e.setAttribute(a, u), Et(e) ? _t(e) : g(n.removed) } catch (e) { } } } St(fe.afterSanitizeAttributes, e, null) }, Rt = function e(t) { let n = null; const o = At(t); for (St(fe.beforeSanitizeShadowDOM, t, null); n = o.nextNode();)St(fe.uponSanitizeShadowNode, n, null), xt(n), Lt(n), n.content instanceof l && e(n.content); St(fe.afterSanitizeShadowDOM, t, null) }; return n.sanitize = function (e) { let t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, o = null, i = null, a = null, s = null; if (it = !e, it && (e = "\x3c!--\x3e"), "string" != typeof e && !bt(e)) { if ("function" != typeof e.toString) throw N("toString is not a function"); if ("string" != typeof (e = e.toString())) throw N("dirty is not a string, aborting") } if (!n.isSupported) return e; if (Pe || gt(t), n.removed = [], "string" == typeof e && (Ye = !1), Ye) { if (e.nodeName) { const t = mt(e.nodeName); if (!be[t] || Le[t]) throw N("root node is forbidden and cannot be sanitized in-place") } } else if (e instanceof u) o = Tt("\x3c!----\x3e"), i = o.ownerDocument.importNode(e, !0), i.nodeType === ne && "BODY" === i.nodeName || "HTML" === i.nodeName ? o = i : o.appendChild(i); else { if (!He && !De && !ze && -1 === e.indexOf("<")) return ee && Be ? ee.createHTML(e) : e; if (o = Tt(e), !o) return He ? null : Be ? se : "" } o && Ue && _t(o.firstChild); const c = At(Ye ? e : o); for (; a = c.nextNode();)xt(a), Lt(a), a.content instanceof l && Rt(a.content); if (Ye) return e; if (He) { if (We) for (s = de.call(o.ownerDocument); o.firstChild;)s.appendChild(o.firstChild); else s = o; return (xe.shadowroot || xe.shadowrootmode) && (s = pe.call(r, s, !0)), s } let d = ze ? o.outerHTML : o.innerHTML; return ze && be["!doctype"] && o.ownerDocument && o.ownerDocument.doctype && o.ownerDocument.doctype.name && x(Q, o.ownerDocument.doctype.name) && (d = "\n" + d), De && f([he, ge, ye], e => { d = A(d, e, " ") }), ee && Be ? ee.createHTML(d) : d }, n.setConfig = function () { gt(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}), Pe = !0 }, n.clearConfig = function () { pt = null, Pe = !1 }, n.isValidAttribute = function (e, t, n) { pt || gt({}); const o = mt(e), i = mt(t); return Nt(o, i, n) }, n.addHook = function (e, t) { "function" == typeof t && y(fe[e], t) }, n.removeHook = function (e, t) { if (void 0 !== t) { const n = h(fe[e], t); return -1 === n ? void 0 : w(fe[e], n, 1)[0] } return g(fe[e]) }, n.removeHooks = function (e) { fe[e] = [] }, n.removeAllHooks = function () { fe = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] } }, n }(); function de() { if (null == se) { var e = function () { var e = window.location; "about:srcdoc" == e.href && (e = window.parent.location); var t = {}; return function (e, n, o) { for (; o = n.exec(e);)t[decodeURIComponent(o[1])] = decodeURIComponent(o[2]) }(e.search.substring(1).replace(/\+/g, "%20"), /([^&=]+)=?([^&]*)/g), t }(); se = "referrer" in e ? /^https:\/\/medium.com\//.test(e.referrer) : !("auto" in e) } return se } function me(e) { var t = e || window.innerWidth; return t > 999 ? 650 : t > 599 ? 575 : 400 } function pe(e) { if (e && window.top !== window.self) { var t = window; "srcdoc" == t.location.pathname && (t = t.parent); var n = { sender: "Flourish", method: "scrolly", captions: e.captions, hasScrollyTransformFix: e.hasScrollyTransformFix }; t.parent.postMessage(JSON.stringify(n), "*") } } function fe(e, t) { if (window.top !== window.self) { var n = window; if ("srcdoc" == n.location.pathname && (n = n.parent), ce) return e = parseInt(e, 10), void n.parent.postMessage({ sentinel: "amp", type: "embed-size", height: e }, "*"); var o = { sender: "Flourish", context: "iframe.resize", method: "resize", height: e, src: n.location.toString() }; if (t) for (var i in t) o[i] = t[i]; n.parent.postMessage(JSON.stringify(o), "*") } } function he() { return (-1 !== navigator.userAgent.indexOf("Safari") || -1 !== navigator.userAgent.indexOf("iPhone")) && -1 == navigator.userAgent.indexOf("Chrome") } function ge(e) { return "string" == typeof e || e instanceof String } function ye(e) { return "warn" !== e.method ? (console.warn("BUG: validateWarnMessage called for method" + e.method), !1) : !(null != e.message && !ge(e.message)) && !(null != e.explanation && !ge(e.explanation)) } function we(e) { return "resize" !== e.method ? (console.warn("BUG: validateResizeMessage called for method" + e.method), !1) : !!ge(e.src) && (!!ge(e.context) && !!("number" == typeof (t = e.height) ? !isNaN(t) && t >= 0 : ge(t) && /\d/.test(t) && /^[0-9]*(\.[0-9]*)?(cm|mm|Q|in|pc|pt|px|em|ex|ch|rem|lh|vw|vh|vmin|vmax|%)?$/i.test(t))); var t } function _e(e) { throw new Error("Validation for setSetting is not implemented yet; see issue #4328") } function ve(e) { return "scrolly" !== e.method ? (console.warn("BUG: validateScrolly called for method" + e.method), !1) : !!Array.isArray(e.captions) } function Te(e) { return "customerAnalytics" === e.method || (console.warn("BUG: validateCustomerAnalyticsMessage called for method" + e.method), !1) } function Ae(e) { return "request-upload" !== e.method ? (console.warn("BUG: validateResizeMessage called for method" + e.method), !1) : !!ge(e.name) && !(null != e.accept && !ge(e.accept)) } function Ee(e, t, n) { var o = function (e) { for (var t = { warn: ye, resize: we, setSetting: _e, customerAnalytics: Te, "request-upload": Ae, scrolly: ve }, n = {}, o = 0; o < e.length; o++) { var i = e[o]; if (!t[i]) throw new Error("No validator found for method " + i); n[i] = t[i] } return n }(t); window.addEventListener("message", function (t) { var i = function () { if (t.origin == document.location.origin) return !0; if (n) { const e = t.origin.toLowerCase(); if (n = n.toLowerCase(), e.endsWith("//" + n)) return !0; if (e.endsWith("." + n)) return !0 } return !!t.origin.match(/\/\/localhost:\d+$|\/\/(?:public|app)\.local\.flourish-internal\.com$|\/\/flourish-api\.com$|\.flourish\.(?:local(:\d+)?|net|rocks|studio)$|\.uri\.sh$|\/\/flourish-user-templates\.com$/) }(); if (null != t.source && i) { var r; try { r = "object" == typeof t.data ? t.data : JSON.parse(t.data) } catch (e) { return void console.warn("Unexpected non-JSON message: " + JSON.stringify(t.data)) } if ("Flourish" === r.sender) if (r.method) if (Object.prototype.hasOwnProperty.call(o, r.method)) if (o[r.method](r)) { for (var a = document.querySelectorAll("iframe"), l = 0; l < a.length; l++)if (a[l].contentWindow == t.source || a[l].contentWindow == t.source.parent) return void e(r, a[l]); console.warn("could not find frame", r) } else console.warn("Validation failed for the message", r); else console.warn("No validator implemented for message", r); else console.warn("The 'method' property was missing from message", r) } }), he() && (window.addEventListener("resize", be), be()) } function be() { for (var e = document.querySelectorAll(".flourish-embed"), t = 0; t < e.length; t++) { var n = e[t]; if (!n.getAttribute("data-width")) { var o = n.querySelector("iframe"); if (o) { var i = window.getComputedStyle(n), r = n.offsetWidth - parseFloat(i.paddingLeft) - parseFloat(i.paddingRight); o.style.width = r + "px" } } } } function Se(e, t, n) { var o = e.parentNode; if (o.classList.contains("fl-scrolly-wrapper")) return void console.warn("createScrolly is being called more than once per story. This should not happen."); o.classList.add("fl-scrolly-wrapper"), o.style.position = "relative", o.style.paddingBottom = "1px", o.style.transform = "translate3d(0, 0, 0)"; const i = navigator.platform.indexOf("Win") > -1, r = !!window.chrome && (navigator.userAgent.indexOf("Chrome") > -1 || navigator.userAgent.indexOf("Edg") > -1 || navigator.userAgent.indexOf("OPR") > -1); if (i && r && n) { let e, t = 0; window.addEventListener("scroll", function () { clearTimeout(e), e = setTimeout(() => { t = 0 === t ? 1 : 0, o.style.transform = `translateZ(${t}px)` }, 100) }) } e.style.position = "sticky"; var a = o.getAttribute("data-height") || null; a || (a = "80vh", e.style.height = a), e.style.top = "calc(50vh - " + a + "/2)"; var l = o.querySelector(".flourish-credit"); l && (l.style.position = "sticky", l.style.top = "calc(50vh + " + a + "/2)"), t.forEach(function (e, t) { var n = "string" == typeof e && "" != e.trim(), i = document.createElement("div"); i.setAttribute("data-slide", t), i.classList.add("fl-scrolly-caption"), i.style.position = "relative", i.style.transform = "translate3d(0,0,0)", i.style.textAlign = "center", i.style.maxWidth = "500px", i.style.height = "auto", i.style.marginTop = "0", i.style.marginBottom = n ? "100vh" : "50vh", i.style.marginLeft = "auto", i.style.marginRight = "auto"; var r = document.createElement("div"); r.innerHTML = ue.sanitize(e, { ADD_ATTR: ["target"] }), r.style.visibility = n ? "" : "hidden", r.style.display = "inline-block", r.style.paddingTop = "1.25em", r.style.paddingRight = "1.25em", r.style.paddingBottom = "1.25em", r.style.paddingLeft = "1.25em", r.style.background = "rgba(255,255,255,0.9)", r.style.boxShadow = "0px 0px 10px rgba(0,0,0,0.2)", r.style.borderRadius = "10px", r.style.textAlign = "center", r.style.maxWidth = "100%", r.style.margin = "0 20px", r.style.overflowX = "hidden", i.appendChild(r), o.appendChild(i) }), function (e) { for (var t = new IntersectionObserver(function (t) { t.forEach(function (t) { if (t.isIntersecting) { var n = e.querySelector("iframe"); n && (n.src = n.src.replace(/#slide-.*/, "") + "#slide-" + t.target.getAttribute("data-slide")) } }) }, { rootMargin: "0px 0px -0% 0px" }), n = e.querySelectorAll(".fl-scrolly-caption"), o = 0; o < n.length; o++)t.observe(n[o]); e.querySelectorAll(".fl-scrolly-caption img").forEach(function (e) { e.style.maxWidth = "100%" }) }(o) } function xe(e, t, n, o, i) { var r = document.createElement("iframe"); if (r.setAttribute("scrolling", "no"), r.setAttribute("frameborder", "0"), r.setAttribute("title", "Interactive or visual content"), r.setAttribute("sandbox", "allow-same-origin allow-forms allow-scripts allow-downloads allow-popups allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation"), t.appendChild(r), r.offsetParent || "fixed" === getComputedStyle(r).position) Ne(e, t, r, n, o, i); else { var a = { embed_url: e, container: t, iframe: r, width: n, height: o, play_on_load: i }; if (window._flourish_poll_items ? window._flourish_poll_items.push(a) : window._flourish_poll_items = [a], window._flourish_poll_items.length > 1) return r; var l = setInterval(function () { window._flourish_poll_items = window._flourish_poll_items.filter(function (e) { return !e.iframe.offsetParent || (Ne(e.embed_url, e.container, e.iframe, e.width, e.height, e.play_on_load), !1) }), window._flourish_poll_items.length || clearInterval(l) }, 500) } return r } function Ne(e, t, n, o, i, r) { var a; return o && "number" == typeof o ? (a = o, o += "px") : o && o.match(/^[ \t\r\n\f]*([+-]?\d+|\d*\.\d+(?:[eE][+-]?\d+)?)(?:\\?[Pp]|\\0{0,4}[57]0(?:\r\n|[ \t\r\n\f])?)(?:\\?[Xx]|\\0{0,4}[57]8(?:\r\n|[ \t\r\n\f])?)[ \t\r\n\f]*$/) && (a = parseFloat(o)), i && "number" == typeof i && (i += "px"), o ? n.style.width = o : he() ? n.style.width = t.offsetWidth + "px" : n.style.width = "100%", !!i || (e.match(/\?/) ? e += "&auto=1" : e += "?auto=1", i = me(a || n.offsetWidth) + "px"), i && ("%" === i.charAt(i.length - 1) && (i = parseFloat(i) / 100 * t.parentNode.offsetHeight + "px"), n.style.height = i), n.setAttribute("src", e + (r ? "#play-on-load" : "")), n.addEventListener("load", function () { try { n.contentWindow.postMessage({ sender: "Flourish", method: "flourish:creditHandledExternally" }, "*") } catch (e) { console && console.warn && console.warn("Could not send credit postMessage:", e) } }, { once: !0 }), n } function Oe(e) { return !Array.isArray(e) && "object" == typeof e && null != e } function Le(e, t) { for (const n in t) Oe(e[n]) && Oe(t[n]) ? Le(e[n], t[n]) : e[n] = t[n]; return e } !function () { var e, i = window.top === window.self, r = i ? null : (ce = "#amp=1" == window.location.hash, { createEmbedIframe: xe, isFixedHeight: de, getHeightForBreakpoint: me, startEventListeners: Ee, notifyParentWindow: fe, initScrolly: pe, createScrolly: Se, isSafari: he, initCustomerAnalytics: o, addAnalyticsListener: n, sendCustomerAnalyticsMessage: t }), a = !0; function l() { var t; Flourish.fixed_height || (null != e ? t = e : a && (t = r.getHeightForBreakpoint()), t !== window.innerHeight && r.notifyParentWindow(t)) } function s() { -1 !== window.location.search.indexOf("enable_customer_analytics=1") && Flourish.enableCustomerAnalytics(), l(), window.addEventListener("resize", l) } Flourish.warn = function (e) { if ("string" == typeof e && (e = { message: e }), i || "editor" !== Flourish.environment) console.warn(e.message); else { var t = { sender: "Flourish", method: "warn", message: e.message, explanation: e.explanation }; window.parent.postMessage(JSON.stringify(t), "*") } }, Flourish.uploadImage = function (e) { if (i || "story_editor" !== Flourish.environment) throw "Invalid upload request"; var t = { sender: "Flourish", method: "request-upload", name: e.name, accept: e.accept }; window.parent.postMessage(JSON.stringify(t), "*") }, Flourish.setSetting = function (e, t) { if ("editor" === Flourish.environment || "sdk" === Flourish.environment) { var n = { sender: "Flourish", method: "setSetting", name: e, value: t }; window.parent.postMessage(JSON.stringify(n), "*") } else if ("story_editor" === Flourish.environment) { var o = {}; o[e] = t, Le(window.template.state, function (e) { var t = Object.create(null); for (var n in e) { for (var o = t, i = n.indexOf("."), r = 0; i >= 0; i = n.indexOf(".", r = i + 1)) { var a = n.substring(r, i); a in o || (o[a] = Object.create(null)), o = o[a] } o[n.substring(r)] = e[n] } return t }(o)) } }, Flourish.setHeight = function (t) { Flourish.fixed_height || (e = t, a = null == t, l()) }, Flourish.checkHeight = function () { if (!i) { var e = Flourish.__container_height; null != e ? (Flourish.fixed_height = !0, r.notifyParentWindow(e)) : r.isFixedHeight() ? Flourish.fixed_height = !0 : (Flourish.fixed_height = !1, l()) } }, Flourish.fixed_height = i || r.isFixedHeight(), Flourish.enableCustomerAnalytics = function () { r && r.initCustomerAnalytics() }, window.addEventListener("message", function (e) { try { var t = "object" == typeof e.data ? e.data : JSON.parse(e.data) } catch (e) { return } if ("Flourish" === t.sender && "flourish:creditHandledExternally" === t.method) for (var n = document.querySelectorAll(".flourish-credit"), o = 0; o < n.length; o++)n[o].style.display = "none" }), "loading" === document.readyState ? document.addEventListener("DOMContentLoaded", s) : s() }() }(); //# sourceMappingURL=embedded.js.map