// src/plugin-intent/intent-dispatcher.ts
import * as Effect3 from "effect/Effect";
import * as Function2 from "effect/Function";
import * as Option from "effect/Option";
import * as Ref2 from "effect/Ref";
import { live as live2 } from "@dxos/live-object";
import { log as log3 } from "@dxos/log";
import { byPosition } from "@dxos/util";

// src/core/capabilities.ts
import { Atom } from "@effect-atom/atom-react";
import * as Effect from "effect/Effect";
import { Trigger } from "@dxos/async";
import { invariant } from "@dxos/invariant";
import { log } from "@dxos/log";
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
var defineCapability = (identifier) => {
  return {
    identifier
  };
};
var CapabilityImpl = class {
  moduleId;
  implementation;
  constructor(moduleId, implementation) {
    this.moduleId = moduleId;
    this.implementation = implementation;
  }
};
var contributes = (interfaceDef, implementation, deactivate) => {
  return {
    interface: interfaceDef,
    implementation,
    deactivate
  };
};
var lazy = (c) => async (props) => {
  const { default: getCapability } = await c();
  return async () => getCapability(props);
};
var PluginContext = class {
  _registry;
  _capabilityImpls = Atom.family(() => {
    return Atom.make([]).pipe(Atom.keepAlive);
  });
  _capabilities = Atom.family((id) => {
    return Atom.make((get) => {
      const current = get(this._capabilityImpls(id));
      return current.map((c) => c.implementation);
    });
  });
  _capability = Atom.family((id) => {
    return Atom.make((get) => {
      const current = get(this._capabilities(id));
      invariant(current.length > 0, `No capability found for ${id}`, {
        F: __dxlog_file,
        L: 126,
        S: this,
        A: [
          "current.length > 0",
          "`No capability found for ${id}`"
        ]
      });
      return current[0];
    });
  });
  /**
  * Activates plugins based on the activation event.
  * @param event The activation event.
  * @returns Whether the activation was successful.
  */
  activate;
  /**
  * Re-activates the modules that were activated by the event.
  * @param event The activation event.
  * @returns Whether the reset was successful.
  */
  reset;
  constructor({ registry, activate, reset }) {
    this._registry = registry;
    this.activate = activate;
    this.reset = reset;
  }
  /**
  * @internal
  */
  contributeCapability({ module: moduleId, interface: interfaceDef, implementation }) {
    const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
    const capability = new CapabilityImpl(moduleId, implementation);
    if (current.includes(capability)) {
      return;
    }
    this._registry.set(this._capabilityImpls(interfaceDef.identifier), [
      ...current,
      capability
    ]);
    log("capability contributed", {
      id: interfaceDef.identifier,
      moduleId,
      count: current.length
    }, {
      F: __dxlog_file,
      L: 170,
      S: this,
      C: (f, a) => f(...a)
    });
  }
  /**
  * @internal
  */
  removeCapability(interfaceDef, implementation) {
    const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
    if (current.length === 0) {
      return;
    }
    const next = current.filter((c) => c.implementation !== implementation);
    if (next.length !== current.length) {
      this._registry.set(this._capabilityImpls(interfaceDef.identifier), next);
      log("capability removed", {
        id: interfaceDef.identifier,
        count: current.length
      }, {
        F: __dxlog_file,
        L: 189,
        S: this,
        C: (f, a) => f(...a)
      });
    } else {
      log.warn("capability not removed", {
        id: interfaceDef.identifier
      }, {
        F: __dxlog_file,
        L: 191,
        S: this,
        C: (f, a) => f(...a)
      });
    }
  }
  /**
  * Get the Atom reference to the available capabilities for a given interface.
  * Primarily useful for deriving other Atom values based on the capabilities or
  * for subscribing to changes in the capabilities.
  * @returns An atom reference to the available capabilities.
  */
  capabilities(interfaceDef) {
    return this._capabilities(interfaceDef.identifier);
  }
  /**
  * Get the Atom reference to the available capabilities for a given interface.
  * Primarily useful for deriving other Atom values based on the capability or
  * for subscribing to changes in the capability.
  * @returns An atom reference to the available capability.
  * @throws If no capability is found.
  */
  capability(interfaceDef) {
    return this._capability(interfaceDef.identifier);
  }
  /**
  * Get capabilities from the plugin context.
  * @returns An array of capabilities.
  */
  getCapabilities(interfaceDef) {
    return this._registry.get(this.capabilities(interfaceDef));
  }
  /**
  * Requests a single capability from the plugin context.
  * @returns The capability.
  * @throws If no capability is found.
  */
  getCapability(interfaceDef) {
    return this._registry.get(this.capability(interfaceDef));
  }
  /**
  * Waits for a capability to be available.
  * @returns The capability.
  */
  async waitForCapability(interfaceDef) {
    const [capability] = this.getCapabilities(interfaceDef);
    if (capability) {
      return capability;
    }
    const trigger = new Trigger();
    const cancel = this._registry.subscribe(this.capabilities(interfaceDef), (capabilities) => {
      if (capabilities.length > 0) {
        trigger.wake(capabilities[0]);
      }
    });
    const result = await trigger.wait();
    cancel();
    return result;
  }
  async activatePromise(event) {
    return this.activate(event).pipe(Effect.runPromise);
  }
  async resetPromise(event) {
    return this.reset(event).pipe(Effect.runPromise);
  }
};

