// runtime/subsystems/integration/loopback.middleware.ts
function createLoopbackMiddleware(store) {
  return (next) => {
    return async function* (subscription, cursor) {
      for await (const change of next(subscription, cursor)) {
        const isEcho = await store.isEchoOfOwnWrite(
          subscription.domain,
          change.externalId,
          change.record
        );
        if (isEcho) continue;
        yield change;
      }
    };
  };
}

export {
  createLoopbackMiddleware
};
//# sourceMappingURL=chunk-PRWIX6UW.js.map