import Blockly from 'blockly';
import { pythonGenerator } from "blockly/python";

Blockly.Python = pythonGenerator

// variables
Blockly.variables = {
    HUE: "#ffab2f"
}
Blockly.Blocks.variables_get = {
    init: function () {
        this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);
        this.setColour(Blockly.variables.HUE);
        this.appendDummyInput().
            appendField(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_DEFAULT_NAME), "VAR");
        this.setOutput(!0);
        this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
        this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET
    },
    contextMenuType_: "variables_set",
    customContextMenu: function (a) {
        var b = {
            enabled: !0
        }
            , c = this.getFieldValue("VAR");
        b.text = this.contextMenuMsg_.replace("%1", c);
        c = goog.dom.createDom("field", null, c);
        c.setAttribute("name", "VAR");
        c = goog.dom.createDom("block", null, c);
        c.setAttribute("type", this.contextMenuType_);
        b.callback = Blockly.ContextMenu.callbackFactory(this, c);
        a.push(b)
    }
};
Blockly.Blocks.variables_set = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.VARIABLES_SET,
            args0: [{
                type: "field_variable",
                name: "VAR",
                variable: Blockly.Msg.VARIABLES_DEFAULT_NAME
            }, {
                type: "input_value",
                name: "VALUE",
            }],
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.variables.HUE,
            tooltip: Blockly.Msg.VARIABLES_SET_TOOLTIP,
            helpUrl: Blockly.Msg.VARIABLES_SET_HELPURL
        });
    },
    contextMenuType_: "variables_get",
    customContextMenu: Blockly.Blocks.variables_get.customContextMenu
};


Blockly.Blocks.math_change = {
    init: function () {
        this.jsonInit({
            message0: Blockly.Msg.MATH_CHANGE_TITLE,
            args0: [{
                type: "field_variable",
                name: "VAR",
                variable: Blockly.Msg.MATH_CHANGE_TITLE_ITEM
            }, {
                type: "input_value",
                name: "DELTA",
                check: "Number"
            }],
            previousStatement: null,
            nextStatement: null,
            colour: Blockly.variables.HUE,
            helpUrl: Blockly.Msg.MATH_CHANGE_HELPURL
        });
        var a = this;
        this.setTooltip(function () {
            return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1", a.getField("VAR").variable.name)
        })
    }
};


export default Blockly;