import * as React from 'react';
import { forwardRef } from 'react';
import { extendTailwindMerge, twMerge as twMerge$1 } from 'tailwind-merge';
import { omit, get } from 'lodash-es';
import { createClassed } from '@tw-classed/react';
import { createClassed as createClassed$1 } from '@tw-classed/core';
import 'clsx';
import createVariatGroupTransfomer from 'tailwind-group-variant';
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
import { jsx, jsxs } from 'react/jsx-runtime';
import AutoSizer from 'react-virtualized-auto-sizer';
import { getByPath as getByPath$1 } from '@clickbar/dot-diver';

var __defProp = Object.defineProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};

// src/components/ScrollViewport/ScrollViewport.tsx
var ScrollViewport_exports = {};
__export(ScrollViewport_exports, {
  Container: () => Container,
  FooterSection: () => FooterSection,
  HeaderSection: () => HeaderSection,
  ScrollArea: () => ScrollArea,
  ScrollAreaContainer: () => ScrollAreaContainer,
  ScrollAreaViewport: () => ScrollAreaViewport
});
var twMerge = extendTailwindMerge({
  classGroups: {
    "font-size": [
      {
        // Fixes incorect merging of text size
        text: ["h1", "h2", "h3", "h4", "h5", "h6"]
      }
    ]
  }
});
var { classed } = createClassed({ merger: twMerge });
createClassed$1({ merger: twMerge });

// src/utils/notEmpty.ts
function notEmpty(value) {
  return value !== null && value !== void 0;
}

// src/utils/classed/expandVariant.ts
createVariatGroupTransfomer({});
var ScrollBarElement = classed(
  ScrollAreaPrimitive.ScrollAreaScrollbar,
  "flex touch-none select-none transition-colors relative z-30",
  {
    variants: {
      orientation: {
        vertical: "h-full w-12 border-l border-l-transparent p-[1.5px] animate-slide-left-fade",
        horizontal: "h-8 border-t border-t-transparent p-[1.5px] animate-slide-up-fade"
      }
    },
    defaultVariants: {
      orientation: "vertical"
    }
  }
);
var ScrolllBarThumbElement = classed(
  ScrollAreaPrimitive.ScrollAreaThumb,
  "bg-content-ghost relative flex-1 rounded-full overflow-hidden backdrop-contrast-100 min-h-[44px] transition-[height] will-change-[height]"
);
var ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(ScrollBarElement, { ref, orientation, ...props, children: /* @__PURE__ */ jsx(ScrolllBarThumbElement, {}) }));
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;

// src/utils/environment-utils.ts
function isDevelopment() {
  if (typeof window === "undefined" && typeof process !== "undefined" && process.env.NODE_ENV === "development") {
    return true;
  }
  if (typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1")) {
    return true;
  }
  return false;
}
function getByPath(object, path, _maxDepth) {
  return getByPath$1(object, path);
}

// src/utils/objectMap.ts
function objectMap(obj, fn) {
  return Object.fromEntries(
    Object.entries(obj).map(([k, v], index) => fn({ key: k, value: v, index, get: getByPath })).filter(notEmpty)
  );
}

// src/utils/pickProps.ts
var NO_DEFAULT_VALUE = "_pick_";
function pickProps(props, pickedProps, options) {
  const { shouldValidatePickProp = true } = options ?? {};
  const entries = Object.entries(pickedProps).map(([path, defaultValue]) => {
    const prop = get(props, path);
    if (defaultValue === NO_DEFAULT_VALUE) {
      return [path, prop];
    }
    if (shouldValidatePickProp) {
      validatePickProp(defaultValue, pickedProps);
    }
    return [path, prop ?? defaultValue];
  });
  return Object.fromEntries(entries);
}
function validatePickProp(input, pickedProps) {
  if (isDevelopment()) {
    const startsWith = ["_p", "pick"];
    const isLikelyTypo = typeof input === "string" && startsWith.some((typo) => input.startsWith(typo));
    if (isLikelyTypo) {
      const functionName = "`pickProps`";
      throw new Error(`
      Error thrown from ${functionName}
      
      A possible typo was detected in the arguments passed to the ${functionName} function.

      Expected value: "${NO_DEFAULT_VALUE}"

      Received value: "${input}" \u274C

      ${JSON.stringify(
        objectMap(pickedProps, ({ key, value }) => [
          key,
          value === input ? `${value} \u274C` : value
        ]),
        null,
        2
      )}
 
      If this is intended, add \`shouldValidatePickProp: true\` to the options.

      Note: This error is thrown only during development.

      `);
    }
  }
}
var ScrollAreaContainer = ({
  scrollAreaClassName,
  autoSizerClassName,
  ...props
}) => {
  const scrollAreaProps = pickProps(props, {
    asChild: "_pick_",
    dir: "_pick_",
    scrollHideDelay: "_pick_",
    type: "_pick_"
  });
  const autoSizerProps = pickProps(props, {
    defaultHeight: "_pick_",
    defaultWidth: "_pick_",
    disableHeight: "_pick_",
    disableWidth: "_pick_"
  });
  const { children, className, ...rest } = omit(props, [
    ...Object.keys(scrollAreaProps),
    ...Object.keys(autoSizerProps)
  ]);
  return /* @__PURE__ */ jsx(ScrollAreaContainerElement, { className, ...rest, children: /* @__PURE__ */ jsx(
    AutoSizer,
    {
      className: twMerge$1(
        "bg-inherit rounded-[inherit] rounded-b-[inherit] rounded-t-[inherit]",
        autoSizerClassName
      ),
      ...autoSizerProps,
      children: ({ width, height }) => /* @__PURE__ */ jsxs(
        ScrollAreaPrimitive.Root,
        {
          className: twMerge$1("bg-inherit", scrollAreaClassName),
          ...scrollAreaProps,
          style: { width, height, overflow: "hidden" },
          children: [
            children,
            /* @__PURE__ */ jsx(ScrollBar, {}),
            /* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
          ]
        }
      )
    }
  ) });
};
var ScrollAreaContainerElement = classed("div", "w-full  bg-inherit", {
  variants: {
    grow: {
      true: "!grow",
      false: "!grow"
    }
  },
  defaultVariants: {
    grow: true
  }
});
var ScrollArea = forwardRef(
  ({ children, ...props }, forwardedRef) => {
    return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, { ...props, className: "overflow-hidden grow", children: [
      /* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full", ref: forwardedRef, children }),
      /* @__PURE__ */ jsx(ScrollBar, {})
    ] });
  }
);
var ScrollAreaViewport = classed(ScrollAreaPrimitive.Viewport, "w-full h-full");
var Container = classed("div", "grow flex flex-col");
var HeaderSection = classed("div", "shrink-0");
var FooterSection = classed("div", "shrink-0");

export { ScrollViewport_exports as ScrollViewport };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map