import { Multiaddr } from 'multiaddr';
import { configure } from '../lib/configure.js';
import { toUrlSearchParams } from '../lib/to-url-search-params.js';
export const createLocalAddrs = configure(api => {
  async function localAddrs(options = {}) {
    const res = await api.post('swarm/addrs/local', {
      signal: options.signal,
      searchParams: toUrlSearchParams(options),
      headers: options.headers
    });
    const {Strings} = await res.json();
    return (Strings || []).map(a => new Multiaddr(a));
  }
  return localAddrs;
});