// src/components/properties/CheckboxProperty.tsx
import { Check as Check2 } from "lucide-react";

// src/components/user-action/Checkbox.tsx
import { Check, Minus } from "lucide-react";
import clsx from "clsx";

// node_modules/@radix-ui/react-checkbox/dist/index.mjs
import * as React10 from "react";

// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
import * as React from "react";
function setRef(ref, value) {
  if (typeof ref === "function") {
    return ref(value);
  } else if (ref !== null && ref !== void 0) {
    ref.current = value;
  }
}
function composeRefs(...refs) {
  return (node) => {
    let hasCleanup = false;
    const cleanups = refs.map((ref) => {
      const cleanup = setRef(ref, node);
      if (!hasCleanup && typeof cleanup == "function") {
        hasCleanup = true;
      }
      return cleanup;
    });
    if (hasCleanup) {
      return () => {
        for (let i = 0; i < cleanups.length; i++) {
          const cleanup = cleanups[i];
          if (typeof cleanup == "function") {
            cleanup();
          } else {
            setRef(refs[i], null);
          }
        }
      };
    }
  };
}
function useComposedRefs(...refs) {
  return React.useCallback(composeRefs(...refs), refs);
}

// node_modules/@radix-ui/react-context/dist/index.mjs
import * as React2 from "react";
import { jsx } from "react/jsx-runtime";
function createContextScope(scopeName, createContextScopeDeps = []) {
  let defaultContexts = [];
  function createContext32(rootComponentName, defaultContext) {
    const BaseContext = React2.createContext(defaultContext);
    const index = defaultContexts.length;
    defaultContexts = [...defaultContexts, defaultContext];
    const Provider = (props) => {
      const { scope, children, ...context } = props;
      const Context = scope?.[scopeName]?.[index] || BaseContext;
      const value = React2.useMemo(() => context, Object.values(context));
      return /* @__PURE__ */ jsx(Context.Provider, { value, children });
    };
    Provider.displayName = rootComponentName + "Provider";
    function useContext22(consumerName, scope) {
      const Context = scope?.[scopeName]?.[index] || BaseContext;
      const context = React2.useContext(Context);
      if (context) return context;
      if (defaultContext !== void 0) return defaultContext;
      throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
    }
    return [Provider, useContext22];
  }
  const createScope = () => {
    const scopeContexts = defaultContexts.map((defaultContext) => {
      return React2.createContext(defaultContext);
    });
    return function useScope(scope) {
      const contexts = scope?.[scopeName] || scopeContexts;
      return React2.useMemo(
        () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
        [scope, contexts]
      );
    };
  };
  createScope.scopeName = scopeName;
  return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
}
function composeContextScopes(...scopes) {
  const baseScope = scopes[0];
  if (scopes.length === 1) return baseScope;
  const createScope = () => {
    const scopeHooks = scopes.map((createScope2) => ({
      useScope: createScope2(),
      scopeName: createScope2.scopeName
    }));
    return function useComposedScopes(overrideScopes) {
      const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
        const scopeProps = useScope(overrideScopes);
        const currentScope = scopeProps[`__scope${scopeName}`];
        return { ...nextScopes2, ...currentScope };
      }, {});
      return React2.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
    };
  };
  createScope.scopeName = baseScope.scopeName;
  return createScope;
}

// node_modules/@radix-ui/primitive/dist/index.mjs
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
  return function handleEvent(event) {
    originalEventHandler?.(event);
    if (checkForDefaultPrevented === false || !event.defaultPrevented) {
      return ourEventHandler?.(event);
    }
  };
}

// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
import * as React4 from "react";

// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
import * as React3 from "react";
var useLayoutEffect2 = globalThis?.document ? React3.useLayoutEffect : () => {
};

// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
import * as React22 from "react";
var useInsertionEffect = React4[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
function useControllableState({
  prop,
  defaultProp,
  onChange = () => {
  },
  caller
}) {
  const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
    defaultProp,
    onChange
  });
  const isControlled = prop !== void 0;
  const value = isControlled ? prop : uncontrolledProp;
  if (true) {
    const isControlledRef = React4.useRef(prop !== void 0);
    React4.useEffect(() => {
      const wasControlled = isControlledRef.current;
      if (wasControlled !== isControlled) {
        const from = wasControlled ? "controlled" : "uncontrolled";
        const to = isControlled ? "controlled" : "uncontrolled";
        console.warn(
          `${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
        );
      }
      isControlledRef.current = isControlled;
    }, [isControlled, caller]);
  }
  const setValue = React4.useCallback(
    (nextValue) => {
      if (isControlled) {
        const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
        if (value2 !== prop) {
          onChangeRef.current?.(value2);
        }
      } else {
        setUncontrolledProp(nextValue);
      }
    },
    [isControlled, prop, setUncontrolledProp, onChangeRef]
  );
  return [value, setValue];
}
function useUncontrolledState({
  defaultProp,
  onChange
}) {
  const [value, setValue] = React4.useState(defaultProp);
  const prevValueRef = React4.useRef(value);
  const onChangeRef = React4.useRef(onChange);
  useInsertionEffect(() => {
    onChangeRef.current = onChange;
  }, [onChange]);
  React4.useEffect(() => {
    if (prevValueRef.current !== value) {
      onChangeRef.current?.(value);
      prevValueRef.current = value;
    }
  }, [value, prevValueRef]);
  return [value, setValue, onChangeRef];
}
function isFunction(value) {
  return typeof value === "function";
}
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");

// node_modules/@radix-ui/react-use-previous/dist/index.mjs
import * as React5 from "react";
function usePrevious(value) {
  const ref = React5.useRef({ value, previous: value });
  return React5.useMemo(() => {
    if (ref.current.value !== value) {
      ref.current.previous = ref.current.value;
      ref.current.value = value;
    }
    return ref.current.previous;
  }, [value]);
}

// node_modules/@radix-ui/react-use-size/dist/index.mjs
import * as React6 from "react";
function useSize(element) {
  const [size, setSize] = React6.useState(void 0);
  useLayoutEffect2(() => {
    if (element) {
      setSize({ width: element.offsetWidth, height: element.offsetHeight });
      const resizeObserver = new ResizeObserver((entries) => {
        if (!Array.isArray(entries)) {
          return;
        }
        if (!entries.length) {
          return;
        }
        const entry = entries[0];
        let width;
        let height;
        if ("borderBoxSize" in entry) {
          const borderSizeEntry = entry["borderBoxSize"];
          const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
          width = borderSize["inlineSize"];
          height = borderSize["blockSize"];
        } else {
          width = element.offsetWidth;
          height = element.offsetHeight;
        }
        setSize({ width, height });
      });
      resizeObserver.observe(element, { box: "border-box" });
      return () => resizeObserver.unobserve(element);
    } else {
      setSize(void 0);
    }
  }, [element]);
  return size;
}

// node_modules/@radix-ui/react-presence/dist/index.mjs
import * as React23 from "react";
import * as React7 from "react";
function useStateMachine(initialState, machine) {
  return React7.useReducer((state, event) => {
    const nextState = machine[state][event];
    return nextState ?? state;
  }, initialState);
}
var Presence = (props) => {
  const { present, children } = props;
  const presence = usePresence(present);
  const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
  const ref = useComposedRefs(presence.ref, getElementRef(child));
  const forceMount = typeof children === "function";
  return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
};
Presence.displayName = "Presence";
function usePresence(present) {
  const [node, setNode] = React23.useState();
  const stylesRef = React23.useRef(null);
  const prevPresentRef = React23.useRef(present);
  const prevAnimationNameRef = React23.useRef("none");
  const initialState = present ? "mounted" : "unmounted";
  const [state, send] = useStateMachine(initialState, {
    mounted: {
      UNMOUNT: "unmounted",
      ANIMATION_OUT: "unmountSuspended"
    },
    unmountSuspended: {
      MOUNT: "mounted",
      ANIMATION_END: "unmounted"
    },
    unmounted: {
      MOUNT: "mounted"
    }
  });
  React23.useEffect(() => {
    const currentAnimationName = getAnimationName(stylesRef.current);
    prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
  }, [state]);
  useLayoutEffect2(() => {
    const styles = stylesRef.current;
    const wasPresent = prevPresentRef.current;
    const hasPresentChanged = wasPresent !== present;
    if (hasPresentChanged) {
      const prevAnimationName = prevAnimationNameRef.current;
      const currentAnimationName = getAnimationName(styles);
      if (present) {
        send("MOUNT");
      } else if (currentAnimationName === "none" || styles?.display === "none") {
        send("UNMOUNT");
      } else {
        const isAnimating = prevAnimationName !== currentAnimationName;
        if (wasPresent && isAnimating) {
          send("ANIMATION_OUT");
        } else {
          send("UNMOUNT");
        }
      }
      prevPresentRef.current = present;
    }
  }, [present, send]);
  useLayoutEffect2(() => {
    if (node) {
      let timeoutId;
      const ownerWindow = node.ownerDocument.defaultView ?? window;
      const handleAnimationEnd = (event) => {
        const currentAnimationName = getAnimationName(stylesRef.current);
        const isCurrentAnimation = currentAnimationName.includes(event.animationName);
        if (event.target === node && isCurrentAnimation) {
          send("ANIMATION_END");
          if (!prevPresentRef.current) {
            const currentFillMode = node.style.animationFillMode;
            node.style.animationFillMode = "forwards";
            timeoutId = ownerWindow.setTimeout(() => {
              if (node.style.animationFillMode === "forwards") {
                node.style.animationFillMode = currentFillMode;
              }
            });
          }
        }
      };
      const handleAnimationStart = (event) => {
        if (event.target === node) {
          prevAnimationNameRef.current = getAnimationName(stylesRef.current);
        }
      };
      node.addEventListener("animationstart", handleAnimationStart);
      node.addEventListener("animationcancel", handleAnimationEnd);
      node.addEventListener("animationend", handleAnimationEnd);
      return () => {
        ownerWindow.clearTimeout(timeoutId);
        node.removeEventListener("animationstart", handleAnimationStart);
        node.removeEventListener("animationcancel", handleAnimationEnd);
        node.removeEventListener("animationend", handleAnimationEnd);
      };
    } else {
      send("ANIMATION_END");
    }
  }, [node, send]);
  return {
    isPresent: ["mounted", "unmountSuspended"].includes(state),
    ref: React23.useCallback((node2) => {
      stylesRef.current = node2 ? getComputedStyle(node2) : null;
      setNode(node2);
    }, [])
  };
}
function getAnimationName(styles) {
  return styles?.animationName || "none";
}
function getElementRef(element) {
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.ref;
  }
  getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
  mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.props.ref;
  }
  return element.props.ref || element.ref;
}

// node_modules/@radix-ui/react-primitive/dist/index.mjs
import * as React9 from "react";
import * as ReactDOM from "react-dom";

// node_modules/@radix-ui/react-slot/dist/index.mjs
import * as React8 from "react";
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
// @__NO_SIDE_EFFECTS__
function createSlot(ownerName) {
  const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
  const Slot2 = React8.forwardRef((props, forwardedRef) => {
    const { children, ...slotProps } = props;
    const childrenArray = React8.Children.toArray(children);
    const slottable = childrenArray.find(isSlottable);
    if (slottable) {
      const newElement = slottable.props.children;
      const newChildren = childrenArray.map((child) => {
        if (child === slottable) {
          if (React8.Children.count(newElement) > 1) return React8.Children.only(null);
          return React8.isValidElement(newElement) ? newElement.props.children : null;
        } else {
          return child;
        }
      });
      return /* @__PURE__ */ jsx2(SlotClone, { ...slotProps, ref: forwardedRef, children: React8.isValidElement(newElement) ? React8.cloneElement(newElement, void 0, newChildren) : null });
    }
    return /* @__PURE__ */ jsx2(SlotClone, { ...slotProps, ref: forwardedRef, children });
  });
  Slot2.displayName = `${ownerName}.Slot`;
  return Slot2;
}
// @__NO_SIDE_EFFECTS__
function createSlotClone(ownerName) {
  const SlotClone = React8.forwardRef((props, forwardedRef) => {
    const { children, ...slotProps } = props;
    if (React8.isValidElement(children)) {
      const childrenRef = getElementRef2(children);
      const props2 = mergeProps(slotProps, children.props);
      if (children.type !== React8.Fragment) {
        props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
      }
      return React8.cloneElement(children, props2);
    }
    return React8.Children.count(children) > 1 ? React8.Children.only(null) : null;
  });
  SlotClone.displayName = `${ownerName}.SlotClone`;
  return SlotClone;
}
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
function isSlottable(child) {
  return React8.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
}
function mergeProps(slotProps, childProps) {
  const overrideProps = { ...childProps };
  for (const propName in childProps) {
    const slotPropValue = slotProps[propName];
    const childPropValue = childProps[propName];
    const isHandler = /^on[A-Z]/.test(propName);
    if (isHandler) {
      if (slotPropValue && childPropValue) {
        overrideProps[propName] = (...args) => {
          const result = childPropValue(...args);
          slotPropValue(...args);
          return result;
        };
      } else if (slotPropValue) {
        overrideProps[propName] = slotPropValue;
      }
    } else if (propName === "style") {
      overrideProps[propName] = { ...slotPropValue, ...childPropValue };
    } else if (propName === "className") {
      overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
    }
  }
  return { ...slotProps, ...overrideProps };
}
function getElementRef2(element) {
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.ref;
  }
  getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
  mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
  if (mayWarn) {
    return element.props.ref;
  }
  return element.props.ref || element.ref;
}

// node_modules/@radix-ui/react-primitive/dist/index.mjs
import { jsx as jsx3 } from "react/jsx-runtime";
var NODES = [
  "a",
  "button",
  "div",
  "form",
  "h2",
  "h3",
  "img",
  "input",
  "label",
  "li",
  "nav",
  "ol",
  "p",
  "select",
  "span",
  "svg",
  "ul"
];
var Primitive = NODES.reduce((primitive, node) => {
  const Slot = createSlot(`Primitive.${node}`);
  const Node2 = React9.forwardRef((props, forwardedRef) => {
    const { asChild, ...primitiveProps } = props;
    const Comp = asChild ? Slot : node;
    if (typeof window !== "undefined") {
      window[Symbol.for("radix-ui")] = true;
    }
    return /* @__PURE__ */ jsx3(Comp, { ...primitiveProps, ref: forwardedRef });
  });
  Node2.displayName = `Primitive.${node}`;
  return { ...primitive, [node]: Node2 };
}, {});

// node_modules/@radix-ui/react-checkbox/dist/index.mjs
import { Fragment as Fragment3, jsx as jsx4, jsxs } from "react/jsx-runtime";
var CHECKBOX_NAME = "Checkbox";
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
function CheckboxProvider(props) {
  const {
    __scopeCheckbox,
    checked: checkedProp,
    children,
    defaultChecked,
    disabled,
    form,
    name,
    onCheckedChange,
    required,
    value = "on",
    // @ts-expect-error
    internal_do_not_use_render
  } = props;
  const [checked, setChecked] = useControllableState({
    prop: checkedProp,
    defaultProp: defaultChecked ?? false,
    onChange: onCheckedChange,
    caller: CHECKBOX_NAME
  });
  const [control, setControl] = React10.useState(null);
  const [bubbleInput, setBubbleInput] = React10.useState(null);
  const hasConsumerStoppedPropagationRef = React10.useRef(false);
  const isFormControl = control ? !!form || !!control.closest("form") : (
    // We set this to true by default so that events bubble to forms without JS (SSR)
    true
  );
  const context = {
    checked,
    disabled,
    setChecked,
    control,
    setControl,
    name,
    form,
    value,
    hasConsumerStoppedPropagationRef,
    required,
    defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
    isFormControl,
    bubbleInput,
    setBubbleInput
  };
  return /* @__PURE__ */ jsx4(
    CheckboxProviderImpl,
    {
      scope: __scopeCheckbox,
      ...context,
      children: isFunction2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
    }
  );
}
var TRIGGER_NAME = "CheckboxTrigger";
var CheckboxTrigger = React10.forwardRef(
  ({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
    const {
      control,
      value,
      disabled,
      checked,
      required,
      setControl,
      setChecked,
      hasConsumerStoppedPropagationRef,
      isFormControl,
      bubbleInput
    } = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
    const composedRefs = useComposedRefs(forwardedRef, setControl);
    const initialCheckedStateRef = React10.useRef(checked);
    React10.useEffect(() => {
      const form = control?.form;
      if (form) {
        const reset = () => setChecked(initialCheckedStateRef.current);
        form.addEventListener("reset", reset);
        return () => form.removeEventListener("reset", reset);
      }
    }, [control, setChecked]);
    return /* @__PURE__ */ jsx4(
      Primitive.button,
      {
        type: "button",
        role: "checkbox",
        "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
        "aria-required": required,
        "data-state": getState(checked),
        "data-disabled": disabled ? "" : void 0,
        disabled,
        value,
        ...checkboxProps,
        ref: composedRefs,
        onKeyDown: composeEventHandlers(onKeyDown, (event) => {
          if (event.key === "Enter") event.preventDefault();
        }),
        onClick: composeEventHandlers(onClick, (event) => {
          setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
          if (bubbleInput && isFormControl) {
            hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
            if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
          }
        })
      }
    );
  }
);
CheckboxTrigger.displayName = TRIGGER_NAME;
var Checkbox = React10.forwardRef(
  (props, forwardedRef) => {
    const {
      __scopeCheckbox,
      name,
      checked,
      defaultChecked,
      required,
      disabled,
      value,
      onCheckedChange,
      form,
      ...checkboxProps
    } = props;
    return /* @__PURE__ */ jsx4(
      CheckboxProvider,
      {
        __scopeCheckbox,
        checked,
        defaultChecked,
        disabled,
        required,
        onCheckedChange,
        name,
        form,
        value,
        internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs(Fragment3, { children: [
          /* @__PURE__ */ jsx4(
            CheckboxTrigger,
            {
              ...checkboxProps,
              ref: forwardedRef,
              __scopeCheckbox
            }
          ),
          isFormControl && /* @__PURE__ */ jsx4(
            CheckboxBubbleInput,
            {
              __scopeCheckbox
            }
          )
        ] })
      }
    );
  }
);
Checkbox.displayName = CHECKBOX_NAME;
var INDICATOR_NAME = "CheckboxIndicator";
var CheckboxIndicator = React10.forwardRef(
  (props, forwardedRef) => {
    const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
    const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
    return /* @__PURE__ */ jsx4(
      Presence,
      {
        present: forceMount || isIndeterminate(context.checked) || context.checked === true,
        children: /* @__PURE__ */ jsx4(
          Primitive.span,
          {
            "data-state": getState(context.checked),
            "data-disabled": context.disabled ? "" : void 0,
            ...indicatorProps,
            ref: forwardedRef,
            style: { pointerEvents: "none", ...props.style }
          }
        )
      }
    );
  }
);
CheckboxIndicator.displayName = INDICATOR_NAME;
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
var CheckboxBubbleInput = React10.forwardRef(
  ({ __scopeCheckbox, ...props }, forwardedRef) => {
    const {
      control,
      hasConsumerStoppedPropagationRef,
      checked,
      defaultChecked,
      required,
      disabled,
      name,
      value,
      form,
      bubbleInput,
      setBubbleInput
    } = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
    const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
    const prevChecked = usePrevious(checked);
    const controlSize = useSize(control);
    React10.useEffect(() => {
      const input = bubbleInput;
      if (!input) return;
      const inputProto = window.HTMLInputElement.prototype;
      const descriptor = Object.getOwnPropertyDescriptor(
        inputProto,
        "checked"
      );
      const setChecked = descriptor.set;
      const bubbles = !hasConsumerStoppedPropagationRef.current;
      if (prevChecked !== checked && setChecked) {
        const event = new Event("click", { bubbles });
        input.indeterminate = isIndeterminate(checked);
        setChecked.call(input, isIndeterminate(checked) ? false : checked);
        input.dispatchEvent(event);
      }
    }, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
    const defaultCheckedRef = React10.useRef(isIndeterminate(checked) ? false : checked);
    return /* @__PURE__ */ jsx4(
      Primitive.input,
      {
        type: "checkbox",
        "aria-hidden": true,
        defaultChecked: defaultChecked ?? defaultCheckedRef.current,
        required,
        disabled,
        name,
        value,
        form,
        ...props,
        tabIndex: -1,
        ref: composedRefs,
        style: {
          ...props.style,
          ...controlSize,
          position: "absolute",
          pointerEvents: "none",
          opacity: 0,
          margin: 0,
          // We transform because the input is absolutely positioned but we have
          // rendered it **after** the button. This pulls it back to sit on top
          // of the button.
          transform: "translateX(-100%)"
        }
      }
    );
  }
);
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
function isFunction2(value) {
  return typeof value === "function";
}
function isIndeterminate(checked) {
  return checked === "indeterminate";
}
function getState(checked) {
  return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
}

// src/hooks/useOverwritableState.ts
import { useEffect as useEffect5, useState as useState5 } from "react";

// src/utils/resolveSetState.ts
function resolveSetState(action, prev) {
  return typeof action === "function" ? action(prev) : action;
}

// src/hooks/useOverwritableState.ts
var useOverwritableState = (initialValue, onChange) => {
  const [state, setState] = useState5(initialValue);
  useEffect5(() => {
    setState(initialValue);
  }, [initialValue]);
  const onChangeWrapper = (action) => {
    const resolved = resolveSetState(action, state);
    setState(resolved);
    onChange?.(state);
  };
  return [state, onChangeWrapper];
};

// src/components/user-action/Checkbox.tsx
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
var checkboxSizeMapping = {
  sm: "size-5 border-1",
  md: "size-6 border-1",
  lg: "size-8 border-2"
};
var checkboxIconSizeMapping = {
  sm: "size-4 stroke-3",
  md: "size-5 stroke-3",
  lg: "size-7 stroke-3"
};
var Checkbox2 = ({
  disabled,
  checked = false,
  indeterminate = false,
  onChange,
  size = "md",
  className = "",
  ...props
}) => {
  const usedSizeClass = checkboxSizeMapping[size];
  const innerIconSize = checkboxIconSizeMapping[size];
  return /* @__PURE__ */ jsx5(
    Checkbox,
    {
      ...props,
      disabled,
      checked: indeterminate ? "indeterminate" : checked,
      onCheckedChange: onChange,
      className: clsx(
        usedSizeClass,
        `flex-col-0 items-center justify-center rounded`,
        {
          "text-disabled border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
          "hover:border-primary": !disabled,
          "bg-input-background": !disabled && !checked,
          "bg-primary/30 border-primary text-primary": !disabled && (checked || indeterminate)
        },
        className
      ),
      children: /* @__PURE__ */ jsxs2(CheckboxIndicator, { children: [
        !checked && !indeterminate && /* @__PURE__ */ jsx5("div", { className: clsx("bg-input-background", innerIconSize) }),
        checked && !indeterminate && /* @__PURE__ */ jsx5(Check, { className: innerIconSize }),
        indeterminate && /* @__PURE__ */ jsx5(Minus, { className: innerIconSize })
      ] })
    }
  );
};

// src/localization/LanguageProvider.tsx
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect6, useMemo as useMemo4, useState as useState7 } from "react";

// src/hooks/useLocalStorage.ts
import { useCallback as useCallback4, useState as useState6 } from "react";

// src/localization/util.ts
var languages = ["en", "de"];
var languagesLocalNames = {
  en: "English",
  de: "Deutsch"
};
var DEFAULT_LANGUAGE = "en";
var LanguageUtil = {
  languages,
  DEFAULT_LANGUAGE,
  languagesLocalNames
};

// src/localization/LanguageProvider.tsx
import { jsx as jsx6 } from "react/jsx-runtime";
var LanguageContext = createContext2({
  language: LanguageUtil.DEFAULT_LANGUAGE,
  setLanguage: (v) => v
});
var useLanguage = () => {
  const context = useContext2(LanguageContext);
  if (!context) {
    throw new Error("useLanguage must be used within LanguageContext. Try adding a LanguageProvider around your app.");
  }
  return context;
};

// src/localization/useTranslation.ts
var TranslationPluralCount = {
  zero: 0,
  one: 1,
  two: 2,
  few: 3,
  many: 11,
  other: -1
};
var useTranslation = (translations, overwriteTranslation = {}) => {
  const { language: languageProp, translation: overwrite } = overwriteTranslation;
  const { language: inferredLanguage } = useLanguage();
  const usedLanguage = languageProp ?? inferredLanguage;
  const usedTranslations = [...translations];
  if (overwrite) {
    usedTranslations.push(overwrite);
  }
  return (key, options) => {
    const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
    try {
      for (let i = translations.length - 1; i >= 0; i--) {
        const translation = translations[i];
        const localizedTranslation = translation[usedLanguage];
        if (!localizedTranslation) {
          continue;
        }
        const value = localizedTranslation[key];
        if (!value) {
          continue;
        }
        let forProcessing;
        if (typeof value !== "string") {
          if (count === TranslationPluralCount.zero && value?.zero) {
            forProcessing = value.zero;
          } else if (count === TranslationPluralCount.one && value?.one) {
            forProcessing = value.one;
          } else if (count === TranslationPluralCount.two && value?.two) {
            forProcessing = value.two;
          } else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
            forProcessing = value.few;
          } else if (count > TranslationPluralCount.many && value?.many) {
            forProcessing = value.many;
          } else {
            forProcessing = value.other;
          }
        } else {
          forProcessing = value;
        }
        forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
          return replacements[placeholder] ?? `{{key:${placeholder}}}`;
        });
        return forProcessing;
      }
    } catch (e) {
      console.error(e);
    }
    return `{{${usedLanguage}:${key}}}`;
  };
};

// src/components/properties/PropertyBase.tsx
import { AlertTriangle } from "lucide-react";
import clsx3 from "clsx";

// src/components/user-action/Button.tsx
import { forwardRef as forwardRef4 } from "react";
import clsx2 from "clsx";
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
var ButtonColorUtil = {
  solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
  text: ["primary", "negative", "neutral"],
  outline: ["primary"]
};
var IconButtonUtil = {
  icon: [...ButtonColorUtil.solid, "transparent"]
};
var paddingMapping = {
  none: "",
  small: "btn-sm",
  medium: "btn-md",
  large: "btn-lg"
};
var iconPaddingMapping = {
  none: "",
  tiny: "icon-btn-xs",
  small: "icon-btn-sm",
  medium: "icon-btn-md",
  large: "icon-btn-lg"
};
var ButtonUtil = {
  paddingMapping,
  iconPaddingMapping
};
var SolidButton = forwardRef4(function SolidButton2({
  children,
  color = "primary",
  size = "medium",
  startIcon,
  endIcon,
  onClick,
  className,
  ...restProps
}, ref) {
  const colorClasses = {
    primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
    secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
    tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
    positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
    warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
    negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
    neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
  }[color];
  const iconColorClasses = {
    primary: "not-group-disabled:text-button-solid-primary-icon",
    secondary: "not-group-disabled:text-button-solid-secondary-icon",
    tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
    positive: "not-group-disabled:text-button-solid-positive-icon",
    warning: "not-group-disabled:text-button-solid-warning-icon",
    negative: "not-group-disabled:text-button-solid-negative-icon",
    neutral: "not-group-disabled:text-button-solid-neutral-icon"
  }[color];
  return /* @__PURE__ */ jsxs3(
    "button",
    {
      ref,
      onClick,
      className: clsx2(
        "group font-semibold",
        colorClasses,
        "not-disabled:hover:brightness-90",
        "disabled:text-disabled disabled:bg-disabled-background",
        ButtonUtil.paddingMapping[size],
        className
      ),
      ...restProps,
      children: [
        startIcon && /* @__PURE__ */ jsx7(
          "span",
          {
            className: clsx2(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: startIcon
          }
        ),
        children,
        endIcon && /* @__PURE__ */ jsx7(
          "span",
          {
            className: clsx2(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: endIcon
          }
        )
      ]
    }
  );
});
var TextButton = ({
  children,
  color = "neutral",
  size = "medium",
  startIcon,
  endIcon,
  onClick,
  coloredHoverBackground = true,
  className,
  ...restProps
}) => {
  const colorClasses = {
    primary: "not-disabled:bg-transparent not-disabled:text-button-text-primary-text not-disabled:focus-visible:outline-button-text-primary-text",
    negative: "not-disabled:bg-transparent not-disabled:text-button-text-negative-text not-disabled:focus-visible:outline-button-text-negative-text",
    neutral: "not-disabled:bg-transparent not-disabled:text-button-text-neutral-text not-disabled:focus-visible:outline-button-text-neutral-text"
  }[color];
  const backgroundColor = {
    primary: "not-disabled:hover:bg-button-text-primary-text/20 not-disabled:focus-visible:bg-button-text-primary-text/20",
    negative: "not-disabled:hover:bg-button-text-negative-text/20 not-disabled:focus-visible:bg-button-text-negative-text/20",
    neutral: "not-disabled:hover:bg-button-text-neutral-text/20 not-disabled:focus-visible:bg-button-text-neutral-text/20"
  }[color];
  const iconColorClasses = {
    primary: "not-group-disabled:text-button-text-primary-icon",
    negative: "not-group-disabled:text-button-text-negative-icon",
    neutral: "not-group-disabled:text-button-text-neutral-icon"
  }[color];
  return /* @__PURE__ */ jsxs3(
    "button",
    {
      onClick,
      className: clsx2(
        "group font-semibold",
        "disabled:text-disabled",
        colorClasses,
        {
          [backgroundColor]: coloredHoverBackground,
          "not-disabled:hover:bg-button-text-hover-background": !coloredHoverBackground
        },
        ButtonUtil.paddingMapping[size],
        className
      ),
      ...restProps,
      children: [
        startIcon && /* @__PURE__ */ jsx7(
          "span",
          {
            className: clsx2(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: startIcon
          }
        ),
        children,
        endIcon && /* @__PURE__ */ jsx7(
          "span",
          {
            className: clsx2(
              iconColorClasses,
              "group-disabled:text-disabled-icon"
            ),
            children: endIcon
          }
        )
      ]
    }
  );
};
var IconButton = forwardRef4(function IconButton2({
  children,
  color = "primary",
  size = "medium",
  className,
  ...restProps
}, ref) {
  const colorClasses = {
    primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
    secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
    tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
    positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
    warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
    negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
    neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
    transparent: "not-disabled:bg-transparent"
  }[color];
  return /* @__PURE__ */ jsx7(
    "button",
    {
      ref,
      className: clsx2(
        colorClasses,
        "not-disabled:hover:brightness-90",
        "disabled:text-disabled",
        {
          "disabled:bg-disabled-background": color !== "transparent",
          "disabled:opacity-70": color === "transparent",
          "not-disabled:hover:bg-button-text-hover-background": color === "transparent"
        },
        ButtonUtil.iconPaddingMapping[size],
        className
      ),
      ...restProps,
      children
    }
  );
});

// src/localization/defaults/form.ts
var formTranslation = {
  en: {
    add: "Add",
    all: "All",
    apply: "Apply",
    back: "Back",
    cancel: "Cancel",
    change: "Change",
    clear: "Clear",
    click: "Click",
    clickToCopy: "Click to Copy",
    close: "Close",
    confirm: "Confirm",
    copy: "Copy",
    copied: "Copied",
    create: "Create",
    decline: "Decline",
    delete: "Delete",
    discard: "Discard",
    discardChanges: "Discard Changes",
    done: "Done",
    edit: "Edit",
    enterText: "Enter text here",
    error: "Error",
    exit: "Exit",
    fieldRequiredError: "This field is required.",
    invalidEmailError: "Please enter a valid email address.",
    less: "Less",
    loading: "Loading",
    maxLengthError: "Maximum length exceeded.",
    minLengthError: "Minimum length not met.",
    more: "More",
    next: "Next",
    no: "No",
    none: "None",
    nothingFound: "Nothing found",
    of: "of",
    optional: "Optional",
    pleaseWait: "Please wait...",
    previous: "Previous",
    remove: "Remove",
    required: "Required",
    reset: "Reset",
    save: "Save",
    saved: "Saved",
    search: "Search",
    select: "Select",
    selectOption: "Select an option",
    show: "Show",
    showMore: "Show more",
    showLess: "Show less",
    submit: "Submit",
    success: "Success",
    update: "Update",
    unsavedChanges: "Unsaved Changes",
    unsavedChangesSaveQuestion: "Do you want to save your changes?",
    yes: "Yes"
  },
  de: {
    add: "Hinzuf\xFCgen",
    all: "Alle",
    apply: "Anwenden",
    back: "Zur\xFCck",
    cancel: "Abbrechen",
    change: "\xC4ndern",
    clear: "L\xF6schen",
    click: "Klicken",
    clickToCopy: "Zum kopieren klicken",
    close: "Schlie\xDFen",
    confirm: "Best\xE4tigen",
    copy: "Kopieren",
    copied: "Kopiert",
    create: "Erstellen",
    decline: "Ablehnen",
    delete: "L\xF6schen",
    discard: "Verwerfen",
    discardChanges: "\xC4nderungen Verwerfen",
    done: "Fertig",
    edit: "Bearbeiten",
    enterText: "Text hier eingeben",
    error: "Fehler",
    exit: "Beenden",
    fieldRequiredError: "Dieses Feld ist erforderlich.",
    invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
    less: "Weniger",
    loading: "L\xE4dt",
    maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
    minLengthError: "Mindestl\xE4nge nicht erreicht.",
    more: "Mehr",
    next: "Weiter",
    no: "Nein",
    none: "Nichts",
    nothingFound: "Nichts gefunden",
    of: "von",
    optional: "Optional",
    pleaseWait: "Bitte warten...",
    previous: "Vorherige",
    remove: "Entfernen",
    required: "Erforderlich",
    reset: "Zur\xFCcksetzen",
    save: "Speichern",
    saved: "Gespeichert",
    search: "Suche",
    select: "Select",
    selectOption: "Option ausw\xE4hlen",
    show: "Anzeigen",
    showMore: "Mehr anzeigen",
    showLess: "Weniger anzeigen",
    submit: "Abschicken",
    success: "Erfolg",
    update: "Update",
    unsavedChanges: "Ungespeicherte \xC4nderungen",
    unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
    yes: "Ja"
  }
};

// src/components/properties/PropertyBase.tsx
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
var PropertyBase = ({
  overwriteTranslation,
  name,
  input,
  softRequired = false,
  hasValue,
  icon,
  readOnly,
  onRemove,
  className = ""
}) => {
  const translation = useTranslation([formTranslation], overwriteTranslation);
  const requiredAndNoValue = softRequired && !hasValue;
  return /* @__PURE__ */ jsxs4("div", { className: clsx3("flex-row-0 group", className), children: [
    /* @__PURE__ */ jsxs4(
      "div",
      {
        className: clsx3(
          "flex-row-2 max-w-48 min-w-48 px-3 py-2 items-center rounded-l-xl border-2 border-r-0",
          {
            "bg-property-title-background text-property-title-text group-hover:border-primary": !requiredAndNoValue,
            "bg-warning text-surface-warning group-hover:border-warning border-warning/90": requiredAndNoValue
          },
          className
        ),
        children: [
          /* @__PURE__ */ jsx8("div", { className: "max-w-6 min-w-6 text-text-primary", children: icon }),
          /* @__PURE__ */ jsx8("span", { className: "font-semibold", children: name })
        ]
      }
    ),
    /* @__PURE__ */ jsxs4(
      "div",
      {
        className: clsx3(
          "flex-row-2 grow px-3 py-2 justify-between items-center rounded-r-xl border-2 border-l-0 min-h-15",
          {
            "bg-input-background text-input-text group-hover:border-primary": !requiredAndNoValue,
            "bg-surface-warning group-hover:border-warning border-warning/90": requiredAndNoValue
          },
          className
        ),
        children: [
          input({ softRequired, hasValue }),
          requiredAndNoValue && /* @__PURE__ */ jsx8("div", { className: "text-warning", children: /* @__PURE__ */ jsx8(AlertTriangle, { size: 24 }) }),
          onRemove && !readOnly && /* @__PURE__ */ jsx8(
            TextButton,
            {
              onClick: onRemove,
              color: "negative",
              className: clsx3("items-center"),
              disabled: !hasValue,
              children: translation("remove")
            }
          )
        ]
      }
    )
  ] });
};

// src/components/properties/CheckboxProperty.tsx
import { useId } from "react";

// src/components/user-action/Label.tsx
import clsx4 from "clsx";
import { jsx as jsx9 } from "react/jsx-runtime";
var styleMapping = {
  md: "typography-label-md color-label-text",
  lg: "typography-label-lg color-label-text"
};
var Label = ({
  children,
  size = "md",
  className,
  ...props
}) => {
  return /* @__PURE__ */ jsx9("label", { ...props, className: clsx4(styleMapping[size], className), children });
};

// src/components/properties/CheckboxProperty.tsx
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
var CheckboxProperty = ({
  overwriteTranslation,
  value,
  onChange,
  readOnly,
  ...baseProps
}) => {
  const translation = useTranslation([formTranslation], overwriteTranslation);
  const id = useId();
  return /* @__PURE__ */ jsx10(
    PropertyBase,
    {
      ...baseProps,
      hasValue: true,
      readOnly,
      icon: /* @__PURE__ */ jsx10(Check2, { size: 24 }),
      input: () => /* @__PURE__ */ jsxs5("div", { className: "flex-row-2 items-center", children: [
        /* @__PURE__ */ jsx10(
          Checkbox2,
          {
            id,
            checked: value ?? true,
            disabled: readOnly,
            onChange,
            "aria-labelledby": id + "label"
          }
        ),
        /* @__PURE__ */ jsx10(Label, { id: id + "label", children: `${translation("yes")}/${translation("no")}` })
      ] })
    }
  );
};

// src/components/properties/DateProperty.tsx
import { CalendarDays } from "lucide-react";
import clsx6 from "clsx";

// src/utils/date.ts
var formatDate = (date) => {
  const year = date.getFullYear().toString().padStart(4, "0");
  const month = (date.getMonth() + 1).toString().padStart(2, "0");
  const day = date.getDate().toString().padStart(2, "0");
  return `${year}-${month}-${day}`;
};
var formatDateTime = (date) => {
  const dateString = formatDate(date);
  const hours = date.getHours().toString().padStart(2, "0");
  const minutes = date.getMinutes().toString().padStart(2, "0");
  return `${dateString}T${hours}:${minutes}`;
};

// src/components/user-action/input/Input.tsx
import { forwardRef as forwardRef5, useImperativeHandle, useRef as useRef6 } from "react";
import clsx5 from "clsx";

// src/hooks/useDelay.ts
import { useEffect as useEffect7, useState as useState8 } from "react";
var defaultOptions = {
  delay: 3e3,
  disabled: false
};
function useDelay(options) {
  const [timer, setTimer] = useState8(void 0);
  const { delay, disabled } = {
    ...defaultOptions,
    ...options
  };
  const clearTimer = () => {
    clearTimeout(timer);
    setTimer(void 0);
  };
  const restartTimer = (onDelayFinish) => {
    if (disabled) {
      return;
    }
    clearTimeout(timer);
    setTimer(setTimeout(() => {
      onDelayFinish();
      setTimer(void 0);
    }, delay));
  };
  useEffect7(() => {
    return () => {
      clearTimeout(timer);
    };
  }, [timer]);
  useEffect7(() => {
    if (disabled) {
      clearTimeout(timer);
      setTimer(void 0);
    }
  }, [disabled, timer]);
  return { restartTimer, clearTimer, hasActiveTimer: !!timer };
}

// src/hooks/focus/useFocusManagement.ts
import { useCallback as useCallback5 } from "react";
function useFocusManagement() {
  const getFocusableElements = useCallback5(() => {
    return Array.from(
      document.querySelectorAll(
        'input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])'
      )
    ).filter(
      (el) => el instanceof HTMLElement && !el.hasAttribute("disabled") && !el.hasAttribute("hidden") && el.tabIndex !== -1
    );
  }, []);
  const getNextFocusElement = useCallback5(() => {
    const elements = getFocusableElements();
    if (elements.length === 0) {
      return void 0;
    }
    let nextElement = elements[0];
    if (document.activeElement instanceof HTMLElement) {
      const currentIndex = elements.indexOf(document.activeElement);
      nextElement = elements[(currentIndex + 1) % elements.length];
    }
    return nextElement;
  }, [getFocusableElements]);
  const focusNext = useCallback5(() => {
    const nextElement = getNextFocusElement();
    nextElement?.focus();
  }, [getNextFocusElement]);
  const getPreviousFocusElement = useCallback5(() => {
    const elements = getFocusableElements();
    if (elements.length === 0) {
      return void 0;
    }
    let previousElement = elements[0];
    if (document.activeElement instanceof HTMLElement) {
      const currentIndex = elements.indexOf(document.activeElement);
      if (currentIndex === 0) {
        previousElement = elements[elements.length - 1];
      } else {
        previousElement = elements[currentIndex - 1];
      }
    }
    return previousElement;
  }, [getFocusableElements]);
  const focusPrevious = useCallback5(() => {
    const previousElement = getPreviousFocusElement();
    if (previousElement) previousElement.focus();
  }, [getPreviousFocusElement]);
  return {
    getFocusableElements,
    getNextFocusElement,
    getPreviousFocusElement,
    focusNext,
    focusPrevious
  };
}

// src/components/user-action/input/Input.tsx
import { jsx as jsx11 } from "react/jsx-runtime";
var defaultEditCompleteOptions = {
  allowEnterComplete: false,
  onBlur: true,
  afterDelay: true,
  delay: 2500
};
var Input = forwardRef5(function Input2({
  value,
  onChange,
  onChangeText,
  onEditCompleted,
  editCompleteOptions,
  disabled = false,
  invalid = false,
  defaultStyle = true,
  className,
  ...props
}, forwardedRef) {
  const {
    onBlur: allowEditCompleteOnBlur,
    afterDelay,
    delay,
    allowEnterComplete
  } = { ...defaultEditCompleteOptions, ...editCompleteOptions };
  const {
    restartTimer,
    clearTimer
  } = useDelay({ delay, disabled: !afterDelay });
  const innerRef = useRef6(null);
  useImperativeHandle(forwardedRef, () => innerRef.current);
  const { focusNext } = useFocusManagement();
  return /* @__PURE__ */ jsx11(
    "input",
    {
      ...props,
      ref: innerRef,
      value,
      disabled,
      className: defaultStyle ? clsx5(
        "px-3 py-2 rounded-md text-sm h-10 border-2 border-transparent focus-style-none",
        {
          "bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
          "bg-negative/20 text-negative hover:border-negative focus-visible:border-negative": !disabled && invalid,
          "bg-disabled-background text-disabled border-disabled-border": disabled
        },
        className
      ) : className,
      onKeyDown: (event) => {
        props.onKeyDown?.(event);
        if (!allowEnterComplete) {
          return;
        }
        if (event.key === "Enter" && !event.shiftKey) {
          event.preventDefault();
          innerRef.current?.blur();
          onEditCompleted?.(event.target.value);
          focusNext();
        }
      },
      onBlur: (event) => {
        props.onBlur?.(event);
        if (allowEditCompleteOnBlur) {
          onEditCompleted?.(event.target.value);
          clearTimer();
        }
      },
      onChange: (event) => {
        onChange?.(event);
        const value2 = event.target.value;
        restartTimer(() => {
          innerRef.current?.blur();
          onEditCompleted?.(value2);
        });
        onChangeText?.(value2);
      },
      "aria-invalid": props["aria-invalid"] ?? invalid,
      "aria-disabled": props["aria-disabled"] ?? disabled
    }
  );
});

// src/components/properties/DateProperty.tsx
import { jsx as jsx12 } from "react/jsx-runtime";
var DateProperty = ({
  value,
  onChange,
  onEditComplete,
  readOnly,
  type = "dateTime",
  ...baseProps
}) => {
  const hasValue = !!value;
  const dateText = value ? type === "dateTime" ? formatDateTime(value) : formatDate(value) : "";
  return /* @__PURE__ */ jsx12(
    PropertyBase,
    {
      ...baseProps,
      hasValue,
      icon: /* @__PURE__ */ jsx12(CalendarDays, { size: 24 }),
      input: ({ softRequired }) => /* @__PURE__ */ jsx12(
        Input,
        {
          className: clsx6("!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !w-fit !rounded-none", { "bg-surface-warning": softRequired && !hasValue }),
          value: dateText,
          type: type === "dateTime" ? "datetime-local" : "date",
          readOnly,
          onChange: (event) => {
            const value2 = event.target.value;
            if (!value2) {
              event.preventDefault();
              return;
            }
            const dueDate = new Date(value2);
            onChange?.(dueDate);
          },
          onEditCompleted: (value2) => onEditComplete?.(new Date(value2))
        }
      )
    }
  );
};

// src/components/properties/MultiSelectProperty.tsx
import { List } from "lucide-react";
import clsx10 from "clsx";

// src/components/user-action/select/Select.tsx
import {
  createContext as createContext3,
  forwardRef as forwardRef7,
  useCallback as useCallback9,
  useContext as useContext3,
  useEffect as useEffect11,
  useId as useId4,
  useImperativeHandle as useImperativeHandle2,
  useMemo as useMemo5,
  useRef as useRef8,
  useState as useState12
} from "react";
import clsx9 from "clsx";

// src/components/layout/Expandable.tsx
import { forwardRef as forwardRef6, useCallback as useCallback6, useId as useId2 } from "react";
import { ChevronDown } from "lucide-react";
import clsx7 from "clsx";
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
var ExpansionIcon = ({ isExpanded, className }) => {
  return /* @__PURE__ */ jsx13(
    ChevronDown,
    {
      "aria-hidden": true,
      className: clsx7(
        "min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
        { "rotate-180": isExpanded },
        className
      )
    }
  );
};
var Expandable = forwardRef6(function Expandable2({
  children,
  id: providedId,
  label,
  icon,
  isExpanded = false,
  onChange,
  clickOnlyOnHeader = true,
  disabled = false,
  className,
  headerClassName,
  contentClassName,
  contentExpandedClassName
}, ref) {
  const defaultIcon = useCallback6((expanded) => /* @__PURE__ */ jsx13(ExpansionIcon, { isExpanded: expanded }), []);
  icon ??= defaultIcon;
  const generatedId = useId2();
  const id = providedId ?? generatedId;
  return /* @__PURE__ */ jsxs6(
    "div",
    {
      ref,
      onClick: () => !clickOnlyOnHeader && !disabled && onChange?.(!isExpanded),
      className: clsx7(
        "flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
        { "cursor-pointer": !clickOnlyOnHeader && !disabled },
        className
      ),
      children: [
        /* @__PURE__ */ jsxs6(
          "button",
          {
            onClick: () => clickOnlyOnHeader && !disabled && onChange?.(!isExpanded),
            className: clsx7(
              "flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
              {
                "group-hover:brightness-97": !isExpanded,
                "hover:brightness-97": isExpanded && !disabled,
                "cursor-pointer": clickOnlyOnHeader && !disabled
              },
              headerClassName
            ),
            "aria-expanded": isExpanded,
            "aria-controls": `${id}-content`,
            "aria-disabled": disabled ?? void 0,
            children: [
              label,
              icon(isExpanded)
            ]
          }
        ),
        /* @__PURE__ */ jsx13(
          "div",
          {
            id: `${id}-content`,
            className: clsx7(
              "flex-col-2 px-4 transition-all duration-300 ease-in-out",
              {
                [clsx7("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
                "max-h-0 opacity-0 overflow-hidden": !isExpanded
              },
              contentClassName
            ),
            role: "region",
            children
          }
        )
      ]
    }
  );
});
var ExpandableUncontrolled = forwardRef6(function ExpandableUncontrolled2({
  isExpanded,
  onChange,
  ...props
}, ref) {
  const [usedIsExpanded, setUsedIsExpanded] = useOverwritableState(isExpanded, onChange);
  return /* @__PURE__ */ jsx13(
    Expandable,
    {
      ...props,
      ref,
      isExpanded: usedIsExpanded,
      onChange: setUsedIsExpanded
    }
  );
});

// src/hooks/focus/useFocusTrap.ts
import { useCallback as useCallback7, useEffect as useEffect9, useId as useId3, useRef as useRef7, useState as useState10 } from "react";

// src/hooks/focus/useIsMounted.ts
import { useEffect as useEffect8, useLayoutEffect as useLayoutEffect3, useState as useState9 } from "react";
var isClient = typeof window !== "undefined" && typeof document !== "undefined";
var useIsomorphicEffect = isClient ? useLayoutEffect3 : useEffect8;
var useIsMounted = () => {
  const [isMounted, setIsMounted] = useState9(false);
  useIsomorphicEffect(() => {
    setIsMounted(true);
    return () => {
      setIsMounted(false);
    };
  }, []);
  return isMounted;
};

// src/hooks/focus/useFocusTrap.ts
var createFocusGuard = () => {
  const div = document.createElement("div");
  Object.assign(div.style, {
    opacity: "0",
    outline: "none",
    boxShadow: "none",
    position: "fixed",
    pointerEvents: "none",
    touchAction: "none"
  });
  div.tabIndex = 0;
  div.setAttribute("data-hw-focus-guard", "");
  document.body.appendChild(div);
  return div;
};
function getContainedFocusableElements(element) {
  return element?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
}
var FocusTrapService = class {
  constructor() {
    // The last entry is always the active one
    this.listeners = [];
    this.onFocusIn = (event) => {
      const active = this.getActive();
      if (!active || !active.container.current) return;
      const { container } = active;
      if (!container.current.contains(event.target)) {
        this.focusElement();
      }
    };
  }
  getActive() {
    if (this.listeners.length === 0) return void 0;
    return this.listeners[this.listeners.length - 1];
  }
  focusElement() {
    const active = this.getActive();
    if (!active) return;
    const { container, initialFocusElement } = active;
    const containerElement = container.current;
    if (initialFocusElement?.current) {
      initialFocusElement.current.focus();
    } else {
      const elements = getContainedFocusableElements(containerElement);
      if (elements && elements.length > 0) {
        const first = elements.item(0);
        first.focus();
      } else {
        containerElement.focus();
      }
    }
  }
  removeGuards() {
    document.querySelectorAll("[data-hw-focus-guard]").forEach((node) => node.remove());
  }
  addGuards() {
    document.body.insertAdjacentElement("afterbegin", createFocusGuard());
    document.body.insertAdjacentElement("beforeend", createFocusGuard());
  }
  activate() {
    document.addEventListener("focusin", this.onFocusIn);
    this.addGuards();
  }
  deactivate() {
    document.removeEventListener("focusin", this.onFocusIn);
    this.removeGuards();
  }
  register(listener) {
    this.listeners.push(listener);
    if (this.listeners.length === 1) {
      this.activate();
    }
    const active = listener;
    this.listeners.forEach((listener2) => {
      const { focus, pause } = listener2;
      if (listener2 === active) {
        focus();
      } else {
        pause();
      }
    });
  }
  unregister(id) {
    const index = this.listeners.findIndex((trap) => trap.id === id);
    if (index !== -1) {
      const isActive = index === this.listeners.length - 1;
      const listener = this.listeners[index];
      this.listeners = this.listeners.filter((listener2) => listener2.id !== id);
      if (isActive) {
        this.deactivate();
        listener.focusLast();
        const active = this.getActive();
        this.listeners.forEach((listener2) => {
          const { pause, unpause } = listener2;
          if (listener2 === active) {
            unpause();
          } else {
            pause();
          }
        });
        if (this.listeners.length > 0) {
          this.activate();
        }
      }
    } else {
      console.warn(`Unable to unregister id ${id}: not found`);
    }
  }
};
var service = new FocusTrapService();
var useFocusTrap = ({
  container,
  active = true,
  initialFocus,
  focusFirst = true
}) => {
  const lastFocusRef = useRef7(null);
  const [paused, setPaused] = useState10(false);
  const isMounted = useIsMounted();
  const id = useId3();
  const focusElement = useCallback7(() => {
    const containerElement = container.current;
    if (initialFocus?.current) {
      initialFocus.current.focus();
    } else {
      const elements = getContainedFocusableElements(containerElement);
      if (elements && elements.length > 0) {
        const first = elements.item(0);
        first.focus();
      } else {
        containerElement.focus();
      }
    }
  }, [container, initialFocus]);
  useEffect9(() => {
    if (active && isMounted) {
      let pause = function() {
        setPaused(true);
      }, unpause = function() {
        setPaused(false);
        if (!container.current.contains(document.activeElement)) {
          focusElement();
        }
      }, focus = function() {
        focusElement();
        setPaused(false);
      }, focusLast = function() {
        lastFocusRef.current?.focus();
      };
      if (!lastFocusRef.current) {
        lastFocusRef.current = document.activeElement;
      }
      service.register({ id, pause, focus, focusLast, unpause, container, initialFocusElement: initialFocus });
      return () => {
        service.unregister(id);
        lastFocusRef.current = void 0;
      };
    }
  }, [active, container, focusElement, id, initialFocus, isMounted]);
  useEffect9(() => {
    if (active && !paused && isMounted) {
      let onKeyDown = function(event) {
        const key = event.key;
        const elements = getContainedFocusableElements(containerElement);
        const active2 = document.activeElement;
        const index = [...elements].findIndex((value) => value === active2);
        if (index === -1 || event.altKey || event.ctrlKey || event.metaKey) {
          return;
        }
        if (key === "Tab") {
          const next = event.shiftKey ? -1 : 1;
          const nextIndex = (index + next + elements.length) % elements.length;
          const nextElement = elements[nextIndex];
          nextElement.focus();
          event.preventDefault();
        }
      };
      const containerElement = container.current;
      containerElement.addEventListener("keydown", onKeyDown);
      return () => {
        containerElement.removeEventListener("keydown", onKeyDown);
      };
    }
  }, [active, paused, isMounted, container, initialFocus, focusFirst, focusElement]);
};

// src/utils/match.ts
var match = (key, values) => {
  return values[key];
};

// src/components/user-action/select/Select.tsx
import { CheckIcon, Plus, XIcon } from "lucide-react";

// src/components/layout/Chip.tsx
import clsx8 from "clsx";
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
var Chip = ({
  children,
  trailingIcon,
  color = "default",
  size = "md",
  icon = false,
  variant = "normal",
  className = "",
  ...restProps
}) => {
  const colorMapping = {
    default: "text-tag-default-text bg-tag-default-background",
    dark: "text-tag-dark-text bg-tag-dark-background",
    red: "text-tag-red-text bg-tag-red-background",
    yellow: "text-tag-yellow-text bg-tag-yellow-background",
    green: "text-tag-green-text bg-tag-green-background",
    blue: "text-tag-blue-text bg-tag-blue-background",
    pink: "text-tag-pink-text bg-tag-pink-background",
    orange: "text-tag-orange-text bg-tag-orange-background"
  }[color];
  const colorMappingIcon = {
    default: "text-tag-default-icon",
    dark: "text-tag-dark-icon",
    red: "text-tag-red-icon",
    yellow: "text-tag-yellow-icon",
    green: "text-tag-green-icon",
    blue: "text-tag-blue-icon",
    pink: "text-tag-pink-icon",
    orange: "text-tag-orange-icon"
  }[color];
  return /* @__PURE__ */ jsxs7(
    "div",
    {
      ...restProps,
      className: clsx8(
        `flex-row-0 w-fit font-semibold`,
        colorMapping,
        !icon ? {
          "px-1 py-0.5": size === "sm",
          "px-2 py-1": size === "md",
          "px-4 py-2": size === "lg"
        } : {
          "p-0.5": size === "sm",
          "p-1": size === "md",
          "p-2": size === "lg"
        },
        {
          "rounded-md": variant === "normal",
          "rounded-full": variant === "fullyRounded"
        },
        className
      ),
      children: [
        children,
        trailingIcon && /* @__PURE__ */ jsx14("span", { className: colorMappingIcon, children: trailingIcon })
      ]
    }
  );
};

// src/hooks/useFloatingElement.ts
import { useCallback as useCallback8, useEffect as useEffect10, useState as useState11 } from "react";

// src/utils/math.ts
var clamp = (value, range = [0, 1]) => {
  const [min, max] = range;
  return Math.min(Math.max(value, min), max);
};

// src/hooks/useFloatingElement.ts
function calculatePosition({
  windowRect,
  containerRect,
  anchorRect,
  options
}) {
  const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
  const windowWidth = windowRect.width;
  const windowHeight = windowRect.height;
  const maxWidth = windowWidth - 2 * screenPadding;
  const maxHeight = windowHeight - 2 * screenPadding;
  const width = Math.min(containerRect.width, maxWidth);
  const height = Math.min(containerRect.height, maxHeight);
  const leftSuggestion = {
    beforeStart: anchorRect.left - width - gap,
    afterStart: anchorRect.left,
    center: anchorRect.left + anchorRect.width / 2 - width / 2,
    beforeEnd: anchorRect.right - width,
    afterEnd: anchorRect.right + gap
  }[horizontalAlignment];
  const topSuggestion = {
    beforeStart: anchorRect.top - height - gap,
    afterStart: anchorRect.top,
    center: anchorRect.top + anchorRect.height / 2 - height / 2,
    beforeEnd: anchorRect.bottom - height,
    afterEnd: anchorRect.bottom + gap
  }[verticalAlignment];
  const left = clamp(leftSuggestion, [
    screenPadding,
    windowWidth - screenPadding - width
  ]);
  const top = clamp(topSuggestion, [
    screenPadding,
    windowHeight - screenPadding - height
  ]);
  return {
    left,
    top,
    maxWidth,
    maxHeight
  };
}
function useFloatingElement({
  active = true,
  windowRef,
  anchorRef,
  containerRef,
  isPolling = false,
  pollingInterval = 100,
  verticalAlignment = "afterEnd",
  horizontalAlignment = "afterStart",
  screenPadding = 16,
  gap = 4
}) {
  const [style, setStyle] = useState11();
  const isMounted = useIsMounted();
  const calculate = useCallback8(() => {
    const containerRect = containerRef.current.getBoundingClientRect();
    const windowRect = windowRef?.current.getBoundingClientRect() ?? {
      top: 0,
      bottom: window.innerHeight,
      left: 0,
      right: window.innerWidth,
      width: window.innerWidth,
      height: window.innerHeight
    };
    const anchorElement = anchorRef?.current;
    if (anchorRef && !anchorElement) {
      console.warn("FloatingContainer anchor provided, but its value is undefined");
    }
    const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
    const calculateProps = {
      windowRect,
      anchorRect,
      containerRect,
      options: {
        horizontalAlignment,
        verticalAlignment,
        screenPadding,
        gap
      }
    };
    setStyle(calculatePosition(calculateProps));
  }, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
  const height = containerRef.current?.getBoundingClientRect().height;
  const width = containerRef.current?.getBoundingClientRect().width;
  useEffect10(() => {
    if (active && isMounted) {
      calculate();
    } else {
      setStyle(void 0);
    }
  }, [calculate, active, isMounted, height, width]);
  useEffect10(() => {
    window.addEventListener("resize", calculate);
    let timeout;
    if (isPolling) {
      timeout = setInterval(calculate, pollingInterval);
    }
    return () => {
      window.removeEventListener("resize", calculate);
      if (timeout) {
        clearInterval(timeout);
      }
    };
  }, [calculate, isPolling, pollingInterval]);
  return style;
}

// src/components/user-action/select/Select.tsx
import { createPortal } from "react-dom";
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
var defaultToggleOpenOptions = {
  highlightStartPositionBehavior: "first"
};
var SelectContext = createContext3(null);
function useSelectContext() {
  const ctx = useContext3(SelectContext);
  if (!ctx) {
    throw new Error("SelectContext must be used within a ListBoxPrimitive");
  }
  return ctx;
}
var SelectRoot = ({
  children,
  id,
  value,
  onValueChanged,
  values,
  onValuesChanged,
  isOpen = false,
  disabled = false,
  invalid = false,
  isMultiSelect = false,
  iconAppearance = "left"
}) => {
  const triggerRef = useRef8(null);
  const generatedId = useId4();
  const usedId = id ?? generatedId;
  const [internalState, setInternalState] = useState12({
    isOpen,
    options: []
  });
  const selectedValues = useMemo5(
    () => isMultiSelect ? values ?? [] : [value].filter(Boolean),
    [isMultiSelect, value, values]
  );
  const selectedOptions = useMemo5(
    () => selectedValues.map((value2) => internalState.options.find((option) => value2 === option.value)).filter(Boolean),
    [selectedValues, internalState.options]
  );
  const state = {
    ...internalState,
    id: usedId,
    disabled,
    invalid,
    value: selectedValues,
    selectedOptions
  };
  const config = {
    isMultiSelect,
    iconAppearance
  };
  const registerItem = useCallback9((item) => {
    setInternalState((prev) => {
      const updatedOptions = [...prev.options, item];
      updatedOptions.sort((a, b) => {
        const aEl = a.ref.current;
        const bEl = b.ref.current;
        if (!aEl || !bEl) return 0;
        return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
      });
      return {
        ...prev,
        options: updatedOptions
      };
    });
  }, []);
  const unregisterItem = useCallback9((value2) => {
    setInternalState((prev) => {
      const updatedOptions = prev.options.filter((i) => i.value !== value2);
      return {
        ...prev,
        options: updatedOptions
      };
    });
  }, []);
  const toggleSelection = (value2, isSelected) => {
    if (disabled) {
      return;
    }
    const option = state.options.find((i) => i.value === value2);
    if (!option) {
      console.error(`SelectOption with value: ${value2} not found`);
      return;
    }
    let newValue;
    if (isMultiSelect) {
      const isSelectedBefore = state.value.includes(value2);
      const isSelectedAfter = isSelected ?? !isSelectedBefore;
      if (!isSelectedAfter) {
        newValue = state.value.filter((v) => v !== value2);
      } else {
        newValue = [...state.value, value2];
      }
    } else {
      newValue = [value2];
    }
    if (!isMultiSelect) {
      onValueChanged?.(newValue[0]);
    } else {
      onValuesChanged?.(newValue);
    }
    setInternalState((prevState) => ({
      ...prevState,
      highlightedValue: value2
    }));
  };
  const highlightItem = (value2) => {
    if (disabled) {
      return;
    }
    setInternalState((prevState) => ({
      ...prevState,
      highlightedValue: value2
    }));
  };
  const registerTrigger = useCallback9((ref) => {
    triggerRef.current = ref.current;
  }, []);
  const unregisterTrigger = useCallback9(() => {
    triggerRef.current = null;
  }, []);
  const toggleOpen = (isOpen2, toggleOpenOptions) => {
    const { highlightStartPositionBehavior } = { ...defaultToggleOpenOptions, ...toggleOpenOptions };
    let firstSelectedValue;
    let firstEnabledValue;
    for (let i = 0; i < state.options.length; i++) {
      const currentOption = state.options[highlightStartPositionBehavior === "first" ? i : state.options.length - i - 1];
      if (!currentOption.disabled) {
        if (!firstEnabledValue) {
          firstEnabledValue = currentOption.value;
        }
        if (selectedValues.includes(currentOption.value)) {
          firstSelectedValue = currentOption.value;
          break;
        }
      }
    }
    setInternalState((prevState) => ({
      ...prevState,
      isOpen: isOpen2 ?? !prevState.isOpen,
      highlightedValue: firstSelectedValue ?? firstEnabledValue
    }));
  };
  const moveHighlightedIndex = (delta) => {
    let highlightedIndex = state.options.findIndex((value2) => value2.value === internalState.highlightedValue);
    if (highlightedIndex === -1) {
      highlightedIndex = 0;
    }
    const optionLength = state.options.length;
    const startIndex = (highlightedIndex + delta % optionLength + optionLength) % optionLength;
    const isForward = delta >= 0;
    let highlightedValue = state.options[startIndex].value;
    for (let i = 0; i < state.options.length; i++) {
      const index = (startIndex + (isForward ? i : -i) + optionLength) % optionLength;
      if (!state.options[index].disabled) {
        highlightedValue = state.options[index].value;
        break;
      }
    }
    setInternalState((prevState) => ({
      ...prevState,
      highlightedValue
    }));
  };
  useEffect11(() => {
    if (!internalState.highlightedValue) return;
    const highlighted = internalState.options.find((value2) => value2.value === internalState.highlightedValue);
    if (highlighted) {
      highlighted.ref.current?.scrollIntoView({ behavior: "instant", block: "nearest" });
    } else {
      console.error(`SelectRoot: Could not find highlighted value (${internalState.highlightedValue})`);
    }
  }, [internalState.highlightedValue]);
  const contextValue = {
    state,
    config,
    item: {
      register: registerItem,
      unregister: unregisterItem,
      toggleSelection,
      highlightItem,
      moveHighlightedIndex
    },
    trigger: {
      ref: triggerRef,
      register: registerTrigger,
      unregister: unregisterTrigger,
      toggleOpen
    }
  };
  return /* @__PURE__ */ jsx15(SelectContext.Provider, { value: contextValue, children });
};
var SelectOption = forwardRef7(
  function SelectOption2({ children, value, disabled = false, iconAppearance, className, ...restProps }, ref) {
    const { state, config, item, trigger } = useSelectContext();
    const { register, unregister, toggleSelection, highlightItem } = item;
    const itemRef = useRef8(null);
    iconAppearance ??= config.iconAppearance;
    const label = children ?? value;
    useEffect11(() => {
      register({
        value,
        label,
        disabled,
        ref: itemRef
      });
      return () => unregister(value);
    }, [value, disabled, register, unregister, children, label]);
    const isHighlighted = state.highlightedValue === value;
    const isSelected = state.value.includes(value);
    return /* @__PURE__ */ jsxs8(
      "li",
      {
        ...restProps,
        ref: (node) => {
          itemRef.current = node;
          if (typeof ref === "function") ref(node);
          else if (ref) ref.current = node;
        },
        id: value,
        role: "option",
        "aria-disabled": disabled,
        "aria-selected": isSelected,
        "data-highlighted": isHighlighted ? "" : void 0,
        "data-selected": isSelected ? "" : void 0,
        "data-disabled": disabled ? "" : void 0,
        className: clsx9(
          "flex-row-1 items-center px-2 py-1 rounded-md",
          "data-highlighted:bg-primary/20",
          "data-disabled:text-disabled data-disabled:cursor-not-allowed",
          "not-data-disabled:cursor-pointer",
          className
        ),
        onClick: (event) => {
          if (!disabled) {
            toggleSelection(value);
            if (!config.isMultiSelect) {
              trigger.toggleOpen(false);
            }
            restProps.onClick?.(event);
          }
        },
        onMouseEnter: (event) => {
          if (!disabled) {
            highlightItem(value);
            restProps.onMouseEnter?.(event);
          }
        },
        children: [
          iconAppearance === "left" && /* @__PURE__ */ jsx15(
            CheckIcon,
            {
              className: clsx9("w-4 h-4", { "opacity-0": !isSelected || disabled }),
              "aria-hidden": true
            }
          ),
          label,
          iconAppearance === "right" && /* @__PURE__ */ jsx15(
            CheckIcon,
            {
              className: clsx9("w-4 h-4", { "opacity-0": !isSelected || disabled }),
              "aria-hidden": true
            }
          )
        ]
      }
    );
  }
);
var defaultSelectButtonTranslation = {
  en: {
    clickToSelect: "Click to select"
  },
  de: {
    clickToSelect: "Zum ausw\xE4hlen dr\xFCcken"
  }
};
var SelectButton = forwardRef7(function SelectButton2({ placeholder, selectedDisplay, ...props }, ref) {
  const translation = useTranslation([defaultSelectButtonTranslation]);
  const { state, trigger } = useSelectContext();
  const { register, unregister, toggleOpen } = trigger;
  const innerRef = useRef8(null);
  useImperativeHandle2(ref, () => innerRef.current);
  useEffect11(() => {
    register(innerRef);
    return () => unregister();
  }, [register, unregister]);
  const disabled = !!props?.disabled || !!state.disabled;
  const invalid = state.invalid;
  const hasValue = state.value.length > 0;
  return /* @__PURE__ */ jsxs8(
    "button",
    {
      ...props,
      ref: innerRef,
      id: state.id,
      disabled,
      onClick: (event) => {
        props.onClick?.(event);
        toggleOpen(!state.isOpen);
      },
      onKeyDown: (event) => {
        props.onKeyDown?.(event);
        switch (event.key) {
          case "ArrowDown":
            toggleOpen(true, { highlightStartPositionBehavior: "first" });
            event.preventDefault();
            event.stopPropagation();
            break;
          case "ArrowUp":
            toggleOpen(true, { highlightStartPositionBehavior: "last" });
            event.preventDefault();
            event.stopPropagation();
            break;
        }
      },
      className: clsx9(
        "flex-row-2 items-center justify-between rounded-md px-3 py-2",
        {
          "bg-input-background text-placeholder": !hasValue && !disabled && !invalid,
          "bg-input-background text-input-text": hasValue && !disabled && !invalid,
          "bg-negative/20": !disabled && invalid,
          "text-placeholder": !hasValue && !disabled,
          "text-negative": hasValue && !disabled && invalid,
          "bg-disabled-background text-disabled": disabled
        },
        props.className
      ),
      "data-placeholder": !hasValue ? "" : void 0,
      "data-disabled": disabled ? "" : void 0,
      "data-invalid": invalid ? "" : void 0,
      "aria-invalid": invalid,
      "aria-disabled": disabled,
      "aria-haspopup": "listbox",
      "aria-expanded": state.isOpen,
      "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
      children: [
        hasValue ? selectedDisplay?.(state.value) ?? /* @__PURE__ */ jsx15("div", { className: clsx9("flex flex-wrap gap-x-1 gap-y-2"), children: state.selectedOptions.map(({ value, label }, index) => /* @__PURE__ */ jsxs8("span", { className: "flex-row-0", children: [
          label,
          index < state.value.length - 1 && /* @__PURE__ */ jsx15("span", { children: "," })
        ] }, value)) }) : placeholder ?? translation("clickToSelect"),
        /* @__PURE__ */ jsx15(
          ExpansionIcon,
          {
            isExpanded: state.isOpen,
            className: clsx9({
              "text-input-text": !disabled && !invalid,
              "text-negative": !disabled && invalid,
              "text-disabled": disabled
            })
          }
        )
      ]
    }
  );
});
var SelectChipDisplay = forwardRef7(function SelectChipDisplay2({ ...props }, ref) {
  const { state, trigger, item } = useSelectContext();
  const { register, unregister, toggleOpen } = trigger;
  const innerRef = useRef8(null);
  useImperativeHandle2(ref, () => innerRef.current);
  useEffect11(() => {
    register(innerRef);
    return () => unregister();
  }, [register, unregister]);
  const disabled = !!props?.disabled || !!state.disabled;
  const invalid = state.invalid;
  return /* @__PURE__ */ jsxs8(
    "div",
    {
      ...props,
      ref: innerRef,
      className: clsx9(
        "flex flex-wrap flex-row gap-2 items-center bg-input-background text-input-text rounded-md px-2.5 py-2.5",
        props.className
      ),
      "data-disabled": disabled ? "" : void 0,
      "data-invalid": invalid ? "" : void 0,
      "aria-invalid": invalid,
      "aria-disabled": disabled,
      children: [
        state.selectedOptions.map(({ value, label }) => /* @__PURE__ */ jsxs8(Chip, { className: "gap-x-2", children: [
          label,
          /* @__PURE__ */ jsx15(
            TextButton,
            {
              onClick: () => {
                item.toggleSelection(value, false);
              },
              size: "none",
              color: "negative",
              className: "flex-row-0 items-center px-0.5 py-0.5 w-6 h-6 rounded",
              children: /* @__PURE__ */ jsx15(XIcon, { className: "w-5 h-5" })
            }
          )
        ] }, value)),
        /* @__PURE__ */ jsx15(
          IconButton,
          {
            id: state.id,
            onClick: () => toggleOpen(),
            onKeyDown: (event) => {
              switch (event.key) {
                case "ArrowDown":
                  toggleOpen(true, { highlightStartPositionBehavior: "first" });
                  break;
                case "ArrowUp":
                  toggleOpen(true, { highlightStartPositionBehavior: "last" });
              }
            },
            size: "small",
            color: "neutral",
            "aria-invalid": invalid,
            "aria-disabled": disabled,
            "aria-haspopup": "listbox",
            "aria-expanded": state.isOpen,
            "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
            children: /* @__PURE__ */ jsx15(Plus, {})
          }
        )
      ]
    }
  );
});
var SelectContent = forwardRef7(
  function SelectContent2({
    alignment,
    orientation = "vertical",
    containerClassName,
    ...props
  }, ref) {
    const innerRef = useRef8(null);
    useImperativeHandle2(ref, () => innerRef.current);
    const { trigger, state, config, item } = useSelectContext();
    const position = useFloatingElement({
      active: state.isOpen,
      anchorRef: trigger.ref,
      containerRef: innerRef,
      ...alignment
    });
    useFocusTrap({
      container: innerRef,
      active: state.isOpen && !!position
    });
    return createPortal(
      /* @__PURE__ */ jsxs8(
        "div",
        {
          id: `select-container-${state.id}`,
          className: clsx9("fixed inset-0 w-screen h-screen", containerClassName),
          hidden: !state.isOpen,
          children: [
            /* @__PURE__ */ jsx15(
              "div",
              {
                id: `select-background-${state.id}`,
                onClick: () => trigger.toggleOpen(false),
                className: clsx9("fixed inset-0 w-screen h-screen")
              }
            ),
            /* @__PURE__ */ jsx15(
              "ul",
              {
                ...props,
                id: `${state.id}-listbox`,
                ref: innerRef,
                onKeyDown: (event) => {
                  switch (event.key) {
                    case "Escape":
                      trigger.toggleOpen(false);
                      event.preventDefault();
                      event.stopPropagation();
                      break;
                    case match(orientation, {
                      vertical: "ArrowDown",
                      horizontal: "ArrowUp"
                    }):
                      item.moveHighlightedIndex(1);
                      event.preventDefault();
                      break;
                    case match(orientation, {
                      vertical: "ArrowUp",
                      horizontal: "ArrowDown"
                    }):
                      item.moveHighlightedIndex(-1);
                      event.preventDefault();
                      break;
                    case "Home":
                      event.preventDefault();
                      break;
                    case "End":
                      event.preventDefault();
                      break;
                    case "Enter":
                    // Fall through
                    case " ":
                      if (state.highlightedValue) {
                        item.toggleSelection(state.highlightedValue);
                        if (!config.isMultiSelect) {
                          trigger.toggleOpen(false);
                        }
                        event.preventDefault();
                      }
                      break;
                  }
                },
                className: clsx9("flex-col-0 p-2 bg-menu-background text-menu-text rounded-md shadow-hw-bottom focus-style-within overflow-auto", props.className),
                style: {
                  opacity: position ? void 0 : 0,
                  position: "fixed",
                  ...position
                },
                role: "listbox",
                "aria-multiselectable": config.isMultiSelect,
                "aria-orientation": orientation,
                tabIndex: position ? 0 : void 0,
                children: props.children
              }
            )
          ]
        }
      ),
      document.body
    );
  }
);
var Select = forwardRef7(function Select2({
  children,
  contentPanelProps,
  buttonProps,
  ...props
}, ref) {
  return /* @__PURE__ */ jsxs8(SelectRoot, { ...props, isMultiSelect: false, children: [
    /* @__PURE__ */ jsx15(
      SelectButton,
      {
        ref,
        ...buttonProps,
        selectedDisplay: (values) => {
          const value = values[0];
          if (!buttonProps?.selectedDisplay) return void 0;
          return buttonProps.selectedDisplay(value);
        }
      }
    ),
    /* @__PURE__ */ jsx15(SelectContent, { ...contentPanelProps, children })
  ] });
});
var SelectUncontrolled = forwardRef7(function SelectUncontrolled2({
  value: initialValue,
  onValueChanged,
  ...props
}, ref) {
  const [value, setValue] = useOverwritableState(initialValue, onValueChanged);
  return /* @__PURE__ */ jsx15(
    Select,
    {
      ...props,
      ref,
      value,
      onValueChanged: setValue
    }
  );
});
var MultiSelect = forwardRef7(function MultiSelect2({
  children,
  contentPanelProps,
  buttonProps,
  ...props
}, ref) {
  return /* @__PURE__ */ jsxs8(SelectRoot, { ...props, isMultiSelect: true, children: [
    /* @__PURE__ */ jsx15(SelectButton, { ref, ...buttonProps }),
    /* @__PURE__ */ jsx15(SelectContent, { ...contentPanelProps, children })
  ] });
});
var MultiSelectUncontrolled = forwardRef7(function MultiSelectUncontrolled2({
  values: initialValues,
  onValuesChanged,
  ...props
}, ref) {
  const [values, setValues] = useOverwritableState(initialValues, onValuesChanged);
  return /* @__PURE__ */ jsx15(
    MultiSelect,
    {
      ...props,
      ref,
      values,
      onValuesChanged: setValues
    }
  );
});
var MultiSelectChipDisplay = forwardRef7(function MultiSelectChipDisplay2({
  children,
  contentPanelProps,
  chipDisplayProps,
  ...props
}, ref) {
  return /* @__PURE__ */ jsxs8(SelectRoot, { ...props, isMultiSelect: true, children: [
    /* @__PURE__ */ jsx15(SelectChipDisplay, { ref, ...chipDisplayProps }),
    /* @__PURE__ */ jsx15(SelectContent, { ...contentPanelProps, children })
  ] });
});
var MultiSelectChipDisplayUncontrolled = forwardRef7(function MultiSelectChipDisplayUncontrolled2({
  values: initialValues,
  onValuesChanged,
  ...props
}, ref) {
  const [values, setValues] = useOverwritableState(initialValues, onValuesChanged);
  return /* @__PURE__ */ jsx15(
    MultiSelectChipDisplay,
    {
      ...props,
      ref,
      values,
      onValuesChanged: setValues
    }
  );
});

// src/components/properties/MultiSelectProperty.tsx
import { jsx as jsx16 } from "react/jsx-runtime";
var MultiSelectProperty = ({
  children,
  values,
  onValuesChanged,
  ...props
}) => {
  const hasValue = values.length > 0;
  return /* @__PURE__ */ jsx16(
    PropertyBase,
    {
      ...props,
      hasValue,
      icon: /* @__PURE__ */ jsx16(List, { size: 24 }),
      input: ({ softRequired }) => /* @__PURE__ */ jsx16(
        MultiSelectChipDisplay,
        {
          values,
          onValuesChanged,
          disabled: props.readOnly,
          contentPanelProps: {
            className: clsx10(
              "!border-none !min-h-10"
            )
          },
          chipDisplayProps: {
            className: clsx10({
              "!bg-warning !text-surface-warning": softRequired && !hasValue
            })
          },
          children
        }
      )
    }
  );
};

// src/components/properties/NumberProperty.tsx
import { Binary } from "lucide-react";
import clsx11 from "clsx";
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
var defaultNumberPropertyTranslation = {
  en: {
    value: "Value"
  },
  de: {
    value: "Wert"
  }
};
var NumberProperty = ({
  overwriteTranslation,
  value,
  onChange,
  onRemove,
  onEditComplete,
  readOnly,
  suffix,
  ...baseProps
}) => {
  const translation = useTranslation([defaultNumberPropertyTranslation], overwriteTranslation);
  const hasValue = value !== void 0;
  return /* @__PURE__ */ jsx17(
    PropertyBase,
    {
      ...baseProps,
      onRemove,
      hasValue,
      icon: /* @__PURE__ */ jsx17(Binary, { size: 24 }),
      input: ({ softRequired }) => /* @__PURE__ */ jsxs9(
        "div",
        {
          className: clsx11("flex-row-2 grow", { "text-warning": softRequired && !hasValue }),
          children: [
            /* @__PURE__ */ jsx17(
              Input,
              {
                className: clsx11("!ring-0 !border-0 !outline-0 !p-0 !m-0 !w-fit !shadow-none !rounded-none", { "bg-surface-warning placeholder-warning": softRequired && !hasValue }),
                value: value?.toString() ?? "",
                type: "number",
                readOnly,
                placeholder: `${translation("value")}...`,
                onChangeText: (value2) => {
                  const numberValue = parseFloat(value2);
                  if (isNaN(numberValue)) {
                    onRemove();
                  } else {
                    onChange?.(numberValue);
                  }
                },
                onEditCompleted: (value2) => {
                  const numberValue = parseFloat(value2);
                  if (isNaN(numberValue)) {
                    onRemove();
                  } else {
                    onEditComplete(numberValue);
                  }
                }
              }
            ),
            suffix && /* @__PURE__ */ jsx17("span", { className: clsx11("ml-1", { "bg-surface-warning": softRequired && !hasValue }), children: suffix })
          ]
        }
      )
    }
  );
};

// src/components/properties/SelectProperty.tsx
import { List as List2 } from "lucide-react";
import clsx12 from "clsx";
import { jsx as jsx18 } from "react/jsx-runtime";
var SingleSelectProperty = ({
  children,
  value,
  onValueChanged,
  selectedDisplay,
  ...props
}) => {
  const hasValue = value !== void 0;
  return /* @__PURE__ */ jsx18(
    PropertyBase,
    {
      ...props,
      hasValue,
      icon: /* @__PURE__ */ jsx18(List2, { size: 24 }),
      input: ({ softRequired }) => /* @__PURE__ */ jsx18(
        Select,
        {
          value,
          onValueChanged,
          disabled: props.readOnly,
          buttonProps: {
            className: clsx12(
              "border-none w-full",
              {
                "!bg-warning !text-surface-warning": softRequired && !hasValue
              }
            ),
            selectedDisplay
          },
          children
        }
      )
    }
  );
};

// src/components/properties/TextProperty.tsx
import { Text } from "lucide-react";
import clsx14 from "clsx";

// src/components/user-action/Textarea.tsx
import { forwardRef as forwardRef8, useId as useId5 } from "react";
import clsx13 from "clsx";
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
var Textarea = forwardRef8(function Textarea2({
  id,
  onChange,
  onChangeText,
  onBlur,
  onEditCompleted,
  saveDelayOptions,
  defaultStyle = true,
  invalid = false,
  disabled = false,
  className,
  ...props
}, ref) {
  const { restartTimer, clearTimer } = useDelay(saveDelayOptions);
  const onEditCompletedWrapper = (text) => {
    onEditCompleted?.(text);
    clearTimer();
  };
  return /* @__PURE__ */ jsx19(
    "textarea",
    {
      ref,
      id,
      className: clsx13(
        "resize-none w-full h-32 overflow-y-scroll",
        "py-2 px-3 rounded-md border-2 border-transparent focus-style-none",
        {
          "bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
          "bg-negative/20 text-negative hover:border-negative focus-visible:border-negative": invalid && !disabled && defaultStyle,
          "text-disabled bg-disabled-background border-disabled-border": disabled && defaultStyle
        },
        className
      ),
      onChange: (event) => {
        const value = event.target.value;
        restartTimer(() => {
          onEditCompletedWrapper(value);
        });
        onChange?.(event);
        onChangeText?.(value);
      },
      onBlur: (event) => {
        onBlur?.(event);
        onEditCompletedWrapper(event.target.value);
      },
      disabled,
      ...props
    }
  );
});

// src/components/properties/TextProperty.tsx
import { jsx as jsx20 } from "react/jsx-runtime";
var defaultTextPropertyTranslation = {
  en: {
    text: "Text"
  },
  de: {
    text: "Text"
  }
};
var TextProperty = ({
  overwriteTranslation,
  value,
  readOnly,
  onChange,
  onRemove,
  onEditComplete,
  ...baseProps
}) => {
  const translation = useTranslation([defaultTextPropertyTranslation], overwriteTranslation);
  const hasValue = value !== void 0;
  return /* @__PURE__ */ jsx20(
    PropertyBase,
    {
      ...baseProps,
      onRemove,
      hasValue,
      icon: /* @__PURE__ */ jsx20(Text, { size: 24 }),
      input: ({ softRequired }) => /* @__PURE__ */ jsx20(
        Textarea,
        {
          className: clsx14({
            "bg-surface-warning placeholder-warning": softRequired && !hasValue
          }),
          rows: 5,
          defaultStyle: false,
          value: value ?? "",
          readOnly,
          placeholder: `${translation("text")}...`,
          onChangeText: (value2) => {
            if (!value2) {
              onRemove?.();
            } else {
              onChange?.(value2);
            }
          },
          onEditCompleted: (value2) => {
            if (!value2) {
              onRemove?.();
            } else {
              onEditComplete?.(value2);
            }
          }
        }
      )
    }
  );
};
export {
  CheckboxProperty,
  DateProperty,
  MultiSelectProperty,
  NumberProperty,
  PropertyBase,
  SingleSelectProperty,
  TextProperty
};
//# sourceMappingURL=index.mjs.map