"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var graphql_tag_1 = __importDefault(require("graphql-tag"));
var react_apollo_1 = require("react-apollo");
var CurrencyConverterStyledComponents_1 = require("./CurrencyConverterStyledComponents");
var CurrencyConverterTextComponents_1 = require("./CurrencyConverterTextComponents");
var UsdEthConverter_1 = require("./UsdEthConverter");
var cvlPriceQuery = graphql_tag_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  query($usdToSpend: Float!) {\n    storefrontCvlPrice\n    storefrontCvlQuoteUsd(usdToSpend: $usdToSpend)\n  }\n"], ["\n  query($usdToSpend: Float!) {\n    storefrontCvlPrice\n    storefrontCvlQuoteUsd(usdToSpend: $usdToSpend)\n  }\n"])));
var UsdEthCvlConverter = /** @class */ (function (_super) {
    __extends(UsdEthCvlConverter, _super);
    function UsdEthCvlConverter(props) {
        var _this = _super.call(this, props) || this;
        _this.state = {
            usdToSpend: 0,
            convertedEth: 0,
        };
        return _this;
    }
    UsdEthCvlConverter.prototype.render = function () {
        var usdToSpend = this.state.usdToSpend;
        var updateConversion = this.updateConversion.bind(this);
        return (React.createElement(CurrencyConverterStyledComponents_1.CurrencyConverterSection, null,
            React.createElement(UsdEthConverter_1.UsdEthConverter, { onConversion: updateConversion }),
            React.createElement(CurrencyConverterStyledComponents_1.CurrencyCalcCVL, null,
                React.createElement(react_apollo_1.Query, { query: cvlPriceQuery, variables: { usdToSpend: usdToSpend } }, function (_a) {
                    var loading = _a.loading, error = _a.error, data = _a.data;
                    return (React.createElement(CurrencyConverterTextComponents_1.CurrencyCVLPriceText, { pricePerCvl: data.storefrontCvlPrice, totalPrice: data.storefrontCvlQuoteUsd }));
                }))));
    };
    UsdEthCvlConverter.prototype.updateConversion = function (usdValue, ethValue) {
        this.setState({ usdToSpend: usdValue });
        this.props.onConversion(usdValue, ethValue);
    };
    return UsdEthCvlConverter;
}(React.Component));
exports.UsdEthCvlConverter = UsdEthCvlConverter;
var templateObject_1;
//# sourceMappingURL=UsdEthCvlConverter.js.map