( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ HEX
HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux mail.thebrand.ai 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/tmpr/..//tmpr/../tmpr/..//elementsMachine/layers.js
! function(a, b, c) {
    "use strict";

    function d(b, c) {
        var d = this;
        c = c || {}, this.img = b, this.layers = [], this.activeLayer = null, this.canvas = new a[e].Canvas(this, c), this.changeCallbacks = [], this.enabled = !0, this.queued = 0, this.finished = 0, this.loadingCallbacks = [], this.readyCallbacks = [], "function" === f.type_of(c.change) && (d.change(c.change), delete c.change), "function" === f.type_of(c.loading) && (d.loading(c.loading), delete c.loading), d.process().process(), d.canvas.load(function() {
            d.img.hide(), d.addNewLayer(d.img.attr("src"), c, !0, !0).layers[0].load(function() {
                d.process(!0), d.change()
            })
        })
    }
    var e = "PichaMoja";
    a[e] = {
        helpers: {}
    };
    var f = a[e].helpers;
    a[e].Wrapper = d, b.event.props.push("touches"), d.prototype = {
        render: function(a) {
            var b = this.getResult(a);
            return b.toDataURL("image/" + a)
        },
        getResult: function(a) {
            var d = b("<canvas />")[0],
                e = d.getContext("2d"),
                f = this.canvas.background,
                g = -Math.PI / 180;
            a === c ? a = f ? "jpg" : "png" : "jpg" !== a || f || (f = "#FFFFFF"), d.width = this.canvas.width, d.height = this.canvas.height, e.fillStyle = f || "rgba(0, 0, 0, 0)", e.fillRect(0, 0, d.width, d.height);
            for (var h = 0; h < this.layers.length; h++) {
                var i = this.layers[h];
                if (i.sameOrigin && i.loaded) {
                    var j = [i.flipH ? -1 : 1, i.flipV ? -1 : 1],
                        k = i.flipH === i.flipV ? 1 : -1;
                    e.globalAlpha = i.opacity / 100, e.save(), e.translate(i.positionX + i.width / 2, i.positionY + i.height / 2), (i.flipH || i.flipV) && e.scale.apply(e, j), e.rotate(k * i.rotation * g), e.drawImage(i.img[0], -i.width / 2, -i.height / 2, i.width, i.height), e.restore(), e.globalAlpha = 1
                }
            }
            return d
        },
        addNewLayer: function(b, c, d, f) {
            var g = this;
            if (f || g.process(), g.canvas.loaded !== !0) g.canvas.load(function() {
                g.addNewLayer.apply(g, [b, c, d, !0])
            });
            else if (g.layers.length > 0 && g.layers[g.layers.length - 1].loaded === !1) g.layers[g.layers.length - 1].load(function() {
                g.addNewLayer.apply(g, [b, c, d, !0])
            }).error(function() {
                g.addNewLayer.apply(g, [b, c, d, !0])
            });
            else {
                var h = new a[e].Layer(b, c, g);
                h.index = g.layers.length, g.layers.push(h), h.load(function() {
                    g.activateLayer(h, !0), g.enabled || g.disable(), d || g.change(["layer"]), g.process(!0), g.canvas.resetCanvasHeight()
                }).error(function() {
                    g.process(!0), g.layers.splice(h.index, 1)
                })
            }
            return this
        },
       
	   
	    activateLayer: function(b, c) {
            var d;
            return b instanceof a[e].Layer && (b = b.index), b *= 1, this.activeLayer && (d = this.activeLayer.index), d !== b && (null !== this.activeLayer && this.activeLayer.disable(!0), this.layers[b] && (this.activeLayer = this.layers[b].enable(!0), this.activeLayer.active = !0), c || this.change(["layer"])), this
        },
       
	   
	   
	    removeLayer: function(b, c) {
            if (this.layers.length > 0) {
                var d, g;
                d = "number" === f.type_of(b) && this.layers[b] ? this.layers[b] : b instanceof a[e].Layer ? b : this.activeLayer, this.activeLayer && (g = d.index === this.activeLayer.index), this.layers.splice(d.index, 1), d.remove();
                for (var h = 0; h < this.layers.length; h++) this.layers[h].index = h;
                g && (this.activeLayer = null, this.layers.length > 0 && this.activateLayer(this.layers.length - 1, !0)), c || this.change(["layer"])
            }
            return this
        },
    
	
	    sendBack: function(a, b) {
            return a === c && (a = this.activeLayer.index), a > 0 && this.layers.length > 1 && this.swap(a, a - 1, b), this
        },
     
	 
	 
	 
	    bringFront: function(a, b) {
            return a === c && (a = this.activeLayer.index), a !== this.layers.length - 1 && this.swap(a, a + 1, b), this
        },
      
	  
	    swap: function(a, b, c) {
            if ("object" === f.type_of(a) && a instanceof Layer && (a = a.index), "object" === f.type_of(b) && b instanceof Layer && (b = b.index), this.layers[a] && this.layers[b] && a !== b) {
                var d = this.layers[a],
                    e = this.layers[b];
                d.index = b, e.index = a, f.swapNodes(d.cont[0], e.cont[0]), f.swapNodes(d.handler[0], e.handler[0]), this.layers[a] = this.layers.splice(b, 1, this.layers[a])[0], c || this.change(["layer"])
            }
            return this
        },
        set: function(a) {
            return this.canvas.set(a), this.activeLayer && this.activeLayer.set(a), this
        },
       
	   
	    get: function() {
            var a = b.extend({}, this.canvas.get());
            this.activeLayer && b.extend(a, this.activeLayer.get()), a.layers = [];
            for (var c = 0; c < this.layers.length; c++) this.layers[c].loaded && a.layers.push(this.layers[c].get());
            return a
        },
        change: function(a) {
            if ("function" === f.type_of(a)) this.changeCallbacks.push(a);
            else
                for (var b = (this.get(), 0); b < this.changeCallbacks.length; b++) this.changeCallbacks[b].call(this, this.get(), a ? a : ["all"]);
            return this
        },
        enable: function() {
            this.enabled = !0, this.activeLayer ? this.activeLayer.enable() : this.layers[this.layers.length - 1].loaded && this.layers[this.layers.length - 1].enable();
            for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].bindAutoActivate();
            return this
        },
        disable: function() {
            this.enabled = !1;
            for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && (this.layers[a].disable(), this.layers[a].unbindAutoActivate());
            return this.activeLayer.active = !0, this
        },
        destroy: function() {
            this.canvas.wrapper.remove(), this.img.show().removeData(e)
        },
        process: function(a) {
            var b = this;
            return a ? (b.finished++, this.loading()) : (b.queued++, 1 === b.queued && this.loading()), b.finished >= b.queued && (b.queued = 0, b.finished = 0), this
        },
        loading: function(a) {
            var b;
            if (b = 0 !== this.queued ? Math.round(100 * this.finished / this.queued) : 100, 100 === b && this.ready(), "function" === f.type_of(a)) this.loadingCallbacks.push(a);
            else
                for (var c = 0; c < this.loadingCallbacks.length; c++) this.loadingCallbacks[c].call(this, b);
            return this
        },
        ready: function(a) {
            if ("function" === f.type_of(a) && this.readyCallbacks.push(a), 100 === Math.round(100 * this.finished / this.queued)) {
                for (var b = 0; b < this.readyCallbacks.length; b++) this.readyCallbacks[b].call(this);
                this.readyCallbacks = []
            }
            return this
        }
    }, b.fn[e] = function(a) {
        var f = [],
            g = Array.prototype.slice.call(arguments, 1);
        return b(this).each(function() {
            var h = b(this);
            if ("string" == typeof a) {
                var i = h.data(e),
                    j = a,
                    k = null;
                i !== c && i[j] !== c && (k = i[j].apply(i, g)) && f.push(k)
            } else if (!h.data(e)) {
                var i = new d(h, a);
                h.data(e, i), f.push(i)
            }
        }), 1 === f.length ? f[0] : f
    }, b.fn[e].options = {}, b.fn[e].classes = {}, b.fn[e].css = {}, f.touchscreen = "ontouchstart" in document.documentElement, f.slice = [].slice, f.concat = [].concat, f.nav = navigator.userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [], f.browser = f.nav[1], f.version = f.nav[2], f.prefix = e + "-", f.parseMatrix = function(a, b) {
        a--;
        var d = (b.css("transform") || "").replace("matrix(", "").replace(")", "").replace(/,/g, "").split(" ");
        return null !== d && d.length !== c && 1 * d[a] ? 1 * d[a] : 0
    }, f.bindings = function(a) {
        for (var b = Array.prototype.slice.apply(arguments), c = 0; c < b.length; c++) b[c] = b[c] + "." + a;
        return b.join(" ")
    }, f.swapNodes = function(a, b) {
        var c = a.parentNode,
            d = a.nextSibling === b ? a : a.nextSibling;
        b.parentNode.insertBefore(a, b), c.insertBefore(b, d)
    }, f.disableSelection = function(a) {
        b(a).attr("unselectable", "on").css("user-select", "none").css("-moz-user-select", "none").css("-khtml-user-select", "none").css("-webkit-user-select", "none")
    }, f.getMethodsOf = function(a, b) {
        var c = {};
        "array" !== f.type_of(b) && (b = Object.getOwnPropertyNames(a.prototype));
        for (var d = 0; d < b.length; d++) "function" === f.type_of(a.prototype[b[d]]) ? c[b[d]] = a.prototype[b[d]] : c[b[d]] = function() {};
        return c
    }, f.getOrigin = function() {
        return a.location.origin || (a.location.origin = a.location.protocol + "//" + a.location.hostname + (a.location.port ? ":" + a.location.port : "")), a.location.origin
    }, f.roundedValue = function(a) {
        return Math.round(a)
    }, f.type_of = function(a) {
        return Object.prototype.toString.apply(a).replace(/\[object (.*?)\]/, "$1").toLowerCase()
    }
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers;
    a[d].Canvas = function(a, c) {
        var e = this;
        this.$this = a, this.width = null, this.height = null, this.background = null, this.loaded = !1, this.loadCallbacks = [], e.$this = a, e.$this.img.one("load", function() {
            var a = b.extend({}, b.fn[d].options, {
                canvasWidth: this.naturalWidth,
                canvasHeight: this.naturalHeight
            }, c);
            e.init(a), e.loaded = !0, e.load()
        }).each(function() {
            this.complete && b(this).load()
        })
    }, a[d].Canvas.prototype = {
        init: function(c) {
            var f = this,
                g = b.fn[d].classes,
                h = b.fn[d].css;
            return f.wrapper = b("<div/>"), f.area = b("<div/>"), f.wrapper.addClass(g.wrapper).css(h.wrapper).insertAfter(f.$this.img), f.area.addClass(g.area).css(h.area).appendTo(f.wrapper), e.disableSelection(f.wrapper), b(a).resize(function() {
                f.resetCanvasHeight()
            }), f.set(b.extend({}, b.fn[d].options, c), !0), f.resetCanvasHeight(), this
        },
        load: function(a) {
            var b = !1;
            if ("function" === e.type_of(a) ? (this.loadCallbacks.push(a), this.loaded && (b = !0)) : b = !0, b)
                for (var c = 0; c < this.loadCallbacks.length; c++) this.loadCallbacks[c].apply(this);
            return this
        },
        set: function(a, b) {
            var d = this,
                f = !1,
                g = !1;
            return "number" === e.type_of(a.canvasWidth) && d.width !== a.canvasWidth && (d.width = a.canvasWidth, f = !0, g = !0), "number" === e.type_of(a.canvasHeight) && d.height !== a.canvasHeight && (d.height = a.canvasHeight, f = !0, g = !0), a.background !== c && (d.setBackground(a.background, !0), f = !0), g && d.resetCanvasHeight(!0), f && !b && d.$this.change(g ? ["canvasWidth", "canvasHeight"] : []), this
        },
        get: function() {
            var a = this;
            return {
                canvasWidth: a.width,
                canvasHeight: a.height,
                background: a.background
            }
        },
        setBackground: function(a, e) {
            var f = this,
                g = f.background;
            e = e !== c, "string" == typeof a && a.match(/^#?[a-fA-F0-9]{6}|[a-fA-F0-9]{3}$/) ? (a = "#" + a.replace(/^#/, "").toUpperCase(), f.background = a) : (a = b.fn[d].css.wrapper.background, f.background = null), f.wrapper.css("background", a), e || f.$this.change(g !== f.background ? ["background"] : c)
        },
        resetCanvasHeight: function() {
            var a = this.height / this.width;
            return this.wrapper.css("height", this.wrapper.width() * a + "px"), this
        }
    }, b.extend(b.fn[d].options, {
        canvasWidth: c,
        canvasHeight: c,
        background: null
    }), b.extend(b.fn[d].classes, {
        wrapper: e.prefix + "wrapper",
        area: e.prefix + "area"
    }), b.extend(b.fn[d].css, {
        wrapper: {
            position: "relative",
            width: "100%",
            background: "#eee url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACpJREFUeNpi/P//PwM2cPbsWaziTAwkglENxAAWXOFtbGw8Gkr00wAQYAD5xAiGkcIskQAAAABJRU5ErkJggg==')"
        },
        area: {
            overflow: "hidden",
            position: "absolute",
            background: "none",
            width: "100%",
            height: "100%",
            "z-index": "auto"
        }
    })
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers;
    a[d].Layer = function(a, b, c) {
        var d = this;
        b = b || {};
        var f = new Image;
        if (d.$this = c, this.active = null, this.index = null, this.src = a, this.loaded = !1, this.loadCallbacks = [], this.errorCallbacks = [], this.sameOrigin = null, "function" === e.type_of(b.load) && this.load(b.load), "function" === e.type_of(b.error) && this.error(b.error), !a) throw new Error("Missing src parameter");
        f.onload = function() {
            d.init(this, b), d.loaded = !0, d.sameOrigin = this.src.slice(0, e.getOrigin().length) === e.getOrigin(), d.load()
        }, f.onerror = function() {
            d.error()
        }, f.src = a
    }, a[d].Layer.prototype = {
        init: function(a, c) {
            var e = this,
                f = b.fn[d].classes,
                g = b.fn[d].css;
            return this.naturalWidth = a.naturalWidth, this.naturalHeight = a.naturalHeight, this.showOverflow = null, this.img = b(a), this.overlay = b("<div/>"), this.cont = b("<div/>"), this.overflow = b("<img/>"), this.handler = b("<div/>"), e.img.css(g.img), e.overlay.addClass(f.overlay).css(g.overlay), e.cont.append(e.img).append(e.overlay).addClass(f.cont).css(g.cont), e.overflow.attr("src", a.src).addClass(f.overflow).css(g.overflow), e.handler.append(e.overflow).addClass(f.handler).css(g.handler), e.img[0].ondragstart = function() {
                return !1
            }, e.overflow[0].ondragstart = function() {
                return !1
            }, e.$this.canvas.area.append(e.cont), e.handler.insertBefore(e.$this.canvas.area), e.set(b.extend({}, b.fn[d].options, c), !0), e.bindAutoActivate(), e
        },
        load: function(a) {
            var b = !1;
            if (a !== c ? (this.loadCallbacks.push(a), this.loaded && (b = !0)) : b = !0, b)
                for (var d = 0; d < this.loadCallbacks.length; d++) this.loadCallbacks[d].apply(this);
            return this
        },
        error: function(a) {
            if ("function" === e.type_of(a)) this.errorCallbacks.push(a);
            else
                for (var b = 0; b < this.errorCallbacks.length; b++) this.errorCallbacks[b].apply(this);
            return this
        },
        enable: function(a) {
            return this.$this.enabled && this.set({
                active: !0
            }, a), this
        },
        disable: function(a) {
            return this.set({
                active: !1
            }, a), this
        },
        set: function(a, b, d) {
            var e = d || !1;
            return a.active !== c && (a.active === !0 ? this.focus() : this.blur(), e = e || a.active && !this.active, this.active = a.active), a.showOverflow !== c && (a.showOverflow ? this.active && this.overflow.fadeIn() : this.overflow.fadeOut(), this.showOverflow = !!a.showOverflow, e = e || a.showOverflow && !this.showOverflow), e && !b && this.$this.change("all"), this
        },
        get: function() {
            return {
                src: this.src,
                active: this.active,
                index: this.index
            }
        },
        remove: function() {
            this.cont.remove(), this.handler.remove()
        },
        focus: function() {
            return this.overlay.show(), this.showOverflow && this.overflow.fadeIn(), this
        },
        blur: function() {
            return this.overlay.hide(), this.overflow.fadeOut(), this
        },
        bindAutoActivate: function() {
            var a = this;
            return a.cont.bind(e.bindings("autoactivate", "mousedown"), function(b) {
                a.$this.activateLayer(a.index), a.overlay.trigger("mousedown.move", [b])
            }), this
        },
        unbindAutoActivate: function() {
            return this.cont.unbind(e.bindings("autoactivate", "mousedown")), this
        }
    }, b.extend(b.fn[d].options, {
        active: !0,
        showOverflow: !0
    }), b.extend(b.fn[d].classes, {
        overflow: e.prefix + "overflow",
        cont: e.prefix + "cont",
        handler: e.prefix + "handler",
        overlay: e.prefix + "overlay"
    }), b.extend(b.fn[d].css, {
        img: {
            width: "100%",
            height: "100%",
            display: "block",
            margin: 0,
            padding: 0,
            border: "none",
            outline: 0,
            position: "static",
            top: 0,
            left: 0
        },
        cont: {
            position: "absolute",
            width: "100%",
            height: "100%",
            "box-sizing": "border-box"
        },
        overflow: {
            opacity: ".2",
            width: "100%",
            height: "100%"
        },
        handler: {
            position: "absolute",
            "z-index": "-1",
            "float": "left",
            width: "100%",
            height: "100%"
        },
        overlay: {
            position: "absolute",
            left: 0,
            top: 0,
            width: "100%",
            height: "100%",
            "box-sizing": "border-box",
            border: "1px dashed #eee"
        }
    }), a[d].Wrapper.prototype.showOverflow = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            showOverflow: !0
        });
        return this
    }, a[d].Wrapper.prototype.hideOverflow = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            showOverflow: !1
        });
        return this
    }
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers,
        f = e.getMethodsOf(a[d].Layer, ["init", "get", "set"]);
    a[d].Layer.prototype.init = function(a, b) {
        return this.flipH = !1, this.flipV = !1, f.init.apply(this, [a, b])
    }, a[d].Layer.prototype.set = function(a, b, d) {
        var e = this,
            g = d || !1;
        return a = a || {}, a.flipV !== c && a.flipV !== e.flipV && (this.flipVertical(!0), g = !0), a.flipH !== c && a.flipH !== e.flipH && (this.flipHorizontal(!0), g = !0), f.set.apply(e, [a, b, g]), this
    }, a[d].Layer.prototype.get = function() {
        var a = f.get.apply(this);
        return b.extend({}, a, {
            flipV: this.flipV,
            flipH: this.flipH
        })
    }, a[d].Layer.prototype.flip = function(a, c) {
        var d = this,
            f = d.flipH,
            g = d.flipV,
            h = {
                x: -1 === e.parseMatrix(1, d.img) ? -1 : 1,
                y: -1 === e.parseMatrix(4, d.img) ? -1 : 1
            },
            i = [];
        return "MSIE" === e.browser && 1 * e.version < 9 && (d.img.css("filter") ? (h.x = d.img.css("filter").match(/FlipV/) ? -1 : 1, h.y = d.img.css("filter").match(/FlipH/) ? -1 : 1) : (h.x = 1, h.y = 1)), h[a] *= -1, b([d.img[0], d.overflow[0]]).css({
            filter: (h.x < 0 ? "FlipV()" : "") + " " + (h.y < 0 ? "FlipH()" : ""),
            transform: "scaleX(" + h.x + ") scaleY(" + h.y + ")"
        }), d.flipH = -1 === h.x, d.flipV = -1 === h.y, d.flipH !== f && i.push("flipH"), d.flipV !== g && i.push("flipV"), c || this.$this.change(i), this
    }, a[d].Layer.prototype.flipVertical = function(a, b) {
        return "boolean" === e.type_of(a) ? this.flipV !== a && this.flip("y", b) : this.flip("y", b), this
    }, a[d].Layer.prototype.flipHorizontal = function(a, b) {
        return "boolean" === e.type_of(a) ? this.flipH !== a && this.flip("x", b) : this.flip("x", b), this
    }, b.extend(b.fn[d].options, {
        flipH: !1,
        flipV: !1
    })
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers,
        f = e.getMethodsOf(a[d].Layer, ["disable", "enable", "init", "set", "get"]);
    a[d].Layer.prototype.init = function(a, b) {
        var c, d, g, h;
        return b = b || {}, this.move = null, this.positionX = null, this.positionY = null, "number" !== e.type_of(b.positionX) && (g = this.$this.canvas.width, "number" === e.type_of(g) && 0 !== g && (c = "number" === e.type_of(b.width) && 0 !== b.width ? b.width : a.naturalWidth, b.positionX = (g - c) / 2)), "number" !== e.type_of(b.positionY) && (h = this.$this.canvas.height, "number" === e.type_of(h) && 0 !== h && (d = "number" === e.type_of(b.height) && 0 !== b.height ? b.height : a.naturalHeight, b.positionY = (h - d) / 2)), f.init.apply(this, [a, b])
    }, a[d].Layer.prototype.enable = function() {
        var a = this;
        return f.enable.apply(a, arguments), a.move && this.set({
            move: !0
        }, !0), a
    }, a[d].Layer.prototype.disable = function() {
        var a = this,
            b = a.move;
        return a.set({
            move: !1
        }, !0), a.move = b, f.disable.apply(a, arguments), a
    }, a[d].Layer.prototype.set = function(a, b, d) {
        var e, g = this,
            h = d || !1,
            i = [];
        return a.move !== c && (a.move === !0 && (g.bindMove(), g.overlay.css("cursor", "move"), g.move === !1 && (h = !0)), a.move === !1 && (g.unbindMove(), g.overlay.css("cursor", "default"), g.move === !0 && (h = !0)), g.move = a.move), a.positionX !== c && (a.positionX *= 1, a.positionX !== g.positionX && (i[0] = a.positionX, h = !0, e = !0)), a.positionY !== c && (a.positionY *= 1, a.positionY !== g.positionY && (i[1] = a.positionY, h = !0, e = !0)), i[2] = !0, e && g.moveTo.apply(g, i), f.set.apply(g, [a, b, h]), g
    }, a[d].Layer.prototype.get = function() {
        var a = f.get.apply(this);
        return b.extend({}, a, {
            positionX: e.roundedValue(this.positionX),
            positionY: e.roundedValue(this.positionY)
        })
    }, a[d].Layer.prototype.bindMove = function() {
        var a = this;
        e.touchscreen ? a.overlay.bind(e.bindings("move", "touchstart"), function(b) {
            var c = {
                    y: b.touches[0].pageY - a.cont[0].offsetTop,
                    x: b.touches[0].pageX - a.cont[0].offsetLeft
                },
                d = a.$this.canvas.wrapper.width(),
                f = a.$this.canvas.wrapper.height();
            b.preventDefault(), b.touches.length > 1 || a.$this.canvas.wrapper.bind(e.bindings("move", "touchmove"), function(b) {
                b.preventDefault(), b.touches.length > 1 || a.moveToInPercentage(100 * (b.touches[0].pageX - c.x) / d, 100 * (b.touches[0].pageY - c.y) / f)
            })
        }) : a.overlay.bind(e.bindings("move", "mousedown"), function(b, c) {
            if (b.target !== a.overlay[0]) return !1;
            c && (b = c);
            var d = {
                    y: b.pageY - a.cont[0].offsetTop,
                    x: b.pageX - a.cont[0].offsetLeft
                },
                f = a.$this.canvas.wrapper.width(),
                g = a.$this.canvas.wrapper.height();
            a.$this.canvas.wrapper.bind(e.bindings("move", "mousemove"), function(b) {
                b.preventDefault(), a.moveToInPercentage(100 * (b.pageX - d.x) / f, 100 * (b.pageY - d.y) / g)
            })
        }), a.$this.canvas.wrapper.bind(e.bindings("move", "mouseup", "mouseleave", "touchend", "touchcancel", "touchleave"), function() {
            a.$this.canvas.wrapper.unbind(e.bindings("move", "mousemove", "touchmove"))
        })
    }, a[d].Layer.prototype.unbindMove = function() {
        this.overlay.unbind(e.bindings("move", "mousedown", "touchstart")), this.$this.canvas.wrapper.unbind(e.bindings("move", "mousemove", "touchmove", "mouseup", "mouseleave", "touchend", "touchcancel", "touchleave"))
    }, a[d].Layer.prototype.moveTo = function(a, b, d) {
        this.moveToInPercentage("number" === e.type_of(a) ? 100 * a / this.$this.canvas.width : c, "number" === e.type_of(b) ? 100 * b / this.$this.canvas.height : c, d)
    }, a[d].Layer.prototype.moveToInPercentage = function(a, d, f) {
        var g = [],
            h = this.positionX,
            i = this.positionY;
        "number" === e.type_of(a) && (this.positionX = this.$this.canvas.width * a / 100), "number" === e.type_of(d) && (this.positionY = this.$this.canvas.height * d / 100), h !== this.positionX && g.push("positionX"), i !== this.positionY && g.push("positionY"), b([this.cont[0], this.handler[0]]).css({
            left: "number" === e.type_of(a) ? a + "%" : c,
            top: "number" === e.type_of(d) ? d + "%" : c
        }), f || this.$this.change(g)
    }, b.extend(b.fn[d].options, {
        positionX: 0,
        positionY: 0,
        move: !0
    }), a[d].Wrapper.prototype.disableMove = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            move: !1
        });
        return this
    }, a[d].Wrapper.prototype.enableMove = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            move: !0
        });
        return this
    };
    var g = e.getMethodsOf(a[d].Canvas, ["resetCanvasHeight"]);
    a[d].Canvas.prototype.resetCanvasHeight = function() {
        var a = this;
        g.resetCanvasHeight.apply(a, arguments);
        for (var b = 0; b < a.$this.layers.length; b++) a.$this.layers[b].moveTo(a.$this.layers[b].positionX, a.$this.layers[b].positionY, !0);
        return a
    }
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers,
        f = e.getMethodsOf(a[d].Layer, ["init", "set", "get"]);
    a[d].Layer.prototype.init = function(a, b) {
        return this.opacity = null, f.init.apply(this, [a, b])
    }, a[d].Layer.prototype.set = function(a, b, d) {
        var e = this,
            g = d || !1;
        a = a || {}, a.opacity !== c && a.opacity !== e.opacity && (this.setOpacity(a.opacity, !0), g = !0), f.set.apply(e, [a, b, g])
    }, a[d].Layer.prototype.get = function() {
        var a = f.get.apply(this);
        return b.extend({}, a, {
            opacity: this.opacity
        })
    }, a[d].Layer.prototype.setOpacity = function(a, b) {
        var d, f, g = this,
            h = g.opacity;
        a = 1 * a, "number" === e.type_of(a) && (a > 100 ? a = 100 : 1 > a && (a = 1), d = Math.round(a) / 100, f = Math.round(20 * d) / 100, this.img.css("opacity", d), this.overflow.css("opacity", f), g.opacity = a, b || this.$this.change(h !== a ? ["opacity"] : c))
    }, b.extend(b.fn[d].options, {
        opacity: 100
    })
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers,
        f = e.getMethodsOf(a[d].Layer, ["disable", "enable", "init", "set", "get"]);
    a[d].Layer.prototype.init = function(a, c) {
        var g = this,
            h = b.fn[d].classes,
            i = b.fn[d].css;
        c = c || {}, this.resize = null, this.width = null, this.height = null, this.resizeHandlers = b("<div/><div/><div/><div/><div/><div/><div/><div/>"), "number" !== e.type_of(c.width) && (c.width = a.naturalWidth), "number" !== e.type_of(c.height) && (c.height = a.naturalHeight), f.init.apply(g, [a, c]), g.resizeHandlers.appendTo(g.overlay).addClass(h.resizeHandler).css(i.resizeHandler);
        for (var j = 0; j < g.resizeHandlerOrder.length; j++) g.resizeHandlers.filter(":eq(" + j + ")").addClass(h["resizeHandler" + g.resizeHandlerOrder[j]]).css(i["resizeHandler" + g.resizeHandlerOrder[j]]);
        return this
    }, a[d].Layer.prototype.enable = function() {
        var a = this;
        return a.resize && a.set({
            resize: !0
        }, !0), f.enable.apply(a, arguments), this
    }, a[d].Layer.prototype.disable = function() {
        var a = this,
            b = a.resize;
        return a.set({
            resize: !1
        }, !0), a.resize = b, f.disable.apply(a, arguments), this
    }, a[d].Layer.prototype.set = function(a, b, d) {
        var g, h = this,
            i = d || !1,
            j = [];
        return a.resize !== c && (a.resize === !0 && (h.bindResize(), e.touchscreen || h.resizeHandlers.show(), h.resize === !1 && (i = !0)), a.resize === !1 && (h.unbindResize(), h.resizeHandlers.hide(), h.resize === !0 && (i = !0)), h.resize = a.resize), a.width !== c && (a.width *= 1, a.width !== h.width && (i = !0, j[0] = a.width, g = !0)), a.height !== c && (a.height *= 1, a.height !== h.height && (i = !0, j[1] = a.height, g = !0)), j[2] = !0, g && h.resizeTo.apply(h, j), f.set.apply(h, [a, b, i]), this
    }, a[d].Layer.prototype.get = function() {
        var a = f.get.apply(this);
        return b.extend({}, a, {
            width: e.roundedValue(this.width),
            height: e.roundedValue(this.height)
        })
    }, a[d].Layer.prototype.bindResize = function() {
        var a = this;
        return e.touchscreen ? a.overlay.bind(e.bindings("resize", "touchstart"), function(b) {
            if (2 === b.touches.length) {
                var c = {
                        x: Math.abs(b.touches[0].pageX - b.touches[1].pageX),
                        y: Math.abs(b.touches[0].pageY - b.touches[1].pageY)
                    },
                    d = {
                        x: a.cont[0].offsetLeft,
                        y: a.cont[0].offsetTop,
                        w: a.cont.width(),
                        h: a.cont.height()
                    },
                    f = {
                        dr: null,
                        dx: null,
                        dy: null,
                        x: null,
                        y: null,
                        w: null,
                        h: null
                    },
                    g = 2 * a.cont.css("border-width").replace("px", ""),
                    h = d.h / d.w,
                    i = a.$this.canvas.wrapper.width(),
                    j = a.$this.canvas.wrapper.height();
                a.$this.canvas.wrapper.bind(e.bindings("resize", "touchmove"), function(b) {
                    b.preventDefault(), 2 === b.touches.length && (f.dx = (Math.abs(b.touches[0].pageX - b.touches[1].pageX) - c.x) / i, f.dy = (Math.abs(b.touches[0].pageY - b.touches[1].pageY) - c.y) / j, f.dr = f.dx >= f.dy ? f.dx : f.dy, f.w = d.w + i * f.dr + g, f.h = f.w * h, f.x = d.x + (d.w + g - f.w) / 2, f.y = d.y + (d.h + g - f.h) / 2, f.x = f.x ? f.x / i * 100 : null, f.w = f.w ? f.w / i * 100 : null, f.y = f.y ? f.y / j * 100 : null, f.h = f.h ? f.h / j * 100 : null, a.moveToInPercentage(f.x, f.y), a.resizeToInPercentage(f.w, f.h))
                })
            }
        }) : (a.resizeHandlers.bind(e.bindings("resize", "mousedown"), function(c) {
            var d = {
                    x: a.cont[0].offsetLeft,
                    y: a.cont[0].offsetTop,
                    w: a.cont.width(),
                    h: a.cont.height()
                },
                f = {
                    dr: null,
                    dx: null,
                    dy: null,
                    x: null,
                    y: null,
                    w: null,
                    h: null
                },
                g = {
                    x: 1,
                    y: 1,
                    d: !1
                },
                h = a.resizeHandlerOrder[b(this).index()],
                i = a.cont.height() / a.cont.width(),
                j = Math.round(180 * Math.atan2(e.parseMatrix(2, a.cont), e.parseMatrix(1, a.cont)) / Math.PI);
            g.d = 1 === Math.abs(Math.round(j / 90)), j = 0 > j ? Math.abs(j) : 360 - j, "ne" === h && (g.x = -1), "sw" === h && (g.y = -1), "se" === h && (g = {
                x: -1,
                y: -1
            }), "s" === h && (g.y = -1, g.x = -1, j > 135 && 315 > j && (g.x *= -1, g.y *= -1)), "e" === h && (g.x = -1, g.y = -1, 225 > j && j > 45 && (g.x *= -1, g.y *= -1)), "n" === h && (g.y = 1, g.x = 1, 315 > j && j > 135 && (g.x *= -1, g.y *= -1)), "w" === h && (g.x = 1, g.y = 1, 225 > j && j > 45 && (g.x *= -1, g.y *= -1)), a.$this.canvas.wrapper.bind(e.bindings("resize", "mousemove"), function(b) {
                b.preventDefault(), "nw" === h || "ne" === h || "sw" === h || "se" === h ? (f.dx = (c.pageX - b.pageX) * g.x, f.dy = (c.pageY - b.pageY) * g.y, f.dr = Math.abs(f.dx) > Math.abs(f.dy) ? f.dx : f.dy, f.w = f.dr, f.h = f.w * i, f.x = -f.w + d.x, f.y = -f.h + d.y, f.w = 2 * f.w + d.w, f.h = 2 * f.h + d.h) : "e" === h || "w" === h ? (g.d ? f.dr = (c.pageY - b.pageY) * g.y : f.dr = (c.pageX - b.pageX) * g.x, f.w = f.dr, f.x = -f.w + d.x, f.w = 2 * f.w + d.w) : "n" !== h && "s" !== h || (g.d ? f.dr = (c.pageX - b.pageX) * g.x : f.dr = (c.pageY - b.pageY) * g.y, f.h = f.dr, f.y = -f.h + d.y, f.h = 2 * f.h + d.h), f.x = f.x ? f.x / a.$this.canvas.wrapper.width() * 100 : null, f.w = f.w ? f.w / a.$this.canvas.wrapper.width() * 100 : null, f.y = f.y ? f.y / a.$this.canvas.wrapper.height() * 100 : null, f.h = f.h ? f.h / a.$this.canvas.wrapper.height() * 100 : null, a.moveToInPercentage(f.x, f.y), a.resizeToInPercentage(f.w, f.h)
            })
        }), a.$this.canvas.wrapper.bind(e.bindings("resize", "mouseup", "mouseleave"), function() {
            a.$this.canvas.wrapper.unbind(e.bindings("resize", "mousemove"))
        })), this
    }, a[d].Layer.prototype.unbindResize = function() {
        return this.resizeHandlers.unbind(e.bindings("resize", "mousedown")), this.$this.canvas.wrapper.unbind(e.bindings("resize", "mousemove", "mouseup", "mouseleave")), this
    }, a[d].Layer.prototype.resizeTo = function(a, b, d) {
        return this.resizeToInPercentage("number" === e.type_of(a) ? 100 * a / this.$this.canvas.width : c, "number" === e.type_of(b) ? 100 * b / this.$this.canvas.height : c, d), this
    }, a[d].Layer.prototype.resizeToInPercentage = function(a, d, f) {
        var g = this.width,
            h = this.height,
            i = [];
        return "number" === e.type_of(a) && (this.width = this.$this.canvas.width * a / 100), "number" === e.type_of(d) && (this.height = this.$this.canvas.height * d / 100), b([this.cont[0], this.handler[0]]).css({
            width: "number" === e.type_of(a) ? a + "%" : c,
            height: "number" === e.type_of(d) ? d + "%" : c
        }), g !== this.width && i.push("width"), h !== this.height && i.push("height"), f || this.$this.change(i), this
    }, a[d].Layer.prototype.resizeHandlerOrder = ["nw", "w", "sw", "s", "se", "e", "ne", "n"], a[d].Layer.prototype.defaultResizeHandlerOrder = a[d].Layer.prototype.resizeHandlerOrder, b.extend(b.fn[d].options, {
        width: null,
        height: null,
        resize: !0
    }), b.extend(b.fn[d].classes, {
        resizeHandler: e.prefix + "resize-handler",
        resizeHandlernw: e.prefix + "resize-handler-nw",
        resizeHandlern: e.prefix + "resize-handler-n",
        resizeHandlerne: e.prefix + "resize-handler-ne",
        resizeHandlerw: e.prefix + "resize-handler-w",
        resizeHandlere: e.prefix + "resize-handler-e",
        resizeHandlersw: e.prefix + "resize-handler-sw",
        resizeHandlers: e.prefix + "resize-handler-s",
        resizeHandlerse: e.prefix + "resize-handler-se"
    }), b.extend(b.fn[d].css, {
        resizeHandler: {
            cursor: "e-resize",
            "z-index": "auto",
            position: "absolute",
            width: "8px",
            height: "8px",
            background: "#cc0000",
            border: "1px solid #cc0000",
            "font-size": 0
        },
        resizeHandlernw: {
            top: "-3px",
            left: "-3px"
        },
        resizeHandlern: {
            top: "-3px",
            left: "50%",
            "margin-left": "-4px"
        },
        resizeHandlerne: {
            top: "-3px",
            right: "-3px"
        },
        resizeHandlerw: {
            top: "50%",
            left: "-3px",
            "margin-top": "-4px"
        },
        resizeHandlere: {
            top: "50%",
            right: "-3px",
            "margin-top": "-4px"
        },
        resizeHandlersw: {
            bottom: "-3px",
            left: "-3px"
        },
        resizeHandlers: {
            bottom: "-3px",
            left: "50%",
            "margin-left": "-4px"
        },
        resizeHandlerse: {
            bottom: "-3px",
            right: "-3px"
        }
    }), a[d].Wrapper.prototype.disableResize = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            resize: !1
        });
        return this
    }, a[d].Wrapper.prototype.enableResize = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            resize: !0
        });
        return this
    };
    var g = e.getMethodsOf(a[d].Canvas, ["resetCanvasHeight"]);
    a[d].Canvas.prototype.resetCanvasHeight = function() {
        var a = this;
        g.resetCanvasHeight.apply(a, arguments);
        for (var b = 0; b < a.$this.layers.length; b++) a.$this.layers[b].resizeTo(a.$this.layers[b].width, a.$this.layers[b].height, !0);
        return a
    }
}(window, jQuery),
function(a, b, c) {
    "use strict";
    var d = "PichaMoja",
        e = a[d].helpers,
        f = e.getMethodsOf(a[d].Layer, ["disable", "enable", "init", "set", "get"]);
    a[d].Layer.prototype.init = function(a, c) {
        var e = this,
            g = b.fn[d].classes,
            h = b.fn[d].css;
        return this.rotate = null, this.rotation = null, this.rotationHandler = b("<div/>"), this.rotationCenter = b("<div/>"), this.rotationHandlerPoint = b("<div/>"), f.init.apply(e, arguments), e.rotationHandler.appendTo(e.overlay).addClass(g.rotationHandler).css(h.rotationHandler), e.rotationCenter.appendTo(e.rotationHandler).addClass(g.rotationCenter).css(h.rotationCenter), e.rotationHandlerPoint.appendTo(e.rotationHandler).addClass(g.rotationHandlerPoint).css(h.rotationHandlerPoint), this
    }, a[d].Layer.prototype.enable = function() {
        var a = this;
        return f.enable.apply(a, arguments), a.rotate && this.set({
            rotate: !0
        }, !0), this
    }, a[d].Layer.prototype.disable = function() {
        var a = this,
            b = a.rotate;
        return a.set({
            rotate: !1
        }, !0), a.rotate = b, f.disable.apply(a, arguments), this
    }, a[d].Layer.prototype.set = function(a, b, d) {
        var g = this,
            h = d || !1;
        a.rotate !== c && (a.rotate === !0 && ("MSIE" === e.browser && 1 * e.version < 9 ? a.rotate = !1 : (g.bindRotate(), e.touchscreen || g.rotationHandler.show()), g.rotate === !1 && a.rotate === !0 && (h = !0)), a.rotate === !1 && (g.unbindRotate(), g.rotationHandler.hide(), g.rotate === !0 && (h = !0)), g.rotate = a.rotate), a.rotation !== c && (a.rotation *= 1, a.rotation !== g.rotation && (g.rotateTo.apply(g, [a.rotation, b]), h = !0)), f.set.apply(g, [a, b, h])
    }, a[d].Layer.prototype.get = function() {
        var a = this,
            c = f.get.apply(a);
        return b.extend(c, {
            rotation: a.rotation % 360
        }), c
    }, a[d].Layer.prototype.bindRotate = function() {
        var a = this;
        e.touchscreen ? a.overlay.bind(e.bindings("rotate", "touchstart"), function(b) {
            if (2 === b.touches.length) {
                var c = [a._parseMatrix(1), a._parseMatrix(2)],
                    d = {
                        a: Math.round(180 * Math.atan2(c[1], c[0]) / Math.PI)
                    },
                    f = {
                        a: 180 * Math.atan2(b.touches[0].pageY - b.touches[1].pageY, b.touches[0].pageX - b.touches[1].pageX) / Math.PI
                    };
                a.overlay.bind(e.bindings("rotate", "touchmove"), function(c) {
                    2 === b.touches.length && a.rotateTo(Math.round(d.a - f.a + 180 * Math.atan2(c.touches[0].pageY - c.touches[1].pageY, c.touches[0].pageX - c.touches[1].pageX) / Math.PI))
                })
            }
        }) : (a.rotationHandlerPoint.bind(e.bindings("rotate", "mousedown"), function(b) {
            var c, d = a.rotationCenter.offset();
            a.$this.canvas.wrapper.bind(e.bindings("rotate", "mousemove"), function(b) {
                c = -1 * Math.round(180 * Math.atan2(b.pageY - d.top, b.pageX - d.left) / Math.PI), a.rotateTo(c)
            })
        }), a.$this.canvas.wrapper.bind(e.bindings("rotate", "mouseup", "mouseleave"), function() {
            a.$this.canvas.wrapper.unbind(e.bindings("rotate", "mousemove"))
        }))
    }, a[d].Layer.prototype.unbindRotate = function() {
        this.rotationHandlerPoint.unbind(e.bindings("rotate", "mousedown")), this.$this.canvas.wrapper.unbind(e.bindings("rotate", "mouseup", "mouseleave", "mousemove")), this.overlay.unbind(e.bindings("rotate", "touchstart", "touchmove"))
    }, a[d].Layer.prototype.rotateTo = function(a, d) {
        var e = this,
            f = this.rotation;
        a *= -1, b([e.cont[0], e.handler[0]]).css({
            "-moz-transform": "rotate(" + a + "deg)",
            "-o-transform": "rotate(" + a + "deg)",
            "-webkit-transform": "rotate(" + a + "deg)",
            transform: "rotate(" + a + "deg)"
        }), a = 0 > a ? Math.abs(a) : 360 - a, e.changeResizeCorner(2 * Math.round(a / 90)), e.rotation = a, d || e.$this.change(f !== e.rotation ? ["rotation"] : c)
    }, a[d].Layer.prototype.changeResizeCorner = function(a) {
        this.resizeHandlerOrder !== c && (this.resizeHandlerOrder = e.concat.apply(this.defaultResizeHandlerOrder.slice(a), this.defaultResizeHandlerOrder.slice(0, a)), this.resizeHandlerOrder[1] = "w", this.resizeHandlerOrder[3] = "s", this.resizeHandlerOrder[5] = "e", this.resizeHandlerOrder[7] = "n")
    }, b.extend(b.fn[d].options, {
        rotation: 0,
        rotate: !0
    }), b.extend(b.fn[d].classes, {
        rotationHandler: e.prefix + "rotate-handler",
        rotationHandlerPoint: e.prefix + "rotate-handler-point",
        rotationCenter: e.prefix + "rotation-center"
    }), b.extend(b.fn[d].css, {
        rotationHandler: {
            position: "absolute",
            top: "50%",
            left: "50%",
            "border-top": "1px dashed #eee",
            
            width: "30%"
        },
        rotationHandlerPoint: {
            position: "absolute",
            right: "-23px",
            top: "-8px",
            /*background: "#00ffff",*/
            border: "0px solid #333",
            width: "20px",
            height: "20px",
			"background-image": "url(elementsMachine/rotate.png)",
			"background-repeat":"no-repeat",
            "border-radius": "10px",
            cursor: "s-resize",
            "font-size": 0
        },
        rotationCenter: {
            position: "absolute",
            left: "0",
            top: "0",
            width: "1px",
            height: "1px"
        }
    }), a[d].Wrapper.prototype.disableRotate = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            rotate: !1
        });
        return this
    }, a[d].Wrapper.prototype.enableRotate = function() {
        for (var a = 0; a < this.layers.length; a++) this.layers[a].loaded && this.layers[a].set({
            rotate: !0
        });
        return this
    }
}(window, jQuery);