/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { InternalError, MatterError } from "#general";
function RemoteResponse(local) {
  switch (local.kind) {
    case "ok":
    case "update":
    case "delete":
      return local;
    case "value":
      return {
        ...local,
        value: local.value.js
      };
    case "error":
      return {
        kind: "error",
        id: local.id,
        code: MatterError.idFor(local.error.constructor),
        message: local.error.bareMessage ?? local.error.message
      };
    default:
      throw new InternalError(`Cannot convert local response kind "${local.kind}" to remote response`);
  }
}
((RemoteResponse2) => {
  function describe(response) {
    switch (response.kind) {
      case "update":
        return `update ${response.endpoint} ${response.behavior}`;
      case "delete":
        return `delete ${response.endpoint}`;
      default:
        return response.kind;
    }
  }
  RemoteResponse2.describe = describe;
})(RemoteResponse || (RemoteResponse = {}));
export {
  RemoteResponse
};
//# sourceMappingURL=RemoteResponse.js.map
