1import{j as e}from"./vendor-ui-apakGoHS.js";import{r,L as Y}from"./vendor-react-jvbcysPe.js";import{m as Z,d as ee,b as te,s as se}from"./index-C-zKQm9Z.js";import{u as ae}from"./vendor-data-8a2i1Wjw.js";import{B as D}from"./button-DFXx_IH3.js";import{I as le}from"./input-D3dvjsgZ.js";import{B as j}from"./badge-CeaPXS8z.js";import{F as M}from"./filter-CJkSOWEp.js";import{F as re}from"./file-text-CKB4fzMw.js";import{E as oe}from"./external-link-CepXWAIq.js";import{C as ne}from"./copy-CFwO1GUF.js";import{F as ie}from"./flask-conical-3JWesKGo.js";import{L as ce}from"./link-2-YXj1yUaV.js";import{B as de}from"./book-open-BmP9HWHv.js";import{C as me}from"./circle-check-big-DLu5-UDG.js";import{C as I}from"./circle-x-Z_dMVE2m.js";import{C as xe}from"./chevron-right-ykjnKUey.js";const l=t=>t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:typeof t=="object"?Object.keys(t).length>0:!0,ue=t=>Array.isArray(t)?t.length:0,B=(t,o)=>o===0?"0":(t/o*100).toFixed(0);function N({label:t,count:o,total:i}){const p=Number(B(o,i)),d=p>=80?"hsl(142,76%,36%)":p>=50?"hsl(45,93%,47%)":"hsl(0,84%,60%)";return e.jsxs("div",{className:"rounded-lg border border-border p-4 bg-card flex-1 min-w-[140px]",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-sans mb-1",children:t}),e.jsx("p",{className:"text-2xl font-mono font-bold",style:{color:d},children:o}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[B(o,i),"% of ",i]})]})}function h({title:t,icon:o,defaultOpen:i=!1,children:p}){const[d,S]=r.useState(i);return e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden mb-3",children:[e.jsxs("button",{className:"flex items-center gap-2 w-full px-4 py-3 bg-muted/30 hover:bg-muted/50 transition-colors text-left",onClick:()=>S(!d),children:[d?e.jsx(te,{className:"h-4 w-4 shrink-0"}):e.jsx(xe,{className:"h-4 w-4 shrink-0"}),o,e.jsx("span",{className:"text-sm font-semibold font-sans",children:t})]}),d&&e.jsx("div",{className:"p-4 border-t border-border",children:p})]})}function y({data:t}){return l(t)?e.jsx("pre",{className:"text-xs font-mono bg-muted/40 p-3 rounded-lg max-h-[300px] overflow-auto whitespace-pre-wrap break-words",children:JSON.stringify(t,null,2)}):e.jsx(f,{label:"Not set"})}function f({label:t}){return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg text-sm",style:{background:"hsla(45,93%,47%,0.05)",border:"1px solid hsla(45,93%,47%,0.2)"},children:[e.jsx(I,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-muted-foreground",children:t})]})}function c({label:t,value:o,mono:i=!1}){return e.jsxs("div",{className:"flex gap-2 py-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-32 shrink-0 font-sans",children:t}),e.jsx("span",{className:`text-sm ${i?"font-mono":"font-sans"}`,children:o??"â"})]})}function v({value:t,count:o}){return l(t)?e.jsxs("span",{className:"flex items-center gap-1",style:{color:"hsl(142,76%,36%)"},children:[e.jsx(me,{className:"h-3.5 w-3.5"}),o!==void 0&&o>0&&e.jsx("span",{className:"text-xs font-mono",children:o})]}):e.jsx(I,{className:"h-3.5 w-3.5 text-destructive"})}function he({title:t,description:o,slug:i,category:p}){const d=`https://procalc.ai/${p}/${i}`;return e.jsxs("div",{className:"bg-muted/30 rounded-lg p-3 mt-2",children:[e.jsx("p",{className:"text-sm font-sans",style:{color:"hsl(217,91%,60%)"},children:t||"Untitled"}),e.jsx("p",{className:"text-xs font-mono",style:{color:"hsl(142,76%,36%)"},children:d}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o||"No description"})]})}const H=["faq","how_to_content","formula_content","source_citations","seo_content"];function qe(){var T,$;const[t,o]=r.useState(null),[i,p]=r.useState(""),[d,S]=r.useState("all"),[_,P]=r.useState("all"),[w,R]=r.useState(!1),[b,J]=r.useState("category"),[g,O]=r.useState(!0),[F,Q]=r.useState(Object.fromEntries(H.map(s=>[s,"all"]))),z=r.useCallback(s=>{Q(a=>{const n=a[s]||"all",m=n==="all"?"has":n==="has"?"missing":"all";return{...a,[s]:m}})},[]),[q,K]=r.useState(40),A=r.useRef(null),L=r.useRef(!1),V=r.useCallback(s=>{s.preventDefault(),L.current=!0;const a=m=>{if(!L.current||!A.current)return;const C=A.current.getBoundingClientRect(),k=(m.clientX-C.left)/C.width*100;K(Math.max(20,Math.min(80,k)))},n=()=>{L.current=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",a),window.addEventListener("mouseup",n)},[]),{data:x=[],isLoading:U}
1=ae({queryKey:["schema-inspector-calcs"],queryFn:async()=>{const{data:s,error:a}=await se.from("calculators").select("id, name, slug, domain, subcategory, status, priority_tier, compute_tier, est_monthly_searches, faq, how_to_content, formula_content, source_citations, seo_content, input_schema, formula_code, formula_type, compute_function, client_libraries, ref_tables, display_blocks, default_example, test_cases, rabbit_holes, system_prompt, meta_title, meta_description, difficulty, related_calculators").order("domain",{ascending:!0});if(a)throw a;return s??[]}}),X=r.useMemo(()=>[...new Set(x.map(s=>s.domain))].sort(),[x]),E=r.useMemo(()=>{let s=x;if(i){const a=i.toLowerCase();s=s.filter(n=>n.name.toLowerCase().includes(a)||n.slug.toLowerCase().includes(a))}d!=="all"&&(s=s.filter(a=>a.domain===d)),_!=="all"&&(s=s.filter(a=>a.status===_)),w&&(s=s.filter(a=>!l(a.faq)||!l(a.how_to_content)||!l(a.formula_content)||!l(a.source_citations)||!l(a.seo_content)));for(const a of H){const n=F[a];n==="has"?s=s.filter(m=>l(m[a])):n==="missing"&&(s=s.filter(m=>!l(m[a])))}return s=[...s].sort((a,n)=>{const m=a[b]??"",C=n[b]??"",k=String(m).localeCompare(String(C));return g?k:-k}),s},[x,i,d,_,w,b,g,F]),u=r.useMemo(()=>({total:x.length,hasFaq:x.filter(a=>l(a.faq)).length,hasHowTo:x.filter(a=>l(a.how_to_content)).length,hasFormula:x.filter(a=>l(a.formula_content)).length,hasSources:x.filter(a=>l(a.source_citations)).length}),[x]),G=r.useCallback(s=>{b===s?O(!g):(J(s),O(!0))},[b,g]),W=r.useCallback(()=>{t&&(navigator.clipboard.writeText(JSON.stringify(t,null,2)),Z.success("Copied calculator JSON to clipboard"))},[t]);return e.jsxs("div",{ref:A,className:"flex flex-col lg:flex-row h-full min-h-0",children:[e.jsxs("div",{className:"flex flex-col min-h-0 overflow-hidden",style:{width:`${q}%`},children:[e.jsx("h2",{className:"text-lg font-semibold font-sans mb-3",children:"Content Coverage Audit"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(N,{label:"Total Calculators",count:u.total,total:u.total}),e.jsx(N,{label:"Has FAQ",count:u.hasFaq,total:u.total}),e.jsx(N,{label:"Has How-To",count:u.hasHowTo,total:u.total}),e.jsx(N,{label:"Has Formula",count:u.hasFormula,total:u.total}),e.jsx(N,{label:"Has Sources",count:u.hasSources,total:u.total})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[140px]",children:[e.jsx(ee,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(le,{placeholder:"Search...",value:i,onChange:s=>p(s.target.value),className:"pl-8 h-9 text-sm"})]}),e.jsxs("select",{value:d,onChange:s=>S(s.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"all",children:"All Domains"}),X.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsxs("select",{value:_,onChange:s=>P(s.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"live",children:"Live"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"archived",children:"Archived"})]}),e.jsxs(D,{variant:w?"default":"outline",size:"sm",className:"h-9",onClick:()=>R(!w),children:[e.jsx(M,{className:"h-3.5 w-3.5 mr-1"}),"Missing"]})]}),e.jsx("div",{className:"flex-1 overflow-auto border border-border rounded-lg",children:U?e.jsx("div",{className:"p-8 text-center text-muted-foreground text-sm",children:"Loading calculators..."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-muted/60 z-10",children:e.jsx("tr",{children:[{key:"name",label:"Calc",filterable:!1},{key:"domain",label:"Dom",filterable:!1},{key:"status",label:"Sts",filterable:!1},{key:"faq",label:"FAQ",filterable:!0},{key:"how_to_content",label:"How",filterable:!0},{key:"formula_content",label:"Frm",filterable:!0},{key:"source_citations",label:"Src",filterable:!0},{key:"seo_content",label:"SEO",filterable:!0}].map(s=>{const a=F[s.key],n=a==="has"?" â
":a==="missing"?" â":"";return e.jsxs("th",{className:"px-1 py-1.5 text-left text-[11px] font-medium text-muted-foreground select-none whitespace-nowrap",children:[e.jsxs("span",{className:"cursor-pointer hover:text-foreground",onClick:()=>
1G(s.key),children:[s.label,b===s.key&&(g?" â":" â")]}),s.filterable&&e.jsx("button",{onClick:m=>{m.stopPropagation(),z(s.key)},className:"ml-1 inline-flex items-center justify-center rounded px-1 text-[10px] font-mono hover:bg-muted transition-colors",title:`Filter: ${a||"all"} â click to cycle`,children:n||e.jsx(M,{className:"h-3 w-3 opacity-30"})})]},s.key)})})}),e.jsx("tbody",{children:E.map(s=>e.jsxs("tr",{className:`border-t border-border cursor-pointer transition-colors hover:bg-muted/30 ${(t==null?void 0:t.id)===s.id?"bg-primary/5":""}`,onClick:()=>o(s),children:[e.jsx("td",{className:"px-1 py-1 font-sans max-w-[130px] truncate text-xs",children:s.name}),e.jsx("td",{className:"px-1 py-1 font-mono text-[11px]",children:s.domain}),e.jsx("td",{className:"px-1 py-1",children:e.jsx(j,{variant:s.status==="live"?"default":"secondary",className:"text-[10px] px-1 py-0",children:s.status})}),e.jsx("td",{className:"px-1 py-1 text-center",children:e.jsx(v,{value:s.faq,count:ue(s.faq)})}),e.jsx("td",{className:"px-1 py-1 text-center",children:e.jsx(v,{value:s.how_to_content})}),e.jsx("td",{className:"px-1 py-1 text-center",children:e.jsx(v,{value:s.formula_content})}),e.jsx("td",{className:"px-1 py-1 text-center",children:e.jsx(v,{value:s.source_citations})}),e.jsx("td",{className:"px-1 py-1 text-center",children:e.jsx(v,{value:s.seo_content})})]},s.id))})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2 font-mono",children:[E.length," calculators shown"]})]}),e.jsx("div",{className:"hidden lg:flex items-center justify-center cursor-col-resize hover:bg-primary/10 transition-colors shrink-0",style:{width:8},onMouseDown:V,children:e.jsx("div",{className:"w-0.5 h-8 rounded-full bg-border"})}),e.jsx("div",{className:"flex flex-col min-h-0 overflow-hidden",style:{width:`${100-q}%`},children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("h2",{className:"text-lg font-semibold font-sans mr-auto",children:t.name}),e.jsxs(Y,{to:`/admin/calculators/${t.slug}`,className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(re,{className:"h-3.5 w-3.5"})," Edit in Editor â"]}),e.jsxs("a",{href:`/${(T=t.domain)==null?void 0:T.toLowerCase()}/${t.slug}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[e.jsx(oe,{className:"h-3.5 w-3.5"})," View Live â"]}),e.jsxs(D,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:W,children:[e.jsx(ne,{className:"h-3 w-3 mr-1"})," Copy JSON"]})]}),e.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[e.jsx(h,{title:"Identity",defaultOpen:!0,children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4",children:[e.jsx(c,{label:"Name",value:t.name}),e.jsx(c,{label:"Slug",value:t.slug,mono:!0}),e.jsx(c,{label:"Domain",value:t.domain}),e.jsx(c,{label:"Subcategory",value:t.subcategory}),e.jsx(c,{label:"Status",value:e.jsx(j,{variant:t.status==="live"?"default":"secondary",children:t.status})}),e.jsx(c,{label:"Priority",value:t.priority_tier,mono:!0}),e.jsx(c,{label:"Volume",value:t.est_monthly_searches?`${(t.est_monthly_searches/1e3).toFixed(1)}K/mo`:"â",mono:!0}),e.jsx(c,{label:"Compute Tier",value:t.compute_tier,mono:!0}),e.jsx(c,{label:"Difficulty",value:t.difficulty})]})}),e.jsx(h,{title:"Input Schema",children:e.jsx(y,{data:t.input_schema})}),e.jsxs(h,{title:"Formula / Compute",icon:e.jsx(ie,{className:"h-4 w-4"}),children:[e.jsx(c,{label:"Formula Type",value:t.formula_type&&e.jsx(j,{variant:"outline",children:t.formula_type})}),e.jsx(c,{label:"Compute Function",value:t.compute_function,mono:!0}),l(t.client_libraries)&&e.jsx("div",{className:"flex gap-1 flex-wrap mt-2",children:t.client_libraries.map(s=>e.jsx(j,{variant:"secondary",className:"text-xs",children:s},s))}),l(t.ref_tables)&&e.jsx("div",{className:"flex gap-1 flex-wrap mt-2",children:t.ref_tables.map(s=>e.jsx(j,{variant:"outline",className:"text-xs font-mono",children:s},s))}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"formula_code"}),e.jsx(y,{data:t.formula_code})]})]}),e.jsxs(h,{title:"Display Blocks",children:[l(t.display_blocks)&&Array.isArray(t.display_blocks)&&e.jsx("div",{className:"flex gap-1 flex-wrap mb-3",children:t.display_blocks.map((s,a)=>e.jsx(j,{variant:"secondary",className:"text-xs",children:s.type||s.block_type||"unknown"},a))}),e.jsx(y,{data:t.display_blocks})]}),e.jsxs(h,{title:"Default Example",children:[l(t.default_example)&&(($=t.default_example)==null?void 0:$.label)&&e.jsx("p",{className:"text-sm font-semibold mb-2",children:t.default_example.label}),e.jsx(y,{data:t.default_example})]}),e.jsxs(h,{title:"Content Fields",icon:e.jsx(de,{className:"h-4 w-4"}),defaultOpen:!0,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"FAQ"}
1),l(t.faq)&&Array.isArray(t.faq)?e.jsx("ol",{className:"space-y-2 pl-4 list-decimal",children:t.faq.map((s,a)=>e.jsxs("li",{className:"text-sm",children:[e.jsxs("p",{className:"font-semibold",children:["Q: ",s.question||s.q]}),e.jsxs("p",{className:"text-muted-foreground",children:["A: ",s.answer||s.a]})]},a))}):e.jsx(f,{label:"No FAQ content"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"How-To Content"}),l(t.how_to_content)?e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/20 p-3 rounded-lg max-h-[200px] overflow-auto",children:t.how_to_content}):e.jsx(f,{label:"No how-to content"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Formula Content"}),l(t.formula_content)?e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/20 p-3 rounded-lg max-h-[200px] overflow-auto",children:t.formula_content}):e.jsx(f,{label:"No formula content"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Source Citations"}),l(t.source_citations)&&Array.isArray(t.source_citations)?e.jsx("ul",{className:"space-y-1 pl-4 list-disc",children:t.source_citations.map((s,a)=>e.jsx("li",{className:"text-sm",children:typeof s=="string"?s:e.jsxs("span",{children:[s.title||s.name," ",s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs ml-1",children:e.jsx(ce,{className:"inline h-3 w-3"})})]})},a))}):e.jsx(f,{label:"No source citations"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"SEO Content"}),l(t.seo_content)?e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-muted/20 p-3 rounded-lg max-h-[200px] overflow-auto",children:t.seo_content}):e.jsx(f,{label:"No SEO content"})]})]}),e.jsxs(h,{title:"SEO Meta",children:[e.jsx(c,{label:"meta_title",value:e.jsxs("span",{className:"font-mono text-xs",children:[t.meta_title||"â",t.meta_title&&e.jsxs("span",{className:`ml-2 ${t.meta_title.length<=60?"text-[hsl(142,76%,36%)]":"text-destructive"}`,children:["(",t.meta_title.length," chars)"]})]})}),e.jsx(c,{label:"meta_description",value:e.jsxs("span",{className:"font-mono text-xs",children:[t.meta_description||"â",t.meta_description&&e.jsxs("span",{className:`ml-2 ${t.meta_description.length>=140&&t.meta_description.length<=160?"text-[hsl(142,76%,36%)]":"text-[hsl(45,93%,47%)]"}`,children:["(",t.meta_description.length," chars)"]})]})}),e.jsx(he,{title:t.meta_title,description:t.meta_description,slug:t.slug,category:t.domain})]}),e.jsxs(h,{title:"Test Cases",children:[l(t.test_cases)&&Array.isArray(t.test_cases)&&e.jsxs(j,{variant:"secondary",className:"mb-2",children:[t.test_cases.length," cases"]}),e.jsx(y,{data:t.test_cases})]}),e.jsx(h,{title:"Rabbit Holes",children:l(t.rabbit_holes)&&Array.isArray(t.rabbit_holes)?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:t.rabbit_holes.map((s,a)=>e.jsxs("div",{className:"border border-border rounded-lg p-3 bg-muted/20",children:[e.jsxs("p",{className:"text-sm font-semibold",children:[s.emoji||"ð"," ",s.label||s.title||s.text]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.description})]},a))}):e.jsx(f,{label:"No rabbit holes"})}),e.jsx(h,{title:"System Prompt",children:l(t.system_prompt)?e.jsx("pre",{className:"text-xs font-mono bg-muted/40 p-3 rounded-lg max-h-[300px] overflow-auto whitespace-pre-wrap",children:t.system_prompt}):e.jsx(f,{label:"Not set (Tier 1 client-side)"})})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm border border-dashed border-border rounded-lg",children:"â Select a calculator to inspect"})})]})}export{qe 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.