{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-office-locations",
  "title": "OfficeLocations",
  "description": "Grid interativo de unidades e endereços com horários e status de funcionamento.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider",
    "@lema-ds/tokens"
  ],
  "files": [
    {
      "path": "components/ds/ds-office-locations.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { MapPin } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\n\n// ── Types ──\n\nexport type OfficeLocationsSize = \"sm\" | \"md\" | \"lg\"\n\nexport interface BusinessHours {\n  /** Local opening hour, 0-24. */\n  start: number\n  /** Local closing hour, 0-24. */\n  end: number\n}\n\nexport type OfficeLocationsProps = React.HTMLAttributes<HTMLUListElement>\n\nexport interface OfficeLocationItemProps\n  extends\n    Omit<React.HTMLAttributes<HTMLLIElement>, \"children\">,\n    VariantProps<typeof officeLocationItemVariants> {\n  city: string\n  country?: string\n  address?: string\n  /** IANA time zone, e.g. \"America/Sao_Paulo\". */\n  timeZone: string\n  /** Local business hours used to compute the open/closed dot. */\n  businessHours?: BusinessHours\n  locale?: UILocale\n  loading?: boolean\n}\n\n// ── Variants ──\n\nexport const officeLocationItemVariants = cva(\n  \"flex items-center justify-between gap-4 border-b border-border py-4 last:border-b-0\",\n  {\n    variants: {\n      size: {\n        sm: \"py-3\",\n        md: \"py-4\",\n        lg: \"py-5\",\n      },\n    },\n    defaultVariants: { size: \"md\" },\n  }\n)\n\nexport const officeLocationIconVariants = cva(\n  \"shrink-0 text-muted-foreground\",\n  {\n    variants: {\n      size: { sm: \"size-3.5\", md: \"size-4\", lg: \"size-5\" },\n    },\n    defaultVariants: { size: \"md\" },\n  }\n)\n\nexport const officeLocationCityVariants = cva(\"font-medium text-foreground\", {\n  variants: {\n    size: { sm: \"text-xs\", md: \"text-sm\", lg: \"text-base\" },\n  },\n  defaultVariants: { size: \"md\" },\n})\n\nexport const officeLocationMetaVariants = cva(\"text-muted-foreground\", {\n  variants: {\n    size: { sm: \"text-xs\", md: \"text-sm\", lg: \"text-sm\" },\n  },\n  defaultVariants: { size: \"md\" },\n})\n\nexport const officeLocationTimeVariants = cva(\n  \"font-semibold text-foreground tabular-nums\",\n  {\n    variants: {\n      size: { sm: \"text-xs\", md: \"text-sm\", lg: \"text-base\" },\n    },\n    defaultVariants: { size: \"md\" },\n  }\n)\n\n// ── Helpers ──\n\nfunction useNow(intervalMs = 30_000) {\n  const [now, setNow] = React.useState(() => new Date())\n  React.useEffect(() => {\n    const id = setInterval(() => setNow(new Date()), intervalMs)\n    return () => clearInterval(id)\n  }, [intervalMs])\n  return now\n}\n\nfunction getLocalHour(date: Date, timeZone: string) {\n  const formatter = new Intl.DateTimeFormat(\"en-US\", {\n    hour: \"numeric\",\n    hourCycle: \"h23\",\n    timeZone,\n  })\n  return Number.parseInt(formatter.format(date), 10)\n}\n\nconst SKELETON_META: Record<OfficeLocationsSize, string> = {\n  sm: \"h-3 w-32\",\n  md: \"h-3.5 w-40\",\n  lg: \"h-4 w-48\",\n}\n\n// ── OfficeLocations ──\n\nexport const OfficeLocations = React.forwardRef<\n  HTMLUListElement,\n  OfficeLocationsProps\n>(({ className, ...props }, ref) => (\n  <ul\n    ref={ref}\n    className={cn(\"flex flex-col\", className)}\n    data-slot=\"office-locations\"\n    {...props}\n  />\n))\nOfficeLocations.displayName = \"OfficeLocations\"\n\n// ── OfficeLocationItem ──\n\nexport const OfficeLocationItem = React.forwardRef<\n  HTMLLIElement,\n  OfficeLocationItemProps\n>(\n  (\n    {\n      city,\n      country,\n      address,\n      timeZone,\n      businessHours = { start: 9, end: 18 },\n      locale: localeProp,\n      size = \"md\",\n      loading = false,\n      className,\n      ...props\n    },\n    ref\n  ) => {\n    const locale = useUILocale(localeProp)\n    const now = useNow()\n    const resolvedSize = size ?? \"md\"\n\n    const timeFormatter = React.useMemo(\n      () =>\n        new Intl.DateTimeFormat(locale, {\n          hour: \"2-digit\",\n          minute: \"2-digit\",\n          timeZone,\n        }),\n      [locale, timeZone]\n    )\n\n    if (loading) {\n      return (\n        <li\n          ref={ref}\n          className={cn(officeLocationItemVariants({ size }), className)}\n          data-slot=\"office-location-item-skeleton\"\n        >\n          <div className=\"flex items-center gap-3\">\n            <Skeleton className=\"size-4 rounded-full\" />\n            <div className=\"flex flex-col gap-1.5\">\n              <Skeleton className=\"h-4 w-24 rounded-md\" />\n              <Skeleton\n                className={cn(\"rounded-md\", SKELETON_META[resolvedSize])}\n              />\n            </div>\n          </div>\n          <Skeleton className=\"h-4 w-16 rounded-md\" />\n        </li>\n      )\n    }\n\n    const localHour = getLocalHour(now, timeZone)\n    const isOpen =\n      localHour >= businessHours.start && localHour < businessHours.end\n    const statusLabel = isOpen\n      ? UI_I18N[locale].officeLocations.openNow\n      : UI_I18N[locale].officeLocations.closed\n\n    return (\n      <li\n        ref={ref}\n        className={cn(officeLocationItemVariants({ size }), className)}\n        data-slot=\"office-location-item\"\n        {...props}\n      >\n        <div className=\"flex min-w-0 items-start gap-3\">\n          <MapPin\n            className={cn(officeLocationIconVariants({ size }), \"mt-0.5\")}\n            aria-hidden=\"true\"\n          />\n          <div className=\"flex min-w-0 flex-col\">\n            <span className={cn(officeLocationCityVariants({ size }))}>\n              {city}\n              {country ? `, ${country}` : \"\"}\n            </span>\n            {address && (\n              <span\n                className={cn(officeLocationMetaVariants({ size }), \"truncate\")}\n              >\n                {address}\n              </span>\n            )}\n          </div>\n        </div>\n\n        <div className=\"flex shrink-0 flex-col items-end gap-1\">\n          <time\n            dateTime={now.toISOString()}\n            className={cn(officeLocationTimeVariants({ size }))}\n          >\n            {timeFormatter.format(now)}\n          </time>\n          <span\n            className={cn(\n              \"inline-flex items-center gap-1.5\",\n              officeLocationMetaVariants({ size })\n            )}\n          >\n            <span\n              className={cn(\n                \"size-1.5 shrink-0 rounded-full\",\n                isOpen ? \"bg-success\" : \"bg-muted-foreground\"\n              )}\n              aria-hidden=\"true\"\n            />\n            {statusLabel}\n          </span>\n        </div>\n      </li>\n    )\n  }\n)\nOfficeLocationItem.displayName = \"OfficeLocationItem\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
