"use strict";
(self["webpackChunkjupyterlab_cube"] = self["webpackChunkjupyterlab_cube"] || []).push([["lib_index_js"],{

/***/ "./lib/index.js":
/*!**********************!*\
  !*** ./lib/index.js ***!
  \**********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "OutputWidget": () => (/* binding */ OutputWidget),
/* harmony export */   "rendererFactory": () => (/* binding */ rendererFactory),
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _lumino_widgets__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lumino/widgets */ "webpack/sharing/consume/default/@lumino/widgets");
/* harmony import */ var _lumino_widgets__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_lumino_widgets__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _visualizer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./visualizer */ "./lib/visualizer.js");
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "webpack/sharing/consume/default/react-dom");
/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);




/**
 * The default mime type for the extension.
 */
const MIME_TYPE = 'application/osscar.cube';
/**
 * The class name added to the extension.
 */
const CLASS_NAME = 'mimerenderer-cube';
/**
 * A widget for rendering cube.
 */
class OutputWidget extends _lumino_widgets__WEBPACK_IMPORTED_MODULE_0__.Widget {
    /**
     * Construct a new output widget.
     */
    constructor(options) {
        super();
        this._mimeType = options.mimeType;
        this.addClass(CLASS_NAME);
    }
    /**
     * Render cube into this widget's node.
     */
    renderModel(model) {
        const data = model.data[this._mimeType];
        return new Promise((resolve, reject) => {
            react_dom__WEBPACK_IMPORTED_MODULE_1__.render(react__WEBPACK_IMPORTED_MODULE_2___default().createElement(_visualizer__WEBPACK_IMPORTED_MODULE_3__.Visualizer, { data: data }), this.node, () => {
                resolve();
            });
        });
    }
}
/**
 * A mime renderer factory for cube data.
 */
const rendererFactory = {
    safe: true,
    mimeTypes: [MIME_TYPE],
    createRenderer: (options) => new OutputWidget(options),
};
/**
 * Extension definition.
 */
const extension = {
    id: 'jupyterlab-cube:plugin',
    rendererFactory,
    rank: 100,
    dataType: 'string',
    fileTypes: [
        {
            name: 'cube',
            mimeTypes: [MIME_TYPE],
            extensions: ['.cube', '.cub'],
            iconClass: 'jp-MaterialIcon jp-CubeIcon',
        },
    ],
    documentWidgetFactoryOptions: {
        name: 'cube viewer',
        primaryFileType: 'cube',
        fileTypes: ['cube'],
        defaultFor: ['cube'],
    },
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (extension);


/***/ }),

/***/ "./lib/visualizer.js":
/*!***************************!*\
  !*** ./lib/visualizer.js ***!
  \***************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Visualizer": () => (/* binding */ Visualizer)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _osscar_ngl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @osscar/ngl */ "webpack/sharing/consume/default/@osscar/ngl/@osscar/ngl");
/* harmony import */ var _osscar_ngl__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_osscar_ngl__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "webpack/sharing/consume/default/underscore/underscore");
/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(underscore__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @material-ui/core/Grid */ "./node_modules/@material-ui/core/esm/Grid/Grid.js");
/* harmony import */ var _material_ui_core_Radio__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @material-ui/core/Radio */ "./node_modules/@material-ui/core/esm/Radio/Radio.js");
/* harmony import */ var _material_ui_core_RadioGroup__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @material-ui/core/RadioGroup */ "./node_modules/@material-ui/core/esm/RadioGroup/RadioGroup.js");
/* harmony import */ var _material_ui_core_FormControlLabel__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @material-ui/core/FormControlLabel */ "./node_modules/@material-ui/core/esm/FormControlLabel/FormControlLabel.js");







class Visualizer extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
    constructor(props, context) {
        super(props, context);
        this.toggle_backgroundColor = () => {
            if (this.dark) {
                this._stage.setParameters({ backgroundColor: 'white' });
            }
            else {
                this._stage.setParameters({ backgroundColor: 'black' });
            }
            this.dark = !this.dark;
        };
        this.handleRadioChange = (event) => {
            this._stage.setParameters({ backgroundColor: event.target.value });
            this.setState({ value: event.target.value });
        };
        this.dark = true;
        this.uuid = underscore__WEBPACK_IMPORTED_MODULE_2__.uniqueId('ngl_');
        this.state = { value: 'black' };
        window.requestAnimationFrame(() => {
            _osscar_ngl__WEBPACK_IMPORTED_MODULE_1__.DatasourceRegistry.add('data', new _osscar_ngl__WEBPACK_IMPORTED_MODULE_1__.StaticDatasource('//cdn.rawgit.com/arose/ngl/v2.0.0-dev.32/data/'));
            // Create NGL Stage object
            this._stage = new _osscar_ngl__WEBPACK_IMPORTED_MODULE_1__.Stage(this.uuid, { quality: 'high' });
            const data = this.props.data;
            const stringBlob = new Blob([data], { type: 'text/plain' });
            this._stage.loadFile(stringBlob, { ext: 'cube' }).then((o) => {
                o.addRepresentation('surface', {
                    visible: true,
                    isolevelType: 'value',
                    isolevel: 0.01,
                    color: 'blue',
                    opacity: 0.7,
                    opaqueBack: false,
                });
                o.addRepresentation('surface', {
                    visible: true,
                    isolevelType: 'value',
                    isolevel: -0.01,
                    color: 'red',
                    opacity: 0.7,
                    opaqueBack: false,
                });
                o.autoView();
            }),
                function (e) {
                    console.log('information:' + e);
                };
        });
    }
    render() {
        return (react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { className: "container" },
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { id: this.uuid, style: { width: '100%', height: '400px', backgroundColor: 'black' } }),
            react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_Grid__WEBPACK_IMPORTED_MODULE_3__.default, { container: true, direction: "row", justify: "center", alignItems: "center" },
                react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_RadioGroup__WEBPACK_IMPORTED_MODULE_4__.default, { "aria-label": "backgroundcolor", name: "backgroundcolor1", value: this.state.value, onChange: this.handleRadioChange, row: true },
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_FormControlLabel__WEBPACK_IMPORTED_MODULE_5__.default, { value: "black", control: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_Radio__WEBPACK_IMPORTED_MODULE_6__.default, null), label: "Black" }),
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_FormControlLabel__WEBPACK_IMPORTED_MODULE_5__.default, { value: "white", control: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_Radio__WEBPACK_IMPORTED_MODULE_6__.default, null), label: "White" }),
                    react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_FormControlLabel__WEBPACK_IMPORTED_MODULE_5__.default, { value: "yellow", control: react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_material_ui_core_Radio__WEBPACK_IMPORTED_MODULE_6__.default, null), label: "Yellow" })))));
    }
}


/***/ })

}]);
//# sourceMappingURL=lib_index_js.2a0b2e3b76a48ece6be1.js.map