// src/core/events.ts
var defineEvent = (id, specifier) => {
  return {
    id,
    specifier
  };
};
var eventKey = (event) => event.specifier ? `${event.id}:${event.specifier}` : event.id;
var oneOf = (...events) => ({
  type: "one-of",
  events
});
var allOf = (...events) => ({
  type: "all-of",
  events
});
var isOneOf = (events) => "type" in events && events.type === "one-of";
var isAllOf = (events) => "type" in events && events.type === "all-of";
var getEvents = (events) => "type" in events ? events.events : [
  events
];

// src/core/manager.ts
import { Registry } from "@effect-atom/atom-react";
import { untracked } from "@preact/signals-core";
import * as Array from "effect/Array";
import * as Duration from "effect/Duration";
import * as Effect2 from "effect/Effect";
import * as Fiber from "effect/Fiber";
import * as Function from "effect/Function";
import * as HashSet from "effect/HashSet";
import * as Match from "effect/Match";
import * as Ref from "effect/Ref";
import { Event } from "@dxos/async";
import { live } from "@dxos/live-object";
import { log as log2 } from "@dxos/log";
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
var isPromise = (value2) => {
  return value2 !== null && typeof value2 === "object" && "then" in value2;
};
var PluginManager = class {
  activation = new Event();
  context;
  registry;
  // TODO(wittjosiah): Replace with Atom.
  _state;
  _pluginLoader;
  _capabilities = /* @__PURE__ */ new Map();
  _moduleMemoMap = /* @__PURE__ */ new Map();
  _activatingEvents = Effect2.runSync(Ref.make([]));
  _activatingModules = Effect2.runSync(Ref.make([]));
  constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
    this.registry = registry ?? Registry.make();
    this.context = new PluginContext({
      registry: this.registry,
      activate: (event) => this._activate(event),
      reset: (id) => this._reset(id)
    });
    this._pluginLoader = pluginLoader;
    this._state = live({
      plugins,
      core,
      enabled,
      modules: [],
      active: [],
      eventsFired: [],
      pendingReset: []
    });
    plugins.forEach((plugin) => this._addPlugin(plugin));
    core.forEach((id) => this.enable(id));
    enabled.forEach((id) => this.enable(id));
  }
  /**
  * Plugins that are currently registered.
  *
  * @reactive
  */
  get plugins() {
    return this._state.plugins;
  }
  /**
  * Ids of plugins that are core and cannot be removed.
  *
  * @reactive
  */
  get core() {
    return this._state.core;
  }
  /**
  * Ids of plugins that are currently enabled.
  *
  * @reactive
  */
  get enabled() {
    return this._state.enabled;
  }
  /**
  * Modules of plugins which are currently enabled.
  *
  * @reactive
  */
  get modules() {
    return this._state.modules;
  }
  /**
  * Ids of modules which are currently active.
  *
  * @reactive
  */
  get active() {
    return this._state.active;
  }
  /**
  * Ids of events which have been fired.
  *
  * @reactive
  */
  get eventsFired() {
    return this._state.eventsFired;
  }
  /**
  * Ids of modules which are pending reset.
  *
  * @reactive
  */
  get pendingReset() {
    return this._state.pendingReset;
  }
  /**
  * Adds a plugin to the manager via the plugin loader.
  * @param id The id of the plugin.
  */
  async add(id) {
    return untracked(async () => {
      log2("add plugin", {
        id
      }, {
        F: __dxlog_file2,
        L: 164,
        S: this,
        C: (f, a) => f(...a)
      });
      const plugin = await this._pluginLoader(id);
      this._addPlugin(plugin);
      return this.enable(id);
    });
  }
  /**
  * Enables a plugin.
  * @param id The id of the plugin.
  */
  enable(id) {
    return untracked(async () => {
      log2("enable plugin", {
        id
      }, {
        F: __dxlog_file2,
        L: 177,
        S: this,
        C: (f, a) => f(...a)
      });
      const plugin = this._getPlugin(id);
      if (!plugin) {
        return false;
      }
      if (!this._state.enabled.includes(id)) {
        this._state.enabled.push(id);
      }
      plugin.modules.forEach((module) => {
        this._addModule(module);
        this._setPendingResetByModule(module);
      });
      log2("pending reset", {
        events: [
          ...this.pendingReset
        ]
      }, {
        F: __dxlog_file2,
        L: 192,
        S: this,
        C: (f, a) => f(...a)
      });
      await Effect2.runPromise(Effect2.all(this.pendingReset.map((event) => this._activate(event)), {
        concurrency: "unbounded"
      }));
      return true;
    });
  }
  /**
  * Removes a plugin from the manager.
  * @param id The id of the plugin.
  */
  remove(id) {
    return untracked(() => {
      log2("remove plugin", {
        id
      }, {
        F: __dxlog_file2,
        L: 210,
        S: this,
        C: (f, a) => f(...a)
      });
      const result = this.disable(id);
      if (!result) {
        return false;
      }
      this._removePlugin(id);
      return true;
    });
  }
  /**
  * Disables a plugin.
  * @param id The id of the plugin.
  */
  disable(id) {
    return untracked(async () => {
      log2("disable plugin", {
        id
      }, {
        F: __dxlog_file2,
        L: 227,
        S: this,
        C: (f, a) => f(...a)
      });
      if (this._state.core.includes(id)) {
        return false;
      }
      const plugin = this._getPlugin(id);
      if (!plugin) {
        return false;
      }
      const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
      if (enabledIndex !== -1) {
        this._state.enabled.splice(enabledIndex, 1);
        await Effect2.runPromise(this._deactivate(id));
        plugin.modules.forEach((module) => {
          this._removeModule(module.id);
        });
      }
      return true;
    });
  }
  /**
  * Activates plugins based on the activation event.
  * @param event The activation event.
  * @returns Whether the activation was successful.
  */
  activate(event) {
    return untracked(() => Effect2.runPromise(this._activate(event)));
  }
  /**
  * Deactivates all of the modules for a plugin.
  * @param id The id of the plugin.
  * @returns Whether the deactivation was successful.
  */
  deactivate(id) {
    return untracked(() => Effect2.runPromise(this._deactivate(id)));
  }
  /**
  * Re-activates the modules that were activated by the event.
  * @param event The activation event.
  * @returns Whether the reset was successful.
  */
  reset(event) {
    return untracked(() => Effect2.runPromise(this._reset(event)));
  }
  _addPlugin(plugin) {
    untracked(() => {
      log2("add plugin", {
        id: plugin.meta.id
      }, {
        F: __dxlog_file2,
        L: 280,
        S: this,
        C: (f, a) => f(...a)
      });
      if (!this._state.plugins.includes(plugin)) {
        this._state.plugins.push(plugin);
      }
    });
  }
  _removePlugin(id) {
    untracked(() => {
      log2("remove plugin", {
        id
      }, {
        F: __dxlog_file2,
        L: 290,
        S: this,
        C: (f, a) => f(...a)
      });
      const pluginIndex = this._state.plugins.findIndex((plugin) => plugin.meta.id === id);
      if (pluginIndex !== -1) {
        this._state.plugins.splice(pluginIndex, 1);
      }
    });
  }
  _addModule(module) {
    untracked(() => {
      log2("add module", {
        id: module.id
      }, {
        F: __dxlog_file2,
        L: 300,
        S: this,
        C: (f, a) => f(...a)
      });
      if (!this._state.modules.includes(module)) {
        this._state.modules.push(module);
      }
    });
  }
  _removeModule(id) {
    untracked(() => {
      log2("remove module", {
        id
      }, {
        F: __dxlog_file2,
        L: 310,
        S: this,
        C: (f, a) => f(...a)
      });
      const moduleIndex = this._state.modules.findIndex((module) => module.id === id);
      if (moduleIndex !== -1) {
        this._state.modules.splice(moduleIndex, 1);
      }
    });
  }
  _getPlugin(id) {
    return this._state.plugins.find((plugin) => plugin.meta.id === id);
  }
  _getActiveModules() {
    return this._state.modules.filter((module) => this._state.active.includes(module.id));
  }
  _getInactiveModules() {
    return this._state.modules.filter((module) => !this._state.active.includes(module.id));
  }
  _getActiveModulesByEvent(key) {
    return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
  }
  _getInactiveModulesByEvent(key) {
    return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
  }
  _setPendingResetByModule(module) {
    return untracked(() => {
      const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
      const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
      if (pendingReset.length > 0) {
        log2("pending reset", {
          events: pendingReset
        }, {
          F: __dxlog_file2,
          L: 348,
          S: this,
          C: (f, a) => f(...a)
        });
        this._state.pendingReset.push(...pendingReset);
      }
    });
  }
  /**
  * @internal
  */
  // TODO(wittjosiah): Improve error typing.
  _activate(event, params) {
    return Effect2.gen(this, function* () {
      const key = typeof event === "string" ? event : eventKey(event);
      log2("activating", {
        key,
        ...params
      }, {
        F: __dxlog_file2,
        L: 364,
        S: this,
        C: (f, a) => f(...a)
      });
      yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
      const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
      if (pendingIndex !== -1) {
        this._state.pendingReset.splice(pendingIndex, 1);
      }
      const activatingEvents = yield* this._activatingEvents;
      const activatingModules = yield* this._activatingModules;
      const modules = this._getInactiveModulesByEvent(key).filter((module) => {
        const allOf2 = isAllOf(module.activatesOn);
        if (!allOf2) {
          return true;
        }
        const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
        return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
      });
      yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
      if (modules.length === 0) {
        log2("no modules to activate", {
          key
        }, {
          F: __dxlog_file2,
          L: 395,
          S: this,
          C: (f, a) => f(...a)
        });
        if (!this._state.eventsFired.includes(key)) {
          this._state.eventsFired.push(key);
        }
        return false;
      }
      log2("activating modules", {
        key,
        modules: modules.map((module) => module.id)
      }, {
        F: __dxlog_file2,
        L: 402,
        S: this,
        C: (f, a) => f(...a)
      });
      this.activation.emit({
        event: key,
        state: "activating"
      });
      yield* Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
        before: key
      })), Effect2.allWith({
        concurrency: "unbounded"
      }));
      const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
        concurrency: "unbounded"
      }), Effect2.catchAll((error) => {
        this.activation.emit({
          event: key,
          state: "error",
          error
        });
        return Effect2.fail(error);
      }));
      yield* Function.pipe(
        modules,
        Array.zip(getCapabilities),
        Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
        Effect2.all
      );
      yield* Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
        after: key
      })), Effect2.allWith({
        concurrency: "unbounded"
      }));
      yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
      yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
      if (!this._state.eventsFired.includes(key)) {
        this._state.eventsFired.push(key);
      }
      this.activation.emit({
        event: key,
        state: "activated"
      });
      log2("activated", {
        key
      }, {
        F: __dxlog_file2,
        L: 458,
        S: this,
        C: (f, a) => f(...a)
      });
      return true;
    });
  }
  // Memoized with _moduleMemoMap
  _loadModule = (mod) => Effect2.tryPromise({
    try: async () => {
      const entry = this._moduleMemoMap.get(mod.id);
      if (entry) {
        return entry;
      }
      const promise2 = (async () => {
        const start = performance.now();
        let failed = false;
        try {
          log2("loading module", {
            module: mod.id
          }, {
            F: __dxlog_file2,
            L: 477,
            S: this,
            C: (f, a) => f(...a)
          });
          let activationResult = await mod.activate(this.context);
          if (typeof activationResult === "function") {
            activationResult = await activationResult();
          }
          return Array.isArray(activationResult) ? activationResult : [
            activationResult
          ];
        } catch (error) {
          failed = true;
          throw error;
        } finally {
          performance.measure("activate-module", {
            start,
            end: performance.now(),
            detail: {
              module: mod.id
            }
          });
          log2("loaded module", {
            module: mod.id,
            elapsed: performance.now() - start,
            failed
          }, {
            F: __dxlog_file2,
            L: 495,
            S: this,
            C: (f, a) => f(...a)
          });
        }
      })();
      this._moduleMemoMap.set(mod.id, promise2);
      return promise2;
    },
    catch: (error) => error
  }).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
    module: mod.id
  }, {
    F: __dxlog_file2,
    L: 506,
    S: this,
    C: (f, a) => f(...a)
  }))))));
  _contributeCapabilities(module, capabilities) {
    return Effect2.gen(this, function* () {
      capabilities.forEach((capability) => {
        this.context.contributeCapability({
          module: module.id,
          ...capability
        });
      });
      this._state.active.push(module.id);
      this._capabilities.set(module.id, capabilities);
    });
  }
  _deactivate(id) {
    return Effect2.gen(this, function* () {
      const plugin = this._getPlugin(id);
      if (!plugin) {
        return false;
      }
      const modules = plugin.modules;
      const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
        concurrency: "unbounded"
      });
      return results.every((result) => result);
    });
  }
  _deactivateModule(module) {
    return Effect2.gen(this, function* () {
      const id = module.id;
      log2("deactivating", {
        id
      }, {
        F: __dxlog_file2,
        L: 540,
        S: this,
        C: (f, a) => f(...a)
      });
      this._moduleMemoMap.delete(id);
      const capabilities = this._capabilities.get(id);
      if (capabilities) {
        for (const capability of capabilities) {
          this.context.removeCapability(capability.interface, capability.implementation);
          const program = capability.deactivate?.();
          yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
            try: () => promise2,
            catch: (error) => error
          })), Match.orElse((program2) => Effect2.succeed(program2)));
        }
        this._capabilities.delete(id);
      }
      const activeIndex = this._state.active.findIndex((event) => event === id);
      if (activeIndex !== -1) {
        this._state.active.splice(activeIndex, 1);
      }
      log2("deactivated", {
        id
      }, {
        F: __dxlog_file2,
        L: 567,
        S: this,
        C: (f, a) => f(...a)
      });
      return true;
    });
  }
  _reset(event) {
    return Effect2.gen(this, function* () {
      const key = typeof event === "string" ? event : eventKey(event);
      log2("reset", {
        key
      }, {
        F: __dxlog_file2,
        L: 575,
        S: this,
        C: (f, a) => f(...a)
      });
      const modules = this._getActiveModulesByEvent(key);
      const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
        concurrency: "unbounded"
      });
      if (results.every((result) => result)) {
        return yield* this._activate(key);
      } else {
        return false;
      }
    });
  }
};
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
  const togetherFiber = yield* Effect2.fork(togetherEffect);
  const result = yield* effect;
  yield* Fiber.interrupt(togetherFiber);
  return result;
});

