/**
* PDA v1.1.2
* (c) 2024 Product Designer App
* @license GPLv3
* Settings
* Free version
* Unminify code for Dev
**/
const { createApp: createApp } = Vue;
var pdappVueApp = createApp({
    data: () => ({
        loadingPage: !0,
        modal: { show: !1 },
        toast: { show: !1, type: "success", text: "" },
        settings: [],
        uploadType: ["jpg", "png", "svg"],
        downloadType: ["pdf", "svg", "png"],
        photoLibraries: ["unsplash", "pexels"],
        langs: {},
        langCode: "en_US",
        listLangs: [],
        oldLangs: {},
        activeTab: 0,
        tabs: [],
        pluginUrl: pdappPluginUrl,
        loading: !1,
        translate: "",
        translateLang: {},
        translateFile: "",
        listTexts: [],
        listFonts: [],
        listShapes: [],
        listFilters: [],
        fontLibrary: [],
        fontCate: {
            search: "",
            find: "all",
            list: ["all", "sans-serif", "serif", "display", "handwriting", "monospace", "custom"],
        },
        selectAll: !1,
        selectAlls: [],
        listUploads: [],
        renderedThumb: !1,
        editMode: !1,
        fontFaces: {},
        team: { dropdown: "", findFont: "", fontCate: "" },
        pdappPurchasedCode: pdappPurchasedCode,
        pdappApiToken: "",
        showStore: !1,
        storeType: "text",
        confirmEmail: { code: "", timeLess: 0, error: "", refresh: !0 },
        loadedStore: !1,
        loadingStore: !1,
        uploadTexts: [],
        uploadShapes: [],
        uploadFilters: [],
    }),
    created() {
        jQuery("#productdesignerapp-app").show(), this.getSystemSetting();
    },
    computed: {
        breadcrumbs() {
            let t = { title: "", pages: [] };
            return (
                void 0 === this.langs.menu ||
                    ((t.title = this.langs.menu.settings), (t.pages = [{ to: "", title: t.title }])),
                t
            );
        },
        general() {
            let t = {};
            return void 0 !== this.settings.general && (t = this.settings.general), t;
        },
        layout() {
            let t = {};
            return void 0 !== this.settings.layout && (t = this.settings.layout), t;
        },
        listFontLib() {
            let t = this,
                e = [];
            if (t.fontLibrary.length) {
                let a = [];
                for (let e = 0; e < t.listFonts.length; e++) a.push(t.listFonts[e].title);
                for (let o = 0; o < t.fontLibrary.length; o++)
                    a.includes(t.fontLibrary[o].title) ||
                        ("all" != t.fontCate.find && t.fontLibrary[o].category != t.fontCate.find) ||
                        (("" == t.fontCate.search ||
                            -1 != t.fontLibrary[o].title.toLowerCase().indexOf(t.fontCate.search.toLowerCase())) &&
                            e.push(t.fontLibrary[o]));
            }
            return e;
        },
        transLang() {
            let t = {};
            return void 0 !== this.translateLang[this.translateFile] && (t = this.translateLang[this.translateFile]), t;
        },
        listFontTexts() {
            let t = this,
                e = { category: [], fonts: [] };
            for (let a = 0; a < t.settings.font.length; a++)
                !1 === e.category.includes(t.settings.font[a].category) && e.category.push(t.settings.font[a].category),
                    ("" != t.modal.fontCate && t.settings.font[a].category != t.modal.fontCate) ||
                        (("" == t.modal.findFont ||
                            -1 != t.settings.font[a].title.toLowerCase().indexOf(t.modal.findFont.toLowerCase())) &&
                            e.fonts.push(t.settings.font[a]));
            return e;
        },
        listFontTeams() {
            let t = this,
                e = { category: [], fonts: [] };
            for (let a = 0; a < t.settings.font.length; a++)
                !1 === e.category.includes(t.settings.font[a].category) && e.category.push(t.settings.font[a].category),
                    ("" != t.team.fontCate && t.settings.font[a].category == t.team.fontCate) ||
                        (("" == t.team.findFont ||
                            -1 != t.settings.font[a].title.toLowerCase().indexOf(t.team.findFont.toLowerCase())) &&
                            e.fonts.push(t.settings.font[a]));
            return e;
        },
        timeDown() {
            let t = "" + Math.floor(this.confirmEmail.timeLess / 60),
                e = "" + (this.confirmEmail.timeLess - 60 * t);
            return 1 == t.length && (t = "0" + t), 1 == e.length && (e = "0" + e), t + ":" + e;
        },
    },
    watch: {
        selectAll() {
            if (((this.selectAlls = []), this.selectAll))
                for (let t = 0; t < this.listFontLib.length; t++) this.selectAlls.push(this.listFontLib[t].title);
        },
        editMode() {
            void 0 !== this.settings.font && (this.listFonts = JSON.parse(JSON.stringify(this.settings.font))),
                void 0 !== this.settings.text && (this.listTexts = JSON.parse(JSON.stringify(this.settings.text))),
                void 0 !== this.settings.shape && (this.listShapes = JSON.parse(JSON.stringify(this.settings.shape))),
                void 0 !== this.settings.filter &&
                    (this.listFilters = JSON.parse(JSON.stringify(this.settings.filter)));
        },
    },
    methods: {
        goToPage(t) {
            "themes" == t && this.showListThemes();
        },
        async getRefreshToken() {
            let t = this,
                e = pdappAdminUrl + "admin-ajax.php?action=pdapp-refresh-token&admin=1";
            try {
                let t = await pdappAPI.tool.getData(e);
                pdappNonce = t.data.token;
            } catch (t) {}
            setTimeout(() => {
                t.getRefreshToken();
            }, 6e4);
        },
        async getSystemSetting() {
            let t = this,
                e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-load-setting&langs=1&&langCode=1&listLangs=1&admin=1&pdapp-nonce=" +
                    pdappNonce;
            try {
                let a = await pdappAPI.tool.getData(e);
                (t.langs = a.data.langs),
                    (t.langCode = a.data.langCode),
                    (t.listLangs = a.data.listLangs),
                    (t.tabs = [
                        { icon: "settings", title: t.langs.setting.general },
                        { icon: "view_comfy_alt", title: t.langs.setting.layout },
                        { icon: "format_size", title: t.langs.setting.text_library },
                        { icon: "font_download", title: t.langs.setting.fonts },
                        { icon: "interests", title: t.langs.setting.shapes },
                        { icon: "discover_tune", title: t.langs.setting.filters },
                        { icon: "language", title: t.langs.setting.languages },
                        { icon: "device_reset", title: t.langs.setting.advanced },
                    ]),
                    t.showListSettings();
            } catch (t) {}
            setTimeout(() => {
                t.getRefreshToken();
            }, 6e4);
        },
        async showListSettings() {
            let t = this;
            if (((t.loadingPage = !0), 0 == t.settings.length)) {
                let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-settings&admin=1&pdapp-nonce=" + pdappNonce;
                try {
                    let a = await pdappAPI.tool.getData(e);
                    (t.settings = a.data),
                        void 0 !== t.settings.font && (t.listFonts = JSON.parse(JSON.stringify(t.settings.font))),
                        void 0 !== t.settings.text && (t.listTexts = JSON.parse(JSON.stringify(t.settings.text))),
                        void 0 !== t.settings.shape && (t.listShapes = JSON.parse(JSON.stringify(t.settings.shape))),
                        void 0 !== t.settings.filter && (t.listFilters = JSON.parse(JSON.stringify(t.settings.filter)));
                } catch (e) {
                    (t.toast = { show: !0, type: "warning", text: e.msg }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                }
            }
            pdappAPI.tool.updateURL("settings"), (t.loadingPage = !1);
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-list-fonts&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = await pdappAPI.tool.getData(e);
                t.fontLibrary = a.data;
            } catch (t) {}
        },
        async updateSettings(t, e) {
            let a = this;
            a.loading = e;
            let o =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-save-settings&type=" +
                e +
                "&admin=1&pdapp-nonce=" +
                pdappNonce;
            try {
                let p = new Blob([JSON.stringify({ data: JSON.stringify(t) })], { type: "application/json" }),
                    i = new FormData();
                i.append("settings", p, "settings.json");
                let d = await pdappAPI.tool.uploadData(o, i);
                (a.toast = { show: !0, type: "success", text: d.msg }),
                    setTimeout(() => {
                        a.toast.show = !1;
                    }, 5e3),
                    (a.editMode = !1),
                    "general" == e &&
                        ((t.text.heading.thumb = "heading.png"),
                        (t.text.body.thumb = "body.png"),
                        (t.text.arc.thumb = "arc.png"),
                        (t.text.reversearc.thumb = "reversearc.png"),
                        (a.general = t)),
                    ("text" != e && "shape" != e && "filter" != e && "font" != e) ||
                        ((a.settings[e] = t),
                        "text" == e && (a.listTexts = JSON.parse(JSON.stringify(a.settings[e]))),
                        "shape" == e && (a.listShapes = JSON.parse(JSON.stringify(a.settings[e]))),
                        "filter" == e && (a.listFilters = JSON.parse(JSON.stringify(a.settings[e]))),
                        "font" == e && (a.listFonts = JSON.parse(JSON.stringify(a.settings[e]))),
                        (a.modal.show = !1));
            } catch (t) {
                return (
                    (a.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        a.toast.show = !1;
                    }, 5e3),
                    (a.loading = !1),
                    !1
                );
            }
            a.loading = !1;
        },
        editTextDefault() {
            let t = this,
                e = JSON.parse(JSON.stringify(t.general.text.heading)),
                a = JSON.parse(JSON.stringify(t.general.text.body)),
                o = JSON.parse(JSON.stringify(t.general.text.arc)),
                p = JSON.parse(JSON.stringify(t.general.text.reversearc));
            (t.modal = {
                show: !0,
                header: !0,
                size: "md",
                title: t.langs.setting.edit_text_default,
                type: "textDefault",
                arcText: [],
                reversearcText: [],
                heading: e,
                body: a,
                arc: o,
                reversearc: p,
                dropdown: "",
                findFont: "",
                fontCate: "",
                render: !1,
            }),
                setTimeout(() => {
                    t.changeFontDefault(t.modal.heading.fontFamily, "create");
                }, 1);
        },
        async changeFontDefault(t, e) {
            let a = this;
            if (((a.modal.dropdown = ""), (a.modal.render = !0), void 0 === a.fontFaces[t])) {
                let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-load-font&admin=1&pdapp-nonce=" + pdappNonce;
                try {
                    let o = await pdappAPI.tool.postData(e, { title: t });
                    (a.fontFaces[t] = o.data.fontface), pdappAPI.tool.loadFontFace(o.data.fontface);
                } catch (t) {
                    (a.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            toast.toast.show = !1;
                        }, 5e3);
                }
            }
            if (void 0 !== a.fontFaces[t]) {
                let e = jQuery("#text_heading_preview"),
                    o = jQuery("#text_body_preview"),
                    p = jQuery("#text_arc_preview"),
                    i = jQuery("#text_reversearc_preview");
                e.find("style").remove(), o.find("style").remove(), p.find("style").remove(), i.find("style").remove();
                let d = "<style>" + a.fontFaces[t] + "</style>";
                e.prepend(d), o.prepend(d), p.prepend(d), i.prepend(d);
            }
            (a.modal.heading.fontFamily = t),
                (a.modal.body.fontFamily = t),
                (a.modal.arc.fontFamily = t),
                (a.modal.reversearc.fontFamily = t),
                setTimeout(() => {
                    void 0 !== e && "create" == e
                        ? (pdappAPI.arc.create("pdapp-edit-text-arc", a.modal.arc, function (t) {
                              (a.modal.arcText = t),
                                  setTimeout(() => {
                                      pdappAPI.tool.responsiveSvgText(jQuery("#text_arc_preview")),
                                          setTimeout(() => {
                                              a.updateThumbDefault("arc", 80);
                                          }, 10);
                                  }, 10);
                          }),
                          pdappAPI.arc.create("pdapp-edit-text-reversearc", a.modal.reversearc, function (t) {
                              (a.modal.reversearcText = t),
                                  setTimeout(() => {
                                      pdappAPI.tool.responsiveSvgText(jQuery("#text_reversearc_preview")),
                                          setTimeout(() => {
                                              a.updateThumbDefault("reversearc", 80);
                                          }, 10);
                                  }, 10);
                          }),
                          a.updateTextDefault("heading"),
                          a.updateTextDefault("body"))
                        : (a.updateTextDefault("arc"),
                          a.updateTextDefault("reversearc"),
                          a.updateTextDefault("heading"),
                          a.updateTextDefault("body"));
                }, 100);
        },
        updateAllDefault(t) {
            let e = this;
            "size" == t
                ? ((e.modal.body.fontSize = e.modal.heading.fontSize),
                  (e.modal.arc.fontSize = e.modal.heading.fontSize),
                  (e.modal.reversearc.fontSize = e.modal.heading.fontSize))
                : ((e.modal.body.color = e.modal.heading.color),
                  (e.modal.arc.color = e.modal.heading.color),
                  (e.modal.reversearc.color = e.modal.heading.color),
                  (e.modal.heading.stroke = e.modal.heading.color),
                  (e.modal.body.stroke = e.modal.heading.color),
                  (e.modal.arc.stroke = e.modal.heading.color),
                  (e.modal.reversearc.stroke = e.modal.heading.color)),
                e.updateTextDefault("arc"),
                e.updateTextDefault("reversearc"),
                e.updateTextDefault("heading"),
                e.updateTextDefault("body");
        },
        updateTextDefault(t) {
            let e = this;
            if (((e.modal.render = !0), "arc" == t || "reversearc" == t))
                (pdappAPI.arc.pdappCircleType = null),
                    pdappAPI.arc.update("pdapp-edit-text-" + t, e.modal[t], function (a) {
                        "arc" == t ? (e.modal.arcText = a) : (e.modal.reversearcText = a),
                            setTimeout(() => {
                                pdappAPI.tool.responsiveSvgText(jQuery("#text_" + t + "_preview")),
                                    setTimeout(() => {
                                        e.updateThumbDefault(t, 80);
                                    }, 100);
                            }, 10);
                    });
            else {
                let a = jQuery("#text_" + t + "_preview"),
                    o = a.find(".pdapp-target")[0].getBoundingClientRect();
                a.attr("width", (o.width + e.modal[t].fontSize / 2).toFixed(3) + "px"),
                    a.attr("height", (o.height + e.modal[t].fontSize / 2).toFixed(3) + "px"),
                    setTimeout(() => {
                        e.updateThumbDefault(t, 30);
                    }, 1);
            }
        },
        updateThumbDefault(t, e) {
            let a = this;
            a.modal.render = !0;
            let o = jQuery("#text_" + t + "_preview");
            pdappAPI.tool.textThumb(o, e, function (e) {
                (a.modal[t].thumb = e), (a.modal.render = !1);
            });
        },
        saveTextDefault() {
            (this.general.text.heading = this.modal.heading),
                (this.general.text.body = this.modal.body),
                (this.general.text.arc = this.modal.arc),
                (this.general.text.reversearc = this.modal.reversearc),
                (this.modal.show = !1);
        },
        addNewText(t) {
            let e = this;
            if (0 == e.settings.font.length)
                return (e.modal = { show: !0, header: !1, size: "md", title: "", type: "fontWarning" }), !1;
            let a = "normal" == t ? e.langs.setting.add_text_normal : e.langs.setting.add_text_arc,
                o = {
                    text: "Add Your Text",
                    color: "#000000",
                    fontSize: 50,
                    fontFamily: e.settings.font[0].title,
                    stroke: "#000000",
                    strokeWidth: 0,
                    fontWeight: "normal",
                    fontStyle: "normal",
                    textDecoration: "none",
                    letterSpacing: 0,
                    textTransform: "none",
                };
            "arc" == t && (o.arc = { radius: 384, dir: 1 }),
                (e.modal = {
                    show: !0,
                    header: !0,
                    size: "md",
                    title: a,
                    type: "text",
                    textType: t,
                    arcText: [],
                    arcDir: !1,
                    data: o,
                    thumb: "",
                    dropdown: "",
                    findFont: "",
                    fontCate: "",
                    render: !1,
                }),
                setTimeout(() => {
                    e.changeFont(o.fontFamily, t);
                }, 1);
        },
        async changeFont(t, e) {
            let a = this;
            if (((a.modal.dropdown = ""), (a.modal.render = !0), void 0 === a.fontFaces[t])) {
                let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-load-font&admin=1&pdapp-nonce=" + pdappNonce;
                try {
                    let o = await pdappAPI.tool.postData(e, { title: t });
                    (a.fontFaces[t] = o.data.fontface), pdappAPI.tool.loadFontFace(o.data.fontface);
                } catch (t) {
                    (a.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            toast.toast.show = !1;
                        }, 5e3);
                }
            }
            if (void 0 !== a.fontFaces[t]) {
                let e = jQuery("#text_thumb_preview");
                e.find("style").remove();
                let o = "<style>" + a.fontFaces[t] + "</style>";
                e.prepend(o);
            }
            (a.modal.data.fontFamily = t),
                setTimeout(() => {
                    void 0 !== e && "arc" == e
                        ? ((pdappAPI.arc.pdappCircleType = null),
                          pdappAPI.arc.create("pdapp-text-library-arc", a.modal.data, function (t) {
                              (a.modal.arcText = t),
                                  setTimeout(() => {
                                      pdappAPI.tool.responsiveSvgText(jQuery("#text_thumb_preview")),
                                          setTimeout(() => {
                                              a.updateThumb();
                                          }, 10);
                                  }, 10);
                          }))
                        : a.updateText();
                }, 100);
        },
        textFormat(t) {
            let e = this,
                a = !1;
            if (
                ("700" == t && (e.modal.data.fontWeight = e.modal.data.fontWeight == t ? "normal" : t),
                "italic" == t && (e.modal.data.fontStyle = e.modal.data.fontStyle == t ? "normal" : t),
                "underline" == t && (e.modal.data.textDecoration = e.modal.data.textDecoration == t ? "none" : t),
                "line-through" == t &&
                    ((a = !0), (e.modal.data.textDecoration = e.modal.data.textDecoration == t ? "none" : t)),
                "uppercase" == t)
            )
                return (
                    (e.modal.data.textTransform = e.modal.data.textTransform == t ? "none" : t),
                    setTimeout(() => {
                        e.updateText(a);
                    }, 1),
                    !1
                );
            e.updateText(a);
        },
        updateText(t) {
            let e = this;
            if (((e.modal.render = !0), "arc" == e.modal.textType)) {
                if (void 0 !== t && 1 == t)
                    return (
                        pdappAPI.tool.responsiveSvgText(jQuery("#text_thumb_preview")),
                        setTimeout(() => {
                            e.updateThumb();
                        }, 1),
                        !1
                    );
                void 0 !== t && "render" == t && (pdappAPI.arc.pdappCircleType = null),
                    (e.modal.data.arc.dir = e.modal.arcDir ? -1 : 1),
                    pdappAPI.arc.update("pdapp-text-library-arc", e.modal.data, function (t) {
                        (e.modal.arcText = t),
                            setTimeout(() => {
                                pdappAPI.tool.responsiveSvgText(jQuery("#text_thumb_preview")),
                                    setTimeout(() => {
                                        e.updateThumb();
                                    }, 10);
                            }, 10);
                    });
            } else {
                let t = jQuery("#text_thumb_preview .pdapp-target")[0].getBoundingClientRect();
                jQuery("#text_thumb_preview").attr("width", (t.width + e.modal.data.fontSize / 2).toFixed(3) + "px"),
                    jQuery("#text_thumb_preview").attr(
                        "height",
                        (t.height + e.modal.data.fontSize / 2).toFixed(3) + "px"
                    ),
                    setTimeout(() => {
                        e.updateThumb();
                    }, 1);
            }
        },
        updateThumb() {
            let t = this,
                e = "arc" == t.modal.textType ? 80 : 25;
            pdappAPI.tool.textThumb(jQuery("#text_thumb_preview"), e, function (e) {
                (t.modal.thumb = e), (t.modal.render = !1);
            });
        },
        textOptionDropdown(t) {
            this.modal.dropdown = this.modal.dropdown == t ? "" : t;
        },
        async saveNewText() {
            let t = this;
            t.loading = "text";
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-add-new-text&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = new Blob([JSON.stringify({ text: JSON.stringify(t.modal.data), thumb: t.modal.thumb })], {
                        type: "application/json",
                    }),
                    o = new FormData();
                o.append("text", a, "text.json");
                let p = await pdappAPI.tool.uploadData(e, o);
                t.settings.text.push(p.data),
                    (t.listTexts = JSON.parse(JSON.stringify(t.settings.text))),
                    (t.modal.show = !1),
                    (t.toast = { show: !0, type: "success", text: p.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.loading = !1;
        },
        saveUpdateText() {
            this.updateSettings(this.listTexts, "text");
        },
        exportText() {
            let t = this,
                e = t.modal.data.fontFamily;
            if (void 0 !== t.fontFaces[e]) {
                let a = t.fontFaces[e],
                    o = a.substring(a.indexOf("url(") + 4, a.indexOf(") format")),
                    p = { type: "textdesign", text: t.modal.data, font: { name: e, data: o }, thumb: t.modal.thumb },
                    i = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(p)),
                    d = document.createElement("a");
                (d.href = i),
                    (d.download = t.modal.data.text + ".json"),
                    document.body.appendChild(d),
                    d.click(),
                    delete d;
            } else
                (t.toast = { show: !0, type: "warning", text: t.langs.msg.export_error }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
        },
        addNewFont(t) {
            let e = this,
                a = "list" == t ? "full-width modal-dialog-scrollable" : "md modal-dialog-scrollable",
                o = "list" == t ? e.langs.setting.add_from_library : e.langs.setting.upload_font;
            (e.modal = { show: !0, header: !0, size: a, title: o, type: t }),
                (e.editMode = !1),
                (e.selectAll = !1),
                (e.selectAlls = []),
                (e.listUploads = []),
                (e.renderedThumb = !1);
        },
        changeFiles(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files;
            for (let t = 0; t < a.length; t++) {
                let o = a[t];
                "ttf" == o.name.substr(o.name.lastIndexOf(".") + 1).toLowerCase() && e.listUploads.push(o);
            }
            e.listUploads.length && e.uploadFont();
        },
        async uploadFont(t, e, a) {
            let o = this;
            if (0 == o.listUploads.length) return !1;
            if (void 0 === t && ((t = 0), (a = []), (e = []), o.fontLibrary.length))
                for (let t = 0; t < o.listFonts.length; t++) e.push(o.listFonts[t].title);
            let p = new FormData();
            if (void 0 !== o.listUploads[t]) {
                p.append("file", o.listUploads[t]);
                let i =
                    pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-font-file&admin=1&pdapp-nonce=" + pdappNonce;
                try {
                    let d = await pdappAPI.tool.uploadData(i, p);
                    void 0 === o.fontFaces[d.data.font.title] && (o.fontFaces[d.data.font.title] = d.data.fontface);
                    let s = !1;
                    if ((e.includes(d.data.font.title) || (a.push(d.data.font), e.push(d.data.font), (s = !0)), !s))
                        return (
                            (o.toast = { show: !0, type: "warning", text: o.langs.msg.upload_font_exists }),
                            setTimeout(() => {
                                o.toast.show = !1;
                            }, 5e3),
                            (o.modal.show = !1),
                            setTimeout(() => {
                                o.uploadFont(t + 1, e, a);
                            }, 200),
                            !1
                        );
                    pdappAPI.tool.loadFontFace(d.data.fontface, function () {
                        pdappAPI.tool.genFontThumb(d.data.font, function (t, e) {
                            o.updateFont(t, e), (o.renderedThumb = !0);
                        });
                    });
                } catch (t) {
                    (o.toast = { show: !0, type: "warning", text: t.msg }),
                        setTimeout(() => {
                            o.toast.show = !1;
                        }, 5e3);
                }
                return (
                    setTimeout(() => {
                        o.uploadFont(t + 1, e, a);
                    }, 200),
                    !1
                );
            }
            o.toast.show ||
                ((o.toast = { show: !0, type: "success", text: o.langs.msg.uploaded }),
                setTimeout(() => {
                    o.toast.show = !1;
                }, 5e3)),
                (o.listUploads = a);
        },
        async updateFont(t, e) {
            let a = this,
                o = pdappAdminUrl + "admin-ajax.php?action=pdapp-update-font&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let p = new Blob([JSON.stringify({ font: JSON.stringify(t), thumb: e })], { type: "application/json" }),
                    i = new FormData();
                i.append("font", p, "font.json"), await pdappAPI.tool.uploadData(o, i), a.fontLibrary.push(t);
            } catch (t) {}
        },
        saveToList(t) {
            let e = this,
                a = JSON.parse(JSON.stringify(e.listFonts));
            if ("list" == t)
                for (let t = 0; t < e.fontLibrary.length; t++) {
                    let o = e.fontLibrary[t].title;
                    e.selectAlls.includes(o) && a.push(e.fontLibrary[t]);
                }
            else for (let t = 0; t < e.listUploads.length; t++) a.push(e.listUploads[t]);
            e.updateSettings(a, "font");
        },
        saveUpdateFont() {
            this.updateSettings(this.listFonts, "font");
        },
        saveUpdateShape() {
            this.updateSettings(this.listShapes, "shape");
        },
        saveUpdateFilter() {
            this.updateSettings(this.listFilters, "filter");
        },
        async openLang(t) {
            let e = this;
            e.loadingPage = !0;
            let a =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-load-setting&translateTo=" +
                t +
                "&admin=1&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(a);
                (e.translate = t),
                    (e.translateLang = o.data),
                    (e.oldLangs = JSON.parse(JSON.stringify(o.data))),
                    (e.translateFile = "admin");
            } catch (t) {}
            e.loadingPage = !1;
        },
        async saveTranslate() {
            let t = this;
            t.loadingPage = !0;
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-save-translate&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = new Blob(
                        [
                            JSON.stringify({
                                file: t.translateFile,
                                code: t.translate,
                                data: JSON.stringify(t.transLang),
                            }),
                        ],
                        { type: "application/json" }
                    ),
                    o = new FormData();
                o.append("translate", a, "translate.json");
                let p = await pdappAPI.tool.uploadData(e, o);
                (t.toast = { show: !0, type: "success", text: p.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3),
                    (t.oldLangs[t.translateFile] = JSON.parse(JSON.stringify(t.transLang)));
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.loadingPage = !1;
        },
        async removeCache(t) {
            let e = this;
            e.loading = t;
            let a = pdappAdminUrl + "admin-ajax.php?action=pdapp-remove-cache&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let o = await pdappAPI.tool.postData(a, { type: t });
                (e.toast = { show: !0, type: "success", text: o.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            } catch (t) {
                (e.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            }
            e.loading = !1;
        },
        verifyPurchased() {
            "" != this.modal.purchased &&
                ((this.modal.verifing = !0),
                postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                    purchased: this.modal.purchased,
                    domain: pdappDomain,
                }));
        },
        showVerifyModal() {
            this.modal = {
                show: !0,
                type: "verifycode",
                purchased: this.pdappPurchasedCode,
                error: "",
                checked: !0,
                verifing: !1,
            };
        },
        async updatePurchased(t) {
            let e = this,
                a = pdappAdminUrl + "admin-ajax.php?action=pdapp-dashboard-purchased&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                await pdappAPI.tool.postData(a, { purchased: e.modal.purchased });
                (e.pdappPurchasedCode = e.modal.purchased), e.checkAuthCode(t.data);
            } catch (t) {
                (e.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            }
        },
        checkAuthCode(t) {
            let e = this;
            void 0 !== t.refreshToken &&
                "" != t.refreshToken &&
                ((e.pdappApiToken = t.refreshToken), pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken)),
                "shop" == t.scope
                    ? ((e.modal.show = !1),
                      e.showStore ||
                          ((e.showStore = !0),
                          "text" == e.storeType
                              ? e.showTextStore()
                              : "font" == e.storeType
                                ? e.showFontStore()
                                : "shape" == e.storeType
                                  ? e.showShapeStore()
                                  : "filter" == e.storeType && e.showFilterStore()))
                    : "confirm" == t.scope
                      ? ((e.modal = {
                            show: !0,
                            type: "confirmemail",
                            code: t.code,
                            email: t.email,
                            verifing: !1,
                            error: "",
                            scope: t.scope,
                        }),
                        (e.confirmEmail.timeLess = parseInt(t.time)),
                        e.countDown())
                      : ("verify" != t.scope && "code" != t.scope) ||
                        (e.modal = {
                            show: !0,
                            type: "verifyemail",
                            code: t.code,
                            email: t.email,
                            verifing: !1,
                            error: "",
                            scope: t.scope,
                        });
        },
        codeValidate() {
            let t = this.confirmEmail.code.toString();
            t.length > 6 && (t = t.substring(0, 6)), (this.confirmEmail.code = parseInt(t));
        },
        expireConfirmCode(t) {
            let e = this;
            t && ((e.pdappApiToken = ""), pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken)),
                (e.modal.show = !1);
        },
        countDown() {
            let t = this;
            0 == t.confirmEmail.timeLess && t.expireConfirmCode(!0),
                (t.confirmEmail.timeLess = t.confirmEmail.timeLess - 1),
                t.confirmEmail.timeLess > 0 &&
                    setTimeout(() => {
                        t.countDown();
                    }, 1e3);
        },
        refreshCode() {
            postToChild(document.getElementById("pdapp-login-frame"), "refreshemail", { token: this.pdappApiToken });
        },
        confirmEmailCode() {
            let t = this;
            (t.confirmEmail.verifing = !0),
                postToChild(document.getElementById("pdapp-login-frame"), "confirmemail", {
                    emailcode: t.confirmEmail.code,
                    token: t.pdappApiToken,
                });
        },
        verifyEmail() {
            let t = this;
            return "" == t.modal.email
                ? ((t.modal.error = "A email is required."), !1)
                : /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
                        String(t.modal.email).toLowerCase()
                    )
                  ? ((t.modal.error = ""),
                    (t.modal.verifing = !0),
                    void postToChild(document.getElementById("pdapp-login-frame"), "verifyemail", {
                        email: t.modal.email,
                        token: t.pdappApiToken,
                    }))
                  : ((t.modal.error = "A email is invalid."), !1);
        },
        onAuthCode(t) {
            let e = this;
            if (0 == t.error)
                return (
                    void 0 !== e.modal.type && "verifycode" == e.modal.type
                        ? void 0 !== t.data && void 0 !== t.data.platform && t.data.platform == pdappPlatform
                            ? e.updatePurchased(t)
                            : ((e.modal.error = "Your platform verify incorrect"), (e.modal.verifing = !1))
                        : e.checkAuthCode(t.data),
                    !1
                );
            void 0 !== e.modal.type && "verifycode" == e.modal.type
                ? ((e.modal.error = t.msg), (e.modal.verifing = !1))
                : "" != e.pdappApiToken && "" != e.pdappPurchasedCode
                  ? ((e.pdappApiToken = ""),
                    pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                    postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                        purchased: e.pdappPurchasedCode,
                        domain: pdappDomain,
                    }))
                  : (e.modal = {
                        show: !0,
                        type: "verifycode",
                        purchased: e.pdappPurchasedCode,
                        error: "",
                        checked: !1,
                        verifing: !1,
                    });
        },
        onAuthEmail(t) {
            let e = this;
            if (((e.modal.verifing = !1), 0 == t.error))
                return (
                    (e.modal.show = !0),
                    (e.modal.email = t.data.email),
                    (e.modal.code = t.data.code),
                    (e.modal.scope = t.data.scope),
                    (e.pdappApiToken = t.data.refreshToken),
                    pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                    (e.confirmEmail.timeLess = parseInt(t.data.time)),
                    e.countDown(),
                    (e.modal.type = "confirmemail"),
                    !1
                );
            e.modal.error = t.msg;
        },
        onAuthRefreshEmail(t) {
            let e = this;
            (e.confirmEmail.refresh = !1),
                0 == t.error
                    ? ((e.pdappApiToken = t.data.refreshToken),
                      pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                      (e.confirmEmail.timeLess = parseInt(t.data.time)))
                    : (e.confirmEmail.error = t.msg);
        },
        onAuthConfirmEmail(t) {
            let e = this;
            0 == t.error
                ? ((e.modal.email = t.data.email),
                  (e.modal.code = t.data.code),
                  (e.modal.scope = t.data.scope),
                  (e.confirmEmail.timeLess = -1),
                  e.expireConfirmCode(!1),
                  (e.pdappApiToken = t.data.refreshToken),
                  pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                  (e.confirmEmail.timeLess = parseInt(t.data.time)))
                : (e.confirmEmail.error = t.msg),
                (e.confirmEmail.verifing = !1);
        },
        showTextStore() {
            let t = this;
            (t.storeType = "text"),
                "" != t.pdappPurchasedCode
                    ? t.showStore
                        ? ((t.modal = { store: !0 }),
                          "" != t.pdappApiToken &&
                              postToChild(
                                  document.getElementById("pdapp-resource-frame"),
                                  "starttext",
                                  t.pdappApiToken
                              ),
                          (t.loadingStore = !1))
                        : ((t.pdappApiToken = pdappAPI.tool.getLocalVar("pdapp_api_token", "")),
                          "" != t.pdappApiToken && "" != t.pdappApiToken
                              ? postToChild(
                                    document.getElementById("pdapp-login-frame"),
                                    "verifytoken",
                                    t.pdappApiToken
                                )
                              : postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                                    purchased: t.pdappPurchasedCode,
                                    domain: pdappDomain,
                                }),
                          (t.loadingStore = !0),
                          setTimeout(() => {
                              t.loadingStore = !1;
                          }, 1500))
                    : t.showVerifyModal();
        },
        uploadText(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files;
            for (let t = 0; t < a.length; t++) {
                let o = a[t];
                "json" == o.name.substr(o.name.lastIndexOf(".") + 1).toLowerCase() &&
                    loadTextJson(o, function (t, a) {
                        t && ((a.uploaded = 0), (a.error = ""), e.uploadTexts.push(a));
                    });
            }
            e.modal = {
                show: !0,
                type: "uploadText",
                size: "lg",
                header: !0,
                title: e.langs.setting.upload,
                saving: !1,
            };
        },
        uploadTextFile() {
            let t = this;
            for (let e = 0; e < t.uploadTexts.length; e++)
                if (0 == t.uploadTexts[e].uploaded && "" == t.uploadTexts[e].error)
                    return t.startUpload(t.uploadTexts[e], "upload", e), !1;
        },
        onImportText(t) {
            if (void 0 === t.id || void 0 === t.data) return !1;
            let e = t.data.split("base64,");
            if (void 0 === e[1]) return !1;
            let a = JSON.parse(pdappAPI.tool.decodeBase64(e[1]));
            this.startUpload(a, "import", t.id);
        },
        async startUpload(t, e, a) {
            let o = this;
            (o.loading = "uploadtext"), (t.font = JSON.stringify(t.font)), (t.text = JSON.stringify(t.text));
            let p = pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-text&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let i = new Blob([JSON.stringify(t)], { type: "application/json" }),
                    d = new FormData();
                d.append("text", i, "text.json");
                let s = await pdappAPI.tool.uploadData(p, d);
                "upload" == e
                    ? void 0 !== o.uploadTexts[a] && 0 == o.uploadTexts[a].uploaded && (o.uploadTexts[a].uploaded = 100)
                    : postToChild(document.getElementById("pdapp-resource-frame"), "addedtext", a),
                    o.listTexts.push(s.data);
            } catch (t) {
                "import" == e
                    ? ((o.toast = { show: !0, type: "warning", text: t.msg }),
                      setTimeout(() => {
                          o.toast.show = !1;
                      }, 5e3))
                    : void 0 !== o.uploadTexts[a] && 0 == o.uploadTexts[a].error && (o.uploadTexts[a].error = t.msg);
            }
            "upload" == e &&
                setTimeout(() => {
                    o.uploadTextFile();
                }, 100),
                (o.loading = !1);
        },
        showFontStore() {
            let t = this;
            (t.storeType = "font"),
                "" != t.pdappPurchasedCode
                    ? t.showStore
                        ? ((t.modal = { store: !0 }),
                          "" != t.pdappApiToken &&
                              postToChild(
                                  document.getElementById("pdapp-resource-frame"),
                                  "startfont",
                                  t.pdappApiToken
                              ),
                          (t.loadingStore = !1))
                        : ((t.pdappApiToken = pdappAPI.tool.getLocalVar("pdapp_api_token", "")),
                          "" != t.pdappApiToken && "" != t.pdappApiToken
                              ? postToChild(
                                    document.getElementById("pdapp-login-frame"),
                                    "verifytoken",
                                    t.pdappApiToken
                                )
                              : postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                                    purchased: t.pdappPurchasedCode,
                                    domain: pdappDomain,
                                }),
                          (t.loadingStore = !0),
                          setTimeout(() => {
                              t.loadingStore = !1;
                          }, 1500))
                    : t.showVerifyModal();
        },
        onImportFont(t) {
            if (void 0 === t.id || void 0 === t.data) return !1;
            this.startUploadFont(t.data, t.id);
        },
        async startUploadFont(t, e) {
            let a = this;
            t.font = JSON.stringify(t.font);
            let o = pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-font&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let p = new Blob([JSON.stringify(t)], { type: "application/json" }),
                    i = new FormData();
                i.append("font", p, "font.json");
                let d = await pdappAPI.tool.uploadData(o, i);
                "function" == typeof e
                    ? e(d.data)
                    : (postToChild(document.getElementById("pdapp-resource-frame"), "addedfont", e),
                      void 0 !== d.data.title && (a.listFonts.push(d.data), a.updateSettings(a.listFonts, "font")));
            } catch (t) {
                (a.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        a.toast.show = !1;
                    }, 5e3);
            }
        },
        changeFontJsons(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            let a = 0,
                o = [];
            const p = t.target.files;
            for (let t = 0; t < p.length; t++) {
                let i = p[t];
                "json" == i.name.substr(i.name.lastIndexOf(".") + 1).toLowerCase() &&
                    loadFontJson(i, function (t, p) {
                        if (t) {
                            e.listUploads.push(i);
                            let t = e.listUploads.length - 1;
                            e.startUploadFont(p, function (p) {
                                void 0 !== e.listUploads[t] && (e.listUploads[t] = p),
                                    a++,
                                    void 0 !== p.title && o.push(p),
                                    e.listUploads.length == a &&
                                        ((e.renderedThumb = !0),
                                        (e.listUploads = o),
                                        0 == o.length &&
                                            ((e.toast = {
                                                show: !0,
                                                type: "warning",
                                                text: e.langs.msg.upload_font_exists,
                                            }),
                                            setTimeout(() => {
                                                e.toast.show = !1;
                                            }, 5e3),
                                            (e.modal.show = !1)));
                            });
                        }
                    });
            }
        },
        showShapeStore() {
            let t = this;
            (t.storeType = "shape"),
                "" != t.pdappPurchasedCode
                    ? t.showStore
                        ? ((t.modal = { store: !0 }),
                          "" != t.pdappApiToken &&
                              postToChild(
                                  document.getElementById("pdapp-resource-frame"),
                                  "startshape",
                                  t.pdappApiToken
                              ),
                          (t.loadingStore = !1))
                        : ((t.pdappApiToken = pdappAPI.tool.getLocalVar("pdapp_api_token", "")),
                          "" != t.pdappApiToken && "" != t.pdappApiToken
                              ? postToChild(
                                    document.getElementById("pdapp-login-frame"),
                                    "verifytoken",
                                    t.pdappApiToken
                                )
                              : postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                                    purchased: t.pdappPurchasedCode,
                                    domain: pdappDomain,
                                }),
                          (t.loadingStore = !0),
                          setTimeout(() => {
                              t.loadingStore = !1;
                          }, 1500))
                    : t.showVerifyModal();
        },
        uploadShape(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files;
            for (let t = 0; t < a.length; t++) {
                let o = a[t];
                "json" == o.name.substr(o.name.lastIndexOf(".") + 1).toLowerCase() &&
                    loadShapeJson(o, function (t, a) {
                        t && ((a.uploaded = 0), (a.error = ""), e.uploadShapes.push(a));
                    });
            }
            e.modal = {
                show: !0,
                type: "uploadShape",
                size: "lg",
                header: !0,
                title: e.langs.setting.upload,
                saving: !1,
            };
        },
        uploadShapeFile() {
            let t = this;
            for (let e = 0; e < t.uploadShapes.length; e++)
                if (0 == t.uploadShapes[e].uploaded && "" == t.uploadShapes[e].error)
                    return t.startUploadShape(t.uploadShapes[e], "upload", e), !1;
        },
        onImportShape(t) {
            if (void 0 === t.id || void 0 === t.data) return !1;
            let e = t.data.split("base64,");
            if (void 0 === e[1]) return !1;
            let a = JSON.parse(pdappAPI.tool.decodeBase64(e[1]));
            this.startUploadShape(a, "import", t.id);
        },
        async startUploadShape(t, e, a) {
            let o = this;
            (o.loading = "uploadshape"), (t.value = JSON.stringify(t.value));
            let p = pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-shape&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let i = new Blob([JSON.stringify(t)], { type: "application/json" }),
                    d = new FormData();
                d.append("shape", i, "shape.json");
                let s = await pdappAPI.tool.uploadData(p, d);
                "upload" == e
                    ? void 0 !== o.uploadShapes[a] &&
                      0 == o.uploadShapes[a].uploaded &&
                      (o.uploadShapes[a].uploaded = 100)
                    : postToChild(document.getElementById("pdapp-resource-frame"), "addedshape", a),
                    o.listShapes.push(s.data);
            } catch (t) {
                "import" == e
                    ? ((o.toast = { show: !0, type: "warning", text: t.msg }),
                      setTimeout(() => {
                          o.toast.show = !1;
                      }, 5e3))
                    : void 0 !== o.uploadShapes[a] && 0 == o.uploadShapes[a].error && (o.uploadShapes[a].error = t.msg);
            }
            "upload" == e &&
                setTimeout(() => {
                    o.uploadShapeFile();
                }, 100),
                (o.loading = !1);
        },
        showFilterStore() {
            let t = this;
            (t.storeType = "filter"),
                "" != t.pdappPurchasedCode
                    ? t.showStore
                        ? ((t.modal = { store: !0 }),
                          "" != t.pdappApiToken &&
                              postToChild(
                                  document.getElementById("pdapp-resource-frame"),
                                  "startfilter",
                                  t.pdappApiToken
                              ),
                          (t.loadingStore = !1))
                        : ((t.pdappApiToken = pdappAPI.tool.getLocalVar("pdapp_api_token", "")),
                          "" != t.pdappApiToken && "" != t.pdappApiToken
                              ? postToChild(
                                    document.getElementById("pdapp-login-frame"),
                                    "verifytoken",
                                    t.pdappApiToken
                                )
                              : postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                                    purchased: t.pdappPurchasedCode,
                                    domain: pdappDomain,
                                }),
                          (t.loadingStore = !0),
                          setTimeout(() => {
                              t.loadingStore = !1;
                          }, 1500))
                    : t.showVerifyModal();
        },
        uploadFilter(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files;
            for (let t = 0; t < a.length; t++) {
                let o = a[t];
                "json" == o.name.substr(o.name.lastIndexOf(".") + 1).toLowerCase() &&
                    loadFilterJson(o, function (t, a) {
                        t && ((a.uploaded = 0), (a.error = ""), e.uploadFilters.push(a));
                    });
            }
            e.modal = {
                show: !0,
                type: "uploadFilter",
                size: "lg",
                header: !0,
                title: e.langs.setting.upload,
                saving: !1,
            };
        },
        uploadFilterFile() {
            let t = this;
            for (let e = 0; e < t.uploadFilters.length; e++)
                if (0 == t.uploadFilters[e].uploaded && "" == t.uploadFilters[e].error)
                    return t.startUploadFilter(t.uploadFilters[e], "upload", e), !1;
        },
        onImportFilter(t) {
            if (void 0 === t.id || void 0 === t.data) return !1;
            let e = t.data.split("base64,");
            if (void 0 === e[1]) return !1;
            let a = JSON.parse(pdappAPI.tool.decodeBase64(e[1]));
            this.startUploadFilter(a, "import", t.id);
        },
        async startUploadFilter(t, e, a) {
            let o = this;
            o.loading = "uploadfilter";
            let p = pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-filter&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let i = new Blob([JSON.stringify(t)], { type: "application/json" }),
                    d = new FormData();
                d.append("filter", i, "filter.json");
                let s = await pdappAPI.tool.uploadData(p, d);
                "upload" == e
                    ? void 0 !== o.uploadFilters[a] &&
                      0 == o.uploadFilters[a].uploaded &&
                      (o.uploadFilters[a].uploaded = 100)
                    : postToChild(document.getElementById("pdapp-resource-frame"), "addedfilter", a),
                    o.listFilters.push(s.data);
            } catch (t) {
                "import" == e
                    ? ((o.toast = { show: !0, type: "warning", text: t.msg }),
                      setTimeout(() => {
                          o.toast.show = !1;
                      }, 5e3))
                    : void 0 !== o.uploadFilters[a] &&
                      0 == o.uploadFilters[a].error &&
                      (o.uploadFilters[a].error = t.msg);
            }
            "upload" == e &&
                setTimeout(() => {
                    o.uploadFilterFile();
                }, 100),
                (o.loading = !1);
        },
    },
}).mount("#productdesignerapp-app");
function loadTextJson(t, e) {
    const a = new FileReader();
    (a.onload = () => {
        let t = a.result.split("base64,");
        if (void 0 === t[1]) return !1;
        let o = JSON.parse(pdappAPI.tool.decodeBase64(t[1])),
            p = void 0 !== o.type && "textdesign" == o.type;
        "function" == typeof e && e(p, o);
    }),
        a.readAsDataURL(t);
}
function loadShapeJson(t, e) {
    const a = new FileReader();
    (a.onload = () => {
        let t = a.result.split("base64,");
        if (void 0 === t[1]) return !1;
        let o = JSON.parse(pdappAPI.tool.decodeBase64(t[1])),
            p = void 0 !== o.type && "path" == o.type;
        "function" == typeof e && e(p, o);
    }),
        a.readAsDataURL(t);
}
function loadFilterJson(t, e) {
    const a = new FileReader();
    (a.onload = () => {
        let t = a.result.split("base64,");
        if (void 0 === t[1]) return !1;
        let o = JSON.parse(pdappAPI.tool.decodeBase64(t[1])),
            p = void 0 !== o.type && "filter" == o.type;
        void 0 === o.value && (p = !1), "function" == typeof e && e(p, o);
    }),
        a.readAsDataURL(t);
}
function loadFontJson(t, e) {
    const a = new FileReader();
    (a.onload = () => {
        let t = a.result.split("base64,");
        if (void 0 === t[1]) return !1;
        let o = JSON.parse(pdappAPI.tool.decodeBase64(t[1])),
            p = void 0 !== o.font && void 0 !== o.font.type && "google" == o.font.type;
        void 0 === o.thumb && (p = !1), "function" == typeof e && e(p, o);
    }),
        a.readAsDataURL(t);
}
function postToChild(t, e, a) {
    t.contentWindow.postMessage({ type: e, data: a }, pdappHomeUrl);
}
window.onmessage = function (t) {
    if (void 0 !== t.data.type) {
        let e = t.data.type,
            a = t.data.data;
        "loadedstore" == e && "ok" == a && (pdappVueApp.loadedStore = !0),
            "importtext" == e && pdappVueApp.onImportText(a),
            "importshape" == e && pdappVueApp.onImportShape(a),
            "importfilter" == e && pdappVueApp.onImportFilter(a),
            "importfont" == e && pdappVueApp.onImportFont(a),
            "authcode" == e && pdappVueApp.onAuthCode(a),
            "authemail" == e && pdappVueApp.onAuthEmail(a),
            "authrefreshemail" == e && pdappVueApp.onAuthRefreshEmail(a),
            "authconfirmemail" == e && pdappVueApp.onAuthConfirmEmail(a);
    }
};