"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
    Query: {
        allCanvasPages: (_obj, _args, { models }) => {
            return models.allCanvasPages();
        },
        paginateCanvasPages: (_obj, { size, page }, { models }) => __awaiter(void 0, void 0, void 0, function* () {
            const offset = (page - 1) * size;
            const allCanvasPages = models.allCanvasPages();
            const items = allCanvasPages.slice(offset, offset + size);
            const paginated = {
                currentPage: page,
                totalItems: allCanvasPages.length,
                lastPage: Math.ceil(allCanvasPages.length / size),
                perPage: size,
                items: items,
            };
            return new Promise((res) => res(paginated));
        }),
        canvasPageById: (_obj, args, { models }) => {
            return models.canvasPageById(args.id);
        },
        canvasPollPeers: (_obj, { id }, { models }) => {
            return models.canvasPollPeers(id);
        },
    },
    Mutation: {
        canvasPageCreate: (_obj, { canvasPageInput }, { models }) => {
            return models.canvasPageCreate(canvasPageInput);
        },
        canvasPageEditSEO: () => {
            //return ctx.models.canvasPageEditSEO(args.id, args.seoInput);
        },
        canvasPageEdit: (_obj, { id, canvasPage }, { models }) => {
            return models.canvasPageEdit(id, canvasPage);
        },
        canvasOpenPeers: (_obj, { id, peerInput }, { models }) => {
            return models.canvasOpenPeers(id, peerInput);
        },
        canvasClosePeers: (_obj, { id }, { models }) => {
            return models.canvasClosePeers(id);
        },
    },
};
