import { BlockService } from '@blockeditor/block-std';
import { Slot } from '@blockeditor/global/utils';
import {} from '../_common/types.js';
import { buildPath } from '../_common/utils/query.js';
import { EditSessionStorage } from './managers/edit-session.js';
import { TemplateJob } from './service/template.js';
export class SurfaceService extends BlockService {
    constructor() {
        super(...arguments);
        this.TemplateJob = TemplateJob;
        this.slots = {
            edgelessToolUpdated: new Slot(),
        };
    }
    mounted() {
        super.mounted();
        this.editSession = new EditSessionStorage(this);
    }
    get _surfaceView() {
        const [surface] = this.page.getBlockByFlavour('affine:surface');
        const view = this.std.view.viewFromPath('block', buildPath(surface));
        return view;
    }
    get currentTool() {
        const view = this._surfaceView;
        if (!view)
            return null;
        const { edgeless } = view;
        return edgeless.edgelessTool;
    }
    setNavigatorMode(on, mode) {
        const view = this._surfaceView;
        if (!view)
            return;
        const { edgeless } = view;
        if (on && edgeless.edgelessTool.type === 'frameNavigator')
            return;
        if (!on && edgeless.edgelessTool.type !== 'frameNavigator')
            return;
        if (on) {
            edgeless.tools.setEdgelessTool({ type: 'frameNavigator', mode });
        }
        else {
            edgeless.tools.setEdgelessTool({ type: 'default' });
        }
    }
}
//# sourceMappingURL=surface-service.js.map