PageSourceSearch

https://radreport.com.br/assets/CalculatorModal-UsDHx789.js

js radreport.com.br collected 2026-09-24 14:36:51 UTC 6,749 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-skQMsM6X.js";import{r as d}from"./vendor-react-DyYvSSk1.js";import{am as S,an as I,aq as V,r as E,v as F,x as R,y as T,z as A,I as z,p as N,c as v}from"./index-BGwtrXIa.js";import{C as D,a as L,b as O}from"./collapsible-CSslgSh4.js";import{bx as W,X as $,ae as q,af as B}from"./vendor-ui-CCmu0bzQ.js";import"./vendor-supabase-BfoV2C50.js";function K({calculator:r,isOpen:x,onClose:c,onInsert:y}){const[l,i]=d.useState({}),[t,o]=d.useState(null),[h,f]=d.useState(!1);d.useEffect(()=>{if(r&&x){o(null);const s={};r.inputs.forEach(a=>{a.defaultValue!==void 0&&(s[a.name]=a.defaultValue)}),i(s),f(!1)}},[r,x]);const u=()=>r?r.inputs.filter(s=>s.showWhen?l[s.showWhen.field]===s.showWhen.value:!0):[];d.useEffect(()=>{if(r&&Object.keys(l).length>0)if(u().every(m=>{const n=l[m.name];return n!==void 0&&n!==""&&n!==null}))try{o(r.calculate(l))}catch{o(null)}else o(null)},[l,r]);const g=(s,a)=>{const m=r==null?void 0:r.inputs.find(n=>n.name===s);if(m)if(m.type==="number"){const n=parseFloat(a);isNaN(n)?a===""&&i(p=>{const j={...p};return delete j[s],j}):i(p=>({...p,[s]:n}))}else i(n=>({...n,[s]:a}))},w=()=>{t&&(y(t.formattedText),c())},C=async()=>{if(t)try{await navigator.clipboard.writeText(t.formattedText),v.success("Resultado copiado")}catch{v.error("Erro ao copiar")}};if(!r)return null;const k=s=>{switch(s){case"success":return"border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300";case"warning":return"border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-300";case"danger":return"border-rose-500/30 bg-rose-500/5 text-rose-700 dark:text-rose-300";default:return"border-primary/20 bg-primary/5 text-foreground"}},b=u();return e.jsx(S,{open:x,onOpenChange:c,children:e.jsxs(I,{className:"max-w-md sm:max-w-md w-[94vw] max-h-[88dvh] sm:max-h-[88vh] flex flex-col p-0 gap-0 rounded-2xl border border-border/40 bg-card/95 backdrop-blur-md overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border/40 pr-10",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(W,{className:"w-3.5 h-3.5 text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-semibold tracking-tight truncate",children:r.name}),r.description&&e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:r.description})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 space-y-3",children:[e.jsx("div",{className:b.length>1?"grid grid-cols-2 gap-2":"grid gap-2",children:b.map(s=>e.jsxs("div",{className:`grid gap-1 ${s.type==="select"?"col-span-2":""}`,children:[e.jsxs(V,{htmlFor:s.name,className:"text-[11px] text-muted-foreground font-normal",children:[s.label," ",s.unit&&e.jsxs("span",{className:"text-muted-foreground/70",children:["(",s.unit,")"]})]}),s.type==="select"&&Array.isArray(s.options)&&s.options.length>0?e.jsxs(E,{value:String(l[s.name]??""),onValueChange:a=>g(s.name,a),children:[e.jsx(F,{className:"h-8 text-xs font-mono",children:e.jsx(R,{placeholder:"Selecione..."})}),e.jsx(T,{children:s.options.map(a=>e.jsx(A,{value:a.value,className:"text-xs",children:a.label},a.value))})]}):e.jsx(z,{id:s.name,type:s.type==="date"?"date":"number",min:s.min,max:s.max,step:s.step,value:l[s.name]??"",onChange:a=>g(s.name,a.target.value),placeholder:s.placeholder,className:"h-8 text-sm font-mono"})]},s.name))}),t&&e.jsxs("div",{className:`rounded-xl border p-3 ${k(t.color)}`,children:[e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-2xl font-bold tabular-nums leading-none",children:typeof t.value=="number"&&!isNaN(t.value)?t.value.toFixed(2):String(t.value??"")}),t.unit&&e.jsx("span",{className:"text-sm font-medium opacity-80",children:t.unit})]}),t.interpretation&&e.jsx("p",{className:"text-xs font-medium mt-1.5 opacity-90",children:t.interpretation})]}),t&&e.jsx("div",{className:"rounded-lg bg-muted/40 border border-border/40 px-2.5 py-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("p",{className:"text-[11px] text-foreground
1/80 flex-1 leading-relaxed line-clamp-3",children:t.formattedText}),e.jsx("button",{onClick:C,className:"shrink-0 p-1 rounded hover:bg-background/60 transition-colors",title:"Copiar texto",children:e.jsx($,{className:"w-3 h-3 text-muted-foreground"})})]})}),r.info&&e.jsxs(D,{open:h,onOpenChange:f,children:[e.jsxs(L,{className:"flex items-center gap-1.5 w-full px-2 py-1.5 rounded-md hover:bg-muted/50 transition-colors text-[11px] text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Sobre esta escala"}),e.jsx(q,{className:`w-3 h-3 ml-auto transition-transform ${h?"rotate-180":""}`})]}),e.jsxs(O,{className:"mt-1.5 px-3 py-2.5 bg-muted/40 border border-border/40 rounded-lg space-y-2.5 animate-in slide-in-from-top-1",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Finalidade"}),e.jsx("p",{className:"text-xs text-foreground leading-relaxed",children:r.info.purpose})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Como usar"}),e.jsx("ul",{className:"text-xs space-y-1",children:(r.info.usage??[]).map((s,a)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{className:"text-primary",children:"•"}),e.jsx("span",{className:"text-foreground",children:s})]},a))})]}),Array.isArray(r.info.grading)&&r.info.grading.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1",children:"Graduação"}),e.jsx("ul",{className:"text-xs space-y-0.5",children:r.info.grading.map((s,a)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsxs("span",{className:"text-muted-foreground font-mono min-w-[1rem]",children:[a,":"]}),e.jsx("span",{className:"text-foreground",children:s})]},a))})]})]})]}),r.reference&&e.jsxs("div",{className:"flex items-start gap-1.5 text-[11px] text-muted-foreground pt-1",children:[e.jsx(B,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"Ref: "}),e.jsx("a",{href:r.reference.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate",children:r.reference.text})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-t border-border/40",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:c,className:"h-8 text-xs",children:"Cancelar"}),e.jsx(N,{size:"sm",onClick:w,disabled:!t,className:"ml-auto h-8 text-xs",children:"Inserir no Laudo"})]})]})})}export{K as CalculatorModal};

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.