{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "location-finder",
  "title": "Location Finder",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/location-finder/LocationFinder.tsx",
      "content": "import * as React from 'react'\nimport { ActivityIndicator, View, type ViewProps } from 'react-native'\nimport { Alert, AlertActions, AlertDescription, AlertTitle } from '@/components/ui/alert'\nimport { Button } from '@/components/ui/button'\nimport { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'\nimport { SearchBar } from '@/components/ui/search-bar'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport interface LocationFinderOption {\n  id: string\n  name: string\n  address: string\n  distance?: string\n  detail?: string\n  unavailableReason?: string\n}\n\nconst sampleLocations: LocationFinderOption[] = [\n  {\n    id: 'canal',\n    name: 'Canal Street Market',\n    address: '18 Canal Street',\n    distance: '0.4 mi',\n    detail: 'Counter pickup until 8 PM',\n  },\n  {\n    id: 'cedar',\n    name: 'Cedar Station Lockers',\n    address: '204 Cedar Avenue',\n    distance: '1.1 mi',\n    detail: 'Locker access all day',\n  },\n]\n\ninterface LocationFinderMap {\n  results: readonly LocationFinderOption[]\n  selectedId: string | null\n  select: (id: string) => void\n}\n\nexport interface LocationFinderProps extends ViewProps {\n  className?: string\n  title?: string\n  searchLabel?: string\n  locations?: readonly LocationFinderOption[]\n  value?: string | null\n  defaultValue?: string\n  onValueChange?: (location: LocationFinderOption) => void\n  renderMap?: (map: LocationFinderMap) => React.ReactNode\n  loading?: boolean\n  error?: string\n  onRetry?: () => void\n  confirmLabel?: string\n  onConfirm?: (location: LocationFinderOption) => void\n}\n\nexport function LocationFinder({\n  className,\n  title = 'Find a location',\n  searchLabel = 'Search locations',\n  locations = sampleLocations,\n  value,\n  defaultValue,\n  onValueChange,\n  renderMap,\n  loading = false,\n  error,\n  onRetry,\n  confirmLabel = 'Use this location',\n  onConfirm,\n  ...props\n}: LocationFinderProps) {\n  const [query, setQuery] = React.useState('')\n  const [internal, setInternal] = React.useState(defaultValue)\n  const selected = locations.find(\n    (location) => location.id === (value === undefined ? internal : value) && !location.unavailableReason,\n  )\n  const term = query.trim().toLocaleLowerCase()\n  const results = term\n    ? locations.filter((location) =>\n        [location.name, location.address, location.detail].some((field) => field?.toLocaleLowerCase().includes(term)),\n      )\n    : locations\n\n  function select(id: string) {\n    if (loading || error || selected?.id === id) return\n    const location = locations.find((entry) => entry.id === id && !entry.unavailableReason)\n    if (!location) return\n    if (value === undefined) setInternal(id)\n    onValueChange?.(location)\n  }\n\n  return (\n    <View {...props} className={cn('gap-4', className)}>\n      <Text size=\"title\" accessibilityRole=\"header\">\n        {title}\n      </Text>\n      <SearchBar value={query} onChangeText={setQuery} accessibilityLabel={searchLabel} placeholder={searchLabel} />\n      {loading ? (\n        <View className=\"flex-row items-center gap-2\" accessibilityRole=\"progressbar\" accessibilityState={{ busy: true }}>\n          <ActivityIndicator aria-hidden />\n          <Text size=\"sm\">Finding locations…</Text>\n        </View>\n      ) : null}\n      {error && !loading ? (\n        <Alert variant=\"destructive\">\n          <AlertTitle>Locations unavailable</AlertTitle>\n          <AlertDescription>{error}</AlertDescription>\n          {onRetry ? (\n            <AlertActions>\n              <Button variant=\"outline\" onPress={onRetry}>\n                Try again\n              </Button>\n            </AlertActions>\n          ) : null}\n        </Alert>\n      ) : (\n        <>\n          {!error && results.length > 0 ? (\n            <>\n              {renderMap?.({ results, selectedId: selected?.id ?? null, select })}\n              <RadioGroup\n                accessibilityLabel=\"Locations\"\n                value={selected?.id ?? ''}\n                onValueChange={select}\n                disabled={loading}\n              >\n                {results.map((location) => (\n                  <RadioGroupItem\n                    key={location.id}\n                    className={cn(\n                      'items-start rounded-lg border border-border bg-card p-3',\n                      selected?.id === location.id && 'border-ring bg-muted',\n                    )}\n                    value={location.id}\n                    label={location.name}\n                    accessibilityLabel={[\n                      location.name,\n                      location.address,\n                      location.distance,\n                      location.detail,\n                      location.unavailableReason,\n                    ]\n                      .filter(Boolean)\n                      .join('. ')}\n                    disabled={Boolean(location.unavailableReason)}\n                  >\n                    <Text size=\"sm\" variant=\"muted\">\n                      {location.address}\n                    </Text>\n                    {location.distance || location.detail ? (\n                      <Text size=\"sm\">{[location.distance, location.detail].filter(Boolean).join(' · ')}</Text>\n                    ) : null}\n                    {location.unavailableReason ? <Text size=\"sm\">{location.unavailableReason}</Text> : null}\n                  </RadioGroupItem>\n                ))}\n              </RadioGroup>\n            </>\n          ) : loading ? null : (\n            <View className=\"gap-1 rounded-lg border border-border bg-card p-4\">\n              <Text className=\"font-semibold\">{term ? 'No matching locations' : 'No locations available'}</Text>\n              <Text variant=\"muted\" size=\"sm\">\n                {term ? 'Try another name, address, or service.' : 'Check again later.'}\n              </Text>\n            </View>\n          )}\n        </>\n      )}\n      {onConfirm ? (\n        <View className=\"gap-2\">\n          {selected ? <Text size=\"sm\">Selected: {selected.name}</Text> : null}\n          <Button\n            disabled={!selected || loading || Boolean(error)}\n            onPress={() => {\n              if (selected && !loading && !error) onConfirm(selected)\n            }}\n          >\n            {confirmLabel}\n          </Button>\n        </View>\n      ) : null}\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/location-finder/LocationFinder.tsx"
    },
    {
      "path": "packages/registry-native/blocks/location-finder/index.ts",
      "content": "export * from './LocationFinder'\n",
      "type": "registry:block",
      "target": "~/components/blocks/location-finder/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/alert.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/radio-group.json",
    "https://native.uipkge.dev/r/native/search-bar.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Search and select pickup points, branches, or other locations, with an optional synchronized map.",
  "categories": [
    "location"
  ]
}