/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { SharedTree as SharedTreeImpl } from "./shared-tree";
import { pkgVersion } from "./packageVersion";
/**
 * A channel factory that creates an {@link ITree}.
 * @internal
 */
export class TreeFactory {
    constructor(options) {
        this.options = options;
        this.type = "https://graph.microsoft.com/types/tree";
        this.attributes = {
            type: this.type,
            snapshotFormatVersion: "0.0.0",
            packageVersion: pkgVersion,
        };
    }
    async load(runtime, id, services, channelAttributes) {
        const tree = new SharedTreeImpl(id, runtime, channelAttributes, this.options, "SharedTree");
        await tree.load(services);
        return tree;
    }
    create(runtime, id) {
        const tree = new SharedTreeImpl(id, runtime, this.attributes, this.options, "SharedTree");
        tree.initializeLocal();
        return tree;
    }
}
/**
 * SharedTree is a hierarchical data structure for collaboratively editing JSON-like trees
 * of objects, arrays, and other data types.
 *
 * @public
 */
export class SharedTree {
    // The IFluidContainer ContainerSchema currently requires a constructable class that
    // implements the union of IChannel and the interface to be returned to the user.
    //
    // Temporarily, we provide one until the following work items is addressed:
    // https://dev.azure.com/fluidframework/internal/_workitems/edit/6458
    static getFactory() {
        return new TreeFactory({});
    }
    schematize(config) {
        return this.useFactory();
    }
    useFactory() {
        throw new Error("Use factory to create instance.");
    }
    get id() {
        return this.useFactory();
    }
    get attributes() {
        return this.useFactory();
    }
    get handle() {
        return this.useFactory();
    }
    get IFluidLoadable() {
        return this.useFactory();
    }
    getAttachSummary(fullTree, trackState, telemetryContext) {
        return this.useFactory();
    }
    async summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext) {
        return this.useFactory();
    }
    isAttached() {
        return this.useFactory();
    }
    connect(services) {
        return this.useFactory();
    }
    getGCData(fullGC) {
        return this.useFactory();
    }
}
//# sourceMappingURL=treeFactory.js.map