// src/core/plugin.ts
var PluginModule = class {
  id;
  activatesOn;
  activatesBefore;
  activatesAfter;
  activate;
  constructor(options) {
    this.id = options.id;
    this.activatesOn = options.activatesOn;
    this.activatesBefore = options.activatesBefore;
    this.activatesAfter = options.activatesAfter;
    this.activate = options.activate;
  }
};
var defineModule = (options) => new PluginModule(options);
var Plugin = class {
  meta;
  modules;
  constructor(meta2, modules) {
    this.meta = meta2;
    this.modules = modules;
  }
};
var definePlugin = (meta2, provider) => {
  const factory = (args) => {
    return new Plugin(meta2, provider(args));
  };
  return Object.assign(factory, {
    meta: meta2
  });
};

// src/common/capabilities.ts
(function(Capabilities2) {
  Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
  Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
  Capabilities2.AtomRegistry = defineCapability("dxos.org/app-framework/capability/atom-registry");
  Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
  Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
  Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
  Capabilities2.IntentResolver = defineCapability("dxos.org/app-framework/capability/intent-resolver");
  Capabilities2.IntentDispatcher = defineCapability("dxos.org/app-framework/capability/intent-dispatcher");
  Capabilities2.Layout = defineCapability("dxos.org/app-framework/capability/layout");
  Capabilities2.Translations = defineCapability("dxos.org/app-framework/capability/translations");
  Capabilities2.AppGraph = defineCapability("dxos.org/app-framework/capability/app-graph");
  Capabilities2.AppGraphBuilder = defineCapability("dxos.org/app-framework/capability/app-graph-builder");
  Capabilities2.AppGraphSerializer = defineCapability("dxos.org/app-framework/capability/app-graph-serializer");
  Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
  Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
  Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
  Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
  Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
  Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
  Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
  Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
  Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
  Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
})(Capabilities || (Capabilities = {}));
var Capabilities;

