/**
* PDA v1.1.2
* (c) 2024 Product Designer App
* @license GPLv3
* Default theme
* Free version
* Unminify code for Dev
**/
const { createApp: createApp } = Vue;
var pdappVueApp = createApp({
    data: () => ({
        settings: {},
        toast: { show: !1, type: "success", text: "" },
        isFullScreen: !1,
        isCheckReload: !1,
        isLoaded: !1,
        isLoadedLayout: !1,
        langs: {},
        langDefault: pdappLangDefault,
        productID: pdappProductID,
        price: pdappPrice,
        product: {},
        activeProduct: { view: 0, area: 0, color: 0 },
        svgViewboxRatio: 0,
        listMenus: {},
        activeMenu: null,
        fontsize: [],
        fontLibrary: {},
        loadedFonts: {},
        addedFonts: [],
        modal: { show: !1 },
        modalCart: { show: !1 },
        loadingPage: !1,
        uploading: !1,
        shapePhoto: [],
        filterPhoto: [],
        sizeUnit: ["px", "cm", "in"],
        showRuler: !0,
        history: { active: -1, values: [] },
        photoStores: {},
        artworkStore: {},
        dropdownMenu: "",
        waitDesign: !1,
        waitTiming: 0,
        pluginUrl: pdappPluginUrl,
        uploadUrl: pdappUploadUrl,
        adminUrl: pdappAdminUrl,
        siteUrl: pdappUrl,
        backUrl: pdappBackUrl,
        tempFolders: [],
        templates: {},
        artFolders: [],
        artworks: {},
        breadcrumbs: [],
        language: {},
        warningBack: !1,
        loadTextTemp: !1,
        mydesigns: null,
        customerMail: pdappCustomerMail,
        myDesign: { id: "", created: "" },
        productCart: {
            pid: 0,
            did: 0,
            sizes: [],
            colors: [],
            extras: [],
            print: { id: 0, title: "", info: {} },
            loading: !1,
            items: [],
            add: !0,
            step: 0,
            error: "",
            help: "",
            phone: "",
            email: "",
            note: "",
            editCart: null,
            team: { qty: 0, items: [] },
        },
        printing: {},
        prinValue: [],
        timeUpdateThumb: 0,
        helpMenus: [],
        groupItem: { show: !1 },
        designsData: {},
        designsTeam: [],
        responsiveLayout: { showCart: !1, showMenu: !0, width: 0, height: 0, screenSize: "desktop", position: "hor" },
        listZoom: [300, 250, 200, 150, 100, 75, 50, 25, 10],
        listCropRatio: ["area_ratio", "1:1", "1:2", "2:1", "free_ratio"],
        loadaddview: !1,
        screenIsLandscape: !0,
        originalScreen: { width: 0, height: 0 },
    }),
    computed: {
        productDataPX() {
            let t = {},
                e = JSON.parse(JSON.stringify(this.product));
            return void 0 !== e.unit && (t = pdappAPI.tool.toProductPX(e)), t;
        },
        viewActivePX() {
            let t = this,
                e = {};
            return (
                void 0 !== t.product.views &&
                    void 0 !== t.productDataPX.views[t.activeProduct.view] &&
                    (e = t.productDataPX.views[t.activeProduct.view]),
                e
            );
        },
        areaActivePX() {
            let t = this,
                e = {};
            return (
                void 0 !== t.viewActivePX.layers &&
                    void 0 !== t.viewActivePX.layers[t.activeProduct.area] &&
                    (e = t.viewActivePX.layers[t.activeProduct.area]),
                e
            );
        },
        viewActive() {
            let t = this,
                e = {};
            return (
                void 0 !== t.product.views &&
                    void 0 !== t.product.views[t.activeProduct.view] &&
                    (e = t.product.views[t.activeProduct.view]),
                e
            );
        },
        areaActive() {
            let t = this,
                e = {};
            return (
                void 0 !== t.viewActive.layers &&
                    void 0 !== t.viewActive.layers[t.activeProduct.area] &&
                    (e = t.viewActive.layers[t.activeProduct.area]),
                e
            );
        },
        customViewNumber() {
            let t = this,
                e = [];
            if (void 0 !== t.product.views) {
                let o = 0;
                for (let a = 0; a < t.product.views.length; a++)
                    void 0 !== t.product.views[a].type && "addmore" == t.product.views[a].type
                        ? (o++, e.push(o))
                        : e.push(0);
            }
            return e;
        },
        getViewInd() {
            let t = this,
                e = 0;
            for (let o = 0; o < t.customViewNumber.length; o++) 0 != t.customViewNumber[o] && (e = o);
            return e;
        },
        productBoxStyle() {
            let t = this,
                e = [];
            if (
                ((t.responsiveLayout = pdappAPI.tool.responsiveLayout()),
                (t.originalScreen = { width: t.responsiveLayout.width, height: t.responsiveLayout.height }),
                void 0 !== t.product.unit && void 0 !== t.areaActivePX.id)
            ) {
                let o = pdappAPI.tool.getAutoZoom(
                    t.productDataPX.views[t.activeProduct.view],
                    t.product.unit,
                    t.areaActivePX,
                    t.responsiveLayout
                );
                0 == t.svgViewboxRatio &&
                    void 0 !== o.unit.ratio &&
                    (t.svgViewboxRatio = (100 * o.unit.ratio) / o.unit.zoom),
                    (t.product.unit = o.unit);
                let a = t.product.unit.ratio;
                for (let p = 0; p < t.productDataPX.views.length; p++) {
                    let i = { viewPort: "", backgrounds: [], layers: [], borders: [] };
                    if (
                        ((i.viewPort =
                            "width:" +
                            (t.productDataPX.views[p].canvas.width * a).toFixed(3) +
                            "px;height:" +
                            (t.productDataPX.views[p].canvas.height * a).toFixed(3) +
                            "px;top:" +
                            o.top.toFixed(3) +
                            "px;left:" +
                            o.left.toFixed(3) +
                            "px"),
                        t.productDataPX.views[p].backgrounds.length)
                    )
                        for (let e = 0; e < t.productDataPX.views[p].backgrounds.length; e++) {
                            let o =
                                "width:" +
                                (t.productDataPX.views[p].backgrounds[e].width * a).toFixed(3) +
                                "px;height:" +
                                (t.productDataPX.views[p].backgrounds[e].height * a).toFixed(3) +
                                "px;top:" +
                                t.productDataPX.views[p].backgrounds[e].top * a +
                                "px;left:" +
                                t.productDataPX.views[p].backgrounds[e].left * a +
                                "px;";
                            i.backgrounds.push(o);
                        }
                    if (
                        (void 0 !== t.productDataPX.views[p].mask &&
                            void 0 !== t.productDataPX.views[p].mask.image &&
                            (i.mask =
                                "width:" +
                                (t.productDataPX.views[p].mask.width * a).toFixed(3) +
                                "px;height:" +
                                (t.productDataPX.views[p].mask.height * a).toFixed(3) +
                                "px;top:" +
                                t.productDataPX.views[p].mask.top * a +
                                "px;left:" +
                                t.productDataPX.views[p].mask.left * a +
                                "px;"),
                        t.productDataPX.views[p].layers.length)
                    )
                        for (let e = 0; e < t.productDataPX.views[p].layers.length; e++) {
                            let o =
                                "width:" +
                                (t.productDataPX.views[p].layers[e].width * a).toFixed(3) +
                                "px;height:" +
                                (t.productDataPX.views[p].layers[e].height * a).toFixed(3) +
                                "px;top:" +
                                t.productDataPX.views[p].layers[e].top * a +
                                "px;left:" +
                                t.productDataPX.views[p].layers[e].left * a +
                                "px;";
                            (o +=
                                "" != t.productDataPX.views[p].layers[e].radius &&
                                0 != t.productDataPX.views[p].layers[e].radius
                                    ? "overflow:hidden;border-radius:" +
                                      t.productDataPX.views[p].layers[e].radius +
                                      "%;"
                                    : "overflow:hidden;"),
                                i.layers.push(o);
                            let s =
                                "" != t.productDataPX.views[p].layers[e].radius &&
                                0 != t.productDataPX.views[p].layers[e].radius
                                    ? "border-radius:" + t.productDataPX.views[p].layers[e].radius + "%;"
                                    : "";
                            i.borders.push(s);
                        }
                    e.push(i);
                }
            }
            return (
                setTimeout(() => {
                    if (
                        t.responsiveLayout.showCart &&
                        void 0 !== t.productDataPX.colors &&
                        void 0 !== t.langs.options
                    ) {
                        let e = jQuery(".pdapp-center-layout").height() - 136;
                        jQuery(".pdapp-cart-variants").css("max-height", e);
                        for (let e = 0; e < t.productDataPX.colors.length; e++)
                            "picker" == t.productDataPX.colors[e].type &&
                                pdappAPI.tool.colorPicker(
                                    "#pdapp-product-colorpicker-" + t.productDataPX.colors[e].id,
                                    t.langs.options,
                                    function (o, a) {
                                        t.changeProductColor(t.productDataPX.colors[e].id, a, e);
                                    }
                                );
                    }
                    if (t.responsiveLayout.showMenu && null == t.activeMenu) {
                        let e = pdappAPI.tool.getLocalVar("pdappActiveMenu", Object.keys(t.listMenus)[0]);
                        t.openMenu(e);
                    }
                    if (
                        (null != pdappAPI.tool.pdappMoveAbleRef && (t.closeMenuOption(), t.closeGroup()),
                        !t.responsiveLayout.showCart && !t.modalCart.show)
                    )
                        if (t.isLoadedLayout) {
                            if (
                                "product_color" == t.dropdownMenu &&
                                0 == jQuery(".pdapp-topbar-colorbox .sp-picker-container").length
                            )
                                for (let e = 0; e < t.productDataPX.colors.length; e++)
                                    "picker" == t.productDataPX.colors[e].type &&
                                        pdappAPI.tool.colorPicker(
                                            "#pdapp-product-colorpicker-" + t.productDataPX.colors[e].id,
                                            t.langs.options,
                                            function (o, a) {
                                                t.changeProductColor(t.productDataPX.colors[e].id, a, e);
                                            }
                                        );
                        } else
                            (t.isLoadedLayout = !0),
                                setTimeout(() => {
                                    t.showProductColor();
                                }, 200);
                }, 1),
                e
            );
        },
        productColors() {
            let t = this,
                e = {};
            for (let o = 0; o < t.productDataPX.colors.length; o++)
                e[t.productDataPX.colors[o].id] = t.productDataPX.colors[o].active;
            return e;
        },
        menuOptions() {
            let t = this,
                e = {};
            return (
                null != t.activeMenu &&
                    void 0 !== t.listMenus[t.activeMenu] &&
                    void 0 !== t.listMenus[t.activeMenu].options &&
                    (e = t.listMenus[t.activeMenu].options),
                e
            );
        },
        listFonts() {
            let t = this,
                e = { category: [], fonts: [], total: 20 };
            if (void 0 !== t.fontLibrary.fonts) {
                for (let o = 0; o < t.fontLibrary.fonts.length; o++)
                    !1 === e.category.includes(t.fontLibrary.fonts[o].category) &&
                        e.category.push(t.fontLibrary.fonts[o].category),
                        ("" != t.fontLibrary.find &&
                            -1 ==
                                t.fontLibrary.fonts[o].title.toLowerCase().indexOf(t.fontLibrary.find.toLowerCase())) ||
                            ("" != t.fontLibrary.category &&
                                t.fontLibrary.fonts[o].category != t.fontLibrary.category) ||
                            e.fonts.push(t.fontLibrary.fonts[o]);
                if (((e.total = e.fonts.length), void 0 !== t.fontLibrary.page)) {
                    let o = t.fontLibrary.page.paged * t.fontLibrary.page.perpage;
                    if (o < e.fonts.length) {
                        let t = [];
                        for (let a = 0; a < e.fonts.length && !(o <= a); a++) t.push(e.fonts[a]);
                        e.fonts = t;
                    }
                }
            }
            return e;
        },
        qrcodeTypes() {
            let t = this;
            return [
                { key: "text", text: t.langs.options.text_type },
                { key: "url", text: t.langs.options.url_type },
                { key: "phone", text: t.langs.options.phone_type },
                { key: "sms", text: t.langs.options.sms_type },
                { key: "mail", text: t.langs.options.mail_type },
            ];
        },
        barcodeTypes: () => [
            { type: "CODE128", values: ["CODE128", "CODE128A", "CODE128B", "CODE128C", "CODE128C-ean128"] },
            {
                type: "EAN / UPC",
                values: [
                    "EAN13",
                    "EAN13-flat",
                    "EAN13-lastchar",
                    "UPC",
                    "UPC-flat",
                    "EAN8",
                    "EAN8-flat",
                    "EAN5",
                    "EAN2",
                ],
            },
            { type: "CODE39", values: ["CODE39", "CODE39-mod43"] },
            { type: "ITF14", values: ["ITF14"] },
            { type: "MSI", values: ["MSI", "MSI10", "MSI11", "MSI1010", "MSI1110"] },
            { type: "pharmacode", values: ["pharmacode"] },
            { type: "codabar", values: ["codabar"] },
        ],
        listTextTemp() {
            let t = this,
                e = { temps: [], total: 20 };
            if ("text" == t.activeMenu && void 0 !== t.listMenus.text && void 0 !== t.listMenus.text.options.values) {
                let o = t.listMenus.text.options.values;
                if (void 0 !== t.listMenus.text.search && "" != t.listMenus.text.search) {
                    let a = t.listMenus.text.search;
                    for (let t = 0; t < o.length; t++)
                        -1 != o[t].text.toLowerCase().indexOf(a.toLowerCase()) && e.temps.push(o[t]);
                } else e.temps = o;
                if (((e.total = e.temps.length), void 0 !== t.listMenus.text.page)) {
                    let o = t.listMenus.text.page.paged * t.listMenus.text.page.perpage;
                    if (o < e.temps.length) {
                        let t = [];
                        for (let a = 0; a < e.temps.length && !(o <= a); a++) t.push(e.temps[a]);
                        e.temps = t;
                    }
                }
            }
            return e;
        },
        listTemplates() {
            let t = this,
                e = { temps: [], total: 20 };
            if (
                "template" == t.activeMenu &&
                void 0 !== t.listMenus.template &&
                void 0 !== t.listMenus.template.options.values.activeFolder &&
                void 0 !== t.templates[t.listMenus.template.options.values.activeFolder]
            ) {
                let o = t.templates[t.listMenus.template.options.values.activeFolder];
                if (
                    void 0 !== t.listMenus.template.options.values.search &&
                    "" != t.listMenus.template.options.values.search
                ) {
                    let a = t.listMenus.template.options.values.search;
                    for (let p = 0; p < o.length; p++)
                        -1 != t.getTitle(o[p].title).toLowerCase().indexOf(a.toLowerCase()) && e.temps.push(o[p]);
                } else e.temps = o;
                if (((e.total = e.temps.length), void 0 !== t.listMenus.template.options.values.page)) {
                    let o =
                        t.listMenus.template.options.values.page.paged *
                        t.listMenus.template.options.values.page.perpage;
                    if (o < e.temps.length) {
                        let t = [];
                        for (let a = 0; a < e.temps.length && !(o <= a); a++) t.push(e.temps[a]);
                        e.temps = t;
                    }
                }
            }
            return e;
        },
        listArtworks() {
            let t = this,
                e = { arts: [], total: 20 };
            if (
                "artwork" == t.activeMenu &&
                void 0 !== t.listMenus.artwork &&
                void 0 !== t.listMenus.artwork.options.values.activeFolder &&
                void 0 !== t.artworks[t.listMenus.artwork.options.values.activeFolder]
            ) {
                let o = t.artworks[t.listMenus.artwork.options.values.activeFolder];
                if (
                    void 0 !== t.listMenus.artwork.options.values.search &&
                    "" != t.listMenus.artwork.options.values.search
                ) {
                    let a = t.listMenus.artwork.options.values.search;
                    for (let p = 0; p < o.length; p++)
                        -1 != t.getTitle(o[p].title).toLowerCase().indexOf(a.toLowerCase()) && e.arts.push(o[p]);
                } else e.arts = o;
                if (((e.total = e.arts.length), void 0 !== t.listMenus.artwork.options.values.page)) {
                    let o =
                        t.listMenus.artwork.options.values.page.paged * t.listMenus.artwork.options.values.page.perpage;
                    if (o < e.arts.length) {
                        let t = [];
                        for (let a = 0; a < e.arts.length && !(o <= a); a++) t.push(e.arts[a]);
                        e.arts = t;
                    }
                }
            }
            return e;
        },
        checkApplyTeam() {
            let t = this,
                e = !1;
            if (void 0 !== t.modal.data && void 0 !== t.modal.data.length)
                for (let o = 0; o < t.modal.data.length; o++)
                    void 0 !== t.modal.data[o].name && "" == t.modal.data[o].name && (e = !0),
                        void 0 !== t.modal.data[o].number && "" == t.modal.data[o].number && (e = !0);
            return e;
        },
        colorAttr() {
            let t = { color: "", options: [] },
                e = this;
            if (void 0 !== e.product.colors)
                for (let o = 0; o < e.product.colors.length; o++)
                    if (
                        ("" == t.color
                            ? (t.color = e.product.colors[o].active)
                            : (t.color += "_" + e.product.colors[o].active),
                        "picker" == e.product.colors[o].type)
                    )
                        t.options.push(e.product.colors[o].title + ": " + e.product.colors[o].active);
                    else {
                        let a = "";
                        for (let t = 0; t < e.product.colors[o].values.length; t++)
                            e.product.colors[o].values[t].hex == e.product.colors[o].active &&
                                (a = e.product.colors[o].values[t].title);
                        (a =
                            "" == a
                                ? e.product.colors[o].title + ": " + e.product.colors[o].active
                                : e.product.colors[o].title + ": " + a),
                            t.options.push(a);
                    }
            return t;
        },
        extraAttr() {
            let t = { extra: "", options: [] },
                e = this;
            if (void 0 !== e.product.extras)
                for (let o = 0; o < e.product.extras.length; o++) {
                    "" == t.extra
                        ? (t.extra = e.product.extras[o].active)
                        : (t.extra += "_" + e.product.extras[o].active);
                    let a = "";
                    for (let t = 0; t < e.product.extras[o].values.length; t++)
                        t == e.product.extras[o].active && (a = e.product.extras[o].values[t]);
                    (a =
                        "" == a
                            ? e.product.extras[o].title + ": " + e.product.extras[o].active
                            : e.product.extras[o].title + ": " + a),
                        t.options.push(a);
                }
            return t;
        },
        getPrice() {
            let t = this,
                e = !0,
                o = JSON.parse(JSON.stringify(t.cartSize)),
                a = JSON.parse(JSON.stringify(t.productCart.items)),
                p = JSON.parse(JSON.stringify(t.productCart.team)),
                i = 0,
                s = 0,
                r = 0;
            if (0 == p.items.length) {
                if (t.cartQuantity > 0 && t.cartQty > 0)
                    for (let p = 0; p < a.length; p++)
                        if (a[p].color == t.colorAttr.color && a[p].extra == t.extraAttr.extra)
                            if (((e = !1), t.productCart.add))
                                for (let t = 0; t < a[p].sizes.length; t++)
                                    void 0 !== o[t] && (a[p].sizes[t].value = o[t].value + a[p].sizes[t].value);
                            else a[p].sizes = o;
                if (
                    (e &&
                        a.push({
                            color: t.colorAttr.color,
                            extra: t.extraAttr.extra,
                            options: [],
                            sizes: o,
                            thumb: [],
                        }),
                    a.length)
                )
                    for (let e = 0; e < a.length; e++)
                        for (let o = 0; o < a[e].sizes.length; o++) {
                            let p = a[e].sizes[o].value;
                            (i += p), (s += p * (parseFloat(a[e].sizes[o].price) + parseFloat(t.price))), (r = s);
                        }
            } else
                for (let e = 0; e < p.items.length; e++) {
                    let a =
                            1 == t.productCart.step && void 0 !== p.items[e].size.qty
                                ? p.items[e].size.qty
                                : t.cartTeamQty[e].qty,
                        l =
                            1 == t.productCart.step && void 0 !== p.items[e].size.size
                                ? p.items[e].size.size
                                : t.cartTeamQty[e].size;
                    (i += a), (s += a * (parseFloat(o[l].price) + parseFloat(t.price))), (r = s);
                }
            (t.productCart.error = ""), (t.productCart.help = "");
            let l = t.product.advanced.minQty > 1 ? t.langs.topbar.items : t.langs.topbar.item;
            if (void 0 !== t.langs.topbar && i < t.product.advanced.minQty) {
                t.productCart.error = t.langs.topbar.min_qty_error + " " + t.product.advanced.minQty + " " + l;
                let e = t.product.advanced.minQty - i;
                (l = e > 1 ? t.langs.topbar.items : t.langs.topbar.item),
                    i > 0 && e > 0 && (t.productCart.help = t.langs.topbar.min_qty_help + " " + e + " " + l);
            }
            if (
                i > 0 &&
                void 0 !== t.productCart.print.info.views &&
                t.productCart.print.info.views > 0 &&
                void 0 !== t.printing &&
                t.printing.prints.length
            ) {
                let e = 0,
                    o =
                        void 0 !== t.printing.prints[t.productCart.print.info.views - 1]
                            ? t.printing.prints[t.productCart.print.info.views - 1]
                            : t.printing.prints[t.printing.prints.length - 1];
                for (let a in o.values)
                    if ("function" == typeof pdappAPI.design.print[a] && void 0 !== o.values[a]) {
                        let p = 0;
                        for (let t = 0; t < o.qtys.length; t++) i >= o.qtys[t] && (p = t);
                        if (void 0 !== o.values[a][p]) {
                            let s = pdappAPI.design.print[a](o.values[a][p], i, t.productCart.print.info);
                            s > 0 && (e += s);
                        }
                    }
                if (((s += e), (r += e), void 0 !== t.productCart.print.info.artwork))
                    for (let e = 0; e < t.productCart.print.info.artwork.length; e++)
                        if (void 0 !== t.artworkStore[t.productCart.print.info.artwork[e]]) {
                            let o = parseFloat(t.artworkStore[t.productCart.print.info.artwork[e]]);
                            (s += o), (r += o);
                        }
            }
            let d = "";
            if (void 0 !== t.product.advanced.discount && void 0 !== t.product.advanced.discount.list && i > 0) {
                let e = 0;
                for (let o = 0; o < t.product.advanced.discount.list.length; o++)
                    if (t.product.advanced.discount.list[o].qty <= i)
                        e =
                            "fixed" == t.product.advanced.discount.type
                                ? t.product.advanced.discount.list[o].price
                                : (t.product.advanced.discount.list[o].price * r) / 100;
                    else if ("" == d) {
                        let a =
                                "fixed" == t.product.advanced.discount.type
                                    ? t.product.advanced.discount.list[o].price
                                    : (t.product.advanced.discount.list[o].price *
                                          ((t.product.advanced.discount.list[o].qty * r) / i)) /
                                      100,
                            p = t.product.advanced.discount.list[o].qty - i;
                        if (((l = p > 1 ? t.langs.topbar.items : t.langs.topbar.item), a > e)) {
                            let e =
                                "fixed" == t.product.advanced.discount.type
                                    ? t.priceFormat(t.product.advanced.discount.list[o].price)
                                    : t.product.advanced.discount.list[o].price + "%";
                            d =
                                t.langs.topbar.buy_more +
                                " " +
                                p +
                                " " +
                                l +
                                " " +
                                t.langs.topbar.will_be_save +
                                " <span>" +
                                e +
                                "</span>";
                        }
                    }
                r = parseFloat((s - e).toFixed(2));
            }
            return (s = s.toFixed(2)), (r = r.toFixed(2)), { price: s, sale: r, discount: d };
        },
        cartTeamQty() {
            let t = this,
                e = [],
                o = JSON.parse(JSON.stringify(t.cartSize));
            for (let a = 0; a < t.productCart.team.items.length; a++) {
                let a = { size: 0, qty: 0 };
                if (t.productCart.team.qty > 0)
                    if (1 == o.length) {
                        let e = o[0].stock - t.productCart.team.qty;
                        e < 0 && (e = 0), (a.qty = e > 0 ? t.productCart.team.qty : o[0].stock), (o[0].stock = e);
                    } else {
                        let e = !1;
                        for (let p = 0; p < o.length; p++) {
                            let i = o[p].stock - t.productCart.team.qty;
                            0 == e &&
                                i >= 0 &&
                                ((o[p].stock = i), (a.qty = t.productCart.team.qty), (a.size = p), (e = !0)),
                                0 == e && p == o.length - 1 && ((o[p].stock = 0), (a.size = 0), (a.qty = 0));
                        }
                    }
                e.push(a);
            }
            return e;
        },
        cartQuantity() {
            let t = this,
                e = 0;
            if (t.productCart.team.items.length > 0) {
                for (let o = 0; o < t.cartTeamQty.length; o++) e += t.cartTeamQty[o].qty;
                return e;
            }
            for (let o = 0; o < t.cartSize.length; o++) e += t.cartSize[o].value;
            return e;
        },
        cartQty() {
            let t = this,
                e = 0;
            if (t.productCart.team.items.length > 0) {
                for (let o = 0; o < t.productCart.team.items.length; o++) {
                    e +=
                        1 == t.productCart.step && void 0 !== t.productCart.team.items[o].size.qty
                            ? t.productCart.team.items[o].size.qty
                            : t.cartTeamQty[o].qty;
                }
                return e;
            }
            if (t.productCart.items.length)
                for (let o = 0; o < t.productCart.items.length; o++)
                    for (let a = 0; a < t.productCart.items[o].sizes.length; a++)
                        e += t.productCart.items[o].sizes[a].value;
            return e;
        },
        productAttrs() {
            let t = this,
                e = {};
            if (void 0 !== t.product.attributes && void 0 !== t.product.attributes.values)
                for (let o = 0; o < t.product.attributes.values.length; o++)
                    e[t.product.attributes.values[o].key] = {
                        stock: t.product.attributes.values[o].stock,
                        price: t.product.attributes.values[o].price,
                    };
            return e;
        },
        cartSize() {
            let t = this,
                e = [],
                o = "";
            if (void 0 !== t.product.attributes && void 0 !== t.product.attributes.color)
                if ("_" != t.product.attributes.color && void 0 !== t.product.colors[t.product.attributes.color]) {
                    if (t.productCart.colors.length)
                        for (let e = 0; e < t.productCart.colors.length; e++)
                            void 0 !== t.product.colors[e] &&
                                ((t.product.colors[e].active = t.productCart.colors[e]),
                                t.changeProductColor(t.product.colors[e].id, t.product.colors[e].active, e),
                                "picker" == t.product.colors[t.product.attributes.color].type &&
                                    setTimeout(() => {
                                        jQuery("#pdapp-product-colorpicker-" + t.product.colors[e].id).spectrum(
                                            "set",
                                            t.product.colors[e].active
                                        );
                                    }, 5));
                    let e = t.product.colors[t.product.attributes.color];
                    if ("picker" == e.type) o = "c_p";
                    else for (let t = 0; t < e.values.length; t++) e.values[t].hex == e.active && (o = "c_" + t);
                } else o = "c";
            let a = "";
            if (void 0 !== t.product.extras && t.product.extras.length)
                for (let e = 0; e < t.product.extras.length; e++)
                    void 0 !== t.productCart.extras[e] && (t.product.extras[e].active = t.productCart.extras[e]),
                        (a += "-e_" + e + "_" + t.product.extras[e].active);
            else a = "-e";
            (t.productCart.colors = []), (t.productCart.extras = []);
            for (let p = 0; p < t.productCart.sizes.length; p++) {
                let i = o;
                (i =
                    void 0 !== t.product.attributes && "_" != t.product.attributes.size
                        ? "" != i
                            ? i + "-s_" + p
                            : "s_" + p
                        : "" != i
                          ? i + "-s"
                          : "s-"),
                    "" != a && (i = "" != i ? i + a : "s" + a);
                let s = t.productCart.sizes[p];
                if (("" == s.value && (s.value = 0), void 0 !== t.productAttrs[i])) {
                    let e = parseInt(t.productAttrs[i].stock);
                    if (t.productCart.items.length && t.productCart.add)
                        for (let o = 0; o < t.productCart.items.length; o++)
                            for (let a = 0; a < t.productCart.items[o].sizes.length; a++)
                                t.productCart.items[o].sizes[a].key == i &&
                                    (e -= parseInt(t.productCart.items[o].sizes[a].value));
                    (s.stock = e), (s.key = i), (s.price = t.productAttrs[i].price);
                }
                s.stock < 0 && (s.stock = 0), s.stock < s.value && (s.value = s.stock), e.push(s);
            }
            return (
                setTimeout(() => {
                    pdappAPI.tool.responsiveCart();
                }, 1),
                e
            );
        },
        cartTeamSize() {
            let t = this,
                e = [],
                o = JSON.parse(JSON.stringify(t.cartSize));
            if (void 0 !== t.productCart.team && void 0 !== t.productCart.team.items)
                for (let a = 0; a < t.productCart.team.items.length; a++) {
                    let p = [];
                    for (let i = 0; i < o.length; i++) {
                        let s = { key: o[i].key, price: o[i].price, stock: o[i].stock, title: o[i].title };
                        if (t.productCart.team.items[a].size.size == i) {
                            s.stock = o[i].stock;
                            let p = o[i].stock - t.productCart.team.items[a].size.qty;
                            if (p <= 0) {
                                (p = 0), (t.productCart.team.items[a].size.qty = o[i].stock);
                                for (let o = 0; o < e.length; o++)
                                    for (let a = 0; a < e[o].length; a++)
                                        i == a && t.productCart.team.items[o].size.size != i && (e[o][a].stock = 0);
                            }
                            o[i].stock = p;
                        }
                        p.push(s);
                    }
                    e.push(p);
                }
            return e;
        },
        cartTeamStock() {
            let t = this,
                e = 0;
            if (1 == t.cartSize.length) e = t.cartSize[0].stock;
            else for (let o = 0; o < t.cartSize.length; o++) e += t.cartSize[o].stock;
            return (
                void 0 !== t.productCart.team &&
                    void 0 !== t.productCart.team.items &&
                    t.productCart.team.items.length &&
                    (e /= t.productCart.team.items.length),
                (e = Math.floor(e)),
                e
            );
        },
        showGroupOption() {
            let t = this,
                e = !1;
            return (
                (t.settings.layout.text.copy ||
                    t.settings.layout.photo.copy ||
                    t.settings.layout.artwork.copy ||
                    t.settings.layout.qrcode.copy ||
                    t.settings.layout.barcode.copy ||
                    (t.groupItem.colors.length &&
                        (t.settings.layout.text.color ||
                            t.settings.layout.photo.color ||
                            t.settings.layout.artwork.color))) &&
                    (e = !0),
                e
            );
        },
    },
    watch: {
        menuOptions: {
            handler(t) {
                let e = this;
                if (void 0 !== t.childID && void 0 !== t.details[t.childID]) {
                    let o = t.details[t.childID];
                    void 0 !== o.dropdown &&
                        setTimeout(() => {
                            pdappAPI.tool.responsiveDropdown(o, e.responsiveLayout);
                        }, 5);
                }
            },
            deep: !0,
        },
        groupItem: {
            handler(t) {
                let e = this;
                if (void 0 !== t.show && t.show && void 0 !== t.active && "" != t.active) {
                    let o = { type: "group", dropdown: t.active };
                    setTimeout(() => {
                        pdappAPI.tool.responsiveDropdown(o, e.responsiveLayout);
                    }, 5);
                }
            },
            deep: !0,
        },
    },
    created() {
        this.initFunc(), jQuery(document).trigger("after_created_called", { self: this });
    },
    mounted() {
        jQuery(document).trigger("after_mounted_called", { self: this });
    },
    methods: {
        startWorker() {
            let t = this;
            if ("undefined" == typeof pdappWorker || 0 == pdappWorker) return !1;
            pdappWorker.onmessage = function (e) {
                t.actionWorker(e.data);
            };
        },
        actionWorker(t) {
            let e = this;
            if ("getPhoto" == t.action) {
                if ("blob" == t.type)
                    if (
                        ((e.photoStores[t.id][t.type] = URL.createObjectURL(t.value)),
                        pdappAPI.photo.readPhoto(e.photoStores[t.id], function (o) {
                            let a = "pdapp-target-" + pdappAPI.tool.uID();
                            (e.photoStores[t.id].target = a), e.createPhoto(o, t.id, a);
                        }),
                        "undefined" != typeof pdappWorker && pdappWorker)
                    )
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "base64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") && (e.photoStores[t.id].base64 = o.result);
                            });
                    }
                if ("origin" == t.type) {
                    if (!1 === t.value)
                        return (
                            void 0 !== t.post &&
                                (e.modal = {
                                    show: !0,
                                    header: !1,
                                    size: "md modal-dialog-centered",
                                    title: "",
                                    type: "confirmRemoveImg",
                                    id: t.id,
                                }),
                            !1
                        );
                    (e.photoStores[t.id].origin = t.value), (e.waitDesign = !1);
                }
            }
            if ("getPhotoReplace" == t.action) {
                if ("blob" == t.type)
                    if (
                        ((e.photoStores[t.id][t.type] = URL.createObjectURL(t.value)),
                        pdappAPI.photo.readPhoto(e.photoStores[t.id], function (o) {
                            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
                            let a = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
                            e.replacePhoto(o, t.id, a);
                        }),
                        "undefined" != typeof pdappWorker && pdappWorker)
                    )
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "base64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") && (e.photoStores[t.id].base64 = o.result);
                            });
                    }
                if ("origin" == t.type) {
                    if (!1 === t.value)
                        return (
                            void 0 !== t.post &&
                                (e.modal = {
                                    show: !0,
                                    header: !1,
                                    size: "md modal-dialog-centered",
                                    title: "",
                                    type: "confirmRemoveImg",
                                    id: t.id,
                                }),
                            !1
                        );
                    (e.photoStores[t.id].origin = t.value), (e.waitDesign = !1);
                }
            }
            if (
                ("toBase64" == t.action && (e.photoStores[t.id][t.type] = t.value),
                "cropImage" == t.action && void 0 !== e.photoStores[t.id] && void 0 !== e.photoStores[t.id].crop)
            ) {
                if (!1 === t.value)
                    return (
                        void 0 !== t.post &&
                            (e.modal = {
                                show: !0,
                                header: !1,
                                size: "md modal-dialog-centered",
                                title: "",
                                type: "confirmRemoveImg",
                                id: t.id,
                            }),
                        !1
                    );
                let o = t.post.hisID;
                (e.photoStores[t.id].crop.origin = t.value),
                    void 0 !== e.history.values[o] &&
                        ("createPhoto" == e.history.values[o].redo.action
                            ? (e.history.values[o].redo.value = JSON.parse(JSON.stringify(e.photoStores[t.id])))
                            : (e.history.values[o].redo.value = JSON.parse(JSON.stringify(e.photoStores[t.id].crop)))),
                    (e.waitDesign = !1);
            }
        },
        removeFileIssues() {
            let t = this;
            if (void 0 !== t.modal.type && "confirmRemoveImg" == t.modal.type && void 0 !== t.modal.id) {
                let e = t.modal.id;
                void 0 !== t.photoStores[t.modal.id] &&
                    (void 0 !== t.photoStores[t.modal.id].target &&
                        "" != t.photoStores[t.modal.id].target &&
                        (e = t.photoStores[t.modal.id].target),
                    delete t.photoStores[t.modal.id]);
                let o = jQuery("#" + e);
                pdappAPI.tool.pdappMoveAbleRef.target = null;
                let a = o.parent("g.pdapp-g-photo");
                if (
                    (0 != a.length ? a.remove() : o.remove(),
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                    (t.menuOptions.childID = null),
                    t.responsiveLayout.showMenu || (t.activeMenu = null),
                    t.history.values.length && void 0 !== t.history.values[t.history.values.length - 1])
                ) {
                    let e = t.history.values[t.history.values.length - 1];
                    void 0 === e.redo ||
                        void 0 === e.redo.action ||
                        ("createPhoto" != e.redo.action && "cropPhoto" != e.redo.action) ||
                        e.redo.target != t.modal.id ||
                        delete t.history.values[t.history.values.length - 1];
                }
                t.waitDesign = !1;
            }
            t.modal.show = !1;
        },
        async checkToken() {
            let t = this,
                e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-verify-token&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
            try {
                await pdappAPI.tool.getData(e);
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
            setTimeout(() => {
                t.checkToken();
            }, 3e5);
        },
        reloadPage() {
            (this.isCheckReload = !0), location.reload();
        },
        priceFormat: (t) => pdappPriceFormat.replace("10", t),
        async initFunc() {
            let t = this;
            jQuery("body").addClass("pdapp-studio-layout"),
                jQuery("#productdesignerapp-app").show(),
                jQuery("#pdapp-loading-page").remove(),
                (t.responsiveLayout = pdappAPI.tool.responsiveLayout());
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-product&id=" +
                t.productID +
                "&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.product = o.data),
                    (t.productCart.pid = t.productID),
                    (t.productCart.did = o.data.id),
                    (t.productCart.print.id = o.data.pid),
                    jQuery(document).trigger("after_product_loaded", { self: t }),
                    t.loadCartSize();
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-settings&langs=1&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let e = await pdappAPI.tool.getData(o);
                    t.language = e.data;
                } catch (e) {
                    return (
                        (t.toast = { show: !0, type: "error", text: e.msg }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3),
                        !1
                    );
                }
                return (t.warningBack = !0), !1;
            }
            e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-settings&general=1&layout=1&all=1&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                if (void 0 !== t.product.advanced && t.product.advanced.customize)
                    for (let e in t.product.advanced)
                        void 0 !== o.data.settings.layout[e] &&
                            void 0 !== o.data.settings.layout[e].allow &&
                            (o.data.settings.layout[e].allow = t.product.advanced[e]),
                            "upload" == e && (o.data.settings.layout.photo.allowUpload = t.product.advanced[e]),
                            "library" == e && (o.data.settings.layout.photo.allowLibrary = t.product.advanced[e]);
                if (
                    ((t.settings = o.data.settings),
                    t.settings.layout.quote.allow ||
                        t.settings.layout.addcart.allow ||
                        jQuery(".pdapp-right-layout").width("0px"),
                    jQuery(document).trigger("after_setting_loaded", { self: t }),
                    pdappAPI.tool.loadMoreLibrary(t.settings),
                    (t.listMenus = o.data.menus),
                    t.responsiveLayout.showMenu)
                ) {
                    let e = pdappAPI.tool.getLocalVar("pdappActiveMenu", Object.keys(o.data.menus)[0]);
                    t.openMenu(e);
                } else t.activeMenu = null;
                (t.langs = o.data.langs), (t.fontsize = o.data.fontsize), t.renderHelpMenu();
            } catch (e) {
                return (
                    (t.toast = { show: !0, type: "error", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3),
                    !1
                );
            }
            e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-fonts&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.fontLibrary = o.data),
                    (t.fontLibrary.page = { paged: 1, perpage: 20 }),
                    jQuery(document).trigger("after_fonts_loaded", { self: t }),
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-font-list", function () {
                            t.listFonts.total > t.listFonts.fonts.length && t.fontLibrary.page.paged++;
                        });
                    }, 1);
            } catch (t) {}
            e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-print&id=" +
                t.productCart.print.id +
                "&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.printing = o.data),
                    (t.productCart.print.title = o.data.title),
                    jQuery(document).trigger("after_print_loaded", { self: t });
            } catch (t) {}
            t.checkReloadPage(),
                t.applyHotKeys(),
                t.startWorker(),
                (t.isLoaded = !0),
                setTimeout(() => {
                    t.checkToken();
                }, 3e5),
                setTimeout(() => {
                    void 0 !== t.product.views &&
                        setTimeout(() => {
                            t.changeProductView(t.activeProduct.view),
                                t.initProduct(),
                                (pdappAPI.tool.ruler.clear_gtitle = t.langs.toolbar.clear_guide_lines),
                                void 0 === t.settings.layout.ruler.allow ||
                                    t.settings.layout.ruler.allow ||
                                    t.toggleShowRuler();
                        }, 10);
                }, 1),
                setTimeout(() => {
                    let e = pdappAPI.tool.getSizeScreen();
                    e.width > e.height ? (t.screenIsLandscape = !0) : (t.screenIsLandscape = !1),
                        (window.onresize = function () {
                            t.onResizeScreen();
                        }),
                        pdappAPI.tool.setScroll();
                }, 100);
        },
        renderHelpMenu() {
            let t = this;
            (t.helpMenus = []),
                void 0 !== t.settings.general.guide &&
                    t.settings.general.guide &&
                    t.helpMenus.push({ key: "design", name: t.langs.help.designs, icon: "brush" });
        },
        checkReloadPage() {
            let t = this;
            hotkeys("f5 ,ctrl+f5, command+r, command+shift+r", function (e) {
                if (((t.isCheckReload = !0), pdappAPI.tool.checkDesign())) {
                    let e = confirm(t.langs.confirm_reload);
                    return (
                        e ||
                            setTimeout(() => {
                                t.isCheckReload = !1;
                            }, 200),
                        e
                    );
                }
                return (
                    setTimeout(() => {
                        t.isCheckReload = !1;
                    }, 200),
                    !0
                );
            }),
                (window.onbeforeunload = function (e) {
                    if (pdappAPI.tool.checkDesign() && 0 == t.isCheckReload) return !0;
                });
        },
        applyHotKeys() {
            let t = this;
            pdappAPI.hotkeys.init(function (e, o, a) {
                if (
                    ("help" == e && t.showHelp(),
                    "move" == e &&
                        ("text" == o && t.settings.layout.text.move
                            ? t.moveText(a)
                            : ("artwork" == o && t.settings.layout.artwork.move) ||
                                ("photo" == o && t.settings.layout.photo.move) ||
                                ("qrcode" == o && t.settings.layout.qrcode.move) ||
                                ("barcode" == o && t.settings.layout.barcode.move)
                              ? t.movePhoto(a)
                              : "group" == o && t.moveGroup(a)),
                    "copy" == e &&
                        ("text" == o && t.settings.layout.text.copy
                            ? t.copyText()
                            : "artwork" == o && t.settings.layout.artwork.copy
                              ? t.copyArtwork()
                              : "photo" == o && t.settings.layout.photo.copy
                                ? t.copyPhoto()
                                : "qrcode" == o && t.settings.layout.qrcode.copy
                                  ? t.copyQrcode()
                                  : "barcode" == o && t.settings.layout.barcode.copy
                                    ? t.copyBarcode()
                                    : "group" == o && t.copyGroup()),
                    "textStyle" == e &&
                        void 0 !== t.settings.layout.text[o] &&
                        t.settings.layout.text[o] &&
                        t.formatText(o),
                    "lock" == e &&
                        ("text" == o && t.settings.layout.text.lock
                            ? t.lockText()
                            : (("artwork" == o && t.settings.layout.artwork.lock) ||
                                  ("photo" == o && t.settings.layout.photo.lock) ||
                                  ("qrcode" == o && t.settings.layout.qrcode.lock) ||
                                  ("barcode" == o && t.settings.layout.barcode.lock)) &&
                              t.lockPhoto()),
                    "flip" == e &&
                        ("text" == o && t.settings.layout.text.flip
                            ? t.flipText()
                            : (("artwork" == o && t.settings.layout.artwork.flip) ||
                                  ("photo" == o && t.settings.layout.photo.flip)) &&
                              t.flipPhoto()),
                    "del" == e &&
                        ("text" == o
                            ? t.deleteText()
                            : "artwork" == o
                              ? t.deleteArtwork()
                              : "photo" == o
                                ? t.deletePhoto()
                                : "team" == o
                                  ? t.deleteTeam()
                                  : "qrcode" == o || "barcode" == o
                                    ? t.deleteQrcode()
                                    : "group" == o && t.deleteGroup()),
                    "selectAll" == e && t.selectAllGroup(),
                    "ruler" == e && t.settings.layout.ruler.allow && t.toggleShowRuler(),
                    "preview" == e && t.settings.layout.preview.allow && t.previewScreen(),
                    "fullscreen" == e && t.settings.layout.fullscreen.allow && t.toggleFullScreen(),
                    "reset" == e && t.settings.layout.reset.allow && t.resetAllDesign(),
                    "back" == e && t.backToProduct(),
                    "open" == e && t.settings.layout.saveDesign.allow && t.openDesign(),
                    "save" == e && t.settings.layout.saveDesign.allow && t.openSaveDesign(""),
                    "download" == e &&
                        t.settings.layout.download.allow &&
                        (t.settings.general.download.type.includes("png") ||
                            t.settings.general.download.type.includes("pdf") ||
                            t.settings.general.download.type.includes("svg")) &&
                        t.showDownload(""),
                    "addCart" == e && t.settings.layout.addcart.allow && t.showCartBox("cart"),
                    "zoom" == e && t.settings.layout.zoom.allow)
                ) {
                    let e = parseInt(t.product.unit.zoom);
                    "up" == o
                        ? ((e += 5), e <= 295 && (t.product.unit.zoom = e + 5))
                        : ((e -= 5), e >= 15 && (t.product.unit.zoom = e - 5));
                }
                ("undo" != e && "redo" != e) || !t.settings.layout.undo.allow || t.doHistory(e);
            });
        },
        resetAllDesign() {
            let t = this;
            pdappAPI.tool.checkDesign() &&
                (t.modal = { show: !0, header: !1, size: "md modal-dialog-centered", title: "", type: "confirmReset" });
        },
        startReset() {
            let t = this;
            pdappAPI.tool.resetDesign(),
                (t.photoStores = {}),
                (t.history = { active: -1, values: [] }),
                t.loadCartSize(),
                (t.productCart.items = []),
                (t.productCart.add = !0),
                (t.productCart.step = 0),
                (t.productCart.error = ""),
                (t.productCart.help = ""),
                (t.productCart.phone = ""),
                (t.productCart.email = ""),
                (t.productCart.note = ""),
                (t.productCart.editCart = null),
                (t.productCart.team = { qty: 0, items: [] }),
                (t.menuOptions.childID = null),
                (t.listMenus.team.options.values = { active: 0, name: "", number: [], teams: [] }),
                (t.groupItem.show = !1),
                (t.modal.show = !1);
        },
        showHelp() {
            let t = this,
                e = void 0 !== t.helpMenus[0] ? t.helpMenus[0].key : "hotkey";
            t.modal = { show: !0, header: !0, size: "full-width", title: t.langs.help.guide, type: "help", tab: e };
        },
        async getListShape() {
            let t = this;
            if (t.shapePhoto.length) return !1;
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-settings&shape=1&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.shapePhoto = o.data.shape), jQuery(document).trigger("after_get_shape", { self: t });
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
        },
        async getListFilter() {
            let t = this;
            if (t.filterPhoto.length) return !1;
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-settings&filter=1&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.filterPhoto = o.data.filter), jQuery(document).trigger("after_get_filter", { self: t });
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
        },
        async getListText() {
            let t = this;
            void 0 === t.listMenus.text.search &&
                ((t.listMenus.text.search = ""), (t.listMenus.text.page = { paged: 1, perpage: 20 })),
                (t.loadTextTemp = !0);
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-settings&text=1&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.listMenus.text.options.values = o.data.text),
                    jQuery(document).trigger("after_get_text", { self: t });
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
            (t.loadTextTemp = !1),
                setTimeout(() => {
                    pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                        t.listTextTemp.total > t.listTextTemp.temps.length && t.listMenus.text.page.paged++;
                    });
                }, 1);
        },
        addCartDesign(t) {
            let e = this;
            jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (o) {
                jQuery(this)
                    .find(".pdapp-viewport-area")
                    .each(function (a) {
                        if (
                            void 0 !== t[o] &&
                            void 0 !== t[o][a] &&
                            "" != t[o][a] &&
                            void 0 !== e.productDataPX.views[o] &&
                            void 0 !== e.productDataPX.views[o].layers[a] &&
                            void 0 !== e.productDataPX.views[o].layers[a]
                        ) {
                            pdappAPI.design.import(jQuery(this), t[o][a], "", function (t, o, a) {
                                (e.photoStores[o] = a),
                                    (e.photoStores[t] = { id: o, crop: "" }),
                                    void 0 !== a.blob &&
                                        "" != a.blob &&
                                        jQuery("#" + t)
                                            .find("image")
                                            .attr("xlink:href", a.blob);
                            });
                            let p = jQuery(this);
                            setTimeout(() => {
                                if (p.find("svg.pdapp-selecto-area").find(".pdapp-team").length) {
                                    let t = !0,
                                        o = e.listMenus.team.options.values.teams;
                                    if (0 == o.length) {
                                        let t = p.find("svg.pdapp-selecto-area").find("span.pdapp-team-value");
                                        if (t.length > 0) {
                                            let e = t.text();
                                            "" != e && (o = JSON.parse(e)), t.remove();
                                        }
                                    }
                                    o.length > 0 &&
                                        ((t = !1),
                                        p
                                            .find("svg.pdapp-selecto-area")
                                            .find(".pdapp-team")
                                            .each(function () {
                                                jQuery(this).hasClass("pdapp-team-name") &&
                                                    (e.listMenus.team.options.values.name = jQuery(this).attr("id")),
                                                    jQuery(this).hasClass("pdapp-team-number") &&
                                                        e.listMenus.team.options.values.number.push(
                                                            jQuery(this).attr("id")
                                                        );
                                            })),
                                        t && p.find("svg.pdapp-selecto-area").find(".pdapp-team").remove();
                                }
                                p.find("svg.pdapp-selecto-area")
                                    .find("g.pdapp-target")
                                    .each(function () {
                                        let t = jQuery(this),
                                            e = t.attr("data-artid"),
                                            o = t.attr("data-tempid");
                                        void 0 !== e && "" != e && 0 == arts.includes(e) && arts.push(e),
                                            void 0 !== o && "" != o && 0 == temps.includes(o) && temps.push(o);
                                    });
                            }, 10);
                        } else jQuery(this).find("svg.pdapp-selecto-area").html("");
                    });
            }),
                setTimeout(() => {
                    e.getPrintInfo();
                }, 500);
        },
        openMenu(t) {
            let e = this;
            if (void 0 !== e.listMenus[t]) {
                if (
                    void 0 !== e.settings.layout[t] &&
                    ((void 0 !== e.settings.layout[t].allow && !e.settings.layout[t].allow) ||
                        (void 0 !== e.settings.layout[t].allowUpload &&
                            !e.settings.layout[t].allowUpload &&
                            !e.settings.layout[t].allowLibrary))
                ) {
                    let o = "";
                    for (let t in e.listMenus)
                        "" == o &&
                            void 0 !== e.settings.layout[t] &&
                            ((void 0 !== e.settings.layout[t].allow && e.settings.layout[t].allow) ||
                                (void 0 !== e.settings.layout[t].allowUpload &&
                                    (e.settings.layout[t].allowUpload || e.settings.layout[t].allowLibrary))) &&
                            (o = t);
                    t = o;
                }
                if (
                    ((e.activeMenu = t),
                    pdappAPI.tool.setLocalVar("pdappActiveMenu", t),
                    void 0 === e.listMenus.team.options.values.teams &&
                        (e.listMenus.team.options.values = { active: 0, name: "", number: [], teams: [] }),
                    (e.groupItem.show = !1),
                    pdappAPI.layer.unselect(),
                    "template" == t)
                )
                    return (
                        void 0 === e.tempFolders[0]
                            ? e.getTempFolders()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-template", function () {
                                      e.listTemplates.total > e.listTemplates.temps.length &&
                                          e.listMenus.template.options.values.page.paged++;
                                  });
                              }, 1),
                        !1
                    );
                if ("text" == t)
                    return (
                        0 == e.listMenus.text.options.values.length
                            ? e.getListText()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                                      e.listTextTemp.total > e.listTextTemp.temps.length &&
                                          e.listMenus.text.page.paged++;
                                  });
                              }, 1),
                        (e.listMenus.text.options.childID = null),
                        !1
                    );
                if ("artwork" == t)
                    return (
                        (e.listMenus.artwork.options.childID = null),
                        void 0 === e.artFolders[0]
                            ? e.getArtFolders()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                                      e.listArtworks.total > e.listArtworks.arts.length &&
                                          e.listMenus.artwork.options.values.page.paged++;
                                  });
                              }, 1),
                        !1
                    );
                if ("photo" == t)
                    return (
                        (e.listMenus.photo.options.childID = null),
                        e.getListShape(),
                        e.getListFilter(),
                        void 0 !== e.settings.layout.photo &&
                            e.settings.layout.photo.allowLibrary &&
                            (0 == e.listMenus.photo.options.values.length
                                ? e.getPhotos()
                                : setTimeout(() => {
                                      pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                          e.getPhotos();
                                      });
                                  }, 1)),
                        !1
                    );
                if ("team" == t) return (e.listMenus.team.options.childID = null), !1;
                if ("barcode" == t) {
                    e.listMenus.barcode.options.childID = null;
                    let t = e.settings.general.barcode.font,
                        o = t.replaceAll(" ", "+");
                    return (
                        void 0 === e.loadedFonts[o] && e.selectFont({ title: t, variants: ["700"], category: "" }),
                        (e.listMenus.barcode.options.values = []),
                        !1
                    );
                }
                if ("layer" == t)
                    return (
                        (e.listMenus.layer.options.childID = null),
                        (e.listMenus.layer.options.values = pdappAPI.layer.loadLayers()),
                        !1
                    );
            }
        },
        initProduct() {
            let t = this;
            if (void 0 !== t.productDataPX.views)
                for (let e = 0; e < t.productDataPX.views.length; e++) {
                    if (
                        void 0 !== t.productDataPX.views[0] &&
                        void 0 !== t.productDataPX.views[0].backgrounds &&
                        t.productDataPX.views[0].backgrounds.length
                    )
                        for (let e = 0; e < t.productDataPX.views[0].backgrounds.length; e++)
                            t.setProductColor(t.productDataPX.views[0].backgrounds[e].id);
                    if (t.productDataPX.views[e].layers.length)
                        for (let o = 0; o < t.productDataPX.views[e].layers.length; o++)
                            "" != t.productDataPX.views[e].layers[o].mask &&
                                pdappAPI.tool.imgToBase64(
                                    t.uploadUrl +
                                        "products/product-" +
                                        t.productDataPX.id +
                                        "/" +
                                        t.productDataPX.views[e].layers[o].mask,
                                    function (a) {
                                        jQuery(
                                            "#pdapp-viewport-area-" +
                                                t.productDataPX.views[e].id +
                                                "-" +
                                                t.productDataPX.views[e].layers[o].id
                                        )
                                            .find(".pdapp-area-mask-img")
                                            .attr("src", a);
                                    },
                                    1e3
                                );
                    void 0 !== t.productDataPX.views[e].mask &&
                        void 0 !== t.productDataPX.views[e].mask.image &&
                        pdappAPI.tool.imgToBase64(
                            t.uploadUrl +
                                "products/product-" +
                                t.productDataPX.id +
                                "/" +
                                t.productDataPX.views[e].mask.image,
                            function (o) {
                                jQuery("#pdapp-viewport-" + t.productDataPX.views[e].id + " .pdapp-mask-img")
                                    .find(".pdapp-product-img")
                                    .attr("src", o);
                            },
                            1e3
                        );
                }
            if (((t.activeProduct.area = 0), void 0 !== t.product.temp && t.product.temp.length)) {
                void 0 === t.settings.layout && (t.settings.layout = {}),
                    void 0 === t.settings.layout.template && (t.settings.layout.template = {}),
                    (t.settings.layout.template.allow = !1);
                let e = t.product.temp,
                    o = 0;
                jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (a) {
                    o++;
                    let p = o == e.length,
                        i = 0;
                    jQuery(this)
                        .find(".pdapp-viewport-area")
                        .each(function (o) {
                            void 0 !== e[a] &&
                                void 0 !== e[a][o] &&
                                "" != e[a][o] &&
                                void 0 !== t.productDataPX.views[a] &&
                                void 0 !== t.productDataPX.views[a].layers[o] &&
                                void 0 !== t.productDataPX.views[a].layers[o] &&
                                (pdappAPI.design.import(jQuery(this), e[a][o], "", function (e, o, a) {
                                    (t.photoStores[o] = a), (t.photoStores[e] = { id: o, crop: "" });
                                }),
                                i++,
                                p &&
                                    i == e[a].length &&
                                    setTimeout(() => {
                                        t.getPrintInfo("update");
                                    }, 500));
                        });
                });
            }
        },
        changeProductView(t, e = "view") {
            let o = this;
            o.closeMenuOption(),
                (o.dropdownMenu = ""),
                "view" == e ? ((o.activeProduct.view = t), (o.activeProduct.area = 0)) : (o.activeProduct.area = t),
                setTimeout(() => {
                    jQuery(".pdapp-viewport.active .pdapp-viewport-area.active .moveable-control-box").length &&
                        jQuery(".pdapp-viewport.active .pdapp-viewport-area.active .moveable-control-box").remove(),
                        pdappAPI.tool.enableMoveAble(
                            function (t) {
                                let e = jQuery(t);
                                if (e.hasClass("pdapp-svg-text")) {
                                    let t = e.find("text").attr("font-size"),
                                        a = pdappAPI.tool.getTransform(e);
                                    if ("" != a) {
                                        let e = a
                                            .replace("matrix(", "")
                                            .replace(")", "")
                                            .replaceAll(" ", "")
                                            .split(",");
                                        if (6 == e.length) {
                                            let a = parseFloat(e[0]);
                                            1 != a &&
                                                ((t = Math.round(parseFloat(t) * a)),
                                                (o.menuOptions.details[o.menuOptions.childID].fontSize = t));
                                        }
                                    }
                                }
                            },
                            function (t) {
                                o.activeLayer(t), pdappAPI.tool.removeControlBox();
                            },
                            function (t, e) {
                                if (e.start != e.end) {
                                    let a = {};
                                    (a.undo = { action: "updateTransform", target: t.attr("id"), value: e.start }),
                                        (a.redo = { action: "updateTransform", target: t.attr("id"), value: e.end }),
                                        o.setHistory(a),
                                        t.attr("transform", e.end),
                                        t.removeAttr("style");
                                }
                            },
                            function (t) {
                                jQuery("#pdapp-upload-a-photo-replace").length &&
                                    "photo" == o.activeMenu &&
                                    null != o.menuOptions.childID &&
                                    void 0 !== o.menuOptions.details[o.menuOptions.childID] &&
                                    void 0 !== o.menuOptions.details[o.menuOptions.childID].clickShowUpload &&
                                    o.menuOptions.details[o.menuOptions.childID].clickShowUpload &&
                                    o.showReplacePhoto();
                            },
                            function (t, e) {
                                if (e.start[0] != e.end[0]) {
                                    let a = {};
                                    (a.undo = { action: "updateTransformGroup", target: t, value: e.start }),
                                        (a.redo = { action: "updateTransformGroup", target: t, value: e.end }),
                                        o.setHistory(a);
                                }
                            }
                        );
                }, 10);
        },
        changeProductArea(t) {
            let e = this;
            e.activeProduct.area != t && e.changeProductView(t, "area");
        },
        addMoreView() {
            let t = this;
            if (void 0 === t.product.advanced || void 0 === t.product.advanced.maxview)
                return (
                    (t.toast = { show: !0, type: "error", text: t.langs.toolbar.add_more_view_error }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3),
                    !1
                );
            if (0 == t.product.advanced.maxview || t.loadaddview) return !1;
            t.loadaddview = !0;
            let e = void 0 !== t.product.advanced.viewtitle ? t.product.advanced.viewtitle : "Page",
                o = {};
            o =
                void 0 !== t.product.advanced.viewcopy && void 0 !== t.product.views[t.product.advanced.viewcopy]
                    ? JSON.parse(JSON.stringify(t.product.views[t.product.advanced.viewcopy]))
                    : JSON.parse(JSON.stringify(t.product.views[0]));
            let a = o.id;
            (o.id = pdappAPI.tool.uID()), (o.type = "addmore"), (o.title = e);
            for (let t = 0; t < o.layers.length; t++) o.layers[t].id = pdappAPI.tool.uID();
            for (let t = 0; t < o.backgrounds.length; t++) {
                let e = "pdapp-background-" + a + "-" + o.backgrounds[t].id,
                    p = jQuery("#" + e)
                        .find(".pdapp-product-img")
                        .attr("src");
                void 0 !== p && "" != p && -1 != p.indexOf("base64,") && (o.backgrounds[t].image = p);
            }
            if (void 0 !== o.mask && void 0 !== o.mask.image && "" != o.mask.image) {
                let t = jQuery("#pdapp-viewport-" + a + " .pdapp-mask-img")
                    .find(".pdapp-product-img")
                    .attr("src");
                void 0 !== t && "" != t && -1 != t.indexOf("base64,") && (o.mask.image = t);
            }
            let p =
                void 0 !== t.product.advanced.viewcopy && void 0 !== t.product.views[t.product.advanced.viewcopy]
                    ? t.product.advanced.viewcopy
                    : 0;
            t.getViewInd > p && (p = t.getViewInd),
                p++,
                t.product.views.length < p ? t.product.views.push(o) : t.product.views.splice(p, 0, o),
                t.product.advanced.maxview--,
                (t.toast = { show: !0, type: "success", text: t.langs.toolbar.add_more_view_success }),
                setTimeout(() => {
                    t.toast.show = !1;
                }, 5e3),
                setTimeout(() => {
                    for (let e = 0; e < t.product.views.length; e++) {
                        let o = t.product.views[e];
                        if ("" != o.id)
                            for (let t = 0; t < o.backgrounds.length; t++)
                                if ("" != o.backgrounds[t].id) {
                                    let e = "#pdapp-background-" + o.id + "-" + o.backgrounds[t].id;
                                    pdappAPI.photo.setColor(jQuery(e));
                                }
                    }
                    t.changeProductView(p),
                        setTimeout(() => {
                            t.loadaddview = !1;
                            let e = "";
                            jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (t) {
                                if (t >= p) {
                                    let t = jQuery(this),
                                        o = e,
                                        a = "";
                                    (e = t.find(".pdapp-viewport-area .pdapp-selecto-area").clone()),
                                        (a = t.find(".pdapp-viewport-area .pdapp-text-arc").clone()),
                                        "" != o
                                            ? (t.find(".pdapp-viewport-area .pdapp-text-arc").html(a),
                                              t.find(".pdapp-viewport-area .pdapp-selecto-area").html(o))
                                            : (t.find(".pdapp-viewport-area .pdapp-text-arc").html(""),
                                              t.find(".pdapp-viewport-area .pdapp-selecto-area").html(""));
                                }
                            });
                        }, 300);
                }, 1e3);
        },
        removeView(t) {
            let e = this;
            if (
                void 0 === e.product.advanced ||
                void 0 === e.product.advanced.maxview ||
                t == e.activeProduct.view ||
                void 0 === e.product.views[t] ||
                void 0 === e.product.views[t].type ||
                "addmore" != e.product.views[t].type
            )
                return (
                    (e.toast = { show: !0, type: "error", text: e.langs.toolbar.remove_view_error }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3),
                    !1
                );
            if (void 0 !== e.product.views[t + 1])
                for (let o = t + 1; o < e.product.views.length; o++) {
                    let t = e.product.views[o],
                        a = e.product.views[o - 1];
                    if ("" != t.id)
                        for (let e = 0; e < t.layers.length; e++)
                            if ("" != t.layers[e].id && void 0 !== a.layers[e].id) {
                                let o = "#pdapp-viewport-area-" + t.id + "-" + t.layers[e].id,
                                    p = "#pdapp-viewport-area-" + a.id + "-" + a.layers[e].id,
                                    i = jQuery(o).find("svg.pdapp-selecto-area").clone();
                                jQuery(p).find("svg.pdapp-selecto-area").html(i);
                            }
                }
            (e.loadaddview = !0),
                e.product.views.splice(t, 1),
                e.product.views.length - 1 < e.activeProduct.view && e.changeProductView(e.product.views.length - 1),
                e.product.advanced.maxview++,
                (e.toast = { show: !0, type: "success", text: e.langs.toolbar.remove_view_success }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3),
                setTimeout(() => {
                    e.loadaddview = !1;
                }, 500),
                setTimeout(() => {
                    for (let t = 0; t < e.product.views.length; t++) {
                        let o = e.product.views[t];
                        if ("" != o.id)
                            for (let t = 0; t < o.backgrounds.length; t++)
                                if ("" != o.backgrounds[t].id) {
                                    let e = "#pdapp-background-" + o.id + "-" + o.backgrounds[t].id;
                                    pdappAPI.photo.setColor(jQuery(e));
                                }
                    }
                }, 1e3);
        },
        showProductColor() {
            let t = this;
            if ("product_color" == t.dropdownMenu) return (t.dropdownMenu = ""), !1;
            (t.dropdownMenu = "product_color"),
                setTimeout(() => {
                    for (let e = 0; e < t.productDataPX.colors.length; e++)
                        "picker" == t.productDataPX.colors[e].type &&
                            pdappAPI.tool.colorPicker(
                                "#pdapp-product-colorpicker-" + t.productDataPX.colors[e].id,
                                t.langs.options,
                                function (o, a) {
                                    t.changeProductColor(t.productDataPX.colors[e].id, a, e);
                                }
                            );
                }, 1);
        },
        changeProductColor(t, e, o) {
            let a = this;
            if (void 0 !== a.product.colors[o])
                if (((a.product.colors[o].active = e), "custom" == a.product.colors[o].type))
                    for (let p = 0; p < a.product.views.length; p++)
                        for (let i = 0; i < a.product.views[p].backgrounds.length; i++) {
                            let s = jQuery("#pdapp-background-" + a.product.views[p].id + "-" + t);
                            if ("image" == a.product.views[p].backgrounds[i].colorType) {
                                for (let t = 0; t < a.product.colors[o].values.length; t++)
                                    if (
                                        a.product.colors[o].values[t].hex == e &&
                                        s.find("img.pdapp-product-img").length
                                    ) {
                                        let e =
                                            void 0 !== a.product.views[p].backgrounds[i].images[t] &&
                                            "" != a.product.views[p].backgrounds[i].images[t]
                                                ? a.product.views[p].backgrounds[i].images[t]
                                                : "";
                                        "" != e && null != e
                                            ? -1 != e.indexOf(";base64,")
                                                ? s.find("img.pdapp-product-img").attr("src", e)
                                                : ((e =
                                                      -1 != e.indexOf("://")
                                                          ? e
                                                          : pdappUploadUrl +
                                                            "products/product-" +
                                                            a.product.id +
                                                            "/" +
                                                            e),
                                                  pdappAPI.tool.imgToBase64(
                                                      e,
                                                      function (t) {
                                                          s.find("img.pdapp-product-img").attr("src", t);
                                                      },
                                                      1e3
                                                  ))
                                            : setTimeout(() => {
                                                  s.find("img.pdapp-product-img").length && pdappAPI.photo.setColor(s);
                                              });
                                    }
                            } else
                                setTimeout(() => {
                                    s.find("img.pdapp-product-img").length && pdappAPI.photo.setColor(s);
                                });
                        }
                else
                    jQuery(".pdapp-background-img-" + t).each(function () {
                        let t = jQuery(this);
                        setTimeout(() => {
                            t.find("img.pdapp-product-img").length && pdappAPI.photo.setColor(t);
                        });
                    });
        },
        hexColor: (t) => t.replace("#", ""),
        updateProductColor(t, e, o) {
            if (6 != t.length) return jQuery("#pdapp-product-colorinput-" + e).addClass("border-warning"), !1;
            let a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec((t = "#" + t));
            return null != a && 4 == a.length
                ? (this.changeProductColor(e, t, o),
                  jQuery("#pdapp-product-colorinput-" + e).removeClass("border-warning"),
                  jQuery("#pdapp-product-colorpicker-" + e).spectrum("set", t),
                  !1)
                : (jQuery("#pdapp-product-colorinput-" + e).addClass("border-warning"), !1);
        },
        updateAttrColor(t, e, o) {
            let a = void 0 !== o ? "-" + o : "";
            if (6 != t.length) return jQuery("#pdapp-" + e + "-colorinput" + a).addClass("border-warning"), !1;
            let p = this,
                i = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec((t = "#" + t));
            if (null != i && 4 == i.length) {
                if (
                    ("text" == e &&
                        ((p.menuOptions.details[p.menuOptions.childID].color = t), p.updateTextStyle("color")),
                    "outline" == e &&
                        ((p.menuOptions.details[p.menuOptions.childID].stroke = t), p.updateTextStyle("outline")),
                    "edit" == e)
                ) {
                    let e = jQuery("#pdapp-edit-colorpicker" + a).attr("data-color");
                    p.updateColor(e, t);
                }
                return (
                    jQuery("#pdapp-" + e + "-colorinput" + a).removeClass("border-warning"),
                    jQuery("#pdapp-" + e + "-colorpicker" + a).spectrum("set", t),
                    !1
                );
            }
            return jQuery("#pdapp-" + e + "-colorinput" + a).addClass("border-warning"), !1;
        },
        setProductColor(t) {
            let e = this;
            for (let o = 0; o < e.productDataPX.colors.length; o++)
                e.productDataPX.colors[o].id == t && e.changeProductColor(t, e.productDataPX.colors[o].active, o);
        },
        async getTempFolders() {
            let t = this;
            t.listMenus.template.options.values = {
                activeFolder: 0,
                loadFolder: !0,
                loadTemp: !1,
                search: "",
                page: { paged: 1, perpage: 20 },
            };
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-temp-folders&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.tempFolders = o.data),
                    (t.breadcrumbs = [{ to: "", title: t.langs.options.root }]),
                    t.getTemplates(t.product.advanced.tempID),
                    (t.listMenus.template.options.values.activeFolder = t.product.advanced.tempID);
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (t.toast = { show: !0, type: "error", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.listMenus.template.options.values.loadFolder = !1;
        },
        async getTemplates(t) {
            let e = this;
            if (void 0 === e.templates[t]) {
                e.listMenus.template.options.values.loadTemp = !0;
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-templates&folder=" +
                    t +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let a = await pdappAPI.tool.getData(o);
                    (e.templates[t] = a.data), jQuery(document).trigger("after_get_templates", { self: e });
                } catch (t) {
                    if (-1 == t.error)
                        return (
                            (e.modal = {
                                show: !0,
                                header: !1,
                                size: "md modal-dialog-centered",
                                title: "",
                                type: "confirmReload",
                            }),
                            !1
                        );
                    (e.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            e.toast.show = !1;
                        }, 5e3);
                }
                (e.listMenus.template.options.values.loadTemp = !1),
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-menu-options-template", function () {
                            e.listTemplates.total > e.listTemplates.temps.length &&
                                e.listMenus.template.options.values.page.paged++;
                        });
                    }, 1);
            }
        },
        openFolder(t) {
            let e = this;
            e.listMenus[e.activeMenu].options.values.activeFolder = t;
            let o = 0,
                a = [];
            "template" == e.activeMenu
                ? (e.getTemplates(t),
                  (a = e.tempFolders),
                  (e.listMenus.template.options.values.page.paged = 1),
                  (o = e.product.advanced.tempID))
                : (e.getArtworks(t),
                  (a = e.artFolders),
                  (e.listMenus.artwork.options.values.page.paged = 1),
                  (o = e.product.advanced.artID)),
                (e.breadcrumbs = []);
            let p = { id: o, pid: 0, title: e.langs.options.root };
            pdappAPI.folder.getFolderBreads(a, p, t, o, function (o) {
                for (let a = 0; a < o.length; a++) {
                    let p = o[a].id == t ? "" : o[a].id;
                    e.breadcrumbs.push({ to: p, title: o[a].title });
                }
            });
        },
        async addTemplate(t) {
            let e = this;
            if (((e.listMenus.template.options.values.loadTemp = t.id), void 0 === t.svg)) {
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-template&id=" +
                    t.id +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let e = await pdappAPI.tool.getData(o);
                    t.svg = e.data;
                } catch (t) {
                    return -1 == t.error
                        ? ((e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmReload",
                          }),
                          !1)
                        : ((e.toast = { show: !0, type: "error", text: t.msg }),
                          setTimeout(() => {
                              e.toast.show = !1;
                          }, 5e3),
                          (e.listMenus.template.options.values.loadTemp = !1),
                          !1);
                }
            }
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                (e.artworkStore["temp-" + t.id] = t.price),
                pdappAPI.design.import(
                    jQuery("#pdapp-viewer-area .pdapp-viewport.active .pdapp-viewport-area.active"),
                    t.svg,
                    t.id,
                    function (t, o, a) {
                        (e.photoStores[o] = a), (e.photoStores[t] = { id: o, crop: "" });
                    }
                ),
                (e.listMenus.template.options.values.loadTemp = !1),
                e.responsiveLayout.showMenu || (e.activeMenu = null),
                setTimeout(() => {
                    e.getPrintInfo();
                }, 500);
        },
        addNewText(t) {
            let e = this;
            (e.loadingPage = !0),
                pdappAPI.text.create(t, function (t, o) {
                    e.selectFont(
                        { title: o.fontFamily, variants: ["700"], category: "" },
                        function () {
                            e.loadingPage = !1;
                            let o = t.attr("id");
                            pdappAPI.layer.afterAdded(o), e.activeLayer(t);
                            let a = {};
                            (a.undo = { action: "deleteText", target: o }),
                                (a.redo = {
                                    action: "createText",
                                    target: o,
                                    index: pdappAPI.history.getIndex(t),
                                    value: "",
                                    svg: t.clone(),
                                    arc: pdappAPI.history.getTextArc(t),
                                    gradient: {},
                                }),
                                e.setHistory(a);
                        },
                        t
                    );
                });
        },
        addTextTemplate(t) {
            let e = this;
            (e.loadingPage = !0),
                pdappAPI.text.create(t, function (t, o) {
                    e.selectFont(
                        { title: o.fontFamily, variants: ["700"], category: "" },
                        function () {
                            e.loadingPage = !1;
                            let o = t.attr("id");
                            pdappAPI.layer.afterAdded(o), e.activeLayer(t);
                            let a = {};
                            (a.undo = { action: "deleteText", target: o }),
                                (a.redo = {
                                    action: "createText",
                                    target: o,
                                    index: pdappAPI.history.getIndex(t),
                                    value: "",
                                    svg: t.clone(),
                                    arc: pdappAPI.history.getTextArc(t),
                                    gradient: {},
                                }),
                                e.setHistory(a);
                        },
                        t
                    );
                });
        },
        updateText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = t.menuOptions.details[t.menuOptions.childID].text;
            void 0 !== t.settings.general.text &&
                t.settings.general.text.emoji &&
                ((e = pdappAPI.tool.removeEmoij(e)), (t.menuOptions.details[t.menuOptions.childID].text = e));
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            e.length < 1 &&
                ((t.menuOptions.details[t.menuOptions.childID].text = ""), (e = o.attr("data-text").substring(0, 1)));
            let a = pdappAPI.history.getTextArc(o),
                p = "" != a ? o.clone() : "",
                i = {};
            (i.undo = {
                action: "updateText",
                target: o.attr("id"),
                value: o.attr("data-text"),
                transform: pdappAPI.tool.getTransform(o),
                svg: p,
                arc: a,
            }),
                pdappAPI.text.updateText(e, function () {
                    (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target)),
                        "" != a && (a = pdappAPI.history.getTextArc(o)),
                        (p = "" != a ? o.clone() : ""),
                        (i.redo = {
                            action: "updateText",
                            target: o.attr("id"),
                            value: e,
                            transform: pdappAPI.tool.getTransform(o),
                            svg: p,
                            arc: a,
                        }),
                        t.setHistory(i);
                });
        },
        updateTextMobile(t) {
            let e = this;
            (e.menuOptions.details[e.menuOptions.childID].text = t.target.value), e.updateText();
        },
        changeFont(t) {
            if (
                ((self = this),
                null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
            )
                return !1;
            self.loadingPage = !0;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = pdappAPI.history.getTextArc(e),
                a = "" != o ? e.clone() : "",
                p = {};
            (p.undo = {
                action: "changeFont",
                target: e.attr("id"),
                value: e.find("text").attr("font-family"),
                transform: pdappAPI.tool.getTransform(e),
                svg: a,
                arc: o,
            }),
                self.selectFont(
                    t,
                    function () {
                        (self.loadingPage = !1),
                            0 == self.addedFonts.includes(t.title) && self.addedFonts.push(t.title),
                            (a = "" != o ? e.clone() : ""),
                            (p.redo = {
                                action: "changeFont",
                                target: e.attr("id"),
                                value: t.title,
                                transform: pdappAPI.tool.getTransform(e),
                                svg: a,
                                arc: o,
                            }),
                            self.setHistory(p);
                    },
                    e
                );
        },
        selectFont(t, e, o) {
            let a = this,
                p = t.title.replaceAll(" ", "+");
            if (void 0 === a.loadedFonts[p])
                pdappAPI.tool.loadFontData(t.title, function (i) {
                    (a.loadedFonts[p] = i),
                        pdappAPI.tool.loadFontFace(t.title, i, function () {
                            "function" == typeof e && e(o),
                                setTimeout(() => {
                                    a.setSvgStyle();
                                }, 10);
                        });
                });
            else if (void 0 !== o) {
                let p = a.addedFonts.includes(t.title) ? 20 : 200;
                pdappAPI.text.changeFont(
                    t.title,
                    p,
                    function () {
                        200 == p && a.addedFonts.push(t.title),
                            "function" == typeof e && e(o),
                            setTimeout(() => {
                                a.setSvgStyle();
                            }, 10);
                    },
                    o
                );
            } else "function" == typeof e && e(o);
            null != a.activeMenu &&
                void 0 !== a.listMenus[a.activeMenu].options.details &&
                void 0 !== a.listMenus[a.activeMenu].options.details[a.menuOptions.childID] &&
                (a.listMenus[a.activeMenu].options.details[a.menuOptions.childID].fontFamily = t.title);
        },
        getCateFont: (t) => t.replace("-", " "),
        updateTextSize(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            "" == t
                ? (t = e.menuOptions.details[e.menuOptions.childID].fontSize)
                : (e.menuOptions.details[e.menuOptions.childID].fontSize = t);
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = pdappAPI.history.getTextArc(o),
                p = "" != a ? o.clone() : "",
                i = {};
            (i.undo = {
                action: "textSize",
                target: o.attr("id"),
                value: o.find("text").attr("font-size"),
                transform: pdappAPI.tool.getTransform(o),
                svg: p,
                arc: a,
            }),
                pdappAPI.text.setSize(t, function () {
                    (p = "" != a ? o.clone() : ""),
                        "" != a && (a = pdappAPI.history.getTextArc(o)),
                        (i.redo = {
                            action: "textSize",
                            target: o.attr("id"),
                            value: t,
                            transform: pdappAPI.tool.getTransform(o),
                            svg: p,
                            arc: a,
                        }),
                        e.setHistory(i);
                });
        },
        formatText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = JSON.parse(JSON.stringify(e.menuOptions.details[e.menuOptions.childID])),
                p = pdappAPI.history.getFormatText(o, a, t),
                i = p.res;
            pdappAPI.text.formatText(t, e.menuOptions.details[e.menuOptions.childID], function (t, a) {
                e.menuOptions.details[e.menuOptions.childID][t] = a;
                let s = "" != i.arc ? pdappAPI.history.getTextArc(o) : "",
                    r = "" != i.arc ? o.clone() : "",
                    l = {};
                (l.undo = { action: "formatText", target: o.attr("id"), value: i, svg: p.svg }),
                    (l.redo = {
                        action: "formatText",
                        target: o.attr("id"),
                        value: { key: t, value: a, arc: s },
                        svg: r,
                    }),
                    e.setHistory(l);
            });
        },
        dropdownText(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                "color" == t &&
                    setTimeout(() => {
                        pdappAPI.tool.colorPicker("#pdapp-text-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].color = o), e.updateTextStyle("color");
                        });
                    }, 1),
                "outline" == t &&
                    setTimeout(() => {
                        pdappAPI.tool.colorPicker("#pdapp-outline-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].stroke = o), e.updateTextStyle("outline");
                        });
                    }, 1),
                "font" == t &&
                    void 0 !== e.fontLibrary.page &&
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-font-list", function () {
                            e.listFonts.total > e.listFonts.fonts.length && e.fontLibrary.page.paged++;
                        });
                    }, 1);
        },
        closeTextDropdown() {
            this.menuOptions.details[this.menuOptions.childID].dropdown = "";
        },
        updateTextStyle(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = pdappAPI.history.getTextStyle(t),
                p = {};
            p.undo = { action: "updateTextStyle", target: o.attr("id"), value: a };
            let i = { type: t, value: "", arc: "" },
                s = "";
            "outline" == t
                ? ((value = {
                      stroke: e.menuOptions.details[e.menuOptions.childID].stroke,
                      strokeWidth: e.menuOptions.details[e.menuOptions.childID].strokeWidth,
                  }),
                  pdappAPI.text.updateTextStyle(t, value, function () {
                      (i.arc = "" != a.arc ? pdappAPI.history.getTextArc(o) : ""),
                          (i.value = value),
                          (p.redo = { action: "updateTextStyle", target: o.attr("id"), value: i, svg: s }),
                          e.setHistory(p);
                  }))
                : void 0 !== e.menuOptions.details[e.menuOptions.childID][t] &&
                  pdappAPI.text.updateTextStyle(t, e.menuOptions.details[e.menuOptions.childID][t], function (r) {
                      (i.arc = "" != a.arc ? pdappAPI.history.getTextArc(o) : ""),
                          (i.value = r),
                          "" == a.arc || ("radius" != t && "letterSpacing" != t) || (s = o.clone()),
                          (p.redo = { action: "updateTextStyle", target: o.attr("id"), value: i, svg: s }),
                          e.setHistory(p);
                  });
        },
        alignText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.text.alignText(t),
                setTimeout(() => {
                    (p.redo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        moveText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.text.moveText(t),
                setTimeout(() => {
                    (p.redo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        gradientText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a =
                    void 0 !== o.attr("data-gradient") && "" != o.attr("data-gradient")
                        ? o.attr("data-gradient").split("-")[0]
                        : "normal",
                p =
                    void 0 !== o.attr("data-gradient") && "" != o.attr("data-gradient")
                        ? "#" + o.attr("data-gradient").split("-").pop()
                        : o.attr("fill"),
                i = {};
            (i.undo = { action: "textGradient", target: o.attr("id"), value: { color: p, type: a } }),
                pdappAPI.text.gradient(t, e.menuOptions.details[e.menuOptions.childID].color),
                (e.menuOptions.details[e.menuOptions.childID].colorType = t),
                (i.redo = {
                    action: "textGradient",
                    target: o.attr("id"),
                    value: { color: e.menuOptions.details[e.menuOptions.childID].color, type: t },
                }),
                e.setHistory(i);
        },
        deleteText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = {};
            void 0 !== e.attr("data-gradient") &&
                "" != e.attr("data-gradient") &&
                ((o.type = e.attr("data-gradient").split("-")[0]),
                (o.color = e.attr("data-gradient").split("-").pop()));
            let a = {};
            (a.undo = {
                action: "createText",
                target: e.attr("id"),
                index: pdappAPI.history.getIndex(e),
                value: "",
                svg: e.clone(),
                arc: pdappAPI.history.getTextArc(e),
                gradient: o,
            }),
                pdappAPI.text.delete(function (e) {
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        t.responsiveLayout.showMenu || (t.activeMenu = null),
                        setTimeout(() => {
                            t.setSvgStyle();
                        }, 1),
                        (a.redo = { action: "deleteText", target: e }),
                        t.setHistory(a);
                });
        },
        lockText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = {};
            (o.undo = { action: "lockText", target: e.attr("id"), value: e.hasClass("pdapp-lock") }),
                pdappAPI.text.lock(t.menuOptions.details[t.menuOptions.childID].textLock, function (a) {
                    (t.menuOptions.details[t.menuOptions.childID].textLock = a),
                        (o.redo = { action: "lockText", target: e.attr("id"), value: a }),
                        t.setHistory(o);
                });
        },
        copyText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.text.copy(t.langs.options, function (e) {
                t.activeLayer(e),
                    (t.toast = { show: !0, type: "success", text: t.langs.options.copy_text_success }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
                let o = {};
                void 0 !== e.attr("data-gradient") &&
                    "" != e.attr("data-gradient") &&
                    ((o.type = e.attr("data-gradient").split("-")[0]),
                    (o.color = e.attr("data-gradient").split("-").pop()));
                let a = {};
                (a.undo = { action: "deleteText", target: e.attr("id") }),
                    (a.redo = {
                        action: "createText",
                        target: e.attr("id"),
                        index: pdappAPI.history.getIndex(e),
                        svg: e.clone(),
                        arc: pdappAPI.history.getTextArc(e),
                        gradient: o,
                    }),
                    t.setHistory(a);
            });
        },
        flipText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = pdappAPI.history.getTextArc(e),
                a = "" != o ? e.clone() : "",
                p = {};
            (p.undo = {
                action: "flipText",
                target: e.attr("id"),
                flip: e.hasClass("pdapp-flip"),
                value: e.attr("data-text"),
                svg: a,
                arc: o,
            }),
                pdappAPI.text.flip(t.menuOptions.details[t.menuOptions.childID].textFlip, function (i) {
                    (t.menuOptions.details[t.menuOptions.childID].textFlip = i),
                        (e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target)),
                        "" != o && (o = pdappAPI.history.getTextArc(e)),
                        (a = "" != o ? e.clone() : ""),
                        (p.redo = {
                            action: "flipText",
                            target: e.attr("id"),
                            flip: i,
                            value: e.attr("data-text"),
                            svg: a,
                            arc: o,
                        }),
                        t.setHistory(p);
                });
        },
        async getArtFolders() {
            let t = this;
            t.listMenus.artwork.options.values = {
                activeFolder: 0,
                loadFolder: !0,
                loadArt: !1,
                search: "",
                page: { paged: 1, perpage: 20 },
            };
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-art-folders&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.artFolders = o.data),
                    (t.breadcrumbs = [{ to: "", title: t.langs.options.root }]),
                    t.getArtworks(t.product.advanced.artID),
                    (t.listMenus.artwork.options.values.activeFolder = t.product.advanced.artID);
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (t.toast = { show: !0, type: "error", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.listMenus.artwork.options.values.loadFolder = !1;
        },
        async getArtworks(t) {
            let e = this;
            if (void 0 === e.artworks[t]) {
                e.listMenus.artwork.options.values.loadArt = !0;
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-artworks&folder=" +
                    t +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let a = await pdappAPI.tool.getData(o);
                    e.artworks[t] = a.data;
                } catch (t) {
                    if (-1 == t.error)
                        return (
                            (e.modal = {
                                show: !0,
                                header: !1,
                                size: "md modal-dialog-centered",
                                title: "",
                                type: "confirmReload",
                            }),
                            !1
                        );
                    (e.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            e.toast.show = !1;
                        }, 5e3);
                }
                (e.listMenus.artwork.options.values.loadArt = !1),
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                            e.listArtworks.total > e.listArtworks.arts.length &&
                                e.listMenus.artwork.options.values.page.paged++;
                        });
                    }, 1);
            }
        },
        updateColor(t, e, o) {
            let a = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            if (t == e) return !1;
            let p = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                i = [];
            if (a.groupItem.show && p.length > 1) {
                for (let o = 0; o < p.length; o++) {
                    let a = jQuery(p[o]);
                    if (void 0 === a.attr("data-color") || a.hasClass("pdapp-svg")) {
                        void 0 !== a.attr("fill") &&
                            (a.attr("fill", a.attr("fill").replaceAll(t, e)),
                            a.attr("fill", a.attr("fill").replaceAll(t.toUpperCase(), e))),
                            void 0 !== a.attr("data-color") &&
                                (a.attr("data-color", a.attr("data-color").replaceAll(t, e)),
                                a.attr("data-color", a.attr("data-color").replaceAll(t.toUpperCase(), e))),
                            void 0 !== a.attr("data-background") &&
                                (a.attr("data-background", a.attr("data-background").replaceAll(t, e)),
                                a.attr("data-background", a.attr("data-background").replaceAll(t.toUpperCase(), e))),
                            (p[o].innerHTML = p[o].innerHTML.replaceAll(t, e)),
                            (p[o].innerHTML = p[o].innerHTML.replaceAll(t.toUpperCase(), e));
                        let s = a.attr("id");
                        i.push(s);
                    }
                }
                for (let o = 0; o < a.groupItem.colors.length; o++)
                    a.groupItem.colors[o] == t && (a.groupItem.colors[o] = e);
            } else if (void 0 !== p[0]) {
                let s = jQuery(p[0]);
                if (
                    (void 0 !== s.attr("fill") &&
                        (s.attr("fill", s.attr("fill").replaceAll(t, e)),
                        s.attr("fill", s.attr("fill").replaceAll(t.toUpperCase(), e))),
                    void 0 !== s.attr("data-color") &&
                        (s.attr("data-color", s.attr("data-color").replaceAll(t, e)),
                        s.attr("data-color", s.attr("data-color").replaceAll(t.toUpperCase(), e))),
                    void 0 !== s.attr("data-background") &&
                        (s.attr("data-background", s.attr("data-background").replaceAll(t, e)),
                        s.attr("data-background", s.attr("data-background").replaceAll(t.toUpperCase(), e))),
                    void 0 !== o && void 0 !== a.menuOptions.details[a.menuOptions.childID].colors[o])
                )
                    a.menuOptions.details[a.menuOptions.childID].colors[o] == t &&
                        ((a.menuOptions.details[a.menuOptions.childID].colors[o] = e),
                        -1 != p[0].innerHTML.indexOf(t + '" data-color="' + o + '"')
                            ? (p[0].innerHTML = p[0].innerHTML.replaceAll(
                                  t + '" data-color="' + o + '"',
                                  e + '" data-color="' + o + '"'
                              ))
                            : -1 != p[0].innerHTML.indexOf(t.toUpperCase() + '" data-color="' + o + '"')
                              ? (p[0].innerHTML = p[0].innerHTML.replaceAll(
                                    t.toUpperCase() + '" data-color="' + o + '"',
                                    e + '" data-color="' + o + '"'
                                ))
                              : ((p[0].innerHTML = p[0].innerHTML.replaceAll(t + '"', e + '" data-color="' + o + '"')),
                                (p[0].innerHTML = p[0].innerHTML.replaceAll(
                                    t.toUpperCase() + '"',
                                    e + '" data-color="' + o + '"'
                                ))));
                else
                    for (let o = 0; o < a.menuOptions.details[a.menuOptions.childID].colors.length; o++)
                        a.menuOptions.details[a.menuOptions.childID].colors[o] == t &&
                            ((a.menuOptions.details[a.menuOptions.childID].colors[o] = e),
                            (p[0].innerHTML = p[0].innerHTML.replaceAll(t, e)),
                            (p[0].innerHTML = p[0].innerHTML.replaceAll(t.toUpperCase(), e)));
                let r = s.attr("id");
                i.push(r);
            }
            let s = {};
            (s.undo = { action: "updateColor", target: i, value: { old: e, new: t } }),
                (s.redo = { action: "updateColor", target: i, value: { old: t, new: e } }),
                a.setHistory(s);
        },
        async addArtwork(t) {
            let e = this;
            (e.waitDesign = !0), (e.listMenus.artwork.options.values.loadArt = t.id);
            let o = "artwork-" + t.id,
                a = "";
            void 0 !== e.photoStores[o] && (a = e.photoStores[o]);
            let p = "pdapp-target-" + pdappAPI.tool.uID();
            if ("" == a && void 0 === t.artFile) {
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-artwork&id=" +
                    t.id +
                    "&type=" +
                    t.filetype +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let e = await pdappAPI.tool.getData(o);
                    t.artFile = e.data;
                } catch (t) {
                    return -1 == t.error
                        ? ((e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmReload",
                          }),
                          !1)
                        : ((e.toast = { show: !0, type: "error", text: t.msg }),
                          setTimeout(() => {
                              e.toast.show = !1;
                          }, 5e3),
                          (e.listMenus.artwork.options.values.loadArt = !1),
                          (e.waitDesign = !1),
                          !1);
                }
            }
            "" == a && (a = t),
                pdappAPI.artwork.create(
                    a,
                    t.filetype,
                    function (a, p) {
                        e.activeLayer(a);
                        let i = a.attr("id");
                        a.attr("data-artid", t.id), (e.artworkStore["art-" + t.id] = t.price);
                        let s = "";
                        "svg" != t.filetype &&
                            void 0 !== p &&
                            ((s = { id: o, crop: "" }),
                            (e.photoStores[i] = s),
                            void 0 === e.photoStores[o] && (e.photoStores[o] = p)),
                            setTimeout(() => {
                                pdappAPI.photo.fitPhotoInside();
                                let t = {};
                                t.undo = { action: "deletePhoto", target: i };
                                let o = a.parent("g.pdapp-g-photo");
                                0 == o.length && (o = a),
                                    (t.redo = {
                                        action: "createPhoto",
                                        target: i,
                                        index: pdappAPI.history.getIndex(a),
                                        value: s,
                                        svg: o.clone(),
                                    }),
                                    e.setHistory(t),
                                    (e.listMenus.artwork.options.values.loadArt = !1),
                                    (e.waitDesign = !1);
                            }, 2);
                    },
                    p
                );
        },
        copyArtwork() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deletePhoto", target: e }),
                pdappAPI.artwork.copy(t.langs.options, function (a) {
                    t.activeLayer(a);
                    let p = void 0 !== t.photoStores[e] ? t.photoStores[e] : "",
                        i = a.parent("g.pdapp-g-photo");
                    0 == i.length && (i = a),
                        (o.redo = {
                            action: "createPhoto",
                            target: a.attr("id"),
                            index: pdappAPI.history.getIndex(a),
                            value: p,
                            svg: i.clone(),
                        }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_artwork_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        deleteArtwork() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = void 0 !== t.photoStores[o] ? t.photoStores[o] : "",
                p = {},
                i = e.parent("g.pdapp-g-photo");
            0 == i.length && (i = e),
                (p.undo = {
                    action: "createPhoto",
                    target: o,
                    index: pdappAPI.history.getIndex(e),
                    value: a,
                    svg: i.clone(),
                }),
                pdappAPI.photo.delete(function (e) {
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        t.responsiveLayout.showMenu || (t.activeMenu = null),
                        void 0 !== t.photoStores[e] && delete t.photoStores[e],
                        (p.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(p);
                });
        },
        changePhoto(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const o = t.target.files[0];
            let a = pdappAPI.upload.verify(o, e.settings, e.langs);
            if ("" === a) return e.startUploadPhoto(o), jQuery("#pdapp-upload-a-photo").val(""), !1;
            (e.toast = { show: !0, type: "error", text: a }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3);
        },
        startUploadPhoto(t) {
            let e = this;
            (e.uploading = !0), (e.loadingPage = !0), (e.waitDesign = !0);
            let o = "pdapp-target-" + pdappAPI.tool.uID();
            if ("image/svg+xml" == t.type)
                pdappAPI.upload.readFile(t, function (t) {
                    let a = t.split("base64,"),
                        p = pdappAPI.tool.decodeBase64(a[1]);
                    pdappAPI.photo.create(
                        p,
                        function (t) {
                            (e.uploading = !1),
                                (e.loadingPage = !1),
                                e.activeLayer(t),
                                setTimeout(() => {
                                    pdappAPI.photo.fitPhotoInside(),
                                        jQuery(document).trigger("after_create_svg", { self: e });
                                    let a = {};
                                    a.undo = { action: "deletePhoto", target: o };
                                    let p = t.parent("g.pdapp-g-photo");
                                    0 == p.length && (p = t),
                                        (a.redo = {
                                            action: "createPhoto",
                                            target: o,
                                            index: pdappAPI.history.getIndex(t),
                                            value: "",
                                            svg: p.clone(),
                                        }),
                                        e.setHistory(a),
                                        "photo" == e.activeMenu && (e.listMenus.photo.options.values.loadArt = !1),
                                        (e.waitDesign = !1);
                                }, 10);
                        },
                        o,
                        "svg"
                    );
                });
            else {
                let o = "pdapp-target-" + pdappAPI.tool.uID(),
                    a = "file-" + t.lastModified + "-" + t.size;
                if (void 0 !== e.photoStores[a]) {
                    let t = e.photoStores[a];
                    (e.photoStores[a].target = o), e.createPhoto(t, a, o), (e.waitDesign = !1);
                } else
                    (e.photoStores[a] = {}),
                        pdappAPI.photo.readMediumImage(
                            t,
                            function (p) {
                                (e.photoStores[a] = p),
                                    e.uploadImage(a, t),
                                    (e.photoStores[a].target = o),
                                    e.createPhoto(p, a, o);
                            },
                            0.85
                        );
            }
        },
        async uploadImage(t, e) {
            let o = this;
            o.waitDesign = !0;
            let a =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-upload-image&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            if ("undefined" != typeof pdappWorker && pdappWorker) {
                let o = { id: t, file: e };
                pdappWorker.postMessage({ post: o, action: "uploadImage", value: a });
            } else {
                let p = { id: t, action: "getPhoto", type: "origin", value: !1, post: { id: t, file: e } };
                try {
                    let o = new FormData();
                    o.append("id", t), o.append("file", e);
                    let i = await pdappAPI.upload.uploadFile(a, o);
                    p.value = i.data;
                } catch (t) {}
                o.actionWorker(p);
            }
        },
        getPhotos() {
            let t = this;
            void 0 !== t.settings.general.photo &&
                void 0 !== t.settings.general.photo.library &&
                ((t.listMenus.photo.loading = 1),
                pdappAPI.photo.getPhotos(t.settings.general.photo, t.listMenus.photo, function (e) {
                    if (1 == t.listMenus.photo.page)
                        (t.listMenus.photo.options.values = e), jQuery(".pdapp-photo-libraries").scrollTop(0);
                    else for (let o = 0; o < e.length; o++) t.listMenus.photo.options.values.push(e[o]);
                    (t.listMenus.photo.loading = 0),
                        (t.listMenus.photo.page = parseInt(t.listMenus.photo.page) + 1),
                        setTimeout(() => {
                            pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                t.getPhotos();
                            });
                        }, 1);
                }));
        },
        findPhotos() {
            (this.listMenus.photo.page = 1), this.getPhotos();
        },
        addPhoto(t) {
            let e = this;
            if (
                ((e.loadingPage = !0),
                (e.waitDesign = !0),
                (e.listMenus.photo.loading = 1),
                void 0 !== e.photoStores[t.id] && void 0 !== e.photoStores[t.id].id)
            ) {
                let o = e.photoStores[t.id],
                    a = "pdapp-target-" + pdappAPI.tool.uID();
                (e.photoStores[t.id].target = a), e.createPhoto(o, t.id, a), (e.waitDesign = !1);
            } else {
                e.photoStores[t.id] = {};
                let o = { id: t.id, action: "getPhoto", type: "blob", value: t.regular };
                "undefined" != typeof pdappWorker && pdappWorker
                    ? pdappWorker.postMessage(o)
                    : pdappAPI.photo.getPhoto(url, function (t) {
                          (o.value = t), e.actionWorker(o);
                      }),
                    setTimeout(() => {
                        e.loadOriginPhoto(t.id, t.url);
                    }, 10);
            }
        },
        createPhoto(t, e, o) {
            let a = this;
            pdappAPI.photo.create(
                t,
                function (t) {
                    (a.uploading = !1),
                        (a.loadingPage = !1),
                        (a.listMenus.photo.loading = 0),
                        a.activeLayer(t),
                        setTimeout(() => {
                            pdappAPI.photo.fitPhotoInside(),
                                jQuery(document).trigger("after_create_photo", { self: a }),
                                (a.photoStores[o] = { id: e, crop: "" });
                            let p = a.history.values.length,
                                i = {};
                            i.undo = { action: "deletePhoto", target: o };
                            let s = t.parent("g.pdapp-g-photo");
                            0 == s.length && (s = t),
                                (i.redo = {
                                    action: "createPhoto",
                                    target: o,
                                    index: pdappAPI.history.getIndex(t),
                                    value: a.photoStores[o],
                                    svg: s.clone(),
                                }),
                                a.setHistory(i),
                                a.settings.layout.photo.crop && a.dropdownPhoto("crop", p);
                        }, 10);
                },
                o,
                t.color
            );
        },
        loadOriginPhoto(t, e) {
            let o = this;
            o.waitDesign = !0;
            let a =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-load-image&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce,
                p = { id: t, url: e };
            if ("undefined" != typeof pdappWorker && pdappWorker)
                pdappWorker.postMessage({ post: p, action: "uploadImage", value: a });
            else {
                let e = { id: t, action: "getPhoto", type: "origin", value: !1, post: p };
                try {
                    let t = pdappAPI.tool.postData(a, p);
                    e.value = t.data;
                } catch (t) {}
                o.actionWorker(e);
            }
        },
        closePhotoDropdown() {
            this.menuOptions.details[this.menuOptions.childID].dropdown = "";
        },
        dropdownPhoto(t, e, o) {
            let a = this;
            if (a.menuOptions.details[a.menuOptions.childID].dropdown == t)
                return (a.menuOptions.details[a.menuOptions.childID].dropdown = ""), !1;
            if ("crop" == t) {
                let t = void 0 !== o && "replace" == o,
                    p = pdappAPI.photo.getCrop(t);
                return (
                    (a.modal = {
                        show: !0,
                        header: !0,
                        size: "full-width",
                        title: a.langs.options.crop_photo,
                        type: "crop",
                        data: p,
                        hisID: e,
                        replace: t,
                    }),
                    t ||
                        void 0 === a.photoStores[p.id] ||
                        "" == a.photoStores[p.id].crop ||
                        (a.modal.data = a.photoStores[p.id].crop),
                    jQuery(document).trigger("after_show_crop", { self: a }),
                    !1
                );
            }
            "color" == t &&
                a.menuOptions.details[a.menuOptions.childID].editColor &&
                a.menuOptions.details[a.menuOptions.childID].colors.length &&
                setTimeout(() => {
                    pdappAPI.tool.colorPicker(".pdapp-edit-color", a.langs.options, function (t, e) {
                        (oldcolor = jQuery(t).attr("data-color")), a.updateColor(oldcolor, e);
                    });
                }, 1),
                (a.menuOptions.details[a.menuOptions.childID].dropdown = t);
        },
        useOriginPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id");
            if (
                void 0 !== t.photoStores[o] &&
                "" != t.photoStores[o].crop &&
                void 0 !== t.photoStores[t.photoStores[o].id]
            ) {
                let a = {};
                (a.undo = {
                    action: "cropPhoto",
                    target: o,
                    value: t.photoStores[o].crop,
                    svg: jQuery("#" + o).clone(),
                }),
                    pdappAPI.photo.originPhoto(e, t.photoStores[t.photoStores[o].id], function (e) {
                        (t.menuOptions.details[t.menuOptions.childID].photo = e),
                            (t.photoStores[o].crop = ""),
                            (a.redo = { action: "cropPhoto", target: o, value: "", svg: jQuery("#" + o).clone() }),
                            t.setHistory(a);
                    });
            }
            t.modal.show = !1;
        },
        cropPhoto() {
            let t = this;
            if (t.waitDesign) return !1;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id");
            if (void 0 === t.photoStores[e]) return !1;
            (t.loadingPage = !0), (t.waitDesign = !0);
            let o = void 0 !== t.photoStores[e].crop ? t.photoStores[e].crop : "",
                a = {},
                p = t.modal.hisID;
            "" === p && (a.undo = { action: "cropPhoto", target: e, value: o, svg: jQuery("#" + e).clone() }),
                pdappAPI.photo.crop(t.shapePhoto, t.modal.replace, function (o, i) {
                    if (((t.loadingPage = !1), void 0 === o.blob || "" == o.blob)) return !1;
                    let s =
                        void 0 !== t.modal.data.origin
                            ? t.modal.data.origin
                            : t.photoStores[t.photoStores[e].id].origin;
                    if (
                        ((o.origin = s),
                        (t.modal.show = !1),
                        (t.menuOptions.details[t.menuOptions.childID].photo = o.blob),
                        (t.photoStores[e].crop = o),
                        "" === p)
                    )
                        (a.redo = { action: "cropPhoto", target: i, value: o, svg: jQuery("#" + i).clone() }),
                            t.setHistory(a);
                    else if (
                        void 0 !== t.history.values[p] &&
                        ("createPhoto" == t.history.values[p].redo.action ||
                            "replacePhoto" == t.history.values[p].redo.action)
                    ) {
                        t.history.values[p].redo.value = JSON.parse(JSON.stringify(t.photoStores[e]));
                        let o = jQuery("#" + e).parent("g.pdapp-g-photo");
                        0 == o.length && (o = jQuery("#" + e)), (t.history.values[p].redo.svg = o.clone());
                    }
                    setTimeout(() => {
                        "" === p && (p = t.history.values.length - 1), t.cropOriginPhoto(e, o, p);
                    }, 1);
                });
        },
        cropOriginPhoto(t, e, o) {
            let a = this;
            if (void 0 !== e.width)
                if (
                    void 0 !== a.photoStores[t] &&
                    void 0 !== a.photoStores[a.photoStores[t].id] &&
                    void 0 !== a.photoStores[a.photoStores[t].id].origin &&
                    a.photoStores[a.photoStores[t].id].origin
                ) {
                    let p =
                            pdappAdminUrl +
                            "admin-ajax.php?action=pdapp-crop-image&admin=0&pdapp-token=" +
                            pdappToken +
                            "&pdapp-nonce=" +
                            pdappNonce,
                        i = {
                            id: t,
                            file:
                                void 0 !== a.modal.data.origin
                                    ? a.modal.data.origin
                                    : a.photoStores[a.photoStores[t].id].origin,
                            hisID: o,
                            origW: a.modal.data.width,
                            crop: JSON.stringify({ top: e.top, left: e.left, width: e.width, height: e.height }),
                        };
                    if ("undefined" != typeof pdappWorker && pdappWorker)
                        pdappWorker.postMessage({ post: i, action: "cropImage", value: p });
                    else {
                        let e = { id: t, action: "cropImage", type: "origin", value: !1, post: i };
                        try {
                            let t = pdappAPI.tool.postData(p, i);
                            e.value = t.data;
                        } catch (t) {}
                        a.actionWorker(e);
                    }
                } else void 0 !== a.photoStores[t] && void 0 !== a.photoStores[t].id && (a.waitDesign = !1);
        },
        changeCropRatio() {
            pdappAPI.photo.changeCropRatio(this.modal.data.ratio);
        },
        showReplacePhoto() {
            let t = this;
            return (
                "photo" == t.activeMenu &&
                null != t.menuOptions.childID &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID] &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID].clickUpload &&
                !(
                    !t.menuOptions.details[t.menuOptions.childID].clickUpload &&
                    !t.menuOptions.details[t.menuOptions.childID].clickPhoto
                ) &&
                (t.menuOptions.details[t.menuOptions.childID].clickPhoto
                    ? ((t.modal = {
                          show: !0,
                          header: !0,
                          size: "lg modal-dialog-scrollable",
                          title: t.langs.options.replace_photo,
                          type: "replacePhoto",
                          data: "",
                      }),
                      void setTimeout(() => {
                          pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                              t.getPhotos();
                          });
                      }, 1))
                    : (setTimeout(() => {
                          jQuery("#pdapp-upload-a-photo-replace").trigger("click");
                      }, 200),
                      !1))
            );
        },
        changePhotoReplace(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files[0];
            let p = JSON.parse(JSON.stringify(e.settings));
            p.general.upload.type = ["png", "jpg", "jpeg"];
            let i = pdappAPI.upload.verify(a, p, e.langs);
            if ("" === i) {
                (e.loadingPage = !0), (e.waitDesign = !0);
                let t = "file-" + a.lastModified + "-" + a.size;
                if (void 0 !== e.photoStores[t]) {
                    let a = e.photoStores[t];
                    e.replacePhoto(a, t, o), (e.waitDesign = !1);
                } else
                    (e.photoStores[t] = {}),
                        pdappAPI.photo.readMediumImage(
                            a,
                            function (p) {
                                (e.photoStores[t] = p), e.uploadImage(t, a), e.replacePhoto(p, t, o);
                            },
                            0.85
                        );
                return jQuery("#pdapp-upload-a-photo-replace").val(""), !1;
            }
            (e.toast = { show: !0, type: "error", text: i }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3);
        },
        replacePhoto(t, e, o) {
            let a = this,
                p = o.attr("id"),
                i = a.history.values.length,
                s = {};
            (s.undo = { action: "replacePhoto", target: p, value: a.photoStores[p], svg: o.clone() }),
                pdappAPI.photo.replace(t, o, function () {
                    (a.loadingPage = !1),
                        (a.uploading = !1),
                        (a.listMenus.photo.loading = 0),
                        (a.photoStores[p] = { id: e, crop: "" }),
                        (s.redo = { action: "replacePhoto", target: p, value: a.photoStores[p], svg: o.clone() }),
                        a.setHistory(s),
                        a.dropdownPhoto("crop", i, "replace"),
                        o.removeClass("pdapp-showupload"),
                        "photo" == a.activeMenu &&
                            null != a.menuOptions.childID &&
                            void 0 !== a.menuOptions.details[a.menuOptions.childID] &&
                            void 0 !== a.menuOptions.details[a.menuOptions.childID].clickShowUpload &&
                            (a.menuOptions.details[a.menuOptions.childID].clickShowUpload = !1);
                });
        },
        addPhotoReplace(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            if (
                ((e.loadingPage = !0),
                (e.waitDesign = !0),
                (e.listMenus.photo.loading = 1),
                void 0 !== e.photoStores[t.id])
            ) {
                let a = e.photoStores[t.id];
                e.replacePhoto(a, t.id, o), (e.waitDesign = !1);
            } else {
                e.photoStores[t.id] = {};
                let o = { id: t.id, action: "getPhotoReplace", type: "blob", value: t.regular };
                "undefined" != typeof pdappWorker && pdappWorker
                    ? pdappWorker.postMessage(o)
                    : pdappAPI.photo.getPhoto(t.regular, function (t) {
                          (o.value = t), e.actionWorker(o);
                      }),
                    setTimeout(() => {
                        e.loadOriginPhoto(t.id, t.url, "getPhotoReplace");
                    }, 10);
            }
        },
        fitPhotoInside() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                pdappAPI.photo.fitPhotoInside(),
                setTimeout(() => {
                    (a.redo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                        t.setHistory(a);
                });
        },
        fitPhotoOutside() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                pdappAPI.photo.fitPhotoOutside(),
                setTimeout(() => {
                    (a.redo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                        t.setHistory(a);
                });
        },
        updatePhotoStyle(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            if (void 0 !== e.menuOptions.details[e.menuOptions.childID][t] && "transparency" == t) {
                let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                    a = o.attr("id"),
                    p = {};
                (p.undo = { action: "opacity", target: a, value: o.attr("opacity") }),
                    pdappAPI.photo.updatePhotoStyle(t, e.menuOptions.details[e.menuOptions.childID][t]),
                    (p.redo = { action: "opacity", target: a, value: e.menuOptions.details[e.menuOptions.childID][t] }),
                    e.setHistory(p);
            }
        },
        addShape(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = a + "-shape",
                i = {};
            (i.path = o.attr("clip-path")), (i.slug = o.attr("data-shape"));
            let s = "";
            void 0 === i.path && (i.path = ""), void 0 === i.slug ? (i.slug = "") : (s = jQuery("#" + p).clone());
            let r = {};
            (r.undo = { action: "addShape", target: a, value: i, svg: s }),
                pdappAPI.photo.addShape(t, function () {
                    (e.menuOptions.details[e.menuOptions.childID].photoShape = "" == t ? "" : t.slug),
                        (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target));
                    let p = { path: "", slug: "" },
                        i = "";
                    "" != t &&
                        ((p.path = o.attr("clip-path")),
                        (p.slug = t.slug),
                        (i = 0 != o.find("defs").length ? o.find("defs").clone() : "")),
                        (r.redo = { action: "addShape", target: a, value: p, svg: i }),
                        e.setHistory(r),
                        "mobile" == e.responsiveLayout.screenSize && e.closePhotoDropdown();
                });
        },
        addFilter(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = o.attr("data-filter");
            void 0 === p && (p = "");
            let i = {};
            (i.undo = { action: "addFilter", target: a, value: p, svg: "" }),
                pdappAPI.photo.addFilter(t, function () {
                    (e.menuOptions.details[e.menuOptions.childID].photoFilter = "" == t ? "" : t.slug),
                        (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target));
                    let p = "",
                        s = "";
                    if ("" != t) {
                        p = o.attr("data-filter");
                        let t = o.parent("g.pdapp-g-photo");
                        s = 0 != t.length && 0 != t.find("defs").length ? t.find("defs").clone() : "";
                    }
                    (i.redo = { action: "addFilter", target: a, value: p, svg: s }),
                        e.setHistory(i),
                        setTimeout(() => {
                            e.setSvgStyle(), "mobile" == e.responsiveLayout.screenSize && e.closePhotoDropdown();
                        }, 10);
                });
        },
        alignPhoto(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.photo.alignPhoto(t),
                setTimeout(() => {
                    (p.redo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        movePhoto(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.photo.movePhoto(t),
                setTimeout(() => {
                    (p.redo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        deletePhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = void 0 !== t.photoStores[o] ? t.photoStores[o] : "",
                p = {},
                i = e.parent("g.pdapp-g-photo");
            0 == i.length && (i = e),
                (p.undo = {
                    action: "createPhoto",
                    target: o,
                    index: pdappAPI.history.getIndex(e),
                    value: a,
                    svg: i.clone(),
                }),
                pdappAPI.photo.delete(function (e) {
                    void 0 !== t.photoStores[e] && delete t.photoStores[e],
                        t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        t.responsiveLayout.showMenu || (t.activeMenu = null),
                        (p.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(p),
                        setTimeout(() => {
                            t.setSvgStyle();
                        }, 1);
                });
        },
        lockPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = {
                action: "lockPhoto",
                target: e,
                value: t.menuOptions.details[t.menuOptions.childID].photoLock,
            }),
                pdappAPI.photo.lock(t.menuOptions.details[t.menuOptions.childID].photoLock, function (a) {
                    (t.menuOptions.details[t.menuOptions.childID].photoLock = a),
                        (o.redo = { action: "lockPhoto", target: e, value: a }),
                        t.setHistory(o);
                });
        },
        copyPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.photo.copy(t.langs.options, function (e, o) {
                t.activeLayer(e),
                    (t.toast = { show: !0, type: "success", text: t.langs.options.copy_photo_success }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
                let a = e.attr("id"),
                    p = {};
                (p.undo = { action: "deletePhoto", target: a }),
                    void 0 !== t.photoStores[o] && (t.photoStores[a] = JSON.parse(JSON.stringify(t.photoStores[o])));
                let i = e.parent("g.pdapp-g-photo");
                0 == i.length && (i = e),
                    (p.redo = {
                        action: "createPhoto",
                        target: a,
                        index: pdappAPI.history.getIndex(e),
                        value: t.photoStores[a],
                        svg: i.clone(),
                    }),
                    t.setHistory(p);
            });
        },
        flipPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.photo.flip(t.menuOptions.details[t.menuOptions.childID].photoFlip, function (e) {
                let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                    a = {};
                (a.undo = { action: "flipPhoto", target: o, value: e }),
                    (t.menuOptions.details[t.menuOptions.childID].photoFlip = e),
                    (a.redo = { action: "flipPhoto", target: o, value: !e }),
                    t.setHistory(a);
            });
        },
        confirmMembers(t) {
            let e = this,
                o = JSON.parse(JSON.stringify(e.listMenus.team.options.values.teams));
            if (o.length > 0) {
                let a = [];
                if ("edit" != t) {
                    let p = 0;
                    for (let i = 0; i < o.length; i++) {
                        p <= i && p++;
                        let s = ("" + p).length < 2 ? "0" + p : "" + p;
                        "name" == t && void 0 === o[i].name && (o[i].name = ""),
                            "number" == t && void 0 === o[i].number && (o[i].number = s);
                        let r = {};
                        ("name" == t ||
                            (void 0 !== e.listMenus.team.options.values.name &&
                                "" != e.listMenus.team.options.values.name)) &&
                            (r.name = o[i].name),
                            ("number" == t ||
                                (void 0 !== e.listMenus.team.options.values.number &&
                                    e.listMenus.team.options.values.number.length > 0)) &&
                                (r.number = o[i].number),
                            a.push(r);
                    }
                } else
                    for (let t = 0; t < o.length; t++) {
                        let p = {};
                        void 0 !== e.listMenus.team.options.values.name &&
                            "" != e.listMenus.team.options.values.name &&
                            (p.name = o[t].name),
                            void 0 !== e.listMenus.team.options.values.number &&
                                e.listMenus.team.options.values.number.length > 0 &&
                                (p.number = o[t].number),
                            a.push(p);
                    }
                e.modal = {
                    show: !0,
                    header: !0,
                    size: "lg",
                    title: e.langs.options.your_team,
                    type: "confirmTeam",
                    member: o.length,
                    addType: t,
                    data: a,
                };
            } else
                e.modal = {
                    show: !0,
                    header: !0,
                    size: "md",
                    title: e.langs.options.your_team,
                    type: "confirmMember",
                    member: o.length,
                    addType: t,
                    data: o,
                };
            e.responsiveLayout.showMenu || (e.activeMenu = null);
        },
        setMembers() {
            let t = this,
                e = void 0 !== t.modal.data[0] && void 0 !== t.modal.data[0].name,
                o = void 0 !== t.modal.data[0] && void 0 !== t.modal.data[0].number;
            "name" == t.modal.addType ? (e = !0) : "number" == t.modal.addType && (o = !0);
            let a = 0;
            if (o)
                for (let e = 0; e < t.modal.data.length; e++) {
                    let o = parseInt(t.modal.data[e].number);
                    o > a && (a = o);
                }
            for (let p = 0; p < t.modal.member; p++) {
                if (
                    "edit" == t.modal.addType &&
                    void 0 !== t.listMenus.team.options.values &&
                    void 0 !== t.listMenus.team.options.values.teams &&
                    t.listMenus.team.options.values.teams.length
                ) {
                    let p = JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams));
                    for (let i = 0; i < p.length; i++)
                        if (t.modal.data.length <= i) {
                            let s = {};
                            if (
                                (void 0 !== p[i].name
                                    ? ((s.name = p[i].name), (e = !0))
                                    : void 0 === p[i].number && ((s.name = ""), (e = !0)),
                                void 0 !== p[i].number)
                            ) {
                                let t = parseInt(p[i].number);
                                (s.number = ("" + t).length < 2 ? "0" + t : "" + t), t > a && (a = t), (o = !0);
                            }
                            t.modal.data.push(s);
                        }
                } else "edit" == t.modal.addType && ((e = !0), (t.modal.addType = "name"));
                if (t.modal.data.length <= p) {
                    let p = {};
                    e && (p.name = ""),
                        o && (a++, (p.number = ("" + a).length < 2 ? "0" + a : "" + a)),
                        t.modal.data.push(p);
                }
            }
            (t.modal.size = "lg"), (t.modal.type = "confirmTeam");
        },
        resetMember() {
            let t = this,
                e = [];
            if (
                (void 0 !== t.listMenus.team.options.values &&
                    void 0 !== t.listMenus.team.options.values.number &&
                    t.listMenus.team.options.values.number.length &&
                    (e = JSON.parse(JSON.stringify(t.listMenus.team.options.values.number))),
                void 0 !== t.listMenus.team.options.values &&
                    void 0 !== t.listMenus.team.options.values.name &&
                    e.push(t.listMenus.team.options.values.name),
                0 == e.length)
            )
                return !1;
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (t.menuOptions.childID = null),
                t.responsiveLayout.showMenu || (t.activeMenu = null);
            for (let o = 0; o < e.length; o++) {
                let a = e[o],
                    p = jQuery("#" + a),
                    i = p.hasClass("pdapp-team-number") ? "number" : "name";
                if ((p.remove(), "name" == i && (t.listMenus.team.options.values.name = ""), "number" == i))
                    for (let e = 0; e < t.listMenus.team.options.values.number.length; e++)
                        t.listMenus.team.options.values.number[e] == a &&
                            t.listMenus.team.options.values.number.splice(e, 1);
            }
            setTimeout(() => {
                (t.modal.type = "confirmMember"),
                    (t.modal.data = []),
                    (t.listMenus.team.options.values.teams = []),
                    (t.productCart.team = { qty: 0, items: [] }),
                    t.setSvgStyle(),
                    t.updateCartTeam();
            }, 1);
        },
        removeMember(t) {
            let e = this;
            e.modal.data.splice(t, 1),
                (e.modal.member = e.modal.data.length),
                0 == e.modal.member && ((e.modal.size = "md"), (e.modal.type = "confirmMember"));
        },
        addYourName() {
            this.confirmMembers("name");
        },
        addYourNumber() {
            let t = this;
            void 0 !== t.listMenus.team.options.values.number && 0 == t.listMenus.team.options.values.number.length
                ? t.confirmMembers("number")
                : t.createNewTeam("number");
        },
        activeMember(t) {
            let e = this;
            if (0 == e.listMenus.team.options.values.teams.length) return !1;
            (e.listMenus.team.options.values.active = t), e.updateTeam();
        },
        updateTeam() {
            let t = this,
                e = t.listMenus.team.options.values,
                o = e.active;
            if (void 0 === e.teams[o]) return !1;
            if (void 0 !== e.name && "" != e.name && void 0 !== e.teams[o].name) {
                let a = jQuery("#" + e.name)
                    .parents("#pdapp-viewer-area .pdapp-viewport")
                    .index();
                a == jQuery("#pdapp-viewer-area .pdapp-viewport.active").index()
                    ? pdappAPI.team.updateMember(e.name, "name", e.teams[o].name, o)
                    : (t.changeProductView(a),
                      setTimeout(() => {
                          pdappAPI.team.updateMember(e.name, "name", e.teams[o].name, o);
                      }, 50));
            }
            void 0 !== e.number &&
                "" != e.number &&
                void 0 !== e.teams[o].number &&
                pdappAPI.team.updateMember(e.number, "number", e.teams[o].number, o);
        },
        updateMember() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = t.menuOptions.details[t.menuOptions.childID].text,
                o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            e.length < 1 &&
                ((t.menuOptions.details[t.menuOptions.childID].text = o.attr("data-text").substring(0, 1)),
                (e = t.menuOptions.details[t.menuOptions.childID].text));
            let a = o.hasClass("pdapp-team-name") ? "name" : "number",
                p = t.listMenus.team.options.values,
                i = {};
            (i.undo = { action: "updateMember", target: o.attr("id"), active: p.active, value: o.attr("data-text") }),
                pdappAPI.team.updateMember(p[a], a, e),
                (t.listMenus.team.options.values.teams[p.active][a] = e),
                (i.redo = { action: "updateMember", target: o.attr("id"), active: p.active, value: e }),
                t.setHistory(i);
        },
        applyTeams() {
            let t = this;
            if (t.checkApplyTeam) return !1;
            let e = JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams));
            (t.listMenus.team.options.values.teams = t.modal.data),
                (void 0 !== t.listMenus.team.options.values.active &&
                    void 0 !== t.listMenus.team.options.values.teams[t.listMenus.team.options.values.active]) ||
                    (t.listMenus.team.options.values.active = 0);
            let o = !0;
            if (
                ("name" == t.modal.addType &&
                    "" == t.listMenus.team.options.values.name &&
                    (t.createNewTeam(t.modal.addType, e), (o = !1)),
                "number" == t.modal.addType &&
                    0 == t.listMenus.team.options.values.number.length &&
                    (t.createNewTeam(t.modal.addType, e), (o = !1)),
                o)
            ) {
                t.updateTeam();
                let o = {};
                (o.undo = {
                    action: "updateTeam",
                    target: "",
                    active: t.listMenus.team.options.values.active,
                    value: e,
                }),
                    (o.redo = {
                        action: "updateTeam",
                        target: "",
                        active: t.listMenus.team.options.values.active,
                        value: JSON.parse(JSON.stringify(t.modal.data)),
                    }),
                    t.setHistory(o),
                    setTimeout(() => {
                        t.updateCartTeam();
                    }, 100);
            }
            t.modal.show = !1;
        },
        createNewTeam(t, e) {
            let o = this;
            if (0 == o.listMenus.team.options.values.teams.length) return !1;
            (void 0 !== o.listMenus.team.options.values.active &&
                void 0 !== o.listMenus.team.options.values.teams[o.listMenus.team.options.values.active]) ||
                (o.listMenus.team.options.values.active = 0),
                "name" == t &&
                    (o.settings.general.team[t].text =
                        o.listMenus.team.options.values.teams[o.listMenus.team.options.values.active].name),
                "number" == t &&
                    (o.settings.general.team[t].text =
                        o.listMenus.team.options.values.teams[o.listMenus.team.options.values.active].number),
                void 0 === e && (e = []),
                (o.loadingPage = !0),
                pdappAPI.team.create(o.settings.general.team[t], t, function (a, p) {
                    let i = jQuery("#" + a);
                    o.selectFont(
                        { title: p.fontFamily, variants: ["700"], category: "" },
                        function () {
                            (o.loadingPage = !1),
                                "name" == t && (o.listMenus.team.options.values.name = a),
                                "number" == t && o.listMenus.team.options.values.number.push(a),
                                pdappAPI.team.setTargets(o.listMenus.team.options.values),
                                pdappAPI.layer.afterAdded(a),
                                o.activeLayer(i),
                                o.updateCartTeam();
                            let p = {};
                            (p.undo = {
                                action: "updateTeam",
                                target: a,
                                active: o.listMenus.team.options.values.active,
                                value: e,
                                svg: "",
                            }),
                                (p.redo = {
                                    action: "updateTeam",
                                    target: a,
                                    active: o.listMenus.team.options.values.active,
                                    value: JSON.parse(JSON.stringify(o.listMenus.team.options.values.teams)),
                                    svg: i.clone(),
                                }),
                                o.setHistory(p);
                        },
                        i
                    );
                });
        },
        deleteTeam() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            a.undo = {
                action: "updateTeam",
                target: o,
                active: t.listMenus.team.options.values.active,
                value: JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams)),
                svg: e.clone(),
            };
            let p = e.hasClass("pdapp-team-number") ? "number" : "name";
            pdappAPI.team.delete(function (e) {
                if (
                    (t.menuOptions.details.splice(t.menuOptions.childID, 1),
                    (t.menuOptions.childID = null),
                    t.responsiveLayout.showMenu || (t.activeMenu = null),
                    setTimeout(() => {
                        t.setSvgStyle();
                    }, 1),
                    "name" == p && (t.listMenus.team.options.values.name = ""),
                    "number" == p)
                )
                    for (let o = 0; o < t.listMenus.team.options.values.number.length; o++)
                        t.listMenus.team.options.values.number[o] == e &&
                            t.listMenus.team.options.values.number.splice(o, 1);
                "" == t.listMenus.team.options.values.name &&
                    0 == t.listMenus.team.options.values.number.length &&
                    ((t.listMenus.team.options.values.teams = []), (t.productCart.team = { qty: 0, items: [] })),
                    (a.redo = {
                        action: "updateTeam",
                        target: e,
                        active: t.listMenus.team.options.values.active,
                        value: JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams)),
                        svg: "",
                    }),
                    t.setHistory(a),
                    t.updateCartTeam();
            });
        },
        updateCartTeam() {
            let t = this,
                e = [];
            if (
                (void 0 !== t.productCart.team &&
                    void 0 !== t.productCart.team.items &&
                    (e = JSON.parse(JSON.stringify(t.productCart.team.items))),
                (t.productCart.team = { name: "", number: [], qty: 0, items: [] }),
                void 0 !== t.listMenus.team.options.values.name &&
                    (t.productCart.team.name = t.listMenus.team.options.values.name),
                void 0 !== t.listMenus.team.options.values.number &&
                    (t.productCart.team.number = t.listMenus.team.options.values.number),
                t.listMenus.team.options.values.teams.length)
            ) {
                let o = JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams));
                for (let a = 0; a < o.length; a++) {
                    let p = {};
                    void 0 !== t.listMenus.team.options.values.name &&
                        "" != t.listMenus.team.options.values.name &&
                        (p.name = o[a].name),
                        void 0 !== t.listMenus.team.options.values.number &&
                            t.listMenus.team.options.values.number.length > 0 &&
                            (p.number = o[a].number),
                        void 0 === e[a] && (e[a] = {}),
                        void 0 === e[a].size && (e[a].size = { size: 0, qty: 0 }),
                        (p.size = e[a].size),
                        t.productCart.team.items.push(p);
                }
            }
        },
        renderTeams() {
            let t = this;
            if (void 0 !== t.listMenus.team.options.values.teams && t.listMenus.team.options.values.teams.length) {
                if (t.designsTeam.length) return !1;
                (t.designsTeam = JSON.parse(JSON.stringify(t.listMenus.team.options.values.teams))),
                    (t.waitDesign = !0),
                    pdappAPI.download.renderTeams(t.listMenus.team.options.values.teams, function (e, o, a) {
                        a
                            ? (t.waitDesign = !1)
                            : void 0 !== t.designsTeam[e] &&
                              (void 0 === t.designsTeam[e].svg && (t.designsTeam[e].svg = []),
                              t.designsTeam[e].svg.push({ svg: o, loading: !1 }));
                    });
            }
        },
        changeQrcodeType() {
            let t = this;
            "text" == t.menuOptions.details[t.menuOptions.childID].qrtype
                ? (t.menuOptions.details[t.menuOptions.childID].text =
                      void 0 !== t.settings.general.qrcode.text && "" != t.settings.general.qrcode.text
                          ? t.settings.general.qrcode.text
                          : "Add your text content...")
                : "url" == t.menuOptions.details[t.menuOptions.childID].qrtype
                  ? (t.menuOptions.details[t.menuOptions.childID].text = "https://www.yourdomain.com")
                  : "phone" == t.menuOptions.details[t.menuOptions.childID].qrtype
                    ? (t.menuOptions.details[t.menuOptions.childID].text = "+1234567890")
                    : "sms" == t.menuOptions.details[t.menuOptions.childID].qrtype
                      ? ((t.menuOptions.details[t.menuOptions.childID].text = "+1234567890"),
                        (t.menuOptions.details[t.menuOptions.childID].message = t.langs.options.qrcode_message))
                      : "mail" == t.menuOptions.details[t.menuOptions.childID].qrtype &&
                        ((t.menuOptions.details[t.menuOptions.childID].text = "example@example.com"),
                        (t.menuOptions.details[t.menuOptions.childID].subject = t.langs.options.qrcode_subject),
                        (t.menuOptions.details[t.menuOptions.childID].message = t.langs.options.qrcode_message)),
                t.updateQrcode();
        },
        addQrcode() {
            let t = this;
            (t.loadingPage = !0),
                pdappAPI.qrcode.create(t.settings.general.qrcode, function (e) {
                    (t.loadingPage = !1), t.activeLayer(e);
                    let o = e.attr("id"),
                        a = {};
                    (a.undo = { action: "deletePhoto", target: o }),
                        (a.redo = {
                            action: "createPhoto",
                            target: o,
                            index: pdappAPI.history.getIndex(e),
                            value: "",
                            svg: e.clone(),
                        }),
                        t.setHistory(a);
                });
        },
        dropdownQrcode(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                setTimeout(() => {
                    "edit" == t &&
                        pdappAPI.tool.colorPicker("#pdapp-qrcode-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].color = o),
                                e.settings.layout.qrcode.type &&
                                    void 0 === e.menuOptions.details[e.menuOptions.childID].type &&
                                    (e.menuOptions.details[e.menuOptions.childID].type = "text"),
                                e.updateQrcode();
                        }),
                        "background" == t &&
                            "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                            pdappAPI.tool.colorPicker("#pdapp-qrcode-bg-colorpicker", e.langs.options, function (t, o) {
                                (e.menuOptions.details[e.menuOptions.childID].background = o), e.updateQrcode();
                            });
                }, 1);
        },
        changeUpdateQrcode(t, e) {
            let o = this;
            "background" == t
                ? jQuery("#pdapp-qrcode-background").prop("checked")
                    ? (jQuery("#pdapp-qrcode-bg-box .sp-container").remove(),
                      (o.menuOptions.details[o.menuOptions.childID].background = "transparent"))
                    : ((o.menuOptions.details[o.menuOptions.childID].background = "#ffffff"),
                      setTimeout(() => {
                          pdappAPI.tool.colorPicker("#pdapp-qrcode-bg-colorpicker", o.langs.options, function (t, e) {
                              (o.menuOptions.details[o.menuOptions.childID].background = e), o.updateQrcode();
                          });
                      }, 1))
                : (o.menuOptions.details[o.menuOptions.childID][t] = e),
                o.updateQrcode();
        },
        updateQrcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            void 0 !== t.menuOptions.details[t.menuOptions.childID].text &&
                0 == t.menuOptions.details[t.menuOptions.childID].text.length &&
                (t.menuOptions.details[t.menuOptions.childID].text = e.attr("data-text").substring(0, 1)),
                "mail" == t.menuOptions.details[t.menuOptions.childID].qrtype &&
                    0 == t.menuOptions.details[t.menuOptions.childID].subject.length &&
                    (t.menuOptions.details[t.menuOptions.childID].subject = e.attr("data-subject").substring(0, 1)),
                ("sms" != t.menuOptions.details[t.menuOptions.childID].qrtype &&
                    "mail" != t.menuOptions.details[t.menuOptions.childID].qrtype) ||
                    0 != t.menuOptions.details[t.menuOptions.childID].message.length ||
                    (t.menuOptions.details[t.menuOptions.childID].message = e.attr("data-message").substring(0, 1));
            let o = e.attr("id"),
                a = {};
            (a.undo = { action: "updateQr", target: o, svg: e.clone() }),
                pdappAPI.qrcode.update(t.menuOptions.details[t.menuOptions.childID], function (e) {
                    (a.redo = { action: "updateQr", target: o, svg: e.clone() }), t.setHistory(a);
                });
        },
        deleteQrcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = {
                action: "createPhoto",
                target: o,
                index: pdappAPI.history.getIndex(e),
                value: "",
                svg: e.clone(),
            }),
                pdappAPI.photo.delete(function (e) {
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        t.responsiveLayout.showMenu || (t.activeMenu = null),
                        (a.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(a);
                });
        },
        copyQrcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deletePhoto", target: e }),
                pdappAPI.qrcode.copy(t.langs.options, function (e) {
                    t.activeLayer(e),
                        (o.redo = {
                            action: "createPhoto",
                            target: e.attr("id"),
                            index: pdappAPI.history.getIndex(e),
                            value: "",
                            svg: e.clone(),
                        }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_qrcode_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        addBarcode() {
            let t = this;
            (t.loadingPage = !0),
                pdappAPI.barcode.create(t.settings.general.barcode, t.loadedFonts, function (e) {
                    (t.loadingPage = !1), t.activeLayer(e);
                    let o = e.attr("id"),
                        a = {};
                    (a.undo = { action: "deletePhoto", target: o }),
                        (a.redo = {
                            action: "createPhoto",
                            target: o,
                            index: pdappAPI.history.getIndex(e),
                            value: "",
                            svg: e.clone(),
                        }),
                        t.setHistory(a);
                });
        },
        dropdownBarcode(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                setTimeout(() => {
                    "edit" == t &&
                        pdappAPI.tool.colorPicker("#pdapp-barcode-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].lineColor = o), e.updateBarcode();
                        }),
                        "background" == t &&
                            "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                            pdappAPI.tool.colorPicker(
                                "#pdapp-barcode-bg-colorpicker",
                                e.langs.options,
                                function (t, o) {
                                    (e.menuOptions.details[e.menuOptions.childID].background = o), e.updateBarcode();
                                }
                            );
                }, 1);
        },
        checkBarcode() {
            let t = this,
                e = pdappAPI.barcode.checkBarcode(
                    t.menuOptions.details[t.menuOptions.childID].text,
                    t.menuOptions.details[t.menuOptions.childID].format,
                    t.langs.options
                );
            if ("" === e) return t.updateBarcode(), !1;
            (t.toast = { show: !0, type: "error", text: e }),
                setTimeout(() => {
                    t.toast.show = !1;
                }, 5e3);
        },
        changeUpdateBarcode(t, e) {
            let o = this;
            "background" == t
                ? jQuery("#pdapp-barcode-background").prop("checked")
                    ? (jQuery("#pdapp-barcode-bg-box .sp-container").remove(),
                      (o.menuOptions.details[o.menuOptions.childID].background = "transparent"))
                    : ((o.menuOptions.details[o.menuOptions.childID].background = "#ffffff"),
                      setTimeout(() => {
                          pdappAPI.tool.colorPicker("#pdapp-barcode-bg-colorpicker", o.langs.options, function (t, e) {
                              (o.menuOptions.details[o.menuOptions.childID].background = e), o.updateBarcode();
                          });
                      }, 1))
                : (o.menuOptions.details[o.menuOptions.childID][t] = e),
                o.updateBarcode();
        },
        updateBarcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            t.menuOptions.details[t.menuOptions.childID].width < 1 &&
                (t.menuOptions.details[t.menuOptions.childID].width = 1);
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "updateQr", target: o, svg: e.clone() }),
                pdappAPI.barcode.update(t.menuOptions.details[t.menuOptions.childID], t.loadedFonts, function (e) {
                    (a.redo = { action: "updateQr", target: o, svg: e.clone() }), t.setHistory(a);
                });
        },
        copyBarcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deletePhoto", target: e }),
                pdappAPI.barcode.copy(t.langs.options, function (e) {
                    t.activeLayer(e),
                        (o.redo = {
                            action: "createPhoto",
                            target: e.attr("id"),
                            index: pdappAPI.history.getIndex(e),
                            value: "",
                            svg: e.clone(),
                        }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_barcode_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        showSettingOption(t, e, o) {
            let a = this;
            if (t) {
                let p = 0;
                for (let t = 0; t < e.length; t++) {
                    let i = !1;
                    void 0 === o ||
                        ("text" != o && "team" != o) ||
                        void 0 === a.settings.layout ||
                        void 0 === a.settings.layout.text ||
                        ("font" != e[t] || a.settings.layout[o].font || (i = !0),
                        "size" != e[t] || a.settings.layout[o].size || (i = !0),
                        "color" != e[t] || a.settings.layout[o].color || (i = !0),
                        "arc" != e[t] ||
                            (a.settings.layout[o].arc &&
                                (null == a.menuOptions.childID ||
                                    void 0 !== a.menuOptions.details[a.menuOptions.childID].radius)) ||
                            (i = !0),
                        "space" != e[t] || a.settings.layout[o].space || (i = !0),
                        "outline" != e[t] || a.settings.layout[o].outline || (i = !0),
                        "transparent" != e[t] || a.settings.layout[o].transparent || (i = !0),
                        "bold" != e[t] || a.settings.layout[o].bold || (i = !0),
                        "italic" != e[t] || a.settings.layout[o].italic || (i = !0),
                        "underline" != e[t] || a.settings.layout[o].underline || (i = !0),
                        "strike" != e[t] || a.settings.layout[o].strike || (i = !0),
                        "uppercase" != e[t] || a.settings.layout[o].uppercase || (i = !0),
                        "style" != e[t] ||
                            a.settings.layout[o].bold ||
                            a.settings.layout[o].italic ||
                            a.settings.layout[o].underline ||
                            a.settings.layout[o].strike ||
                            a.settings.layout[o].uppercase ||
                            (i = !0),
                        "copy" != e[t] || a.settings.layout[o].copy || (i = !0),
                        "lock" != e[t] || a.settings.layout[o].lock || (i = !0),
                        "flip" != e[t] || a.settings.layout[o].flip || (i = !0),
                        "move" != e[t] || a.settings.layout[o].move || (i = !0)),
                        void 0 !== o &&
                            "art" == o &&
                            void 0 !== a.settings.layout &&
                            void 0 !== a.settings.layout.artwork &&
                            ("transparent" != e[t] || a.settings.layout.artwork.transparent || (i = !0),
                            "color" != e[t] ||
                                (a.settings.layout.artwork.color &&
                                    a.menuOptions.details[a.menuOptions.childID].editColor &&
                                    0 != a.menuOptions.details[a.menuOptions.childID].colors.length) ||
                                (i = !0),
                            "copy" != e[t] || a.settings.layout.artwork.copy || (i = !0),
                            "lock" != e[t] || a.settings.layout.artwork.lock || (i = !0),
                            "flip" != e[t] ||
                                (a.settings.layout.artwork.flip &&
                                    !a.menuOptions.details[a.menuOptions.childID].editColor) ||
                                (i = !0),
                            "move" != e[t] || a.settings.layout.artwork.move || (i = !0)),
                        void 0 !== o &&
                            "photo" == o &&
                            void 0 !== a.settings.layout &&
                            void 0 !== a.settings.layout.photo &&
                            ("shape" != e[t] ||
                                (a.settings.layout.photo.shape &&
                                    !a.menuOptions.details[a.menuOptions.childID].editColor) ||
                                (i = !0),
                            "transparent" != e[t] || a.settings.layout.photo.transparent || (i = !0),
                            "filter" != e[t] ||
                                (a.settings.layout.photo.filter &&
                                    !a.menuOptions.details[a.menuOptions.childID].editColor) ||
                                (i = !0),
                            "color" != e[t] ||
                                (a.settings.layout.photo.color &&
                                    a.menuOptions.details[a.menuOptions.childID].editColor &&
                                    0 != a.menuOptions.details[a.menuOptions.childID].colors.length) ||
                                (i = !0),
                            "copy" != e[t] || a.settings.layout.photo.copy || (i = !0),
                            "lock" != e[t] || a.settings.layout.photo.lock || (i = !0),
                            "crop" != e[t] ||
                                (a.settings.layout.photo.crop &&
                                    !a.menuOptions.details[a.menuOptions.childID].editColor) ||
                                (i = !0),
                            "flip" != e[t] ||
                                (a.settings.layout.photo.flip &&
                                    !a.menuOptions.details[a.menuOptions.childID].editColor) ||
                                (i = !0),
                            "move" != e[t] || a.settings.layout.photo.move || (i = !0)),
                        void 0 !== o &&
                            "qrcode" == o &&
                            void 0 !== a.settings.layout &&
                            void 0 !== a.settings.layout.qrcode &&
                            ("type" != e[t] || a.settings.layout.qrcode.type || (i = !0),
                            "color" != e[t] || a.settings.layout.qrcode.color || (i = !0),
                            "level" != e[t] || a.settings.layout.qrcode.level || (i = !0),
                            "background" != e[t] || a.settings.layout.qrcode.background || (i = !0),
                            "transparent" != e[t] || a.settings.layout.qrcode.transparent || (i = !0),
                            "copy" != e[t] || a.settings.layout.qrcode.copy || (i = !0),
                            "lock" != e[t] || a.settings.layout.qrcode.lock || (i = !0),
                            "move" != e[t] || a.settings.layout.qrcode.move || (i = !0)),
                        void 0 !== o &&
                            "barcode" == o &&
                            void 0 !== a.settings.layout &&
                            void 0 !== a.settings.layout.barcode &&
                            ("type" != e[t] || a.settings.layout.barcode.type || (i = !0),
                            "color" != e[t] || a.settings.layout.barcode.color || (i = !0),
                            "width" != e[t] || a.settings.layout.barcode.width || (i = !0),
                            "height" != e[t] || a.settings.layout.barcode.height || (i = !0),
                            "background" != e[t] || a.settings.layout.barcode.background || (i = !0),
                            "transparent" != e[t] || a.settings.layout.barcode.transparent || (i = !0),
                            "copy" != e[t] || a.settings.layout.barcode.copy || (i = !0),
                            "lock" != e[t] || a.settings.layout.barcode.lock || (i = !0),
                            "text" != e[t] || a.settings.layout.barcode.text || (i = !0),
                            "move" != e[t] || a.settings.layout.barcode.move || (i = !0)),
                        i ||
                            "team" == o ||
                            void 0 === a.menuOptions.details ||
                            void 0 === a.menuOptions.details[a.menuOptions.childID] ||
                            void 0 === a.menuOptions.details[a.menuOptions.childID].settings ||
                            0 == a.menuOptions.details[a.menuOptions.childID].settings.includes(e[t]) ||
                            (i = !0),
                        i && p++;
                }
                p == e.length && (t = !1);
            }
            return t;
        },
        dropdownGroup(t) {
            let e = this;
            if (e.groupItem.active == t) return (e.groupItem.active = ""), !1;
            "color" == t &&
                e.groupItem.colors.length &&
                (e.settings.layout.text.color || e.settings.layout.photo.color || e.settings.layout.artwork.color) &&
                setTimeout(() => {
                    pdappAPI.tool.colorPicker(".pdapp-edit-color", e.langs.options, function (t, o) {
                        (oldcolor = jQuery(t).attr("data-color")), e.updateColor(oldcolor, o);
                    });
                }, 1),
                (e.groupItem.active = t);
        },
        selectAllGroup() {
            let t = this,
                e = jQuery(".pdapp-viewport.active .pdapp-viewport-area.active g.pdapp-target");
            return 0 == e.length
                ? ((t.toast = { show: !0, type: "warning", text: t.langs.select_item_not_found }),
                  setTimeout(() => {
                      t.toast.show = !1;
                  }, 5e3),
                  !1)
                : 1 == e.length
                  ? (t.activeLayer(e), !1)
                  : void pdappAPI.group.selectAll(function (e, o) {
                        (pdappAPI.tool.pdappMoveAbleRef.target = e),
                            (pdappAPI.tool.pdappMoveAbleRef.keepRatio = !0),
                            (pdappAPI.tool.targets = e),
                            (t.groupItem = o),
                            pdappAPI.group.getColors(e, function (e) {
                                for (let o = 0; o < e.length; o++) {
                                    let a = pdappAPI.tool.rgbToHex(e[o]);
                                    0 == t.groupItem.colors.includes(a) &&
                                        -1 != a.indexOf("#") &&
                                        t.groupItem.colors.push(a);
                                }
                            });
                    });
        },
        copyGroup() {
            let t = this,
                e = [],
                o = [],
                a = [],
                p = [],
                i = [];
            pdappAPI.group.copyGroup(t.settings.layout, t.langs.options, function (s, r, l, d, n) {
                if ((e.push(jQuery("#" + s)[0]), o.push(s), a.push(r), p.push(l), "" != d)) {
                    let e = { id: s, value: "" };
                    void 0 !== t.photoStores[d] &&
                        ((t.photoStores[s] = t.photoStores[d]), (e.value = t.photoStores[d])),
                        i.push(e);
                }
                if (n) {
                    let s = {};
                    (s.undo = { action: "removeGroup", target: o, value: i }),
                        (s.redo = { action: "createGroup", index: a, value: i, svg: p }),
                        t.setHistory(s),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = e), (pdappAPI.tool.targets = e);
                        }, 1),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_text_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                }
            });
        },
        setGroup() {
            let t = this,
                e = [];
            pdappAPI.group.setGroup(t.groupItem.isGroup, function (o, a) {
                if ((e.push(o), a)) {
                    let o = {};
                    (o.undo = { action: "setGroup", target: e, value: t.groupItem.isGroup }),
                        (t.groupItem.isGroup = !t.groupItem.isGroup),
                        (o.redo = { action: "setGroup", target: e, value: t.groupItem.isGroup }),
                        t.setHistory(o),
                        t.groupItem.isGroup ||
                            (null != t.activeMenu &&
                                void 0 !== t.listMenus[t.activeMenu] &&
                                (t.listMenus[t.activeMenu].options.childID = null),
                            t.responsiveLayout.showMenu || (t.activeMenu = null),
                            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                            (pdappAPI.tool.targets = []),
                            (t.groupItem.show = !1));
                }
            });
        },
        alignGroup(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = pdappAPI.tool.pdappMoveAbleRef.target;
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                pdappAPI.group.alignGroup(t, o, function (t, a, p) {
                    let i = {};
                    (i.undo = { action: "alignGroup", target: t, value: a }),
                        (i.redo = { action: "alignGroup", target: t, value: p }),
                        e.setHistory(i),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = o), (pdappAPI.tool.targets = o);
                        }, 1);
                });
        },
        moveGroup(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = "top";
            "top" == t ? (o = "bot") : "right" == t ? (o = "left") : "left" == t && (o = "right");
            let a = pdappAPI.tool.pdappMoveAbleRef.target;
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                pdappAPI.group.moveGroup(t, a, function (p) {
                    let i = {};
                    (i.undo = { action: "moveGroup", target: p, value: o }),
                        (i.redo = { action: "moveGroup", target: p, value: t }),
                        e.setHistory(i),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = a), (pdappAPI.tool.targets = a);
                        }, 1);
                });
        },
        deleteGroup() {
            let t = this;
            pdappAPI.group.deleteGroup(function (e, o, a, p) {
                for (let e = 0; e < p.length; e++) {
                    let o = p[e].id;
                    void 0 !== t.photoStores[o] && (p[e].value = t.photoStores[o]);
                }
                let i = {};
                (i.undo = { action: "createGroup", index: o, value: p, svg: a }),
                    (i.redo = { action: "removeGroup", target: e, value: p }),
                    t.setHistory(i),
                    t.closeGroup();
            });
        },
        activeLayer(t) {
            let e = this;
            if (void 0 === t.length || 0 == t.length) return e.closeMenuOption(), e.closeGroup(), !1;
            if (t.length > 1) {
                let o = !1;
                for (let e = t.length - 1; e >= 0; e--)
                    (jQuery(t[e]).hasClass("pdapp-lock") || jQuery(t[e]).hasClass("pdapp-team")) &&
                        (t.splice(e, 1), (o = !0));
                if (0 == t.length) return e.closeMenuOption(), !1;
                o && ((pdappAPI.tool.targets = t), (pdappAPI.tool.pdappMoveAbleRef.target = t));
            } else if (jQuery(t[0]).hasClass("pdapp-group")) {
                let e = jQuery(t[0]).attr("data-group"),
                    o = [];
                jQuery(".pdapp-viewport.active .pdapp-viewport-area.active g.pdapp-group").each(function () {
                    jQuery(this).attr("data-group") == e && o.push(this);
                }),
                    o.length && ((t = o), (pdappAPI.tool.pdappMoveAbleRef.target = o), (pdappAPI.tool.targets = o));
            }
            jQuery(".pdapp-viewport.active").addClass("pdapp-hide-mask"),
                pdappAPI.layer.active(t, e.langs.options, function (o, a, p) {
                    if (null == e.activeMenu && "group" == a) {
                        let t = "text";
                        if (
                            void 0 !== e.settings.layout[t] &&
                            ((void 0 !== e.settings.layout[t].allow && !e.settings.layout[t].allow) ||
                                (void 0 !== e.settings.layout[t].allowUpload &&
                                    !e.settings.layout[t].allowUpload &&
                                    !e.settings.layout[t].allowLibrary))
                        ) {
                            let o = "";
                            for (let t in e.listMenus)
                                "" == o &&
                                    void 0 !== e.settings.layout[t] &&
                                    ((void 0 !== e.settings.layout[t].allow && e.settings.layout[t].allow) ||
                                        (void 0 !== e.settings.layout[t].allowUpload &&
                                            (e.settings.layout[t].allowUpload || e.settings.layout[t].allowLibrary))) &&
                                    (o = t);
                            t = o;
                        }
                        (e.activeMenu = t), pdappAPI.tool.setLocalVar("pdappActiveMenu", t);
                    }
                    if (null == o && t.length > 1)
                        return (
                            pdappAPI.group.getGroup(t, function (o) {
                                (e.groupItem = o),
                                    pdappAPI.group.getColors(t, function (t) {
                                        for (let o = 0; o < t.length; o++) {
                                            let a = pdappAPI.tool.rgbToHex(t[o]);
                                            0 == e.groupItem.colors.includes(a) &&
                                                -1 != a.indexOf("#") &&
                                                e.groupItem.colors.push(a);
                                        }
                                    });
                            }),
                            !1
                        );
                    if (
                        ("group" != a &&
                            "unselect" != a &&
                            (e.listMenus[a], 1) &&
                            ((e.activeMenu = a), pdappAPI.tool.setLocalVar("pdappActiveMenu", a)),
                        ("text" == a || "artwork" == a || "photo" == a || "qrcode" == a || "barcode" == a) &&
                            p.length > 0 &&
                            void 0 !== p[0].settings)
                    ) {
                        if (1 == t.length && !jQuery(t).hasClass("pdapp-lock")) {
                            let o = { size: !0, move: !0, rotate: !0 };
                            void 0 !== e.settings.layout[a] &&
                                (void 0 === e.settings.layout[a].size ||
                                    e.settings.layout[a].size ||
                                    1 == e.settings.layout[a].size ||
                                    (o.size = !1),
                                void 0 === e.settings.layout[a].move ||
                                    e.settings.layout[a].move ||
                                    1 == e.settings.layout[a].move ||
                                    (o.move = !1),
                                void 0 === e.settings.layout[a].rotate ||
                                    e.settings.layout[a].rotate ||
                                    1 == e.settings.layout[a].rotate ||
                                    (o.rotate = !1)),
                                pdappAPI.tool.setHideOptions(p[0].settings, o),
                                jQuery(document).trigger("after_layer_active", { type: a, evt: jQuery(t), self: e });
                        }
                        "photo" == a &&
                            p[0].clickShowUpload &&
                            setTimeout(() => {
                                e.showReplacePhoto();
                            }, 1);
                    }
                    return (
                        (e.listMenus[e.activeMenu].options.childID = o),
                        (e.listMenus[e.activeMenu].options.details = p),
                        (e.groupItem.show = !1),
                        "text" == e.activeMenu && 0 == e.listMenus.text.options.values.length
                            ? e.getListText()
                            : "text" == e.activeMenu &&
                              null == e.menuOptions.childID &&
                              setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                                      e.listTextTemp.total > e.listTextTemp.temps.length &&
                                          e.listMenus.text.page.paged++;
                                  });
                              }, 1),
                        "text" == e.activeMenu &&
                        null != e.menuOptions.childID &&
                        void 0 !== e.menuOptions.details[e.menuOptions.childID].dropdown
                            ? ("color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                  setTimeout(() => {
                                      pdappAPI.tool.colorPicker(
                                          "#pdapp-text-colorpicker",
                                          e.langs.options,
                                          function (t, o) {
                                              if (null == e.menuOptions.childID) return !1;
                                              (e.menuOptions.details[e.menuOptions.childID].color = o),
                                                  e.updateTextStyle("color");
                                          }
                                      );
                                  }, 1),
                              "outline" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                  setTimeout(() => {
                                      pdappAPI.tool.colorPicker(
                                          "#pdapp-outline-colorpicker",
                                          e.langs.options,
                                          function (t, o) {
                                              if (null == e.menuOptions.childID) return !1;
                                              (e.menuOptions.details[e.menuOptions.childID].stroke = o),
                                                  e.updateTextStyle("outline");
                                          }
                                      );
                                  }, 1),
                              "font" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                  void 0 !== e.fontLibrary.page &&
                                  setTimeout(() => {
                                      pdappAPI.tool.loadMore(".pdapp-font-list", function () {
                                          e.listFonts.total > e.listFonts.fonts.length && e.fontLibrary.page.paged++;
                                      });
                                  }, 1),
                              !1)
                            : "artwork" == e.activeMenu && null != e.menuOptions.childID
                              ? (void 0 === e.artFolders[0]
                                    ? e.getArtFolders()
                                    : null == e.menuOptions.childID &&
                                      setTimeout(() => {
                                          pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                                              e.listArtworks.total > e.listArtworks.arts.length &&
                                                  e.listMenus.artwork.options.values.page.paged++;
                                          });
                                      }, 1),
                                (e.menuOptions.details[e.menuOptions.childID].colors = []),
                                e.menuOptions.details[e.menuOptions.childID].editColor &&
                                    pdappAPI.tool.getColors(jQuery(t), function (t) {
                                        (e.menuOptions.details[e.menuOptions.childID].colors = t),
                                            "color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                                setTimeout(() => {
                                                    pdappAPI.tool.colorPicker(
                                                        ".pdapp-edit-color",
                                                        e.langs.options,
                                                        function (t, o) {
                                                            (oldcolor = jQuery(t).attr("data-color")),
                                                                e.updateColor(oldcolor, o);
                                                        }
                                                    );
                                                }, 1);
                                    }),
                                !1)
                              : "photo" == e.activeMenu && null != e.menuOptions.childID
                                ? (e.getListShape(),
                                  e.getListFilter(),
                                  void 0 !== e.settings.layout.photo &&
                                      e.settings.layout.photo.allowLibrary &&
                                      (0 == e.listMenus.photo.options.values.length
                                          ? e.getPhotos()
                                          : null == e.menuOptions.childID &&
                                            setTimeout(() => {
                                                pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                                    e.getPhotos();
                                                });
                                            }, 1)),
                                  (e.menuOptions.details[e.menuOptions.childID].colors = []),
                                  e.menuOptions.details[e.menuOptions.childID].editColor &&
                                      pdappAPI.tool.getColors(jQuery(t), function (t) {
                                          (e.menuOptions.details[e.menuOptions.childID].colors = t),
                                              "color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                                  setTimeout(() => {
                                                      pdappAPI.tool.colorPicker(
                                                          ".pdapp-edit-color",
                                                          e.langs.options,
                                                          function (t, o) {
                                                              (oldcolor = jQuery(t).attr("data-color")),
                                                                  e.updateColor(oldcolor, o);
                                                          }
                                                      );
                                                  }, 1);
                                      }),
                                  !1)
                                : "team" == e.activeMenu &&
                                    null != e.menuOptions.childID &&
                                    void 0 !== e.menuOptions.details[e.menuOptions.childID].dropdown
                                  ? ("color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                        setTimeout(() => {
                                            pdappAPI.tool.colorPicker(
                                                "#pdapp-text-colorpicker",
                                                e.langs.options,
                                                function (t, o) {
                                                    if (null == e.menuOptions.childID) return !1;
                                                    (e.menuOptions.details[e.menuOptions.childID].color = o),
                                                        e.updateTextStyle("color");
                                                }
                                            );
                                        }, 1),
                                    "outline" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                        setTimeout(() => {
                                            pdappAPI.tool.colorPicker(
                                                "#pdapp-outline-colorpicker",
                                                e.langs.options,
                                                function (t, o) {
                                                    if (null == e.menuOptions.childID) return !1;
                                                    (e.menuOptions.details[e.menuOptions.childID].stroke = o),
                                                        e.updateTextStyle("outline");
                                                }
                                            );
                                        }, 1),
                                    !1)
                                  : "qrcode" == e.activeMenu && null != e.menuOptions.childID
                                    ? (setTimeout(() => {
                                          if (
                                              (pdappAPI.tool.colorPicker(
                                                  "#pdapp-qrcode-colorpicker",
                                                  e.langs.options,
                                                  function (t, o) {
                                                      if (null == e.menuOptions.childID) return !1;
                                                      (e.menuOptions.details[e.menuOptions.childID].color = o),
                                                          e.settings.layout.qrcode.type &&
                                                              void 0 ===
                                                                  e.menuOptions.details[e.menuOptions.childID].type &&
                                                              (e.menuOptions.details[e.menuOptions.childID].type =
                                                                  "text"),
                                                          e.updateQrcode();
                                                  }
                                              ),
                                              null == e.menuOptions.childID)
                                          )
                                              return !1;
                                          "background" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                              "transparent" !=
                                                  e.menuOptions.details[e.menuOptions.childID].background &&
                                              pdappAPI.tool.colorPicker(
                                                  "#pdapp-qrcode-bg-colorpicker",
                                                  e.langs.options,
                                                  function (t, o) {
                                                      if (null == e.menuOptions.childID) return !1;
                                                      (e.menuOptions.details[e.menuOptions.childID].background = o),
                                                          e.updateQrcode();
                                                  }
                                              );
                                      }, 1),
                                      !1)
                                    : "barcode" == e.activeMenu && null != e.menuOptions.childID
                                      ? (setTimeout(() => {
                                            if (
                                                (pdappAPI.tool.colorPicker(
                                                    "#pdapp-barcode-colorpicker",
                                                    e.langs.options,
                                                    function (t, o) {
                                                        if (null == e.menuOptions.childID) return !1;
                                                        (e.menuOptions.details[e.menuOptions.childID].lineColor = o),
                                                            e.updateBarcode();
                                                    }
                                                ),
                                                null == e.menuOptions.childID)
                                            )
                                                return !1;
                                            "background" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                                "transparent" !=
                                                    e.menuOptions.details[e.menuOptions.childID].background &&
                                                pdappAPI.tool.colorPicker(
                                                    "#pdapp-barcode-bg-colorpicker",
                                                    e.langs.options,
                                                    function (t, o) {
                                                        if (null == e.menuOptions.childID) return !1;
                                                        (e.menuOptions.details[e.menuOptions.childID].background = o),
                                                            e.updateBarcode();
                                                    }
                                                );
                                        }, 1),
                                        !1)
                                      : void 0
                    );
                });
        },
        closeMenuOption() {
            let t = this;
            if (
                null == t.activeMenu ||
                void 0 === t.listMenus[t.activeMenu] ||
                void 0 === t.listMenus[t.activeMenu].options ||
                "undefined" == t.listMenus[t.activeMenu].options.childID ||
                null == t.listMenus[t.activeMenu].options.childID
            )
                return !1;
            (t.listMenus[t.activeMenu].options.childID = null),
                (pdappAPI.tool.pdappMoveAbleRef.target = null),
                t.responsiveLayout.showMenu || (t.activeMenu = null),
                (t.groupItem.active = ""),
                (pdappAPI.tool.targets = []),
                (t.groupItem.show = !1),
                ("text" != t.activeMenu &&
                    "artwork" != t.activeMenu &&
                    "template" != t.activeMenu &&
                    "photo" != t.activeMenu) ||
                    setTimeout(() => {
                        let e =
                            "photo" == t.activeMenu ? ".pdapp-photo-libraries" : ".pdapp-menu-options-" + t.activeMenu;
                        pdappAPI.tool.loadMore(e, function () {
                            "text" == t.activeMenu &&
                                t.listTextTemp.total > t.listTextTemp.temps.length &&
                                t.listMenus.text.page.paged++,
                                "artwork" == t.activeMenu &&
                                    t.listArtworks.total > t.listArtworks.arts.length &&
                                    t.listMenus.artwork.options.values.page.paged++,
                                "template" == t.activeMenu &&
                                    t.listTemplates.total > t.listTemplates.temps.length &&
                                    t.listMenus.template.options.values.page.paged++,
                                "photo" == t.activeMenu && t.getPhotos();
                        });
                    }, 1),
                jQuery(".pdapp-viewport.active").removeClass("pdapp-hide-mask");
        },
        closeGroup() {
            let t = this;
            null != t.activeMenu &&
                void 0 !== t.listMenus[t.activeMenu] &&
                (t.listMenus[t.activeMenu].options.childID = null),
                (pdappAPI.tool.pdappMoveAbleRef.target = null),
                t.responsiveLayout.showMenu || (t.activeMenu = null),
                (pdappAPI.tool.targets = []),
                (t.groupItem.show = !1),
                jQuery(".pdapp-viewport.active").removeClass("pdapp-hide-mask");
        },
        activeMask() {
            jQuery(".pdapp-viewport.active").hasClass("pdapp-hide-mask") ||
                jQuery(".pdapp-viewport.active").addClass("pdapp-hide-mask");
        },
        setSvgStyle() {
            pdappAPI.tool.setSvgStyle(this.loadedFonts);
        },
        setActiveLayer(t) {
            let e = jQuery("#" + t.id);
            this.activeLayer(e);
        },
        moveLayer(t, e) {
            let o = this;
            pdappAPI.layer.moveLayer(t, e),
                null != o.activeMenu &&
                    void 0 !== o.listMenus[o.activeMenu] &&
                    (o.listMenus[o.activeMenu].options.values = pdappAPI.layer.loadLayers());
        },
        zoomLimit(t) {
            this.product.unit.zoom < t && (this.product.unit.zoom = t);
        },
        toggleShowRuler() {
            let t = this;
            (t.showRuler = !t.showRuler), pdappAPI.tool.ruler.setShow(t.showRuler);
        },
        previewScreen() {
            let t = this;
            (t.loadingPage = !0),
                setTimeout(() => {
                    let e = pdappAPI.tool.previewScreen(t.photoStores, t.settings, function (e, o) {
                        (t.loadingPage = !1), void 0 !== t.modal.data[e] && (t.modal.data[e].src = o);
                    });
                    t.modal = {
                        show: !0,
                        header: !0,
                        size: "full-width",
                        title: t.langs.toolbar.preview_title,
                        type: "preview",
                        data: e,
                    };
                });
        },
        updatePrintSize(t, e) {
            let o = this;
            if (("width" == e || "height" == e) && !o.product.unit.edit) return !1;
            void 0 !== o.product.views &&
                void 0 !== o.activeProduct.view &&
                (o.product = pdappAPI.tool.updatePrintSize(
                    t,
                    e,
                    o.product,
                    o.activeProduct.view,
                    o.activeProduct.area
                ));
        },
        onResizeScreen() {
            let t = this,
                e = !0,
                o = pdappAPI.tool.getSizeScreen();
            (t.originalScreen.width < 1 || t.originalScreen.height < 1) &&
                ((t.originalScreen = { width: o.width, height: o.height }), (e = !1));
            let a = { width: o.width, height: o.height };
            if (a.width === t.originalScreen.width && a.height === t.originalScreen.height && e) return !1;
            void 0 !== t.product.unit &&
                (jQuery("#pdapp-viewer-area").css({ width: "100%", height: "100%" }),
                (t.product.unit.zoom = "fit"),
                pdappAPI.tool.setScroll()),
                o.width > o.height && !t.screenIsLandscape
                    ? ((t.screenIsLandscape = !0),
                      setTimeout(() => {
                          t.product.unit.zoom = "fit";
                      }, 200))
                    : o.width <= o.height &&
                      t.screenIsLandscape &&
                      ((t.screenIsLandscape = !1),
                      setTimeout(() => {
                          t.product.unit.zoom = "fit";
                      }, 200)),
                (t.originalScreen = a);
        },
        toggleFullScreen() {
            let t = this;
            pdappAPI.tool.toggleFullScreen(function (e) {
                t.isFullScreen = e;
            });
        },
        setHistory(t) {
            let e = this;
            (t.view = e.activeProduct.view),
                (t.area = e.activeProduct.area),
                e.history.values.length > 0 &&
                    void 0 !== e.history.values[e.history.active + 1] &&
                    e.history.values.splice(e.history.active + 1),
                e.history.values.length > 30 && e.history.values.splice(0, 1),
                e.history.values.push(t),
                (e.history.active = e.history.values.length - 1),
                (e.designsTeam = []),
                void 0 !== e.designsData[t.view] &&
                    void 0 !== e.designsData[t.view][t.area] &&
                    delete e.designsData[t.view][t.area],
                e.getPrintInfo();
        },
        doHistory(t) {
            let e = this;
            if (0 == e.history.values.length) return !1;
            if (
                ((pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                e.responsiveLayout.showMenu || (e.activeMenu = null),
                "redo" == t && (e.history.active = e.history.active + 1),
                e.history.active >= e.history.values.length)
            )
                return (e.history.active = e.history.values.length - 1), !1;
            if (
                void 0 === e.history.values[e.history.active] ||
                void 0 === e.history.values[e.history.active].view ||
                void 0 === e.history.values[e.history.active][t]
            )
                return !1;
            let o = e.history.values[e.history.active];
            o.view != e.activeProduct.view && (e.activeProduct.view = o.view),
                o.area != e.activeProduct.area && (e.activeProduct.area = o.area),
                (e.designsTeam = []),
                void 0 !== e.designsData[o.view] &&
                    void 0 !== e.designsData[o.view][o.area] &&
                    delete e.designsData[o.view][o.area],
                null != e.menuOptions.childID &&
                    void 0 !== e.menuOptions.details[e.menuOptions.childID] &&
                    ((e.menuOptions.details[e.menuOptions.childID].dropdown = ""), (e.menuOptions.childID = null)),
                "undo" == t && (e.history.active = e.history.active - 1),
                e.history.active < 0 && (e.history.active = -1);
            let a = o[t];
            if (
                (setTimeout(() => {
                    "updateMember" == a.action && "function" == typeof pdappAPI.history.updateMember
                        ? pdappAPI.history.updateMember(a, function (t, o, a) {
                              (e.listMenus.team.options.values.active = t),
                                  (e.listMenus.team.options.values.teams[t][o] = a);
                          })
                        : "updateTeam" == a.action && "function" == typeof pdappAPI.history.updateTeam
                          ? pdappAPI.history.updateTeam(a, function (t, o, p) {
                                if (
                                    ((e.listMenus.team.options.values.active = o),
                                    "update" == p && (e.listMenus.team.options.values.teams = t),
                                    "add" == p &&
                                        ((e.listMenus.team.options.values.teams = t),
                                        jQuery("#" + a.target).hasClass("pdapp-team-name")
                                            ? (e.listMenus.team.options.values.name = a.target)
                                            : e.listMenus.team.options.values.number.push(a.target)),
                                    "name" == p)
                                )
                                    if (
                                        ((e.listMenus.team.options.values.name = ""),
                                        void 0 !== e.listMenus.team.options.values.teams[0].number)
                                    ) {
                                        for (let t = 0; t < e.listMenus.team.options.values.teams.length; t++)
                                            if (void 0 !== e.listMenus.team.options.values.teams[t].number) {
                                                let o = { number: e.listMenus.team.options.values.teams[t].number };
                                                e.listMenus.team.options.values.teams[t] = o;
                                            }
                                    } else e.listMenus.team.options.values.teams = [];
                                if ("number" == p) {
                                    for (let t = 0; t < e.listMenus.team.options.values.number.length; t++)
                                        e.listMenus.team.options.values.number[t] == a.target &&
                                            e.listMenus.team.options.values.number.splice(t, 1);
                                    if (0 == e.listMenus.team.options.values.number.length)
                                        if (void 0 !== e.listMenus.team.options.values.teams[0].name) {
                                            for (let t = 0; t < e.listMenus.team.options.values.teams.length; t++)
                                                if (void 0 !== e.listMenus.team.options.values.teams[t].name) {
                                                    let o = { name: e.listMenus.team.options.values.teams[t].name };
                                                    e.listMenus.team.options.values.teams[t] = o;
                                                }
                                        } else e.listMenus.team.options.values.teams = [];
                                }
                                e.updateTeam();
                            })
                          : void 0 !== pdappAPI.history[a.action] && pdappAPI.history[a.action](a);
                }),
                "createPhoto" == a.action &&
                    "" != a.value &&
                    (e.photoStores[a.target] = JSON.parse(JSON.stringify(a.value))),
                "createGroup" == a.action && a.value.length)
            )
                for (let t = 0; t < a.value.length; t++)
                    e.photoStores[a.value[t].id] = JSON.parse(JSON.stringify(a.value[t].value));
            if (
                ("cropPhoto" == a.action &&
                    void 0 !== a.value.width &&
                    (e.photoStores[a.target].crop = JSON.parse(JSON.stringify(a.value))),
                "replacePhoto" == a.action && void 0 !== a.value.id && (e.photoStores[a.target] = a.value),
                "deletePhoto" == a.action && void 0 !== e.photoStores[a.target] && delete e.photoStores[a.target],
                "deleteGroup" == a.action && a.value.length)
            )
                for (let t = 0; t < a.value.length; t++)
                    void 0 !== e.photoStores[a.value[t]] && delete e.photoStores[a.value[t]];
            ["createText", "changeFont", "deleteText", "addFilter", "deletePhoto"].includes(a.action) &&
                setTimeout(() => {
                    e.setSvgStyle();
                }, 100),
                e.getPrintInfo();
        },
        showDownload(t) {
            let e = this;
            if (((e.modalCart.show = !1), !pdappAPI.tool.checkDesign()))
                return (
                    (e.modal = {
                        show: !0,
                        header: !1,
                        size: "md modal-dialog-centered",
                        title: "",
                        type: "message",
                        data: {
                            type: "warning",
                            title: e.langs.topbar.design_empty,
                            text: e.langs.topbar.design_empty_desc,
                            btn: e.langs.ok,
                        },
                    }),
                    !1
                );
            if (
                ((e.modal = {
                    show: !0,
                    header: !0,
                    size: "full-width",
                    title: e.langs.topbar.download_design,
                    type: "download",
                    loading: !0,
                }),
                e.waitDesign)
            ) {
                e.loadingPage = !0;
                let o = !1;
                return (
                    "" == t ? (e.waitTiming = pdappAPI.tool.getTime()) : (o = pdappAPI.tool.checkTime(e.waitTiming, 2)),
                    o
                        ? ((e.loadingPage = !1),
                          (e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: e.langs.topbar.processing_design_error,
                                  text: e.langs.topbar.processing_design_error_desc,
                                  btn: e.langs.ok,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (e.loadingPage = !1), e.showDownload("recall");
                          }, 300),
                          !1)
                );
            }
            (e.waitDesign = !0), (e.modal.loading = !1);
            let o = JSON.parse(JSON.stringify(e.designsData));
            e.designsData = pdappAPI.download.renderDesigns(
                e.photoStores,
                o,
                e.listMenus.team.options.values,
                "download",
                function (t, o, a, p, i) {
                    if (i) {
                        if (((e.waitDesign = !1), 0 == e.listMenus.team.options.values.length)) return !1;
                        setTimeout(() => {
                            e.renderTeams();
                        }, 10);
                    } else
                        void 0 !== e.designsData[t] &&
                            void 0 !== e.designsData[t][o] &&
                            void 0 !== e.designsData[t][o].svg &&
                            ((e.designsData[t][o].svg = a),
                            (e.designsData[t][o].origin = p),
                            (e.designsData[t][o].loading = !1));
                }
            );
        },
        async startDownload(t, e, o) {
            let a = this;
            if (void 0 !== a.designsData[e] && void 0 !== a.designsData[e][o] && void 0 !== a.designsData[e][o].svg) {
                if (!a.settings.general.download.type.includes(t)) return !1;
                if (
                    ((a.modal.loading = !0), void 0 !== a.designsData[e][o].origin && "" != a.designsData[e][o].origin)
                ) {
                    let p =
                        pdappAdminUrl +
                        "admin-ajax.php?action=pdapp-render-design&admin=0&pdapp-token=" +
                        pdappToken +
                        "&pdapp-nonce=" +
                        pdappNonce;
                    try {
                        let i = new Blob([JSON.stringify({ svg: a.designsData[e][o].origin })], {
                                type: "application/json",
                            }),
                            s = new FormData();
                        s.append("design", i, "design.json");
                        let r = await pdappAPI.upload.uploadFile(p, s),
                            l = JSON.parse(JSON.stringify(a.designsData[e][o]));
                        (l.svg = r.data),
                            pdappAPI.download.downloadDesign(
                                l,
                                t,
                                a.product.unit.type,
                                a.settings.general.download,
                                function () {
                                    a.modal.loading = !1;
                                }
                            );
                    } catch (t) {
                        if (-1 == t.error)
                            return (
                                (a.modal = {
                                    show: !0,
                                    header: !1,
                                    size: "md modal-dialog-centered",
                                    title: "",
                                    type: "confirmReload",
                                }),
                                !1
                            );
                        (a.toast = { show: !0, type: "error", text: t.msg }),
                            setTimeout(() => {
                                a.toast.show = !1;
                            }, 5e3);
                    }
                } else
                    pdappAPI.download.downloadDesign(
                        a.designsData[e][o],
                        t,
                        a.product.unit.type,
                        a.settings.general.download,
                        function () {
                            a.modal.loading = !1;
                        }
                    );
            }
        },
        backToProduct() {
            let t = this;
            pdappAPI.tool.checkDesign()
                ? (t.modal = { show: !0, header: !1, size: "md modal-dialog-centered", title: "", type: "confirmBack" })
                : t.redirectBack();
        },
        redirectBack() {
            (this.isCheckReload = !0), (window.location.href = this.backUrl);
        },
        redirectHomepage() {
            (this.warningBack = !1), (window.location.href = pdappUrl);
        },
        getTitle(t) {
            let e = this,
                o = "Untitled";
            if (null == t || "" == t) return o;
            if (void 0 !== t[e.langDefault] && "" != t[e.langDefault]) o = t[e.langDefault];
            else for (let e in t) "" != t[e] && (o = t[e]);
            return o;
        },
        showImg(t, e, o) {
            if ("" != t && null != t && -1 != t.indexOf("base64,")) return t;
            let a = pdappPluginUrl + "assets/images/image.png";
            return (
                ("tempf" != o && "artf" != o) || (a = pdappPluginUrl + "assets/images/folder.png"),
                "" != t &&
                    ("product" == o && (a = pdappUploadUrl + "products/product-" + e + "/" + t),
                    "tempf" == o && (a = pdappUploadUrl + "thumbnails/templates/template-folder-" + t),
                    "temp" == o && (a = pdappUploadUrl + "thumbnails/templates/template-" + t),
                    "artf" == o && (a = pdappUploadUrl + "thumbnails/arts/art-folder-" + t),
                    "art" == o && (a = pdappUploadUrl + "thumbnails/arts/art-" + t)),
                a
            );
        },
        openDesign(t) {
            let e = this;
            "reload" == t && (e.mydesigns = null),
                (e.modalCart.show = !1),
                "" == e.customerMail
                    ? (e.customerMail = pdappAPI.tool.getLocalVar("pdappCustomerMail", ""))
                    : pdappAPI.tool.setLocalVar("pdappCustomerMail", e.customerMail),
                "" == e.customerMail || "edit" == t
                    ? (e.modal = {
                          show: !0,
                          header: !0,
                          size: "md",
                          title: e.langs.topbar.confirm_your_email,
                          type: "confirmEmail",
                      })
                    : e.loadDesigns();
        },
        async loadDesigns() {
            let t = this;
            if ("" == t.customerMail) return t.openDesign(), !1;
            if (
                ((t.modal = {
                    show: !0,
                    header: !0,
                    size: "xl",
                    title: t.langs.topbar.your_designs,
                    type: "yourDesign",
                    loading: !0,
                    loadDesign: !1,
                }),
                null == t.mydesigns)
            ) {
                let e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-your-designs&email=" +
                    t.customerMail +
                    "&id=" +
                    t.productID +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let o = await pdappAPI.tool.getData(e);
                    t.mydesigns = o.data;
                } catch (e) {
                    return -1 == e.error
                        ? ((t.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmReload",
                          }),
                          !1)
                        : ((t.toast = { show: !0, type: "error", text: e.msg }),
                          setTimeout(() => {
                              t.toast.show = !1;
                          }, 5e3),
                          !1);
                }
            }
            t.modal.loading = !1;
        },
        async loadDesign(t) {
            let e = this;
            if ("" == e.customerMail) return e.openDesign(), !1;
            if (((e.modal.loadDesign = t.id), void 0 === t.design)) {
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-load-design&email=" +
                    e.customerMail +
                    "&id=" +
                    t.id +
                    "&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let e = await pdappAPI.tool.getData(o);
                    t.design = e.data;
                } catch (t) {
                    return -1 == t.error
                        ? ((e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmReload",
                          }),
                          !1)
                        : ((e.toast = { show: !0, type: "error", text: t.msg }),
                          setTimeout(() => {
                              e.toast.show = !1;
                          }, 5e3),
                          (e.modal.loadDesign = !1),
                          !1);
                }
            }
            if (
                (e.startReset(),
                (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                t.design.length > e.productDataPX.views.length)
            ) {
                let o = !(
                    void 0 === e.product.advanced ||
                    void 0 === e.product.advanced.customview ||
                    !e.product.advanced.customview
                );
                return (
                    (e.modal = {
                        show: !0,
                        header: !1,
                        size: "md modal-dialog-centered",
                        title: "",
                        type: "confirmView",
                        addview: o,
                        data: t,
                    }),
                    !1
                );
            }
            setTimeout(() => {
                e.addDesign(t);
            }, 100);
        },
        removeDesign(t) {
            let e = this;
            (e.modal.type = "confirmRemoveDesign"),
                (e.modal.header = !1),
                (e.modal.size = "md modal-dialog-centered"),
                (e.modal.data = t);
        },
        async startRemoveDesign() {
            let t = this;
            if (void 0 === t.modal.data) return (t.modal.type = "yourDesign"), !1;
            let e =
                pdappAdminUrl +
                "admin-ajax.php?action=pdapp-remove-design&admin=0&pdapp-token=" +
                pdappToken +
                "&pdapp-nonce=" +
                pdappNonce;
            try {
                let o = await pdappAPI.tool.postData(e, {
                    id: t.modal.data.id,
                    productID: t.modal.data.pid,
                    email: t.modal.data.email,
                });
                if (null != t.mydesigns)
                    for (let e = 0; e < t.mydesigns.length; e++)
                        t.modal.data.id == t.mydesigns[e].id && t.mydesigns.splice(e, 1);
                (t.toast = { show: !0, type: "success", text: o.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (t.toast = { show: !0, type: "error", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.backToDesign();
        },
        backToDesign() {
            let t = this;
            (t.modal.type = "yourDesign"), (t.modal.header = !0), (t.modal.size = "xl modal-dialog-scrollable");
        },
        addCustomView() {
            let t = this,
                e = t.modal.data;
            if (
                ((t.modal.show = !1),
                void 0 !== t.product.advanced &&
                    void 0 !== t.product.advanced.maxview &&
                    t.product.advanced.maxview > 0)
            ) {
                t.activeProduct.view = 0;
                let o = JSON.parse(JSON.stringify(t.product));
                for (let t = o.views.length - 1; t >= 0; t--)
                    void 0 !== o.views[t].type &&
                        "addmore" == o.views[t].type &&
                        (o.views.splice(t, 1), o.advanced.maxview++);
                let a = {};
                a =
                    void 0 !== o.advanced.viewcopy && void 0 !== o.views[o.advanced.viewcopy]
                        ? JSON.parse(JSON.stringify(o.views[o.advanced.viewcopy]))
                        : JSON.parse(JSON.stringify(o.views[0]));
                let p = a.id;
                a.type = "addmore";
                for (let t = 0; t < a.backgrounds.length; t++) {
                    let e = "pdapp-background-" + p + "-" + a.backgrounds[t].id,
                        o = jQuery("#" + e)
                            .find(".pdapp-product-img")
                            .attr("src");
                    void 0 !== o && "" != o && -1 != o.indexOf("base64,") && (a.backgrounds[t].image = o);
                }
                if (void 0 !== a.mask && void 0 !== a.mask.image && "" != a.mask.image) {
                    let t = jQuery("#pdapp-viewport-" + p + " .pdapp-mask-img")
                        .find(".pdapp-product-img")
                        .attr("src");
                    void 0 !== t && "" != t && -1 != t.indexOf("base64,") && (a.mask.image = t);
                }
                let i =
                    void 0 !== o.advanced.viewcopy && void 0 !== o.views[o.advanced.viewcopy] ? o.advanced.viewcopy : 0;
                i++;
                let s = e.design.length - o.views.length;
                for (let t = 0; t < s; t++) {
                    a.id = pdappAPI.tool.uID();
                    for (let t = 0; t < a.layers.length; t++) a.layers[t].id = pdappAPI.tool.uID();
                    o.views.length < i ? o.views.push(a) : o.views.splice(i, 0, a), o.advanced.maxview--;
                }
                return (
                    (t.product = o),
                    setTimeout(() => {
                        t.addDesign(e);
                    }, 500),
                    !1
                );
            }
            setTimeout(() => {
                t.addDesign(e);
            }, 100);
        },
        addDesign(t) {
            let e = this;
            (e.myDesign = t), (e.modal = { show: !1 });
            let o = [],
                a = [];
            jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (p) {
                jQuery(this)
                    .find(".pdapp-viewport-area")
                    .each(function (i) {
                        if (
                            void 0 !== t.design[p] &&
                            void 0 !== t.design[p][i] &&
                            "" != t.design[p][i] &&
                            void 0 !== e.productDataPX.views[p] &&
                            void 0 !== e.productDataPX.views[p].layers[i] &&
                            void 0 !== e.productDataPX.views[p].layers[i]
                        ) {
                            pdappAPI.design.import(jQuery(this), t.design[p][i], "", function (t, o, a) {
                                (e.photoStores[o] = a),
                                    (e.photoStores[t] = { id: o, crop: "" }),
                                    void 0 !== a.blob &&
                                        "" != a.blob &&
                                        jQuery("#" + t)
                                            .find("image")
                                            .attr("xlink:href", a.blob);
                            });
                            let s = jQuery(this);
                            setTimeout(() => {
                                if (s.find("svg.pdapp-selecto-area").find(".pdapp-team").length) {
                                    let t = !0,
                                        o = e.listMenus.team.options.values.teams;
                                    if (0 == o.length) {
                                        let t = s.find("svg.pdapp-selecto-area").find("span.pdapp-team-value");
                                        if (t.length > 0) {
                                            let e = t.text();
                                            "" != e && (o = JSON.parse(e)), t.remove();
                                        }
                                    }
                                    o.length > 0 &&
                                        ((t = !1),
                                        s
                                            .find("svg.pdapp-selecto-area")
                                            .find(".pdapp-team")
                                            .each(function () {
                                                jQuery(this).hasClass("pdapp-team-name") &&
                                                    (e.listMenus.team.options.values.name = jQuery(this).attr("id")),
                                                    jQuery(this).hasClass("pdapp-team-number") &&
                                                        e.listMenus.team.options.values.number.push(
                                                            jQuery(this).attr("id")
                                                        );
                                            })),
                                        t && s.find("svg.pdapp-selecto-area").find(".pdapp-team").remove();
                                }
                                s.find("svg.pdapp-selecto-area")
                                    .find("g.pdapp-target")
                                    .each(function () {
                                        let t = jQuery(this),
                                            e = t.attr("data-artid"),
                                            p = t.attr("data-tempid");
                                        void 0 !== e && "" != e && 0 == o.includes(e) && o.push(e),
                                            void 0 !== p && "" != p && 0 == a.includes(p) && a.push(p);
                                    });
                            }, 10);
                        } else jQuery(this).find("svg.pdapp-selecto-area").html("");
                    });
            }),
                pdappAPI.design.getArtPrice(o, a, function (t) {
                    e.artworkStore = t;
                }),
                (e.modal.show = !1),
                setTimeout(() => {
                    e.getPrintInfo();
                }, 500);
        },
        openSaveDesign(t) {
            let e = this;
            if (
                ((e.modalCart.show = !1),
                "" == e.customerMail
                    ? (e.customerMail = pdappAPI.tool.getLocalVar("pdappCustomerMail", ""))
                    : pdappAPI.tool.setLocalVar("pdappCustomerMail", e.customerMail),
                !pdappAPI.tool.checkDesign())
            )
                return (
                    (e.modal = {
                        show: !0,
                        header: !1,
                        size: "md modal-dialog-centered",
                        title: "",
                        type: "message",
                        data: {
                            type: "warning",
                            title: e.langs.topbar.design_empty,
                            text: e.langs.topbar.design_empty_desc,
                            btn: e.langs.ok,
                        },
                    }),
                    !1
                );
            if (e.waitDesign) {
                e.loadingPage = !0;
                let o = !1;
                return (
                    "" == t ? (e.waitTiming = pdappAPI.tool.getTime()) : (o = pdappAPI.tool.checkTime(e.waitTiming, 2)),
                    o
                        ? ((e.loadingPage = !1),
                          (e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: e.langs.topbar.processing_design_error,
                                  text: e.langs.topbar.processing_design_error_desc,
                                  btn: e.langs.ok,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (e.loadingPage = !1), e.openSaveDesign("recall");
                          }, 300),
                          !1)
                );
            }
            e.waitDesign = !0;
            let o = jQuery("#pdapp-viewer-area .pdapp-viewport.active");
            e.loadingPage = !0;
            let a = void 0 !== e.myDesign.title ? e.myDesign.title : "Untitled";
            (e.modal = {
                show: !0,
                header: !0,
                footer: !0,
                size: "lg",
                title: e.langs.topbar.save_design,
                type: "saveDesign",
                data: { title: a, email: e.customerMail, thumb: "", total: 0, loading: !1, render: !0 },
                close: !0,
            }),
                pdappAPI.design.thumb(e.photoStores, e.settings, o, function (t) {
                    (e.modal.data.thumb = t),
                        setTimeout(() => {
                            (e.loadingPage = !1), (e.modal.data.render = !0);
                            let t = JSON.parse(JSON.stringify(e.designsData));
                            e.designsData = pdappAPI.download.renderDesigns(
                                e.photoStores,
                                t,
                                e.listMenus.team.options.values,
                                "design",
                                function (t, o, a, p, i) {
                                    i
                                        ? ((e.waitDesign = !1), (e.modal.data.render = !1))
                                        : void 0 !== e.designsData[t] &&
                                          void 0 !== e.designsData[t][o] &&
                                          void 0 !== e.designsData[t][o].svg &&
                                          ((e.designsData[t][o].svg = a),
                                          (e.designsData[t][o].origin = p),
                                          (e.designsData[t][o].loading = !1));
                                }
                            );
                        }, 100);
                });
        },
        checkEmail(t) {
            let e = this;
            return "" == t
                ? e.langs.email_required
                : /^(([^<>()[\]\\.,;:\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).toLowerCase()
                    )
                  ? ""
                  : e.langs.email_invalid;
        },
        async saveDesign(t) {
            let e = this;
            if ("" == e.modal.data.title || "" != e.checkEmail(e.modal.data.email)) return !1;
            if (
                ("" == e.customerMail && pdappAPI.tool.setLocalVar("pdappCustomerMail", e.modal.data.email),
                e.modal.data.render)
            ) {
                e.loadingPage = !0;
                let o = !1;
                return (
                    "" == t ? (e.waitTiming = pdappAPI.tool.getTime()) : (o = pdappAPI.tool.checkTime(e.waitTiming, 2)),
                    o
                        ? ((e.loadingPage = !1),
                          (e.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: e.langs.topbar.processing_design_error,
                                  text: e.langs.topbar.processing_design_error_desc,
                                  btn: e.langs.ok,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (e.loadingPage = !1), e.saveDesign("recall");
                          }, 300),
                          !1)
                );
            }
            let o = JSON.parse(JSON.stringify(e.designsData));
            for (let t in o)
                for (let e in o[t])
                    o[t][e].origin && "" != o[t][e].origin && ((o[t][e].svg = o[t][e].origin), (o[t][e].origin = ""));
            e.modal.data.loading = !0;
            let a = {
                    id: e.myDesign.id,
                    title: e.modal.data.title,
                    email: e.modal.data.email,
                    thumb: JSON.stringify(e.modal.data.thumb),
                    design: JSON.stringify(o),
                    designID: e.product.id,
                    productID: e.productID,
                    created: e.myDesign.created,
                },
                p =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-save-design&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
            try {
                let t = new Blob([JSON.stringify(a)], { type: "application/json" }),
                    o = new FormData();
                o.append("design", t, "design.json");
                let i = await pdappAPI.upload.uploadFile(p, o);
                if (null != e.mydesigns) {
                    let t = !0;
                    for (let o = 0; o < e.mydesigns.length; o++)
                        i.data.id == e.mydesigns[o].id && ((e.mydesigns[o] = i.data), (t = !1));
                    t && e.mydesigns.push(i.data);
                }
                (e.toast = { show: !0, type: "success", text: i.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3),
                    (e.modal.show = !1);
            } catch (t) {
                if (-1 == t.error)
                    return (
                        (e.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (e.toast = { show: !0, type: "error", text: t.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            }
            e.modal.data.loading = !1;
        },
        getPrintInfo(t) {
            let e = this;
            void 0 === e.listMenus.team && (e.listMenus.team = {}),
                void 0 === e.listMenus.team.options && (e.listMenus.team.options = {}),
                void 0 === e.listMenus.team.options.values && (e.listMenus.team.options.values = {}),
                void 0 === e.listMenus.team.options.values.teams && (e.listMenus.team.options.values.teams = []),
                (e.productCart.print.info = pdappAPI.design.printInfo(
                    e.prinValue,
                    e.listMenus.team.options.values.teams,
                    e.product.unit,
                    function (o) {
                        (e.prinValue = o),
                            void 0 !== t &&
                                "update" == t &&
                                setTimeout(() => {
                                    e.updatePrice();
                                }, 200);
                    }
                )),
                e.productCart.items.length > 0 &&
                    ((e.timeUpdateThumb = pdappAPI.tool.getTime()),
                    setTimeout(() => {
                        pdappAPI.tool.getTime() - e.timeUpdateThumb >= 1e3 && e.updateCartThumb();
                    }, 1e3));
        },
        updateCartThumb() {
            let t = this;
            jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (e) {
                let o = jQuery(this);
                pdappAPI.design.cartThumb(
                    t.photoStores,
                    t.settings,
                    o,
                    !1,
                    function (e, a, p) {
                        if ("product" != e)
                            for (let e = 0; e < t.productCart.items.length; e++)
                                void 0 !== t.productCart.items[e].productImg &&
                                    void 0 !== t.productCart.items[e].productImg[p] &&
                                    pdappAPI.design.mergeCartThumb(
                                        t.productCart.items[e].productImg[p],
                                        o,
                                        a,
                                        p,
                                        function (o) {
                                            t.productCart.items[e].thumb[p] = o;
                                        }
                                    );
                    },
                    e
                );
            });
        },
        updatePrice() {
            let t = this;
            if (
                void 0 !== t.productCart.print.info.views &&
                t.productCart.print.info.views > 0 &&
                void 0 !== t.printing &&
                t.printing.prints.length
            ) {
                let e = 0,
                    o =
                        void 0 !== t.printing.prints[t.productCart.print.info.views - 1]
                            ? t.printing.prints[t.productCart.print.info.views - 1]
                            : t.printing.prints[t.printing.prints.length - 1];
                for (let a in o.values)
                    if ("function" == typeof pdappAPI.design.print[a] && void 0 !== o.values[a]) {
                        let p = 0;
                        for (let t = 0; t < o.qtys.length; t++) 1 >= o.qtys[t] && (p = t);
                        if (void 0 !== o.values[a][p]) {
                            let i = pdappAPI.design.print[a](o.values[a][p], 1, t.productCart.print.info);
                            i > 0 && (e += i);
                        }
                    }
                if (((t.price = parseFloat(t.price) - e), void 0 !== t.productCart.print.info.artwork))
                    for (let e = 0; e < t.productCart.print.info.artwork.length; e++)
                        if (void 0 !== t.artworkStore[t.productCart.print.info.artwork[e]]) {
                            let o = parseFloat(t.artworkStore[t.productCart.print.info.artwork[e]]);
                            t.price = parseFloat(t.price) - o;
                        }
            }
        },
        showCartBox() {
            let t = this;
            (t.productCart.step = 0),
                (t.modalCart = { show: !0, title: t.langs.topbar.add_to_cart }),
                (t.dropdownMenu = ""),
                setTimeout(() => {
                    for (let e = 0; e < t.productDataPX.colors.length; e++)
                        "picker" == t.productDataPX.colors[e].type &&
                            pdappAPI.tool.colorPicker(
                                "#pdapp-product-colorpicker-" + t.productDataPX.colors[e].id,
                                t.langs.options,
                                function (o, a) {
                                    t.changeProductColor(t.productDataPX.colors[e].id, a, e);
                                }
                            );
                    setTimeout(() => {
                        pdappAPI.tool.responsiveCart();
                    }, 1);
                }, 1);
        },
        loadCartSize() {
            let t = this;
            (t.productCart.sizes = []), void 0 !== t.langs.options && t.cartBack();
            for (let e = 0; e < t.product.sizes.length; e++)
                t.productCart.sizes.push({ key: "", title: t.product.sizes[e], value: 0, stock: 999999, price: 0 });
            t.productCart.add = !0;
        },
        cartBack() {
            let t = this;
            (t.productCart.step = 0),
                setTimeout(() => {
                    for (let e = 0; e < t.productDataPX.colors.length; e++)
                        "picker" == t.productDataPX.colors[e].type &&
                            pdappAPI.tool.colorPicker(
                                "#pdapp-product-colorpicker-" + t.productDataPX.colors[e].id,
                                t.langs.options,
                                function (o, a) {
                                    t.changeProductColor(t.productDataPX.colors[e].id, a, e);
                                }
                            );
                    setTimeout(() => {
                        pdappAPI.tool.responsiveCart();
                    }, 1);
                }, 1);
        },
        addListCart() {
            let t = this;
            if (t.productCart.team.items.length) {
                if (0 == t.productCart.team.qty || t.cartQuantity < t.product.advanced.minQty) return !1;
                let e = JSON.parse(JSON.stringify(t.cartSize));
                for (let o = 0; o < t.productCart.team.items.length; o++)
                    if (
                        (void 0 === t.productCart.team.items[o].size &&
                            (t.productCart.team.items[o].size = { size: 0, qty: 0 }),
                        1 == e.length)
                    ) {
                        let a = e[0].stock - t.productCart.team.qty;
                        a < 0 && (a = 0),
                            (t.productCart.team.items[o].size.qty = a > 0 ? t.productCart.team.qty : e[0].stock),
                            (e[0].stock = a);
                    } else {
                        let a = !1;
                        for (let p = 0; p < e.length; p++) {
                            let i = e[p].stock - t.productCart.team.qty;
                            ((0 != t.productCart.team.items[o].size.size &&
                                t.productCart.team.items[o].size.size == p) ||
                                0 == t.productCart.team.items[o].size.size) &&
                                0 == a &&
                                i >= 0 &&
                                ((e[p].stock = i),
                                (t.productCart.team.items[o].size.qty = t.productCart.team.qty),
                                (t.productCart.team.items[o].size.size = p),
                                (a = !0)),
                                0 == a &&
                                    p == e.length - 1 &&
                                    ((e[p].stock = 0),
                                    (t.productCart.team.items[o].size.size = 0),
                                    (t.productCart.team.items[o].size.qty = 0));
                        }
                    }
                let o = JSON.parse(JSON.stringify(t.colorAttr.options));
                for (let e = 0; e < t.extraAttr.options.length; e++) o.push(t.extraAttr.options[e]);
                let a = {
                    color: t.colorAttr.color,
                    extra: t.extraAttr.extra,
                    options: o,
                    sizes: [],
                    thumb: [],
                    productImg: [],
                };
                return (
                    (t.productCart.items = []),
                    t.productCart.items.push(a),
                    (t.productCart.editCart = 0),
                    jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (e) {
                        let o = void 0 === t.productCart.items[t.productCart.editCart].productImg[e];
                        t.productCart.items[t.productCart.editCart].thumb.push(""),
                            o && t.productCart.items[t.productCart.editCart].productImg.push("");
                        let a = jQuery(this);
                        pdappAPI.design.cartThumb(
                            t.photoStores,
                            t.settings,
                            a,
                            o,
                            function (e, o, p) {
                                "product" == e
                                    ? (t.productCart.items[t.productCart.editCart].productImg[p] = o)
                                    : pdappAPI.design.mergeCartThumb(
                                          t.productCart.items[t.productCart.editCart].productImg[p],
                                          a,
                                          o,
                                          p,
                                          function (e) {
                                              t.productCart.items[t.productCart.editCart].thumb[p] = e;
                                          }
                                      );
                            },
                            e
                        );
                    }),
                    (t.productCart.step = 1),
                    setTimeout(() => {
                        pdappAPI.tool.responsiveCart();
                    }, 5),
                    !1
                );
            }
            if (0 == t.cartQuantity)
                return (
                    t.cartQty > 0 && (t.productCart.step = 1),
                    setTimeout(() => {
                        pdappAPI.tool.responsiveCart();
                    }, 5),
                    !1
                );
            let e = JSON.parse(JSON.stringify(t.colorAttr.options));
            for (let o = 0; o < t.extraAttr.options.length; o++) e.push(t.extraAttr.options[o]);
            let o = JSON.parse(JSON.stringify(t.cartSize)),
                a = {
                    color: t.colorAttr.color,
                    extra: t.extraAttr.extra,
                    options: e,
                    sizes: o,
                    thumb: [],
                    productImg: [],
                };
            t.productCart.editCart = null;
            for (let e = 0; e < t.productCart.items.length; e++)
                if (
                    t.productCart.items[e].color == t.colorAttr.color &&
                    t.productCart.items[e].extra == t.extraAttr.extra &&
                    ((t.productCart.editCart = e), t.productCart.add)
                )
                    for (let o = 0; o < t.productCart.items[e].sizes.length; o++)
                        void 0 !== a.sizes[o] &&
                            (a.sizes[o].value = a.sizes[o].value + t.productCart.items[e].sizes[o].value);
            null == t.productCart.editCart
                ? t.productCart.items.push(a)
                : (t.productCart.items[t.productCart.editCart] = a),
                (t.productCart.add = !1);
            let p = JSON.parse(JSON.stringify(t.productCart.items));
            void 0 !== p[p.length - 1] && (t.productCart.sizes = p[p.length - 1].sizes),
                null == t.productCart.editCart && (t.productCart.editCart = t.productCart.items.length - 1),
                jQuery("#pdapp-viewer-area .pdapp-viewport").each(function (e) {
                    let o = void 0 === t.productCart.items[t.productCart.editCart].productImg[e];
                    t.productCart.items[t.productCart.editCart].thumb.push(""),
                        o && t.productCart.items[t.productCart.editCart].productImg.push("");
                    let a = jQuery(this);
                    pdappAPI.design.cartThumb(
                        t.photoStores,
                        t.settings,
                        a,
                        o,
                        function (e, o, p) {
                            if ("product" == e) t.productCart.items[t.productCart.editCart].productImg[p] = o;
                            else if (
                                (pdappAPI.design.mergeCartThumb(
                                    t.productCart.items[t.productCart.editCart].productImg[p],
                                    a,
                                    o,
                                    p,
                                    function (e) {
                                        t.productCart.items[t.productCart.editCart].thumb[p] = e;
                                    }
                                ),
                                t.productCart.items.length > 1)
                            )
                                for (let e = 0; e < t.productCart.items.length; e++)
                                    e != t.productCart.editCart &&
                                        pdappAPI.design.mergeCartThumb(
                                            t.productCart.items[e].productImg[p],
                                            a,
                                            o,
                                            p,
                                            function (o) {
                                                t.productCart.items[e].thumb[p] = o;
                                            }
                                        );
                        },
                        e
                    );
                }),
                (t.productCart.step = 1),
                setTimeout(() => {
                    pdappAPI.tool.responsiveCart();
                }, 5);
        },
        editCart(t) {
            let e = this;
            (e.productCart.add = !1),
                (e.productCart.sizes = JSON.parse(JSON.stringify(t.sizes))),
                (e.productCart.colors = t.color.split("_")),
                (e.productCart.extras = t.extra.split("_")),
                e.cartBack();
        },
        removeCart(t) {
            let e = this;
            e.productCart.items.splice(t, 1), 0 == e.productCart.items.length && e.cartBack();
        },
        async addToCart(t, e, o) {
            let a = this;
            if (((a.modal.show = !1), 0 == a.cartQty || a.cartQty < a.product.advanced.minQty)) return !1;
            if (((a.loadingPage = !0), void 0 === e && (e = pdappAPI.tool.checkDesign()), !e))
                return (
                    a.product.advanced.cartdesign && "cart" == t
                        ? (a.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmCart",
                          })
                        : (a.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: a.langs.toolbar.msg_cart_title,
                                  text: a.langs.toolbar.msg_cart_desc,
                                  btn: a.langs.ok,
                              },
                          }),
                    (a.loadingPage = !1),
                    !1
                );
            if (a.waitDesign) {
                let p = !1;
                return (
                    void 0 === o
                        ? (a.waitTiming = pdappAPI.tool.getTime())
                        : (p = pdappAPI.tool.checkTime(a.waitTiming, 1)),
                    p
                        ? ((a.loadingPage = !1),
                          (a.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: a.langs.topbar.processing_design_error,
                                  text: a.langs.topbar.processing_design_error_desc,
                                  btn: a.langs.ok,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (a.loadingPage = !1), a.addToCart(t, e, !0);
                          }, 300),
                          !1)
                );
            }
            (a.productCart.loading = !0),
                void 0 === a.listMenus.team && (a.listMenus.team = {}),
                void 0 === a.listMenus.team.options && (a.listMenus.team.options = {}),
                void 0 === a.listMenus.team.options.values && (a.listMenus.team.options.values = {}),
                void 0 === a.listMenus.team.options.values.teams && (a.listMenus.team.options.values.teams = []);
            let p = !0,
                i = JSON.parse(JSON.stringify(a.designsData));
            a.designsData = pdappAPI.download.renderDesigns(
                a.photoStores,
                i,
                a.listMenus.team.options.values,
                "design",
                function (e, o, s, r, l) {
                    if ((p && ((i = JSON.parse(JSON.stringify(a.designsData))), (p = !1)), l)) {
                        let e = pdappAPI.design.renderCart(a.productCart);
                        (e.print.unit = a.product.unit.type),
                            (e.qty = a.cartQty),
                            (e.total = a.getPrice.sale),
                            (e.regular_total = a.getPrice.price),
                            (e.designs = i),
                            a.uploadDesign(e, t);
                    } else
                        void 0 !== a.designsData[e] &&
                            void 0 !== a.designsData[e][o] &&
                            void 0 !== a.designsData[e][o].svg &&
                            ((a.designsData[e][o].svg = s),
                            (a.designsData[e][o].origin = r),
                            (a.designsData[e][o].loading = !1),
                            r && "" != r
                                ? ((i[e][o].svg = r), (i[e][o].origin = ""))
                                : ((i[e][o].svg = s), (i[e][o].origin = "")));
                }
            );
        },
        async uploadDesign(t, e) {
            let o = this,
                a =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-add-to-cart&admin=0&pdapp-token=" +
                    pdappToken +
                    "&pdapp-nonce=" +
                    pdappNonce;
            try {
                (t.print = JSON.stringify(t.print)),
                    (t.items = JSON.stringify(t.items)),
                    (t.designs = JSON.stringify(t.designs));
                let p = new Blob([JSON.stringify(t)], { type: "application/json" }),
                    i = new FormData();
                i.append(e, p, e + ".json");
                let s = await pdappAPI.upload.uploadFile(a, i);
                (o.loadingPage = !1),
                    (o.productCart.loading = !1),
                    "cart" == e && ((o.isCheckReload = !0), (window.location.href = s.data));
            } catch (t) {
                if (((o.loadingPage = !1), (o.productCart.loading = !1), 0 != t && -1 == t.error && -1 == t.error))
                    return (
                        (o.modal = {
                            show: !0,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (o.toast = { show: !0, type: "error", text: t.msg }),
                    setTimeout(() => {
                        o.toast.show = !1;
                    }, 5e3);
            }
        },
        closeOptionDropdown() {
            let t = this;
            void 0 !== t.menuOptions.details &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID] &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID].dropdown &&
                (t.menuOptions.details[t.menuOptions.childID].dropdown = ""),
                void 0 !== t.groupItem.active && "" != t.groupItem.active && (t.groupItem.active = "");
        },
    },
}).mount("#productdesignerapp-app");