"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWatchActionObjectValid = void 0;
const misc_1 = require("../misc");
const video_view_1 = require("../video-view");
const misc_2 = require("./misc");
function isWatchActionObjectValid(action) {
    return (0, misc_1.exists)(action) &&
        action.type === 'WatchAction' &&
        (0, misc_2.isObjectValid)(action.id) &&
        (0, misc_2.isActivityPubVideoDurationValid)(action.duration) &&
        (0, misc_1.isDateValid)(action.startTime) &&
        (0, misc_1.isDateValid)(action.endTime) &&
        isLocationValid(action.location) &&
        (0, misc_1.isUUIDValid)(action.uuid) &&
        (0, misc_2.isObjectValid)(action.object) &&
        isWatchSectionsValid(action.watchSections);
}
exports.isWatchActionObjectValid = isWatchActionObjectValid;
function isLocationValid(location) {
    if (!location)
        return true;
    return typeof location === 'object' && typeof location.addressCountry === 'string';
}
function isWatchSectionsValid(sections) {
    return Array.isArray(sections) && sections.every(s => {
        return (0, video_view_1.isVideoTimeValid)(s.startTimestamp) && (0, video_view_1.isVideoTimeValid)(s.endTimestamp);
    });
}
//# sourceMappingURL=watch-action.js.map