"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addVideo = void 0;
const const_1 = require("./VideoSpecs/const.js");
const md_video_1 = require("./VideoSpecs/md-video.js");
const utils_1 = require("./VideoSpecs/utils.js");
exports.addVideo = {
    isEnable(state) {
        return state.selection.empty;
    },
    run(state, dispatch, _view, attrs) {
        if (!attrs || !attrs.service || !attrs.url) {
            return;
        }
        const { service } = attrs;
        const videoID = (0, md_video_1.parseVideoUrl)(service, attrs.url);
        dispatch(state.tr.insert(state.selection.from, (0, utils_1.videoType)(state.schema).create({
            [const_1.VideoAttr.Service]: service,
            [const_1.VideoAttr.VideoID]: videoID,
        })));
    },
};
//# sourceMappingURL=actions.js.map
