1import{r as j,c3 as D,bW as Rt,j as e,c4 as Tt,c5 as Mt,c6 as Et,c7 as It,c8 as tt,c9 as Ot,ca as At,cb as Pt,cc as Dt,cd as kt,ce as Lt,bN as Ft,bP as O}from"./vendor-NvxgggIO.js";import{u as st,f as Ut,D as Qe}from"./index-DSPgNDCJ.js";import{m as Ie}from"./moderation-CXJWneLc.js";import{i as Yt}from"./inference-DN9ATWdQ.js";import{C as qt,Z as Wt,a7 as Bt,S as Ht,k as zt,g as Ze,v as rt,a8 as at,aq as Xt,ar as Gt,X as Jt,F as Ke,d as Ve,M as et,as as Qt,c as Zt,V as Kt,a2 as Vt,Y as es,ao as ts,h as ss}from"./icons-CuHvV7Wu.js";D.registerLanguage("javascript",Tt);D.registerLanguage("typescript",Mt);D.registerLanguage("python",Et);D.registerLanguage("ruby",It);D.registerLanguage("html",tt);D.registerLanguage("xml",tt);D.registerLanguage("css",Ot);D.registerLanguage("json",At);D.registerLanguage("bash",Pt);D.registerLanguage("sql",Dt);D.registerLanguage("plaintext",kt);function rs({code:v}){const[l,s]=j.useState(!1),I=async()=>{try{await navigator.clipboard.writeText(v),s(!0),setTimeout(()=>s(!1),2e3)}catch(B){console.error("Failed to copy:",B)}};return e.jsx("button",{onClick:I,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded transition-all duration-200 bg-gray-700/80 hover:bg-gray-600 text-gray-300 hover:text-white border border-gray-600/50",title:l?"Copied!":"Copy code",children:l?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-3 h-3 text-green-400"}),e.jsx("span",{className:"text-green-400",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(at,{className:"w-3 h-3"}),e.jsx("span",{children:"Copy"})]})})}const as=({model:v})=>{const{isDarkMode:l}=st(),s=j.useRef(null);j.useEffect(()=>{v.documentation&&s.current&&s.current.querySelectorAll("pre").forEach(u=>{if(u.querySelector(".code-copy-btn"))return;u.style.position="relative";const M=u.querySelector("code");let Z="Code";if(M){const k=Array.from(M.classList).find(U=>U.startsWith("language-"));if(k){const U=k.replace("language-","");Z={javascript:"JavaScript",typescript:"TypeScript",python:"Python",ruby:"Ruby",html:"HTML",xml:"XML",css:"CSS",json:"JSON",bash:"Bash",sql:"SQL",plaintext:"Plain Text",java:"Java",go:"Go",rust:"Rust",php:"PHP",csharp:"C#",cpp:"C++",c:"C"}[U]||U.charAt(0).toUpperCase()+U.slice(1),D.getLanguage(U)&&D.highlightElement(M)}else D.highlightElement(M)}const re=document.createElement("div");re.className="code-lang-label",re.textContent=Z,u.appendChild(re);const J=document.createElement("div");J.className="code-copy-btn",u.appendChild(J),Rt.createRoot(J).render(e.jsx(rs,{code:M?.textContent||""}))})},[v.documentation]);const I=p=>p?new Date(p).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"",B=p=>p>=1e3?`${(p/1e3).toFixed(1)}s`:`${p}ms`,me=p=>p<500?"text-blue-500":p<5e3?"text-green-500":"text-orange-500",d=p=>(typeof p=="number"?p:Number(p)).toFixed(5).replace(/\.?0+$/,"");return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Overview"}),e.jsx("p",{className:`text-sm mb-6 ${l?"text-gray-300":"text-gray-700"}`,children:v.input_schema?.description||v.description}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:`p-4 rounded-lg ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(qt,{className:`h-4 w-4 ${l?"text-emerald-400":"text-emerald-600"}`}),e.jsx("span",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"}`,children:"Version"})]}),e.jsx("div",{className:`text-2xl font-bold ${l?"text-white":"text-gray-900"}`,children:v.version||"N/A"}),v.version_date&&e.jsx("div",{className:`text-xs mt-1 ${l?"text-gray-500":"text-gray-400"}`,children:I(v.version_date)})]}),e.jsxs("div",{className:`p-4 rounded-lg ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Wt,{className:`h-4 w-4 ${l?"text-yellow-400":"text-yellow-600"}`}),e.jsx("span",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"}`,children:"Avg. Processing"})]}),e.jsx("div",{className:`text-2xl font-bold ${me(v.avg_response_time_ms)}`,children:B(v.avg_response_time_ms)})]}),e.jsxs("div",{className:`p-4 rounded-lg ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Bt,{className:`h-4 w-4 ${l?"text-green-400":"text-green-600"}`}),e.jsx("span",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"}`,children:"Per Request"})]}),e.jsxs("div",{className:`text-2xl font-bold ${l?"text-white":"text-gray-900"}`,children:["$",d(v.pricing.per_request)]})]}),e.jsxs("div",{className:`p-4 rounded-lg ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ht,{className:`h-4 w-4 ${l?"text-indigo-400":"text-indigo-600"}`}),e.jsx("span",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"}`,children:"Required Plan"})]}),e.jsx("div",{className:`text-lg font-bold ${l?"text-white":"text-gray-900"} capitalize`,children:v.require_plan})]})]})]}),v.documentation&&e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Model Documentation"}),e.jsx("div",{ref:s,className:`prose max-w-none 2 prose-h1:text-3xl prose-h1:font-bold prose-h1:mt-6 prose-h1:mb-4 prose-h1:leading-tight 3 prose-h2:text-2xl prose-h2:font-semibold prose-h2:mt-6 prose-h2:mb-3 prose-h2:leading-snug 4 prose-h3:text-xl prose-h3:font-semibold prose-h3:mt-5 prose-h3:mb-2 prose-h3:leading-snug 5 prose-h4:text-lg prose-h4:font-semibold prose-h4:mt-4 prose-h4:mb-2 6 prose-p:text-sm prose-p:my-2 prose-p:leading-relaxed 7 prose-ul:my-2 prose-ol:my-2 8 prose-li:my-0.5 prose-li:text-sm 9 prose-blockquote:border-l-4 prose-blockquote:pl-3 prose-blockquote:italic prose-blockquote:text-sm 10 prose-img:rounded-lg prose-img:my-3 11 prose-pre:rounded-lg prose-pre:p-3 prose-pre:overflow-x-auto prose-pre:text-sm 12 prose-code:font-mono prose-code:text-xs 13 ${l?"prose-invert prose-headings:text-white prose-p:text-gray-300 prose-a:text-blue-400 hover:prose-a:text-blue-300 prose-strong:text-white prose-code:text-blue-300 prose-pre:bg-gray-800 prose-blockquote:border-gray-600 prose-blockquote:text-gray-400":"prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600 hover:prose-a:text-blue-700 prose-blockquote:border-gray-300 prose-blockquote:text-gray-600 prose-pre:bg-slate-800"}`,dangerouslySetInnerHTML:{__html:v.documentation}})]}),v.input_schema&&e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Input Parameters"}),e.jsx("div",{className:"space-y-3",children:v.input_schema.parameters.map(p=>e.jsxs("div",{className:`rounded-lg p-4 ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-2",children:[e.jsx("code",{className:`px-2 py-1 rounded text-sm font-mono ${l?"bg-gray-900 text-emerald-400":"bg-gray-100 text-emerald-700"}`,children:p.name}),e.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${l?"bg-blue-900/30 text-blue-400":"bg-blue-100 text-blue-700"}`,children:p.type}),p.required&&e.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${l?"bg-red-900/30 text-red-400":"bg-red-100 text-red-700"}`,children:"Required"})]}),e.jsx("p",{className:`text-sm mb-2 ${l?"text-gray-300":"text-gray-700"}`,children:p.description}),p.example&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:`text-xs mb-1 ${l?"text-gray-400":"text-gray-600"}`,children:"Example:"}),e.jsx("code",{className:`block px-3 py-2 rounded text-sm font-mono ${l?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-800"}`,children:typeof p.example=="string"?p.example:JSON.stringify(p.example)})]})]},p.name))})]}),v.output_schema&&e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Response Fields"}),e.jsx("div",{className:"space-y-3",children:v.output_schema.fields.map(p=>e.jsxs("div",{className:`rounded-lg p-4 ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-2",children:[e.jsx("code",{className:`px-2 py-1 rounded text-sm font-mono ${l?"bg-gray-900 text-purple-400":"bg-gray-100 text-purple-700"}`,children:p.name}),e.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${l?"bg-blue-900/30 text-blue-400":"bg-blue-100 text-blue-700"}`,children:p.type})]}),e.jsx("p",{className:`text-sm mb-2 ${l?"text-gray-300":"text-gray-700"}`,children:p.description}),p.example!==void 0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:`text-xs mb-1 ${l?"text-gray-400":"text-gray-600"}`,children:"Example:"}),e.jsx("code",{className:`block px-3 py-2 rounded text-sm font-mono ${l?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-800"}`,children:typeof p.example=="object"?JSON.stringify(p.example,null,2):String(p.example)})]}),p.type==="object"&&p.properties&&e.jsxs("div",{className:`mt-4 p-4 rounded-lg space-y-3 ${l?"bg-gray-900/50 border border-gray-700":"bg-gray-50 border border-gray-200"}`,children:[e.jsx("div",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"}
13 mb-2`,children:"Object Properties:"}),p.properties.map(u=>e.jsxs("div",{className:"pb-3 last:pb-0 border-b last:border-b-0 border-gray-700/50",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[e.jsx("code",{className:`px-1.5 py-0.5 rounded text-xs font-mono ${l?"text-emerald-400":"text-emerald-700"}`,children:u.name}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l?"bg-gray-800 text-gray-400":"bg-gray-200 text-gray-600"}`,children:u.type})]}),u.description&&e.jsx("p",{className:`text-xs ${l?"text-gray-400":"text-gray-600"}`,children:u.description}),u.possible_values&&u.possible_values.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Possible values:"," "]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:u.possible_values.map(M=>e.jsx("code",{className:`px-2 py-0.5 rounded text-xs font-mono ${l?"bg-purple-900/30 text-purple-300":"bg-purple-100 text-purple-700"}`,children:M},M))})]}),u.type==="object"&&u.properties&&e.jsx("div",{className:`mt-2 ml-3 pl-3 border-l-2 ${l?"border-gray-700":"border-gray-300"}`,children:u.properties.map(M=>e.jsx("div",{className:"py-1",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:`px-1 py-0.5 rounded text-xs font-mono ${l?"text-cyan-400":"text-cyan-700"}`,children:M.name}),e.jsx("span",{className:"px-1 py-0.5 text-xs text-gray-500",children:M.type})]})},M.name))}),u.example!==void 0&&e.jsx("code",{className:`block mt-2 px-2 py-1 rounded text-xs font-mono ${l?"bg-gray-950 text-gray-400":"bg-white text-gray-700"}`,children:typeof u.example=="object"?JSON.stringify(u.example):String(u.example)})]},u.name))]}),p.type==="array"&&p.items?.properties&&e.jsxs("div",{className:`mt-4 p-4 rounded-lg space-y-3 ${l?"bg-gray-900/50 border border-gray-700":"bg-gray-50 border border-gray-200"}`,children:[e.jsx("div",{className:`text-xs font-medium ${l?"text-gray-400":"text-gray-600"} mb-2`,children:"Array Item Properties:"}),p.items.properties.map(u=>e.jsxs("div",{className:"pb-3 last:pb-0 border-b last:border-b-0 border-gray-700/50",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[e.jsx("code",{className:`px-1.5 py-0.5 rounded text-xs font-mono ${l?"text-emerald-400":"text-emerald-700"}`,children:u.name}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l?"bg-gray-800 text-gray-400":"bg-gray-200 text-gray-600"}`,children:u.type})]}),u.description&&e.jsx("p",{className:`text-xs ${l?"text-gray-400":"text-gray-600"}`,children:u.description}),u.possible_values&&u.possible_values.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Possible values:"," "]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:u.possible_values.map(M=>e.jsx("code",{className:`px-2 py-0.5 rounded text-xs font-mono ${l?"bg-purple-900/30 text-purple-300":"bg-purple-100 text-purple-700"}`,children:M},M))})]}),u.example!==void 0&&e.jsx("code",{className:`block mt-2 px-2 py-1 rounded text-xs font-mono ${l?"bg-gray-950 text-gray-400":"bg-white text-gray-700"}`,children:typeof u.example=="object"?JSON.stringify(u.example):String(u.example)})]},u.name))]})]},p.name))})]}),v.example_request&&v.example_response&&e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Complete Example"}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:`text-sm font-medium mb-2 ${l?"text-gray-300":"text-gray-700"}`,children:"Request"}),e.jsx("pre",{className:`p-4 rounded-lg text-sm font-mono overflow-x-auto ${l?"bg-gray-900 text-gray-300 border border-gray-700":"bg-gray-50 text-gray-800 border border-gray-200"}`,children:JSON.stringify(v.example_request,null,2)})]}),e.jsxs("div",{children:[e.jsx("h3",{className:`text-sm font-medium mb-2 ${l?"text-gray-300":"text-gray-700"}`,children:"Response"}),e.jsx("pre",{className:`p-4 rounded-lg text-sm font-mono overflow-x-auto ${l?"bg-gray-900 text-gray-300 border border-gray-700":"bg-gray-50 text-gray-800 border border-gray-200"}`,children:JSON.stringify(v.example_response,null,2)})]})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:`text-xl font-semibold mb-4 ${l?"text-white":"text-gray-900"}`,children:"Additional Information"}),e.jsxs("div",{className:`rounded-lg p-6 space-y-4 ${l?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${l?"bg-gray-900":"bg-gray-100"}`,children:e.jsx(zt,{className:`h-4 w-4 ${l?"text-gray-400":"text-gray-600"}`})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`text-sm font-medium mb-1 ${l?"text-white":"text-gray-900"}`,children:"Rate Limiting"}),e.jsxs("div",{className:`text-sm ${l?"text-gray-400":"text-gray-600"}`,children:["If we throttle your request, you will receive a ",e.jsx("code",{className:`px-1 py-0.5 rounded text-xs font-mono ${l?"bg-gray-900 text-red-400":"bg-gray-100 text-red-600"}`,children:"429"})," HTTP error code along with an error message. You should then retry with an exponential back-off strategy, meaning that you should retry after 4 seconds, then 8 seconds, then 16 seconds, etc."]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${l?"bg-gray-900":"bg-gray-100"}`,children:e.jsx(Ze,{className:`h-4 w-4 ${l?"text-gray-400":"text-gray-600"}`})}),e.jsxs("div",{children:[e.jsx("div",{className:`text-sm font-medium ${l?"text-white":"text-gray-900"}`,children:"Supported Formats"}),e.jsx("div",{className:`text-sm ${l?"text-gray-400":"text-gray-600"}`,children:v.supported_formats.join(", ")})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${l?"bg-gray-900":"bg-gray-100"}`,children:e.jsx(Ze,{className:`h-4 w-4 ${l?"text-gray-400":"text-gray-600"}`})}),e.jsxs("div",{children:[e.jsx("div",{className:`text-sm font-medium ${l?"text-white":"text-gray-900"}`,children:"Maximum File Size"}),e.jsxs("div",{className:`text-sm ${l?"text-gray-400":"text-gray-600"}`,children:[v.max_file_size_mb,"MB"]})]})]})]})]})]})},xs=()=>{const{apiName:v}=Lt(),l=Ft(),{isDarkMode:s}=st(),{showToast:I}=Ut(),[B,me]=j.useState("test"),[d,p]=j.useState(l.state?.model||null),[u,M]=j.useState(!d),[Z,re]=j.useState(null),[J,fe]=j.useState(!1),[k,U]=j.useState(null),[Y,je]=j.useState(null),[ae,Oe]=j.useState(""),[Ae,Ne]=j.useState(""),[nt,ve]=j.useState(!1),[$e,Pe]=j.useState("upload"),[X,De]=j.useState(!1),[we,ke]=j.useState(0),Q=j.useRef(null),_e=j.useRef([]),K=j.useRef(null),[ne,Le]=j.useState(!1),[V,it]=j.useState("async"),[lt,he]=j.useState(null),[C,pe]=j.useState(null),[Fe,ee]=j.useState([]),[te,Ue]=j.useState(null),[q,ie]=j.useState({visible:!1,x:0,y:0,data:null}),[le,oe]=j.useState(null),W=O.useRef(null),H=O.useRef([]),ce=O.useRef([]),P=O.useRef(null),A=O.useRef(null),Ce=O.useRef(null),se=O.useRef(null),Se=O.useRef(null),[de,ot]=j.useState("curl"),[Ye,qe]=j.useState(!1);j.useEffect(()=>{(async()=>
13{if(!d&&v){M(!0);const a=await Ie.getModelById(v);a?p(a):I("error","Model not found"),M(!1)}})()},[v,d,I]),j.useEffect(()=>{(async()=>{if(B==="docs"&&d&&!Z&&!J){fe(!0);const a=await Ie.getModelWithDocumentation(d.api_name);a&&re(a),fe(!1)}})()},[B,d,Z,J]),j.useEffect(()=>()=>{Y&&URL.revokeObjectURL(Y)},[Y]);const ct=t=>{const a=Math.floor(t/60),r=t%60;return`${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},dt=j.useCallback(async()=>{try{const t=await navigator.mediaDevices.getUserMedia({audio:!0}),a=new MediaRecorder(t);Q.current=a,_e.current=[],a.ondataavailable=r=>{r.data.size>0&&_e.current.push(r.data)},a.onstop=()=>{const r=a.mimeType||"audio/webm",n=new Blob(_e.current,{type:r}),i=r.includes("mp4")?"mp4":r.includes("wav")?"wav":"webm",o=new File([n],`recording.${i}`,{type:r}),m=URL.createObjectURL(n);je(m),U(o),t.getTracks().forEach(g=>g.stop())},a.start(),De(!0),ke(0),K.current=setInterval(()=>{ke(r=>r+1)},1e3)}catch{I("error","Could not access microphone. Please check permissions.")}},[I]),Re=j.useCallback(()=>{Q.current&&Q.current.state!=="inactive"&&Q.current.stop(),K.current&&(clearInterval(K.current),K.current=null),De(!1)},[]),xt=60;j.useEffect(()=>{X&&we>=xt&&(Re(),I("info","Recording stopped at 60 seconds maximum"))},[X,we,Re,I]),j.useEffect(()=>()=>{K.current&&clearInterval(K.current),Q.current&&Q.current.state!=="inactive"&&Q.current.stop()},[]);const gt=()=>{Y&&URL.revokeObjectURL(Y),U(null),je(null),Ne(""),pe(null),ee([]),oe(null),ie({visible:!1,x:0,y:0,data:null}),H.current=[],ce.current=[],W.current&&(cancelAnimationFrame(W.current),W.current=null),A.current&&A.current.getContext("2d")?.clearRect(0,0,A.current.width,A.current.height)},Te=t=>{t.preventDefault(),t.stopPropagation(),t.type==="dragenter"||t.type==="dragover"?ve(!0):t.type==="dragleave"&&ve(!1)},mt=t=>{if(t.preventDefault(),t.stopPropagation(),ve(!1),t.dataTransfer.files&&t.dataTransfer.files[0]){const a=t.dataTransfer.files[0];Me(a)}},ht=t=>{if(t.preventDefault(),t.target.files&&t.target.files[0]){const a=t.target.files[0];Me(a)}},Me=t=>{if(!d)return;const a=d.max_file_size_mb*1024*1024;if(t.size>a){I("error",`File size exceeds ${d.max_file_size_mb}MB limit`);return}const r=t.name.split(".").pop()?.toLowerCase();if(r&&!d.supported_formats.includes(r)){I("error",`File type .${r} is not supported. Supported formats: ${d.supported_formats.join(", ")}`);return}const n=URL.createObjectURL(t);je(n),U(t)},We=t=>t?.name?.toLowerCase().endsWith(".pdf"),Be=async t=>{if(d){if(pe(null),ee([]),A.current&&A.current.getContext("2d")?.clearRect(0,0,A.current.width,A.current.height),t.content!==void 0&&Ne(t.content),t.text){Oe(t.text);return}if(t.url){Ue(t.label);try{const a=await fetch(t.url,{mode:"cors",cache:"no-cache"});if(!a.ok)throw new Error("Failed to fetch sample");const r=await a.blob(),n=t.url.split("/"),i=n[n.length-1]||`sample.${r.type.split("/")[1]||"bin"}`,o=new File([r],i,{type:r.type});Me(o)}catch(a){I("error","Failed to load sample content"),console.error("Sample load error:",a)}finally{Ue(null)}}}},E=["#22c55e","#3b82f6","#f59e0b","#ec4899","#8b5cf6","#06b6d4","#f97316","#14b8a6"],L=O.useCallback(async(t,a=-1)=>{if(!A.current||!P.current)return;const r=A.current,n=P.current,i=r.getContext("2d");if(!i)return;r.width=n.width,r.height=n.height,i.clearRect(0,0,r.width,r.height),H.current=[],ce.current=t;const o=n.width,m=n.height,g=Math.min(o/n.naturalWidth,m/n.naturalHeight),y=n.naturalWidth*g,c=n.naturalHeight*g,$=(o-y)/2,R=(m-c)/2;for(let x=0;x<t.length;x++){const w=t[x];if(!w.mask_png)continue;const N=E[x%E.length];try{const b=new Image;await new Promise((_,S)=>{b.onload=()=>_(),b.onerror=()=>S(),b.src=w.mask_png}),H.current.push({img:b,data:w,offsetX:$,offsetY:R,displayedWidth:y,displayedHeight:c,colorIndex:x}),i.save(),i.globalAlpha=.5,i.globalCompositeOperation="source-over";const f=document.createElement("canvas");f.width=b.width,f.height=b.height;const h=f.getContext("2d");h&&(h.drawImage(b,0,0),h.globalCompositeOperation="source-in",h.fillStyle=N,h.fillRect(0,0,f.width,f.height),i.drawImage(f,$,R,y,c)),i.restore()}catch{}}t.forEach((x,w)=>{if(!x.bbox||x.mask_png)return;let N,b,f,h;Array.isArray(x.bbox)?[N,b,f,h]=[x.bbox[0],x.bbox[1],x.bbox[0]+x.bbox[2],x.bbox[1]+x.bbox[3]]:{x1:N,y1:b,x2:f,y2:h}=x.bbox;const _=E[w%E.length],S=w===a,T=N*g+$,F=b*g+R,z=f*g+$,ge=h*g+R;
13i.strokeStyle=_,i.lineWidth=S?6:3,i.strokeRect(T,F,z-T,ge-F),S&&(i.shadowColor=_,i.shadowBlur=15,i.strokeRect(T,F,z-T,ge-F),i.shadowBlur=0)}),t.forEach((x,w)=>{if(!x.bbox)return;let N,b;Array.isArray(x.bbox)?[N,b]=[x.bbox[0],x.bbox[1]]:{x1:N,y1:b}=x.bbox;const f=E[w%E.length],h=N*g+$,_=b*g+R,S=x.label?`${x.label}${x.similarity?` ${(x.similarity*100).toFixed(0)}%`:""}`:x.class_name?`${x.class_name}${x.score?` ${(x.score*100).toFixed(0)}%`:""}`:x.age?`${Math.round(x.age)} years`:`#${w+1}`;i.font="bold 14px sans-serif";const T=i.measureText(S).width;i.fillStyle=f,i.fillRect(h,_-24,T+12,24),i.fillStyle="#ffffff",i.fillText(S,h+6,_-6)})},[E]),He=O.useCallback(t=>{if(!A.current||!P.current||!t?.length)return;const a=A.current,r=P.current,n=a.getContext("2d");if(!n)return;(a.width!==r.width||a.height!==r.height)&&(a.width=r.width,a.height=r.height);const i=r.width,o=r.height,m=Math.min(i/r.naturalWidth,o/r.naturalHeight),g=r.naturalWidth*m,y=r.naturalHeight*m,c=(i-g)/2,$=(o-y)/2;t.forEach(R=>{const{x,y:w,intensity:N}=R,b=c+x*g,f=$+w*y,h=12+N*18,_=60-N*60;n.save(),n.beginPath(),n.arc(b,f,h+8,0,Math.PI*2),n.fillStyle=`hsla(${_}, 100%, 50%, 0.3)`,n.fill(),n.beginPath(),n.arc(b,f,h,0,Math.PI*2),n.fillStyle=`hsla(${_}, 100%, 50%, 0.6)`,n.fill(),n.strokeStyle=`hsl(${_}, 100%, 50%)`,n.lineWidth=3,n.stroke(),n.beginPath(),n.arc(b,f,4,0,Math.PI*2),n.fillStyle="#ffffff",n.fill(),n.font="bold 12px sans-serif",n.fillStyle="#ffffff",n.strokeStyle="rgba(0,0,0,0.7)",n.lineWidth=3;const S=`${Math.round(N*100)}%`,T=n.measureText(S).width;n.strokeText(S,b-T/2,f+h+16),n.fillText(S,b-T/2,f+h+16),n.restore()})},[]),Ee=O.useCallback(t=>{if(!Se.current||!se.current||!t?.length)return;const a=Se.current,r=se.current,n=a.getContext("2d");if(!n)return;const i=r.getBoundingClientRect();a.width=i.width,a.height=i.height,n.clearRect(0,0,a.width,a.height);const o=r.videoWidth/r.videoHeight,m=i.width/i.height;let g,y,c,$;o>m?(g=i.width,y=i.width/o,c=0,$=(i.height-y)/2):(y=i.height,g=i.height*o,c=(i.width-g)/2,$=0),t.forEach(R=>{const{x,y:w,intensity:N}=R,b=c+x*g,f=$+w*y,h=12+N*18,_=60-N*60;n.save(),n.beginPath(),n.arc(b,f,h+8,0,Math.PI*2),n.fillStyle=`hsla(${_}, 100%, 50%, 0.3)`,n.fill(),n.beginPath(),n.arc(b,f,h,0,Math.PI*2),n.fillStyle=`hsla(${_}, 100%, 50%, 0.6)`,n.fill(),n.strokeStyle=`hsl(${_}, 100%, 50%)`,n.lineWidth=3,n.stroke(),n.beginPath(),n.arc(b,f,4,0,Math.PI*2),n.fillStyle="#ffffff",n.fill(),n.font="bold 12px sans-serif",n.fillStyle="#ffffff",n.strokeStyle="rgba(0,0,0,0.7)",n.lineWidth=3;const S=`${Math.round(N*100)}%`,T=n.measureText(S).width;n.strokeText(S,b-T/2,f+h+16),n.fillText(S,b-T/2,f+h+16),n.restore()})},[]),ze=O.useCallback(t=>{if(!A.current||t>=H.current.length)return;const a=A.current,r=a.getContext("2d");if(!r)return;const n=E[H.current[t].colorIndex%E.length];let i=null;const o=m=>{i||(i=m);const g=m-i,y=.55+Math.sin(g/300)*.25;r.clearRect(0,0,a.width,a.height),H.current.forEach((c,$)=>{const R=E[c.colorIndex%E.length],x=$===t;r.save(),r.globalAlpha=x?y:.5,r.globalCompositeOperation="source-over";const w=document.createElement("canvas");w.width=c.img.width,w.height=c.img.height;const N=w.getContext("2d");if(N&&(N.drawImage(c.img,0,0),N.globalCompositeOperation="source-in",N.fillStyle=R,N.fillRect(0,0,w.width,w.height),r.drawImage(w,c.offsetX,c.offsetY,c.displayedWidth,c.displayedHeight)),x){const b=.3+Math.sin(g/200)*.2;r.shadowColor=n,r.shadowBlur=15+Math.sin(g/150)*5,r.globalAlpha=b;for(let f=0;f<3;f++){const h=document.createElement("canvas");h.width=c.img.width,h.height=c.img.height;const _=h.getContext("2d");_&&(_.drawImage(c.img,0,0),_.globalCompositeOperation="source-in",_.strokeStyle=n,_.lineWidth=3,_.fillStyle="transparent",r.drawImage(h,c.offsetX,c.offsetY,c.displayedWidth,c.displayedHeight))}r.shadowBlur=0}r.restore()}),ce.current.forEach((c,$)=>{if(!c.bbox||c.mask_png)return;const R=a.width,x=a.height,w=P.current;if(!w)return;const N=Math.min(R/w.naturalWidth,x/w.naturalHeight),b=w.naturalWidth*N,f=w.naturalHeight*N,h=(R-b)/2,_=(x-f)/2;let S,T,F,z;Array.isArray(c.bbox)?[S,T,F,z]=[c.bbox[0],c.bbox[1],c.bbox[0]+c.bbox[2],c.bbox[1]+c.bbox[3]]:{x1:S,y1:T,x2:F,y2:z}=c.bbox;const ge=E[$%E.length],ye=S*N+h,be=T*N+_,_t=F*N+h,Ct=z*N+_;r.strokeStyle=ge,r.lineWidth=3,r.strokeRect(ye,be,_t-ye,Ct-be);const Je=c.label?`${c.label}${c.similarity?` ${(c.similarity*100).toFixed(0)}%`:""}`:c.class_name?`${c.class_name}${c.score?` ${(c.score*100).toFixed(0)}%`:""}`:c.age?`${Math.round(c.age)} years`:`#${$+1}`;r.font="bold 14px sans-serif";const St=r.measureText(Je).width;r.fillStyle=ge,r.fillRect(ye,be-24,St+12,24),r.fillStyle="#ffffff",r.fillText(Je,ye+6,be-6)}),le===t&&(W.current=requestAnimationFrame(o))};W.current=requestAnimationFrame(o)},[E,le]);O.useEffect(()=>(le!==null?ze(le):(W.current&&(cancelAnimationFrame(W.current),W.current=null),ce.current.length>0&&L(ce.current,-1)),()=>{W.current&&cancelAnimationFrame(W.current)}),[le,ze,L]);const ue=O.useCallback(t=>{if(!P.current||t.length===0)return[];const a=P.current,r=[],n=document.createElement("canvas"),i=n.getContext("2d");return i?(t.forEach(o=>{if(!o.bbox){r.push("");return}let m,g,y,c;Array.isArray(o.bbox)?[m,g,y,c]=[o.bbox[0],o.bbox[1],o.bbox[0]+o.bbox[2],o.bbox[1]+o.bbox[3]]:{x1:m,y1:g,x2:y,y2:c}=o.bbox;const $=y-m,R=c-g,x=.1,w=Math.max(0,m-$*x),N=Math.max(0,g-R*x),b=$*(1+2*x),f=R*(1+2*x),h=80;n.width=h,n.height=h;const _=b/f;let S=h,T=h,F=0,z=0;_>
131?(T=h/_,z=(h-T)/2):(S=h*_,F=(h-S)/2),i.clearRect(0,0,h,h),i.drawImage(a,w,N,b,f,F,z,S,T),r.push(n.toDataURL("image/jpeg",.8))}),r):[]},[]),pt=O.useCallback(t=>{const a=A.current;if(!a||H.current.length===0){ie(o=>o.visible?{...o,visible:!1}:o),oe(null);return}const r=a.getBoundingClientRect(),n=t.clientX-r.left,i=t.clientY-r.top;for(let o=H.current.length-1;o>=0;o--){const m=H.current[o],{img:g,data:y,offsetX:c,offsetY:$,displayedWidth:R,displayedHeight:x}=m;if(n<c||n>c+R||i<$||i>$+x)continue;const w=Math.floor((n-c)/R*g.width),N=Math.floor((i-$)/x*g.height),b=document.createElement("canvas");b.width=g.width,b.height=g.height;const f=b.getContext("2d");if(f&&(f.drawImage(g,0,0),f.getImageData(w,N,1,1).data[3]>30)){oe(o),ie({visible:!0,x:t.clientX,y:t.clientY,data:{score:y.score,class_id:y.class_id,class_name:y.class_name}});return}}oe(null),ie(o=>o.visible?{...o,visible:!1}:o)},[]),ut=O.useCallback(()=>{oe(null),ie(t=>t.visible?{...t,visible:!1}:t)},[]),yt=O.useCallback((t,a)=>{Ce.current&&Ce.current.scrollIntoView({behavior:"smooth",block:"center"}),L(t,a);let r=0;const n=setInterval(()=>{r++,r%2===0?L(t,a):L(t,-1),r>=12&&(clearInterval(n),L(t,-1))},200)},[L]),bt=async()=>{if(d){if(d.moderation_type==="text"&&!ae.trim()){I("error","Please enter text to analyze");return}if(d.moderation_type!=="text"&&!k){I("error","Please select a file to upload");return}Le(!0),pe(null),he(null);try{let t=await Ie.testInference(d.api_name,{content:d.moderation_type==="text"?ae||void 0:Ae||void 0,file:k||void 0,mediaType:d.moderation_type,isPdf:We(k)||void 0,extract_faces:d.api_name==="wanted-person-detection"||d.api_name==="wanted-person-detection-image"?!0:void 0,mode:V});if(V==="async"&&(t.status==="pending"||t.status==="processing")&&(he(t.status),t=await ft(t.inference_id)),t.status==="failed")throw new Error(t.error_message||"Inference failed");if(pe(t),I("success","Analysis complete"),d.moderation_type==="image"&&t.result){if(d.api_name==="wanted-person-detection-image"&&t.result.matches){const r=t.result.matches.flatMap(n=>(n.all_detections||(n.best_match?[n.best_match]:[])).map(o=>({bbox:o.bbox,label:n.matched_person?.name||"Unknown",det_score:o.det_score,similarity:o.similarity})));if(r.length>0)if(P.current?.complete){L(r,-1);const n=ue(r);ee(n)}else P.current?.addEventListener("load",()=>{L(r,-1);const n=ue(r);ee(n)},{once:!0})}else Object.values(t.result).forEach(r=>{if(Array.isArray(r)&&r.length>0&&r[0]?.bbox)if(P.current?.complete){L(r,-1);const n=ue(r);ee(n)}else P.current?.addEventListener("load",()=>{L(r,-1);const n=ue(r);ee(n)},{once:!0})});const a=t.result?.hotspots||t.result?.data?.hotspots;a&&Array.isArray(a)&&a.length>0&&(P.current?.complete?He(a):P.current?.addEventListener("load",()=>{He(a)},{once:!0}),se.current&&(se.current.readyState>=1?Ee(a):se.current.addEventListener("loadedmetadata",()=>{Ee(a)},{once:!0})))}}catch(t){I("error",t instanceof Error?t.message:"Test failed"),console.error("Test error:",t)}finally{Le(!1),he(null)}}},ft=async t=>{for(let r=0;r<240;r++){await new Promise(i=>setTimeout(i,1500));const n=await Yt.getInference(t);if(n.status==="completed"||n.status==="failed")return n;he(n.status)}throw new Error("Timed out waiting for the queued inference. Check the history page for the result.")},G=(t,a)=>a==="json"?JSON.stringify(t,null,2):a==="python"?`{ 14${Object.entries(t).map(([i,o])=>{const m=typeof o=="string"?`"${o}"`:JSON.stringify(o);return` "${i}": ${m}`}).join(`, 15`)} 16}`:`{ 17${Object.entries(t).map(([n,i])=>{const o=typeof i=="string"?`'${i}'`:JSON.stringify(i);return` ${n}: ${o}`}).join(`, 18`)} 19}`,Xe=(()=>{if(!d)return{curl:"",python:"",javascript:"",nodejs:""};const t="https://api.bynn.com/v1/moderation",a=`${t}/${V==="async"?"infer_async":"infer"}`,r=d.example_request||{model:d.api_name,...d.moderation_type==="text"?{content:"Your text content here..."}:d.moderation_type==="image"?{image_url:"https://example.com/image.jpg"}:d.moderation_type==="video"?{video_url:"https://example.com/video.mp4"}:{audio_url:"https://example.com/audio.mp3"}};return V==="async"?{curl:`# Submit â returns 202 with the inference id 20curl -X POST ${a} \\ 21 -H "Authorization: Bearer YOUR_API_KEY" \\ 22 -H "Content-Type: application/json" \\ 23 -d '${G(r,"json")}' 24 25# Poll for the result 26curl ${t}
26/inference/INFERENCE_ID \\ 27 -H "Authorization: Bearer YOUR_API_KEY"`,python:`import requests 28import time 29 30base = "${t}" 31headers = {"Authorization": "Bearer YOUR_API_KEY"} 32data = ${G(r,"python")} 33 34# Submit â returns 202 with the inference id 35inference = requests.post(f"{base}/infer_async", headers=headers, json=data).json() 36 37# Poll for the result 38while inference["status"] in ("pending", "processing"): 39 time.sleep(2) 40 inference = requests.get( 41 f"{base}/inference/{inference['inference_id']}", headers=headers 42 ).json() 43 44print(inference["result"])`,javascript:`const base = '${t}'; 45const headers = { 46 'Authorization': 'Bearer YOUR_API_KEY', 47 'Content-Type': 'application/json' 48}; 49 50// Submit â returns 202 with the inference id 51let inference = await fetch(\`\${base}/infer_async\`, { 52 method: 'POST', 53 headers, 54 body: JSON.stringify(${G(r,"javascript")}) 55}).then(r => r.json()); 56 57// Poll for the result 58while (['pending', 'processing'].includes(inference.status)) { 59 await new Promise(r => setTimeout(r, 2000)); 60 inference = await fetch(\`\${base}/inference/\${inference.inference_id}\`, { headers }) 61 .then(r => r.json()); 62} 63 64console.log(inference.result);`,nodejs:`const axios = require('axios'); 65 66const base = '${t}'; 67const headers = { 'Authorization': 'Bearer YOUR_API_KEY' }; 68const data = ${G(r,"javascript")}; 69 70async function run() { 71 // Submit â returns 202 with the inference id 72 let { data: inference } = await axios.post(\`\${base}/infer_async\`, data, { headers }); 73 74 // Poll for the result 75 while (['pending', 'processing'].includes(inference.status)) { 76 await new Promise(r => setTimeout(r, 2000)); 77 ({ data: inference } = await axios.get( 78 \`\${base}/inference/\${inference.inference_id}\`, { headers } 79 )); 80 } 81 82 console.log(inference.result); 83} 84 85run();`}:{curl:`curl -X POST ${a} \\ 86 -H "Authorization: Bearer YOUR_API_KEY" \\ 87 -H "Content-Type: application/json" \\ 88 -d '${G(r,"json")}'`,python:`import requests 89 90url = "${a}" 91headers = {"Authorization": "Bearer YOUR_API_KEY"} 92data = ${G(r,"python")} 93 94response = requests.post(url, headers=headers, json=data) 95print(response.json())`,javascript:`fetch('${a}', { 96 method: 'POST', 97 headers: { 98 'Authorization': 'Bearer YOUR_API_KEY', 99 'Content-Type': 'application/json' 100 }, 101 body: JSON.stringify(${G(r,"javascript")}) 102}) 103.then(response => response.json()) 104.then(data => console.log(data));`,nodejs:`const axios = require('axios'); 105 106const data = ${G(r,"javascript")}; 107 108axios.post('${a}', data, { 109 headers: { 110 'Authorization': 'Bearer YOUR_API_KEY', 111 'Content-Type': 'application/json' 112 } 113}) 114.then(response => console.log(response.data));`}})(),jt=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?|[{}\[\],:;])/g,a=>{let r="text-yellow-400";return/^"/.test(a)?/:$/.test(a)?(r="text-blue-400",`<span class="${r}">${a}</span>`):(r="text-green-400",`<span class="${r}">${a}</span>`):(/true|false/.test(a)?r="text-purple-400":/null/.test(a)?r="text-red-400":/[{}\[\],:;]/.test(a)&&(r="text-gray-300"),`<span class="${r}">${a}</span>`)}),Nt=(t,a)=>{const r=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return a==="curl"?r.replace(/('([^'\\]|\\.)*')/g,"##STRING1##$1##/STRING1##").replace(/("([^"\\]|\\.)*")/g,"##STRING2##$1##/STRING2##").replace(/(https?:\/\/[^\s\\]+)/g,"##URL##$1##/URL##").replace(/(curl|POST|GET|-[XHFD]|\\)/g,"##CMD##$1##/CMD##").replace(/##STRING1##/g,'<span class="text-green-400">').replace(/##\/STRING1##/g,"</span>").replace(/##STRING2##/g,'<span class="text-green-400">').replace(/##\/STRING2##/g,"</span>").replace(/##URL##/g,'<span class="text-yellow-400">').replace(/##\/URL##/g,"</span>").replace(/##CMD##/g,'<span class="text-blue-400">').replace(/##\/CMD##/g,"</span>"):a==="python"?r.replace(/('([^'\\]|\\.)*')/g,"##STRING##$1##/STRING##").replace(/("([^"\\]|\\.)*")/g,"##STRING##$1##/STRING##").replace(/#.*/g,"##COMMENT##$&##/COMMENT##").replace(/\b(import|def|class|return|if|else|for|in|print|as)\b/g,"##KEYWORD##$1##/KEYWORD##").replace(/\b(requests|json|open)\b/g,"##MODULE##$1##/MODULE##").replace(/##STRING##/g,'<span class="text-green-400">').replace(/##\/STRING##/g,"</span>").replace(/##COMMENT##/g,'<span class="text-gray-500">').replace(/##\/COMMENT##/g,"</span>").replace(/##KEYWORD##/g,'<span class="text-purple-400">').replace(/##\/KEYWORD##/g,"</span>").replace(/##MODULE##/g,'<span class="text-blue-400">').replace(/##\/MODULE##/g,"</span>"):a==="javascript"||a==="nodejs"?r.replace(/('([^'\\]|\\.)*')/g,"##STRING##$1##/STRING##").replace(/("([^"\\]|\\.)*")/g,"##STRING##$1##/STRING##").replace(/(\/\/.*)/g,"##COMMENT##$1##/COMMENT##").replace(/\b(const|let|var|function|return|if|else|for|in|require|import|from|export|async|await|then)\b/g,"##KEYWORD##$1##/KEYWORD##").replace(/\b(fetch|axios|FormData|console|fs|JSON|stringify)\b/g,"##MODULE##$1##/MODULE##").replace(/##STRING##/g,'<span class="text-green-400">').replace(/##\/STRING##/g,"</span>").replace(/##COMMENT##/g,'<span class="text-gray-500">').replace(/##\/COMMENT##/g,"</span>").replace(/##KEYWORD##/g,'<span class="text-purple-400">').replace(/##\/KEYWORD##/g,"</span>").replace(/##MODULE##/g,'<span class="text-blue-400">').replace(/##\/MODULE##/g,"</span>"):r},vt=()=>{navigator.clipboard.writeText(Xe[de]),qe(!0),setTimeout(()=>qe(!1),2e3)},$t=()=>d?d.supported_formats.map(t=>`.${t}`).join(","):"";if(u)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Qe,{title:"Playground",description:"Run moderation models with your own content"}),e.jsx("div",{className:`h-8 w-48 rounded ${s?"bg-gray-700":"bg-gray-200"} animate-pulse`}),e.jsx("div",{className:`h-96 rounded-xl ${s?"bg-gray-800":"bg-white"} animate-pulse`})]});if(!d)return e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:s?"text-gray-400":"text-gray-600",children:"Model not found"})});const xe=d.moderation_type==="text",wt=!xe&&d.sample_content?.some(t=>"content"in t),Ge=xe?ae.length>0:k!==null;return e.jsxs(e.Fragment,{children:[e.jsx(Qe,{title:`${d.name} Playground`,description:`Run the ${d.name} moderation model with your own content`}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:`text-2xl font-bold ${s?"text-white":"text-gray-900"}`,children:d.name}),e.jsx("p",{className:`mt-1 text-sm ${s?"text-gray-400":"text-gray-600"}`,children:d.description})]}),e.jsx("div",{className:`border-b ${s?"border-gray-700":"border-gray-200"}`,children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>me("test"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 ${B==="test"?s?"border-indigo-400 text-indigo-400":"border-indigo-600 text-indigo-600":s?"border-transparent text-gray-400 hover:text-gray-300":"border-transparent text-gray-600 hover:text-gray-900"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xt,{className:"h-4 w-4"}),"Playground"]}
114)}),e.jsx("button",{onClick:()=>me("docs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 ${B==="docs"?s?"border-indigo-400 text-indigo-400":"border-indigo-600 text-indigo-600":s?"border-transparent text-gray-400 hover:text-gray-300":"border-transparent text-gray-600 hover:text-gray-900"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"h-4 w-4"}),"Documentation"]})})]})}),B==="docs"?J?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"w-8 h-8 border-3 border-blue-500 border-t-transparent rounded-full animate-spin mb-3"}),e.jsx("p",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:"Loading documentation..."})]}):e.jsx(as,{model:Z||d}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:`rounded-xl p-6 ${s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsx("h3",{className:`font-semibold mb-4 ${s?"text-white":"text-gray-900"}`,children:xe?"Enter Text":"Upload Content"}),xe?e.jsxs("div",{children:[e.jsx("textarea",{value:ae,onChange:t=>Oe(t.target.value),placeholder:"Enter text to moderate...",rows:10,className:`w-full p-4 rounded-lg border resize-none ${s?"bg-gray-900 border-gray-600 text-white placeholder-gray-500":"bg-white border-gray-300 text-gray-900 placeholder-gray-400"} focus:outline-none focus:ring-2 focus:ring-emerald-500`}),e.jsxs("div",{className:"text-xs mt-2 text-gray-500",children:[ae.length," characters"]})]}):k&&Y?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium truncate ${s?"text-white":"text-gray-900"}`,children:k.name}),e.jsxs("p",{className:`text-xs ${s?"text-gray-400":"text-gray-600"}`,children:[(k.size/1024/1024).toFixed(2)," MB"]})]}),e.jsx("button",{onClick:gt,className:`ml-3 p-2 rounded-lg transition-colors ${s?"hover:bg-gray-800 text-gray-400 hover:text-white":"hover:bg-gray-200 text-gray-600 hover:text-gray-900"}`,title:"Clear file",children:e.jsx(Jt,{className:"h-4 w-4"})})]}),d.moderation_type==="image"&&We(k)?e.jsxs("div",{className:`flex flex-col items-center justify-center p-8 rounded-lg border ${s?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"}`,children:[e.jsx(Ke,{className:`h-16 w-16 mb-3 ${s?"text-gray-500":"text-gray-400"}`}),e.jsx("p",{className:`text-sm font-medium ${s?"text-gray-300":"text-gray-700"}`,children:"PDF Document"}),e.jsx("p",{className:"text-xs mt-1 text-gray-500",children:"Each page will be processed separately"})]}):d.moderation_type==="image"?e.jsxs("div",{ref:Ce,className:`relative rounded-lg overflow-hidden border ${s?"border-gray-700":"border-gray-200"}`,children:[e.jsx("img",{ref:P,src:Y,alt:"Preview",className:"w-full h-auto max-h-96 object-contain bg-gray-900"}),e.jsx("canvas",{ref:A,className:"absolute top-0 left-0",style:{width:"100%",height:"auto",maxHeight:"384px"},onMouseMove:pt,onMouseLeave:ut}),q.visible&&q.data&&e.jsx("div",{className:`fixed z-50 px-3 py-2 rounded-lg shadow-lg text-xs pointer-events-none ${s?"bg-gray-900 border border-gray-700 text-white":"bg-white border border-gray-200 text-gray-900"}`,style:{left:q.x+12,top:q.y+12},children:e.jsxs("div",{className:"space-y-1",children:[q.data.class_name&&e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:s?"text-gray-400":"text-gray-600",children:"Class"}),e.jsx("span",{className:"font-medium",children:q.data.class_name})]}),q.data.score!==void 0&&e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:s?"text-gray-400":"text-gray-600",children:"Score"}),e.jsxs("span",{className:"font-medium",children:[(q.data.score*100).toFixed(1),"%"]})]}),q.data.class_id!==void 0&&e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:s?"text-gray-400":"text-gray-600",children:"Class ID"}),e.jsx("span",{className:"font-medium",children:q.data.class_id})]})]})})]}):null,d.moderation_type==="video"&&e.jsx("div",{className:`rounded-lg overflow-hidden border ${s?"border-gray-700":"border-gray-200"}`,children:e.jsxs("div",{className:"relative",children:[e.jsx("video",{ref:se,src:Y,controls:!0,className:"w-full h-auto max-h-96 bg-gray-900",onLoadedMetadata:()=>{const t=C?.result?.hotspots||C?.result?.data?.hotspots;t?.length&&Ee(t)},children:"Your browser does not support video playback."}),e.jsx("canvas",{ref:Se,className:"absolute inset-0 pointer-events-none"})]})}),d.moderation_type==="audio"&&e.jsx("div",{className:`p-4 rounded-lg ${s?"bg-gray-900/50 border border-gray-700":"bg-gray-50 border border-gray-200"}`,children:e.jsx("audio",{src:Y,controls:!0,className:"w-full",children:"Your browser does not support audio playback."})})]}):e.jsxs("div",{className:"space-y-4",children:[d.moderation_type==="audio"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>Pe("upload"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg transition-colors ${$e==="upload"?s?"bg-indigo-600 text-white":"bg-indigo-500 text-white":s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:[e.jsx(Ve,{className:"h-4 w-4"}),"Upload File"]}),e.jsxs("button",{onClick:()=>Pe("record"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg transition-colors ${$e==="record"?s?"bg-indigo-600 text-white":"bg-indigo-500 text-white":s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:[e.jsx(et,{className:"h-4 w-4"}),"Record Audio"]})]}),d.moderation_type!=="audio"||$e==="upload"?e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${nt?"border-indigo-500 bg-indigo-500/10":s?"border-gray-600 hover:border-gray-500":"border-gray-300 hover:border-gray-400"}`,onDragEnter:Te,onDragLeave:Te,onDragOver:Te,onDrop:mt,children:[e.jsx("input",{type:"file",id:"file-upload",className:"hidden",accept:$t(),onChange:ht}),e.jsxs("label",{htmlFor:"file-upload",className:"cursor-pointer",children:[e.jsx(Ve,{className:`h-12 w-12 mx-auto mb-4 ${s?"text-gray-400":"text-gray-500"}`}),e.jsx("p",{className:`text-sm mb-2 ${s?"text-gray-300":"text-gray-700"}`,children:"Drag and drop your file here"}),e.jsx("p",{className:"text-xs text-gray-500",children:"or click to browse"}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500",children:["Supported: ",d.supported_formats.join(", ")," (max ",d.max_file_size_mb,"MB)"]})]})]}):e.jsx("div",{className:`rounded-lg p-8 text-center border-2 border-dashed ${X?"border-red-500 bg-red-500/10":s?"border-gray-600":"border-gray-300"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("button",{onClick:X?Re:dt,className:`relative w-20 h-20 rounded-full flex items-center justify-center transition-all ${X?"bg-red-500 hover:bg-red-600":s?"bg-gray-700 hover:bg-gray-600":"bg-gray-200 hover:bg-gray-300"}`,children:X?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-red-500 animate-ping opacity-25"}),e.jsx(Qt,{className:"h-8 w-8 text-white"})]}):e.jsx(et,{className:`h-8 w-8 ${s?"text-gray-300":"text-gray-600"}`})}),e.jsx("div",{className:`font-mono text-2xl ${X?"text-red-500":s?"text-gray-400":"text-gray-500"}`,children:ct(we)}),e.jsx("p",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:X?"Recording... Click stop when finished":"Click the microphone to start recording"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Max file size: ",d.max_file_size_mb,"MB"]})]})})]}),wt&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("label",{className:`text-xs font-medium mb-1.5 block ${s?"text-gray-400":"text-gray-600"}`,children:["Prompt ",e.jsx("span",{className:s?"text-gray-500":"text-gray-400",children:"(optional)"})]}),e.jsx("textarea",{value:Ae,onChange:t=>Ne(t.target.value),placeholder:"Text Recognition:",rows:2,className:`w-full p-3 rounded-lg border resize-none text-sm ${s?"bg-gray-900 border-gray-600 text-white placeholder-gray-500":"bg-white border-gray-300 text-gray-900 placeholder-gray-400"} focus:outline-none focus:ring-2 focus:ring-emerald-500`})]}),d.sample_content&&d.sample_content.length>0&&!k&&e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s?"text-gray-400":"text-gray-600"}`,children:"Try with samples:"}),xe?e.jsx("div",{className:"flex flex-wrap gap-2",children:d.sample_content.map((t,a)=>e.jsx("button",{onClick:()=>Be(t),disabled:te!==null,className:`px-3 py-2 text-xs rounded-lg transition-colors ${s?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"} ${te===t.label?"opacity-50":""}`,children:t.label},a))}):e.jsx("div",{className:"flex flex-wrap gap-2",children:d.sample_content.map((t,a)=>e.jsx("button",{onClick:()=>Be(t),disabled:te!==null,className:`relative group overflow-hidden rounded-lg transition-all ${te===t.label?"opacity-50":"hover:ring-2 hover:ring-indigo-500"} ${s?"bg-gray-700":"bg-gray-100"}`,title:t.label,children:d.moderation_type==="image"&&t.url?e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:t.url,alt:t.label,className:"w-full h-full object-cover"}),te===t.label&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
114ded-full animate-spin"})})]}):e.jsxs("div",{className:`px-3 py-2 text-xs flex items-center gap-1.5 ${s?"text-gray-300":"text-gray-700"}`,children:[t.icon==="music"&&e.jsx(Zt,{className:"w-3.5 h-3.5"}),t.icon==="video"&&e.jsx(Kt,{className:"w-3.5 h-3.5"}),t.icon==="audio"&&e.jsx(Vt,{className:"w-3.5 h-3.5"}),te===t.label?"Loading...":t.label]})},a))})]}),e.jsxs("button",{onClick:bt,disabled:!Ge||ne,className:`w-full mt-4 flex items-center justify-center gap-2 px-4 py-3 rounded-lg transition-colors ${!Ge||ne?"bg-gray-600 text-gray-400 cursor-not-allowed":s?"bg-emerald-800 hover:bg-emerald-700 text-white":"bg-emerald-500 hover:bg-emerald-600 text-white"}`,children:[e.jsx(es,{className:"h-5 w-5"}),ne?V==="async"?lt==="processing"?"Processingâ¦":"Queuedâ¦":"Running...":"Run"]})]}),C&&e.jsxs("div",{className:`rounded-xl p-6 ${s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border`,children:[e.jsx("h3",{className:`font-semibold mb-4 ${s?"text-white":"text-gray-900"}`,children:"Results"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`p-3 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-xs mb-1 ${s?"text-gray-400":"text-gray-600"}`,children:"Status"}),e.jsx("div",{className:`text-sm font-semibold ${s?"text-emerald-400":"text-emerald-600"}`,children:C.status||"completed"})]}),e.jsxs("div",{className:`p-3 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-xs mb-1 ${s?"text-gray-400":"text-gray-600"}`,children:"Processing Time"}),e.jsxs("div",{className:`text-sm font-semibold ${s?"text-white":"text-gray-900"}`,children:[C.response_time_ms,"ms"]})]})]}),C.result&&(v==="wanted-person-detection"||v==="wanted-person-detection-image")?e.jsxs("div",{className:`p-4 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-sm font-medium mb-3 ${s?"text-gray-300":"text-gray-700"}`,children:"Analysis Results"}),C.result.matches&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`text-sm font-medium ${s?"text-gray-300":"text-gray-700"}`,children:["Matches (",C.result.matches.length,")"]}),C.result.matches.length===0?e.jsx("div",{className:`text-sm ${s?"text-gray-500":"text-gray-600"} italic`,children:"No wanted persons detected"}):C.result.matches.map((t,a)=>e.jsxs("div",{className:`p-4 rounded-lg ${s?"bg-gray-950/50 border border-gray-800":"bg-white border border-gray-200"}`,children:[e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[t.best_match?.face_crop_png&&e.jsx("img",{src:`data:image/png;base64,${t.best_match.face_crop_png}`,alt:"Detected face",className:"w-20 h-20 rounded-lg object-cover border-2 border-red-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`text-lg font-semibold ${s?"text-white":"text-gray-900"}`,children:t.matched_person?.name||"Unknown"}),e.jsxs("div",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:["Source: ",e.jsx("span",{className:"font-medium",children:t.matched_person?.source?.replace(/_/g," ")})]}),t.matched_person?.metadata?.nationalities&&e.jsxs("div",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:["Nationality: ",e.jsx("span",{className:"font-medium",children:t.matched_person.metadata.nationalities.join(", ")})]}),t.matched_person?.metadata?.date_of_birth&&e.jsxs("div",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:["DOB: ",e.jsx("span",{className:"font-medium",children:t.matched_person.metadata.date_of_birth})]})]})]}),e.jsxs("div",{className:`p-3 rounded-lg mb-3 ${s?"bg-gray-900/50":"bg-gray-100"}`,children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s?"text-gray-400":"text-gray-600"}`,children:"Best Match"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.best_match?.timestamp_ms!==null&&t.best_match?.timestamp_ms!==void 0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Timestamp"}),e.jsxs("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:[Math.floor(t.best_match.timestamp_ms/1e3),"s (",t.best_match.timestamp_ms,"ms)"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Frame/Image"}),e.jsxs("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:["#",t.best_match?.index]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Distance"}),e.jsx("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:t.best_match?.distance?.toFixed(4)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Similarity"}),e.jsxs("div",{className:`text-sm font-medium ${s?"text-emerald-400":"text-emerald-600"}`,children:[((t.best_match?.similarity||0)*100).toFixed(1),"%"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Detection Score"}),e.jsxs("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:[((t.best_match?.det_score||0)*100).toFixed(1),"%"]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:["Detected in ",e.jsx("span",{className:"font-medium",children:t.occurrence_count})," frame",t.occurrence_count!==1?"s":""]}),t.all_detections&&t.all_detections.length>1&&e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:`curs
114or-pointer ${s?"text-blue-400":"text-blue-600"}`,children:"View all detections"}),e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${s?"bg-gray-900/50":"bg-gray-100"}`,children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:s?"text-gray-500":"text-gray-600",children:[e.jsx("th",{className:"text-left py-1",children:"Frame"}),e.jsx("th",{className:"text-left py-1",children:"Time"}),e.jsx("th",{className:"text-right py-1",children:"Distance"}),e.jsx("th",{className:"text-right py-1",children:"Similarity"})]})}),e.jsx("tbody",{children:t.all_detections.map((r,n)=>e.jsxs("tr",{className:s?"text-gray-300":"text-gray-700",children:[e.jsxs("td",{className:"py-1",children:["#",r.index]}),e.jsx("td",{className:"py-1",children:r.timestamp_ms!==null?`${(r.timestamp_ms/1e3).toFixed(1)}s`:"-"}),e.jsx("td",{className:"text-right py-1",children:r.distance?.toFixed(4)}),e.jsxs("td",{className:"text-right py-1",children:[((r.similarity||0)*100).toFixed(1),"%"]})]},n))})]})})]})]})]},a))]}),C.result.stats&&e.jsxs("div",{className:`mt-4 p-3 rounded-lg ${s?"bg-gray-950/50 border border-gray-800":"bg-white border border-gray-200"}`,children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s?"text-gray-400":"text-gray-600"}`,children:"Processing Stats"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Input Type"}),e.jsx("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:C.result.stats.input_type})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Frames/Images"}),e.jsx("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:C.result.stats.items_processed})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Faces Detected"}),e.jsx("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:C.result.stats.faces_detected})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Matches"}),e.jsx("div",{className:`text-sm font-medium ${C.result.stats.unique_matches>0?s?"text-red-400":"text-red-600":s?"text-white":"text-gray-900"}`,children:C.result.stats.unique_matches})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"Time"}),e.jsxs("div",{className:`text-sm font-medium ${s?"text-white":"text-gray-900"}`,children:[(C.result.stats.processing_time_ms/1e3).toFixed(2),"s"]})]})]})]})]}):C.result&&e.jsxs("div",{className:`p-4 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:[e.jsx("div",{className:`text-sm font-medium mb-3 ${s?"text-gray-300":"text-gray-700"}`,children:"Analysis Results"}),C.result.png_image_base64&&e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s?"text-gray-400":"text-gray-600"}`,children:"Processed Image"}),e.jsx("div",{className:`rounded-lg overflow-hidden border ${s?"border-gray-700":"border-gray-200"}`,children:e.jsx("img",{src:`data:image/png;base64,${C.result.png_image_base64}`,alt:"Processed result",className:"w-full h-auto max-h-96 object-contain bg-gray-900"})}),e.jsxs("a",{href:`data:image/png;base64,${C.result.png_image_base64}`,download:"processed-image.png",className:`inline-flex items-center gap-1.5 mt-2 text-xs font-medium ${s?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-700"}`,children:[e.jsx(ts,{className:"w-3.5 h-3.5"}),"Download Image"]})]}),e.jsx("div",{className:"space-y-3",children:Object.entries(C.result).filter(([t])=>t!=="hotspots"&&t!=="png_image_base64").map(([t,a])=>{const r=(i,o)=>{if(typeof i=="boolean")return i?"Yes":"No";if(typeof i=="number"){const g=o&&["age","from_age","to_age","uncertainty","race_code","gender_code"].some($=>o.toLowerCase().includes($));return!Number.isInteger(i)&&i>=0&&i<=1&&!g?`${(i*100).toFixed(1)}%`:Number.isInteger(i)?i.toString():i.toFixed(3)}return String(i)},n=i=>typeof i=="boolean"?i?"text-green-500":"text-red-500":s?"text-white":"text-gray-900";return Array.isArray(a)?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:`text-sm font-medium ${s?"text-gray-300":"text-gray-700"}`,children:[t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())," (",a.length,")"]}),a.map((i,o)=>e.jsxs("div",{className:`ml-4 p-3 rounded-lg ${s?"bg-gray-950/50 border border-gray-800":"bg-white border border-gray-200"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[Fe[o]&&i.bbox&&e.jsx("img",{src:Fe[o],alt:`Detection ${o+1}`,className:"w-16 h-16 rounded-lg object-cover border-2",style:{borderColor:E[o%E.length]}}),e.jsxs("div",{className:`text-xs font-medium ${s?"text-gray-400":"text-gray-600"}`,children:["Item ",o+1]})]}),typeof i=="object"&&i!==null?e.jsx("div",{className:"space-y-2",children:Object.entries(i).map(([m,g])=>
114{if(m==="bbox"){const y=E[o%E.length];return e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:"Bounding Box"}),e.jsx("button",{onClick:()=>yt(a,o),className:"text-xs font-medium underline hover:opacity-70 transition-opacity",style:{color:y},children:"show"})]},m)}return m==="mask_png"?null:Array.isArray(g)?e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:m.replace(/_/g," ").replace(/\b\w/g,y=>y.toUpperCase())}),g.length>0?e.jsx("div",{className:"space-y-1 mt-1",children:g.map((y,c)=>e.jsx("div",{className:`ml-2 p-2 rounded text-xs ${s?"bg-gray-900/50":"bg-gray-100"}`,children:typeof y=="object"&&y!==null?e.jsx("div",{className:"space-y-0.5",children:Object.entries(y).map(([$,R])=>e.jsxs("div",{className:"flex justify-between items-center gap-2",children:[e.jsxs("span",{className:s?"text-gray-500":"text-gray-600",children:[$,":"]}),e.jsx("span",{className:`font-medium ${s?"text-white":"text-gray-900"}`,children:String(R)})]},$))}):String(y)},c))}):e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:"(empty)"})]},m):e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:m.replace(/_/g," ").replace(/\b\w/g,y=>y.toUpperCase())}),e.jsx("span",{className:`text-xs font-medium ${n(g)}`,children:typeof g=="object"&&g!==null?JSON.stringify(g):r(g,m)})]},m)})}):e.jsx("span",{className:`text-xs ${s?"text-white":"text-gray-900"}`,children:r(i,t)})]},o))]},t):typeof a=="object"&&a!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:`text-sm font-medium ${s?"text-gray-300":"text-gray-700"}`,children:t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}),e.jsx("div",{className:`ml-4 p-3 rounded-lg ${s?"bg-gray-950/50 border border-gray-800":"bg-white border border-gray-200"}`,children:e.jsx("div",{className:"space-y-2",children:Object.entries(a).map(([i,o])=>Array.isArray(o)?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:`text-xs font-medium ${s?"text-gray-400":"text-gray-600"}`,children:[i.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase())," (",o.length,")"]}),o.length>0?e.jsx("div",{className:"space-y-2 mt-1",children:o.map((m,g)=>e.jsx("div",{className:`ml-3 p-2 rounded-lg ${s?"bg-gray-900/30 border border-gray-700":"bg-gray-100 border border-gray-200"}`,children:typeof m=="object"&&m!==null?e.jsx("div",{className:"space-y-1",children:Object.entries(m).map(([y,c])=>e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:y.replace(/_/g," ").replace(/\b\w/g,$=>$.toUpperCase())}),e.jsx("span",{className:`text-xs font-medium text-right ${s?"text-white":"text-gray-900"}`,children:String(c)})]},y))}):e.jsx("span",{className:`text-xs ${s?"text-white":"text-gray-900"}`,children:String(m)})},g))}):e.jsx("span",{className:`text-xs ml-3 ${s?"text-gray-500":"text-gray-600"}`,children:"(empty)"})]},i):typeof o=="object"&&o!==null&&!Array.isArray(o)?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:`text-xs font-medium ${s?"text-gray-400":"text-gray-600"}`,children:i.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase())}),e.jsx("div",{className:`ml-3 pl-3 border-l-2 space-y-1 ${s?"border-gray-700":"border-gray-300"}`,children:Object.entries(o).map(([m,g])=>e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:m.replace(/_/g," ").replace(/\b\w/g,y=>y.toUpperCase())}),e.jsx("span",{className:`text-xs font-medium ${n(g)}`,children:r(g,m)})]},m))})]},i):e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:i.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase())}),e.jsx("span",{className:`text-xs font-medium ${n(o)}`,children:r(o,i)})]},i))})})]},t):e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:`text-sm ${s?"text-gray-400":"text-gray-600"}`,children:t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}),e.jsx("span",{className:`text-sm font-medium ${n(a)}`,children:r(a,t)}
114)]},t)})})]}),e.jsxs("details",{className:`rounded-lg ${s?"bg-gray-900/30":"bg-gray-50"}`,children:[e.jsx("summary",{className:`cursor-pointer p-3 font-medium text-sm ${s?"text-gray-300":"text-gray-700"}`,children:"View Raw Response"}),e.jsx("div",{className:"p-4 pt-0",children:e.jsx("pre",{className:`text-xs rounded-lg p-3 overflow-x-auto ${s?"bg-gray-900 text-gray-300":"bg-white text-gray-800"} border ${s?"border-gray-700":"border-gray-200"}`,children:JSON.stringify(C,null,2)})})]})]})]}),C&&e.jsxs("div",{className:`flex items-start gap-2 p-3 rounded-lg ${s?"bg-gray-800/50 border border-gray-700":"bg-gray-100 border border-gray-200"}`,children:[e.jsx(ss,{className:`w-3.5 h-3.5 mt-0.5 flex-shrink-0 ${s?"text-gray-500":"text-gray-400"}`}),e.jsx("p",{className:"text-xs text-gray-500",children:"This analysis is produced by an artificial intelligence model trained on millions of images, videos, and audio files. Although the system applies advanced statistical and machine-learning techniques, it may generate false positives or false negatives. Accordingly, AI detection results are provided for informational purposes only and should not be relied upon as the sole basis for any decision. Users are advised to apply their own judgment and verify findings using additional sources or contextual information."})]})]}),e.jsxs("div",{className:`rounded-xl p-6 ${s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"} border h-fit sticky top-6`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`p-2 rounded-lg ${s?"bg-indigo-900/30":"bg-indigo-100"}`,children:e.jsx(Ke,{className:`h-5 w-5 ${s?"text-indigo-400":"text-indigo-600"}`})}),e.jsx("h3",{className:`font-semibold ${s?"text-white":"text-gray-900"}`,children:"API Playground"})]}),e.jsxs("select",{"aria-label":"Request mode",title:"Request mode",value:V,onChange:t=>it(t.target.value),disabled:ne,className:`px-2.5 py-1.5 text-xs font-medium rounded-lg border transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 ${s?"bg-gray-700 border-gray-600 text-gray-200":"bg-white border-gray-300 text-gray-700"} ${ne?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[e.jsx("option",{value:"async",children:"Async â recommended"}),e.jsx("option",{value:"sync",children:"Sync"})]})]}),e.jsx("div",{className:`flex gap-1 mb-4 p-1 rounded-lg ${s?"bg-gray-900/50":"bg-gray-50"}`,children:["curl","python","javascript","nodejs"].map(t=>e.jsx("button",{onClick:()=>ot(t),className:`flex-1 px-3 py-2 text-xs font-medium rounded-md transition-all whitespace-nowrap ${de===t?"bg-indigo-600 text-white shadow-sm":s?"text-gray-400 hover:text-gray-300":"text-gray-600 hover:text-gray-900"}`,children:t.toUpperCase()},t))}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:`text-sm font-medium ${s?"text-gray-300":"text-gray-700"}`,children:"Request"}),e.jsx("button",{onClick:vt,className:`flex items-center gap-1.5 px-2 py-1 text-xs rounded-md transition-colors ${Ye?s?"bg-emerald-900/30 text-emerald-400":"bg-emerald-100 text-emerald-700":s?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"}`,children:Ye?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"h-3 w-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(at,{className:"h-3 w-3"}),"Copy"]})})]}),e.jsxs("div",{className:`rounded-lg border ${s?"bg-gray-950 border-gray-700":"bg-gray-950 border-gray-800"}`,children:[e.jsx("div",{className:`px-3 py-2 border-b ${s?"bg-gray-900 border-gray-700":"bg-gray-900 border-gray-800"}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:de})}),e.jsx("div",{className:"p-4 overflow-x-auto",children:e.jsx("pre",{className:"text-xs font-mono leading-relaxed text-gray-300",children:e.jsx("code",{dangerouslySetInnerHTML:{__html:Nt(Xe[de],de)}})})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:`text-sm font-medium mb-2 ${s?"text-gray-300":"text-gray-700"}`,children:"Response Example"}),e.jsxs("div",{className:`rounded-lg border ${s?"bg-gray-950 border-gray-700":"bg-gray-950 border-gray-800"}`,children:[e.jsx("div",{className:`px-3 py-2 border-b ${s?"bg-gray-900 border-gray-700":"bg-gray-900 border-gray-800"}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-400",children:"json"})}),e.jsx("div",{className:"p-4 overflow-x-auto",children:e.jsx("pre",{className:"text-xs font-mono leading-relaxed text-gray-300",children:e.jsx("code",{dangerouslySetInnerHTML:{__html:jt(d.example_response?JSON.stringify(d.example_response,null,2):`{ 115 "status": "success", 116 "message": "No example response available for this model" 117}`)}})})})]})]}),d.output_schema&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h4",{className:`text-sm font-medium mb-3 ${s?"text-gray-300":"text-gray-700"}`,children:"Response Fields"}),e.jsx("div",{className:"space-y-2",children:d.output_schema.fields.map(t=>e.jsxs("div",{className:`p-3 rounded-lg ${s?"bg-gray-900/50 border border-gray-800":"bg-gray-50 border border-gray-200"}`,children:[e.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[e.jsx("code",{className:`text-xs font-mono ${s?"text-purple-400":"text-purple-600"}`,children:t.name}),e.jsx("span",{className:`px-1.5 py-0.5 text-xs rounded ${s?"bg-gray-800 text-gray-400":"bg-gray-200 text-gray-600"}`,children:t.type})]}),e.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-600"}`,children:t.description}),t.type==="object"&&t.properties&&e.jsx("div",{className:`mt-3 p-3 rounded-lg space-y-2 ${s?"bg-gray-950/50 border border-gray-700":"bg-white border border-gray-200"}`,children:t.properties.map(a=>e.jsxs("div",{className:"pb-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-start gap-1.5 mb-0.5",children:[e.jsx("code",{className:`text-xs font-mono ${s?"text-emerald-400":"text-emerald-600"}`,children:a.name}),e.jsx("span",{className:"px-1 py-0.5 text-xs text-gray-500",children:a.type})]}),a.description&&e.jsx("p",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:a.description}),a.possible_values&&a.possible_values.length>0&&e.jsxs("div",{className:"mt-1.5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Possible values:"," "]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:a.possible_values.map(r=>e.jsx("code",{className:`px-1.5 py-0.5 rounded text-xs font-mono ${s?"bg-purple-900/30 text-purple-300":"bg-purple-100 text-purple-700"}`,children:r},r))})]}),a.type==="object"&&a.properties&&e.jsx("div",{className:`mt-1.5 ml-2 pl-2 border-l-2 ${s?"border-gray-700":"border-gray-300"}`,children:a.properties.map(r=>e.jsx("div",{className:"py-0.5",children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("code",{className:`text-xs font-mono ${s?"text-cyan-400":"text-cyan-600"}`,children:r.name}),e.jsx("span",{className:"text-xs text-gray-500",children:r.type})]})},r.name))})]},a.name))}),t.type==="array"&&t.items?.properties&&e.jsxs("div",{className:`mt-3 p-3 rounded-lg space-y-2 ${s?"bg-gray-950/50 border border-gray-700":"bg-white border border-gray-200"}`,children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s?"text-gray-400":"text-gray-600"}`,children:"Array Item Properties:"}),t.items.properties.map(a=>e.jsxs("div",{className:"pb-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-start gap-1.5 mb-0.5",children:[e.jsx("code",{className:`text-xs font-mono ${s?"text-emerald-400":"text-emerald-600"}`,children:a.name}),e.jsx("span",{className:"px-1 py-0.5 text-xs text-gray-500",children:a.type})]}),a.description&&e.jsx("p",{className:`text-xs ${s?"text-gray-500":"text-gray-600"}`,children:a.description}),a.possible_values&&a.possible_values.length>0&&e.jsxs("div",{className:"mt-1.5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Possible values:"," "]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:a.possible_values.map(r=>e.jsx("code",{className:`px-1.5 py-0.5 rounded text-xs font-mono ${s?"bg-purple-900/30 text-purple-300":"bg-purple-100 text-purple-700"}`,children:r},r))})]})]},a.name))]})]},t.name))})]})]})]})})]})]})};export{xs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.