!function () {
    "use strict";

    function t(t) {
        const e = t.indexOf(">") + 1, s = t.lastIndexOf("<");
        return t.substring(e, s)
    }

    function e(t) {
        const e = `<script src="${t}"><\/script>`;
        return (new DOMParser).parseFromString(e, "text/html").scripts[0].src
    }

    const s = /(<script[\s\S]*?>)[\s\S]*?<\/script>/gi,
        n = /<(script)\s+((?!type=('|")text\/ng-template\3).)*?>.*?<\/\1>/is, r = /.*\ssrc=('|")?([^>'"\s]+)/,
        i = /.*\stype=('|")?([^>'"\s]+)/, c = /.*\sentry\s*.*/, o = /.*\sasync\s*.*/,
        l = /.*\scrossorigin=('|")?use-credentials\1/, a = /.*\snomodule\s*.*/, p = /.*\stype=('|")?module('|")?\s*.*/,
        u = /<(link)\s+.*?>/gis, h = /\srel=('|")?(preload|prefetch)\1/, d = /.*\shref=('|")?([^>'"\s]+)/,
        m = /.*\sas=('|")?font\1.*/, f = /<style[^>]*>[\s\S]*?<\/style>/gi, y = /\s+rel=('|")?stylesheet\1.*/,
        x = /.*\shref=('|")?([^>'"\s]+)/, g = /<!--([\s\S]*?)-->/g, w = /<link(\s+|\s+.+\s+)ignore(\s*|\s+.*|=.*)>/is,
        b = /<style(\s+|\s+.+\s+)ignore(\s*|\s+.*|=.*)>/is, v = /<script(\s+|\s+.+\s+)ignore(\s*|\s+.*|=.*)>/is;

    function E(t) {
        return t.startsWith("http://") || t.startsWith("https://")
    }

    function S(t, e) {
        return new URL(t, e).toString()
    }

    const $ = (t, e = !1) => `\x3c!-- ${e ? "prefetch/preload" : ""} link ${t} replaced by import-html-entry --\x3e`,
        C = (t, e = !1, s = !1) => `\x3c!-- ${s ? "cors" : ""} ${e ? "async" : ""} script ${t} replaced by import-html-entry --\x3e`,
        O = "\x3c!-- inline scripts replaced by import-html-entry --\x3e",
        T = t => `\x3c!-- ignore asset ${t || "file"} replaced by import-html-entry --\x3e`,
        A = (t, e) => `\x3c!-- ${e ? "nomodule" : "module"} script ${t} ignored by import-html-entry --\x3e`;

    function j(j, k) {
        let H = [];
        const L = [];
        let M = null;
        const U = "noModule" in document.createElement("script");
        return {
            template: j.replace(g, "").replace(u, (t => {
                if (!!t.match(y)) {
                    const s = t.match(x), n = t.match(w);
                    if (s) {
                        const t = s && s[2];
                        let r = t;
                        return t && !E(t) && (r = S(t, k)), n ? T(r) : (r = e(r), L.push({url: r}), $(r))
                    }
                }
                if (t.match(h) && t.match(d) && !t.match(m)) {
                    const [, , e] = t.match(d) || [];
                    return $(e, !0)
                }
                return t
            })).replace(f, (e => {
                if (b.test(e)) return T("style file");
                const s = t(e);
                return L.push({code: s}), e
            })).replace(s, ((s, u) => {
                const h = u.match(v), d = U && !!u.match(a) || !U && !!u.match(p), m = u.match(i), f = m && m[2];
                if ((y = f) && -1 === ["text/javascript", "module", "application/javascript", "text/ecmascript", "application/ecmascript"].indexOf(y)) return s;
                var y;
                if (n.test(s) && u.match(r)) {
                    const t = u.match(c), n = u.match(r);
                    let i = n && n[2];
                    if (M && t) throw new SyntaxError("You should not set multiply entry script!");
                    if (i && (E(i) || (i = S(i, k)), i = e(i)), M = M || t && i, h) return T(i || "js file");
                    if (d) return A(i || "js file", U);
                    if (i) {
                        const t = !!u.match(o), e = !!u.match(l);
                        return H.push({async: t, src: i, crossOrigin: e, moduleSupport: U}), C(i, t, e)
                    }
                    return s
                }
                {
                    if (h) return T("js file");
                    if (d) return A("js file", U);
                    const e = t(s);
                    return e.split(/[\r\n]+/).every((t => !t.trim() || t.trim().startsWith("//"))) || H.push({code: e}), O
                }
            })), scripts: H, styles: L
        }
    }

    if (!window.fetch) throw new Error('[import-html-entry] Here is no "fetch" on the window env, you need to polyfill it');
    (function (t) {
        return fetch(t).then((t => function (t) {
            if (!t.headers) return t.text();
            const e = t.headers.get("Content-Type");
            if (!e) return t.text();
            let s = "utf-8";
            const n = e.split(";");
            if (2 === n.length) {
                const [, t] = n[1].split("="), e = t && t.trim();
                e && (s = e)
            }
            return "UTF-8" === s.toUpperCase() ? t.text() : t.blob().then((t => new Promise(((e, n) => {
                const r = new window.FileReader;
                r.onload = () => {
                    e(r.result)
                }, r.onerror = n, r.readAsText(t, s)
            }))))
        }(t))).then((e => {
            const {template: s, scripts: n, styles: r} = j(e, t);
            return {scripts: n, styles: r, template: e}
        }))
    })(window.AICHATBOTURL || "https://crm-static.wondershare.cc/crm-chatbot/").then((async t => {
        !function (t, e, s) {
            const n = document.createElement("iframe");
            n.setAttribute("id", "chatBot"), n.setAttribute("style", "position: fixed;\n  bottom: 0;\n  right: 0;\n  height: 0;\n  width:0;\n  z-index:999"), document.body.appendChild(n), setTimeout((function () {
                var s;
                const r = n.contentDocument || (null === (s = n.contentWindow) || void 0 === s ? void 0 : s.document);
                if (console.log("iframeDoc", r), r) {
                    const s = r.createElement("div");
                    null == s || s.setAttribute("id", "app"), null == r || r.body.appendChild(s), function (t, e) {
                        e.forEach((e => {
                            const s = null == t ? void 0 : t.createElement("script");
                            s && (e.code && (s.innerHTML = e.code), e.src && (s.src = e.src), e.async && (s.async = !0), e.moduleSupport && (s.type = "module"), s.crossOrigin && (s.crossOrigin = "anonymous"), null == t || t.body.appendChild(s))
                        }))
                    }(r, t), function (t, e) {
                        e.forEach((e => {
                            if (e.url) {
                                const s = null == t ? void 0 : t.createElement("link");
                                s.href = e.url, s.setAttribute("rel", "stylesheet"), null == t || t.head.appendChild(s)
                            } else {
                                const s = null == t ? void 0 : t.createElement("style");
                                s.innerHTML = e.code, null == t || t.head.appendChild(s)
                            }
                        }))
                    }(r, e)
                }
            }), 0)
        }(t.scripts, t.styles, t.template)
    }))
}();