// src/common/collaboration.ts
import * as Schema from "effect/Schema";
import { ContentBlock } from "@dxos/types";
(function(CollaborationActions2) {
  class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
    input: Schema.Struct({
      subject: Schema.Any,
      anchor: Schema.String,
      proposal: ContentBlock.Proposal
    }),
    output: Schema.Void
  }) {
  }
  CollaborationActions2.AcceptProposal = AcceptProposal;
})(CollaborationActions || (CollaborationActions = {}));
var CollaborationActions;

// src/common/events.ts
(function(Events2) {
  Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
  Events2.SetupReactSurface = defineEvent("dxos.org/app-framework/event/setup-react-surface");
  Events2.SetupMetadata = defineEvent("dxos.org/app-framework/event/setup-metadata");
  Events2.SetupIntentResolver = defineEvent("dxos.org/app-framework/event/setup-intent-resolver");
  Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
  Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
  Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
  Events2.SetupArtifactDefinition = defineEvent("dxos.org/app-framework/event/setup-artifact-definition");
  Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
  Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
  Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
  Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
  Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
})(Events || (Events = {}));
var Events;

// src/common/file.ts
import * as Schema2 from "effect/Schema";
var defaultFileTypes = {
  images: [
    "png",
    "jpg",
    "jpeg",
    "gif"
  ],
  media: [
    "mp3",
    "mp4",
    "mov",
    "avi"
  ],
  text: [
    "pdf",
    "txt",
    "md"
  ]
};
var FileInfoSchema = Schema2.Struct({
  name: Schema2.String,
  type: Schema2.String,
  url: Schema2.optional(Schema2.String),
  cid: Schema2.optional(Schema2.String)
});

