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S,EAAI,eAAe,QAAQ,GAAQ,CAElE,SAAS,eAAe,EAAI,YAAY,MAAM,OAAS,UACvD,KAAK,yBAA0B,EAC/B,KACJ,CAGJ,EAAI,eAAe,EAAI,EAAI,EAAI,eAC/B,EAAI,eAAe,EAAI,EAAI,EAAI,eAE/B,EAAI,QACR,MACK,GAA+B,OAA5B,EAAI,oBAER,EAAI,oBAAoB,WAAa,CAAC,EAAG,GAEzC,EAAI,aAEH,CAGD,IAAI,IAAK,EAAG,KAAU,EAAI,QACtB,IAAsC,IAAnC,EAAM,mBAAmB,EAAG,GAE3B,YADA,SAAS,eAAe,EAAI,YAAY,MAAM,OAAS,QAK/D,IAAI,IAAI,KAAc,EAAI,aAAc,CAEpC,MAAM,EAAY,EAAW,SAAS,WAAW,EAAW,MAE5D,GAAG,kBAAkB,gBAAgB,EAAG,EAAG,EAAU,GAAI,EAAU,GAAI,EAAW,SAAS,gBAGvF,YADA,SAAS,eAAe,EAAI,YAAY,MAAM,OAAS,OAG/D,CAIA,GAAkB,MAFA,EAAI,gCAAgC,EAAG,GAAG,GAKxD,YADA,SAAS,eAAe,EAAI,YAAY,MAAM,OAAS,OAG/D,CACJ","file":"/npm/jsdragblocks@0.2.0/src/blocks.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/jsdragblocks@0.2.0/src/blocks.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nclass Block {\n\n    constructor(name, x, y, w, h, in_qtd, out_qtd) {\n\n        this.in_qtd = in_qtd == null ? 0 : in_qtd;\n        this.out_qtd = out_qtd == null ? 0 : out_qtd;\n\n        this.x = x;\n        this.y = y;\n        this.w = w;\n        this.h = h;\n        this.name = name;\n        this.font = `${Math.trunc((w + h)/10)}px Georgia`;\n        this.connector_size = this.h/10;\n    }\n\n    draw(ctx, selected) {\n\n        this.drawBlock(ctx, selected);\n        this.drawConnectors(ctx, selected);\n    }\n\n    drawBlock(ctx, selected) {\n\n        ctx.lineWidth = 2;\n\n        ctx.fillStyle = this.bg_color || \"#FFFFFF\";\n        ctx.fillRect(this.x, this.y, this.w, this.h);\n        ctx.fillStyle = this.fg_color || \"#000000\";\n        ctx.font = this.font;\n        ctx.textAlign = \"center\";\n        ctx.textBaseline = \"middle\";\n        ctx.fillText(this.name, this.x + this.w/2, this.y + this.h/2)\n        if(selected) {\n            ctx.strokeStyle = this.sel_border_color || \"#FF0000\";\n        }\n        else {\n            ctx.strokeStyle = this.border_color || \"#000000\";\n        }\n        ctx.strokeRect(this.x, this.y, this.w, this.h);\n    }\n\n    drawConnectors(ctx, _selected, color) {\n\n        ctx.fillStyle = color == null ? \"#0000FF\" : color;\n        this._draw_vertical_points(ctx, this.in_qtd, this.x);\n        this._draw_vertical_points(ctx, this.out_qtd, this.x + this.w);\n    }\n\n    collide(other) {\n\n        return this.x < other.x + other.w && this.x + this.w > other.x &&\n            this.y < other.y + other.h && this.y + this.h > other.y\n    }\n\n    pointIsInsideBlock(x, y) {\n\n        if(x > this.x && x < this.x + this.w && y > this.y && y < this.y + this.h) {\n\n            return true;\n        }\n\n        return false;\n    }\n\n    inputPoint(input_number) {\n\n        return [this.x, this.y + (input_number + 1)*this.h/(this.in_qtd + 1)]\n    }\n\n    outputPoint(output_number) {\n\n        return [this.x + this.w, this.y + (output_number + 1)*this.h/(this.out_qtd + 1)]\n    }\n\n    _draw_vertical_points(ctx, npoints, x) {\n\n        for(let i = 0; i < npoints; i++) {\n            ctx.beginPath();\n            ctx.arc(x, this.y + (i + 1)*this.h/(npoints + 1), this.connector_size, 0, 2 * Math.PI);\n            ctx.fill();\n        }\n    }\n\n    saveJSON(stringify) {\n\n        let obj = {\n\n            'x': this.x,\n            'y': this.y,\n            'width': this.w,\n            'height': this.h,\n            'name': this.name,\n            'inputs': this.in_qtd,\n            'outputs': this.out_qtd\n        }\n\n        if(stringify !== false) {\n\n            return JSON.stringify(obj);\n        }\n\n        return obj;\n    }\n}\n\nclass BlockConnection {\n\n    constructor(block_out, n_out, block_in, n_in, cbv) {\n\n        this.block_out = block_out;\n        this.n_out = n_out;\n        this.block_in = block_in;\n        this.n_in = n_in;\n\n        this.moving_pos = null;\n\n        this._cbv = cbv;\n    }\n\n    draw(ctx) {\n\n        const b_out_con_size = this.block_out.connector_size;\n        const arrow_width = 10;\n        const arrow_x_offset = 5;\n        const arrow_height = 7;\n\n        const start = this.block_out.outputPoint(this.n_out);\n\n        let end = null;\n        if(this.moving_pos === null) {\n\n            end = this.block_in.inputPoint(this.n_in);\n        }\n        else {\n\n            end = this.moving_pos;\n\n            if(CanvasBlockViewer._test_if_inside(end[0], end[1], start[0], start[1], 3*b_out_con_size)) {\n\n                return;\n            }\n        }\n\n        ctx.strokeStyle = this._get_color();\n        ctx.lineWidth = 3;\n\n        ctx.beginPath();\n        ctx.moveTo(start[0], start[1]);\n\n        if(start[0] + 40 < end[0] || (end[0] > start[0] && end[0] - start[0] <= 40 && (this.block_in === null || (\n            this.block_out.y < this.block_in.y + this.block_in.h && this.block_out.y + this.block_out.h > this.block_in.y)))) {\n\n            const middle_x = start[0] + (end[0] - start[0])/2;\n\n            ctx.lineTo(middle_x, start[1]);\n            ctx.lineTo(middle_x, end[1]);\n        }\n        else {\n\n            const middle_y = start[1] + (end[1] - start[1])/2;\n\n            let y_turn = null;\n\n            const diff_center_y = middle_y - this.block_out.y - this.block_out.h/2;\n            if(Math.abs(diff_center_y) > this.block_out.h) {\n                y_turn = middle_y;\n            }\n            else {\n                if(diff_center_y > 0) {\n                    y_turn = this.block_out.y + 3*this.block_out.h/2;\n                    if(this.moving_pos === null) {\n                        const in_y_turn = this.block_in.y + 3*this.block_in.h/2;\n                        if(in_y_turn > y_turn) {\n                            y_turn = in_y_turn;\n                        }\n                    }\n                }\n                else {\n                    y_turn = this.block_out.y - this.block_out.h/2\n                    if(this.moving_pos === null) {\n                        const in_y_turn = this.block_in.y - this.block_in.h/2;\n                        if(in_y_turn < y_turn) {\n                            y_turn = in_y_turn;\n                        }\n                    }\n                }\n            }\n\n            let x_start = start[0] + 20;\n            if(this.moving_pos === null && y_turn != middle_y && this.block_in.x + this.block_in.w > start[0]) {\n                x_start = this.block_in.x + this.block_in.w + 20;\n            }\n\n            ctx.lineTo(x_start, start[1]);\n            ctx.lineTo(x_start, y_turn);\n            ctx.lineTo(end[0] - 20, y_turn);\n            ctx.lineTo(end[0] - 20, end[1]);\n        }\n\n        ctx.lineTo(end[0] - arrow_x_offset - 2, end[1]);\n        ctx.stroke();\n\n        ctx.beginPath();\n        ctx.moveTo(end[0] - arrow_width - arrow_x_offset, end[1] - arrow_height);\n        ctx.lineTo(end[0] - arrow_x_offset, end[1]);\n        ctx.lineTo(end[0] - arrow_width - arrow_x_offset, end[1] + arrow_height);\n        ctx.closePath();\n        ctx.fillStyle = this._get_color();\n        ctx.fill();\n    }\n\n    _get_color() {\n\n        const out_get_color_func = this.block_out.connectionColor;\n\n        let connection_color = null;\n        let connection_color_priority = null;\n\n        if(out_get_color_func != null) {\n            let out_result = this.block_out.connectionColor(true, this.n_out);\n\n            if(out_result instanceof Array) {\n                connection_color = out_result[0];\n                connection_color_priority = out_result[1];\n            }\n            else {\n\n                connection_color = out_result;\n            }\n        }\n\n        if(this.block_in != null) {\n            const in_get_color_func = this.block_in.connectionColor;\n\n            if(in_get_color_func != null) {\n\n                let in_result = this.block_in.connectionColor(false, this.n_in);\n                if(in_result instanceof Array) {\n\n                    if(connection_color_priority === null || in_result[1] <= connection_color_priority) {\n                        connection_color = in_result[0];\n                        connection_color_priority = in_result[1];\n                    }\n                }\n                else if(connection_color_priority === null) {\n\n                    connection_color = in_result;\n                }\n            }\n        }\n\n        return connection_color !== null ? connection_color : this._cbv.connection_color;\n    }\n}\n\nclass CanvasBlockViewer {\n\n    constructor(canvas_id) {\n\n        let cbv = this;\n\n        this.select_callback = null;\n        this.connection_color = \"#0000FF\";\n\n        this._blocks = new Map();\n        this._connections = [];\n        this._canvas_id = canvas_id;\n        this._block_clicked = null;\n        this._connection_clicked = null;\n        this._clicked_x_off = 0;\n        this._clicked_y_off = 0;\n        this._before_click_block_x = 0;\n        this._before_click_block_y = 0;\n        this._block_invalid_position = false;\n        this._moved_after_press = false;\n        this._selected_block = null;\n        this._clicked_blank_point = null;\n        this._translate = [0, 0];\n        this._zoom = 1;\n\n        let canvas = document.getElementById(this._canvas_id);\n\n        canvas.addEventListener('mousedown', function(event) { CanvasBlockViewer._canvas_mousedown_event(cbv, event); }, false);\n        canvas.addEventListener('mouseup', function(event) { CanvasBlockViewer._canvas_mouseup_event(cbv, event); }, false);\n        canvas.addEventListener('mousemove', function(event) { CanvasBlockViewer._canvas_mousemove_event(cbv, event); }, false);\n    }\n\n    _saveJSON_connection_push(connection, block_info, type, other_block_id) {\n\n        if(block_info[type] == null) {\n\n            block_info[type] = [];\n        }\n\n        block_info[type].push({\n\n            'input_number': connection.n_in,\n            'output_number': connection.n_out,\n            'block': other_block_id\n        })\n    }\n\n    zoomIn(value) {\n\n        this._zoom *= value;\n        this.redraw();\n    }\n\n    zoomOut(value) {\n\n        this._zoom /= value;\n        this.redraw();\n    }\n\n    saveJSON(stringify) {\n\n        let output = [];\n        let block_to_id = new Map();\n\n        let i = 0;\n\n        for(let [_, block] of this._blocks) {\n\n            output.push(block.saveJSON(false));\n\n            block_to_id.set(block, i);\n\n            i++;\n        }\n\n        for(let connection of this._connections) {\n\n            if(connection.block_in != null && connection.block_out != null) {\n\n                let in_block_id = block_to_id.get(connection.block_in);\n                let out_block_id = block_to_id.get(connection.block_out);\n\n                this._saveJSON_connection_push(connection, output[in_block_id], 'input', out_block_id);\n                this._saveJSON_connection_push(connection, output[out_block_id], 'output', in_block_id);\n            }\n        }\n\n        if(stringify !== false) {\n\n            return JSON.stringify(output);\n        }\n\n        return output;\n    }\n\n    loadJSONCreateBlockDefault(block_json) {\n\n        return new Block(block_json.name, block_json.x, block_json.y, block_json.width,\n                         block_json.height, block_json.inputs, block_json.outputs);\n    }\n\n    loadJSON(blocks_json_info, parse_string, args) {\n\n        if(parse_string !== false) {\n            blocks_json_info = JSON.parse(blocks_json_info);\n        }\n\n        let create_block = null;\n\n        if(args != null && args.create_block != null) {\n\n            create_block = args.create_block;\n        }\n        else create_block = this.loadJSONCreateBlockDefault;\n\n        if(args != null && args.clear_before === true) {\n\n            this._blocks.clear();\n            this._connections.length = 0;\n            this._block_clicked = null;\n            this._connection_clicked = null;\n            this._block_invalid_position = false;\n            this._moved_after_press = false;\n            this._selected_block = null;\n            this._translate = [0, 0];\n            this._clicked_blank_point = null;\n            this._zoom = 1;\n        }\n\n        const pos_to_block = new Map();\n\n        for(let i = 0; i < blocks_json_info.length; i++) {\n\n            const block_json = blocks_json_info[i];\n\n            let block = create_block(block_json);\n            this.addBlock(block, false);\n\n            pos_to_block.set(i, block);\n        }\n\n        for(let i = 0; i < blocks_json_info.length; i++) {\n\n            const block_json = blocks_json_info[i];\n\n            const block = pos_to_block.get(i);\n\n            if(block_json.output == null) continue;\n\n            for(let output_info of block_json.output) {\n\n                const out_block = pos_to_block.get(output_info.block);\n\n                this.addConnection(block.name, output_info.output_number,\n                                   out_block.name, output_info.input_number);\n            }\n        }\n\n        this.redraw();\n    }\n\n    addBlock(block, need_redraw) {\n\n        if(this._blocks.get(block.name) != null) return false;\n\n        this._blocks.set(block.name, block);\n\n        if(need_redraw !== false) {\n            this.redraw();\n        }\n\n        return true;\n    }\n\n    remBlock(block, need_redraw) {\n\n        if(!this._blocks.delete(block.name)) return false;\n\n        this._connections = this._connections.filter((value) => {\n\n            return value.block_in != block && value.block_out != block;\n        })\n\n        if(need_redraw !== false) {\n            this.redraw();\n        }\n\n        return true;\n    }\n\n    findBlock(block_name) {\n\n        return this._blocks.get(block_name);\n    }\n\n    addConnection(block_in, n_in, block_out, n_out, need_redraw) {\n\n        const b_in = this._blocks.get(block_in);\n        const b_out = this._blocks.get(block_out);\n\n        this._connections.push(new BlockConnection(b_in, n_in, b_out, n_out, this))\n\n        if(need_redraw !== false) {\n            this.redraw();\n        }\n    }\n\n    redraw() {\n\n        let canvas = document.getElementById(this._canvas_id);\n        let ctx = canvas.getContext(\"2d\");\n\n        ctx.setTransform(1, 0, 0, 1, 0, 0);\n        ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n        ctx.translate(this._translate[0], this._translate[1]);\n        ctx.scale(this._zoom, this._zoom);\n\n        for(let [_, block] of this._blocks) {\n            block.drawBlock(ctx, this._selected_block === block);\n        }\n\n        for(let connection of this._connections) {\n            connection.draw(ctx);\n        }\n\n        for(let [_, block] of this._blocks) {\n            block.drawConnectors(ctx, this._selected_block === block);\n        }\n\n    }\n\n    static _test_if_inside(x, y, cx, cy, half_side) {\n\n        return x > cx - half_side && x < cx + half_side && y > cy - half_side && y < cy + half_side\n    }\n\n    _find_block_inout_next_to_point(x, y, is_input) {\n\n        for(let [block_name, block] of this._blocks) {\n\n            const qtd = is_input ? block.in_qtd : block.out_qtd;\n\n            for(let i = 0; i < qtd; i++) {\n\n                const p_pos = is_input ? block.inputPoint(i) : block.outputPoint(i);\n                const c_size = block.connector_size;\n\n                if(CanvasBlockViewer._test_if_inside(x, y, p_pos[0], p_pos[1], c_size)) {\n                    return [block, i];\n                }\n            }\n        }\n\n        return null;\n    }\n\n    static _canvas_mousedown_event(cbv, event) {\n\n        cbv._moved_after_press = false;\n\n        const rect = event.target.getBoundingClientRect();\n        const not_translated_x = event.clientX - rect.left;\n        const not_translated_y = event.clientY - rect.top;\n        const x = (not_translated_x - cbv._translate[0])/cbv._zoom;\n        const y = (not_translated_y - cbv._translate[1])/cbv._zoom;\n\n        for(let connection of cbv._connections) {\n\n            const end_point = connection.block_in.inputPoint(connection.n_in);\n\n            if(CanvasBlockViewer._test_if_inside(x, y, end_point[0], end_point[1], connection.block_in.connector_size)) {\n\n                document.getElementById(cbv._canvas_id).style.cursor = \"copy\";\n                cbv._connection_clicked = connection;\n\n                return;\n            }\n        }\n\n        let block_found = cbv._find_block_inout_next_to_point(x, y, false);\n\n        if(block_found != null) {\n\n            let connection = new BlockConnection(block_found[0], block_found[1], null, 0, cbv);\n            cbv._connections.push(connection);\n            cbv._connection_clicked = connection;\n            return;\n        }\n\n        let block_clicked = null;\n        for(let [_, block] of cbv._blocks) {\n            if(block.pointIsInsideBlock(x, y) === true) {\n                block_clicked = block;\n            }\n        }\n\n        if(block_clicked !== null) {\n\n            cbv._block_clicked = block_clicked;\n\n            cbv._clicked_x_off = x - block_clicked.x;\n            cbv._clicked_y_off = y - block_clicked.y;\n\n            cbv._before_click_block_x = block_clicked.x;\n            cbv._before_click_block_y = block_clicked.y;\n\n            cbv._clicked_blank_point = null;\n        }\n        else {\n\n            if(cbv._selected_block !== null) {\n                cbv._selected_block = null;\n                if(cbv.select_callback != null) {\n\n                    cbv.select_callback(null);\n                }\n                cbv.redraw();\n            }\n            cbv._clicked_blank_point = [not_translated_x, not_translated_y];\n        }\n    }\n\n    static _canvas_mouseup_event(cbv, event) {\n\n        cbv._clicked_blank_point = null;\n\n        if(cbv._connection_clicked !== null) {\n\n            const connection = cbv._connection_clicked;\n            const current_position = connection.moving_pos;\n\n            let block_found = cbv._find_block_inout_next_to_point(current_position[0], current_position[1], true);\n\n            if(block_found != null) {\n\n                connection.block_in = block_found[0];\n                connection.n_in = block_found[1];\n            }\n            else {\n\n                const out_pos = connection.block_out.outputPoint(connection.n_out);\n                const out_size = connection.block_out.connector_size;\n\n                if(connection.block_in == null || CanvasBlockViewer._test_if_inside(current_position[0], current_position[1], out_pos[0], out_pos[1], 3*out_size)) {\n\n                    cbv._connections.splice(cbv._connections.indexOf(connection), 1);\n                }\n            }\n\n            connection.moving_pos = null;\n            cbv._connection_clicked = null;\n\n            cbv.redraw();\n        }\n        else if(cbv._block_clicked !== null && cbv._moved_after_press === false) {\n\n            cbv._selected_block = cbv._block_clicked;\n\n            if(cbv.select_callback != null) {\n\n                cbv.select_callback(cbv._selected_block);\n            }\n\n            cbv.redraw();\n        }\n        else if(cbv._block_clicked !== null && this._block_invalid_position === true) {\n\n            cbv._block_clicked.x = cbv._before_click_block_x;\n            cbv._block_clicked.y = cbv._before_click_block_y;\n\n            cbv.redraw();\n        }\n\n        document.getElementById(cbv._canvas_id).style.cursor = \"auto\";\n        cbv._block_clicked = null;\n    }\n\n    static _canvas_mousemove_event(cbv, event) {\n\n        cbv._moved_after_press = true;\n        document.getElementById(cbv._canvas_id).style.cursor = \"auto\";\n\n        const rect = event.target.getBoundingClientRect();\n        const not_translated_x = event.clientX - rect.left;\n        const not_translated_y = event.clientY - rect.top;\n        const x = (not_translated_x - cbv._translate[0])/cbv._zoom;\n        const y = (not_translated_y - cbv._translate[1])/cbv._zoom;\n\n        if(cbv._clicked_blank_point !== null) {\n\n            cbv._translate[0] += (not_translated_x - cbv._clicked_blank_point[0]);\n            cbv._translate[1] += (not_translated_y - cbv._clicked_blank_point[1]);\n            cbv._clicked_blank_point = [not_translated_x, not_translated_y];\n\n            cbv.redraw();\n        }\n        else if(cbv._block_clicked !== null) {\n\n            this._block_invalid_position = false;\n            for(let [block_name, block] of cbv._blocks) {\n\n                if(cbv._block_clicked !== block && cbv._block_clicked.collide(block)) {\n\n                    document.getElementById(cbv._canvas_id).style.cursor = \"no-drop\";\n                    this._block_invalid_position = true;\n                    break;\n                }\n            }\n\n            cbv._block_clicked.x = x - cbv._clicked_x_off;\n            cbv._block_clicked.y = y - cbv._clicked_y_off;\n\n            cbv.redraw();\n        }\n        else if(cbv._connection_clicked !== null) {\n\n            cbv._connection_clicked.moving_pos = [x, y];\n\n            cbv.redraw();\n        }\n        else {\n\n            let can_move = false;\n            for(let [_, block] of cbv._blocks) {\n                if(block.pointIsInsideBlock(x, y) === true) {\n                    document.getElementById(cbv._canvas_id).style.cursor = \"move\";\n                    return;\n                }\n            }\n\n            for(let connection of cbv._connections) {\n\n                const end_point = connection.block_in.inputPoint(connection.n_in);\n\n                if(CanvasBlockViewer._test_if_inside(x, y, end_point[0], end_point[1], connection.block_in.connector_size)) {\n\n                    document.getElementById(cbv._canvas_id).style.cursor = \"move\";\n                    return;\n                }\n            }\n\n            let block_found = cbv._find_block_inout_next_to_point(x, y, false);\n\n            if(block_found != null) {\n\n                document.getElementById(cbv._canvas_id).style.cursor = \"move\";\n                return;\n            }\n        }\n    }\n}\n"]}