import React, { useState } from "react"; import CodeBlock from "@theme/CodeBlock"; import ConfigTabs from "@site/src/components/ConfigTabs"; import TabItem from "@theme/TabItem"; import { marked } from "marked"; import styles from "./styles.module.css"; marked.setOptions({ gfm: true }); /** * @typedef {Object} Model * @property {string} key * @property {string} label * @property {boolean} recommended * @property {string} download Markdown for the "download the model" step. * @property {string} ui Markdown for the Frigate UI configuration step. * @property {string} yaml Raw YAML for the configuration step. */ // marked does not understand Docusaurus admonitions (:::warning ... :::), so // render those blocks ourselves and marked-parse everything around them. function renderMarkdown(md) { if (!md) return ""; const admonition = /:::(\w+)[ \t]*([^\n]*)\n([\s\S]*?)\n:::/g; let html = ""; let lastIndex = 0; let match; while ((match = admonition.exec(md)) !== null) { html += marked.parse(md.slice(lastIndex, match.index)); const [, type, title, body] = match; const heading = (title || type).trim(); html += `
` + `
${heading}
` + marked.parse(body) + `
`; lastIndex = admonition.lastIndex; } html += marked.parse(md.slice(lastIndex)); return html; } function Markdown({ children }) { return (
); } function RecommendedBadge() { return Recommended; } /** * @param {{ models: Model[] }} props */ export default function ModelConfigDropdown({ models }) { const [selectedModelIndex, setSelectedModelIndex] = useState(0); const [isOpen, setIsOpen] = useState(false); const selectedModel = models[selectedModelIndex]; const hasChoices = models.length > 1; const handleModelSelect = (index) => { setSelectedModelIndex(index); setIsOpen(false); }; return (

Step 1 — Choose a model

setIsOpen(!isOpen) : undefined} >
{selectedModel.label} {selectedModel.recommended && } {hasChoices && ( {isOpen ? "▲" : "▼"} )}
{isOpen && hasChoices && (
{models.map((model, index) => (
handleModelSelect(index)} > {model.label} {model.recommended && }
))}
)}

Step 2 — Download the model

{selectedModel.download}

Step 3 — Configure the detector

{selectedModel.ui} {selectedModel.yaml}
); }