"use client";
'use strict';

var AutoScroll = require('embla-carousel-auto-scroll');
var clsx = require('clsx');
var tailwindMerge = require('tailwind-merge');
var img = require('@page-speed/img');
var React = require('react');
var useEmblaCarousel = require('embla-carousel-react');
var jsxRuntime = require('react/jsx-runtime');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var AutoScroll__default = /*#__PURE__*/_interopDefault(AutoScroll);
var React__namespace = /*#__PURE__*/_interopNamespace(React);
var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);

// components/blocks/logos/logos-minimal-carousel.tsx
function cn(...inputs) {
  return tailwindMerge.twMerge(clsx.clsx(inputs));
}
var CarouselContext = React__namespace.createContext(null);
function useCarousel() {
  const context = React__namespace.useContext(CarouselContext);
  if (!context) {
    throw new Error("useCarousel must be used within a <Carousel />");
  }
  return context;
}
function Carousel({
  orientation = "horizontal",
  opts,
  setApi,
  plugins,
  className,
  children,
  ...props
}) {
  const [carouselRef, api] = useEmblaCarousel__default.default(
    {
      ...opts,
      axis: orientation === "horizontal" ? "x" : "y"
    },
    plugins
  );
  const [canScrollPrev, setCanScrollPrev] = React__namespace.useState(false);
  const [canScrollNext, setCanScrollNext] = React__namespace.useState(false);
  const onSelect = React__namespace.useCallback((api2) => {
    if (!api2) return;
    setCanScrollPrev(api2.canScrollPrev());
    setCanScrollNext(api2.canScrollNext());
  }, []);
  const scrollPrev = React__namespace.useCallback(() => {
    api?.scrollPrev();
  }, [api]);
  const scrollNext = React__namespace.useCallback(() => {
    api?.scrollNext();
  }, [api]);
  const handleKeyDown = React__namespace.useCallback(
    (event) => {
      if (event.key === "ArrowLeft") {
        event.preventDefault();
        scrollPrev();
      } else if (event.key === "ArrowRight") {
        event.preventDefault();
        scrollNext();
      }
    },
    [scrollPrev, scrollNext]
  );
  React__namespace.useEffect(() => {
    if (!api || !setApi) return;
    setApi(api);
  }, [api, setApi]);
  React__namespace.useEffect(() => {
    if (!api) return;
    onSelect(api);
    api.on("reInit", onSelect);
    api.on("select", onSelect);
    return () => {
      api?.off("select", onSelect);
    };
  }, [api, onSelect]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    CarouselContext.Provider,
    {
      value: {
        carouselRef,
        api,
        opts,
        orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
        scrollPrev,
        scrollNext,
        canScrollPrev,
        canScrollNext
      },
      children: /* @__PURE__ */ jsxRuntime.jsx(
        "div",
        {
          onKeyDownCapture: handleKeyDown,
          className: cn("relative", className),
          role: "region",
          "aria-roledescription": "carousel",
          "data-slot": "carousel",
          ...props,
          children
        }
      )
    }
  );
}
function CarouselContent({ className, ...props }) {
  const { carouselRef, orientation } = useCarousel();
  return /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      ref: carouselRef,
      className: "overflow-hidden",
      "data-slot": "carousel-content",
      children: /* @__PURE__ */ jsxRuntime.jsx(
        "div",
        {
          className: cn(
            "flex",
            orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
            className
          ),
          ...props
        }
      )
    }
  );
}
function CarouselItem({ className, ...props }) {
  const { orientation } = useCarousel();
  return /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      role: "group",
      "aria-roledescription": "slide",
      "data-slot": "carousel-item",
      className: cn(
        "min-w-0 shrink-0 grow-0 basis-full",
        orientation === "horizontal" ? "pl-4" : "pt-4",
        className
      ),
      ...props
    }
  );
}
var defaultLogos = [
  {
    name: "Company 1",
    logo: "https://cdn.ing/assets/files/record/286222/4w39lhwei0pa97up2wjnay3j96gh"
  },
  {
    name: "Company 2",
    logo: "https://cdn.ing/assets/files/record/286252/xd7hyzbpkjwsauxm5j9yn9v44min"
  },
  {
    name: "Company 3",
    logo: "https://cdn.ing/assets/files/record/286216/bw4zypgflisdtapxy0n4nbmsmtum"
  },
  {
    name: "Company 4",
    logo: "https://cdn.ing/assets/files/record/286284/cz20wf2l2tjokrxu563pcml7pkmu"
  },
  {
    name: "Company 5",
    logo: "https://cdn.ing/assets/files/record/286215/6wwi6yh2ax2nuo2vqa5gn9vozrgq"
  },
  {
    name: "Company 6",
    logo: "https://cdn.ing/assets/files/record/286249/ff7m4wdw0zefj7d96v4ajmljuifc"
  }
];
function LogosMinimalCarousel({
  className,
  logos = defaultLogos,
  optixFlowConfig
}) {
  return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cn("py-16", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative border-y border-border", children: /* @__PURE__ */ jsxRuntime.jsx(
    Carousel,
    {
      opts: { loop: true },
      plugins: [AutoScroll__default.default({ playOnInit: true, speed: 0.5 })],
      children: /* @__PURE__ */ jsxRuntime.jsx(CarouselContent, { className: "ml-0 py-8", children: [...logos, ...logos].map((logo, index) => /* @__PURE__ */ jsxRuntime.jsx(
        CarouselItem,
        {
          className: "flex basis-1/3 justify-center border-r border-border pl-0 last:border-r-0 sm:basis-1/4 md:basis-1/5 lg:basis-1/6",
          children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center justify-center px-8", children: /* @__PURE__ */ jsxRuntime.jsx(
            img.Img,
            {
              src: logo.logo,
              alt: `${logo.name} logo`,
              width: 100,
              height: 32,
              className: "h-8 w-auto object-contain opacity-50 grayscale transition-all hover:opacity-100 hover:grayscale-0",
              optixFlowConfig
            }
          ) })
        },
        index
      )) })
    }
  ) }) });
}

exports.LogosMinimalCarousel = LogosMinimalCarousel;
//# sourceMappingURL=logos-minimal-carousel.cjs.map
//# sourceMappingURL=logos-minimal-carousel.cjs.map