{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "image-cropper",
  "title": "Image Cropper",
  "description": "The selection springs to a new ratio, handles grow while you drag and the zoom settles on a spring.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.2",
    "@ui-sdk/react@0.1.0-beta.2"
  ],
  "registryDependencies": [
    "@keyframery/motion"
  ],
  "files": [
    {
      "path": "registry/components/keyframery/primitives/image-cropper.tsx",
      "content": "\"use client\"\n\n/* Animated drop-in for `@ui-sdk/react/image-cropper`: same parts, same props. Swap the import and keep\n   your code. This file adds motion only. Colours, radii, shadows and spacing stay yours. */\n\nimport {\n  ImageCropper as ImageCropperPart,\n  ImageCropperFlip as ImageCropperFlipPart,\n  ImageCropperGrid as ImageCropperGridPart,\n  ImageCropperHandle as ImageCropperHandlePart,\n  ImageCropperImage as ImageCropperImagePart,\n  ImageCropperRotate as ImageCropperRotatePart,\n  ImageCropperSelection as ImageCropperSelectionPart,\n} from \"@ui-sdk/react/image-cropper\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport * from \"@ui-sdk/react/image-cropper\"\n\n/* UI SDK accepts a class name or a function of state; keep both working. */\nfunction withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {\n  return typeof className === \"function\" ? (state: S) => cn(base, className(state)) : cn(base, className)\n}\n\n/* Press: buttons give under the finger and spring back on release. */\nconst press =\n  \"transition-[scale] duration-[calc(200ms*var(--kf-speed,1))] ease-pop not-disabled:active:scale-[0.96] motion-reduce:transition-none!\"\n\n/* The root names a group so the image can tell when a drag is under way. */\nfunction ImageCropper({ className, ...props }: React.ComponentProps<typeof ImageCropperPart>) {\n  return <ImageCropperPart className={withClass(\"group/kf-cropper\", className)} {...props} />\n}\n\n/* The image clears out of a blur once it loads, and springs to its new place and turn on a rotate,\n   a flip or a frame zoom. While a pointer pans it, it follows the pointer exactly. */\nfunction ImageCropperImage({ className, ...props }: React.ComponentProps<typeof ImageCropperImagePart>) {\n  return (\n    <ImageCropperImagePart\n      className={withClass(\n        cn(\n          \"[transition:left_calc(560ms*var(--kf-speed,1))_var(--ease-spring),top_calc(560ms*var(--kf-speed,1))_var(--ease-spring),width_calc(560ms*var(--kf-speed,1))_var(--ease-spring),height_calc(560ms*var(--kf-speed,1))_var(--ease-spring),transform_calc(620ms*var(--kf-speed,1))_var(--ease-spring),opacity_calc(420ms*var(--kf-speed,1))_var(--ease-house),filter_calc(420ms*var(--kf-speed,1))_var(--ease-house)]\",\n          \"data-loading:opacity-0 data-loading:blur-[10px]\",\n          \"group-data-dragging/kf-cropper:[transition:opacity_calc(420ms*var(--kf-speed,1))_var(--ease-house),filter_calc(420ms*var(--kf-speed,1))_var(--ease-house)]\",\n          \"motion-reduce:[transition:none]!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* The selection springs to its new box when the ratio or the zoom changes, or an arrow key moves\n   it, and tracks the pointer exactly while dragged. Its shadow (the dimmed area outside) fades:\n   in once the image loads, and lighter or darker as your own classes change it during a drag. */\nfunction ImageCropperSelection({ className, ...props }: React.ComponentProps<typeof ImageCropperSelectionPart>) {\n  return (\n    <ImageCropperSelectionPart\n      className={withClass(\n        cn(\n          \"[transition:left_calc(560ms*var(--kf-speed,1))_var(--ease-spring),top_calc(560ms*var(--kf-speed,1))_var(--ease-spring),width_calc(560ms*var(--kf-speed,1))_var(--ease-spring),height_calc(560ms*var(--kf-speed,1))_var(--ease-spring),box-shadow_calc(320ms*var(--kf-speed,1))_var(--ease-house),opacity_calc(360ms*var(--kf-speed,1))_var(--ease-house),scale_calc(520ms*var(--kf-speed,1))_var(--ease-spring)]\",\n          \"data-dragging:[transition:box-shadow_calc(320ms*var(--kf-speed,1))_var(--ease-house)]\",\n          \"starting:scale-[0.9] starting:opacity-0\",\n          \"motion-reduce:[transition:none]!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* The thirds fade in while you drag, and out when you let go. */\nfunction ImageCropperGrid({ className, ...props }: React.ComponentProps<typeof ImageCropperGridPart>) {\n  return (\n    <ImageCropperGridPart\n      className={withClass(\n        cn(\n          \"opacity-0 transition-opacity duration-[calc(240ms*var(--kf-speed,1))] ease-house data-dragging:opacity-100\",\n          \"motion-reduce:transition-none!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* A handle grows with a pop under the pointer, and a little more while it is dragged. Set\n   `data-hovered` to show the hover from script. */\nfunction ImageCropperHandle({ className, ...props }: React.ComponentProps<typeof ImageCropperHandlePart>) {\n  return (\n    <ImageCropperHandlePart\n      className={withClass(\n        cn(\n          \"transition-[scale] duration-[calc(360ms*var(--kf-speed,1))] ease-pop\",\n          \"not-data-disabled:hover:scale-[1.45] data-hovered:scale-[1.45] data-dragging:scale-[1.6]\",\n          \"motion-reduce:transition-none!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction ImageCropperRotate({ className, ...props }: React.ComponentProps<typeof ImageCropperRotatePart>) {\n  return <ImageCropperRotatePart className={withClass(press, className)} {...props} />\n}\n\nfunction ImageCropperFlip({ className, ...props }: React.ComponentProps<typeof ImageCropperFlipPart>) {\n  return <ImageCropperFlipPart className={withClass(press, className)} {...props} />\n}\n\nexport {\n  ImageCropper,\n  ImageCropperFlip,\n  ImageCropperGrid,\n  ImageCropperHandle,\n  ImageCropperImage,\n  ImageCropperRotate,\n  ImageCropperSelection,\n}\n",
      "type": "registry:component",
      "target": "components/keyframery/primitives/image-cropper.tsx"
    },
    {
      "path": "registry/components/keyframery/image-cropper.tsx",
      "content": "\"use client\"\n\n/* Styled image cropper: the animated primitive plus the Keyframery look. */\n\nimport * as React from \"react\"\n\nimport {\n  ImageCropper as ImageCropperPrimitive,\n  ImageCropperFlip as ImageCropperFlipPrimitive,\n  ImageCropperGrid as ImageCropperGridPrimitive,\n  ImageCropperHandle as ImageCropperHandlePrimitive,\n  ImageCropperImage as ImageCropperImagePrimitive,\n  ImageCropperRotate as ImageCropperRotatePrimitive,\n  ImageCropperSelection as ImageCropperSelectionPrimitive,\n  ImageCropperViewport as ImageCropperViewportPrimitive,\n  ImageCropperZoom as ImageCropperZoomPrimitive,\n} from \"@/components/keyframery/primitives/image-cropper\"\nimport { cn } from \"@/lib/utils\"\n\nexport { createImageCropperController, type ImageCrop } from \"@/components/keyframery/primitives/image-cropper\"\n\nfunction ImageCropper({ className, ...props }: React.ComponentProps<typeof ImageCropperPrimitive>) {\n  return (\n    <ImageCropperPrimitive\n      className={cn(\"flex flex-col gap-3 data-disabled:opacity-60\", className as string)}\n      {...props}\n    />\n  )\n}\n\n/* A dark well the photo sits in, sized to the photo, with room around it for the handles. Dark in\n   both themes, like a photo editor: the dim outside the crop then reads as one canvas. */\nfunction ImageCropperViewport({ className, ...props }: React.ComponentProps<typeof ImageCropperViewportPrimitive>) {\n  return (\n    <ImageCropperViewportPrimitive\n      className={cn(\n        \"box-border w-full rounded-[14px] bg-[oklch(0.24_0_0)] p-2.5 aspect-(--image-cropper-aspect-ratio,4/3) dark:bg-muted\",\n        \"shadow-[inset_0_1px_2px_rgb(0_0_0/0.3),inset_0_0_0_1px_rgb(0_0_0/0.1)]\",\n        \"dark:shadow-[inset_0_1px_2px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(255_255_255/0.04)]\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction ImageCropperImage({ className, ...props }: React.ComponentProps<typeof ImageCropperImagePrimitive>) {\n  return <ImageCropperImagePrimitive className={cn(\"rounded-[3px]\", className as string)} {...props} />\n}\n\n/* A white hairline around the crop, and a dimmed photo outside it that lightens while you drag. */\nfunction ImageCropperSelection({ className, ...props }: React.ComponentProps<typeof ImageCropperSelectionPrimitive>) {\n  return (\n    <ImageCropperSelectionPrimitive\n      className={cn(\n        \"outline-none data-[shape=circle]:rounded-full\",\n        \"shadow-[0_0_0_1.5px_rgb(255_255_255/0.95),0_0_0_9999px_rgb(0_0_0/0.52)]\",\n        \"data-dragging:shadow-[0_0_0_1.5px_rgb(255_255_255/0.95),0_0_0_9999px_rgb(0_0_0/0.3)]\",\n        \"starting:shadow-[0_0_0_1.5px_rgb(255_255_255/0),0_0_0_9999px_rgb(0_0_0/0)]\",\n        \"focus-visible:shadow-[0_0_0_2px_var(--ring),0_0_0_9999px_rgb(0_0_0/0.52)]\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* Lines in thirds. */\nfunction ImageCropperGrid({ className, ...props }: React.ComponentProps<typeof ImageCropperGridPrimitive>) {\n  return (\n    <ImageCropperGridPrimitive\n      className={cn(\n        \"before:absolute before:inset-y-0 before:left-1/3 before:right-1/3 before:border-x before:border-white/50 before:content-['']\",\n        \"after:absolute after:inset-x-0 after:top-1/3 after:bottom-1/3 after:border-y after:border-white/50 after:content-['']\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* White dots on the corners and short bars on the edges, with a larger invisible grip around each. */\nfunction ImageCropperHandle({ className, ...props }: React.ComponentProps<typeof ImageCropperHandlePrimitive>) {\n  return (\n    <ImageCropperHandlePrimitive\n      className={cn(\n        \"absolute z-10 -translate-1/2 rounded-full bg-white outline-none\",\n        \"shadow-[0_0_0_1px_rgb(0_0_0/0.18),0_1px_3px_rgb(0_0_0/0.35)]\",\n        \"before:absolute before:-inset-2.5 before:content-['']\",\n        \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-white\",\n        \"data-[position=nw]:top-0 data-[position=nw]:left-0 data-[position=ne]:top-0 data-[position=ne]:left-full\",\n        \"data-[position=sw]:top-full data-[position=sw]:left-0 data-[position=se]:top-full data-[position=se]:left-full\",\n        \"data-[position=n]:top-0 data-[position=n]:left-1/2 data-[position=s]:top-full data-[position=s]:left-1/2\",\n        \"data-[position=w]:top-1/2 data-[position=w]:left-0 data-[position=e]:top-1/2 data-[position=e]:left-full\",\n        \"data-[position=ne]:size-3 data-[position=nw]:size-3 data-[position=se]:size-3 data-[position=sw]:size-3\",\n        \"data-[position=n]:h-1.5 data-[position=n]:w-5 data-[position=s]:h-1.5 data-[position=s]:w-5\",\n        \"data-[position=e]:h-5 data-[position=e]:w-1.5 data-[position=w]:h-5 data-[position=w]:w-1.5\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* A thin range: a pill well with a round key for a thumb. */\nfunction ImageCropperZoom({ className, ...props }: React.ComponentProps<typeof ImageCropperZoomPrimitive>) {\n  return (\n    <ImageCropperZoomPrimitive\n      className={cn(\n        \"h-5 w-full cursor-pointer appearance-none bg-transparent outline-none disabled:cursor-not-allowed\",\n        \"[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-muted\",\n        \"[&::-webkit-slider-runnable-track]:shadow-[inset_0_1px_1px_rgb(0_0_0/0.08),inset_0_0_0_1px_rgb(0_0_0/0.04)] dark:[&::-webkit-slider-runnable-track]:bg-accent\",\n        \"[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-background\",\n        \"[&::-webkit-slider-thumb]:shadow-[0_0_0_1px_rgb(0_0_0/0.1),0_1px_1px_rgb(0_0_0/0.06),0_2px_5px_-1px_rgb(0_0_0/0.16)]\",\n        \"[&::-webkit-slider-thumb]:transition-[scale] [&::-webkit-slider-thumb]:duration-[calc(300ms*var(--kf-speed,1))] [&::-webkit-slider-thumb]:ease-pop active:[&::-webkit-slider-thumb]:scale-125\",\n        \"dark:[&::-webkit-slider-thumb]:bg-foreground\",\n        \"[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-muted\",\n        \"[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-background\",\n        \"focus-visible:[&::-webkit-slider-thumb]:ring-2 focus-visible:[&::-webkit-slider-thumb]:ring-ring focus-visible:[&::-webkit-slider-thumb]:ring-offset-2 focus-visible:[&::-webkit-slider-thumb]:ring-offset-background\",\n        \"motion-reduce:[&::-webkit-slider-thumb]:transition-none\",\n        className as string,\n      )}\n      {...props}\n    />\n  )\n}\n\nconst keyButton = cn(\n  \"inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-[9px] px-2.5 text-[13px] leading-none font-medium outline-none\",\n  \"bg-background shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_1px_rgb(0_0_0/0.05),0_3px_6px_-2px_rgb(0_0_0/0.1)]\",\n  \"dark:bg-accent dark:shadow-[0_0_0_1px_rgb(255_255_255/0.07),inset_0_1px_0_rgb(255_255_255/0.08),0_2px_6px_-1px_rgb(0_0_0/0.6)]\",\n  \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n  \"disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0\",\n)\n\nfunction ImageCropperRotate({ className, ...props }: React.ComponentProps<typeof ImageCropperRotatePrimitive>) {\n  return <ImageCropperRotatePrimitive className={cn(keyButton, className as string)} {...props} />\n}\n\nfunction ImageCropperFlip({ className, ...props }: React.ComponentProps<typeof ImageCropperFlipPrimitive>) {\n  return <ImageCropperFlipPrimitive className={cn(keyButton, className as string)} {...props} />\n}\n\nexport {\n  ImageCropper,\n  ImageCropperFlip,\n  ImageCropperGrid,\n  ImageCropperHandle,\n  ImageCropperImage,\n  ImageCropperRotate,\n  ImageCropperSelection,\n  ImageCropperViewport,\n  ImageCropperZoom,\n}\n",
      "type": "registry:component",
      "target": "components/keyframery/image-cropper.tsx"
    }
  ],
  "type": "registry:component"
}