{"version":3,"sources":["../src/select/select.tsx"],"names":["Root","usePermissions","resolvePermissions","useAudit","evaluatePermission","CANONICAL_ACTIONS","jsx","RadixSelect","Trigger","forwardRef","Value","Icon","Portal","Content","Viewport","Item","ItemText","ItemIndicator","Separator","Group","Label"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,SAASA,KAAAA,CAAK;AAAA,EACZ,QAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA,GAAW,QAAA;AAAA,EACX,eAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAoB;AAClB,EAAA,MAAM,UAAUC,yBAAA,EAAe;AAC/B,EAAA,MAAM,SAAA,GAAYC,6BAAA,CAAmB,WAAA,EAAa,OAAO,CAAA;AACzD,EAAA,MAAM,OAAOC,mBAAA,EAAS;AAEtB,EAAA,MAAM,EAAE,OAAA,EAAS,UAAA,EAAW,GAAIC,6BAAA;AAAA,IAC9B,SAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,IAAA,CAAK;AAAA,MACH,SAAA,EAAW,QAAA;AAAA,MACX,QAAQC,4BAAA,CAAkB,iBAAA;AAAA,MAC1B,gBAAA,EAAkB,QAAA;AAAA,MAClB,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,MACnC,OAAA,EAAS,EAAE,eAAA,EAAiB,MAAA,EAAQ,QAAA;AAAS,KAC9C,CAAA;AACD,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAkB;AAC1C,IAAA,IAAA,CAAK;AAAA,MACH,SAAA,EAAW,QAAA;AAAA,MACX,MAAA,EAAQ,IAAA,GAAOA,4BAAA,CAAkB,WAAA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AA,EAAAC,QAAAA;AAAA,EACA,QAAA,EAAAC,SAAAA;AAAA,EACA,IAAA,EAAAC,KAAAA;AAAA,EACA,QAAA,EAAAC,SAAAA;AAAA,EACA,aAAA,EAAAC,cAAAA;AAAA,EACA,SAAA,EAAAC,UAAAA;AAAA,EACA,KAAA,EAAAC,MAAAA;AAAA,EACA,KAAA,EAAAC;AACF","file":"select.cjs","sourcesContent":["/**\n * Select — headless primitive wrapping Radix Select.\n *\n * Radix's Select owns the WAI-ARIA Listbox pattern used for native-like\n * dropdowns: combobox semantics, typeahead, arrow-key navigation,\n * keyboard-only operation, collision detection, portal, and focus\n * return (ARCHITECTURE §6). We wrap thinly:\n *   - Permission gating on <Root> (denied → null + permission:denied\n *     audit; no useful visible-but-inert state)\n *   - Audit on open / close (`select:open` / `select:close`) and on\n *     value change (`select:change`)\n *   - `data-oshon-primitive=\"select-*\"` styling hooks\n *\n * \"use client\" mandatory — Radix uses hooks + DOM APIs internally.\n */\n\n'use client';\n\nimport * as RadixSelect from '@radix-ui/react-select';\nimport { forwardRef } from 'react';\nimport type {\n  ComponentPropsWithoutRef,\n  ElementRef,\n  ReactNode,\n} from 'react';\nimport {\n  evaluatePermission,\n  resolvePermissions,\n  usePermissions,\n  useAudit,\n  type PermissionContext,\n} from '../context.js';\nimport { CANONICAL_ACTIONS } from '../actions.js';\n\n// ────────────────────────────────────────────────────────────────────────────\n// Root\n\nexport interface SelectRootProps\n  extends Omit<RadixSelect.SelectProps, 'onOpenChange' | 'onValueChange'> {\n  /**\n   * Fires whenever the select's open state changes. Primitive emits\n   * `select:open` / `select:close` audit before the callback runs.\n   */\n  onOpenChange?: (open: boolean) => void;\n  /**\n   * Fires whenever the user picks a value. Primitive emits\n   * `select:change` audit with `{ value }` details before the callback\n   * runs.\n   */\n  onValueChange?: (value: string) => void;\n  /**\n   * Per-instance permission override. Merges over the ambient\n   * `PermissionContext`. Denied → primitive returns null (a select has\n   * no useful visible-but-inert state — the components layer can render\n   * a static readout for that case) and emits `permission:denied`.\n   */\n  permissions?: Partial<PermissionContext>;\n  /**\n   * Resource name for `permissions.can('view', resource, attrs)`.\n   * Default `'select'`. Override for e.g. `resource=\"field:status\"`.\n   */\n  resource?: string;\n  /** Attribute bag for attribute-based access control. */\n  permissionAttrs?: Record<string, unknown>;\n  children: ReactNode;\n}\n\nfunction Root({\n  children,\n  value,\n  defaultValue,\n  onValueChange,\n  open,\n  defaultOpen,\n  onOpenChange,\n  permissions,\n  resource = 'select',\n  permissionAttrs,\n  ...rest\n}: SelectRootProps) {\n  const context = usePermissions();\n  const effective = resolvePermissions(permissions, context);\n  const emit = useAudit();\n\n  const { granted, denyReason } = evaluatePermission(\n    effective,\n    'view',\n    resource,\n    permissionAttrs,\n  );\n\n  if (!granted) {\n    emit({\n      component: 'select',\n      action: CANONICAL_ACTIONS.PERMISSION_DENIED,\n      permissionResult: 'denied',\n      ...(denyReason ? { denyReason } : {}),\n      details: { attemptedAction: 'view', resource },\n    });\n    return null;\n  }\n\n  const handleOpenChange = (next: boolean) => {\n    emit({\n      component: 'select',\n      action: next ? CANONICAL_ACTIONS.SELECT_OPEN : CANONICAL_ACTIONS.SELECT_CLOSE,\n      permissionResult: 'granted',\n    });\n    onOpenChange?.(next);\n  };\n\n  const handleValueChange = (next: string) => {\n    emit({\n      component: 'select',\n      action: CANONICAL_ACTIONS.SELECT_CHANGE,\n      permissionResult: 'granted',\n      details: { value: next },\n    });\n    onValueChange?.(next);\n  };\n\n  return (\n    <RadixSelect.Root\n      value={value}\n      defaultValue={defaultValue}\n      onValueChange={handleValueChange}\n      open={open}\n      defaultOpen={defaultOpen}\n      onOpenChange={handleOpenChange}\n      {...rest}\n    >\n      {children}\n    </RadixSelect.Root>\n  );\n}\nRoot.displayName = 'Select.Root';\n\n// ────────────────────────────────────────────────────────────────────────────\n// Trigger\n\nexport type SelectTriggerProps = ComponentPropsWithoutRef<typeof RadixSelect.Trigger>;\n\nconst Trigger = forwardRef<\n  ElementRef<typeof RadixSelect.Trigger>,\n  SelectTriggerProps\n>(function SelectTrigger(props, ref) {\n  return (\n    <RadixSelect.Trigger\n      ref={ref}\n      data-oshon-primitive=\"select-trigger\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Value\n\nexport type SelectValueProps = ComponentPropsWithoutRef<typeof RadixSelect.Value>;\n\n/**\n * Reads the currently-selected item's text content. Radix renders a\n * `<span>` with `data-placeholder` when no value is set — the\n * components layer styles both states.\n */\nconst Value = forwardRef<\n  ElementRef<typeof RadixSelect.Value>,\n  SelectValueProps\n>(function SelectValue(props, ref) {\n  return <RadixSelect.Value ref={ref} {...props} />;\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Icon\n\nexport type SelectIconProps = ComponentPropsWithoutRef<typeof RadixSelect.Icon>;\n\nconst Icon = forwardRef<\n  ElementRef<typeof RadixSelect.Icon>,\n  SelectIconProps\n>(function SelectIcon(props, ref) {\n  return (\n    <RadixSelect.Icon\n      ref={ref}\n      data-oshon-primitive=\"select-icon\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Portal\n\nexport type SelectPortalProps = RadixSelect.SelectPortalProps;\n\nfunction Portal(props: SelectPortalProps) {\n  return <RadixSelect.Portal {...props} />;\n}\nPortal.displayName = 'Select.Portal';\n\n// ────────────────────────────────────────────────────────────────────────────\n// Content\n\nexport type SelectContentProps = ComponentPropsWithoutRef<typeof RadixSelect.Content>;\n\nconst Content = forwardRef<\n  ElementRef<typeof RadixSelect.Content>,\n  SelectContentProps\n>(function SelectContent(props, ref) {\n  return (\n    <RadixSelect.Content\n      ref={ref}\n      data-oshon-primitive=\"select-content\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Viewport\n\nexport type SelectViewportProps = ComponentPropsWithoutRef<typeof RadixSelect.Viewport>;\n\nconst Viewport = forwardRef<\n  ElementRef<typeof RadixSelect.Viewport>,\n  SelectViewportProps\n>(function SelectViewport(props, ref) {\n  return (\n    <RadixSelect.Viewport\n      ref={ref}\n      data-oshon-primitive=\"select-viewport\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Item\n\nexport type SelectItemProps = ComponentPropsWithoutRef<typeof RadixSelect.Item>;\n\nconst Item = forwardRef<\n  ElementRef<typeof RadixSelect.Item>,\n  SelectItemProps\n>(function SelectItem(props, ref) {\n  return (\n    <RadixSelect.Item\n      ref={ref}\n      data-oshon-primitive=\"select-item\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// ItemText / ItemIndicator / Separator / Group / Label\n\nexport type SelectItemTextProps = ComponentPropsWithoutRef<typeof RadixSelect.ItemText>;\n\nconst ItemText = forwardRef<\n  ElementRef<typeof RadixSelect.ItemText>,\n  SelectItemTextProps\n>(function SelectItemText(props, ref) {\n  return <RadixSelect.ItemText ref={ref} {...props} />;\n});\n\nexport type SelectItemIndicatorProps = ComponentPropsWithoutRef<typeof RadixSelect.ItemIndicator>;\n\nconst ItemIndicator = forwardRef<\n  ElementRef<typeof RadixSelect.ItemIndicator>,\n  SelectItemIndicatorProps\n>(function SelectItemIndicator(props, ref) {\n  return (\n    <RadixSelect.ItemIndicator\n      ref={ref}\n      data-oshon-primitive=\"select-item-indicator\"\n      {...props}\n    />\n  );\n});\n\nexport type SelectSeparatorProps = ComponentPropsWithoutRef<typeof RadixSelect.Separator>;\n\nconst Separator = forwardRef<\n  ElementRef<typeof RadixSelect.Separator>,\n  SelectSeparatorProps\n>(function SelectSeparator(props, ref) {\n  return (\n    <RadixSelect.Separator\n      ref={ref}\n      data-oshon-primitive=\"select-separator\"\n      {...props}\n    />\n  );\n});\n\nexport type SelectGroupProps = ComponentPropsWithoutRef<typeof RadixSelect.Group>;\n\nconst Group = forwardRef<\n  ElementRef<typeof RadixSelect.Group>,\n  SelectGroupProps\n>(function SelectGroup(props, ref) {\n  return <RadixSelect.Group ref={ref} {...props} />;\n});\n\nexport type SelectLabelProps = ComponentPropsWithoutRef<typeof RadixSelect.Label>;\n\nconst Label = forwardRef<\n  ElementRef<typeof RadixSelect.Label>,\n  SelectLabelProps\n>(function SelectLabel(props, ref) {\n  return (\n    <RadixSelect.Label\n      ref={ref}\n      data-oshon-primitive=\"select-label\"\n      {...props}\n    />\n  );\n});\n\n// ────────────────────────────────────────────────────────────────────────────\n// Compound export\n\n/**\n * Compound Select primitive. Use as:\n *\n *   <Select.Root defaultValue=\"open\">\n *     <Select.Trigger aria-label=\"Status\">\n *       <Select.Value placeholder=\"Select…\" />\n *       <Select.Icon>▾</Select.Icon>\n *     </Select.Trigger>\n *     <Select.Portal>\n *       <Select.Content>\n *         <Select.Viewport>\n *           <Select.Item value=\"open\">\n *             <Select.ItemText>Open</Select.ItemText>\n *             <Select.ItemIndicator>✓</Select.ItemIndicator>\n *           </Select.Item>\n *           <Select.Item value=\"closed\">\n *             <Select.ItemText>Closed</Select.ItemText>\n *           </Select.Item>\n *         </Select.Viewport>\n *       </Select.Content>\n *     </Select.Portal>\n *   </Select.Root>\n */\nexport const Select = {\n  Root,\n  Trigger,\n  Value,\n  Icon,\n  Portal,\n  Content,\n  Viewport,\n  Item,\n  ItemText,\n  ItemIndicator,\n  Separator,\n  Group,\n  Label,\n};\n\nexport type SelectProps = SelectRootProps;\n"]}