import { i as CollectionStoreOptions, n as CollectionStoreFunctions, o as CollectionStoreState, r as CollectionStoreItem } from "./collection-store-pWfIj1Gh.js";
import { Store, StoreOptions, StoreProps } from "@ariakit/store";
import { SetState } from "@ariakit/utils";
//#region src/composite/composite-store.d.ts
type Orientation = "horizontal" | "vertical" | "both";
interface NextOptions extends Pick<Partial<CompositeStoreState>, "activeId" | "focusShift" | "focusLoop" | "focusWrap" | "compositeElementInFocusOrder" | "includesBaseElement" | "renderedItems" | "rtl"> {
  /**
   * The number of items to skip.
   */
  skip?: number;
}
declare const NULL_ITEM: {
  id: string;
};
/**
 * Finds the first enabled item.
 */
declare function findFirstEnabledItem(items: CompositeStoreItem[], excludeId?: string): CompositeStoreItem | undefined;
/**
 * Moves all the items before the passed `id` to the end of the array. This is
 * useful when we want to loop through the items in the same row or column as
 * the first items will be placed after the last items.
 *
 * The null item that's inserted when `shouldInsertNullItem` is set to `true`
 * represents the composite container itself. When the active item is null, the
 * composite container has focus.
 */
declare function flipItems(items: CompositeStoreItem[], activeId: string, shouldInsertNullItem?: boolean): CompositeStoreItem[];
/**
 * Creates a two-dimensional array with items grouped by their rowId's.
 */
declare function groupItemsByRows(items: CompositeStoreItem[]): CompositeStoreItem[][];
/**
 * Creates a composite store.
 */
