import { defaultFormat } from "../../../zero-types/src/format.js";
import { QueryImpl } from "./query-impl.js";
function newRunnableQuery(delegate, schema, table) {
  return new RunnableQueryImpl(
    delegate,
    schema,
    table,
    { table },
    defaultFormat,
    void 0
  );
}
class RunnableQueryImpl extends QueryImpl {
  #delegate;
  constructor(delegate, schema, tableName, ast = { table: tableName }, format = defaultFormat, system = "client", customQueryID, currentJunction) {
    super(
      schema,
      tableName,
      ast,
      format,
      system,
      customQueryID,
      currentJunction,
      (tableName2, ast2, format2, customQueryID2, currentJunction2) => new RunnableQueryImpl(
        delegate,
        schema,
        tableName2,
        ast2,
        format2,
        system,
        customQueryID2,
        currentJunction2
      )
    );
    this.#delegate = delegate;
  }
  run(options) {
    return this.#delegate.run(this, options);
  }
  preload(options) {
    return this.#delegate.preload(this, options);
  }
  materialize(factory, ttl) {
    let actualFactory;
    let options;
    if (typeof factory === "function") {
      actualFactory = factory;
      options = { ttl };
    } else {
      actualFactory = void 0;
      options = { ttl: factory };
    }
    return this.#delegate.materialize(this, actualFactory, options);
  }
}
export {
  RunnableQueryImpl,
  newRunnableQuery
};
//# sourceMappingURL=runnable-query-impl.js.map
