'use client' import { ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, CheckIcon, MinusIcon, PlusIcon, } from 'lucide-react' import { useEffect, useId, useMemo, useRef, useState, type PointerEvent } from 'react' import { canvasToPngBlob, cardFileName, downloadBlob, ensureCardFont, loadCardImage, loadCardPhoto, } from '@/components/cards/cardCanvas' import { CARD_COLINHA_PRIVACY_NOTE, CARD_HARMONY_HELP, CARD_HARMONY_LABEL, CARD_PHOTO_PRIVACY_NOTE, CARD_PRIVACY_NOTE, } from '@/components/cards/cardCopy' import { CardPreviewCanvas } from '@/components/cards/CardPreviewCanvas' import { StateDeputySelect } from '@/components/cards/StateDeputySelect' import { useCardCutout } from '@/components/cards/useCardCutout' import { DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { DrawerDescription, DrawerHeader, DrawerTitle } from '@/components/ui/Drawer' import { COLINHA_ESTADUAL_LABEL, COLINHA_FONT_FAMILY } from '@/lib/cardColinha' import { TEAM_CARD_NAME_SLOT, type CardModel, type CardRect } from '@/lib/cardModels' import { fitCardName, type CardNameFit } from '@/lib/cardNameFit' import { CARD_PHOTO_MAX_ZOOM, CARD_PHOTO_MIN_ZOOM, cardPhotoTransformsEqual, centerCardPhotoTransform, panCardPhotoTransform, zoomCardPhotoTransform, type CardPhotoSize, type CardPhotoTransform, } from '@/lib/cardPhotoTransform' import { createCardMeasure, renderColinhaCard, renderNameCard, renderPhotoCard, renderTeamCard, } from '@/lib/cardRender' import { sendCardDownloadEvent } from '@/lib/contentEvents' import { getStateDeputyCard, type StateDeputyCatalogEntry } from '@/lib/stateDeputyCatalog' const primaryButtonClassName = 'inline-flex min-h-11 flex-1 items-center justify-center rounded-lg bg-(--pt-red) px-5 text-sm font-extrabold text-white transition hover:brightness-95 focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50' const secondaryButtonClassName = 'inline-flex min-h-11 flex-1 items-center justify-center rounded-lg border-2 border-(--campaign-line) bg-white px-5 text-sm font-extrabold text-(--pt-red) transition-colors hover:bg-(--campaign-band) focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:ring-offset-2 focus-visible:outline-none' const controlButtonClassName = 'inline-flex size-11 items-center justify-center rounded-lg border border-(--campaign-line) bg-white text-(--campaign-ink) transition-colors hover:bg-(--campaign-band) focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:outline-none' const NAME_TOO_LONG_MESSAGE = 'Não foi possível encaixar esse nome no card. Use um nome mais curto, como você é chamado.' /** S15 design gate: the team preview width per state (S17 ready: 180px mobile / 240px desktop). */ type TeamPreviewStage = 'idle' | 'processing' | 'ready' | 'result' const TEAM_PREVIEW_WIDTH: Record = { idle: 'max-w-[10.75rem]', processing: 'max-w-[9rem]', ready: 'max-w-[11.25rem] sm:max-w-[15rem]', result: 'max-w-[11.875rem]', } /** * S30 — the dobradinha preview gets the gate's larger stage (scene 4: 230px * desktop; scene 5: 205px mobile) while the S15 tokens above stay untouched. * `selected` is the chosen-but-photoless state, which the gate draws at the same * prominence as the result; the pre-selection and the too-long error stay * compact (scenes 3 and 4-right). */ type StateDeputyPreviewStage = TeamPreviewStage | 'selected' const STATE_DEPUTY_PREVIEW_WIDTH: Record = { idle: 'max-w-[10.75rem]', processing: 'max-w-[9rem]', ready: 'max-w-[12.8125rem] sm:max-w-[15rem]', result: 'max-w-[12.8125rem] sm:max-w-[14.375rem]', selected: 'max-w-[12.8125rem] sm:max-w-[14.375rem]', } /** * S31/S34 — the colinha stages of the design gate: the delivered art while the * estadual is unchosen (scene 1: 236px desktop / scene 2: 248px mobile) and the * scene 3/5 stage after the pick (405px desktop, 300px mobile). */ const COLINHA_PREVIEW_WIDTH: Record<'idle' | 'selected', string> = { idle: 'max-w-[15.5rem] sm:max-w-[14.75rem]', selected: 'max-w-[18.75rem] sm:max-w-[25.3125rem]', } const TeamNameField = ({ id, value, onChange, error, inputClassName, }: { id: string value: string onChange: (value: string) => void error: boolean inputClassName: string }) => (
onChange(event.target.value)} autoComplete="off" maxLength={60} placeholder="Como você é chamado" aria-invalid={error} className={inputClassName} />

Vai aparecer em caixa alta depois de “TIME DE”. Use um nome curto e conhecido.

{error ? (

{NAME_TOO_LONG_MESSAGE}

) : null}
) /** * S17 — the tone-harmony switch of the ready state. Native `role="switch"` (the * design gate's semantics; the studio has no shadcn Switch) with the whole row * as the target and the label/help always visible. */ const TeamHarmonySwitch = ({ enabled, onToggle }: { enabled: boolean; onToggle: () => void }) => { const helpId = useId() return ( ) } type CardComposerProps = { model: CardModel shell: 'dialog' | 'drawer' fontFamily: string onClose: () => void } export const CardComposer = ({ model, shell, fontFamily, onClose }: CardComposerProps) => { const [step, setStep] = useState<'compose' | 'result'>('compose') const [name, setName] = useState('') const [nameFit, setNameFit] = useState(null) const [photo, setPhoto] = useState(null) const [photoTransform, setPhotoTransform] = useState(null) const [photoError, setPhotoError] = useState(null) const [loadState, setLoadState] = useState<'loading' | 'ready' | 'error'>('loading') const [baseImage, setBaseImage] = useState(null) const [overlayImage, setOverlayImage] = useState(null) const [previewImage, setPreviewImage] = useState(null) const [downloadError, setDownloadError] = useState(null) const [isDownloading, setIsDownloading] = useState(false) /** S17 — LIGADO by default; resets only when the composer unmounts (no persistence). */ const [harmonyEnabled, setHarmonyEnabled] = useState(true) /** S30 — the state deputy of the dobradinha model (name/number/art pair). */ const [selectedDeputySlug, setSelectedDeputySlug] = useState(null) const [deputyImages, setDeputyImages] = useState<{ slug: string photos: HTMLImageElement base: HTMLImageElement } | null>(null) const [deputyAssetError, setDeputyAssetError] = useState(false) /** Bumped when the same deputy is re-picked after a pair load failure. */ const [deputyReloadToken, setDeputyReloadToken] = useState(0) const canvasRef = useRef(null) const fileInputRef = useRef(null) const dragRef = useRef<{ pointerId: number; x: number; y: number } | null>(null) const nameInputId = useId() const zoomInputId = useId() const photoWindow = model.photoWindow /** S33 — the model's adjustment policy: the two team models are position-free. */ const photoPosition = model.photoPosition ?? 'bounded' const isNameModel = model.kind === 'name' const isTeamModel = model.kind === 'team' const isColinhaModel = model.kind === 'colinha' const isStateDeputyModel = isTeamModel && model.stateDeputyPicker === true const selectedDeputy = selectedDeputySlug ? (getStateDeputyCard(selectedDeputySlug) ?? null) : null const deputyPairReady = selectedDeputy !== null && deputyImages?.slug === selectedDeputy.slug // S30 — the tone reference is the selected deputy's group art, frozen when the // cutout starts (switching the deputy later keeps the processed photo). const cutout = useCardCutout( photoWindow, isStateDeputyModel ? selectedDeputy?.photosSrc : isTeamModel ? model.assetSrc : undefined, ) const cutoutState = cutout.state const teamProcessing = cutoutState.status === 'processing' ? cutoutState : null const teamError = cutoutState.status === 'error' ? cutoutState : null const teamReady = cutoutState.status === 'ready' ? cutoutState : null const photoSize = useMemo( () => (photo ? { width: photo.naturalWidth, height: photo.naturalHeight } : null), [photo], ) const transformSourceSize = useMemo(() => { if (!isTeamModel) return photoSize return teamReady ? { width: teamReady.width, height: teamReady.height } : null }, [isTeamModel, photoSize, teamReady]) /** * The cutout carries the initial framing; local state takes over after the * first pan/zoom. Deriving (instead of mirroring through an effect) keeps the * first ready paint composed — no bare-base frame. */ const effectiveTransform = isTeamModel ? (photoTransform ?? teamReady?.transform ?? null) : photoTransform // Assets + font load once per model: typing/panning must not flip the preview // back into the loading state (flicker) nor re-announce the live region. useEffect(() => { let cancelled = false setLoadState('loading') setBaseImage(null) setOverlayImage(null) setPreviewImage(null) const load = async () => { try { const fontReady = await ensureCardFont(fontFamily) if (!fontReady) throw new Error('card-font-unavailable') // S30 — the dobradinha model loads its art pair per selection (below); // the static defaults stay unused so no illustrative JULIO art flashes // before the choice. S34 — the colinha draws the approved art as the // base and carries no `previewSrc` (the tile falls back to `assetSrc`). const [image, overlay, preview] = await Promise.all([ isStateDeputyModel ? Promise.resolve(null) : loadCardImage(model.assetSrc), !isStateDeputyModel && model.overlaySrc ? loadCardImage(model.overlaySrc) : Promise.resolve(null), model.previewSrc ? loadCardImage(model.previewSrc) : Promise.resolve(null), ]) if (cancelled) return setBaseImage(image) setOverlayImage(overlay) setPreviewImage(preview) setLoadState('ready') } catch { if (!cancelled) setLoadState('error') } } void load() return () => { cancelled = true } }, [ isStateDeputyModel, isColinhaModel, model.assetSrc, model.overlaySrc, model.previewSrc, fontFamily, ]) /** * S30 — the selected deputy's pair swaps in place: the previous art stays * painted until both files decode (no loading state, no flicker) and the name * and cutout states are untouched by the swap. */ useEffect(() => { if (!isStateDeputyModel || !selectedDeputy) return let cancelled = false setDeputyAssetError(false) const load = async () => { try { const [photos, base] = await Promise.all([ loadCardImage(selectedDeputy.photosSrc), loadCardImage(selectedDeputy.baseSrc), ]) if (cancelled) return setDeputyImages({ slug: selectedDeputy.slug, photos, base }) } catch { if (!cancelled) setDeputyAssetError(true) } } void load() return () => { cancelled = true } }, [isStateDeputyModel, selectedDeputy, deputyReloadToken]) useEffect(() => { const ctx = canvasRef.current?.getContext('2d') if (!ctx || loadState !== 'ready') return const measure = createCardMeasure(ctx, fontFamily) if (isNameModel) { if (!baseImage) return ctx.clearRect(0, 0, model.width, model.height) setNameFit(renderNameCard(ctx, model, { image: baseImage, name, fontFamily, measure })) return } if (isColinhaModel) { // S34 — the approved art is the base; only the estadual row is drawn over // it (or nothing, before a pick). No name, photo or cutout enters this flow. if (!baseImage) return ctx.clearRect(0, 0, model.width, model.height) renderColinhaCard(ctx, model, { image: baseImage, deputy: selectedDeputy, fontFamily: COLINHA_FONT_FAMILY, measure: createCardMeasure(ctx, COLINHA_FONT_FAMILY, 900), }) return } if (isTeamModel) { // S30 — the dobradinha pair comes from the selected catalog entry: `photos` // is the FOTOS background (drawn under the cutout) and `base` is the front // BASE overlay (drawn above it) — the opposite of the S15 masters. const artBase = isStateDeputyModel ? deputyImages?.photos : baseImage const artOverlay = isStateDeputyModel ? deputyImages?.base : overlayImage if (isStateDeputyModel && !selectedDeputy) { // Before the choice: the approved example art (no banners), exactly the // gate's scene 3 placeholder. ctx.clearRect(0, 0, model.width, model.height) setNameFit(fitCardName(name, measure, TEAM_CARD_NAME_SLOT)) if (previewImage) ctx.drawImage(previewImage, 0, 0, model.width, model.height) return } // Art not decoded yet (first selection or a swap in flight): keep the // current frame painted instead of clearing to a bare canvas. if (!artBase || !artOverlay) return ctx.clearRect(0, 0, model.width, model.height) if (teamReady && effectiveTransform && photoWindow) { const result = renderTeamCard(ctx, model, { base: artBase, overlay: artOverlay, subject: { photo: harmonyEnabled && teamReady.harmonized ? teamReady.harmonized : teamReady.canvas, photoSize: { width: teamReady.width, height: teamReady.height }, transform: effectiveTransform, }, window: photoWindow, name, fontFamily, measure, }) setNameFit(result.fit) if (result.transform && !cardPhotoTransformsEqual(result.transform, effectiveTransform)) { setPhotoTransform(result.transform) } return } if (isStateDeputyModel) { // Chosen but no photo yet: the art shows as-is — the window stays empty // until the visitor photo lands (no drawn placeholder). if (!photoWindow) return setNameFit( renderTeamCard(ctx, model, { base: artBase, overlay: artOverlay, subject: null, window: photoWindow, name, fontFamily, measure, }).fit, ) return } setNameFit(fitCardName(name, measure, TEAM_CARD_NAME_SLOT)) const idleImage = cutoutState.status === 'idle' && previewImage ? previewImage : artBase ctx.drawImage(idleImage, 0, 0, model.width, model.height) return } if (!baseImage) return ctx.clearRect(0, 0, model.width, model.height) if (photo && effectiveTransform && photoWindow && photoSize) { const clamped = renderPhotoCard(ctx, { photo, frame: baseImage, photoSize, frameSize: { width: model.width, height: model.height }, window: photoWindow, transform: effectiveTransform, }) if (!cardPhotoTransformsEqual(clamped, effectiveTransform)) { setPhotoTransform(clamped) } return } if (photoWindow) { ctx.fillStyle = '#ded8d2' ctx.fillRect(0, 0, model.width, model.height) ctx.drawImage(baseImage, 0, 0, model.width, model.height) } }, [ baseImage, overlayImage, previewImage, loadState, isNameModel, isTeamModel, isColinhaModel, isStateDeputyModel, selectedDeputy, deputyImages, teamReady, harmonyEnabled, cutoutState.status, model, name, fontFamily, photo, photoSize, effectiveTransform, photoWindow, ]) const handlePhotoFile = async (file: File | undefined) => { if (!file || !photoWindow) return setPhotoError(null) try { const image = await loadCardPhoto(file) setPhoto(image) setPhotoTransform( centerCardPhotoTransform( { width: image.naturalWidth, height: image.naturalHeight }, photoWindow, ), ) } catch { setPhoto(null) setPhotoTransform(null) setPhotoError('Não foi possível usar esta foto. Escolha outra imagem e tente novamente.') } finally { if (fileInputRef.current) fileInputRef.current.value = '' } } const handleTeamPhotoFile = (file: File | undefined) => { if (!file) return setPhotoError(null) setPhotoTransform(null) void cutout.start(file) if (fileInputRef.current) fileInputRef.current.value = '' } /** S30 — the swap keeps name and processed photo (only the art pair changes). */ const handleSelectDeputy = (card: StateDeputyCatalogEntry) => { // Re-picking the same entry after a pair failure must retry the load. if (card.slug === selectedDeputySlug) setDeputyReloadToken((token) => token + 1) setSelectedDeputySlug(card.slug) } /** Applies a pan/zoom update over the derived or user-owned transform. */ const withTransform = ( update: ( transform: CardPhotoTransform, size: CardPhotoSize, window: CardRect, ) => CardPhotoTransform, ) => { if (!transformSourceSize || !photoWindow) return setPhotoTransform((current) => { const base = current ?? (isTeamModel ? (teamReady?.transform ?? null) : null) return base ? update(base, transformSourceSize, photoWindow) : base }) } const handlePointerDown = (event: PointerEvent) => { if (!transformSourceSize || !photoWindow) return dragRef.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY } event.currentTarget.setPointerCapture(event.pointerId) } const handlePointerMove = (event: PointerEvent) => { const drag = dragRef.current const canvas = canvasRef.current if (!drag || drag.pointerId !== event.pointerId || !canvas) return const scale = model.width / Math.max(1, canvas.getBoundingClientRect().width) const dx = (event.clientX - drag.x) * scale const dy = (event.clientY - drag.y) * scale dragRef.current = { ...drag, x: event.clientX, y: event.clientY } withTransform((transform, size, window) => panCardPhotoTransform(transform, size, window, dx, dy, { position: photoPosition }), ) } const handlePointerEnd = () => { dragRef.current = null } const panBy = (dx: number, dy: number) => { withTransform((transform, size, window) => panCardPhotoTransform(transform, size, window, dx, dy, { position: photoPosition }), ) } const zoomTo = (zoom: number) => { withTransform((transform, size, window) => zoomCardPhotoTransform(transform, size, window, zoom, undefined, { position: photoPosition }), ) } const handleDownload = async () => { const canvas = canvasRef.current if (!canvas) return setIsDownloading(true) setDownloadError(null) try { const blob = await canvasToPngBlob(canvas) downloadBlob(blob, cardFileName(model.id)) // S32 — anonymous download count (fire-and-forget, never blocks/throws); // the state-deputy slug rides along on the models that have a picker. sendCardDownloadEvent(model.id, selectedDeputy?.slug ?? null) } catch { setDownloadError('Não foi possível gerar o arquivo agora. Tente de novo.') } finally { setIsDownloading(false) } } const nameCanAdvance = nameFit?.ok === true const canAdvance = isColinhaModel ? selectedDeputy !== null : isNameModel ? nameCanAdvance : isStateDeputyModel ? selectedDeputy !== null && deputyPairReady && teamReady !== null && nameCanAdvance : isTeamModel ? teamReady !== null && nameCanAdvance : photo !== null const nameError = (isNameModel || isTeamModel) && name.trim().length > 0 && nameFit !== null && !nameFit.ok const adjustable = isStateDeputyModel ? deputyPairReady && teamReady !== null : isTeamModel ? teamReady !== null : photo !== null const title = (() => { if (step === 'result') return 'Seu card está pronto para compartilhar.' if (isNameModel) return 'Personalize com seu nome' if (isColinhaModel) { if (!selectedDeputy) return 'Escolha seu estadual' return shell === 'dialog' ? 'Pronta para levar com você' : 'Pronta para baixar' } if (isStateDeputyModel && !selectedDeputy) return 'Escolha sua dobradinha' if (!isTeamModel) return 'Enquadre sua foto' if (teamProcessing) return 'Preparando sua foto' if (teamError) return 'Vamos tentar outra vez' if (nameError) return 'Encurte o nome' if (teamReady) return 'Confira seu card' if (isStateDeputyModel) return 'Agora coloque seu nome' return 'Entre para o time' })() const photoHeaderDescription = step === 'compose' && !isNameModel && !isTeamModel && !isColinhaModel ? 'Arraste para posicionar e use os controles para aproximar ou ajustar.' : null const stateDeputyHeaderDescription = isStateDeputyModel && step === 'compose' && !selectedDeputy ? 'Escolha seu estadual da dobradinha.' : null /** * S31 — the colinha description lives only in the dialog: the gate's mobile * drawer (scene 5) carries eyebrow + title only, so the compact preview keeps * the selector in the first viewport. */ const colinhaHeaderDescription = isColinhaModel && step === 'compose' && shell === 'dialog' ? selectedDeputy ? 'Confira o estadual escolhido. As demais escolhas já vêm preenchidas no modelo oficial.' : 'A linha de deputado estadual será preenchida na hora.' : null const headerDescription = photoHeaderDescription ?? stateDeputyHeaderDescription ?? colinhaHeaderDescription const teamBodyNotice = isTeamModel && step === 'compose' && teamReady && !nameError ? 'O recorte já foi centralizado. Se precisar, arraste a foto ou use os controles.' : null const ShellDescription = shell === 'dialog' ? DialogDescription : DrawerDescription const eyebrow = isColinhaModel ? 'Minha colinha' : isTeamModel ? step === 'result' ? 'Tudo certo' : teamError ? 'Falha no recorte' : nameError ? 'Nome muito longo' : isStateDeputyModel ? selectedDeputy ? 'Estadual escolhido' : 'Time do estadual' : 'Time de você' : null const eyebrowNode = eyebrow ? (

{eyebrow}

) : null // The dialog header takes the available row width so the close button // sits on the right edge (S35 design gate). The drawer header defaults to // centered + `shrink-0`, so `text-left!` + `flex-1` port the gate // (left-aligned, wrapped header) for every model in the shared composer. const header = shell === 'dialog' ? ( {eyebrowNode} {title} {headerDescription ? {headerDescription} : null} ) : ( {eyebrowNode} {title} {headerDescription ? {headerDescription} : null} ) const teamPreviewStage: TeamPreviewStage = step === 'result' ? 'result' : teamReady ? 'ready' : teamProcessing ? 'processing' : 'idle' const stateDeputyPreviewStage: StateDeputyPreviewStage = teamPreviewStage === 'idle' && selectedDeputy && !nameError ? 'selected' : teamPreviewStage const previewWidthClassName = isColinhaModel ? selectedDeputy ? COLINHA_PREVIEW_WIDTH.selected : COLINHA_PREVIEW_WIDTH.idle : isStateDeputyModel ? STATE_DEPUTY_PREVIEW_WIDTH[stateDeputyPreviewStage] : isTeamModel ? TEAM_PREVIEW_WIDTH[teamPreviewStage] : 'max-w-[22rem]' /** * S34 designer critique (c) — the filled desktop state follows the gate's * scene 3 composition: the full 9:16 preview beside the controls (two-column * grid, wider dialog), never clipped by the footer. The empty state keeps the * compact dialog of scene 1. The `data-colinha-filled` attribute below is the * contract that widens the dialog in `CardsStudio` (`has-[[...]]`). */ const colinhaFilledDialog = isColinhaModel && shell === 'dialog' && selectedDeputy !== null /** * S34 — caps the colinha preview by the viewport so the whole 9:16 fits * between the dialog chrome (`max-h-[92dvh]` in `CardsStudio` minus ~224px of * header/footer); on tall viewports the width reaches the gate's 405px. */ const colinhaPreviewMaxHeight = 'max-h-[calc(92dvh-14rem)]' const nameInputClassName = `mt-2 h-11 w-full rounded-lg bg-white px-3 text-base text-(--campaign-ink) focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:outline-none ${ nameError ? 'border-2 border-(--pt-red)' : 'border border-(--field-border) focus-visible:border-(--pt-red)' }` const zoomAndPanControls = effectiveTransform ? ( <>
zoomTo(Number(event.target.value))} className="h-11 w-full flex-1 accent-(--pt-red)" />