declare function createCompositeStore<T extends CompositeStoreItem = CompositeStoreItem>(props?: CompositeStoreProps<T>): CompositeStore<T>;
type CompositeStoreOrientation = Orientation;
interface CompositeStoreItem extends CollectionStoreItem {
  /**
   * The row id of the item. This is only used on two-dimensional composite
   * widgets (when using
   * [`CompositeRow`](https://ariakit.com/reference/composite-row)).
   */
  rowId?: string;
  /**
   * If enabled, the item will be disabled and users won't be able to focus on
   * it using arrow keys.
   */
  disabled?: boolean;
  /**
   * The item children. This can be used for typeahead purposes.
   */
  children?: string;
  /**
   * The text used by typeahead to match this item.
   */
  typeaheadText?: string;
}
interface CompositeStoreState<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreState<T> {
  /**
   * The ID of the composite store is used to reference elements within the
   * composite widget before hydration. If not provided, a random ID will be
   * generated.
   */
  id: string;
  /**
   * The composite element itself. Typically, it's the wrapper element that
   * contains composite items. However, in a combobox, it's the input element.
   *
   * Live examples:
   * - [Sliding Menu](https://ariakit.com/examples/menu-slide)
   */
  compositeElement: HTMLElement | null;
  /**
   * The composite element itself.
   *
   * @deprecated Use `compositeElement` instead.
   */
  baseElement: HTMLElement | null;
  /**
   * If enabled, the composite element will act as an
   * [aria-activedescendant](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_activedescendant)
   * container instead of [roving
   * tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex).
   * DOM focus will remain on the composite element while its items receive
   * virtual focus.
   *
   * In both scenarios, the item in focus will carry the
   * [`data-active-item`](https://ariakit.com/guide/styling#data-active-item)
   * attribute.
   *
   * Live examples:
   * - [Select with Combobox and
   *   Tabs](https://ariakit.com/examples/select-combobox-tab)
   * @default false
   */
  virtualFocus: boolean;
  /**
   * Defines the orientation of the composite widget. If the composite has a
   * single row or column (one-dimensional), the `orientation` value determines
   * which arrow keys can be used to move focus:
   * - `both`: all arrow keys work.
   * - `horizontal`: only left and right arrow keys work.
   * - `vertical`: only up and down arrow keys work.
   *
   * It doesn't have any effect on two-dimensional composites.
   * @default "both"
   */
  orientation: Orientation;
  /**
   * Determines how the
   * [`next`](https://ariakit.com/reference/use-composite-store#next) and
   * [`previous`](https://ariakit.com/reference/use-composite-store#previous)
   * functions will behave. If `rtl` is set to `true`, they will be inverted.
   *
   * This only affects the composite widget behavior. You still need to set
   * `dir="rtl"` on HTML/CSS.
   * @default false
   */
  rtl: boolean;
  /**
   * Determines how the focus behaves when the user reaches the end of the
   * composite widget.
   *
   * On one-dimensional composite widgets:
   * - `true` loops from the last item to the first item and vice-versa.
   * - `horizontal` loops only if
   *   [`orientation`](https://ariakit.com/reference/composite-provider#orientation)
   *   is `horizontal` or not set.
   * - `vertical` loops only if
   *   [`orientation`](https://ariakit.com/reference/composite-provider#orientation)
   *   is `vertical` or not set.
   * - If
   *   [`compositeElementInFocusOrder`](https://ariakit.com/reference/composite-provider#compositeelementinfocusorder)
   *   is set to `true` (or
   *   [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   *   is initially set to `null`), the composite element will be focused in
   *   between the last and first items.
   *
   * On two-dimensional composite widgets (when using
   * [`CompositeRow`](https://ariakit.com/reference/composite-row) or explicitly
   * passing a [`rowId`](https://ariakit.com/reference/composite-item#rowid)
   * prop to composite items):
   * - `true` loops from the last row/column item to the first item in the same
   *   row/column and vice-versa. If it's the last item in the last row, it
   *   moves to the first item in the first row and vice-versa.
   * - `horizontal` loops only from the last row item to the first item in the
   *   same row.
   * - `vertical` loops only from the last column item to the first item in the
   *   column row.
   * - If
   *   [`compositeElementInFocusOrder`](https://ariakit.com/reference/composite-provider#compositeelementinfocusorder)
   *   is set to `true` (or
   *   [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   *   is initially set to `null`), vertical loop will have no effect as moving
   *   down from the last row or up from the first row will focus on the
   *   composite element.
   * - If
   *   [`focusWrap`](https://ariakit.com/reference/composite-provider#focuswrap)
   *   matches the value of `focusLoop`, it'll wrap between the last item in the
   *   last row or column and the first item in the first row or column and
   *   vice-versa.
   *
   * Live examples:
   * - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)
   * - [Command Menu with
   *   Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
   * @default false
   */
  focusLoop: boolean | Orientation;
  /**
   * **Works only on two-dimensional composite widgets**.
   *
   * If enabled, moving to the next item from the last one in a row or column
   * will focus on the first item in the next row or column and vice-versa.
   * - `true` wraps between rows and columns.
   * - `horizontal` wraps only between rows.
   * - `vertical` wraps only between columns.
   * - If
   *   [`focusLoop`](https://ariakit.com/reference/composite-provider#focusloop)
   *   matches the value of `focusWrap`, it'll wrap between the last item in the
   *   last row or column and the first item in the first row or column and
   *   vice-versa.
   *
   * Live examples:
   * - [Command Menu with
   *   Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
   * @default false
   */
  focusWrap: boolean | Orientation;
  /**
   * **Works only on two-dimensional composite widgets**.
   *
   * If enabled, moving up or down when there's no next item or when the next
   * item is disabled will shift to the item right before it.
   *
   * Live examples:
   * - [Command Menu with
   *   Tabs](https://ariakit.com/examples/dialog-combobox-tab-command-menu)
   * @default false
   */
  focusShift: boolean;
  /**
   * The number of times the
   * [`move`](https://ariakit.com/reference/use-composite-store#move) function
   * has been called.
   */
  moves: number;
  /**
   * Indicates if the composite element (the one with a [composite
   * role](https://w3c.github.io/aria/#composite)) should be part of the focus
   * order when navigating with arrow keys. In other words, moving to the
   * previous element when the first item is in focus will focus on the
   * composite element itself. The same applies to the last item when moving to
   * the next element.
   *
   * Live examples:
   * - [Submenu with
   *   Combobox](https://ariakit.com/examples/menu-nested-combobox)
   * - [Command Menu](https://ariakit.com/examples/dialog-combobox-command-menu)
   * @default false
   */
  compositeElementInFocusOrder: boolean;
  /**
   * Whether the composite element is in the arrow-key focus order.
   *
   * @deprecated Use
   * [`compositeElementInFocusOrder`](https://ariakit.com/reference/composite-provider#compositeelementinfocusorder)
   * instead.
   */
  includesBaseElement: boolean;
  /**
   * The current active item `id`. The active item is the element within the
   * composite widget that has either DOM or virtual focus (in case
   * [`virtualFocus`](https://ariakit.com/reference/composite-provider#virtualfocus)
   * is enabled).
   * - `null` represents the composite element (the one with a [composite
   *   role](https://w3c.github.io/aria/#composite)). Users will be able to
   *   navigate out of it using arrow keys.
   * - If `activeId` is initially set to `null`, the
   *   [`compositeElementInFocusOrder`](https://ariakit.com/reference/composite-provider#compositeelementinfocusorder)
   *   prop will also default to `true`, which means the composite element
   *   itself will have focus and users will be able to navigate to it using
   *   arrow keys.
   *
   * Live examples:
   * - [Combobox with Tabs](https://ariakit.com/examples/combobox-tabs)
   */
  activeId: string | null | undefined;
}
interface CompositeStoreFunctions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreFunctions<T> {
  /**
   * Sets the `compositeElement` state.
   */
  setCompositeElement: SetState<CompositeStoreState<T>["compositeElement"]>;
  /**
   * Sets the composite element state.
   *
   * @deprecated Use
   * [`setCompositeElement`](https://ariakit.com/reference/use-composite-store#setcompositeelement)
   * instead.
   */
  setBaseElement: SetState<CompositeStoreState<T>["baseElement"]>;
  /**
   * Sets the
   * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   * state _without moving focus_. If you want to move focus, use the
   * [`move`](https://ariakit.com/reference/use-composite-store#move) function
   * instead.
   * @example
   * // Sets the composite element as the active item
   * store.setActiveId(null);
   * // Sets the item with id "item-1" as the active item
   * store.setActiveId("item-1");
   * // Sets the next item as the active item
   * store.setActiveId(store.next());
   */
  setActiveId: SetState<CompositeStoreState<T>["activeId"]>;
  /**
   * Moves focus to a given item id and sets it as the active item.
   * - Passing `null` will focus on the composite element itself (the one with a
   *   [composite role](https://w3c.github.io/aria/#composite)). Users will be
   *   able to navigate out of it using arrow keys.
   * - If you want to set the active item id _without moving focus_, use the
   *   [`setActiveId`](https://ariakit.com/reference/use-composite-store#setactiveid)
   *   function instead.
   *
   * Live examples:
   * - [Select Grid](https://ariakit.com/examples/select-grid)
   * @example
   * // Moves focus to the composite element
   * store.move(null);
   * // Moves focus to the item with id "item-1"
   * store.move("item-1");
   * // Moves focus to the next item
   * store.move(store.next());
   */
  move: (id?: string | null) => void;
  /**
   * Returns the id of the next enabled item based on the current
   * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   * state. You can pass additional options to override the current state.
   * @example
   * const nextId = store.next();
   */
  next: {
    (options?: NextOptions): string | null | undefined;
    /**
     * @deprecated Use the object syntax instead: `next({ skip: 2 })`.
     */
    (skip?: number): string | null | undefined;
  };
  /**
   * Returns the id of the previous enabled item based on the current
   * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   * state. You can pass additional options to override the current state.
   * @example
   * const previousId = store.previous();
   */
  previous: {
    (options?: NextOptions): string | null | undefined;
    /**
     * @deprecated Use the object syntax instead: `previous({ skip: 2 })`.
     */
    (skip?: number): string | null | undefined;
  };
  /**
   * Returns the id of the enabled item above based on the current
   * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   * state. You can pass additional options to override the current state.
   * @example
   * const upId = store.up();
   */
  up: {
    (options?: NextOptions): string | null | undefined;
    /**
     * @deprecated Use the object syntax instead: `up({ skip: 2 })`.
     */
    (skip?: number): string | null | undefined;
  };
  /**
   * Returns the id of the enabled item below based on the current
   * [`activeId`](https://ariakit.com/reference/composite-provider#activeid)
   * state. You can pass additional options to override the current state.
   * @example
   * const downId = store.down();
   */
  down: {
    (options?: NextOptions): string | null | undefined;
    /**
     * @deprecated Use the object syntax instead: `down({ skip: 2 })`.
     */
    (skip?: number): string | null | undefined;
  };
  /**
   * Returns the id of the first enabled item.
   */
  first: () => string | null | undefined;
  /**
   * Returns the id of the last enabled item.
   */
  last: () => string | null | undefined;
}
interface CompositeStoreOptions<T extends CompositeStoreItem = CompositeStoreItem> extends CollectionStoreOptions<T>, StoreOptions<CompositeStoreState<T>, "id" | "virtualFocus" | "orientation" | "rtl" | "focusLoop" | "focusWrap" | "focusShift" | "compositeElementInFocusOrder" | "includesBaseElement" | "activeId"> {
  /**
   * The composite item id that should be active by default when the composite
   * widget is rendered. If `null`, the composite element itself will have focus
   * and users will be able to navigate to it using arrow keys. If `undefined`,
   * the first enabled item will be focused.
   */
  defaultActiveId?: CompositeStoreState<T>["activeId"];
}
interface CompositeStoreProps<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreOptions<T>, StoreProps<CompositeStoreState<T>> {}
interface CompositeStore<T extends CompositeStoreItem = CompositeStoreItem> extends CompositeStoreFunctions<T>, Store<CompositeStoreState<T>> {}
//#endregion
export { CompositeStoreOrientation as a, NULL_ITEM as c, flipItems as d, groupItemsByRows as f, CompositeStoreOptions as i, createCompositeStore as l, CompositeStoreFunctions as n, CompositeStoreProps as o, CompositeStoreItem as r, CompositeStoreState as s, CompositeStore as t, findFirstEnabledItem as u };
//# sourceMappingURL=composite-store-C5m2qUBo.d.ts.map