/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { makeGenericController } from "@arcgis/lumina/controllers";
const useCancelable = () => {
  return makeGenericController((_, controller) => {
    const resources = /* @__PURE__ */ new Set();
    controller.onDisconnected(() => {
      resources.forEach((resource) => resource.cancel());
    });
    return {
      add: (resourceOrResources) => {
        [resourceOrResources].flat().forEach((resource) => resources.add(resource));
      },
      resources
    };
  });
};
export {
  useCancelable as u
};