Ajuste fino

) : null // S23 design gate (scene 02): the drawer body carries a scroll tail so the // team notice leaves the viewport by the end of the scroll. const bodyScrollClassName = `min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 ${ teamBodyNotice && shell === 'drawer' ? 'pb-14' : 'pb-5' }${colinhaFilledDialog ? ' sm:grid sm:grid-cols-[430px_1fr] sm:items-start sm:gap-8' : ''}` return (
{header}

{loadState === 'loading' ? 'Carregando prévia…' : ''}

{teamBodyNotice ? ( {teamBodyNotice} ) : null}
{ const step = event.shiftKey ? 48 : 12 const deltas: Record = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step], } const delta = deltas[event.key] if (!delta) return event.preventDefault() panBy(delta[0], delta[1]) } : undefined } >
{loadState === 'error' ? (

Não foi possível carregar o modelo. Recarregue a página e tente de novo.

) : null} {step === 'compose' && isStateDeputyModel ? (
{!selectedDeputy ? (

A silhueta marca o lugar da sua foto. O card final usa a arte do estadual escolhido.

) : null} {deputyAssetError ? (

Não foi possível carregar a arte deste estadual. Escolha outro e tente de novo.

) : null}
) : null} {step === 'compose' && isColinhaModel ? (
{selectedDeputy ? (

Linha conferida

{COLINHA_ESTADUAL_LABEL} · {selectedDeputy.name.toLocaleUpperCase('pt-BR')} ·{' '} {selectedDeputy.ballotNumber}

) : (

Escolha um estadual para baixar. A linha vazia será preenchida com o nome e os cinco dígitos.

)}

{CARD_COLINHA_PRIVACY_NOTE}

{downloadError ? (

{downloadError}

) : null}
) : null} {step === 'compose' && isNameModel ? (
setName(event.target.value)} autoComplete="off" maxLength={60} className="mt-2 h-11 w-full rounded-lg border border-(--field-border) bg-white px-3 text-base text-(--campaign-ink) focus-visible:border-(--pt-red) focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:outline-none" />

Use seu primeiro nome ou o nome pelo qual as pessoas conhecem você.

{nameError ? (

{NAME_TOO_LONG_MESSAGE}

) : null}

{CARD_PRIVACY_NOTE}

) : null} {step === 'compose' && isTeamModel && !teamProcessing && !teamReady && !teamError ? (
{isStateDeputyModel && !selectedDeputy ? (

Escolha um estadual para continuar. A prévia e o download usam a arte oficial da dobradinha escolhida.

) : (

Sua foto de busto

Para um recorte melhor, escolha uma foto nítida, de frente e com fundo simples.

)}

{CARD_PRIVACY_NOTE}

) : null} {step === 'compose' && teamProcessing ? (

{teamProcessing.phase === 'download' ? 'Baixando o modelo de recorte…' : 'Removendo o fundo da foto…'}

Na primeira vez, o modelo precisa ser baixado. Depois, vamos remover o fundo da foto no seu aparelho. Isso pode levar um pouco.

{CARD_PHOTO_PRIVACY_NOTE}

) : null} {step === 'compose' && teamError ? (

{teamError.reason === 'unsupported' ? 'Seu navegador está bloqueando o recorte de fundo.' : 'Não foi possível remover o fundo desta foto.'}

{teamError.reason === 'unsupported' ? 'O recorte roda no seu aparelho e precisa de WebAssembly e WebGL, que navegadores com proteções avançadas (como IronFox e Tor) desligam por padrão. Ative essas opções para este site nas configurações do navegador — ou abra a página em outro navegador — e toque em “Tentar de novo”.' : 'Tente de novo ou escolha outra foto.'}

{teamError.reason === 'unsupported' ? null : (

Fotos de busto, nítidas e com fundo simples costumam funcionar melhor.

)}

{CARD_PHOTO_PRIVACY_NOTE}

) : null} {step === 'compose' && teamReady && photoWindow && transformSourceSize ? (
{nameError ? ( <>

A foto escolhida e o recorte permanecem salvos neste aparelho enquanto você corrige o nome.

) : ( <> {zoomAndPanControls} {teamReady.harmonized ? ( setHarmonyEnabled((enabled) => !enabled)} /> ) : null}

{CARD_PHOTO_PRIVACY_NOTE}

)}
) : null} {step === 'compose' && !isNameModel && !isTeamModel && photoWindow ? (
{photo && effectiveTransform ? ( zoomAndPanControls ) : (

Escolha uma foto vertical ou horizontal para começar.

)} {photoError ? (

Não foi possível usar esta foto

Escolha outra imagem e tente novamente.

) : null}

{CARD_PHOTO_PRIVACY_NOTE}

) : null} isTeamModel ? handleTeamPhotoFile(event.target.files?.[0]) : void handlePhotoFile(event.target.files?.[0]) } /> {step === 'result' ? (
{isTeamModel ? ( <> {isStateDeputyModel && selectedDeputy ? (

{selectedDeputy.name} · {selectedDeputy.ballotNumber}

) : null}

{CARD_PRIVACY_NOTE}

) : (

{CARD_PRIVACY_NOTE}

)} {downloadError ? (

{downloadError}

) : null}
) : null}
{step === 'compose' ? ( <> {isColinhaModel && shell === 'drawer' ? null : ( )} ) : ( <> )}
) }