{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cookie-consent",
  "title": "Cookie consent",
  "description": "A card in a corner that asks about cookies, with Reject all as easy as Accept all; Customise grows it upward into a switch for each category. The choice is saved and scripts wait for it.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/badge.json",
    "https://kinoui.com/r/button.json",
    "https://kinoui.com/r/collapsible.json",
    "https://kinoui.com/r/consent.json",
    "https://kinoui.com/r/cookie-consent-parts.json",
    "https://kinoui.com/r/panel.json",
    "https://kinoui.com/r/scroll.json",
    "https://kinoui.com/r/skeleton.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/cookie-consent/cookie-consent.tsx",
      "content": "'use client'\n\nimport { Button } from '@/registry/components/kino/button'\nimport { Collapsible, CollapsiblePanel } from '@/registry/components/kino/collapsible'\nimport type { Consent } from '@/registry/lib/consent'\nimport {\n  CookieConsentCategory,\n  CookieConsentDescription,\n  cookieConsentFocusClassName,\n  cookieConsentPresenceClassName,\n  type CookieConsentText,\n  defaultText,\n  useCookieConsent,\n} from '@/registry/lib/cookie-consent-parts'\nimport { panelTitleClassName } from '@/registry/lib/panel'\nimport { edgeFadeClassName, useEdgeFades } from '@/registry/lib/scroll'\nimport { type ComponentProps, useId, useRef } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A card in a corner of the page that asks about cookies: Customise, Reject\n * all and Accept all, as easy as each other. Customise grows the card in\n * place into a switch for each category, and turns into Save choices. The\n * page places it with its className, pinned to a corner of the window above\n * everything else, since a block lays out only inside the box it is given.\n *\n *   <CookieConsent consent={consent} policyHref='/cookies' className={corner} />\n */\n\ninterface CookieConsentProps<Id extends string>\n  extends Omit<ComponentProps<'div'>, 'title'>, CookieConsentText {\n  consent: Consent<Id>\n}\n\nfunction CookieConsent<Id extends string>({\n  consent,\n  title = defaultText.title,\n  description = defaultText.description,\n  policyHref,\n  className,\n  ...props\n}: CookieConsentProps<Id>) {\n  const surfaceRef = useRef<HTMLElement>(null)\n  const model = useCookieConsent(consent, surfaceRef)\n  const titleId = useId()\n  // Reject all and Accept all weigh the same; once the switches show, Save choices leads.\n  const answerVariant = model.customising ? 'outline' : 'default'\n  const fades = useEdgeFades<HTMLDivElement>()\n  if (!model.ready) return null\n  return (\n    <div\n      data-slot='cookie-consent'\n      className={cn(\n        '@container/cookie-consent pointer-events-none w-full max-w-sm',\n        className,\n      )}\n      {...props}\n    >\n      <section\n        ref={surfaceRef}\n        aria-labelledby={titleId}\n        tabIndex={-1}\n        data-closed={model.shown ? undefined : ''}\n        inert={!model.shown}\n        className={cn(\n          cookieConsentPresenceClassName,\n          cookieConsentFocusClassName,\n          'bg-popover text-popover-foreground pointer-events-auto flex flex-col rounded-(--surface-radius) border p-(--surface-padding) shadow-lg',\n        )}\n      >\n        <h2 id={titleId} className={panelTitleClassName}>\n          {title}\n        </h2>\n        <CookieConsentDescription\n          className='mt-1'\n          description={description}\n          policyHref={policyHref}\n        />\n        {/* The Customise button opens it, so an agent presses that, as a person does. */}\n        <Collapsible\n          open={model.customising}\n          disabled\n          role='group'\n          aria-label='Cookie categories'\n        >\n          <CollapsiblePanel className='p-0'>\n            <div\n              ref={fades}\n              className={cn(\n                edgeFadeClassName,\n                'scrollbar-thin -mx-(--surface-padding) mt-(--surface-gap) max-h-72 overflow-y-auto border-t px-(--surface-padding) pt-(--surface-gap)',\n              )}\n            >\n              <div className='flex flex-col gap-4 pb-1'>\n                {model.categories.map((category) => (\n                  <CookieConsentCategory\n                    key={category.id}\n                    category={category}\n                    model={model}\n                  />\n                ))}\n              </div>\n            </div>\n          </CollapsiblePanel>\n        </Collapsible>\n        <div className='mt-(--surface-gap) flex flex-col gap-2 @xs/cookie-consent:flex-row'>\n          <Button\n            variant={model.customising ? 'default' : 'ghost'}\n            className='@xs/cookie-consent:me-auto'\n            onClick={model.customiseOrSave}\n          >\n            {model.customising ? 'Save choices' : 'Customise'}\n          </Button>\n          <Button variant={answerVariant} onClick={model.rejectAll}>\n            Reject all\n          </Button>\n          <Button variant={answerVariant} onClick={model.acceptAll}>\n            Accept all\n          </Button>\n        </div>\n      </section>\n    </div>\n  )\n}\n\nexport { CookieConsent }\n\nexport type { CookieConsentProps }\n",
      "type": "registry:component",
      "target": "@components/kino/cookie-consent/cookie-consent.tsx"
    }
  ],
  "type": "registry:block"
}