{"version":3,"file":"chunk-Tour.mjs","names":["useTour","useTourPrimitive","TourPrimitive"],"sources":["../../src/components/Tour/Tour.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { Portal } from '@ark-ui/react/portal';\nimport {\n  Tour as TourPrimitive,\n  type TourStepDetails,\n  type UseTourProps,\n  type UseTourReturn,\n  useTourContext,\n  useTour as useTourPrimitive,\n} from '@ark-ui/react/tour';\nimport React, { type ComponentPropsWithoutRef, type ReactNode, type RefObject, forwardRef } from 'react';\nimport { useTranslation } from 'react-i18next';\n\nimport { mx } from '@dxos/ui-theme';\nimport { type ThemedClassName } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\n\nimport { recipes } from '../../recipes.ts';\nimport { type Size } from '../../sizes.ts';\nimport { Button, type ButtonProps } from '../Button/Button.tsx';\n\n/**\n * Creates the machine, which owns the steps, waits for each target, scrolls it into view, places the card beside it\n * (or centres it, for a `dialog` step), cuts it out of the backdrop and traps focus. The spotlight sits on the target's\n * own rect (zag pads it by 10px), so its inset ring paints over the target's border.\n */\nconst useTour = (props?: UseTourProps): UseTourReturn =>\n  useTourPrimitive({ spotlightOffset: { x: 0, y: 0 }, ...props });\n\ntype TourStepPlacement = NonNullable<TourStepDetails['placement']>;\n\ntype TourStepAction = NonNullable<TourStepDetails['actions']>[number];\n\n//\n// Root\n//\n\ntype TourRootProps = TourPrimitive.RootProps;\n\n/** Provides the machine from `useTour` to the parts; renders no element. The card mounts only while the tour runs. */\nconst TourRoot = ({ lazyMount = true, unmountOnExit = true, ...props }: TourRootProps) => (\n  <TourPrimitive.Root {...props} lazyMount={lazyMount} unmountOnExit={unmountOnExit} />\n);\n\nTourRoot.displayName = 'Tour.Root';\n\n//\n// Content\n//\n\ntype TourContentProps = ThemedClassName<TourPrimitive.ContentProps> & {\n  /** The card's size; it has no sized trigger to inherit one from. */\n  size?: Size;\n  /** Portals into this element instead of the body. */\n  container?: RefObject<HTMLElement | null>;\n};\n\n/**\n * The card, an `alertdialog` at `level='popup'` named by its Title and described by its Description. It brings the\n * backdrop (shown for a step with `backdrop`), the spotlight over the target and the arrow (for a step with `arrow`),\n * all portalled, since the machine places them against the document.\n */\nconst TourContent = forwardRef<HTMLDivElement, TourContentProps>(\n  ({ classNames, size = 'md', container, children, ...props }, forwardedRef) => (\n    <Portal container={container}>\n      <TourPrimitive.Backdrop className={recipes.tourBackdrop()} />\n      <TourPrimitive.Spotlight className={recipes.tourSpotlight()} />\n      <TourPrimitive.Positioner className={recipes.tourPositioner()}>\n        <TourPrimitive.Content\n          {...props}\n          data-surface='popup'\n          data-size={size}\n          className={mx(recipes.popup(), recipes.tourContent(), classNames)}\n          ref={forwardedRef}\n        >\n          {children}\n          <TourPrimitive.Arrow className={recipes.arrow()}>\n            <TourPrimitive.ArrowTip className={recipes.arrowTip()} />\n          </TourPrimitive.Arrow>\n        </TourPrimitive.Content>\n      </TourPrimitive.Positioner>\n    </Portal>\n  ),\n);\n\nTourContent.displayName = 'Tour.Content';\n\n//\n// Header\n//\n\ntype TourHeaderProps = ThemedClassName<ComponentPropsWithoutRef<'div'>>;\n\n/** A block row holding the Title and an optional trailing CloseTrigger. */\nconst TourHeader = forwardRef<HTMLDivElement, TourHeaderProps>(({ classNames, ...props }, forwardedRef) => (\n  <div\n    {...props}\n    data-scope='tour'\n    data-part='header'\n    className={mx(recipes.tourHeader(), classNames)}\n    ref={forwardedRef}\n  />\n));\n\nTourHeader.displayName = 'Tour.Header';\n\n//\n// Title\n//\n\ntype TourTitleProps = ThemedClassName<TourPrimitive.TitleProps>;\n\n/** The step's `title` by default. */\nconst TourTitle = forwardRef<HTMLHeadingElement, TourTitleProps>(({ classNames, ...props }, forwardedRef) => (\n  <TourPrimitive.Title {...props} className={mx(recipes.tourTitle(), classNames)} ref={forwardedRef} />\n));\n\nTourTitle.displayName = 'Tour.Title';\n\n//\n// Description\n//\n\ntype TourDescriptionProps = ThemedClassName<TourPrimitive.DescriptionProps>;\n\n/** The step's `description` by default. */\nconst TourDescription = forwardRef<HTMLParagraphElement, TourDescriptionProps>(\n  ({ classNames, ...props }, forwardedRef) => (\n    <TourPrimitive.Description {...props} className={mx(recipes.tourDescription(), classNames)} ref={forwardedRef} />\n  ),\n);\n\nTourDescription.displayName = 'Tour.Description';\n\n//\n// ProgressText\n//\n\ntype TourProgressTextProps = ThemedClassName<TourPrimitive.ProgressTextProps>;\n\n/** \"1 of 4\" by default, from the machine's translations; children replace it. */\nconst TourProgressText = forwardRef<HTMLDivElement, TourProgressTextProps>(({ classNames, ...props }, forwardedRef) => (\n  <TourPrimitive.ProgressText {...props} className={mx(recipes.tourProgressText(), classNames)} ref={forwardedRef} />\n));\n\nTourProgressText.displayName = 'Tour.ProgressText';\n\n//\n// Control\n//\n\ntype TourControlProps = ThemedClassName<TourPrimitive.ControlProps>;\n\n/** The block row the progress and actions sit in, pushed apart. */\nconst TourControl = forwardRef<HTMLDivElement, TourControlProps>(({ classNames, ...props }, forwardedRef) => (\n  <TourPrimitive.Control {...props} className={mx(recipes.tourControl(), classNames)} ref={forwardedRef} />\n));\n\nTourControl.displayName = 'Tour.Control';\n\n//\n// Actions\n//\n\ntype TourActionsProps = TourPrimitive.ActionsProps;\n\n/** Render prop over the current step's `actions`. */\nconst TourActions = TourPrimitive.Actions;\n\n//\n// ActionTrigger\n//\n\ntype TourActionTriggerProps = Omit<ButtonProps, 'label'> & {\n  action: TourStepAction;\n  /** Defaults to the action's `label`. */\n  label?: string;\n};\n\n/**\n * A Button wired to one step action (`next`, `prev`, `dismiss`, `skip` or a function), named by its visible label\n * rather than zag's role label (\"next step\"), so what is read matches what is shown.\n */\nconst TourActionTrigger = forwardRef<HTMLButtonElement, TourActionTriggerProps>(\n  ({ action, label, ...props }, forwardedRef) => (\n    // Button drops zag's `aria-label` unless it is icon-only, so its visible label names it.\n    <TourPrimitive.ActionTrigger action={action} asChild>\n      <Button {...props} label={label ?? action.label} ref={forwardedRef} />\n    </TourPrimitive.ActionTrigger>\n  ),\n);\n\nTourActionTrigger.displayName = 'Tour.ActionTrigger';\n\n//\n// CloseTrigger\n//\n\ntype TourCloseTriggerProps = Omit<TourPrimitive.CloseTriggerProps, 'children'> & {\n  /** With `asChild`, the child (e.g. a \"Done\" `Button`) ends the tour instead of the default icon button. */\n  children?: ReactNode;\n  icon?: string;\n  label?: string;\n};\n\n/** Ends the tour: a ghost icon-only Button by default. */\nconst TourCloseTrigger = forwardRef<HTMLButtonElement, TourCloseTriggerProps>(\n  ({ asChild, children, icon = 'ph--x--regular', label, ...props }, forwardedRef) => {\n    const { t } = useTranslation(translationKey);\n    return asChild ? (\n      <TourPrimitive.CloseTrigger {...props} asChild ref={forwardedRef}>\n        {children}\n      </TourPrimitive.CloseTrigger>\n    ) : (\n      <TourPrimitive.CloseTrigger {...props} asChild ref={forwardedRef}>\n        <Button variant='ghost' icon={icon} label={label ?? t('toolbar-close.label')} iconOnly />\n      </TourPrimitive.CloseTrigger>\n    );\n  },\n);\n\nTourCloseTrigger.displayName = 'Tour.CloseTrigger';\nexport { useTour, useTourContext };\n\nexport type {\n  TourActionsProps as ActionsProps,\n  TourActionTriggerProps as ActionTriggerProps,\n  TourCloseTriggerProps as CloseTriggerProps,\n  TourContentProps as ContentProps,\n  TourControlProps as ControlProps,\n  TourDescriptionProps as DescriptionProps,\n  TourHeaderProps as HeaderProps,\n  TourProgressTextProps as ProgressTextProps,\n  TourRootProps as RootProps,\n  TourStepAction as StepAction,\n  TourStepDetails as StepDetails,\n  TourStepPlacement as StepPlacement,\n  TourTitleProps as TitleProps,\n  UseTourProps,\n  UseTourReturn,\n};\n\nexport {\n  TourActions as Actions,\n  TourActionTrigger as ActionTrigger,\n  TourCloseTrigger as CloseTrigger,\n  TourContent as Content,\n  TourControl as Control,\n  TourDescription as Description,\n  TourHeader as Header,\n  TourProgressText as ProgressText,\n  TourRoot as Root,\n  TourTitle as Title,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAMA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