import { useEffect, useState } from "react"; import type { Asset } from "@core/asset"; import type { AppStore } from "@editor/store"; import { analyzeMask, runMaskOperation, type MaskAnalysis, type MaskRasterOperation } from "@operations/masks/rasterActions"; export function MaskStatus({ asset }: { asset: Asset }) { const [analysis, setAnalysis] = useState(); useEffect(() => { let cancelled = false; void analyzeMask(asset) .then((nextAnalysis) => { if (!cancelled) setAnalysis(nextAnalysis); }) .catch(() => { if (!cancelled) setAnalysis(undefined); }); return () => { cancelled = true; }; }, [asset.source, asset.intrinsicSize.w, asset.intrinsicSize.h]); if (!analysis) return Reading; return ( Reveal {formatPercent(analysis.coverage)} Inpaint {formatPercent(analysis.hiddenCoverage)} ); } export function MaskOperationButtons({ maskLayerId, maskAsset, dispatch }: { maskLayerId: string; maskAsset: Asset; dispatch: AppStore["dispatch"] }) { return ( <> ); } function MaskOperationButton({ label, title, maskLayerId, maskAsset, operation, dispatch, }: { label: string; title: string; maskLayerId: string; maskAsset: Asset; operation: MaskRasterOperation; dispatch: AppStore["dispatch"]; }) { const [busy, setBusy] = useState(false); return ( ); } function maskActionButtonClass() { return "rounded-full bg-white/5 px-2.5 py-1 text-[0.7rem] font-semibold text-white/60 transition hover:bg-white/10 hover:text-white disabled:pointer-events-none disabled:opacity-35"; } function formatPercent(value: number) { return `${Math.round(value * 100)}%`; }