// src/common/layout.ts
import * as Schema5 from "effect/Schema";

// src/plugin-intent/actions.ts
import * as Schema4 from "effect/Schema";

// src/plugin-intent/intent.ts
import * as Schema3 from "effect/Schema";
var createIntent = (schema, data = {}, params = {}) => {
  const _ = Schema3.validateSync(schema.fields.input)(data);
  const intent = {
    ...params,
    _schema: schema,
    id: schema._tag,
    data
  };
  return {
    first: intent,
    last: intent,
    all: [
      intent
    ]
  };
};
var chain = (schema, data = {}, params = {}) => (intent) => {
  const intents = "all" in intent ? intent.all : [
    intent
  ];
  const first = intents[0];
  const last = {
    ...params,
    _schema: schema,
    id: schema._tag,
    data
  };
  return {
    first,
    last,
    all: [
      ...intents,
      last
    ]
  };
};
var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
  ns: Schema3.String,
  count: Schema3.optional(Schema3.Number),
  defaultValue: Schema3.optional(Schema3.String)
})))));

// src/plugin-intent/meta.ts
var meta = {
  id: "dxos.org/plugin/intent",
  name: "Intent"
};

// src/plugin-intent/actions.ts
(function(IntentAction2) {
  class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
    input: Schema4.Struct({
      intents: Schema4.Array(Schema4.String),
      error: Schema4.optional(Schema4.String)
    }),
    output: Schema4.Void
  }) {
  }
  IntentAction2.Track = Track;
  class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
    input: Schema4.Struct({
      message: Label
    }),
    output: Schema4.Void
  }) {
  }
  IntentAction2.ShowUndo = ShowUndo;
})(IntentAction || (IntentAction = {}));
var IntentAction;

// src/plugin-intent/errors.ts
var BaseError = class extends Error {
  code;
  context;
  constructor(code, message, context) {
    super(message ?? code, {
      cause: context
    }), this.code = code, this.context = context;
    this.name = code;
    Object.setPrototypeOf(this, new.target.prototype);
  }
};
var NoResolversError = class extends BaseError {
  constructor(action) {
    super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
      action
    });
  }
};
var CycleDetectedError = class extends BaseError {
  constructor(context) {
    super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
  }
};

