Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

21.9 KB
Raw Blame
{
  "type": "remotion-element",
  "version": 1,
  "element": {
    "assets": [],
    "dependencies": [
      {
        "name": "@remotion/captions",
        "version": null
      }
    ],
    "dimensions": null,
    "displayName": "Caption Cube",
    "initialProps": null,
    "slug": "caption-cube",
    "sourceCode": "import { Fragment, forwardRef, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ComponentProps } from \"react\";\nimport { Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\nimport { createTikTokStyleCaptions, type Caption, type TikTokPage } from \"@remotion/captions\";\n\ntype SpeakerCaption = Caption & { speaker?: string };\n\ninterface CaptionBaseProps {\n  captions: Caption[];\n  combineTokensWithinMilliseconds?: number;\n  holdMs?: number;\n  fontSize?: number;\n  fontWeight?: number;\n  color?: string;\n  className?: string;\n}\n\nconst DEFAULT_HOLD_MS = 600;\nconst MIN_SILENCE_BREAK_MS = 300;\n\ninterface CaptionPageWindow {\n  page: TikTokPage;\n  index: number;\n  speaker: string | undefined;\n  startMs: number;\n  speechEndMs: number;\n  endMs: number;\n  endsInSilence: boolean;\n}\n\ntype CaptionTokenStatus = \"upcoming\" | \"active\" | \"spoken\";\n\ninterface CaptionTokenState {\n  text: string;\n  spaceBefore: boolean;\n  fromMs: number;\n  toMs: number;\n  progress: number;\n  status: CaptionTokenStatus;\n}\n\ninterface CaptionPreviousPage {\n  page: TikTokPage;\n  pageIndex: number;\n  tokens: CaptionTokenState[];\n}\n\ninterface CaptionsState {\n  page: TikTokPage;\n  pageIndex: number;\n  speaker: string | undefined;\n  timeMs: number;\n  activeIndex: number;\n  tokens: CaptionTokenState[];\n  sinceStartMs: number;\n  untilEndMs: number;\n  holdRoomMs: number;\n  endsInSilence: boolean;\n  previous: CaptionPreviousPage | null;\n}\n\ninterface CaptionPagingOptions {\n  combineTokensWithinMilliseconds: number;\n  holdMs?: number;\n}\n\nconst SENTENCE_END = /[.!?…][\"')\\]]*$/;\n\nfunction markPageBreaks(captions: SpeakerCaption[]): Caption[] {\n  return captions.map((caption, i) => {\n    if (caption.pageBreakAfter !== undefined) return caption;\n    const next = captions[i + 1];\n    const speakerChanges =\n      next !== undefined && next.speaker !== caption.speaker;\n    return speakerChanges || SENTENCE_END.test(caption.text.trim())\n      ? { ...caption, pageBreakAfter: true }\n      : caption;\n  });\n}\n\nfunction buildCaptionPages(\n  captions: SpeakerCaption[],\n  {\n    combineTokensWithinMilliseconds,\n    holdMs = DEFAULT_HOLD_MS,\n  }: CaptionPagingOptions,\n): CaptionPageWindow[] {\n  if (captions.length === 0) return [];\n  const { pages } = createTikTokStyleCaptions({\n    captions: markPageBreaks(captions),\n    combineTokensWithinMilliseconds,\n    breakOnSilenceAfterMilliseconds: Math.max(holdMs, MIN_SILENCE_BREAK_MS),\n  });\n  const speakers = new Map<number, string | undefined>();\n  for (const caption of captions) {\n    if (!speakers.has(caption.startMs)) {\n      speakers.set(caption.startMs, caption.speaker);\n    }\n  }\n  const spoken = pages.filter((page) => page.tokens.length > 0);\n  return spoken.map((page, index) => {\n    const last = page.tokens[page.tokens.length - 1];\n    const speechEndMs = last ? last.toMs : page.startMs;\n    const heldUntil = speechEndMs + Math.max(0, holdMs);\n    const next = spoken[index + 1];\n    const endsInSilence = !next || next.startMs > heldUntil;\n    const endMs = endsInSilence\n      ? heldUntil\n      : Math.max(page.startMs, next.startMs);\n    return {\n      page,\n      index,\n      speaker: speakers.get(page.tokens[0].fromMs),\n      startMs: page.startMs,\n      speechEndMs,\n      endMs,\n      endsInSilence,\n    };\n  });\n}\n\nfunction findWindowIndex(windows: CaptionPageWindow[], timeMs: number): number {\n  let lo = 0;\n  let hi = windows.length - 1;\n  let found = -1;\n  while (lo <= hi) {\n    const mid = (lo + hi) >> 1;\n    if (windows[mid].startMs <= timeMs) {\n      found = mid;\n      lo = mid + 1;\n    } else {\n      hi = mid - 1;\n    }\n  }\n  if (found === -1) return -1;\n  return timeMs < windows[found].endMs ? found : -1;\n}\n\nfunction tokenProgress(fromMs: number, toMs: number, timeMs: number): number {\n  if (timeMs < fromMs) return 0;\n  if (toMs <= fromMs) return 1;\n  return Math.min(1, (timeMs - fromMs) / (toMs - fromMs));\n}\n\nfunction getTokenStates(\n  page: TikTokPage,\n  timeMs: number,\n): { activeIndex: number; tokens: CaptionTokenState[] } {\n  let activeIndex = -1;\n  page.tokens.forEach((token, i) => {\n    if (token.fromMs <= timeMs) activeIndex = i;\n  });\n  const tokens = page.tokens.map(\n    (token, i): CaptionTokenState => ({\n      text: token.text.trim(),\n      spaceBefore: i > 0 && /^\\s/.test(token.text),\n      fromMs: token.fromMs,\n      toMs: token.toMs,\n      progress: tokenProgress(token.fromMs, token.toMs, timeMs),\n      status:\n        i < activeIndex ? \"spoken\" : i === activeIndex ? \"active\" : \"upcoming\",\n    }),\n  );\n  return { activeIndex, tokens };\n}\n\nfunction getCaptionsState(\n  windows: CaptionPageWindow[],\n  timeMs: number,\n): CaptionsState | null {\n  const found = findWindowIndex(windows, timeMs);\n  if (found === -1) return null;\n  const window = windows[found];\n  const { activeIndex, tokens } = getTokenStates(window.page, timeMs);\n  const before = found > 0 ? windows[found - 1] : null;\n  const previous =\n    before && !before.endsInSilence\n      ? {\n          page: before.page,\n          pageIndex: before.index,\n          tokens: getTokenStates(before.page, before.endMs).tokens,\n        }\n      : null;\n  return {\n    page: window.page,\n    pageIndex: window.index,\n    speaker: window.speaker,\n    timeMs,\n    activeIndex,\n    tokens,\n    sinceStartMs: timeMs - window.startMs,\n    untilEndMs: window.endMs - timeMs,\n    holdRoomMs: window.endMs - window.speechEndMs,\n    endsInSilence: window.endsInSilence,\n    previous,\n  };\n}\n\nfunction getExitWindowMs(state: CaptionsState, exitMs: number): number {\n  return Math.max(1, Math.min(exitMs, state.holdRoomMs));\n}\n\nfunction groupCaptionWords(\n  tokens: CaptionTokenState[],\n): { index: number; token: CaptionTokenState }[][] {\n  const words: { index: number; token: CaptionTokenState }[][] = [];\n  tokens.forEach((token, index) => {\n    const current = words[words.length - 1];\n    if (!current || token.spaceBefore) {\n      words.push([{ index, token }]);\n    } else {\n      current.push({ index, token });\n    }\n  });\n  return words;\n}\n\nfunction normalizeCaptionWord(text: string): string {\n  return text\n    .toLowerCase()\n    .replace(/[\\u2018\\u2019]/g, \"'\")\n    .replace(/[^\\p{L}\\p{N}']/gu, \"\");\n}\n\nfunction createKeywordMatcher(\n  keywords: readonly string[] = [],\n): (text: string) => boolean {\n  const set = new Set(keywords.map(normalizeCaptionWord).filter(Boolean));\n  return (text) => set.has(normalizeCaptionWord(text));\n}\n\nfunction captionWordText(word: { token: CaptionTokenState }[]): string {\n  return word.map(({ token }) => token.text).join(\"\");\n}\n\ninterface CaptionWordRect {\n  left: number;\n  top: number;\n  width: number;\n  height: number;\n}\n\nfunction sameRects(a: CaptionWordRect[], b: CaptionWordRect[]): boolean {\n  return (\n    a.length === b.length &&\n    a.every(\n      (r, i) =>\n        r.left === b[i].left &&\n        r.top === b[i].top &&\n        r.width === b[i].width &&\n        r.height === b[i].height,\n    )\n  );\n}\n\nfunction useCaptionWordRects(\n  pageIndex: number,\n  count: number,\n): {\n  wordRef: (index: number) => (el: HTMLElement | null) => void;\n  rects: CaptionWordRect[] | null;\n} {\n  const elements = useRef<(HTMLElement | null)[]>([]);\n  const [measured, setMeasured] = useState<{\n    pageIndex: number;\n    rects: CaptionWordRect[];\n  } | null>(null);\n\n  useLayoutEffect(() => {\n    if (pageIndex === -1) return;\n    const rects = elements.current.slice(0, count).map((el) =>\n      el\n        ? {\n            left: el.offsetLeft,\n            top: el.offsetTop,\n            width: el.offsetWidth,\n            height: el.offsetHeight,\n          }\n        : { left: 0, top: 0, width: 0, height: 0 },\n    );\n    setMeasured((prev) =>\n      prev && prev.pageIndex === pageIndex && sameRects(prev.rects, rects)\n        ? prev\n        : { pageIndex, rects },\n    );\n  });\n\n  return {\n    wordRef: (index) => (el) => {\n      elements.current[index] = el;\n    },\n    rects: measured && measured.pageIndex === pageIndex ? measured.rects : null,\n  };\n}\n\nfunction useCaptions({\n  captions,\n  combineTokensWithinMilliseconds,\n  holdMs = DEFAULT_HOLD_MS,\n}: {\n  captions: SpeakerCaption[];\n  combineTokensWithinMilliseconds: number;\n  holdMs?: number;\n}): CaptionsState | null {\n  const frame = useCurrentFrame();\n  const { fps } = useVideoConfig();\n  const windows = useMemo(\n    () =>\n      buildCaptionPages(captions, { combineTokensWithinMilliseconds, holdMs }),\n    [captions, combineTokensWithinMilliseconds, holdMs],\n  );\n  return getCaptionsState(windows, (frame / fps) * 1000);\n}\n\ninterface CaptionCubeProps extends CaptionBaseProps {\n  tintActive?: boolean;\n  activeColor?: string;\n  shadow?: boolean;\n}\n\nconst LINE_HEIGHT = 1.3;\nconst DEPTH_EM = LINE_HEIGHT / 2;\nconst TURN_MS = 320;\nconst EXIT_MS = 280;\nconst PERSPECTIVE_EM = 10;\nconst LEGIBILITY_SHADOW =\n  \"0 2px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35)\";\n\nconst turnEasing = Easing.bezier(0.65, 0, 0.35, 1);\nconst exitEasing = Easing.bezier(0.7, 0, 0.84, 0);\n\nfunction CubeFace({\n  tokens,\n  activeIndex,\n  activeColor,\n  angle,\n  before,\n  style,\n}: {\n  tokens: CaptionTokenState[];\n  activeIndex: number;\n  activeColor: string | undefined;\n  angle: number;\n  before: string;\n  style?: CSSProperties;\n}) {\n  const facing = Math.max(0, Math.cos((angle * Math.PI) / 180));\n  return (\n    <div\n      style={{\n        whiteSpace: \"nowrap\",\n        backfaceVisibility: \"hidden\",\n        WebkitBackfaceVisibility: \"hidden\",\n        opacity: 0.35 + 0.65 * facing,\n        transform: `${before}rotateX(${angle}deg) translateZ(${DEPTH_EM}em)`,\n        ...style,\n      }}\n    >\n      {groupCaptionWords(tokens).map((word, w) => (\n        <Fragment key={word[0].index}>\n          {w > 0 && \" \"}\n          {word.map(({ index, token }) => (\n            <span\n              key={index}\n              style={{\n                color:\n                  activeColor !== undefined && index === activeIndex\n                    ? activeColor\n                    : undefined,\n              }}\n            >\n              {token.text}\n            </span>\n          ))}\n        </Fragment>\n      ))}\n    </div>\n  );\n}\n\nfunction CaptionCubeBase({\n  captions,\n  combineTokensWithinMilliseconds = 800,\n  holdMs = DEFAULT_HOLD_MS,\n  fontSize = 64,\n  fontWeight = 800,\n  color = \"#ffffff\",\n  tintActive = false,\n  activeColor = \"#facc15\",\n  shadow = true,\n  className,\n}: CaptionCubeProps) {\n  const state = useCaptions({\n    captions,\n    combineTokensWithinMilliseconds,\n    holdMs,\n  });\n  if (!state) return null;\n\n  const turnMs = Math.max(\n    1,\n    Math.min(TURN_MS, state.sinceStartMs + state.untilEndMs),\n  );\n  const turn = interpolate(state.sinceStartMs, [0, turnMs], [0, 1], {\n    easing: turnEasing,\n    extrapolateLeft: \"clamp\",\n    extrapolateRight: \"clamp\",\n  });\n  const exitProgress = state.endsInSilence\n    ? exitEasing(\n        Math.min(\n          1,\n          Math.max(0, 1 - state.untilEndMs / getExitWindowMs(state, EXIT_MS)),\n        ),\n      )\n    : 0;\n  const currentAngle = (turn - 1) * 90 + exitProgress * 90;\n\n  return (\n    <div\n      className={className}\n      style={{\n        position: \"relative\",\n        fontSize,\n        fontWeight,\n        color,\n        lineHeight: LINE_HEIGHT,\n        height: `${LINE_HEIGHT}em`,\n        textAlign: \"center\",\n        textShadow: shadow ? LEGIBILITY_SHADOW : undefined,\n        perspective: `${PERSPECTIVE_EM}em`,\n      }}\n    >\n      <div\n        style={{\n          position: \"relative\",\n          height: \"100%\",\n          transformStyle: \"preserve-3d\",\n          transform: `translateZ(${-DEPTH_EM}em)`,\n        }}\n      >\n        {state.previous && turn < 1 ? (\n          <CubeFace\n            key={`page-${state.previous.pageIndex}`}\n            tokens={state.previous.tokens}\n            activeIndex={-1}\n            activeColor={undefined}\n            angle={turn * 90}\n            before=\"translateX(-50%) \"\n            style={{ position: \"absolute\", top: 0, left: \"50%\" }}\n          />\n        ) : null}\n        <CubeFace\n          key={`page-${state.pageIndex}`}\n          tokens={state.tokens}\n          activeIndex={state.activeIndex}\n          activeColor={tintActive ? activeColor : undefined}\n          angle={currentAngle}\n          before=\"\"\n        />\n      </div>\n    </div>\n  );\n}\n\nconst elementSchema = {\n  ...Interactive.baseSchema,\n  captions: {\n    type: \"remotion-captions\",\n    default: [{\n      text: \" So\",\n      startMs: 300,\n      endMs: 460,\n      timestampMs: 380,\n      confidence: 0.97,\n    }, {\n      text: \" here's\",\n      startMs: 460,\n      endMs: 700,\n      timestampMs: 580,\n      confidence: 0.97,\n    }, {\n      text: \" the\",\n      startMs: 700,\n      endMs: 820,\n      timestampMs: 760,\n      confidence: 0.97,\n    }, {\n      text: \" thing.\",\n      startMs: 820,\n      endMs: 1240,\n      timestampMs: 1030,\n      confidence: 0.97,\n    }, {\n      text: \" Most\",\n      startMs: 1700,\n      endMs: 1960,\n      timestampMs: 1830,\n      confidence: 0.97,\n    }, {\n      text: \" demo\",\n      startMs: 1960,\n      endMs: 2240,\n      timestampMs: 2100,\n      confidence: 0.97,\n    }, {\n      text: \" videos\",\n      startMs: 2240,\n      endMs: 2680,\n      timestampMs: 2460,\n      confidence: 0.97,\n    }, {\n      text: \" lose\",\n      startMs: 2680,\n      endMs: 2960,\n      timestampMs: 2820,\n      confidence: 0.97,\n    }, {\n      text: \" people\",\n      startMs: 2960,\n      endMs: 3320,\n      timestampMs: 3140,\n      confidence: 0.97,\n    }, {\n      text: \" in\",\n      startMs: 3320,\n      endMs: 3420,\n      timestampMs: 3370,\n      confidence: 0.97,\n    }, {\n      text: \" the\",\n      startMs: 3420,\n      endMs: 3520,\n      timestampMs: 3470,\n      confidence: 0.97,\n    }, {\n      text: \" first\",\n      startMs: 3520,\n      endMs: 3820,\n      timestampMs: 3670,\n      confidence: 0.97,\n    }, {\n      text: \" three\",\n      startMs: 3820,\n      endMs: 4100,\n      timestampMs: 3960,\n      confidence: 0.97,\n    }, {\n      text: \" seconds.\",\n      startMs: 4100,\n      endMs: 4780,\n      timestampMs: 4440,\n      confidence: 0.97,\n    }, {\n      text: \" Captions\",\n      startMs: 5400,\n      endMs: 5920,\n      timestampMs: 5660,\n      confidence: 0.97,\n    }, {\n      text: \" keep\",\n      startMs: 5920,\n      endMs: 6140,\n      timestampMs: 6030,\n      confidence: 0.97,\n    }, {\n      text: \" them\",\n      startMs: 6140,\n      endMs: 6300,\n      timestampMs: 6220,\n      confidence: 0.97,\n    }, {\n      text: \" watching,\",\n      startMs: 6300,\n      endMs: 6860,\n      timestampMs: 6580,\n      confidence: 0.97,\n    }, {\n      text: \" even\",\n      startMs: 6960,\n      endMs: 7180,\n      timestampMs: 7070,\n      confidence: 0.97,\n    }, {\n      text: \" with\",\n      startMs: 7180,\n      endMs: 7320,\n      timestampMs: 7250,\n      confidence: 0.97,\n    }, {\n      text: \" the\",\n      startMs: 7320,\n      endMs: 7420,\n      timestampMs: 7370,\n      confidence: 0.97,\n    }, {\n      text: \" sound\",\n      startMs: 7420,\n      endMs: 7760,\n      timestampMs: 7590,\n      confidence: 0.97,\n    }, {\n      text: \" off.\",\n      startMs: 7760,\n      endMs: 8300,\n      timestampMs: 8030,\n      confidence: 0.97,\n    }],\n    description: \"Transcript\",\n    keyframable: false,\n  },\n  fontSize: {\n    type: \"number\",\n    min: 24,\n    max: 140,\n    step: 1,\n    default: 64,\n    description: \"Font size\",\n    hiddenFromList: false,\n  },\n  fontWeight: {\n    type: \"number\",\n    min: 400,\n    max: 900,\n    step: 100,\n    default: 800,\n    description: \"Font weight\",\n    hiddenFromList: false,\n  },\n  color: {\n    type: \"color\",\n    default: \"#ffffff\",\n    description: \"Text color\",\n  },\n  tintActive: {\n    type: \"boolean\",\n    default: false,\n    description: \"Tint active word\",\n  },\n  activeColor: {\n    type: \"color\",\n    default: \"#facc15\",\n    description: \"Active color\",\n  },\n  combineTokensWithinMilliseconds: {\n    type: \"number\",\n    min: 0,\n    max: 3000,\n    step: 100,\n    default: 800,\n    description: \"Page window (ms)\",\n    hiddenFromList: false,\n  },\n  holdMs: {\n    type: \"number\",\n    min: 0,\n    max: 2000,\n    step: 50,\n    default: 600,\n    description: \"Hold (ms)\",\n    hiddenFromList: false,\n  },\n  shadow: {\n    type: \"boolean\",\n    default: true,\n    description: \"Shadow\",\n  },\n  ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"captions\",\"fontSize\",\"fontWeight\",\"color\",\"tintActive\",\"activeColor\",\"combineTokensWithinMilliseconds\",\"holdMs\",\"shadow\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n  captions: [{\n    text: \" So\",\n    startMs: 300,\n    endMs: 460,\n    timestampMs: 380,\n    confidence: 0.97,\n  }, {\n    text: \" here's\",\n    startMs: 460,\n    endMs: 700,\n    timestampMs: 580,\n    confidence: 0.97,\n  }, {\n    text: \" the\",\n    startMs: 700,\n    endMs: 820,\n    timestampMs: 760,\n    confidence: 0.97,\n  }, {\n    text: \" thing.\",\n    startMs: 820,\n    endMs: 1240,\n    timestampMs: 1030,\n    confidence: 0.97,\n  }, {\n    text: \" Most\",\n    startMs: 1700,\n    endMs: 1960,\n    timestampMs: 1830,\n    confidence: 0.97,\n  }, {\n    text: \" demo\",\n    startMs: 1960,\n    endMs: 2240,\n    timestampMs: 2100,\n    confidence: 0.97,\n  }, {\n    text: \" videos\",\n    startMs: 2240,\n    endMs: 2680,\n    timestampMs: 2460,\n    confidence: 0.97,\n  }, {\n    text: \" lose\",\n    startMs: 2680,\n    endMs: 2960,\n    timestampMs: 2820,\n    confidence: 0.97,\n  }, {\n    text: \" people\",\n    startMs: 2960,\n    endMs: 3320,\n    timestampMs: 3140,\n    confidence: 0.97,\n  }, {\n    text: \" in\",\n    startMs: 3320,\n    endMs: 3420,\n    timestampMs: 3370,\n    confidence: 0.97,\n  }, {\n    text: \" the\",\n    startMs: 3420,\n    endMs: 3520,\n    timestampMs: 3470,\n    confidence: 0.97,\n  }, {\n    text: \" first\",\n    startMs: 3520,\n    endMs: 3820,\n    timestampMs: 3670,\n    confidence: 0.97,\n  }, {\n    text: \" three\",\n    startMs: 3820,\n    endMs: 4100,\n    timestampMs: 3960,\n    confidence: 0.97,\n  }, {\n    text: \" seconds.\",\n    startMs: 4100,\n    endMs: 4780,\n    timestampMs: 4440,\n    confidence: 0.97,\n  }, {\n    text: \" Captions\",\n    startMs: 5400,\n    endMs: 5920,\n    timestampMs: 5660,\n    confidence: 0.97,\n  }, {\n    text: \" keep\",\n    startMs: 5920,\n    endMs: 6140,\n    timestampMs: 6030,\n    confidence: 0.97,\n  }, {\n    text: \" them\",\n    startMs: 6140,\n    endMs: 6300,\n    timestampMs: 6220,\n    confidence: 0.97,\n  }, {\n    text: \" watching,\",\n    startMs: 6300,\n    endMs: 6860,\n    timestampMs: 6580,\n    confidence: 0.97,\n  }, {\n    text: \" even\",\n    startMs: 6960,\n    endMs: 7180,\n    timestampMs: 7070,\n    confidence: 0.97,\n  }, {\n    text: \" with\",\n    startMs: 7180,\n    endMs: 7320,\n    timestampMs: 7250,\n    confidence: 0.97,\n  }, {\n    text: \" the\",\n    startMs: 7320,\n    endMs: 7420,\n    timestampMs: 7370,\n    confidence: 0.97,\n  }, {\n    text: \" sound\",\n    startMs: 7420,\n    endMs: 7760,\n    timestampMs: 7590,\n    confidence: 0.97,\n  }, {\n    text: \" off.\",\n    startMs: 7760,\n    endMs: 8300,\n    timestampMs: 8030,\n    confidence: 0.97,\n  }],\n  fontSize: 64,\n  fontWeight: 800,\n  color: \"#ffffff\",\n  tintActive: false,\n  activeColor: \"#facc15\",\n  combineTokensWithinMilliseconds: 800,\n  holdMs: 600,\n  shadow: true,\n};\n\ntype CaptionCubeElementProps = InteractiveBaseProps &\n  InteractiveTransformProps &\n  ComponentProps<typeof CaptionCubeBase>;\n\nconst CaptionCubeInner = forwardRef<\n  HTMLDivElement,\n  CaptionCubeElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n  const outlineRef = useRef<HTMLDivElement>(null);\n  useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n  const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n  const sequenceProps: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(rest)) {\n    if (ELEMENT_PROP_KEYS.has(key)) {\n      if (value !== undefined) componentProps[key] = value;\n    } else {\n      sequenceProps[key] = value;\n    }\n  }\n  return (\n    <Sequence\n      layout=\"none\"\n      {...sequenceProps}\n      controls={controls}\n      name={name ?? \"<CaptionCube>\"}\n      outlineRef={outlineRef}\n    >\n      <div\n        ref={outlineRef}\n        style={{\n          position: \"relative\",\n          width: \"100%\",\n          height: \"100%\",\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          ...style,\n        }}\n      >\n        <CaptionCubeBase\n          {...(componentProps as unknown as ComponentProps<typeof CaptionCubeBase>)}\n        />\n      </div>\n    </Sequence>\n  );\n});\n\nexport const CaptionCube = Interactive.withSchema({\n  Component: CaptionCubeInner,\n  componentName: \"<CaptionCube>\",\n  componentIdentity: null,\n  schema: elementSchema,\n  supportsEffects: false,\n});\n",
    "durationInFrames": 279,
    "installationMode": "component-owned-sequence",
    "isCaptionStyle": true
  },
  "durationInFrames": 279
}