"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = void 0;
const STRING_1 = require("../constant/STRING");
function init(reset) {
    let _init = false;
    let _ref;
    onmessage = function (event) {
        const { data } = event;
        const { type, data: _data } = data;
        switch (type) {
            case STRING_1.INIT:
                _init = true;
                _ref = reset(_data);
                break;
            case STRING_1.EXEC:
                if (!_init) {
                    throw new Error('ref was not initialized');
                }
                _ref.exec(_data);
                break;
            default:
                throw new Error('invalid message type');
        }
    };
}
exports.init = init;
//# sourceMappingURL=service.js.map