// src/plugin-intent/IntentPlugin.ts
var IntentPlugin = definePlugin(meta, () => [
  defineModule({
    id: `${meta.id}/module/dispatcher`,
    // TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
    //   This is fine for now because it's how it worked prior to capabilities api anyways.
    //   In the future, the intent dispatcher should be able to be reset without resetting the entire app.
    activatesOn: Events.Startup,
    activatesAfter: [
      Events.DispatcherReady
    ],
    activate: lazy(() => import("./intent-dispatcher-LZ4AE66E.mjs"))
  })
]);

// src/common/layout.ts
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
(function(LayoutAction2) {
  LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
  class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.String.annotations({
        description: "The part of the layout to mutate."
      }),
      subject: Schema5.optional(Schema5.Any.annotations({
        description: "The subject of the layout update."
      })),
      options: Schema5.optional(Schema5.Record({
        key: Schema5.String,
        value: Schema5.Any
      }).annotations({
        description: "Additional options for the layout action."
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.UpdateLayout = UpdateLayout;
  class SetLayoutMode extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("mode").annotations({
        description: "Setting the layout mode."
      }),
      subject: Schema5.optional(Schema5.String.annotations({
        description: "Item which is the subject of the new layout mode."
      })),
      options: Schema5.Union(Schema5.Struct({
        mode: Schema5.String.annotations({
          description: "The new layout mode."
        })
      }), Schema5.Struct({
        revert: Schema5.Boolean.annotations({
          description: "Revert to the previous layout mode."
        })
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.SetLayoutMode = SetLayoutMode;
  class UpdateSidebar extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("sidebar").annotations({
        description: "Updating the sidebar."
      }),
      subject: Schema5.optional(Schema5.String.annotations({
        description: "URI of the component to display in the sidebar."
      })),
      options: Schema5.optional(Schema5.Struct({
        state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
          description: "Whether the sidebar is closed, collapsed, or expanded."
        })
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.UpdateSidebar = UpdateSidebar;
  class UpdateComplementary extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("complementary").annotations({
        description: "Updating the complementary sidebar."
      }),
      subject: Schema5.optional(Schema5.String.annotations({
        description: "URI of the component to display in the complementary area."
      })),
      options: Schema5.optional(Schema5.Struct({
        state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
          description: "Whether the complementary sidebar is closed, collapsed, or expanded."
        })
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.UpdateComplementary = UpdateComplementary;
  class UpdateDialog extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("dialog").annotations({
        description: "Updating the dialog."
      }),
      subject: Schema5.optional(Schema5.String.annotations({
        description: "URI of the component to display in the dialog."
      })),
      options: Schema5.Struct({
        state: Schema5.optional(Schema5.Boolean.annotations({
          description: "Whether the dialog is open or closed."
        })),
        type: Schema5.optional(Schema5.Literal("default", "alert").annotations({
          description: "The type of dialog."
        })),
        blockAlign: Schema5.optional(Schema5.Literal("start", "center", "end").annotations({
          description: "The alignment of the dialog."
        })),
        overlayClasses: Schema5.optional(Schema5.String.annotations({
          description: "Additional classes for the dialog overlay."
        })),
        overlayStyle: Schema5.optional(Schema5.Record({
          key: Schema5.String,
          value: Schema5.Any
        }).annotations({
          description: "Additional styles for the dialog overlay."
        })),
        props: Schema5.optional(Schema5.Record({
          key: Schema5.String,
          value: Schema5.Any
        }).annotations({
          description: "Additional props for the dialog."
        }))
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.UpdateDialog = UpdateDialog;
  class UpdatePopover extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("popover").annotations({
        description: "Updating the popover."
      }),
      subject: Schema5.optional(Schema5.Any.annotations({
        description: "URI of the component to display in the popover or data to pass to the popover."
      })),
      options: Schema5.Struct({
        side: Schema5.optional(Schema5.Literal("top", "right", "bottom", "left").annotations({
          description: "The side of the anchor."
        })),
        state: Schema5.optional(Schema5.Boolean.annotations({
          description: "Whether the popover is open or closed."
        })),
        props: Schema5.optional(Schema5.Record({
          key: Schema5.String,
          value: Schema5.Any
        }).annotations({
          description: "Additional props for the popover."
        }))
      }).pipe(Schema5.extend(Schema5.Union(Schema5.Struct({
        variant: Schema5.Literal("virtual"),
        anchor: Schema5.Any.annotations({
          description: "The DOM element to anchor the popover to."
        })
      }), Schema5.Struct({
        variant: Schema5.optional(Schema5.Literal("react")),
        anchorId: Schema5.String.annotations({
          description: "An id that can be used to determine whether to render the anchor subcomponent."
        })
      }))))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.UpdatePopover = UpdatePopover;
  LayoutAction2.Toast = Schema5.Struct({
    id: Schema5.String.annotations({
      description: "The id of the toast."
    }),
    title: Schema5.optional(Label.annotations({
      description: "The title of the toast."
    })),
    description: Schema5.optional(Label.annotations({
      description: "The description of the toast."
    })),
    icon: Schema5.optional(Schema5.String.annotations({
      description: "The icon of the toast."
    })),
    duration: Schema5.optional(Schema5.Number.annotations({
      description: "The duration of the toast."
    })),
    closeLabel: Schema5.optional(Label.annotations({
      description: "The label of the close button."
    })),
    actionLabel: Schema5.optional(Label.annotations({
      description: "The label of the action button."
    })),
    actionAlt: Schema5.optional(Label.annotations({
      description: "The alt text of the action button."
    })),
    onAction: Schema5.optional(Schema5.Any.annotations({
      description: "The action to perform when the action button is clicked."
    }))
  });
  class AddToast extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("toast").annotations({
        description: "Adding a toast."
      }),
      subject: LayoutAction2.Toast.annotations({
        description: "The toast to add."
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.AddToast = AddToast;
  class SwitchWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("workspace").annotations({
        description: "Switching the workspace."
      }),
      subject: Schema5.String.annotations({
        description: "The id of the workspace to switch to."
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.SwitchWorkspace = SwitchWorkspace;
  class RevertWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("workspace").annotations({
        description: "Switching the workspace."
      }),
      options: Schema5.Struct({
        revert: Schema5.Literal(true).annotations({
          description: "Revert to the previous workspace."
        })
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.RevertWorkspace = RevertWorkspace;
  class Open extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("main").annotations({
        description: "Opening an item in the main content area."
      }),
      subject: Schema5.Array(Schema5.String.annotations({
        description: "Ids of the items to open."
      })),
      options: Schema5.optional(Schema5.Struct({
        state: Schema5.optional(Schema5.Literal(true).annotations({
          description: "The items are being added."
        })),
        variant: Schema5.optional(Schema5.String.annotations({
          description: "The variant of the item to open."
        })),
        key: Schema5.optional(Schema5.String.annotations({
          description: "If provided, will replace item with a matching key (id prefix)."
        })),
        workspace: Schema5.optional(Schema5.String.annotations({
          description: "The workspace to open the items in."
        })),
        scrollIntoView: Schema5.optional(Schema5.Boolean.annotations({
          description: "Scroll the items into view."
        })),
        pivotId: Schema5.optional(Schema5.String.annotations({
          description: "The id of the item to place new items next to."
        })),
        positioning: Schema5.optional(Schema5.Union(Schema5.Literal("start").annotations({
          description: "The items are being added before the pivot item."
        }), Schema5.Literal("end").annotations({
          description: "The items are being added after the pivot item."
        })))
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.Open = Open;
  class Set2 extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("main").annotations({
        description: "Setting items in the main content area."
      }),
      subject: Schema5.Array(Schema5.String.annotations({
        description: "Ids of the items to set."
      })),
      options: Schema5.Struct({
        override: Schema5.Literal(true).annotations({
          description: "Override the current items in the main content area."
        })
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.Set = Set2;
  class Close extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("main").annotations({
        description: "Closing items in the main content area."
      }),
      subject: Schema5.Array(Schema5.String.annotations({
        description: "Ids of the items to close."
      })),
      options: Schema5.Struct({
        state: Schema5.Literal(false).annotations({
          description: "The items are being removed."
        })
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.Close = Close;
  class ScrollIntoView extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("current").annotations({
        description: "Setting the current item"
      }),
      subject: Schema5.optional(Schema5.String.annotations({
        description: "The id of the item to set as current."
      })),
      options: Schema5.optional(Schema5.Record({
        key: Schema5.String,
        value: Schema5.Any
      }).annotations({
        description: "Additional options for the scroll into view."
      }))
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.ScrollIntoView = ScrollIntoView;
  class Expose extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
    input: Schema5.Struct({
      part: Schema5.Literal("navigation").annotations({
        description: "Exposing an item in the navigation area."
      }),
      subject: Schema5.String.annotations({
        description: "The id of the item to expose."
      })
    }),
    output: Schema5.Void
  }) {
  }
  LayoutAction2.Expose = Expose;
})(LayoutAction || (LayoutAction = {}));
var LayoutAction;

// src/common/surface.ts
var createSurface = (definition) => definition;

// src/common/translations.ts
import * as Schema6 from "effect/Schema";
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
  key: Schema6.String,
  value: Schema6.Any
}));
var ResourceLanguage = Schema6.Record({
  key: Schema6.String,
  value: ResourceKey
});
var Resource = Schema6.Record({
  key: Schema6.String,
  value: ResourceLanguage
});

// src/plugin-intent/intent-dispatcher.ts
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
var EXECUTION_LIMIT = 100;
var HISTORY_LIMIT = 100;
var createResolver = (resolver) => resolver;
var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
  const historyRef = Effect3.runSync(Ref2.make([]));
  const handleIntent = (intent) => Effect3.gen(function* () {
    const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
    if (candidates.length === 0) {
      return yield* Effect3.fail(new NoResolversError(intent.id));
    }
    const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
    const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
    return {
      _intent: intent,
      ...result
    };
  });
  const dispatch = (intentChain, depth = 0) => {
    log3("dispatch", {
      intentChain: intentChain.all.map((i) => i.id),
      depth
    }, {
      F: __dxlog_file3,
      L: 212,
      S: void 0,
      C: (f, a) => f(...a)
    });
    return Effect3.gen(function* () {
      if (depth > executionLimit) {
        return yield* Effect3.fail(new CycleDetectedError());
      }
      const resultsRef = yield* Ref2.make([]);
      for (const intent of intentChain.all) {
        log3("processing", {
          intent
        }, {
          F: __dxlog_file3,
          L: 220,
          S: this,
          C: (f, a) => f(...a)
        });
        const { data: prev } = (yield* resultsRef.get)[0] ?? {};
        const result2 = yield* handleIntent({
          ...intent,
          data: {
            ...intent.data,
            ...prev
          }
        });
        log3("ok", {
          intent: intent.id,
          result: result2
        }, {
          F: __dxlog_file3,
          L: 223,
          S: this,
          C: (f, a) => f(...a)
        });
        yield* Ref2.update(resultsRef, (results2) => [
          result2,
          ...results2
        ]);
        if (result2.intents) {
          for (const intent2 of result2.intents) {
            yield* dispatch(intent2, depth + 1);
          }
        }
        if (result2.error) {
          log3.error("failed", {
            intent: intent.id,
            error: result2.error
          }, {
            F: __dxlog_file3,
            L: 240,
            S: this,
            C: (f, a) => f(...a)
          });
          return yield* Effect3.fail(result2.error);
        }
      }
      const results = yield* resultsRef.get;
      const result = results[0];
      yield* Ref2.update(historyRef, (history) => {
        const next = [
          ...history,
          results
        ];
        if (next.length > historyLimit) {
          next.splice(0, next.length - historyLimit);
        }
        return next;
      });
      if (result.undoable && isUndoable(results)) {
        yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
          message: result.undoable.message
        })), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
      }
      log3("done", {
        intent: intentChain.all.map((i) => i.id),
        result: result.data
      }, {
        F: __dxlog_file3,
        L: 270,
        S: this,
        C: (f, a) => f(...a)
      });
      return result.data;
    });
  };
  const dispatchPromise = (intentChain) => {
    return Effect3.runPromise(dispatch(intentChain)).then((data) => ({
      data
    })).catch((error) => {
      log3.catch(error, void 0, {
        F: __dxlog_file3,
        L: 279,
        S: void 0,
        C: (f, a) => f(...a)
      });
      return {
        error
      };
    });
  };
  const undo = () => {
    return Effect3.gen(function* () {
      const history = yield* historyRef.get;
      const last = history.findLastIndex(isUndoable);
      const result = last !== -1 ? history[last] : void 0;
      if (result) {
        const all2 = result.map(({ _intent, undoable }) => {
          const data = _intent.data;
          const undoData = undoable?.data ?? {};
          return {
            ..._intent,
            data: {
              ...data,
              ...undoData
            },
            undo: true
          };
        });
        const intent = {
          first: all2[0],
          last: all2.at(-1),
          all: all2
        };
        yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
        return yield* dispatch(intent);
      }
    });
  };
  const undoPromise = () => {
    return Effect3.runPromise(undo()).then((data) => ({
      data
    })).catch((error) => ({
      error
    }));
  };
  return {
    dispatch,
    dispatchPromise,
    undo,
    undoPromise
  };
};
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
var defaultPromise = () => Effect3.runPromise(defaultEffect());
var intent_dispatcher_default = ((context) => {
  const state = live2({
    dispatch: defaultEffect,
    dispatchPromise: defaultPromise,
    undo: defaultEffect,
    undoPromise: defaultPromise
  });
  const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher(() => context.getCapabilities(Capabilities.IntentResolver).flat());
  const manager = context.getCapability(Capabilities.PluginManager);
  state.dispatch = (intentChain, depth) => {
    return Effect3.gen(function* () {
      yield* manager._activate(Events.SetupIntentResolver);
      return yield* dispatch(intentChain, depth);
    });
  };
  state.dispatchPromise = async (intentChain) => {
    await manager.activate(Events.SetupIntentResolver);
    return await dispatchPromise(intentChain);
  };
  state.undo = undo;
  state.undoPromise = undoPromise;
  return contributes(Capabilities.IntentDispatcher, state);
});

export {
  defineCapability,
  contributes,
  lazy,
  PluginContext,
  defineEvent,
  eventKey,
  oneOf,
  allOf,
  isOneOf,
  isAllOf,
  getEvents,
  PluginManager,
  PluginModule,
  defineModule,
  Plugin,
  definePlugin,
  Capabilities,
  CollaborationActions,
  Events,
  defaultFileTypes,
  FileInfoSchema,
  createIntent,
  chain,
  Label,
  IntentAction,
  BaseError,
  NoResolversError,
  CycleDetectedError,
  createResolver,
  createDispatcher,
  intent_dispatcher_default,
  IntentPlugin,
  LayoutAction,
  createSurface,
  ResourceKey,
  ResourceLanguage,
  Resource
};
//# sourceMappingURL=chunk-WPW5VVAX.mjs.map
