From ae4c36ff8e53166be1617e21d8f846b960375d37 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 24 Apr 2026 05:46:45 +0200 Subject: [PATCH] chore(verify): drop vanilla-era test + linter; rebuild React bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The verify pipeline carried two scripts whose targets no longer exist after the vanilla deletion at commit 25a9c4c: test/calc-math.test.js — required public/js/calc-math.js (gone); every assertion is now covered by shared/clinical/ calculators.test.ts (vitest). scripts/lint-references.js — scans public/js/*.js for DOM id references and checks each target exists in public/components/ *.html. Those trees are gone; TypeScript + knip + vite build cover the equivalent dead-reference class for the React tree. package.json: • `verify` drops `test:node` and `lint:refs`; now runs typecheck + vitest + knip + client vite build. • `test:node` script removed (test/ directory empty). public/app/assets/ — fresh vite build so the bundle hashes match the current source (new chunks for ByVisitAge, Cms, DxPicker, EditableResult, LabsList, Milestones, OutputActions, Recorder, Shadess, SlideEditor, VisitNote — all features landed in the preceding commits). Verified locally on node 20: tsc + 9 test files / 177 tests pass, knip finds nothing, vite builds 35 chunks, client bundle is 343 kB initial / 106 kB gzipped (Cms is the biggest lazy chunk at 402 kB due to Tiptap/ProseMirror). --- package.json | 4 +- .../{Admin-C0fswhTW.js => Admin-DR6X-rgC.js} | 2 +- .../{Auth-BtfAUU3w.js => Auth-B-3rDdHk.js} | 2 +- ...edside-BsBuEI_m.js => Bedside-Da0d6Hsf.js} | 2 +- public/app/assets/ByVisitAge-jMcNy23H.js | 2 + ...rs-hFcuewWL.js => Calculators-BLZD2bUs.js} | 2 +- ...atchup--869idMv.js => Catchup-DCX8L2yV.js} | 2 +- public/app/assets/ChartReview-95oCueTc.js | 1 - public/app/assets/ChartReview-BvAH_gpU.js | 3 + public/app/assets/Cms-BmSRdQI9.js | 143 ++++++++++++++ ...l-zYA0ebt6.js => ConfirmModal-CIfDDoVq.js} | 0 public/app/assets/Dictation-D10JY0ar.js | 1 + public/app/assets/Dictation-Dk3CctmR.js | 1 - public/app/assets/DxPicker-CCeyfxop.js | 4 + public/app/assets/EditableResult-DaHQp1Pv.js | 1 + public/app/assets/Encounter-Br_IbTDu.js | 1 + public/app/assets/Encounter-CbwLX_2x.js | 1 - public/app/assets/HospitalCourse-BeNFIL_Z.js | 1 - public/app/assets/HospitalCourse-CzXNLHTv.js | 3 + public/app/assets/LabsList-CVygta6B.js | 1 + ...rning-BRd1B0-L.js => Learning-CYutu0C6.js} | 2 +- public/app/assets/Milestones-BIwzyW98.js | 1 + public/app/assets/OutputActions-6XZlmtIw.js | 1 + ...eGuide-eWPZEjQC.js => PeGuide-DChX9qua.js} | 2 +- public/app/assets/Recorder-DdXTjnSC.js | 1 + ...-pLQAcaAT.js => ResetPassword-CVgOn7wd.js} | 2 +- ...tings-CnDpQmnm.js => Settings-B_mY7MfB.js} | 2 +- public/app/assets/Shadess-DU9cvMlg.js | 1 + public/app/assets/SickVisit-BHH5UBrw.js | 1 + public/app/assets/SickVisit-vgkhrwdD.js | 1 - public/app/assets/Soap-DyFxx9HE.js | 1 + public/app/assets/Soap-VyU-WHem.js | 1 - ...le-WVnLWGX9.js => VaxSchedule-DSxl1k27.js} | 2 +- public/app/assets/VisitNote-B6TwVraG.js | 5 + public/app/assets/WellVisit-CQEpKEWj.js | 1 - public/app/assets/WellVisit-Dv-oLhFb.js | 2 + ...{fenton-Dvwmge1q.js => fenton-BaYL-F22.js} | 0 public/app/assets/index-BEGt1l85.css | 2 - public/app/assets/index-BuU36CvS.js | 50 ----- public/app/assets/index-C9wKWOAN.js | 50 +++++ public/app/assets/index-D2yFXEFs.css | 2 + public/app/assets/preload-helper-BmrihbwG.js | 1 + public/app/index.html | 5 +- scripts/lint-references.js | 179 ----------------- test/calc-math.test.js | 184 ------------------ 45 files changed, 239 insertions(+), 437 deletions(-) rename public/app/assets/{Admin-C0fswhTW.js => Admin-DR6X-rgC.js} (99%) rename public/app/assets/{Auth-BtfAUU3w.js => Auth-B-3rDdHk.js} (99%) rename public/app/assets/{Bedside-BsBuEI_m.js => Bedside-Da0d6Hsf.js} (99%) create mode 100644 public/app/assets/ByVisitAge-jMcNy23H.js rename public/app/assets/{Calculators-hFcuewWL.js => Calculators-BLZD2bUs.js} (99%) rename public/app/assets/{Catchup--869idMv.js => Catchup-DCX8L2yV.js} (97%) delete mode 100644 public/app/assets/ChartReview-95oCueTc.js create mode 100644 public/app/assets/ChartReview-BvAH_gpU.js create mode 100644 public/app/assets/Cms-BmSRdQI9.js rename public/app/assets/{ConfirmModal-zYA0ebt6.js => ConfirmModal-CIfDDoVq.js} (100%) create mode 100644 public/app/assets/Dictation-D10JY0ar.js delete mode 100644 public/app/assets/Dictation-Dk3CctmR.js create mode 100644 public/app/assets/DxPicker-CCeyfxop.js create mode 100644 public/app/assets/EditableResult-DaHQp1Pv.js create mode 100644 public/app/assets/Encounter-Br_IbTDu.js delete mode 100644 public/app/assets/Encounter-CbwLX_2x.js delete mode 100644 public/app/assets/HospitalCourse-BeNFIL_Z.js create mode 100644 public/app/assets/HospitalCourse-CzXNLHTv.js create mode 100644 public/app/assets/LabsList-CVygta6B.js rename public/app/assets/{Learning-BRd1B0-L.js => Learning-CYutu0C6.js} (99%) create mode 100644 public/app/assets/Milestones-BIwzyW98.js create mode 100644 public/app/assets/OutputActions-6XZlmtIw.js rename public/app/assets/{PeGuide-eWPZEjQC.js => PeGuide-DChX9qua.js} (99%) create mode 100644 public/app/assets/Recorder-DdXTjnSC.js rename public/app/assets/{ResetPassword-pLQAcaAT.js => ResetPassword-CVgOn7wd.js} (97%) rename public/app/assets/{Settings-CnDpQmnm.js => Settings-B_mY7MfB.js} (99%) create mode 100644 public/app/assets/Shadess-DU9cvMlg.js create mode 100644 public/app/assets/SickVisit-BHH5UBrw.js delete mode 100644 public/app/assets/SickVisit-vgkhrwdD.js create mode 100644 public/app/assets/Soap-DyFxx9HE.js delete mode 100644 public/app/assets/Soap-VyU-WHem.js rename public/app/assets/{VaxSchedule-WVnLWGX9.js => VaxSchedule-DSxl1k27.js} (97%) create mode 100644 public/app/assets/VisitNote-B6TwVraG.js delete mode 100644 public/app/assets/WellVisit-CQEpKEWj.js create mode 100644 public/app/assets/WellVisit-Dv-oLhFb.js rename public/app/assets/{fenton-Dvwmge1q.js => fenton-BaYL-F22.js} (100%) delete mode 100644 public/app/assets/index-BEGt1l85.css delete mode 100644 public/app/assets/index-BuU36CvS.js create mode 100644 public/app/assets/index-C9wKWOAN.js create mode 100644 public/app/assets/index-D2yFXEFs.css create mode 100644 public/app/assets/preload-helper-BmrihbwG.js delete mode 100755 scripts/lint-references.js delete mode 100644 test/calc-math.test.js diff --git a/package.json b/package.json index e714306..549fe4e 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,12 @@ "prebuild": "rm -rf dist", "build": "tsc", "typecheck": "tsc --noEmit", - "verify": "npm run typecheck && npm test && npm run test:node && npm run lint:refs && npm run lint:dead && npm --prefix client run build", + "verify": "npm run typecheck && npm test && npm run lint:dead && npm --prefix client run build", "verify:full": "npm run verify && npm run e2e", "dev": "ts-node-dev --respawn --transpile-only server.ts", "test": "vitest run", - "test:node": "node --test test/", "test:coverage": "vitest run --coverage", "e2e": "./scripts/e2e.sh", - "lint:refs": "node scripts/lint-references.js", "lint:dead": "knip --no-config-hints", "maint:check": "node scripts/maintenance.js check", "maint:reindex": "node scripts/maintenance.js reindex", diff --git a/public/app/assets/Admin-C0fswhTW.js b/public/app/assets/Admin-DR6X-rgC.js similarity index 99% rename from public/app/assets/Admin-C0fswhTW.js rename to public/app/assets/Admin-DR6X-rgC.js index 236c0b9..a5ce295 100644 --- a/public/app/assets/Admin-C0fswhTW.js +++ b/public/app/assets/Admin-DR6X-rgC.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-BuU36CvS.js";import{t as s}from"./ConfirmModal-zYA0ebt6.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,f=`block text-xs font-medium text-muted-foreground`,p=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,m=`rounded-md border border-border bg-background px-3 py-2 text-xs font-medium hover:bg-muted disabled:opacity-50`,h=`rounded-md bg-destructive text-white px-3 py-2 text-xs font-medium disabled:opacity-50`,g=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,_=`px-2 py-1.5 border-b border-border align-top text-sm`;function v({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function y(){let e=o(),[t,n]=(0,c.useState)(null),[f,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(``),{data:E,isLoading:D,error:O}=a({queryKey:[`admin-users`],queryFn:()=>i.get(`/api/admin/users`)}),k=r({mutationFn:e=>i.post(`/api/admin/users/${e}/verify`,{}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),A=r({mutationFn:e=>i.post(`/api/admin/users/${e}/disable`,{}),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),j=r({mutationFn:e=>i.post(`/api/admin/users/${e}/enable`,{}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),M=r({mutationFn:e=>i.post(`/api/admin/users/${e.id}/role`,{role:e.role}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),N=r({mutationFn:e=>i.delete(`/api/admin/users/${e}`),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),P=r({mutationFn:e=>i.post(`/api/admin/users/${e.id}/reset-password`,{newPassword:e.newPassword}),onSuccess:e=>{n({text:e.message,kind:`ok`}),C(null),T(``)},onError:e=>n({text:e.message,kind:`err`})}),F=(E?.users||[]).filter(e=>!f||e.email.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase()));return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-users-tab`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Users`}),(0,l.jsx)(`input`,{type:`search`,className:d+` max-w-xs`,placeholder:`Search by name or email…`,value:f,onChange:e=>y(e.target.value),"data-testid":`admin-users-search`})]}),D&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),O&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:O.message}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-users-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:g,children:`Email`}),(0,l.jsx)(`th`,{className:g,children:`Name`}),(0,l.jsx)(`th`,{className:g,children:`Role`}),(0,l.jsx)(`th`,{className:g,children:`Verified`}),(0,l.jsx)(`th`,{className:g,children:`2FA`}),(0,l.jsx)(`th`,{className:g,children:`Status`}),(0,l.jsx)(`th`,{className:g,children:`Actions`})]})}),(0,l.jsxs)(`tbody`,{children:[F.map(e=>(0,l.jsxs)(`tr`,{"data-testid":`admin-user-row-${e.id}`,className:e.disabled?`opacity-60`:``,children:[(0,l.jsx)(`td`,{className:_,children:e.email}),(0,l.jsx)(`td`,{className:_,children:e.name}),(0,l.jsx)(`td`,{className:_,children:(0,l.jsxs)(`select`,{className:d+` text-xs w-28`,value:e.role||`user`,onChange:t=>M.mutate({id:e.id,role:t.target.value}),"data-testid":`admin-user-role-${e.id}`,children:[(0,l.jsx)(`option`,{value:`user`,children:`user`}),(0,l.jsx)(`option`,{value:`moderator`,children:`moderator`}),(0,l.jsx)(`option`,{value:`admin`,children:`admin`})]})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.email_verified?`✅`:(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>k.mutate(e.id),"data-testid":`admin-user-verify-${e.id}`,children:`Verify`})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.totp_enabled?`✅`:`—`}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.disabled?(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>j.mutate(e.id),"data-testid":`admin-user-enable-${e.id}`,children:`Enable`}):(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>A.mutate(e.id),"data-testid":`admin-user-disable-${e.id}`,children:`Disable`})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:(0,l.jsxs)(`div`,{className:`flex gap-1`,children:[(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>C(e),"data-testid":`admin-user-reset-${e.id}`,children:`Reset pw`}),(0,l.jsx)(`button`,{type:`button`,className:h,onClick:()=>x(e),"data-testid":`admin-user-delete-${e.id}`,children:`Delete`})]})})]},e.id)),F.length===0&&E&&(0,l.jsx)(`tr`,{children:(0,l.jsxs)(`td`,{className:_+` text-muted-foreground italic`,colSpan:7,children:[`No users match "`,f,`".`]})})]})]})}),(0,l.jsx)(v,{msg:t}),(0,l.jsx)(s,{open:!!b,title:`Delete ${b?.email}?`,body:`This deletes the user account. Audit log entries are preserved (user_id set to NULL).`,confirmText:`Delete`,danger:!0,busy:N.isPending,onConfirm:()=>{b&&N.mutate(b.id),x(null)},onCancel:()=>x(null)}),S&&(0,l.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>C(null),children:(0,l.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border border-border bg-background p-5 shadow-lg space-y-3`,onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Reset password for `,S.email]}),(0,l.jsx)(`input`,{type:`text`,className:d,placeholder:`New password (8+ chars)`,value:w,onChange:e=>T(e.target.value),autoFocus:!0,minLength:8,"data-testid":`admin-user-reset-input`}),(0,l.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>{C(null),T(``)},children:`Cancel`}),(0,l.jsx)(`button`,{type:`button`,className:p,disabled:w.length<8||P.isPending,onClick:()=>P.mutate({id:S.id,newPassword:w}),"data-testid":`admin-user-reset-submit`,children:P.isPending?`Saving…`:`Reset`})]})]})})]})}function b(){let e=o(),[t,n]=(0,c.useState)(null),{data:s}=a({queryKey:[`admin-settings`],queryFn:()=>i.get(`/api/admin/settings`)}),d=r({mutationFn:e=>i.post(`/api/admin/settings/registration`,{enabled:e}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-settings`]})},onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-settings-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Site settings`}),s&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Total users`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.totalUsers})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`API calls (all time)`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.totalApiCalls})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`API calls (today)`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.todayApiCalls})]})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:s.settings.registrationEnabled,onChange:e=>d.mutate(e.target.checked),"data-testid":`admin-registration-toggle`}),(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:`Allow new user registration`})]})})]}),(0,l.jsx)(v,{msg:t})]})}function x(){let e=o(),[t,n]=(0,c.useState)(null),[s,m]=(0,c.useState)(!1),[h,g]=(0,c.useState)(`info`),[_,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(!1),{data:S}=a({queryKey:[`admin-announcement`],queryFn:()=>i.get(`/api/admin/config/announcement`)});!b&&S&&(m(S.enabled),g(S.type||`info`),y(S.text||``),x(!0));let C=r({mutationFn:async e=>i.put(`/api/admin/config/${encodeURIComponent(e.key)}`,{value:e.value})});async function w(){n(null);try{await Promise.all([C.mutateAsync({key:`announcement.enabled`,value:s?`true`:`false`}),C.mutateAsync({key:`announcement.type`,value:h}),C.mutateAsync({key:`announcement.text`,value:_})]),n({text:`Announcement saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-announcement`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-announcement-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Announcement banner`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Shown at the top of every page when enabled. Use for scheduled maintenance, outage notices, or release notes.`}),(0,l.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:s,onChange:e=>m(e.target.checked),"data-testid":`admin-announcement-enabled`}),(0,l.jsx)(`span`,{className:`text-sm`,children:`Show banner`})]})}),(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,l.jsxs)(`div`,{className:`sm:col-span-1`,children:[(0,l.jsx)(`label`,{className:f,children:`Severity`}),(0,l.jsxs)(`select`,{className:d,value:h,onChange:e=>g(e.target.value),"data-testid":`admin-announcement-type`,children:[(0,l.jsx)(`option`,{value:`info`,children:`Info (blue)`}),(0,l.jsx)(`option`,{value:`warning`,children:`Warning (amber)`}),(0,l.jsx)(`option`,{value:`critical`,children:`Critical (red)`})]})]}),(0,l.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,l.jsx)(`label`,{className:f,children:`Message`}),(0,l.jsx)(`textarea`,{rows:3,className:d+` resize-y`,value:_,onChange:e=>y(e.target.value),placeholder:`e.g. Scheduled maintenance Thursday 02:00 UTC — expect 10 minutes of downtime.`,"data-testid":`admin-announcement-text`})]})]}),(0,l.jsx)(`button`,{type:`button`,onClick:w,disabled:C.isPending,className:p,"data-testid":`admin-announcement-save`,children:C.isPending?`Saving…`:`Save announcement`}),(0,l.jsx)(v,{msg:t})]})}var S=`rounded-lg border border-border bg-card p-5 space-y-3`,C=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,w=`block text-xs font-medium text-muted-foreground`,T=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,E=`rounded-md border border-border bg-background px-3 py-2 text-xs font-medium hover:bg-muted disabled:opacity-50`,D=`rounded-md bg-destructive text-white px-3 py-2 text-xs font-medium disabled:opacity-50`,O=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,k=`px-2 py-1.5 border-b border-border align-top text-sm`;function A({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function j(){return r({mutationFn:e=>i.put(`/api/admin/config/${encodeURIComponent(e.key)}`,{value:e.value})})}function M(){let e=o(),[t,n]=(0,c.useState)(null),[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(``),[m,h]=(0,c.useState)(`587`),[g,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(``),[O,k]=(0,c.useState)(`false`),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(`verify`),{data:L}=a({queryKey:[`admin-smtp-status`],queryFn:()=>i.get(`/api/admin/config/smtp/status`)});!j&&L&&(p(L.host||``),h(String(L.port??`587`)),_(L.user||``),x(L.from||``),M(!0));let R=r({mutationFn:e=>i.put(`/api/admin/config/smtp`,e),onSuccess:()=>{n({text:`SMTP settings saved`,kind:`ok`}),y(``),e.invalidateQueries({queryKey:[`admin-smtp-status`]})},onError:e=>n({text:e.message,kind:`err`})}),z=r({mutationFn:()=>i.delete(`/api/admin/config/smtp`),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-smtp-status`]})},onError:e=>n({text:e.message,kind:`err`})}),B=r({mutationFn:e=>i.post(`/api/admin/config/test-email`,e),onSuccess:()=>n({text:`Test email sent to ${N}`,kind:`ok`}),onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-smtp-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`SMTP`}),L&&(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Status: `,L.configured?`✅ Configured`:`❌ Not configured`,L.source&&(0,l.jsxs)(l.Fragment,{children:[` · source: `,(0,l.jsx)(`strong`,{children:L.source})]})]}),(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Host`}),(0,l.jsx)(`input`,{className:C,value:f,onChange:e=>p(e.target.value),placeholder:`smtp.example.com`,"data-testid":`smtp-host`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Port`}),(0,l.jsx)(`input`,{className:C,value:m,onChange:e=>h(e.target.value),placeholder:`587`,"data-testid":`smtp-port`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Username`}),(0,l.jsx)(`input`,{className:C,value:g,onChange:e=>_(e.target.value),"data-testid":`smtp-user`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Password`}),(0,l.jsx)(`input`,{type:`password`,className:C,value:v,onChange:e=>y(e.target.value),placeholder:`Leave blank to keep existing`,"data-testid":`smtp-pass`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`From`}),(0,l.jsx)(`input`,{className:C,value:b,onChange:e=>x(e.target.value),placeholder:`noreply@example.com`,"data-testid":`smtp-from`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Secure (TLS)`}),(0,l.jsxs)(`select`,{className:C,value:O,onChange:e=>k(e.target.value),"data-testid":`smtp-secure`,children:[(0,l.jsx)(`option`,{value:`false`,children:`STARTTLS (587)`}),(0,l.jsx)(`option`,{value:`true`,children:`SSL/TLS (465)`})]})]})]}),(0,l.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,l.jsx)(`button`,{type:`button`,className:T,disabled:R.isPending||!f,onClick:()=>R.mutate({host:f,port:m,user:g,pass:v,from:b,secure:O===`true`}),"data-testid":`smtp-save`,children:R.isPending?`Saving…`:`Save SMTP settings`}),(0,l.jsx)(`button`,{type:`button`,className:D,onClick:()=>d(!0),"data-testid":`smtp-clear`,children:`Clear DB override`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 space-y-2`,children:[(0,l.jsx)(`div`,{className:`text-sm font-semibold`,children:`Send test email`}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2 items-end`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-[200px]`,children:[(0,l.jsx)(`label`,{className:w,children:`Recipient`}),(0,l.jsx)(`input`,{type:`email`,className:C,value:N,onChange:e=>P(e.target.value),placeholder:`recipient@example.com`,"data-testid":`smtp-test-to`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Template`}),(0,l.jsxs)(`select`,{className:C,value:F,onChange:e=>I(e.target.value),"data-testid":`smtp-test-template`,children:[(0,l.jsx)(`option`,{value:`verify`,children:`verify`}),(0,l.jsx)(`option`,{value:`reset`,children:`reset`}),(0,l.jsx)(`option`,{value:`password-changed`,children:`password-changed`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:E,disabled:B.isPending||!N,onClick:()=>B.mutate({to:N,template:F}),"data-testid":`smtp-test-send`,children:B.isPending?`Sending…`:`Send test`})]})]}),(0,l.jsx)(A,{msg:t}),(0,l.jsx)(s,{open:u,title:`Clear DB SMTP settings?`,body:`Removes smtp.* entries from the DB. Env vars will still apply if they're set (e.g. SMTP_HOST from OpenBao).`,confirmText:`Clear`,danger:!0,busy:z.isPending,onConfirm:()=>{z.mutate(),d(!1)},onCancel:()=>d(!1)})]})}var N=[`verify`,`reset`,`password-changed`];function P(){let e=o(),[t,n]=(0,c.useState)(null),[r,s]=(0,c.useState)(`verify`),[u,d]=(0,c.useState)(``),[f,p]=(0,c.useState)(``),{data:m}=a({queryKey:[`admin-config`],queryFn:()=>i.get(`/api/admin/config`)});function h(e){s(e);let t=new Map((m?.config||[]).map(e=>[e.key,e.value||``]));d(t.get(`email.`+e+`.subject`)||``),p(t.get(`email.`+e+`.body`)||``)}m&&!u&&!f&&h(r);let g=j();async function _(){n(null);try{await Promise.all([g.mutateAsync({key:`email.`+r+`.subject`,value:u}),g.mutateAsync({key:`email.`+r+`.body`,value:f})]),n({text:`Email template saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-config`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-email-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Email templates`}),(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:w,children:`Template`}),(0,l.jsx)(`select`,{className:C,value:r,onChange:e=>h(e.target.value),"data-testid":`email-template`,children:N.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Subject`}),(0,l.jsx)(`input`,{className:C,value:u,onChange:e=>d(e.target.value),"data-testid":`email-subject`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Body (HTML)`}),(0,l.jsx)(`textarea`,{rows:10,className:C+` resize-y font-mono text-xs`,value:f,onChange:e=>p(e.target.value),"data-testid":`email-body`})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:g.isPending,onClick:_,"data-testid":`email-save`,children:g.isPending?`Saving…`:`Save template`}),(0,l.jsx)(A,{msg:t})]})}function F(){let e=o(),[t,n]=(0,c.useState)(null),[u,d]=(0,c.useState)(``),[f,p]=(0,c.useState)(``),[m,h]=(0,c.useState)(!1),{data:g}=a({queryKey:[`admin-prompts`],queryFn:()=>i.get(`/api/admin/config/prompts`)});g&&!u&&g.prompts.length>0&&(d(g.prompts[0].key),p(g.prompts[0].value));function _(e){d(e);let t=g?.prompts.find(t=>t.key===e);p(t?.value||``)}let v=j(),y=r({mutationFn:e=>i.post(`/api/admin/config/prompts/${encodeURIComponent(e)}/reset`,{}),onSuccess:t=>{p(t.value),n({text:`Prompt reset to default`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-prompts`]})},onError:e=>n({text:e.message,kind:`err`})});async function b(){n(null);try{await v.mutateAsync({key:`prompt.`+u,value:f}),n({text:`Prompt saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-prompts`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-prompts-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`AI Prompts`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`System prompts injected before each generation. Reset restores the hardcoded default from src/utils/prompts.ts.`}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Prompt`}),(0,l.jsx)(`select`,{className:C,value:u,onChange:e=>_(e.target.value),"data-testid":`prompts-select`,children:(g?.prompts||[]).map(e=>(0,l.jsx)(`option`,{value:e.key,children:e.key},e.key))})]}),(0,l.jsx)(`textarea`,{rows:14,className:C+` resize-y font-mono text-xs`,value:f,onChange:e=>p(e.target.value),"data-testid":`prompts-text`}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,className:T,disabled:v.isPending||!u,onClick:b,"data-testid":`prompts-save`,children:v.isPending?`Saving…`:`Save prompt`}),(0,l.jsx)(`button`,{type:`button`,className:E,disabled:!u,onClick:()=>h(!0),"data-testid":`prompts-reset`,children:`Reset to default`})]}),(0,l.jsx)(A,{msg:t}),(0,l.jsx)(s,{open:m,title:`Reset "${u}"?`,body:`Restores the hardcoded default. Cannot be undone.`,confirmText:`Reset`,danger:!0,busy:y.isPending,onConfirm:()=>{y.mutate(u),h(!1)},onCancel:()=>h(!1)})]})}function I(){let e=o(),[t,n]=(0,c.useState)(null),{data:s}=a({queryKey:[`admin-models`],queryFn:()=>i.get(`/api/admin/config/models`)}),u=r({mutationFn:e=>i.put(`/api/admin/config/models/toggle`,e),onSuccess:()=>e.invalidateQueries({queryKey:[`admin-models`]}),onError:e=>n({text:e.message,kind:`err`})}),d=r({mutationFn:e=>i.put(`/api/admin/config/models/default`,{modelId:e}),onSuccess:(t,r)=>{n({text:`Default model set to ${r}`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-models`]})},onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-models-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`AI Models`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:s?.provider||`—`}),s?.defaultModel&&(0,l.jsxs)(l.Fragment,{children:[` · Default: `,(0,l.jsx)(`strong`,{children:s.defaultModel})]})]}),s?.litellmHint&&(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`LiteLLM provider has no built-in model list — use the legacy "Discover" flow to populate.`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-models-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Enabled`}),(0,l.jsx)(`th`,{className:O,children:`Default`}),(0,l.jsx)(`th`,{className:O,children:`Model ID`}),(0,l.jsx)(`th`,{className:O,children:`Label`})]})}),(0,l.jsxs)(`tbody`,{children:[(s?.models||[]).map(e=>(0,l.jsxs)(`tr`,{"data-testid":`admin-model-row-${e.id}`,children:[(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:e.enabled,onChange:t=>u.mutate({id:e.id,enabled:t.target.checked})})}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(`input`,{type:`radio`,name:`default-model`,checked:s?.defaultModel===e.id,onChange:()=>d.mutate(e.id),disabled:!e.enabled})}),(0,l.jsx)(`td`,{className:k+` font-mono text-xs`,children:e.id}),(0,l.jsx)(`td`,{className:k,children:e.label||`—`})]},e.id)),(s?.models||[]).length===0&&(0,l.jsx)(`tr`,{children:(0,l.jsx)(`td`,{className:k+` italic text-muted-foreground`,colSpan:4,children:`No models available.`})})]})]})}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Model discovery (search + add-custom) still lives in the legacy viewer — ports when the provider integration is revamped.`}),(0,l.jsx)(A,{msg:t})]})}function L(e){return a({queryKey:[`voice-provider`,e],queryFn:()=>i.get(e)})}function R(){let e=o(),[t,n]=(0,c.useState)(null),{data:r}=L(`/api/admin/config/tts`),i=j(),[a,s]=(0,c.useState)(``);r&&a===``&&r.defaultVoice&&s(r.defaultVoice);async function u(){n(null);try{await i.mutateAsync({key:`tts.default_voice`,value:a}),n({text:`Default TTS voice saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`voice-provider`,`/api/admin/config/tts`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-tts-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`TTS Provider`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:r?.provider||`—`})]}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Default voice`}),(0,l.jsxs)(`select`,{className:C,value:a,onChange:e=>s(e.target.value),"data-testid":`admin-tts-voice`,children:[(0,l.jsx)(`option`,{value:``,children:`(none)`}),(r?.voices||[]).map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label||e.value},e.value))]})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:i.isPending,onClick:u,"data-testid":`admin-tts-save`,children:i.isPending?`Saving…`:`Save default voice`}),(0,l.jsx)(A,{msg:t})]})}function z(){let e=o(),[t,n]=(0,c.useState)(null),{data:r}=L(`/api/admin/config/stt`),i=j(),[a,s]=(0,c.useState)(``);r&&a===``&&r.defaultModel&&s(r.defaultModel);async function u(){n(null);try{await i.mutateAsync({key:`stt.default_model`,value:a}),n({text:`Default STT model saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`voice-provider`,`/api/admin/config/stt`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-stt-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`STT Provider`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:r?.provider||`—`})]}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Default STT model`}),(0,l.jsxs)(`select`,{className:C,value:a,onChange:e=>s(e.target.value),"data-testid":`admin-stt-model`,children:[(0,l.jsx)(`option`,{value:``,children:`(none)`}),(r?.models||[]).map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label||e.value},e.value))]})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:i.isPending,onClick:u,"data-testid":`admin-stt-save`,children:i.isPending?`Saving…`:`Save default model`}),(0,l.jsx)(A,{msg:t})]})}var B=[``,`auth`,`admin`,`clinical`,`export`,`integration`,`documents`];function V(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(100),{data:o,isLoading:s,error:u,refetch:d}=a({queryKey:[`admin-logs`,e,n],queryFn:()=>i.get(`/api/admin/logs/all?limit=${n}${e?`&category=`+encodeURIComponent(e):``}`)});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-logs-tab`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Audit Logs`}),(0,l.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,l.jsx)(`label`,{className:w,children:`Category`}),(0,l.jsx)(`select`,{className:C+` w-36 text-xs`,value:e,onChange:e=>t(e.target.value),"data-testid":`admin-logs-category`,children:B.map(e=>(0,l.jsx)(`option`,{value:e,children:e||`(all)`},e))}),(0,l.jsx)(`label`,{className:w,children:`Limit`}),(0,l.jsx)(`select`,{className:C+` w-24 text-xs`,value:n,onChange:e=>r(Number(e.target.value)),"data-testid":`admin-logs-limit`,children:[50,100,200,500].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}),(0,l.jsx)(`button`,{type:`button`,className:E,onClick:()=>d(),children:`Refresh`})]})]}),s&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),u&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:u.message}),(0,l.jsx)(`div`,{className:`overflow-x-auto max-h-[70vh] overflow-y-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-logs-table`,children:[(0,l.jsx)(`thead`,{className:`sticky top-0 bg-card`,children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Time`}),(0,l.jsx)(`th`,{className:O,children:`User`}),(0,l.jsx)(`th`,{className:O,children:`Category`}),(0,l.jsx)(`th`,{className:O,children:`Action`}),(0,l.jsx)(`th`,{className:O,children:`Detail`}),(0,l.jsx)(`th`,{className:O,children:`IP`})]})}),(0,l.jsx)(`tbody`,{children:(o?.logs||[]).map(e=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` text-xs whitespace-nowrap`,children:new Date(e.timestamp).toLocaleString()}),(0,l.jsxs)(`td`,{className:k+` text-xs`,children:[e.user_email||`—`,e.user_name?` (${e.user_name})`:``]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.category}),(0,l.jsx)(`td`,{className:k+` text-xs font-mono`,children:e.action}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.detail}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.ip_address||``})]},e.id))})]})})]})}var H=`rounded-lg border border-border bg-card p-5 space-y-3`,U=[{id:`users`,label:`Users`},{id:`settings`,label:`Site settings`},{id:`announcement`,label:`Announcement`},{id:`models`,label:`AI models`},{id:`tts`,label:`TTS provider`},{id:`stt`,label:`STT provider`},{id:`smtp`,label:`SMTP`},{id:`email`,label:`Email templates`},{id:`prompts`,label:`AI prompts`},{id:`logs`,label:`Audit logs`}];function W(){let{data:e,isLoading:t}=a({queryKey:[`auth-me`],queryFn:()=>i.get(`/api/auth/me`),staleTime:5*6e4}),[n,r]=(0,c.useState)(`users`);return t?(0,l.jsx)(`div`,{className:`max-w-3xl mx-auto p-6 text-sm text-muted-foreground`,children:`Checking permissions…`}):e?.user.role===`admin`?(0,l.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6 space-y-4`,"data-testid":`admin-shell`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Admin Panel`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Users, site settings, announcement banner, AI model management, TTS/STT provider, SMTP, email templates, and audit logs.`})]}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`admin-subnav`,children:U.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(n===e.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`admin-tab-`+e.id,children:e.label},e.id))}),n===`users`&&(0,l.jsx)(y,{}),n===`settings`&&(0,l.jsx)(b,{}),n===`announcement`&&(0,l.jsx)(x,{}),n===`models`&&(0,l.jsx)(I,{}),n===`tts`&&(0,l.jsx)(R,{}),n===`stt`&&(0,l.jsx)(z,{}),n===`smtp`&&(0,l.jsx)(M,{}),n===`email`&&(0,l.jsx)(P,{}),n===`prompts`&&(0,l.jsx)(F,{}),n===`logs`&&(0,l.jsx)(V,{})]}):(0,l.jsx)(`div`,{className:`max-w-3xl mx-auto p-6`,children:(0,l.jsxs)(`section`,{className:H,"data-testid":`admin-access-denied`,children:[(0,l.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Admin only`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This page is restricted to users with the admin role. If you believe this is a mistake, contact your site administrator.`})]})})}export{W as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-C9wKWOAN.js";import{t as s}from"./ConfirmModal-CIfDDoVq.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,f=`block text-xs font-medium text-muted-foreground`,p=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,m=`rounded-md border border-border bg-background px-3 py-2 text-xs font-medium hover:bg-muted disabled:opacity-50`,h=`rounded-md bg-destructive text-white px-3 py-2 text-xs font-medium disabled:opacity-50`,g=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,_=`px-2 py-1.5 border-b border-border align-top text-sm`;function v({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function y(){let e=o(),[t,n]=(0,c.useState)(null),[f,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(``),{data:E,isLoading:D,error:O}=a({queryKey:[`admin-users`],queryFn:()=>i.get(`/api/admin/users`)}),k=r({mutationFn:e=>i.post(`/api/admin/users/${e}/verify`,{}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),A=r({mutationFn:e=>i.post(`/api/admin/users/${e}/disable`,{}),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),j=r({mutationFn:e=>i.post(`/api/admin/users/${e}/enable`,{}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),M=r({mutationFn:e=>i.post(`/api/admin/users/${e.id}/role`,{role:e.role}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),N=r({mutationFn:e=>i.delete(`/api/admin/users/${e}`),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-users`]})},onError:e=>n({text:e.message,kind:`err`})}),P=r({mutationFn:e=>i.post(`/api/admin/users/${e.id}/reset-password`,{newPassword:e.newPassword}),onSuccess:e=>{n({text:e.message,kind:`ok`}),C(null),T(``)},onError:e=>n({text:e.message,kind:`err`})}),F=(E?.users||[]).filter(e=>!f||e.email.toLowerCase().includes(f.toLowerCase())||e.name.toLowerCase().includes(f.toLowerCase()));return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-users-tab`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Users`}),(0,l.jsx)(`input`,{type:`search`,className:d+` max-w-xs`,placeholder:`Search by name or email…`,value:f,onChange:e=>y(e.target.value),"data-testid":`admin-users-search`})]}),D&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),O&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:O.message}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-users-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:g,children:`Email`}),(0,l.jsx)(`th`,{className:g,children:`Name`}),(0,l.jsx)(`th`,{className:g,children:`Role`}),(0,l.jsx)(`th`,{className:g,children:`Verified`}),(0,l.jsx)(`th`,{className:g,children:`2FA`}),(0,l.jsx)(`th`,{className:g,children:`Status`}),(0,l.jsx)(`th`,{className:g,children:`Actions`})]})}),(0,l.jsxs)(`tbody`,{children:[F.map(e=>(0,l.jsxs)(`tr`,{"data-testid":`admin-user-row-${e.id}`,className:e.disabled?`opacity-60`:``,children:[(0,l.jsx)(`td`,{className:_,children:e.email}),(0,l.jsx)(`td`,{className:_,children:e.name}),(0,l.jsx)(`td`,{className:_,children:(0,l.jsxs)(`select`,{className:d+` text-xs w-28`,value:e.role||`user`,onChange:t=>M.mutate({id:e.id,role:t.target.value}),"data-testid":`admin-user-role-${e.id}`,children:[(0,l.jsx)(`option`,{value:`user`,children:`user`}),(0,l.jsx)(`option`,{value:`moderator`,children:`moderator`}),(0,l.jsx)(`option`,{value:`admin`,children:`admin`})]})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.email_verified?`✅`:(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>k.mutate(e.id),"data-testid":`admin-user-verify-${e.id}`,children:`Verify`})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.totp_enabled?`✅`:`—`}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:e.disabled?(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>j.mutate(e.id),"data-testid":`admin-user-enable-${e.id}`,children:`Enable`}):(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>A.mutate(e.id),"data-testid":`admin-user-disable-${e.id}`,children:`Disable`})}),(0,l.jsx)(`td`,{className:_+` text-xs`,children:(0,l.jsxs)(`div`,{className:`flex gap-1`,children:[(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>C(e),"data-testid":`admin-user-reset-${e.id}`,children:`Reset pw`}),(0,l.jsx)(`button`,{type:`button`,className:h,onClick:()=>x(e),"data-testid":`admin-user-delete-${e.id}`,children:`Delete`})]})})]},e.id)),F.length===0&&E&&(0,l.jsx)(`tr`,{children:(0,l.jsxs)(`td`,{className:_+` text-muted-foreground italic`,colSpan:7,children:[`No users match "`,f,`".`]})})]})]})}),(0,l.jsx)(v,{msg:t}),(0,l.jsx)(s,{open:!!b,title:`Delete ${b?.email}?`,body:`This deletes the user account. Audit log entries are preserved (user_id set to NULL).`,confirmText:`Delete`,danger:!0,busy:N.isPending,onConfirm:()=>{b&&N.mutate(b.id),x(null)},onCancel:()=>x(null)}),S&&(0,l.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:()=>C(null),children:(0,l.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border border-border bg-background p-5 shadow-lg space-y-3`,onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Reset password for `,S.email]}),(0,l.jsx)(`input`,{type:`text`,className:d,placeholder:`New password (8+ chars)`,value:w,onChange:e=>T(e.target.value),autoFocus:!0,minLength:8,"data-testid":`admin-user-reset-input`}),(0,l.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,className:m,onClick:()=>{C(null),T(``)},children:`Cancel`}),(0,l.jsx)(`button`,{type:`button`,className:p,disabled:w.length<8||P.isPending,onClick:()=>P.mutate({id:S.id,newPassword:w}),"data-testid":`admin-user-reset-submit`,children:P.isPending?`Saving…`:`Reset`})]})]})})]})}function b(){let e=o(),[t,n]=(0,c.useState)(null),{data:s}=a({queryKey:[`admin-settings`],queryFn:()=>i.get(`/api/admin/settings`)}),d=r({mutationFn:e=>i.post(`/api/admin/settings/registration`,{enabled:e}),onSuccess:t=>{n({text:t.message,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-settings`]})},onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-settings-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Site settings`}),s&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Total users`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.totalUsers})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`API calls (all time)`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.totalApiCalls})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`API calls (today)`}),(0,l.jsx)(`div`,{className:`text-xl font-bold`,children:s.stats.todayApiCalls})]})]}),(0,l.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:s.settings.registrationEnabled,onChange:e=>d.mutate(e.target.checked),"data-testid":`admin-registration-toggle`}),(0,l.jsx)(`span`,{className:`text-sm font-medium`,children:`Allow new user registration`})]})})]}),(0,l.jsx)(v,{msg:t})]})}function x(){let e=o(),[t,n]=(0,c.useState)(null),[s,m]=(0,c.useState)(!1),[h,g]=(0,c.useState)(`info`),[_,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(!1),{data:S}=a({queryKey:[`admin-announcement`],queryFn:()=>i.get(`/api/admin/config/announcement`)});!b&&S&&(m(S.enabled),g(S.type||`info`),y(S.text||``),x(!0));let C=r({mutationFn:async e=>i.put(`/api/admin/config/${encodeURIComponent(e.key)}`,{value:e.value})});async function w(){n(null);try{await Promise.all([C.mutateAsync({key:`announcement.enabled`,value:s?`true`:`false`}),C.mutateAsync({key:`announcement.type`,value:h}),C.mutateAsync({key:`announcement.text`,value:_})]),n({text:`Announcement saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-announcement`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:u,"data-testid":`admin-announcement-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Announcement banner`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Shown at the top of every page when enabled. Use for scheduled maintenance, outage notices, or release notes.`}),(0,l.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:s,onChange:e=>m(e.target.checked),"data-testid":`admin-announcement-enabled`}),(0,l.jsx)(`span`,{className:`text-sm`,children:`Show banner`})]})}),(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,l.jsxs)(`div`,{className:`sm:col-span-1`,children:[(0,l.jsx)(`label`,{className:f,children:`Severity`}),(0,l.jsxs)(`select`,{className:d,value:h,onChange:e=>g(e.target.value),"data-testid":`admin-announcement-type`,children:[(0,l.jsx)(`option`,{value:`info`,children:`Info (blue)`}),(0,l.jsx)(`option`,{value:`warning`,children:`Warning (amber)`}),(0,l.jsx)(`option`,{value:`critical`,children:`Critical (red)`})]})]}),(0,l.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,l.jsx)(`label`,{className:f,children:`Message`}),(0,l.jsx)(`textarea`,{rows:3,className:d+` resize-y`,value:_,onChange:e=>y(e.target.value),placeholder:`e.g. Scheduled maintenance Thursday 02:00 UTC — expect 10 minutes of downtime.`,"data-testid":`admin-announcement-text`})]})]}),(0,l.jsx)(`button`,{type:`button`,onClick:w,disabled:C.isPending,className:p,"data-testid":`admin-announcement-save`,children:C.isPending?`Saving…`:`Save announcement`}),(0,l.jsx)(v,{msg:t})]})}var S=`rounded-lg border border-border bg-card p-5 space-y-3`,C=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,w=`block text-xs font-medium text-muted-foreground`,T=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,E=`rounded-md border border-border bg-background px-3 py-2 text-xs font-medium hover:bg-muted disabled:opacity-50`,D=`rounded-md bg-destructive text-white px-3 py-2 text-xs font-medium disabled:opacity-50`,O=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,k=`px-2 py-1.5 border-b border-border align-top text-sm`;function A({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function j(){return r({mutationFn:e=>i.put(`/api/admin/config/${encodeURIComponent(e.key)}`,{value:e.value})})}function M(){let e=o(),[t,n]=(0,c.useState)(null),[u,d]=(0,c.useState)(!1),[f,p]=(0,c.useState)(``),[m,h]=(0,c.useState)(`587`),[g,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(``),[O,k]=(0,c.useState)(`false`),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(`verify`),{data:L}=a({queryKey:[`admin-smtp-status`],queryFn:()=>i.get(`/api/admin/config/smtp/status`)});!j&&L&&(p(L.host||``),h(String(L.port??`587`)),_(L.user||``),x(L.from||``),M(!0));let R=r({mutationFn:e=>i.put(`/api/admin/config/smtp`,e),onSuccess:()=>{n({text:`SMTP settings saved`,kind:`ok`}),y(``),e.invalidateQueries({queryKey:[`admin-smtp-status`]})},onError:e=>n({text:e.message,kind:`err`})}),z=r({mutationFn:()=>i.delete(`/api/admin/config/smtp`),onSuccess:t=>{n({text:t.message,kind:`info`}),e.invalidateQueries({queryKey:[`admin-smtp-status`]})},onError:e=>n({text:e.message,kind:`err`})}),B=r({mutationFn:e=>i.post(`/api/admin/config/test-email`,e),onSuccess:()=>n({text:`Test email sent to ${N}`,kind:`ok`}),onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-smtp-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`SMTP`}),L&&(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Status: `,L.configured?`✅ Configured`:`❌ Not configured`,L.source&&(0,l.jsxs)(l.Fragment,{children:[` · source: `,(0,l.jsx)(`strong`,{children:L.source})]})]}),(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Host`}),(0,l.jsx)(`input`,{className:C,value:f,onChange:e=>p(e.target.value),placeholder:`smtp.example.com`,"data-testid":`smtp-host`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Port`}),(0,l.jsx)(`input`,{className:C,value:m,onChange:e=>h(e.target.value),placeholder:`587`,"data-testid":`smtp-port`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Username`}),(0,l.jsx)(`input`,{className:C,value:g,onChange:e=>_(e.target.value),"data-testid":`smtp-user`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Password`}),(0,l.jsx)(`input`,{type:`password`,className:C,value:v,onChange:e=>y(e.target.value),placeholder:`Leave blank to keep existing`,"data-testid":`smtp-pass`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`From`}),(0,l.jsx)(`input`,{className:C,value:b,onChange:e=>x(e.target.value),placeholder:`noreply@example.com`,"data-testid":`smtp-from`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Secure (TLS)`}),(0,l.jsxs)(`select`,{className:C,value:O,onChange:e=>k(e.target.value),"data-testid":`smtp-secure`,children:[(0,l.jsx)(`option`,{value:`false`,children:`STARTTLS (587)`}),(0,l.jsx)(`option`,{value:`true`,children:`SSL/TLS (465)`})]})]})]}),(0,l.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,l.jsx)(`button`,{type:`button`,className:T,disabled:R.isPending||!f,onClick:()=>R.mutate({host:f,port:m,user:g,pass:v,from:b,secure:O===`true`}),"data-testid":`smtp-save`,children:R.isPending?`Saving…`:`Save SMTP settings`}),(0,l.jsx)(`button`,{type:`button`,className:D,onClick:()=>d(!0),"data-testid":`smtp-clear`,children:`Clear DB override`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 space-y-2`,children:[(0,l.jsx)(`div`,{className:`text-sm font-semibold`,children:`Send test email`}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2 items-end`,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-[200px]`,children:[(0,l.jsx)(`label`,{className:w,children:`Recipient`}),(0,l.jsx)(`input`,{type:`email`,className:C,value:N,onChange:e=>P(e.target.value),placeholder:`recipient@example.com`,"data-testid":`smtp-test-to`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Template`}),(0,l.jsxs)(`select`,{className:C,value:F,onChange:e=>I(e.target.value),"data-testid":`smtp-test-template`,children:[(0,l.jsx)(`option`,{value:`verify`,children:`verify`}),(0,l.jsx)(`option`,{value:`reset`,children:`reset`}),(0,l.jsx)(`option`,{value:`password-changed`,children:`password-changed`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:E,disabled:B.isPending||!N,onClick:()=>B.mutate({to:N,template:F}),"data-testid":`smtp-test-send`,children:B.isPending?`Sending…`:`Send test`})]})]}),(0,l.jsx)(A,{msg:t}),(0,l.jsx)(s,{open:u,title:`Clear DB SMTP settings?`,body:`Removes smtp.* entries from the DB. Env vars will still apply if they're set (e.g. SMTP_HOST from OpenBao).`,confirmText:`Clear`,danger:!0,busy:z.isPending,onConfirm:()=>{z.mutate(),d(!1)},onCancel:()=>d(!1)})]})}var N=[`verify`,`reset`,`password-changed`];function P(){let e=o(),[t,n]=(0,c.useState)(null),[r,s]=(0,c.useState)(`verify`),[u,d]=(0,c.useState)(``),[f,p]=(0,c.useState)(``),{data:m}=a({queryKey:[`admin-config`],queryFn:()=>i.get(`/api/admin/config`)});function h(e){s(e);let t=new Map((m?.config||[]).map(e=>[e.key,e.value||``]));d(t.get(`email.`+e+`.subject`)||``),p(t.get(`email.`+e+`.body`)||``)}m&&!u&&!f&&h(r);let g=j();async function _(){n(null);try{await Promise.all([g.mutateAsync({key:`email.`+r+`.subject`,value:u}),g.mutateAsync({key:`email.`+r+`.body`,value:f})]),n({text:`Email template saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-config`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-email-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Email templates`}),(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:w,children:`Template`}),(0,l.jsx)(`select`,{className:C,value:r,onChange:e=>h(e.target.value),"data-testid":`email-template`,children:N.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Subject`}),(0,l.jsx)(`input`,{className:C,value:u,onChange:e=>d(e.target.value),"data-testid":`email-subject`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:w,children:`Body (HTML)`}),(0,l.jsx)(`textarea`,{rows:10,className:C+` resize-y font-mono text-xs`,value:f,onChange:e=>p(e.target.value),"data-testid":`email-body`})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:g.isPending,onClick:_,"data-testid":`email-save`,children:g.isPending?`Saving…`:`Save template`}),(0,l.jsx)(A,{msg:t})]})}function F(){let e=o(),[t,n]=(0,c.useState)(null),[u,d]=(0,c.useState)(``),[f,p]=(0,c.useState)(``),[m,h]=(0,c.useState)(!1),{data:g}=a({queryKey:[`admin-prompts`],queryFn:()=>i.get(`/api/admin/config/prompts`)});g&&!u&&g.prompts.length>0&&(d(g.prompts[0].key),p(g.prompts[0].value));function _(e){d(e);let t=g?.prompts.find(t=>t.key===e);p(t?.value||``)}let v=j(),y=r({mutationFn:e=>i.post(`/api/admin/config/prompts/${encodeURIComponent(e)}/reset`,{}),onSuccess:t=>{p(t.value),n({text:`Prompt reset to default`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-prompts`]})},onError:e=>n({text:e.message,kind:`err`})});async function b(){n(null);try{await v.mutateAsync({key:`prompt.`+u,value:f}),n({text:`Prompt saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-prompts`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-prompts-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`AI Prompts`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`System prompts injected before each generation. Reset restores the hardcoded default from src/utils/prompts.ts.`}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Prompt`}),(0,l.jsx)(`select`,{className:C,value:u,onChange:e=>_(e.target.value),"data-testid":`prompts-select`,children:(g?.prompts||[]).map(e=>(0,l.jsx)(`option`,{value:e.key,children:e.key},e.key))})]}),(0,l.jsx)(`textarea`,{rows:14,className:C+` resize-y font-mono text-xs`,value:f,onChange:e=>p(e.target.value),"data-testid":`prompts-text`}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,className:T,disabled:v.isPending||!u,onClick:b,"data-testid":`prompts-save`,children:v.isPending?`Saving…`:`Save prompt`}),(0,l.jsx)(`button`,{type:`button`,className:E,disabled:!u,onClick:()=>h(!0),"data-testid":`prompts-reset`,children:`Reset to default`})]}),(0,l.jsx)(A,{msg:t}),(0,l.jsx)(s,{open:m,title:`Reset "${u}"?`,body:`Restores the hardcoded default. Cannot be undone.`,confirmText:`Reset`,danger:!0,busy:y.isPending,onConfirm:()=>{y.mutate(u),h(!1)},onCancel:()=>h(!1)})]})}function I(){let e=o(),[t,n]=(0,c.useState)(null),{data:s}=a({queryKey:[`admin-models`],queryFn:()=>i.get(`/api/admin/config/models`)}),u=r({mutationFn:e=>i.put(`/api/admin/config/models/toggle`,e),onSuccess:()=>e.invalidateQueries({queryKey:[`admin-models`]}),onError:e=>n({text:e.message,kind:`err`})}),d=r({mutationFn:e=>i.put(`/api/admin/config/models/default`,{modelId:e}),onSuccess:(t,r)=>{n({text:`Default model set to ${r}`,kind:`ok`}),e.invalidateQueries({queryKey:[`admin-models`]})},onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-models-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`AI Models`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:s?.provider||`—`}),s?.defaultModel&&(0,l.jsxs)(l.Fragment,{children:[` · Default: `,(0,l.jsx)(`strong`,{children:s.defaultModel})]})]}),s?.litellmHint&&(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`LiteLLM provider has no built-in model list — use the legacy "Discover" flow to populate.`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-models-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Enabled`}),(0,l.jsx)(`th`,{className:O,children:`Default`}),(0,l.jsx)(`th`,{className:O,children:`Model ID`}),(0,l.jsx)(`th`,{className:O,children:`Label`})]})}),(0,l.jsxs)(`tbody`,{children:[(s?.models||[]).map(e=>(0,l.jsxs)(`tr`,{"data-testid":`admin-model-row-${e.id}`,children:[(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:e.enabled,onChange:t=>u.mutate({id:e.id,enabled:t.target.checked})})}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(`input`,{type:`radio`,name:`default-model`,checked:s?.defaultModel===e.id,onChange:()=>d.mutate(e.id),disabled:!e.enabled})}),(0,l.jsx)(`td`,{className:k+` font-mono text-xs`,children:e.id}),(0,l.jsx)(`td`,{className:k,children:e.label||`—`})]},e.id)),(s?.models||[]).length===0&&(0,l.jsx)(`tr`,{children:(0,l.jsx)(`td`,{className:k+` italic text-muted-foreground`,colSpan:4,children:`No models available.`})})]})]})}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Model discovery (search + add-custom) still lives in the legacy viewer — ports when the provider integration is revamped.`}),(0,l.jsx)(A,{msg:t})]})}function L(e){return a({queryKey:[`voice-provider`,e],queryFn:()=>i.get(e)})}function R(){let e=o(),[t,n]=(0,c.useState)(null),{data:r}=L(`/api/admin/config/tts`),i=j(),[a,s]=(0,c.useState)(``);r&&a===``&&r.defaultVoice&&s(r.defaultVoice);async function u(){n(null);try{await i.mutateAsync({key:`tts.default_voice`,value:a}),n({text:`Default TTS voice saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`voice-provider`,`/api/admin/config/tts`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-tts-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`TTS Provider`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:r?.provider||`—`})]}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Default voice`}),(0,l.jsxs)(`select`,{className:C,value:a,onChange:e=>s(e.target.value),"data-testid":`admin-tts-voice`,children:[(0,l.jsx)(`option`,{value:``,children:`(none)`}),(r?.voices||[]).map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label||e.value},e.value))]})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:i.isPending,onClick:u,"data-testid":`admin-tts-save`,children:i.isPending?`Saving…`:`Save default voice`}),(0,l.jsx)(A,{msg:t})]})}function z(){let e=o(),[t,n]=(0,c.useState)(null),{data:r}=L(`/api/admin/config/stt`),i=j(),[a,s]=(0,c.useState)(``);r&&a===``&&r.defaultModel&&s(r.defaultModel);async function u(){n(null);try{await i.mutateAsync({key:`stt.default_model`,value:a}),n({text:`Default STT model saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`voice-provider`,`/api/admin/config/stt`]})}catch(e){n({text:e.message,kind:`err`})}}return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-stt-tab`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`STT Provider`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Active provider: `,(0,l.jsx)(`strong`,{children:r?.provider||`—`})]}),(0,l.jsxs)(`div`,{className:`max-w-md`,children:[(0,l.jsx)(`label`,{className:w,children:`Default STT model`}),(0,l.jsxs)(`select`,{className:C,value:a,onChange:e=>s(e.target.value),"data-testid":`admin-stt-model`,children:[(0,l.jsx)(`option`,{value:``,children:`(none)`}),(r?.models||[]).map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label||e.value},e.value))]})]}),(0,l.jsx)(`button`,{type:`button`,className:T,disabled:i.isPending,onClick:u,"data-testid":`admin-stt-save`,children:i.isPending?`Saving…`:`Save default model`}),(0,l.jsx)(A,{msg:t})]})}var B=[``,`auth`,`admin`,`clinical`,`export`,`integration`,`documents`];function V(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(100),{data:o,isLoading:s,error:u,refetch:d}=a({queryKey:[`admin-logs`,e,n],queryFn:()=>i.get(`/api/admin/logs/all?limit=${n}${e?`&category=`+encodeURIComponent(e):``}`)});return(0,l.jsxs)(`section`,{className:S,"data-testid":`admin-logs-tab`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Audit Logs`}),(0,l.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,l.jsx)(`label`,{className:w,children:`Category`}),(0,l.jsx)(`select`,{className:C+` w-36 text-xs`,value:e,onChange:e=>t(e.target.value),"data-testid":`admin-logs-category`,children:B.map(e=>(0,l.jsx)(`option`,{value:e,children:e||`(all)`},e))}),(0,l.jsx)(`label`,{className:w,children:`Limit`}),(0,l.jsx)(`select`,{className:C+` w-24 text-xs`,value:n,onChange:e=>r(Number(e.target.value)),"data-testid":`admin-logs-limit`,children:[50,100,200,500].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}),(0,l.jsx)(`button`,{type:`button`,className:E,onClick:()=>d(),children:`Refresh`})]})]}),s&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),u&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:u.message}),(0,l.jsx)(`div`,{className:`overflow-x-auto max-h-[70vh] overflow-y-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`admin-logs-table`,children:[(0,l.jsx)(`thead`,{className:`sticky top-0 bg-card`,children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Time`}),(0,l.jsx)(`th`,{className:O,children:`User`}),(0,l.jsx)(`th`,{className:O,children:`Category`}),(0,l.jsx)(`th`,{className:O,children:`Action`}),(0,l.jsx)(`th`,{className:O,children:`Detail`}),(0,l.jsx)(`th`,{className:O,children:`IP`})]})}),(0,l.jsx)(`tbody`,{children:(o?.logs||[]).map(e=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` text-xs whitespace-nowrap`,children:new Date(e.timestamp).toLocaleString()}),(0,l.jsxs)(`td`,{className:k+` text-xs`,children:[e.user_email||`—`,e.user_name?` (${e.user_name})`:``]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.category}),(0,l.jsx)(`td`,{className:k+` text-xs font-mono`,children:e.action}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.detail}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.ip_address||``})]},e.id))})]})})]})}var H=`rounded-lg border border-border bg-card p-5 space-y-3`,U=[{id:`users`,label:`Users`},{id:`settings`,label:`Site settings`},{id:`announcement`,label:`Announcement`},{id:`models`,label:`AI models`},{id:`tts`,label:`TTS provider`},{id:`stt`,label:`STT provider`},{id:`smtp`,label:`SMTP`},{id:`email`,label:`Email templates`},{id:`prompts`,label:`AI prompts`},{id:`logs`,label:`Audit logs`}];function W(){let{data:e,isLoading:t}=a({queryKey:[`auth-me`],queryFn:()=>i.get(`/api/auth/me`),staleTime:5*6e4}),[n,r]=(0,c.useState)(`users`);return t?(0,l.jsx)(`div`,{className:`max-w-3xl mx-auto p-6 text-sm text-muted-foreground`,children:`Checking permissions…`}):e?.user.role===`admin`?(0,l.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6 space-y-4`,"data-testid":`admin-shell`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Admin Panel`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Users, site settings, announcement banner, AI model management, TTS/STT provider, SMTP, email templates, and audit logs.`})]}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`admin-subnav`,children:U.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(n===e.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`admin-tab-`+e.id,children:e.label},e.id))}),n===`users`&&(0,l.jsx)(y,{}),n===`settings`&&(0,l.jsx)(b,{}),n===`announcement`&&(0,l.jsx)(x,{}),n===`models`&&(0,l.jsx)(I,{}),n===`tts`&&(0,l.jsx)(R,{}),n===`stt`&&(0,l.jsx)(z,{}),n===`smtp`&&(0,l.jsx)(M,{}),n===`email`&&(0,l.jsx)(P,{}),n===`prompts`&&(0,l.jsx)(F,{}),n===`logs`&&(0,l.jsx)(V,{})]}):(0,l.jsx)(`div`,{className:`max-w-3xl mx-auto p-6`,children:(0,l.jsxs)(`section`,{className:H,"data-testid":`admin-access-denied`,children:[(0,l.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Admin only`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This page is restricted to users with the admin role. If you believe this is a mistake, contact your site administrator.`})]})})}export{W as default}; \ No newline at end of file diff --git a/public/app/assets/Auth-BtfAUU3w.js b/public/app/assets/Auth-B-3rDdHk.js similarity index 99% rename from public/app/assets/Auth-BtfAUU3w.js rename to public/app/assets/Auth-B-3rDdHk.js index 8873453..72475ef 100644 --- a/public/app/assets/Auth-BtfAUU3w.js +++ b/public/app/assets/Auth-B-3rDdHk.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{a as r,i,l as a,o,u as s}from"./index-BuU36CvS.js";var c=e(t(),1),l=n(),u=`https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onTurnstileLoad`,d=!1,f=[];function p(){return new Promise(e=>{if(typeof window>`u`){e();return}if(window.turnstile){e();return}if(f.push(e),d)return;d=!0,window.onTurnstileLoad=()=>{for(let e of f.splice(0))e()};let t=document.createElement(`script`);t.src=u,t.async=!0,t.defer=!0,document.head.appendChild(t)})}function m({siteKey:e,onToken:t,action:n,theme:r=`light`}){let i=(0,c.useRef)(null),a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(!e){t(``);return}let o=!1;return p().then(()=>{if(!(o||!i.current||!window.turnstile))try{a.current=window.turnstile.render(i.current,{sitekey:e,theme:r,action:n,callback:e=>t(e),"error-callback":()=>t(``),"expired-callback":()=>t(``)})}catch{}}),()=>{if(o=!0,a.current&&window.turnstile)try{window.turnstile.remove(a.current)}catch{}}},[e]),e?(0,l.jsx)(`div`,{ref:i,className:`cf-turnstile my-2`}):null}var h=`rounded-2xl border border-border bg-card p-6 shadow-lg space-y-4 w-full max-w-md`,g=`w-full rounded-md bg-primary text-primary-foreground px-4 py-3 text-sm font-semibold disabled:opacity-60`,_=`w-full rounded-md bg-slate-900 text-white px-4 py-3 text-sm font-semibold disabled:opacity-60 hover:bg-slate-800`,v=`w-full rounded-md border border-input bg-background px-3 py-2.5 text-sm outline-none focus:ring-2 focus:ring-ring`,y=`block text-xs font-semibold text-muted-foreground mb-1`,b=`text-sm text-primary hover:underline`,x=`rounded-md bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-900 p-3 text-sm text-green-800 dark:text-green-100`,S=`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3 text-sm text-red-800 dark:text-red-100`,C=`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 p-3 text-sm text-amber-900 dark:text-amber-100`;function w(){let e=o(),t=r();return()=>{e(new URLSearchParams(t.search).get(`next`)||`/`,{replace:!0})}}function T(){let[e,t]=(0,c.useState)(`login`),[n,r]=(0,c.useState)(``),[o,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),p=s(),m=w(),{data:g}=a({queryKey:[`public-config`],queryFn:()=>i.get(`/api/auth/public-config`),staleTime:6e4}),v=!!g?.disableLocalAuth;function y(e){t(e),r(``),u(``),f(``)}return(0,l.jsx)(`div`,{className:`min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 dark:from-slate-900 dark:via-slate-950 dark:to-slate-900 flex items-center justify-center p-4`,children:(0,l.jsxs)(`div`,{className:h,children:[(0,l.jsxs)(`header`,{className:`text-center space-y-1`,children:[(0,l.jsx)(`div`,{className:`text-4xl`,children:`🩺`}),(0,l.jsx)(`h1`,{className:`text-xl font-bold`,children:`Pediatric AI Scribe`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`AI-Powered Clinical Documentation`})]}),n&&(0,l.jsx)(`div`,{className:S,children:n}),d&&(0,l.jsx)(`div`,{className:C,children:d}),o&&(0,l.jsx)(`div`,{className:x,children:o}),e===`login`&&!v&&(0,l.jsx)(E,{cfg:g,onErr:r,onInfo:f,onOk:u,onLogin:()=>{p.invalidateQueries({queryKey:[`auth-me`]}),m()},switchMode:y}),e===`register`&&!v&&(g?.registrationEnabled??!0)&&(0,l.jsx)(D,{cfg:g,onErr:r,onOk:u,switchMode:y}),e===`forgot`&&!v&&(0,l.jsx)(O,{cfg:g,onErr:r,onOk:u,switchMode:y}),g?.oidcEnabled&&(0,l.jsxs)(l.Fragment,{children:[!v&&(0,l.jsxs)(`div`,{className:`relative my-4`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,l.jsx)(`span`,{className:`w-full border-t border-border`})}),(0,l.jsx)(`div`,{className:`relative flex justify-center text-xs text-muted-foreground`,children:(0,l.jsx)(`span`,{className:`bg-card px-3`,children:`or`})})]}),(0,l.jsxs)(`a`,{href:`/api/auth/oidc`,className:_+` text-center block no-underline`,"data-testid":`auth-oidc`,children:[`🛡️ `,g.ssoButtonLabel||`Sign in with SSO`]})]}),v&&!g?.oidcEnabled&&(0,l.jsx)(`div`,{className:C,children:`Single sign-on not configured. Contact your administrator.`}),(0,l.jsxs)(`div`,{className:`pt-4 border-t border-border text-xs text-muted-foreground space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,l.jsx)(`span`,{children:`⚠️`}),(0,l.jsx)(`p`,{children:`HIPAA-compliant AI providers available with BAA. Check your institution's guidelines. Not intended for clinical use without proper authorization.`})]}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`a`,{href:`https://github.com/ifedan-ed/pediatric-ai-scribe-v3/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline`,children:`📱 Download Android app (APK)`})})]})]})})}function E({cfg:e,onErr:t,onInfo:n,onOk:r,onLogin:a,switchMode:o}){let[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),[p,h]=(0,c.useState)(``),[_,x]=(0,c.useState)(!1),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1);async function A(o){if(o.preventDefault(),t(``),n(``),r(``),!s||!d){t(`Enter email and password`);return}if(e?.turnstileSiteKey&&!w){t(`Please complete the verification`);return}D(!0);try{let e={email:s,password:d};w&&(e.turnstileToken=w),p&&(e.totpCode=p);let o=await i.post(`/api/auth/login`,e);if(o.requires2FA){x(!0),n(`Enter your 2FA code`),D(!1);return}if(o.needsVerification){C(!0),t(`Verify your email first. Check your inbox.`),D(!1);return}if(o.token){r(`Signed in`),a();return}t(`Login failed`)}catch(e){t(e.message||`Login failed`)}finally{D(!1)}}async function j(){if(!s){t(`Enter your email first`);return}k(!0);try{r((await i.post(`/api/auth/resend-verification`,{email:s})).message||`Verification email sent`)}catch(e){t(e.message||`Failed to resend`)}finally{k(!1)}}return(0,l.jsxs)(`form`,{onSubmit:A,className:`space-y-3`,"data-testid":`auth-login-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Sign in`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,autoFocus:!0,required:!0,className:v,value:s,onChange:e=>u(e.target.value),"data-testid":`auth-email`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Password`}),(0,l.jsx)(`input`,{type:`password`,required:!0,className:v,value:d,onChange:e=>f(e.target.value),"data-testid":`auth-password`})]}),_&&(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`2FA code`}),(0,l.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,maxLength:6,className:v+` font-mono tracking-widest`,value:p,onChange:e=>h(e.target.value.replace(/\D/g,``)),"data-testid":`auth-totp`,autoFocus:!0})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:T}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:E,"data-testid":`auth-submit`,children:E?`Signing in…`:_?`Verify 2FA`:`Sign in`}),S&&(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:j,className:b,disabled:O,"data-testid":`auth-resend-verify`,children:O?`Sending…`:`Resend verification link`})}),(0,l.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(e?.registrationEnabled??!0)&&(0,l.jsx)(`button`,{type:`button`,onClick:()=>o(`register`),className:b,"data-testid":`auth-show-register`,children:`Create account`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>o(`forgot`),className:b+` ml-auto`,"data-testid":`auth-show-forgot`,children:`Forgot password?`})]})]})}function D({cfg:e,onErr:t,onOk:n,switchMode:r}){let[a,o]=(0,c.useState)(``),[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),[p,h]=(0,c.useState)(``),[_,x]=(0,c.useState)(!1);async function S(o){if(o.preventDefault(),t(``),n(``),!a||!s||d.length<8){t(`Fill all fields (password 8+ chars)`);return}if(e?.turnstileSiteKey&&!p){t(`Please complete the verification`);return}x(!0);try{let e={name:a,email:s,password:d};p&&(e.turnstileToken=p);let t=await i.post(`/api/auth/register`,e);t.needsVerification?n(`Account created. Check your email to verify.`):t.token?(n(`Account created. Signing you in…`),setTimeout(()=>{window.location.href=`/`},800)):n(t.message||`Account created`),r(`login`)}catch(e){t(e.message||`Registration failed`)}finally{x(!1)}}return(0,l.jsxs)(`form`,{onSubmit:S,className:`space-y-3`,"data-testid":`auth-register-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Create account`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Full name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,autoFocus:!0,className:v,value:a,onChange:e=>o(e.target.value),"data-testid":`auth-reg-name`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,required:!0,className:v,value:s,onChange:e=>u(e.target.value),"data-testid":`auth-reg-email`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Password (8+ characters)`}),(0,l.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:v,value:d,onChange:e=>f(e.target.value),"data-testid":`auth-reg-password`})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:h}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:_,"data-testid":`auth-reg-submit`,children:_?`Creating…`:`Create account`}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(`login`),className:b,children:`Back to sign in`})})]})}function O({cfg:e,onErr:t,onOk:n,switchMode:r}){let[a,o]=(0,c.useState)(``),[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(!1);async function p(r){if(r.preventDefault(),t(``),n(``),!a){t(`Enter your email`);return}if(e?.turnstileSiteKey&&!s){t(`Please complete the verification`);return}f(!0);try{let e={email:a};s&&(e.turnstileToken=s),n((await i.post(`/api/auth/forgot-password`,e)).message||`If an account exists, a reset link was sent.`)}catch(e){t(e.message||`Request failed`)}finally{f(!1)}}return(0,l.jsxs)(`form`,{onSubmit:p,className:`space-y-3`,"data-testid":`auth-forgot-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Reset password`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:`Enter your email and we'll send a reset link.`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,required:!0,autoFocus:!0,className:v,value:a,onChange:e=>o(e.target.value),"data-testid":`auth-forgot-email`})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:u}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:d,"data-testid":`auth-forgot-submit`,children:d?`Sending…`:`Send reset link`}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(`login`),className:b,children:`Back to sign in`})})]})}export{T as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{a as r,i,l as a,o,u as s}from"./index-C9wKWOAN.js";var c=e(t(),1),l=n(),u=`https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onTurnstileLoad`,d=!1,f=[];function p(){return new Promise(e=>{if(typeof window>`u`){e();return}if(window.turnstile){e();return}if(f.push(e),d)return;d=!0,window.onTurnstileLoad=()=>{for(let e of f.splice(0))e()};let t=document.createElement(`script`);t.src=u,t.async=!0,t.defer=!0,document.head.appendChild(t)})}function m({siteKey:e,onToken:t,action:n,theme:r=`light`}){let i=(0,c.useRef)(null),a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(!e){t(``);return}let o=!1;return p().then(()=>{if(!(o||!i.current||!window.turnstile))try{a.current=window.turnstile.render(i.current,{sitekey:e,theme:r,action:n,callback:e=>t(e),"error-callback":()=>t(``),"expired-callback":()=>t(``)})}catch{}}),()=>{if(o=!0,a.current&&window.turnstile)try{window.turnstile.remove(a.current)}catch{}}},[e]),e?(0,l.jsx)(`div`,{ref:i,className:`cf-turnstile my-2`}):null}var h=`rounded-2xl border border-border bg-card p-6 shadow-lg space-y-4 w-full max-w-md`,g=`w-full rounded-md bg-primary text-primary-foreground px-4 py-3 text-sm font-semibold disabled:opacity-60`,_=`w-full rounded-md bg-slate-900 text-white px-4 py-3 text-sm font-semibold disabled:opacity-60 hover:bg-slate-800`,v=`w-full rounded-md border border-input bg-background px-3 py-2.5 text-sm outline-none focus:ring-2 focus:ring-ring`,y=`block text-xs font-semibold text-muted-foreground mb-1`,b=`text-sm text-primary hover:underline`,x=`rounded-md bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-900 p-3 text-sm text-green-800 dark:text-green-100`,S=`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3 text-sm text-red-800 dark:text-red-100`,C=`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 p-3 text-sm text-amber-900 dark:text-amber-100`;function w(){let e=o(),t=r();return()=>{e(new URLSearchParams(t.search).get(`next`)||`/`,{replace:!0})}}function T(){let[e,t]=(0,c.useState)(`login`),[n,r]=(0,c.useState)(``),[o,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),p=s(),m=w(),{data:g}=a({queryKey:[`public-config`],queryFn:()=>i.get(`/api/auth/public-config`),staleTime:6e4}),v=!!g?.disableLocalAuth;function y(e){t(e),r(``),u(``),f(``)}return(0,l.jsx)(`div`,{className:`min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 dark:from-slate-900 dark:via-slate-950 dark:to-slate-900 flex items-center justify-center p-4`,children:(0,l.jsxs)(`div`,{className:h,children:[(0,l.jsxs)(`header`,{className:`text-center space-y-1`,children:[(0,l.jsx)(`div`,{className:`text-4xl`,children:`🩺`}),(0,l.jsx)(`h1`,{className:`text-xl font-bold`,children:`Pediatric AI Scribe`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`AI-Powered Clinical Documentation`})]}),n&&(0,l.jsx)(`div`,{className:S,children:n}),d&&(0,l.jsx)(`div`,{className:C,children:d}),o&&(0,l.jsx)(`div`,{className:x,children:o}),e===`login`&&!v&&(0,l.jsx)(E,{cfg:g,onErr:r,onInfo:f,onOk:u,onLogin:()=>{p.invalidateQueries({queryKey:[`auth-me`]}),m()},switchMode:y}),e===`register`&&!v&&(g?.registrationEnabled??!0)&&(0,l.jsx)(D,{cfg:g,onErr:r,onOk:u,switchMode:y}),e===`forgot`&&!v&&(0,l.jsx)(O,{cfg:g,onErr:r,onOk:u,switchMode:y}),g?.oidcEnabled&&(0,l.jsxs)(l.Fragment,{children:[!v&&(0,l.jsxs)(`div`,{className:`relative my-4`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,l.jsx)(`span`,{className:`w-full border-t border-border`})}),(0,l.jsx)(`div`,{className:`relative flex justify-center text-xs text-muted-foreground`,children:(0,l.jsx)(`span`,{className:`bg-card px-3`,children:`or`})})]}),(0,l.jsxs)(`a`,{href:`/api/auth/oidc`,className:_+` text-center block no-underline`,"data-testid":`auth-oidc`,children:[`🛡️ `,g.ssoButtonLabel||`Sign in with SSO`]})]}),v&&!g?.oidcEnabled&&(0,l.jsx)(`div`,{className:C,children:`Single sign-on not configured. Contact your administrator.`}),(0,l.jsxs)(`div`,{className:`pt-4 border-t border-border text-xs text-muted-foreground space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,l.jsx)(`span`,{children:`⚠️`}),(0,l.jsx)(`p`,{children:`HIPAA-compliant AI providers available with BAA. Check your institution's guidelines. Not intended for clinical use without proper authorization.`})]}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`a`,{href:`https://github.com/ifedan-ed/pediatric-ai-scribe-v3/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline`,children:`📱 Download Android app (APK)`})})]})]})})}function E({cfg:e,onErr:t,onInfo:n,onOk:r,onLogin:a,switchMode:o}){let[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),[p,h]=(0,c.useState)(``),[_,x]=(0,c.useState)(!1),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(``),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1);async function A(o){if(o.preventDefault(),t(``),n(``),r(``),!s||!d){t(`Enter email and password`);return}if(e?.turnstileSiteKey&&!w){t(`Please complete the verification`);return}D(!0);try{let e={email:s,password:d};w&&(e.turnstileToken=w),p&&(e.totpCode=p);let o=await i.post(`/api/auth/login`,e);if(o.requires2FA){x(!0),n(`Enter your 2FA code`),D(!1);return}if(o.needsVerification){C(!0),t(`Verify your email first. Check your inbox.`),D(!1);return}if(o.token){r(`Signed in`),a();return}t(`Login failed`)}catch(e){t(e.message||`Login failed`)}finally{D(!1)}}async function j(){if(!s){t(`Enter your email first`);return}k(!0);try{r((await i.post(`/api/auth/resend-verification`,{email:s})).message||`Verification email sent`)}catch(e){t(e.message||`Failed to resend`)}finally{k(!1)}}return(0,l.jsxs)(`form`,{onSubmit:A,className:`space-y-3`,"data-testid":`auth-login-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Sign in`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,autoFocus:!0,required:!0,className:v,value:s,onChange:e=>u(e.target.value),"data-testid":`auth-email`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Password`}),(0,l.jsx)(`input`,{type:`password`,required:!0,className:v,value:d,onChange:e=>f(e.target.value),"data-testid":`auth-password`})]}),_&&(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`2FA code`}),(0,l.jsx)(`input`,{type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,maxLength:6,className:v+` font-mono tracking-widest`,value:p,onChange:e=>h(e.target.value.replace(/\D/g,``)),"data-testid":`auth-totp`,autoFocus:!0})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:T}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:E,"data-testid":`auth-submit`,children:E?`Signing in…`:_?`Verify 2FA`:`Sign in`}),S&&(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:j,className:b,disabled:O,"data-testid":`auth-resend-verify`,children:O?`Sending…`:`Resend verification link`})}),(0,l.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(e?.registrationEnabled??!0)&&(0,l.jsx)(`button`,{type:`button`,onClick:()=>o(`register`),className:b,"data-testid":`auth-show-register`,children:`Create account`}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>o(`forgot`),className:b+` ml-auto`,"data-testid":`auth-show-forgot`,children:`Forgot password?`})]})]})}function D({cfg:e,onErr:t,onOk:n,switchMode:r}){let[a,o]=(0,c.useState)(``),[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(``),[p,h]=(0,c.useState)(``),[_,x]=(0,c.useState)(!1);async function S(o){if(o.preventDefault(),t(``),n(``),!a||!s||d.length<8){t(`Fill all fields (password 8+ chars)`);return}if(e?.turnstileSiteKey&&!p){t(`Please complete the verification`);return}x(!0);try{let e={name:a,email:s,password:d};p&&(e.turnstileToken=p);let t=await i.post(`/api/auth/register`,e);t.needsVerification?n(`Account created. Check your email to verify.`):t.token?(n(`Account created. Signing you in…`),setTimeout(()=>{window.location.href=`/`},800)):n(t.message||`Account created`),r(`login`)}catch(e){t(e.message||`Registration failed`)}finally{x(!1)}}return(0,l.jsxs)(`form`,{onSubmit:S,className:`space-y-3`,"data-testid":`auth-register-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Create account`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Full name`}),(0,l.jsx)(`input`,{type:`text`,required:!0,autoFocus:!0,className:v,value:a,onChange:e=>o(e.target.value),"data-testid":`auth-reg-name`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,required:!0,className:v,value:s,onChange:e=>u(e.target.value),"data-testid":`auth-reg-email`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Password (8+ characters)`}),(0,l.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:v,value:d,onChange:e=>f(e.target.value),"data-testid":`auth-reg-password`})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:h}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:_,"data-testid":`auth-reg-submit`,children:_?`Creating…`:`Create account`}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(`login`),className:b,children:`Back to sign in`})})]})}function O({cfg:e,onErr:t,onOk:n,switchMode:r}){let[a,o]=(0,c.useState)(``),[s,u]=(0,c.useState)(``),[d,f]=(0,c.useState)(!1);async function p(r){if(r.preventDefault(),t(``),n(``),!a){t(`Enter your email`);return}if(e?.turnstileSiteKey&&!s){t(`Please complete the verification`);return}f(!0);try{let e={email:a};s&&(e.turnstileToken=s),n((await i.post(`/api/auth/forgot-password`,e)).message||`If an account exists, a reset link was sent.`)}catch(e){t(e.message||`Request failed`)}finally{f(!1)}}return(0,l.jsxs)(`form`,{onSubmit:p,className:`space-y-3`,"data-testid":`auth-forgot-form`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold text-center`,children:`Reset password`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:`Enter your email and we'll send a reset link.`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:y,children:`Email`}),(0,l.jsx)(`input`,{type:`email`,required:!0,autoFocus:!0,className:v,value:a,onChange:e=>o(e.target.value),"data-testid":`auth-forgot-email`})]}),(0,l.jsx)(m,{siteKey:e?.turnstileSiteKey,onToken:u}),(0,l.jsx)(`button`,{type:`submit`,className:g,disabled:d,"data-testid":`auth-forgot-submit`,children:d?`Sending…`:`Send reset link`}),(0,l.jsx)(`div`,{className:`text-center`,children:(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(`login`),className:b,children:`Back to sign in`})})]})}export{T as default}; \ No newline at end of file diff --git a/public/app/assets/Bedside-BsBuEI_m.js b/public/app/assets/Bedside-Da0d6Hsf.js similarity index 99% rename from public/app/assets/Bedside-BsBuEI_m.js rename to public/app/assets/Bedside-Da0d6Hsf.js index 6bee270..bf17800 100644 --- a/public/app/assets/Bedside-BsBuEI_m.js +++ b/public/app/assets/Bedside-Da0d6Hsf.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,d as i,i as a,l as o,u as s}from"./fenton-Dvwmge1q.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,f=`block text-xs font-medium text-muted-foreground`,p=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,m=`px-2 py-1.5 border-b border-border align-top text-sm`;function h({label:e}){let t=e.indexOf(`(`);return t<0?(0,l.jsx)(`span`,{className:`font-semibold`,children:e}):(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`span`,{className:`font-semibold`,children:e.slice(0,t).trim()}),` `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.slice(t)})]})}function g({children:e,notes:t=!0}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:p,children:`Drug`}),(0,l.jsx)(`th`,{className:p,children:`Dose`}),(0,l.jsx)(`th`,{className:p,children:`Route`}),t&&(0,l.jsx)(`th`,{className:p,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}function _({name:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:m+` font-semibold`,dangerouslySetInnerHTML:{__html:e}}),(0,l.jsx)(`td`,{className:m,children:t}),(0,l.jsx)(`td`,{className:m+` text-xs`,children:n}),r!==void 0&&(0,l.jsx)(`td`,{className:m+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}function v(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`0`),[i,o]=(0,c.useState)(``),[s,p]=(0,c.useState)(`male`),[m,v]=(0,c.useState)(``),[y,b]=(0,c.useState)({appearance:2,pulse:2,grimace:2,activity:2,respiration:2}),x=Number.parseInt(e,10),S=Number.parseInt(n,10)||0,C=Number.parseFloat(i),w=Number.isFinite(x)&&x>=22&&x<=44&&Number.isFinite(C)&&C>0?a(x,S,C,s):null,T=Number.parseFloat(m),E=Number.isFinite(T)&&T>0,D=E?Math.round(T*.01*100)/100:0,O=E?Math.round(T*.03*100)/100:0,k=E?Math.round(T*.05*100)/100:0,A=E?Math.round(T*.1*100)/100:0,j=E?Math.round(T*10):0,M=E?Math.round(T*2*10)/10:0,N=Object.values(y).reduce((e,t)=>e+t,0),P=N>=7?`Reassuring`:N>=4?`Moderately depressed`:`Severely depressed`,F=N>=7?`text-green-600 bg-green-50`:N>=4?`text-amber-600 bg-amber-50`:`text-destructive bg-red-50`,I=N>=7?`Routine newborn care. Continue reassessment. Repeat at 5 min.`:N>=4?`Stimulate, clear airway, warm. Give O₂ if cyanotic. Ventilate with PPV if HR <100 or apneic/gasping. Reassess q30 sec.`:`Full NRP pathway — PPV immediately. Intubate if PPV ineffective. Chest compressions if HR <60. Epinephrine and volume per NRP.`;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-neonatal`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Neonatal Assessment + NRP + Apgar`}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Gestational age + size assessment (Fenton 2013)`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-2 sm:grid-cols-4 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`GA weeks`}),(0,l.jsx)(`input`,{type:`number`,min:`22`,max:`44`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`neo-weeks`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`GA days (0-6)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`6`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`neo-days`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Birth wt (g)`}),(0,l.jsx)(`input`,{type:`number`,min:`200`,max:`7000`,className:d,value:i,onChange:e=>o(e.target.value),"data-testid":`neo-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Sex`}),(0,l.jsxs)(`select`,{className:d,value:s,onChange:e=>p(e.target.value),"data-testid":`neo-sex`,children:[(0,l.jsx)(`option`,{value:`male`,children:`Male`}),(0,l.jsx)(`option`,{value:`female`,children:`Female`})]})]})]}),w&&(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,"data-testid":`neo-result`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.gaClass.color+`55`,background:w.gaClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Gestational Age`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.gaClass.color},children:w.gaClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[x,` wk `,S,` d (`,w.gaDecimal.toFixed(1),` wk)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.weightClass.color+`55`,background:w.weightClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Weight for Gestational Age`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.weightClass.color},children:w.weightClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[w.percentile.toFixed(1),`th percentile · `,w.weightClass.detail]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.bwClass.color+`55`,background:w.bwClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Birth Weight Category`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.bwClass.color},children:w.bwClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[C,` g (`,(C/1e3).toFixed(2),` kg)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/40 p-3 text-xs`,children:[(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:[`Fenton (`,s,`)`]}),(0,l.jsxs)(`div`,{className:`space-y-0.5 mt-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Expected weight (M):`}),` `,w.expectedWeight,` g`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Z-score:`}),` `,w.z.toFixed(2)]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Percentile:`}),` `,w.percentile.toFixed(1),`%`]})]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`NRP pathway (AHA/AAP 8th ed 2020)`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`BIRTH — ASSESS (first 30 sec)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Term? Tone? Breathing/crying? All yes → routine care. Any no → warm, dry, stimulate, clear airway PRN, evaluate HR + resp.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <100 OR apneic/gasping (60 s)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Start PPV`}),` 40-60 breaths/min, room air for term / 21-30% for preterm. Attach SpO₂ (right hand) ± ECG. MR SOPA if ineffective.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <100 after 30 s effective PPV`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Reassess ventilation — ensure chest rise. Consider increasing FiO₂, intubation, or LMA. Continue PPV.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-red-500 bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <60 after 30 s effective PPV`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Intubate + chest compressions`}),` — 3:1 ratio (90 compressions + 30 breaths/min), FiO₂ 100%, lower 1/3 sternum, depth 1/3 AP chest.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-100 dark:bg-red-950/40 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <60 despite compressions + PPV × 60 s`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Epinephrine 1:10,000 (0.1 mg/mL):`}),` IV/IO 0.01-0.03 mg/kg (0.1-0.3 mL/kg) — preferred. ETT 0.05-0.1 mg/kg. Repeat q3-5 min. Hypovolemia: `,(0,l.jsx)(`strong`,{children:`NS 10 mL/kg IV/IO over 5-10 min`}),`.`]})]})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`Target SpO₂ (preductal):`}),(0,l.jsx)(`br`,{}),`1 min 60-65% · 2 min 65-70% · 3 min 70-75% · 4 min 75-80% · 5 min 80-85% · 10 min 85-95%`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`Initial ETT size:`}),(0,l.jsx)(`br`,{}),`<1 kg / <28 wk: 2.5 · 1-2 kg / 28-34 wk: 3.0 · 2-3 kg / 34-38 wk: 3.5 · >3 kg / >38 wk: 3.5-4.0`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`ETT depth (lip):`}),` ~6 + weight(kg) cm`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`NRP drug doses`}),(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:m,onChange:e=>v(e.target.value),"data-testid":`nrp-weight`})]}),E?(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Epinephrine 1:10,000`,dose:(0,l.jsx)(h,{label:`${D}-${O} mg, ${Math.round(D*10)/10}-${Math.round(O*10)/10} mL (0.01-0.03 mg/kg = 0.1-0.3 mL/kg)`}),route:`IV / IO`,notes:`Preferred route. Repeat q3-5 min.`}),(0,l.jsx)(_,{name:`Epinephrine 1:10,000`,dose:(0,l.jsx)(h,{label:`${k}-${A} mg, ${Math.round(k*10)/10}-${Math.round(A*10)/10} mL (0.05-0.1 mg/kg = 0.5-1 mL/kg)`}),route:`ETT`,notes:`While IV being placed.`}),(0,l.jsx)(_,{name:`Normal saline`,dose:(0,l.jsx)(h,{label:`${j} mL (10 mL/kg)`}),route:`IV / IO`,notes:`Over 5-10 min for volume. Repeat PRN.`}),(0,l.jsx)(_,{name:`Dextrose 10%`,dose:(0,l.jsx)(h,{label:`${M} mL (2 mL/kg = 0.2 g/kg)`}),route:`IV slow push`,notes:`For documented hypoglycemia. Then D10 infusion 4-6 mg/kg/min.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see NRP doses.`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Concentration note:`}),` NRP uses epinephrine `,(0,l.jsx)(`strong`,{children:`1:10,000`}),` (0.1 mg/mL). NOT 1:1000 (1 mg/mL) — that is IM for anaphylaxis / older patients.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Apgar score`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-5 text-xs`,children:[[`appearance`,`Appearance`,[`Blue/pale`,`Body pink, extremities blue`,`All pink`]],[`pulse`,`Pulse`,[`Absent`,`<100 bpm`,`≥100 bpm`]],[`grimace`,`Grimace`,[`No response`,`Grimace`,`Cough/sneeze`]],[`activity`,`Activity`,[`Limp`,`Some flexion`,`Active motion`]],[`respiration`,`Respiration`,[`Absent`,`Slow/irregular`,`Good/crying`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:y[e],onChange:t=>b({...y,[e]:Number(t.target.value)}),"data-testid":`apgar-`+e,children:n.map((e,t)=>(0,l.jsxs)(`option`,{value:t,children:[t,` — `,e]},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+F,"data-testid":`apgar-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`Apgar: `,N,`/10 — `,P]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:I})]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground italic`,children:[`Fenton TR, Kim JH. BMC Pediatr 2013;13:59 · NRP 8th ed (AHA/AAP 2020) · Apgar is a description of status — `,(0,l.jsx)(`strong`,{children:`never`}),` delay resuscitation while scoring.`]})]})}function y(){let[e,t]=(0,c.useState)(`asthma`),[n,r]=(0,c.useState)(``),i=Number.parseFloat(n),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,[p,m]=(0,c.useState)(null),[v,y]=(0,c.useState)({spo2:0,retractions:0,scalene:0,air:0,wheeze:0}),b=Object.values(v).reduce((e,t)=>e+t,0),x=b<=3?`Mild`:b<=7?`Moderate`:`Severe`,S=b<=3?`text-green-600 bg-green-50`:b<=7?`text-amber-600 bg-amber-50`:`text-destructive bg-red-50`,[C,w]=(0,c.useState)({conscious:0,cyanosis:0,stridor:0,air:0,retractions:0}),T=Object.values(C).reduce((e,t)=>e+t,0),E=T<=2?`Mild`:T<=5?`Moderate`:T<=11?`Severe`:`Impending Respiratory Failure`,D=T<=2?`text-green-600 bg-green-50`:T<=5?`text-amber-600 bg-amber-50`:T<=11?`text-destructive bg-red-50`:`text-red-900 bg-red-100`,[O,k]=(0,c.useState)({age:`gte12w`,spo2:`ok`,hydration:`ok`,distress:`mild`}),A=O.distress===`severe`||O.spo2===`low`||O.hydration===`poor`||O.age===`lt12w`;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-respiratory`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Respiratory`}),(0,l.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:[`asthma`,`pram`,`croup`,`bronch`].map(n=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:`px-3 py-1 rounded-full text-xs font-medium border `+(e===n?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),"data-testid":`resp-mode-`+n,children:n===`asthma`?`Asthma`:n===`pram`?`PRAM`:n===`croup`?`Croup (Westley)`:`Bronchiolitis`},n))}),e!==`pram`&&e!==`bronch`&&(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`resp-weight`})]}),e===`asthma`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`flex gap-2`,children:[`mild`,`moderate`,`severe`].map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`px-3 py-1 rounded text-xs font-medium border `+(p===e?e===`mild`?`bg-green-600 text-white`:e===`moderate`?`bg-amber-500 text-white`:`bg-destructive text-white`:`bg-muted`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),p&&!a&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`}),p===`mild`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in sentences, no accessory muscle use, SpO₂ ≥94%`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol (MDI)`,dose:`4-8 puffs via spacer`,route:`Inhaled`,notes:`q20min × 3 doses, then q1-4h`}),(0,l.jsx)(_,{name:`Albuterol (neb)`,dose:(0,l.jsx)(h,{label:`${o(.15,5,`mg`).label} (min 2.5 mg)`}),route:`Nebulized`,notes:`q20min × 3 doses`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`PO/IV`,notes:`Single dose, or 2 days`}),(0,l.jsx)(_,{name:`Prednisolone`,dose:(0,l.jsx)(h,{label:`${o(1,60).label}/day`}),route:`PO`,notes:`Alternative: 3-5 day course`})]})]}),p===`moderate`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in phrases, some accessory muscle use, SpO₂ 90-93%`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol (neb)`,dose:(0,l.jsx)(h,{label:`${o(.15,5,`mg`).label} (min 2.5 mg)`}),route:`Nebulized`,notes:`q20min × 3 doses, then continuous if needed`}),(0,l.jsx)(_,{name:`Ipratropium`,dose:i<20?`250 mcg`:`500 mcg`,route:`Nebulized`,notes:`q20min × 3 doses with albuterol`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`PO/IV/IM`,notes:`Single dose`}),(0,l.jsx)(_,{name:`O₂ supplemental`,dose:`Target SpO₂ ≥94%`,route:`NC/mask`,notes:`Titrate to effect`})]})]}),p===`severe`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in words only, significant accessory muscle use, SpO₂ <90%. Consider ICU.`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol continuous`,dose:(0,l.jsx)(h,{label:`${o(.5,20,`mg`).label}/hr`}),route:`Continuous neb`,notes:`Or 0.15-0.3 mg/kg q20min`}),(0,l.jsx)(_,{name:`Ipratropium`,dose:i<20?`250 mcg`:`500 mcg`,route:`Nebulized`,notes:`q20min × 3 doses with albuterol`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`IV`,notes:`Or methylprednisolone 2 mg/kg IV (max 60 mg)`}),(0,l.jsx)(_,{name:`Magnesium sulfate`,dose:(0,l.jsx)(h,{label:`${o(50,2e3).label} IV over 20 min`}),route:`IV`,notes:`Single dose, monitor BP`}),(0,l.jsx)(_,{name:`Epinephrine (IM)`,dose:(0,l.jsx)(h,{label:`${o(.01,.5).label} (1:1000)`}),route:`IM`,notes:`If impending arrest / no IV access`}),(0,l.jsx)(_,{name:`Terbutaline`,dose:(0,l.jsx)(h,{label:`${o(.01,.4).label} SC/IV`}),route:`SC/IV`,notes:`Then 0.1-10 mcg/kg/min infusion`}),(0,l.jsx)(_,{name:`O₂ supplemental`,dose:`Target SpO₂ ≥94%`,route:`High flow / NIPPV`,notes:`Consider BiPAP/CPAP`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-100`,children:[(0,l.jsx)(`strong`,{children:`Continuous monitoring.`}),` Consider ICU admission. If no response to magnesium → terbutaline infusion. If impending respiratory failure → intubation (ketamine preferred induction agent).`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`NAEPP/GINA guidelines. Always use clinical judgment.`})]}),e===`pram`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric Respiratory Assessment Measure (PRAM) — for asthma exacerbation severity (0-12).`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2`,children:[[`spo2`,`SpO₂`,[`≥95% (0)`,`92-94% (1)`,`<92% (2)`]],[`retractions`,`Suprasternal retractions`,[`Absent (0)`,`Present (2)`]],[`scalene`,`Scalene muscle use`,[`Absent (0)`,`Present (2)`]],[`air`,`Air entry`,[`Normal (0)`,`Mild ↓ at bases (1)`,`Widespread ↓ (2)`,`Absent/minimal (3)`]],[`wheeze`,`Wheezing`,[`Absent (0)`,`Expiratory only (1)`,`Ins+exp (2)`,`Audible without stethoscope/silent chest (3)`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:v[e],onChange:t=>y({...v,[e]:Number(t.target.value)}),"data-testid":`pram-`+e,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:t,children:e},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+S,"data-testid":`pram-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`PRAM Score: `,b,`/12 — `,x]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Mild (0-3): outpatient management. Moderate (4-7): consider oral steroids + frequent bronchodilators. Severe (8-12): aggressive treatment, consider ICU.`})]})]}),e===`croup`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Westley croup score (0-17).`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2`,children:[[`conscious`,`Level of consciousness`,[`Normal (0)`,`Disoriented (5)`]],[`cyanosis`,`Cyanosis`,[`None (0)`,`With agitation (4)`,`At rest (5)`]],[`stridor`,`Stridor`,[`None (0)`,`With agitation (1)`,`At rest (2)`]],[`air`,`Air entry`,[`Normal (0)`,`Decreased (1)`,`Severely decreased (2)`]],[`retractions`,`Retractions`,[`None (0)`,`Mild (1)`,`Moderate (2)`,`Severe (3)`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:C[e],onChange:t=>w({...C,[e]:Number(t.target.value)}),"data-testid":`croup-`+e,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:t,children:e},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+D,"data-testid":`croup-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`Westley: `,T,`/17 — `,E]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Mild ≤2 · Moderate 3-5 · Severe 6-11 · Impending failure ≥12.`})]}),a&&(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:T<=2?`PO`:T<=5?`PO/IM`:`IV/IM`,notes:`Preferred corticosteroid; single dose`}),T>2&&(0,l.jsx)(_,{name:`Racemic epinephrine`,dose:`0.5 mL of 2.25% solution`,route:`Nebulized`,notes:`May repeat q15-20min, observe 2-4 h`}),T>2&&(0,l.jsx)(_,{name:`Nebulized epinephrine`,dose:`0.5 mL/kg of 1:1000 (max 5 mL)`,route:`Nebulized`,notes:`Alternative to racemic`}),T>5&&(0,l.jsx)(_,{name:`Heliox`,dose:`70:30 or 80:20`,route:`Face mask`,notes:`Consider if not responding`})]})]}),e===`bronch`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age`}),(0,l.jsxs)(`select`,{className:d,value:O.age,onChange:e=>k({...O,age:e.target.value}),children:[(0,l.jsx)(`option`,{value:`lt12w`,children:`<12 weeks (high risk)`}),(0,l.jsx)(`option`,{value:`gte12w`,children:`≥12 weeks`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`SpO₂`}),(0,l.jsxs)(`select`,{className:d,value:O.spo2,onChange:e=>k({...O,spo2:e.target.value}),children:[(0,l.jsx)(`option`,{value:`ok`,children:`≥90%`}),(0,l.jsx)(`option`,{value:`low`,children:`<90%`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Hydration`}),(0,l.jsxs)(`select`,{className:d,value:O.hydration,onChange:e=>k({...O,hydration:e.target.value}),children:[(0,l.jsx)(`option`,{value:`ok`,children:`Adequate`}),(0,l.jsx)(`option`,{value:`poor`,children:`Poor oral intake`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Distress`}),(0,l.jsxs)(`select`,{className:d,value:O.distress,onChange:e=>k({...O,distress:e.target.value}),children:[(0,l.jsx)(`option`,{value:`mild`,children:`Mild`}),(0,l.jsx)(`option`,{value:`moderate`,children:`Moderate`}),(0,l.jsx)(`option`,{value:`severe`,children:`Severe`})]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+(A?`text-destructive bg-red-50`:`text-green-600 bg-green-50`),"data-testid":`bronch-result`,children:[(0,l.jsx)(`div`,{className:`text-base font-bold`,children:A?`Admit / Observe`:`Likely Safe for Discharge`}),O.age===`lt12w`&&(0,l.jsx)(`div`,{className:`text-xs text-destructive mt-1`,children:`⚠ Age <12 weeks — high risk for apnea. Monitor closely.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`NOT recommended (AAP 2014/2023):`}),` Albuterol/salbutamol (no benefit), epinephrine (no evidence), systemic corticosteroids (no benefit), antibiotics (unless bacterial co-infection), chest physiotherapy.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Clinical Practice Guideline: Management of Bronchiolitis in Infants and Children (2014, reaffirmed 2023). RSV most common (50-80%).`})]})]})}function b(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(``),i=Number.parseFloat(e),a=Number.parseFloat(n),o=Number.isFinite(i)&&i>0,s=o?Math.round(i*1*10)/10:0,p=o?Math.round(i*2*10)/10:0,m=o?Math.round(i*6*10)/10:0,h=o?Math.round(i*8*10)/10:0,v=Number.isFinite(a)&&a>=0?a<.1?`30-40`:a<1?`25-35`:a<5?`20-25`:a<12?`16-20`:`12-16`:``;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-ventilation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`O₂ & Ventilation`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-2 max-w-md`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`vent-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age (years)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,step:`0.5`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`vent-age`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Target SpO₂`}),(0,l.jsxs)(g,{notes:!0,children:[(0,l.jsx)(_,{name:`Most children`,dose:`94-98%`,route:`—`,notes:`Normal`}),(0,l.jsx)(_,{name:`Bronchiolitis (AAP 2014/2023)`,dose:`≥90%`,route:`—`,notes:`Don't chase higher saturations`}),(0,l.jsx)(_,{name:`Chronic lung disease / CF`,dose:`90-94%`,route:`—`,notes:`Avoid hyperoxia in CO₂ retainers`}),(0,l.jsx)(_,{name:`Preterm neonate`,dose:`90-95%`,route:`—`,notes:`Minimize ROP risk`}),(0,l.jsx)(_,{name:`Term neonate (min of life)`,dose:`Per NRP ladder`,route:`—`,notes:`1 min 60-65% · 10 min 85-95%`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Escalation ladder`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`1. Nasal cannula (low-flow)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`0.5-6 L/min`}),` · FiO₂ ~24-40% · comfortable, no humidification. Good for mild hypoxia.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`2. Simple face mask`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`6-10 L/min`}),` · FiO₂ 35-60%. Must keep flow >6 L/min to flush CO₂.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`3. Non-rebreather mask`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`10-15 L/min`}),` · FiO₂ 60-90%. Reservoir bag must stay inflated.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`4. High-flow nasal cannula (HFNC)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:o?`1-2 L/kg/min = ${s}-${p} L/min`:`1-2 L/kg/min`}),` · heated + humidified · FiO₂ 30-100% titratable · generates ~2-5 cmH₂O PEEP. Reassess at 1-2 h.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-red-500 bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`5. Non-invasive (CPAP / BiPAP)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`CPAP 5-10 cmH₂O · BiPAP IPAP 10-14 / EPAP 5. Needs cooperative patient, intact airway reflexes, no copious secretions.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-100 dark:bg-red-950/40 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`6. Intubate + mechanical ventilation`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`When NIV fails, airway compromised, apnea, or GCS ≤8. See Airway tab for RSI drugs.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Bag-Valve-Mask (BVM)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`When:`}),` apnea, bradycardia (HR <60 neonate; inadequate breathing at any age), during resuscitation.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` Newborn 40-60/min · Infant-child 20-30/min · Adolescent 10-12/min (1 breath q5-6 sec).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` 6-8 mL/kg — gentle chest rise only. Avoid over-ventilation.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Technique:`}),` head tilt / jaw thrust, E-C or 2-thumb mask seal, squeeze 1 sec, release fully.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Not ventilating?`}),` MR SOPA — Mask reseal, Reposition airway, Suction, Open mouth, Pressure ↑, Alternative airway.`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Mechanical vent — starting settings`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Mode:`}),` Volume-control OR Pressure-control. PRVC / SIMV-PS hybrids.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` `,(0,l.jsx)(`strong`,{children:o?`${m}-${h} mL`:`6-8 mL/kg`}),` (6-8 mL/kg). Use 4-6 mL/kg for ARDS.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` `,v?`${v}/min (age ${a} yr)`:`Newborn 30-40 · Infant 25-35 · Child 16-20 · Adolescent 12-16`,`.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`PEEP:`}),` start 5 cmH₂O. Increase to 8-12+ for refractory hypoxia.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`FiO₂:`}),` start 100%, wean rapidly to lowest that maintains target SpO₂.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`I:E ratio:`}),` 1:2 normally; 1:3-4 for obstructive disease.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Plateau pressure:`}),` keep <30 cmH₂O (ideally <28).`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Adjusting for gas exchange`}),(0,l.jsxs)(g,{notes:!0,children:[(0,l.jsx)(_,{name:`Low SpO₂ (oxygenation)`,dose:`↑ FiO₂`,route:`—`,notes:`Then ↑ PEEP (recruits collapsed alveoli)`}),(0,l.jsx)(_,{name:`↑ PCO₂ (ventilation)`,dose:`↑ Rate`,route:`—`,notes:`Then ↑ Tidal volume`}),(0,l.jsx)(_,{name:`↓ PCO₂ (over-ventilating)`,dose:`↓ Rate`,route:`—`,notes:`Then ↓ Tidal volume`}),(0,l.jsx)(_,{name:`High peak pressure`,dose:`Check tube / compliance`,route:`—`,notes:`Suction, bronchodilator, lower TV`}),(0,l.jsx)(_,{name:`Auto-PEEP (asthma, bronch)`,dose:`↓ Rate, ↑ Te`,route:`—`,notes:`Disconnect + bag briefly if critical`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-xs text-green-900 dark:text-green-100`,children:[(0,l.jsx)(`strong`,{children:`Mental model:`}),` Oxygenation is mostly `,(0,l.jsx)(`strong`,{children:`FiO₂ + PEEP`}),`. Ventilation (CO₂) is mostly `,(0,l.jsx)(`strong`,{children:`rate + tidal volume`}),`. Obstructive (asthma, bronchiolitis) → long expiratory time, permissive hypercapnia. Restrictive (ARDS) → low TV, high PEEP, permissive hypercapnia + hypoxia.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP / PALS / AARC guidance.`})]})}function x(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`child`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,p=n===`neonate`?`Neonate (0-28 d)`:n===`infant`?`Young infant (29 d - 3 mo)`:`Older child / adolescent`,m=a?Math.round(i*20):null;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-sepsis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Sepsis & Fever`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2 max-w-md`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`sepsis-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age band`}),(0,l.jsxs)(`select`,{className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`sepsis-age`,children:[(0,l.jsx)(`option`,{value:`neonate`,children:`Neonate (0-28 d)`}),(0,l.jsx)(`option`,{value:`infant`,children:`Infant (29 d - 3 mo)`}),(0,l.jsx)(`option`,{value:`child`,children:`Older child / adolescent`})]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,children:[`Sepsis approach — `,p,a?`, ${i} kg`:``]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Definition — Phoenix Sepsis Criteria (JAMA 2024)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Sepsis`}),` = suspected or confirmed infection + Phoenix Score ≥2 (organ dysfunction across respiratory, cardiovascular, coagulation, neurological).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Septic shock`}),` = sepsis + cardiovascular dysfunction (vasoactive support, or ↑lactate ≥5, or ↓MAP for age).`]}),(0,l.jsx)(`div`,{className:`text-muted-foreground italic`,children:`Previous SIRS-based criteria (Goldstein 2005) are now superseded.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Red flags`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-100`,children:[`Abnormal behavior / mentation · Fever + ill-appearance · Tachycardia out of proportion to fever · Prolonged cap refill (>3 s) · Cold/mottled extremities · Weak pulses or wide pulse pressure ("warm shock") · Hypotension is a `,(0,l.jsx)(`strong`,{children:`LATE`}),` sign · Any immune compromise / indwelling line.`]}),(0,l.jsxs)(`h3`,{className:`text-sm font-semibold mt-2`,children:[`Empirical therapy — `,p]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[n===`neonate`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Workup (full sepsis eval):`}),` CBC+diff, CRP, blood culture, UA+urine culture (cath), `,(0,l.jsx)(`strong`,{children:`LP`}),` (CSF+HSV PCR), CXR if respiratory sx, procalcitonin. `,(0,l.jsx)(`strong`,{children:`Early-onset`}),` (<72 h): GBS, E. coli, Listeria. `,(0,l.jsx)(`strong`,{children:`Late-onset`}),` (>72 h): CoNS, S. aureus, gram-negs, Candida.`]}),n===`infant`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Workup:`}),` Use validated rules — PECARN, Aronson, Rochester, Step-by-Step. CBC+ANC, procalcitonin/CRP, blood culture, UA+urine culture. Many warrant LP + admission + empiric abx. `,(0,l.jsx)(`strong`,{children:`Coverage:`}),` GBS, E. coli, Listeria (up to ~6 wk), S. pneumo, N. meningitidis, H. flu, Salmonella.`]}),n===`child`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Recognition:`}),` Phoenix score or clinical concern + suspected infection. `,(0,l.jsx)(`strong`,{children:`Workup:`}),` CBC, CRP, procalcitonin, blood cx (+site-specific), lactate, blood gas, glucose, electrolytes, coags, LP if CNS concern. Source-directed imaging.`]})]}),a&&(0,l.jsxs)(g,{children:[n===`neonate`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ampicillin`,dose:(0,l.jsx)(h,{label:o(100,2e3).label}),route:`IV`,notes:`q8-12h. Covers GBS, Listeria, Enterococcus.`}),(0,l.jsx)(_,{name:`Gentamicin`,dose:(0,l.jsx)(h,{label:o(4,120).label}),route:`IV`,notes:`q24-48h. Monitor levels.`}),(0,l.jsx)(_,{name:`Cefotaxime (add)`,dose:(0,l.jsx)(h,{label:o(50,2e3).label}),route:`IV`,notes:`If meningitis or gram-neg concern.`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`HSV risk: maternal lesions, vesicles, seizures, CSF pleocytosis.`})]}),n===`infant`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ceftriaxone`,dose:(0,l.jsx)(h,{label:o(75,2e3).label}),route:`IV / IM`,notes:`q24h (100 mg/kg/day divided q12h for meningitis). Avoid <28 d if hyperbilirubinemia.`}),(0,l.jsx)(_,{name:`Ampicillin`,dose:(0,l.jsx)(h,{label:o(100,2e3).label}),route:`IV`,notes:`If <6 wk: add for Listeria coverage.`}),(0,l.jsx)(_,{name:`Vancomycin`,dose:(0,l.jsx)(h,{label:o(15,1e3).label}),route:`IV`,notes:`If severe / MRSA risk / meningitis.`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`<6 wk with suspicion of HSV.`})]}),n===`child`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ceftriaxone`,dose:(0,l.jsx)(h,{label:o(50,2e3).label}),route:`IV`,notes:`q24h (100 mg/kg/day divided for meningitis).`}),(0,l.jsx)(_,{name:`Vancomycin`,dose:(0,l.jsx)(h,{label:o(15,1e3).label}),route:`IV`,notes:`q6h. If severe, indwelling line, or MRSA prevalence >10%.`}),(0,l.jsx)(_,{name:`Piperacillin-tazobactam`,dose:(0,l.jsx)(h,{label:o(100,4500).label}),route:`IV`,notes:`If intra-abdominal / neutropenic.`}),(0,l.jsx)(_,{name:`Clindamycin`,dose:(0,l.jsx)(h,{label:o(10,900).label}),route:`IV`,notes:`Adjunct for toxic shock syndrome (toxin suppression).`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`If HSV CNS concern.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`First-hour bundle (SSC Peds 2020)`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`0-5 min — Recognize`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Screen, sepsis huddle/activation, ABCs, O₂ to SpO₂ >94%, warm.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`5-15 min — Access & labs`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Two IVs or IO. Draw blood cx (ideally before abx), lactate, CBC, CMP, coags, blood gas, glucose. UA + culture. Source-specific cultures.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`15-30 min — Fluids`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[a?(0,l.jsxs)(l.Fragment,{children:[`NS or LR `,(0,l.jsxs)(`strong`,{children:[m,` mL`]}),` bolus (20 mL/kg) over 5-10 min.`]}):(0,l.jsx)(l.Fragment,{children:`NS/LR 10-20 mL/kg bolus over 5-10 min.`}),` Reassess HR, perfusion, lungs, liver. Repeat up to 40-60 mL/kg; stop if crackles/hepatomegaly.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`30-60 min — Antibiotics + reassess`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Broad-spectrum empiric abx within 1 hour (≤1 h in septic shock). Recheck lactate, perfusion.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`>60 min — Fluid-refractory shock`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Start vasoactive (`,(0,l.jsx)(`strong`,{children:`epinephrine 0.05-0.3 mcg/kg/min`}),` cold / `,(0,l.jsx)(`strong`,{children:`norepinephrine 0.05-0.3 mcg/kg/min`}),` warm). Central/IO access. Stress-dose hydrocortisone `,a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`strong`,{children:[o(2,100).value,` mg`]}),` IV (2 mg/kg, max 100 mg)`]}):`2 mg/kg IV (max 100 mg)`,` if catecholamine-resistant. ICU.`]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Resuscitation targets`}),(0,l.jsx)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:`Normal mentation · Cap refill ≤2 s · Warm extremities · Strong peripheral pulses · UOP ≥1 mL/kg/hr · MAP ≥5th %ile for age (>65 mmHg adolescent) · SpO₂ ≥94% · Lactate trending down.`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Phoenix Sepsis Criteria (Schlapbach et al., JAMA 2024) · Surviving Sepsis Campaign Pediatric 2020 · AAP pediatric sepsis guidance.`})]})}var S=[{key:`head`,label:`Head`,vals:[18,13,11,9,7],ageSensitive:!0},{key:`neck`,label:`Neck`,vals:[2,2,2,2,2]},{key:`ant_trunk`,label:`Anterior trunk`,vals:[13,13,13,13,13]},{key:`post_trunk`,label:`Posterior trunk`,vals:[13,13,13,13,13]},{key:`r_buttock`,label:`Right buttock`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`l_buttock`,label:`Left buttock`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`genital`,label:`Genitalia`,vals:[1,1,1,1,1]},{key:`r_uparm`,label:`R upper arm`,vals:[4,4,4,4,4]},{key:`l_uparm`,label:`L upper arm`,vals:[4,4,4,4,4]},{key:`r_forearm`,label:`R forearm`,vals:[3,3,3,3,3]},{key:`l_forearm`,label:`L forearm`,vals:[3,3,3,3,3]},{key:`r_hand`,label:`R hand`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`l_hand`,label:`L hand`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`r_thigh`,label:`R thigh`,vals:[5.5,8,8.5,9,9.5],ageSensitive:!0},{key:`l_thigh`,label:`L thigh`,vals:[5.5,8,8.5,9,9.5],ageSensitive:!0},{key:`r_leg`,label:`R lower leg`,vals:[5,5.5,6,6.5,7],ageSensitive:!0},{key:`l_leg`,label:`L lower leg`,vals:[5,5.5,6,6.5,7],ageSensitive:!0},{key:`r_foot`,label:`R foot`,vals:[3.5,3.5,3.5,3.5,3.5]},{key:`l_foot`,label:`L foot`,vals:[3.5,3.5,3.5,3.5,3.5]}],C=[{id:`infant`,label:`Infant (<1 y)`},{id:`young`,label:`Young child (1-5 y)`},{id:`child`,label:`Child (5-10 y)`},{id:`adol`,label:`Adolescent (10-15 y)`},{id:`adult`,label:`Adult (>15 y)`}];function w(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`young`),[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)({}),p=C.findIndex(e=>e.id===n),m=S.reduce((e,t)=>e+t.vals[p]*Math.min(100,Math.max(0,o[t.key]??0))/100,0),h=i.trim()?Number(i):Math.round(m*10)/10,g=Number.parseFloat(e),_=Number.isFinite(g)&&g>0,v=Number.isFinite(h)&&h>0,y=_&&v?Math.round(4*g*h):0,b=Math.round(y/2),x=Math.round(b/8),w=y-b,T=Math.round(w/16),E=_?Math.round(g<=10?g*4:g<=20?40+(g-10)*2:60+(g-20)):0;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-burns`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Burns — Lund-Browder + Parkland`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-3 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`burn-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age band`}),(0,l.jsx)(`select`,{className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`burn-age`,children:C.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`TBSA override (%)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`100`,step:`1`,className:d,value:i,onChange:e=>a(e.target.value),placeholder:v?String(h):`auto`,"data-testid":`burn-tbsa`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Body parts — % of each region burned (2° or deeper)`}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2`,children:S.map(e=>{let t=e.vals[p];return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/30 rounded p-2`,children:[(0,l.jsxs)(`label`,{className:`flex-1 text-xs`,children:[e.label,` `,(0,l.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t,`%`,e.ageSensitive?`*`:``,`)`]})]}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`100`,step:`5`,className:`w-16 rounded border border-input bg-background px-2 py-1 text-xs text-right`,value:o[e.key]??0,onChange:t=>s({...o,[e.key]:Number(t.target.value)}),"data-testid":`burn-region-`+e.key}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`%`})]},e.key)})}),v&&(0,l.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Computed TBSA: `,(0,l.jsxs)(`strong`,{children:[h,`%`]})]}),!_&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see Parkland + maintenance fluids.`}),!v&&_&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter % per region or override TBSA to compute fluids.`}),_&&v&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,"data-testid":`burn-result`,children:[`Burn fluid resuscitation — `,g,` kg, `,h,`% TBSA (2° or deeper)`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Parkland formula:`}),` 4 mL × kg × %TBSA = `,(0,l.jsxs)(`strong`,{children:[y,` mL LR over 24 hours`]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`First 8 h`}),` (from time of burn): `,b,` mL (~`,(0,l.jsxs)(`strong`,{children:[x,` mL/hr`]}),`)`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Next 16 h:`}),` `,w,` mL (~`,(0,l.jsxs)(`strong`,{children:[T,` mL/hr`]}),`)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Plus maintenance (4-2-1):`}),` `,E,` mL/hr (D5 ½NS ± 20 mEq KCl/L once UOP established). Consider dextrose in children <30 kg.`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Titrate to UOP:`}),` target 1-2 mL/kg/hr (infants / children), 0.5-1 mL/kg/hr (adolescents). `,(0,l.jsx)(`strong`,{children:`Clinical response trumps formula.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Other pearls`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rule of palm:`}),` Patient's palm + fingers ≈ 1% TBSA — good for scattered burns.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`First-degree burns DO NOT count`}),` toward TBSA or Parkland.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Analgesia:`}),` Morphine 0.05-0.1 mg/kg IV q2h, or fentanyl 1-2 mcg/kg IV q30-60 min.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tetanus`}),` prophylaxis if indicated. Tdap/Td ± TIG.`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Burn center referral (ABA)`}),(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`Partial-thickness >10% TBSA · any full-thickness · face/hands/feet/genital/perineum/major joints · electrical/chemical/inhalation · associated trauma · significant comorbidities · pediatric burns in non-pediatric center.`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ABA Advanced Burn Life Support 2018 · Parkland formula: Baxter 1968 · Lund-Browder 1944.`})]})}var T=`rounded-lg border border-border bg-card p-5 space-y-3`,E=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,D=`block text-xs font-medium text-muted-foreground`,O=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,k=`px-2 py-1.5 border-b border-border align-top text-sm`;function A({id:e,value:t,onChange:n,testid:r}){return(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{htmlFor:e,className:D,children:`Weight (kg)`}),(0,l.jsx)(`input`,{id:e,type:`number`,min:`0.3`,step:`0.1`,className:E,value:t,onChange:e=>n(e.target.value),"data-testid":r})]})}function j({label:e}){let t=e.indexOf(`(`);if(t<0)return(0,l.jsx)(`span`,{className:`font-semibold`,children:e});let n=e.slice(0,t).trim(),r=e.slice(t);return(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`span`,{className:`font-semibold`,children:n}),` `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})}var M={epi:{perKg:.01,max:.5,unit:`mg`},fluids:{perKg:20,max:null,unit:`mL`},dph:{perKg:1.25,max:50,unit:`mg`},ranitidine:{perKg:1,max:50,unit:`mg`},dex:{perKg:.6,max:16,unit:`mg`},mpn:{perKg:2,max:125,unit:`mg`},glucagon:{perKg:.02,max:1,unit:`mg`}};function N(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e);if(!Number.isFinite(n)||n<=0)return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-anaphylaxis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Anaphylaxis`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Emergency management. Epinephrine IM is the immediate and only proven lifesaving step.`}),(0,l.jsx)(A,{id:`anaph-wt`,value:e,onChange:t,testid:`anaph-weight`}),(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]});let r=s(n,M.epi.perKg,M.epi.max,M.epi.unit),i=Math.round(r.value*10)/10,a=n<10?`Draw up manually`:n<=25?`EpiPen Jr / Auvi-Q 0.15 mg`:`EpiPen / Auvi-Q 0.3 mg`,o=s(n,M.fluids.perKg,M.fluids.max,M.fluids.unit),u=s(n,M.dph.perKg,M.dph.max),d=s(n,M.ranitidine.perKg,M.ranitidine.max),f=s(n,M.dex.perKg,M.dex.max),p=s(n,M.mpn.perKg,M.mpn.max),m=s(n,M.glucagon.perKg,M.glucagon.max),h=[[`STEP 2`,`Position`,`Supine + legs elevated`,`—`,`If dyspneic: sitting position. If vomiting: recovery position`],[`STEP 3`,`O₂`,`High flow 10-15 L/min`,`Face mask`,`100% O₂. Prepare for airway management`],[`STEP 4`,`IV fluids`,`NS ${o.label} bolus`,`IV/IO`,`Repeat up to 60 mL/kg for hypotension`],[`STEP 5`,`Diphenhydramine`,u.label,`IV/IM/PO`,`H1 blocker. NOT first-line — adjunct only`],[``,`Ranitidine`,d.label,`IV over 5 min`,`H2 blocker. Optional adjunct`],[`STEP 6`,`Dexamethasone`,f.label,`IV/IM/PO`,`Prevents biphasic reaction (4-6 hrs later)`],[``,`Methylprednisolone`,p.label,`IV`,`Alternative steroid`],[`REFRACTORY`,`Epinephrine gtt`,`0.1-1 mcg/kg/min`,`IV infusion`,`For persistent hypotension despite fluids + IM epi`],[``,`Glucagon`,m.label,`IV/IM`,`For patients on beta-blockers not responding to epi`]];return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-anaphylaxis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Anaphylaxis`}),(0,l.jsx)(A,{id:`anaph-wt`,value:e,onChange:t,testid:`anaph-weight`}),(0,l.jsxs)(`div`,{className:`rounded-lg border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-4 space-y-1`,children:[(0,l.jsx)(`div`,{className:`text-base font-bold text-destructive`,children:`STEP 1: Epinephrine IM — GIVE IMMEDIATELY`}),(0,l.jsxs)(`div`,{className:`text-sm font-semibold`,children:[`Epinephrine 1:1000 (1 mg/mL): `,(0,l.jsxs)(`span`,{className:`text-destructive`,children:[r.value,` mg (`,i,` mL)`]}),` IM to lateral thigh`]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[M.epi.perKg,` mg/kg (max `,M.epi.max,` mg) · Auto-injector: `,a]}),(0,l.jsx)(`div`,{className:`text-xs text-destructive`,children:`May repeat every 5-15 minutes if symptoms persist. No contraindications in anaphylaxis.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`anaph-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Step`}),(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:h.map((e,t)=>(0,l.jsxs)(`tr`,{className:e[0]===`REFRACTORY`||t>0&&h[t-1][0]===`REFRACTORY`&&e[0]===``?`bg-amber-50 dark:bg-amber-950/30`:``,children:[(0,l.jsx)(`td`,{className:k+` font-semibold text-primary text-xs`,children:e[0]}),(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e[1]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:e[2]})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e[3]}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e[4]})]},t))})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Observe minimum 4-6 hours`}),` after last dose of epinephrine (biphasic reactions occur in 5-20% of cases). Discharge with EpiPen prescription and anaphylaxis action plan. Refer to allergist.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ASCIA Anaphylaxis Guidelines 2021 · WAO Anaphylaxis Guidance 2020 · AAP/ACAAI Practice Parameters.`})]})}function P(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`general`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,u=[{id:`general`,label:`PALS General`},{id:`asystole`,label:`Asystole / PEA`},{id:`brady`,label:`Bradycardia`},{id:`svt`,label:`SVT`},{id:`vfib`,label:`VF / Pulseless VT`},{id:`vt`,label:`Stable VT`}];function d({name:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:r})]})}function f({children:e}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}function p(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.1,10,`mL`),n=o(.1,2.5,`mg`),r=o(5,300,`mg`),i=o(1,100,`mg`),s=o(.02,.5,`mg`),c=o(.1,6,`mg`),u=o(.2,12,`mg`),p=o(1,50,`mEq`),m=o(20,1e3,`mg`),h=o(.2,10,`mL`),g=o(60,3e3,`mg`),_=o(.6,30,`mL`),v=o(50,2e3,`mg`),y=o(2,null,`mL`);return(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Epinephrine 1:10,000`,dose:`${e.label} (${t.label})`,route:`IV / IO`,notes:`0.01 mg/kg = 0.1 mL/kg of 1:10,000. Max single dose 1 mg. Repeat q3-5 min.`}),(0,l.jsx)(d,{name:`Epinephrine ET`,dose:n.label,route:`ETT`,notes:`0.1 mg/kg (1 mL/kg of 1:10,000) if no IV/IO`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:r.label,route:`IV / IO bolus`,notes:`5 mg/kg for arrest. Max 300 mg. Repeat up to 2 times (max 15 mg/kg/day).`}),(0,l.jsx)(d,{name:`Lidocaine`,dose:i.label,route:`IV / IO bolus`,notes:`1 mg/kg. Alternative to amiodarone for VF/VT.`}),(0,l.jsx)(d,{name:`Atropine`,dose:`${s.label} (min 0.1 mg)`,route:`IV / IO`,notes:`0.02 mg/kg. Bradycardia from ↑vagal tone or AV block.`}),(0,l.jsx)(d,{name:`Adenosine (1st)`,dose:c.label,route:`IV push + flush`,notes:`0.1 mg/kg (max 6 mg). For SVT. Rapid push, double flush.`}),(0,l.jsx)(d,{name:`Adenosine (2nd)`,dose:u.label,route:`IV push + flush`,notes:`0.2 mg/kg (max 12 mg). Second dose if first unsuccessful.`}),(0,l.jsx)(d,{name:`Sodium bicarb 8.4%`,dose:p.label,route:`IV / IO`,notes:`1 mEq/kg. ONLY if severe metabolic acidosis, hyperK, or TCA OD. Not routine.`}),(0,l.jsx)(d,{name:`Calcium chloride 10%`,dose:`${m.label} (${h.label})`,route:`IV / IO (central preferred)`,notes:`For hyperK, hypoCa, Mg OD, CCB OD. 20 mg/kg = 0.2 mL/kg.`}),(0,l.jsx)(d,{name:`Calcium gluconate 10%`,dose:`${g.label} (${_.label})`,route:`IV / IO (peripheral OK)`,notes:`60 mg/kg = 0.6 mL/kg. Preferred peripherally.`}),(0,l.jsx)(d,{name:`Magnesium sulfate`,dose:v.label,route:`IV over 10-20 min`,notes:`25-50 mg/kg. Torsades, severe asthma. Max 2 g.`}),(0,l.jsx)(d,{name:`Dextrose 10%`,dose:`${y.label} (0.2 g/kg)`,route:`IV push`,notes:`For documented hypoglycemia`}),(0,l.jsx)(d,{name:`Defibrillation`,dose:`2 J/kg → 4 J/kg → 10 J/kg (max 10 J/kg or adult dose)`,route:`Pad`,notes:`For VF/pulseless VT. Resume CPR immediately after shock.`}),(0,l.jsx)(d,{name:`Cardioversion (sync)`,dose:`0.5-1 J/kg → 2 J/kg`,route:`Pad`,notes:`For unstable SVT/VT. Sedate if possible.`})]})}function m(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.1,2.5,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`CPR`,dose:`100-120/min, depth 1/3 AP`,route:`—`,notes:`15:2 (2 rescuer) or 30:2 (single). Rotate every 2 min.`}),(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`0.01 mg/kg 1:10,000 = 0.1 mL/kg. Q3-5 min. Start early.`}),(0,l.jsx)(d,{name:`Epinephrine ETT`,dose:t.label,route:`ETT`,notes:`0.1 mg/kg if no IV access`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Reversible causes (H's & T's)`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2 text-xs`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`H's`}),` — Hypoxia, Hypovolemia, H+ (acidosis), Hypo/hyperK, Hypoglycemia, Hypothermia`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`T's`}),` — Tension PTX, Tamponade, Toxins, Thrombosis (MI/PE), Trauma`]})]})]})}function h(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.02,.5,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Bradycardia with poor perfusion (HR < 60)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Start CPR if HR < 60 with poor perfusion despite oxygenation and ventilation.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`First-line. Q3-5 min.`}),(0,l.jsx)(d,{name:`Atropine`,dose:`${t.label} (min 0.1 mg)`,route:`IV / IO`,notes:`If ↑ vagal tone or AV block. Max 1 mg child / 0.5 mg infant.`}),(0,l.jsx)(d,{name:`Transcutaneous pacing`,dose:`—`,route:`Pad`,notes:`For refractory bradycardia not responsive to drugs.`}),(0,l.jsx)(d,{name:`Consider`,dose:`—`,route:`—`,notes:`Hypoxia, tension pneumothorax, ↑ICP, toxic ingestion (organo, CCB, BB), heart block`})]})]})}function g(){if(!a)return null;let e=o(.1,6,`mg`),t=o(.2,12,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`SVT — narrow complex, rate usually >220 infant / >180 child`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Differentiate from sinus tach: abrupt onset/offset, no P waves or abnormal P axis, HR minimally variable.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`If STABLE`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Vagal maneuvers`,dose:`Ice to face, blow into syringe, Valsalva`,route:`—`,notes:`Try first in stable patient`}),(0,l.jsx)(d,{name:`Adenosine (1st)`,dose:e.label,route:`IV push (proximal) + flush`,notes:`Rapid push, 3-way stopcock with NS flush`}),(0,l.jsx)(d,{name:`Adenosine (2nd)`,dose:t.label,route:`IV push + flush`,notes:`If first dose unsuccessful`}),(0,l.jsx)(d,{name:`Procainamide`,dose:`15 mg/kg over 30-60 min`,route:`IV`,notes:`Expert consult. Avoid with amiodarone.`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:`5 mg/kg over 20-60 min`,route:`IV`,notes:`Expert consult.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`If UNSTABLE`}),(0,l.jsx)(f,{children:(0,l.jsx)(d,{name:`Synchronized cardioversion`,dose:`0.5-1 J/kg → 2 J/kg`,route:`Pad`,notes:`Sedate if possible. Pre-treat with adenosine if IV available.`})})]})}function _(){if(!a)return null;let e=o(.01,1,`mg`),t=o(5,300,`mg`),n=o(1,100,`mg`),r=o(50,2e3,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-destructive`,children:`VF / Pulseless VT`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`High-quality CPR + defibrillation are key. Minimize interruptions.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Defibrillation (1st)`,dose:`2 J/kg`,route:`Pad`,notes:`Resume CPR immediately after shock.`}),(0,l.jsx)(d,{name:`Defibrillation (2nd)`,dose:`4 J/kg`,route:`Pad`,notes:`After 2 min CPR.`}),(0,l.jsx)(d,{name:`Defibrillation (3rd+)`,dose:`≥4 J/kg (max 10 J/kg or adult dose)`,route:`Pad`,notes:``}),(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`After 2nd shock. Q3-5 min.`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:t.label,route:`IV / IO bolus`,notes:`Refractory VF/VT. Max 15 mg/kg/day.`}),(0,l.jsx)(d,{name:`Lidocaine`,dose:n.label,route:`IV / IO`,notes:`Alternative to amiodarone. Then 20-50 mcg/kg/min gtt.`}),(0,l.jsx)(d,{name:`Mg sulfate`,dose:r.label,route:`IV over 1-2 min`,notes:`For torsades or hypoMg.`})]})]})}function v(){if(!a)return null;let e=o(5,300,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Stable monomorphic VT`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Expert consult. Avoid combining QT-prolonging agents.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Amiodarone`,dose:`5 mg/kg over 20-60 min = ${e.value} mg over 20-60 min`,route:`IV`,notes:``}),(0,l.jsx)(d,{name:`Procainamide`,dose:`15 mg/kg over 30-60 min`,route:`IV`,notes:`Do not combine with amiodarone`}),(0,l.jsx)(d,{name:`Sync cardioversion`,dose:`0.5-1 → 2 J/kg`,route:`Pad`,notes:`If becomes unstable. Sedate.`})]})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-cardiac`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Cardiac Arrest / PALS`}),(0,l.jsx)(A,{id:`cardiac-wt`,value:e,onChange:t,testid:`cardiac-weight`}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(n===e.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`cardiac-view-`+e.id,children:e.label},e.id))}),a?(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,children:[u.find(e=>e.id===n)?.label,` — `,i,` kg`]}),n===`general`&&(0,l.jsx)(p,{}),n===`asystole`&&(0,l.jsx)(m,{}),n===`brady`&&(0,l.jsx)(h,{}),n===`svt`&&(0,l.jsx)(g,{}),n===`vfib`&&(0,l.jsx)(_,{}),n===`vt`&&(0,l.jsx)(v,{}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Concentrations:`}),` Epi 1:10,000 (0.1 mg/mL) for IV arrest. 1:1000 (1 mg/mL) for IM anaphylaxis. Atropine <0.1 mg can cause paradoxical bradycardia.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AHA PALS Guidelines 2020 · Always verify against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var F={lorazepam:{perKg:.1,max:4,unit:`mg`,route:`IV / IO`,note:`Slow push over 1-2 min.`,suffix:` (IV preferred)`},midazolam:{perKg:.2,max:10,unit:`mg`,route:`IM / IN / buccal`,note:`Use 5 mg/mL concentrate for IN; split between nares.`},diazepam:{perKg:.5,max:20,unit:`mg`,route:`PR`,note:`Only if no IV/IM/IN access.`},levetiracetam:{perKg:60,max:4500,unit:`mg`,route:`IV over 5-15 min`,note:`Best tolerability. No ECG monitoring needed.`,suffix:` (preferred)`},fosphenytoin:{perKg:20,max:1500,unit:`mg PE`,route:`IV over 10 min`,note:`Max rate 3 mg PE/kg/min. Monitor ECG, BP. Avoid if cardiac dysrhythmia.`},valproate:{perKg:40,max:3e3,unit:`mg`,route:`IV over 10 min`,note:`Avoid <2 yr, hepatic / mitochondrial disease, pregnancy.`},phenobarb:{perKg:20,max:1e3,unit:`mg`,route:`IV over 20 min`,note:`Last-choice 2nd line. High risk of resp depression + hypotension.`},midazGttBolus:{perKg:.2,max:10,unit:`mg`},midazGttLow:{perKg:.05,max:2,unit:`mg/hr`},midazGttHigh:{perKg:.5,max:18,unit:`mg/hr`},pentobarbBolus:{perKg:5,max:200,unit:`mg`},pentobarbGttLow:{perKg:1,max:null,unit:`mg/hr`},pentobarbGttHigh:{perKg:5,max:null,unit:`mg/hr`},propofolBolus:{perKg:2,max:100,unit:`mg`},propofolGttLow:{perKg:2,max:null,unit:`mg/hr`},propofolGttHigh:{perKg:5,max:null,unit:`mg/hr`},ketamineBolus:{perKg:2,max:100,unit:`mg`},ketamineGttLow:{perKg:1,max:null,unit:`mg/hr`},ketamineGttHigh:{perKg:5,max:null,unit:`mg/hr`}};function I(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=(e,t,i=`mg`)=>r?s(n,e,t,i):null,a=r?Math.round(n*2*10)/10:0,o=r?Math.round(n*5*10)/10:0;function u({time:e,color:t,title:n,children:r,last:i=!1}){return(0,l.jsxs)(`div`,{className:`flex gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center flex-shrink-0`,children:[(0,l.jsx)(`div`,{className:`w-16 py-1.5 rounded-full text-white text-xs font-bold text-center ${t}`,children:e}),!i&&(0,l.jsx)(`div`,{className:`w-0.5 flex-1 bg-border mt-1`})]}),(0,l.jsxs)(`div`,{className:`flex-1 rounded-r-md border-l-4 p-3 bg-muted/30`,style:{borderLeftColor:`currentColor`},children:[(0,l.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wide mb-2`,children:n}),(0,l.jsx)(`div`,{className:`text-sm space-y-2`,children:r})]})]})}function d({name:e,f:t,route:n,notes:r,suffix:i}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsxs)(`td`,{className:k+` font-semibold`,children:[e,i&&(0,l.jsx)(`span`,{className:`text-xs text-green-700 ml-1`,children:i})]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t.label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-seizure`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Seizures — Status Epilepticus Pathway`}),(0,l.jsx)(A,{id:`seizure-wt`,value:e,onChange:t,testid:`seizure-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsxs)(`div`,{className:`font-bold text-destructive text-sm`,children:[`Status Epilepticus Pathway — `,n,` kg`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Time = 0 at seizure onset. Do not pause between steps for benzo to take effect — act on the clock.`})]}),(0,l.jsxs)(`div`,{className:`space-y-0`,children:[(0,l.jsxs)(u,{time:`0 min`,color:`bg-blue-500 text-white`,title:`Stabilize`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ABCs`}),` — position, 100% O₂ via NC / NRB, suction. `,(0,l.jsx)(`strong`,{children:`IV or IO`}),` × 2. Continuous SpO₂, ECG, BP.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`POC glucose`}),` — if <60 mg/dL: `,(0,l.jsxs)(`strong`,{children:[`D10W `,a,`-`,o,` mL IV`]}),` (2-5 mL/kg).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Labs`}),`: CBC, CMP, Mg, Ca, Phos, VBG, lactate, AED levels, toxicology if unclear etiology.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Consider pyridoxine`}),` 100 mg IV in infants <18 mo or INH ingestion. Temperature: treat hyperthermia aggressively.`]})]}),(0,l.jsx)(u,{time:`5 min`,color:`bg-purple-500 text-white`,title:`1st benzodiazepine (give once, pick by access)`,children:(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsx)(d,{name:`Lorazepam`,f:i(F.lorazepam.perKg,F.lorazepam.max),route:`IV / IO`,notes:`Slow push over 1-2 min.`,suffix:` (IV preferred)`}),(0,l.jsx)(d,{name:`Midazolam`,f:i(F.midazolam.perKg,F.midazolam.max),route:`IM / IN / buccal`,notes:`Use 5 mg/mL concentrate for IN; split between nares.`}),(0,l.jsx)(d,{name:`Diazepam`,f:i(F.diazepam.perKg,F.diazepam.max),route:`PR`,notes:`Only if no IV/IM/IN access.`})]})]})})}),(0,l.jsxs)(u,{time:`10 min`,color:`bg-violet-500 text-white`,title:`2nd benzodiazepine — if still seizing`,children:[`Repeat same agent + dose `,(0,l.jsx)(`strong`,{children:`once`}),`. Prepare 2nd-line now (don't wait to see if benzo works). If apnea/airway compromise: BVM, consider advanced airway.`]}),(0,l.jsx)(u,{time:`20 min`,color:`bg-amber-500 text-white`,title:`2nd-line anti-epileptic — pick one (ESETT: equivalent efficacy)`,children:(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsx)(d,{name:`Levetiracetam`,f:i(F.levetiracetam.perKg,F.levetiracetam.max),route:`IV over 5-15 min`,notes:`Best tolerability. No ECG monitoring needed.`,suffix:` (preferred)`}),(0,l.jsx)(d,{name:`Fosphenytoin`,f:i(F.fosphenytoin.perKg,F.fosphenytoin.max,`mg PE`),route:`IV over 10 min`,notes:`Max rate 3 mg PE/kg/min. Monitor ECG, BP. Avoid if cardiac dysrhythmia.`}),(0,l.jsx)(d,{name:`Valproic acid`,f:i(F.valproate.perKg,F.valproate.max),route:`IV over 10 min`,notes:`Avoid <2 yr, hepatic / mitochondrial disease, pregnancy.`}),(0,l.jsx)(d,{name:`Phenobarbital`,f:i(F.phenobarb.perKg,F.phenobarb.max),route:`IV over 20 min`,notes:`Last-choice 2nd line. High risk of resp depression + hypotension.`})]})]})})}),(0,l.jsxs)(u,{time:`30 min`,color:`bg-red-500 text-white`,title:`Still seizing? Consider 2nd agent from 2nd-line OR proceed to refractory`,children:[`If the first 2nd-line drug failed, give a different 2nd-line agent `,(0,l.jsx)(`strong`,{children:`OR`}),` move directly to refractory therapy. Activate ICU, prepare for intubation. Confirm etiology not reversible (electrolytes, glucose, fever, toxin).`]}),(0,l.jsxs)(u,{time:`40 min`,color:`bg-destructive text-white`,title:`Refractory status — intubate + continuous infusion + continuous EEG`,last:!0,children:[(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsxs)(`td`,{className:k+` font-semibold`,children:[`Midazolam `,(0,l.jsx)(`span`,{className:`text-xs text-green-700`,children:`(1st-line infusion)`})]}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.midazGttBolus.perKg,F.midazGttBolus.max).value,` mg → gtt `,i(F.midazGttLow.perKg,F.midazGttLow.max,`mg/hr`).value,`–`,i(F.midazGttHigh.perKg,F.midazGttHigh.max,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 0.2 mg/kg, gtt 0.05-0.5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Titrate to seizure control / burst suppression.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Pentobarbital`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.pentobarbBolus.perKg,F.pentobarbBolus.max).value,` mg → gtt `,i(F.pentobarbGttLow.perKg,null,`mg/hr`).value,`–`,i(F.pentobarbGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 5 mg/kg, gtt 1-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Causes hypotension — often need pressors.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Propofol`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.propofolBolus.perKg,F.propofolBolus.max).value,` mg → gtt `,i(F.propofolGttLow.perKg,null,`mg/hr`).value,`–`,i(F.propofolGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 2 mg/kg, gtt 2-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsxs)(`td`,{className:k+` text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`PRIS risk in children`}),` — limit to <4 mg/kg/hr and duration <48 h.`]})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ketamine`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.ketamineBolus.perKg,F.ketamineBolus.max).value,` mg → gtt `,i(F.ketamineGttLow.perKg,null,`mg/hr`).value,`–`,i(F.ketamineGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 2 mg/kg, gtt 1-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`NMDA antagonist — rescue. Good BP profile; useful if refractory to GABAergics.`})]})]})]})}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[(0,l.jsx)(`strong`,{children:`Continuous EEG within 1 h`}),` — target electrographic seizure suppression × 24-48 h, then wean. Reassess etiology: CNS imaging, LP, expanded workup.`]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100 space-y-1`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`Key points`}),(0,l.jsxs)(`div`,{children:[`• Do `,(0,l.jsx)(`strong`,{children:`NOT`}),` wait for benzo response before starting the 2nd-line — parallel preparation.`]}),(0,l.jsxs)(`div`,{children:[`• Maximum `,(0,l.jsx)(`strong`,{children:`2 benzo doses`}),` total (1 pre-hospital + 1 in ED, or 2 in ED).`]}),(0,l.jsx)(`div`,{children:`• Respiratory depression is common — have BVM, airway equipment, naloxone, flumazenil accessible (but avoid flumazenil here).`}),(0,l.jsx)(`div`,{children:`• ESETT trial: levetiracetam = fosphenytoin = valproate for efficacy. Pick by tolerability / contraindications.`}),(0,l.jsx)(`div`,{children:`• Always reassess: ongoing seizure? Non-convulsive status? Pseudo-seizure? → continuous EEG if any doubt.`})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Based on AES Guidelines 2016 and ESETT (Kapur et al., NEJM 2019). Verify all doses against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function L(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(``),i=Number.parseFloat(e),a=Number.parseFloat(n),o=Number.isFinite(i)&&i>0,u=(e,t,n=`mg`)=>o?s(i,e,t,n):null,d=Number.isFinite(a)&&a>=0,f=d?Math.round((a/4+4)*2)/2:null,p=d?Math.round((a/4+3.5)*2)/2:null,m=f?Math.round(f*3*10)/10:null,h=d?a<1?`Miller 0-1`:a<2?`Miller 1 / Mac 1`:a<8?`Miller 2 / Mac 2`:`Miller/Mac 3`:`—`,g=o?i<5?`1`:i<10?`1.5`:i<20?`2`:i<30?`2.5`:i<50?`3`:i<70?`4`:`5`:`—`,_=o&&i<10?2:1.5,v=u(6,null,`mL`),y=u(8,null,`mL`);function b({title:e,rows:t}){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:e}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:t.map((e,t)=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e[0]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:e[1]})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e[2]}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e[3]})]},t))})]})})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-airway`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Airway / RSI`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-md`,children:[(0,l.jsx)(A,{id:`airway-wt`,value:e,onChange:t,testid:`airway-weight`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`airway-age`,className:D,children:`Age (years)`}),(0,l.jsx)(`input`,{id:`airway-age`,type:`number`,min:`0`,step:`0.5`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`airway-age`})]})]}),o?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[`RSI doses & equipment — `,i,` kg`,d?`, ~${a} yr`:``]}),(0,l.jsx)(b,{title:`Pre-medication (optional)`,rows:[[`Atropine`,`${u(.02,1,`mg`).label} (min 0.1 mg)`,`IV`,`Consider <1 yr or if using succinylcholine, or bradycardia risk`],[`Lidocaine 2%`,u(1.5,100,`mg`).label,`IV over 1 min`,`For ↑ICP, asthma; give 2-3 min pre-induction`],[`Fentanyl`,`${u(2,150,`mcg`).label} (2-3 mcg/kg)`,`IV over 1 min`,`Blunts sympathetic response; avoid if hypotensive`]]}),(0,l.jsx)(b,{title:`Induction`,rows:[[`Ketamine`,`${u(1.5,150,`mg`).label} (1-2 mg/kg)`,`IV`,`Preserves BP. First-line for shock, asthma, sepsis`],[`Etomidate`,u(.3,30,`mg`).label,`IV`,`Hemodynamically neutral. Avoid in septic shock (adrenal suppression)`],[`Propofol`,`${u(2,200,`mg`).label} (1-2 mg/kg)`,`IV`,`Causes hypotension. Avoid in shock`],[`Midazolam`,u(.2,10,`mg`).label,`IV`,`Less optimal induction — slower onset`]]}),(0,l.jsx)(b,{title:`Paralytics`,rows:[[`Rocuronium`,`${u(1.2,100,`mg`).label} (1-1.2 mg/kg)`,`IV`,`30-60 sec onset; 30-45 min duration. First-line non-depolarizing.`],[`Succinylcholine`,u(_,150,`mg`).label,`IV`,`<10kg: 2 mg/kg; ≥10kg: 1.5 mg/kg. Avoid in burns/crush/hyperK/MH/NM dz. IM option: 4 mg/kg.`],[`Vecuronium`,u(.1,10,`mg`).label,`IV`,`2-3 min onset; longer duration than roc`]]}),(0,l.jsx)(b,{title:`Maintenance sedation / analgesia`,rows:[[`Midazolam gtt`,`${u(.05,2,`mg`).label}–${u(.2,10,`mg`).label}/hr`,`IV infusion`,`0.05-0.2 mg/kg/hr`],[`Fentanyl gtt`,`${u(1,100,`mcg`).label}–${u(4,200,`mcg`).label}/hr`,`IV infusion`,`1-4 mcg/kg/hr`],[`Ketamine gtt`,`${u(.5,30,`mg`).label}–${u(2,100,`mg`).label}/hr`,`IV infusion`,`0.5-2 mg/kg/hr. Good for asthma`],[`Dexmedetomidine gtt`,`0.2-1.4 mcg/kg/hr`,`IV infusion`,`No resp depression; causes bradycardia + hypotension`],[`Rocuronium gtt`,`10-12 mcg/kg/min`,`IV infusion`,`If continued paralysis needed — only with adequate sedation`]]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Equipment sizing`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-xs`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:d?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ETT (uncuffed):`}),` `,f,` mm`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ETT (cuffed):`}),` `,p,` mm`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Depth at lip:`}),` ~`,m,` cm`]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{children:(0,l.jsx)(`em`,{children:`Enter age for ETT / blade sizing.`})}),(0,l.jsx)(`div`,{children:`ETT (uncuffed) = (age/4) + 4`}),(0,l.jsx)(`div`,{children:`ETT (cuffed) = (age/4) + 3.5`}),(0,l.jsx)(`div`,{children:`Depth = ETT size × 3`})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Laryngoscope blade:`}),` `,h]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`LMA size:`}),` `,g]}),(0,l.jsx)(`div`,{children:`OPA = corner mouth → angle mandible`}),(0,l.jsx)(`div`,{children:`NPA = tip nose → tragus`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 md:col-span-2`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Suction catheter (Fr):`}),` ETT size × 2`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`NG tube:`}),` ETT × 2`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Chest tube:`}),` 4 × ETT`]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Ventilator — starting settings`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Mode:`}),` Volume or pressure control`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` 6-8 mL/kg (= `,v.value,`-`,y.value,` mL). Use lower (4-6 mL/kg) for ARDS.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` Infant 25-30, Child 15-25, Adolescent 12-16`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`PEEP:`}),` 5 cmH₂O (↑ for oxygenation problems)`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`FiO₂:`}),` Start 100%, wean to SpO₂ 92-97%`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`I:E ratio:`}),` 1:2 (1:3-4 for obstructive disease)`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook 23rd ed · PALS 2020. Always confirm doses against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function R(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0;function i(e,t,n,r){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}let a=r?[i(`Lorazepam`,s(n,.05,2).label,`PO`,`0.05 mg/kg. May repeat in 30 min.`),i(`Midazolam`,s(n,.5,10).label,`PO`,`0.5 mg/kg (max 10 mg)`),i(`Midazolam`,s(n,.3,10).label,`IN (5 mg/mL)`,`0.3 mg/kg split between nares (max 10 mg)`),i(`Olanzapine (ODT)`,n<30?`2.5-5 mg`:`5-10 mg`,`PO / ODT`,`Age ≥6 yr. Avoid IM + benzo combo (risk of resp depression).`),i(`Diphenhydramine`,s(n,1,50).label,`PO`,`1 mg/kg. Adjunct only; sedating.`)]:null,o=r?[i(`Midazolam`,s(n,.1,5).label,`IV / IM`,`0.05-0.1 mg/kg IV, 0.1-0.15 mg/kg IM (max 10 mg)`),i(`Lorazepam`,s(n,.1,4).label,`IV / IM`,`0.05-0.1 mg/kg (max 4 mg). May cause resp depression.`),i(`Haloperidol`,n<40?`0.025-0.075 mg/kg = ${Math.round(n*.05*100)/100} mg`:`2.5-5 mg`,`IM / IV`,`Avoid <3 yr. Risk: QT, EPS, NMS. ECG if repeated.`),i(`Olanzapine`,n<40?`2.5-5 mg`:`5-10 mg`,`IM`,`Avoid benzo co-administration (resp depression, hypotension)`),i(`Ketamine`,s(n,4,500).label,`IM`,`4-5 mg/kg IM (rescue for severe excited delirium). Monitor airway.`),i(`Droperidol`,`0.03-0.07 mg/kg = ${Math.round(n*.05*100)/100} mg`,`IM / IV`,`Effective but QT concern — get ECG.`)]:null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-agitation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Agitation`}),(0,l.jsx)(A,{id:`agit-wt`,value:e,onChange:t,testid:`agit-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3 text-sm font-semibold text-purple-900 dark:text-purple-100`,children:[`Agitation management — `,n,` kg`]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-green-800 dark:text-green-200`,children:`Step 1 — Non-pharmacologic`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Dim lights, quiet room, familiar caregiver present, reduce stimulation. Rule out hypoglycemia, hypoxia, pain, ↑ICP, toxic ingestion, infection.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`Step 2 — Oral / intranasal (cooperative)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`First-line for moderate agitation if the patient will accept PO/IN.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:a})]})}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Step 3 — IM / IV (severe, uncooperative, or safety risk)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Require continuous monitoring. Consider restraints only as last resort.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:o})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Monitoring:`}),` Continuous SpO₂ + HR after parenteral sedation. Have airway equipment, flumazenil, naloxone, and IV access ready.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Clinical Report on Pediatric Agitation · ACEP Guidelines for Acute Agitation.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function z(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=(e,t,i=`mg`)=>r?s(n,e,t,i):null,a=r?n<15?`2 mg`:n<30?`4 mg`:`8 mg`:null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-antiemetics`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Antiemetics`}),(0,l.jsx)(A,{id:`emet-wt`,value:e,onChange:t,testid:`emet-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[`Antiemetic doses — `,n,` kg`]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ondansetron`}),(0,l.jsxs)(`td`,{className:k+` text-xs`,children:[a,` (weight band) OR `,(0,l.jsx)(j,{label:i(.15,8).label})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / ODT / IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`First-line. Max single 8 mg. Repeat q8h. QT prolongation — avoid with other QT drugs. <6 mo: limited data.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Metoclopramide`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.15,10).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV / IM / PO`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`0.1-0.15 mg/kg (max 10 mg). Give with diphenhydramine to prevent EPS / dystonia.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Dimenhydrinate`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(1.25,50).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM / PR`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`1.25 mg/kg (max 50 mg) q6h. ≥2 yr.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Diphenhydramine`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(1,50).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`1 mg/kg (max 50 mg) q6h. Adjunct, sedating.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Promethazine`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.25,25).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:`0.25-1 mg/kg. CONTRAINDICATED <2 yr (resp depression). Tissue injury if IV extrav.`}})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Dexamethasone`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.15,10).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV / PO`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Adjunct, esp. chemo-induced. 0.15 mg/kg (max 10 mg).`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Scopolamine patch`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`1.5 mg patch`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`Transdermal`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`≥12 yr. Motion sickness. Apply 4h before exposure.`})]})]})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Pearls:`}),` Ondansetron is first-line in ED for acute gastroenteritis vomiting — single PO/ODT dose increases oral rehydration success. Avoid anticholinergics + opioid combinations. Check QTc if stacking ondansetron + other QT drugs.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP gastroenteritis guidance · WHO essential medicines · Lexicomp.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var B={neonate:{sepsis:{first:`Ampicillin + gentamicin`,alt:`Add cefotaxime if meningitis suspected or gram-neg concern`,duration:`7-10 days; 21 days if confirmed meningitis`,notes:`Cover GBS, E. coli, Listeria. Add acyclovir if HSV risk (maternal lesions, vesicles, seizures).`},meningitis:{first:`Ampicillin + cefotaxime (or gentamicin) + acyclovir`,alt:`Add vancomycin if gram-positive cocci`,duration:`14-21 days depending on organism`,notes:`HSV coverage essential. LP + HSV PCR.`},pna:{first:`Ampicillin + gentamicin`,alt:`Add cefotaxime for gram-neg`,duration:`7-10 days`,notes:`Same as sepsis coverage.`},uti:{first:`Ampicillin + gentamicin`,alt:`Cefotaxime if sensitivities known`,duration:`10-14 days`,notes:`Evaluate for sepsis. Renal US and VCUG workup.`},skin:{first:`Ampicillin + gentamicin`,alt:`Add vancomycin if MRSA risk`,duration:`7-10 days`,notes:`Omphalitis, mastitis — broad coverage.`},ent:{first:`Discuss with infectious diseases`,alt:`—`,duration:`—`,notes:`Rare in neonates. Any ear/throat infection warrants sepsis eval.`},neutropenic:{first:`Cefepime or piperacillin-tazobactam`,alt:`Add vancomycin if indwelling line, severe mucositis, or MRSA`,duration:`Until ANC recovery + afebrile ≥48h`,notes:`Oncology/ID consult.`},ic:{first:`Ampicillin + gentamicin + metronidazole`,alt:`Or piperacillin-tazobactam`,duration:`7-14 days`,notes:`NEC: add metronidazole/clindamycin for anaerobes.`},bone:{first:`Ampicillin + gentamicin`,alt:`Vancomycin if MRSA risk`,duration:`3-6 weeks (IV then PO)`,notes:`Usually hematogenous. S. aureus, GBS, E. coli.`}},infant:{sepsis:{first:`Ampicillin + ceftriaxone (or gentamicin)`,alt:`+ vancomycin if MRSA / severe`,duration:`7-10 days`,notes:`Add acyclovir if HSV suspected (<6 wks). Fever in <90 days requires workup.`},meningitis:{first:`Ceftriaxone + vancomycin (± ampicillin if <6 wks for Listeria)`,alt:`+ acyclovir if HSV`,duration:`10-14 days (longer for Listeria/gram-neg)`,notes:`Dexamethasone if H. influenzae suspected.`},pna:{first:`Ampicillin (or ceftriaxone)`,alt:`Add azithromycin if atypical`,duration:`7-10 days`,notes:`S. pneumoniae most common. RSV/viral often primary.`},uti:{first:`Ceftriaxone or cefotaxime`,alt:`Ampicillin + gentamicin`,duration:`10-14 days`,notes:`US kidney/bladder if first febrile UTI.`},skin:{first:`Cefazolin or clindamycin`,alt:`Vancomycin if MRSA risk`,duration:`7-10 days`,notes:`Consider MRSA if purulent or local resistance >10%.`},ent:{first:`Amoxicillin (90 mg/kg/day) for AOM`,alt:`Amox-clav if recent abx/treatment failure`,duration:`AOM 10 days <2 yr; 7 days ≥2 yr`,notes:`Observe mild AOM if >6 mo and no severe features.`},neutropenic:{first:`Cefepime or piperacillin-tazobactam`,alt:`+ vancomycin for severe/mucositis/line`,duration:`Until ANC recovery + afebrile`,notes:`Oncology/ID consult.`},ic:{first:`Ceftriaxone + metronidazole`,alt:`Piperacillin-tazobactam`,duration:`5-7 days (uncomplicated), longer for complicated`,notes:`Appendicitis — surgical consult.`},bone:{first:`Cefazolin ± vancomycin`,alt:`Clindamycin`,duration:`3-4 weeks (IV then PO transition)`,notes:`S. aureus most common. Kingella in <4 yr.`}},child:{sepsis:{first:`Ceftriaxone + vancomycin`,alt:`Piperacillin-tazobactam if intra-abdominal`,duration:`7-14 days`,notes:`Expand if specific source. Add antifungal if prolonged neutropenia.`},meningitis:{first:`Ceftriaxone + vancomycin`,alt:`+ dexamethasone (Hib coverage)`,duration:`10-14 days`,notes:`Lumbar puncture. Dexamethasone 0.15 mg/kg q6h x 4 days.`},pna:{first:`Ampicillin OR amoxicillin (high dose)`,alt:`Ceftriaxone if hospitalized; add azithromycin for atypical`,duration:`5-7 days (uncomplicated)`,notes:`Mycoplasma if >5 yr. Consider viral causes.`},uti:{first:`Cephalexin or TMP-SMX (PO)`,alt:`Ceftriaxone if ill`,duration:`7-10 days (10-14 if pyelo)`,notes:`Culture-guided de-escalation.`},skin:{first:`Cephalexin or clindamycin`,alt:`TMP-SMX or doxycycline if MRSA`,duration:`5-10 days`,notes:`Abscess — incision & drainage primary tx.`},ent:{first:`Amoxicillin 90 mg/kg/day (AOM); Penicillin V for strep pharyngitis`,alt:`Amox-clav; cephalexin if non-anaphylactic PCN allergy`,duration:`AOM 5-10 days; strep 10 days`,notes:`Strep pharyngitis dose: PCN V 250 mg BID-TID (<27 kg) or 500 mg BID (≥27 kg).`},neutropenic:{first:`Cefepime OR piperacillin-tazobactam`,alt:`+ vancomycin`,duration:`Until ANC recovery + afebrile`,notes:`Add empiric antifungal if fever >4-7 days.`},ic:{first:`Ceftriaxone + metronidazole`,alt:`Piperacillin-tazobactam`,duration:`5-7 days (uncomplicated appendicitis)`,notes:`Surgical consult.`},bone:{first:`Cefazolin ± vancomycin`,alt:`Clindamycin`,duration:`3-4 weeks total`,notes:`S. aureus, group A strep. Consider MRSA if severe.`}}},V={neonate:`Neonate (0-28 d)`,infant:`Infant (1-3 mo)`,child:`Child (>3 mo)`},H=[[`sepsis`,`Sepsis / bacteremia`],[`meningitis`,`Meningitis`],[`pna`,`Pneumonia`],[`uti`,`Urinary tract infection`],[`skin`,`Skin / soft tissue`],[`ent`,`Ear / throat (ENT)`],[`neutropenic`,`Febrile neutropenia`],[`ic`,`Intra-abdominal`],[`bone`,`Bone / joint`]];function U(){let[e,t]=(0,c.useState)(`child`),[n,r]=(0,c.useState)(`sepsis`),i=B[e][n];return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-antimicrobials`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Antimicrobials (empirical)`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`abx-age`,className:D,children:`Age band`}),(0,l.jsx)(`select`,{id:`abx-age`,className:E,value:e,onChange:e=>t(e.target.value),"data-testid":`abx-age`,children:Object.entries(V).map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`abx-infection`,className:D,children:`Infection`}),(0,l.jsx)(`select`,{id:`abx-infection`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`abx-infection`,children:H.map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[V[e],` — `,H.find(([e])=>e===n)?.[1]]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{className:`text-green-800 dark:text-green-200`,children:`First-line:`}),` `,i.first]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Alternative / add:`}),` `,i.alt]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Duration:`}),` `,i.duration]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Notes:`}),` `,i.notes]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Red Book · IDSA guidelines · Harriet Lane. Always tailor to local resistance patterns and culture results.`})]})}function W(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=r?Math.round(n*20):null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-trauma`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Trauma — primary survey + MTP`}),(0,l.jsx)(A,{id:`trauma-wt`,value:e,onChange:t,testid:`trauma-weight`}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Primary Survey — ABCDE`}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-destructive`,children:`A — Airway + c-spine`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[`Maintain airway (jaw thrust, suction). `,(0,l.jsx)(`strong`,{children:`Manual inline stabilization`}),`; apply collar. Intubate if GCS ≤8, inadequate airway, or impending compromise. Avoid succinylcholine if burn/crush/prolonged immobilization.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`B — Breathing`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`SpO₂, bilateral breath sounds, chest wall integrity. Identify tension PTX (needle decompression), open PTX (3-sided dressing), flail chest, massive hemothorax.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-green-800 dark:text-green-200`,children:`C — Circulation`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[`Two large-bore IVs / IO. Control hemorrhage (direct pressure, tourniquet, pelvic binder).`,` `,r?(0,l.jsxs)(l.Fragment,{children:[`NS or LR 20 mL/kg = `,(0,l.jsxs)(`strong`,{children:[i,` mL`]}),` bolus.`]}):(0,l.jsx)(l.Fragment,{children:`NS/LR 20 mL/kg bolus.`}),` `,`Consider blood after 40-60 mL/kg crystalloid or in Class III shock.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`D — Disability`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`GCS, pupils, glucose, gross motor. Consider ↑ICP (head up 30°, mannitol 0.5-1 g/kg or hypertonic saline 3% 3-5 mL/kg).`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-violet-500 bg-violet-50 dark:bg-violet-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-violet-800 dark:text-violet-200`,children:`E — Exposure + environment`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Fully expose; prevent hypothermia (warm blankets, fluids).`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Massive Transfusion Protocol (MTP)`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ratio`}),(0,l.jsx)(`td`,{className:k,children:`1:1:1 (pRBC : FFP : platelets)`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`—`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Activate early if ≥40 mL/kg transfused or ongoing hemorrhage. Avoid excessive crystalloid.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Tranexamic acid (TXA)`}),(0,l.jsx)(`td`,{className:k,children:`15 mg/kg IV (max 1 g) over 10 min → 2 mg/kg/hr × 8h`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Within 3 hr of injury. CRASH-2 / MATIC.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Calcium`}),(0,l.jsx)(`td`,{className:k,children:`20 mg/kg CaCl or 60 mg/kg Ca-gluconate IV per unit citrated blood`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Citrated blood chelates calcium.`})]})]})]})}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`C-spine clearance (NEXUS / CCR)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[`Pediatric c-spine decision tools are imperfect. `,(0,l.jsx)(`strong`,{children:`Imaging if any:`}),` focal neurologic deficit, altered mental status, neck pain / tenderness, torticollis, substantial torso injury, high-risk mechanism (diving, MVC >55 mph, fall >10 ft). Plain films + CT if positive or equivocal.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Pediatric shock — signs`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-200`,children:[`Children compensate well — `,(0,l.jsx)(`strong`,{children:`hypotension is a late finding`}),`. Early signs: tachycardia, cool extremities, weak peripheral pulses, prolonged cap refill (>3 sec), narrowed pulse pressure, altered mentation. Minimum SBP = 70 + (2 × age in years) for ages 1-10.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Secondary survey — AMPLE + head-to-toe`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[(0,l.jsx)(`strong`,{children:`AMPLE:`}),` Allergies, Medications, Past history, Last meal, Events of injury. Head-to-toe exam; log-roll for back; digital rectal; neurovascular checks of all extremities.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ATLS 10th ed · PALS 2020 · PECARN c-spine rule · CRASH-2 trial (TXA).`})]})}var G=[{name:`Ketamine IV`,display:`Ketamine`,perKgLow:1.5,perKgHigh:2,maxLow:100,maxHigh:150,unit:`mg`,route:`IV`,onset:`1 min`,duration:`15-30 min`,notes:`Dissociative. Preserves airway reflexes.`},{name:`Ketamine IM`,display:null,perKgLow:4,perKgHigh:5,maxLow:300,maxHigh:400,unit:`mg`,route:`IM`,onset:`3-5 min`,duration:`30-60 min`,notes:`Give atropine 0.01 mg/kg to reduce secretions.`},{name:`Midazolam IV`,display:`Midazolam`,perKgLow:.05,perKgHigh:.1,maxLow:2,maxHigh:5,unit:`mg`,route:`IV`,onset:`2-3 min`,duration:`30-60 min`,notes:`Anxiolysis. Titrate q3-5 min.`},{name:`Midazolam IN/PO`,display:null,perKg:.5,max:20,unit:`mg`,route:`IN/PO`,onset:`10-15 min`,duration:`30-60 min`,notes:`IN (max 10 mg / naris) or PO (max 20 mg).`},{name:`Propofol`,display:`Propofol`,perKg:1,max:40,unit:`mg`,route:`IV`,onset:`30 sec`,duration:`5-10 min`,notes:`Short procedures. Causes apnea — manage airway.`},{name:`Fentanyl IV`,display:`Fentanyl`,perKg:1,max:100,unit:`mcg`,route:`IV`,onset:`2-3 min`,duration:`30-60 min`,notes:`Analgesic. Often combined with midazolam.`},{name:`Fentanyl IN`,display:null,perKg:2,max:100,unit:`mcg`,route:`IN`,onset:`5-10 min`,duration:`30-60 min`,notes:`Intranasal.`},{name:`Nitrous oxide`,display:`Nitrous oxide`,doseDisplay:`50:50 or 70:30 mix`,unit:`mix`,route:`Inhaled`,onset:`2-5 min`,duration:`5 min off`,notes:`Self-administered via demand valve. Anxiolysis + mild analgesia.`},{name:`Dexmedetomidine IN`,display:`Dexmedetomidine`,perKgLow:2,perKgHigh:3,maxLow:100,maxHigh:null,unit:`mcg`,route:`IN`,onset:`15-30 min`,duration:`60-90 min`,notes:`Intranasal. No respiratory depression. Good for imaging.`},{name:`Naloxone`,display:`Naloxone`,perKg:.1,max:2,unit:`mg`,route:`IV/IM/IN`,reverses:`Opioids (fentanyl, morphine)`,notes:`Max 2 mg. Repeat q2-3 min. Duration shorter than opioids — monitor for re-sedation.`},{name:`Flumazenil`,display:`Flumazenil`,perKg:.01,max:.2,unit:`mg`,route:`IV`,reverses:`Benzodiazepines (midazolam)`,notes:`Max 0.2 mg single dose. Repeat q1 min to max 1 mg total. Risk of seizures — use cautiously.`}];function K(e,t){if(t.doseDisplay)return t.doseDisplay;let n=t.unit===`mcg`?` mcg`:t.unit===`mix`?``:` mg`,r=t.unit===`mcg`?`mcg`:`mg`;if(t.perKgLow!=null){let i=s(e,t.perKgLow,t.maxLow??null).value;return t.perKgHigh==null?`${i}${n} (${t.perKgLow} ${r}/kg)`:`${i}-${s(e,t.perKgHigh,t.maxHigh??null).value}${n} (${t.perKgLow}-${t.perKgHigh} ${r}/kg)`}return t.perKg==null?``:`${s(e,t.perKg,t.max??null).value}${n} (${t.perKg} ${r}/kg)`}function q(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=G.filter(e=>!e.reverses),a=G.filter(e=>e.reverses);function o({dg:e}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e.display??``}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:K(n,e)})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.route}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.onset??``}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.duration??``}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.notes})]})}function s({dg:e}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e.display}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:K(n,e)})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.route}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.reverses}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.notes})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-sedation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Procedural Sedation`}),(0,l.jsx)(A,{id:`sed-wt`,value:e,onChange:t,testid:`sed-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3 text-sm font-semibold text-purple-900 dark:text-purple-100`,children:[`Procedural Sedation — `,n,` kg patient`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Sedation Agents`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Onset`}),(0,l.jsx)(`th`,{className:O,children:`Duration`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:i.map(e=>(0,l.jsx)(o,{dg:e},e.name))})]})}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold text-destructive`,children:`Reversal Agents`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{className:`bg-red-50 dark:bg-red-950/30`,children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Reverses`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:a.map(e=>(0,l.jsx)(s,{dg:e},e.name))})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Pre-sedation checklist:`}),` NPO status (2h clear liquids, 6h solids), consent, monitoring equipment (pulse ox, capnography, BP), resuscitation equipment at bedside, suction ready, IV access. Minimum monitoring: continuous SpO₂, HR, capnography. Provider capable of managing airway must be present.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Guidelines for Monitoring and Management of Pediatric Patients Before, During, and After Sedation · ASA Practice Guidelines for Sedation and Analgesia by Non-Anesthesiologists.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var J=[[`approach`,`General approach (stabilize → toxidrome → decon → antidote)`],[`acetaminophen`,`Acetaminophen overdose`],[`opioids`,`Opioid overdose`],[`iron`,`Iron overdose`],[`tca`,`Tricyclic antidepressant (TCA) overdose`],[`bbccb`,`β-blocker / CCB overdose`],[`benzo`,`Benzodiazepine overdose`],[`organo`,`Organophosphate / carbamate poisoning`],[`salicylate`,`Salicylate overdose`],[`etoh`,`Toxic alcohols (methanol / ethylene glycol)`],[`dialyzable`,`Dialyzable drugs (ISTUMBLE)`]];function Y(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`approach`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n).value:null;function u({color:e,title:t,body:n}){return(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 ${e} p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold mb-1`,children:t}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n})]})}function d({drug:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:t}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}function f({children:e}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-toxicology`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Toxicology`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-xl`,children:[(0,l.jsx)(A,{id:`tox-wt`,value:e,onChange:t,testid:`tox-weight`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`tox-topic`,className:D,children:`Topic`}),(0,l.jsx)(`select`,{id:`tox-topic`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`tox-topic`,children:J.map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]})]}),n===`approach`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(u,{color:`border-blue-500 bg-blue-50 dark:bg-blue-950/30`,title:`1. Stabilize (ABCDE)`,body:(0,l.jsx)(l.Fragment,{children:`Airway, breathing, circulation, disability (glucose, pupils, GCS), exposure. Naloxone if depressed LOC + resp depression. Dextrose if hypoglycemic. Thiamine in select cases.`})}),(0,l.jsx)(u,{color:`border-purple-500 bg-purple-50 dark:bg-purple-950/30`,title:`2. Identify toxidrome`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Sympathomimetic:`}),` HTN, tachy, mydriasis, diaphoresis (cocaine, meth). `,(0,l.jsx)(`strong`,{children:`Anticholinergic:`}),` hot/dry, mydriasis, tachy, delirium (antihistamines, TCAs). `,(0,l.jsx)(`strong`,{children:`Cholinergic:`}),` SLUDGE-M, miosis (organophosphates). `,(0,l.jsx)(`strong`,{children:`Opioid:`}),` miosis, resp depression, ↓LOC. `,(0,l.jsx)(`strong`,{children:`Sedative-hypnotic:`}),` ↓LOC, normal/low vitals.`]})}),(0,l.jsx)(u,{color:`border-amber-500 bg-amber-50 dark:bg-amber-950/30`,title:`3. Decontamination`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Activated charcoal`}),` 1 g/kg PO (max 50 g): within 1h of ingestion, intact airway, ingestion adsorbed (not Li, metals, alcohols). Avoid caustics/hydrocarbons. `,(0,l.jsx)(`strong`,{children:`Whole bowel irrigation:`}),` PEG for metals/iron/lithium/sustained release. `,(0,l.jsx)(`strong`,{children:`Gastric lavage:`}),` rarely indicated. `,(0,l.jsx)(`strong`,{children:`Ipecac:`}),` no longer recommended.`]})}),(0,l.jsx)(u,{color:`border-green-500 bg-green-50 dark:bg-green-950/30`,title:`4. Enhance elimination`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Urinary alkalinization`}),` (salicylates, phenobarbital). `,(0,l.jsx)(`strong`,{children:`Hemodialysis`}),` (see ISTUMBLE). `,(0,l.jsx)(`strong`,{children:`Lipid emulsion`}),` for lipid-soluble drug toxicity (LA, CCB, TCA).`]})}),(0,l.jsx)(u,{color:`border-destructive bg-red-50 dark:bg-red-950/30`,title:`5. Antidotes`,body:(0,l.jsxs)(l.Fragment,{children:[`See topic list. `,(0,l.jsx)(`strong`,{children:`Contact Poison Center`}),` (US: 1-800-222-1222) early for any significant exposure.`]})})]}),n===`acetaminophen`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Acetaminophen overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Acute toxic dose: >150 mg/kg (or 7.5 g total) single ingestion. Hepatotoxic after 24h; AST/ALT peak day 3-4.`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`strong`,{children:`Diagnosis:`}),` Draw level at 4h post-ingestion (or on arrival if >4h). Plot on `,(0,l.jsx)(`strong`,{children:`Rumack-Matthew nomogram`}),` (treatment line at 150 mcg/mL at 4h).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`N-acetylcysteine (NAC) — IV`,dose:`150 mg/kg over 1h → 50 mg/kg over 4h → 100 mg/kg over 16h (21h total)`,route:`IV`,notes:`Total 300 mg/kg. Most effective if started <8h post-ingestion.`}),(0,l.jsx)(d,{drug:`N-acetylcysteine — PO`,dose:`140 mg/kg load, then 70 mg/kg q4h × 17 doses`,route:`PO`,notes:`Alternative to IV. Unpleasant taste — often with juice.`}),(0,l.jsx)(d,{drug:`Activated charcoal`,dose:`1 g/kg (max 50 g)`,route:`PO`,notes:`If within 1-2h of ingestion and airway protected.`})]}),a&&(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[(0,l.jsxs)(`strong`,{children:[`For `,i,` kg:`]}),` IV loading = `,o(150,null),` mg over 1h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(150 mg/kg)`}),`; 2nd bag = `,o(50,null),` mg over 4h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(50 mg/kg)`}),`; 3rd bag = `,o(100,null),` mg over 16h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(100 mg/kg)`}),`. `,(0,l.jsx)(`em`,{children:`Total 300 mg/kg.`})]})]}),n===`opioids`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Opioid overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Triad: `,(0,l.jsx)(`strong`,{children:`miosis + respiratory depression + ↓ LOC`}),`. Fentanyl / synthetics may require repeated/higher doses.`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Naloxone (initial)`,dose:a?`0.01-0.1 mg/kg = ${o(.01,null)}-${o(.1,null)} mg`:`0.01-0.1 mg/kg`,route:`IV / IM / IN / IO`,notes:`Start low if chronic opioid use (avoid withdrawal). Titrate to respiratory effort, not consciousness.`}),(0,l.jsx)(d,{drug:`Naloxone (full reversal)`,dose:`2 mg IV/IM/IN`,route:`IV / IM / IN`,notes:`If no chronic use and severe resp depression. Repeat q2-3 min.`}),(0,l.jsx)(d,{drug:`Naloxone infusion`,dose:`2/3 of effective bolus per hour`,route:`IV`,notes:`For long-acting opioids (methadone, fentanyl patch, sustained release)`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[`Observe ≥4h after last dose; longer for long-acting agents. Duration of naloxone (30-90 min) is shorter than most opioids — `,(0,l.jsx)(`strong`,{children:`re-sedation is common`}),`.`]})]}),n===`iron`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Iron overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Toxic dose: elemental Fe ≥20 mg/kg. Severe ≥60 mg/kg. `,(0,l.jsx)(`strong`,{children:`Charcoal does NOT bind iron.`})]}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`strong`,{children:`Stages:`}),` 1) GI (0-6h: vomiting, bloody diarrhea); 2) Latent (6-24h); 3) Shock/metabolic acidosis (12-24h); 4) Hepatotoxicity (2-5d); 5) Gastric scarring (2-8 wk).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Whole bowel irrigation`,dose:`PEG-ES 25-40 mL/kg/hr`,route:`NG`,notes:`For radiopaque pills on KUB or ingested sustained-release iron.`}),(0,l.jsx)(d,{drug:`Deferoxamine`,dose:`15 mg/kg/hr IV infusion`,route:`IV`,notes:`Max 6-8 g/day. Indications: shock, metabolic acidosis, Fe >500 mcg/dL, or severe symptoms. Urine turns 'vin rosé' color.`})]}),(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`Iron level at 4-6h. <350 usually asymptomatic; 350-500 mild; >500 severe. Consider KUB for radiopaque pills.`})]}),n===`tca`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`TCA overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Anticholinergic + Na-channel blockade. `,(0,l.jsx)(`strong`,{children:`Risks:`}),` seizure, VT/VF, hypotension, coma. ECG: QRS >100 ms or R in aVR >3 mm predicts toxicity.`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Sodium bicarbonate 8.4%`,dose:`1-2 mEq/kg IV bolus → infusion`,route:`IV`,notes:`Goal pH 7.45-7.55 and narrowing QRS. Repeat bolus for QRS widening, hypotension, or arrhythmia.`}),(0,l.jsx)(d,{drug:`Mg sulfate`,dose:a?`${o(50,2e3)} mg`:`25-50 mg/kg (max 2 g)`,route:`IV over 10 min`,notes:`For torsades.`}),(0,l.jsx)(d,{drug:`IV lipid emulsion 20%`,dose:`1.5 mL/kg bolus → 0.25 mL/kg/min × 30-60 min`,route:`IV`,notes:`If refractory shock/arrest. Consult toxicology.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Avoid`}),` Class IA/IC antiarrhythmics, beta-blockers, physostigmine (risk of asystole with TCAs).`]})]}),n===`bbccb`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`β-blocker / Calcium-channel blocker overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Bradycardia + hypotension. CCBs (esp. verapamil, diltiazem, amlodipine) can be lethal in small pediatric doses.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`IV fluids`,dose:`20 mL/kg NS bolus`,route:`IV`,notes:`Cautious — avoid volume overload`}),(0,l.jsx)(d,{drug:`Calcium chloride 10% or gluconate`,dose:`CaCl 20 mg/kg / Ca-glu 60 mg/kg`,route:`IV`,notes:`First-line for CCB. Repeat q15-20 min.`}),(0,l.jsx)(d,{drug:`Glucagon`,dose:`50 mcg/kg IV bolus → 50-150 mcg/kg/hr`,route:`IV`,notes:`β-blocker antidote. GI side effects common.`}),(0,l.jsx)(d,{drug:`High-dose insulin (HIE)`,dose:`Regular insulin 1 U/kg bolus → 0.5-2 U/kg/hr + D25% infusion`,route:`IV`,notes:`Hyperinsulinemic euglycemia therapy. Monitor K+ and glucose closely.`}),(0,l.jsx)(d,{drug:`Vasopressors`,dose:`Epi / norepi infusion`,route:`IV`,notes:`Titrate to MAP.`}),(0,l.jsx)(d,{drug:`Lipid emulsion 20%`,dose:`1.5 mL/kg → 0.25 mL/kg/min`,route:`IV`,notes:`For lipid-soluble CCBs (verapamil) if refractory.`}),(0,l.jsx)(d,{drug:`Methylene blue / ECMO`,dose:`—`,route:`—`,notes:`Rescue therapy — toxicology/ICU consult.`})]})]}),n===`benzo`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Benzodiazepine overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Sedation + resp depression. Usually supportive — intubation rarely needed alone. `,(0,l.jsx)(`strong`,{children:`Flumazenil caution.`})]}),(0,l.jsx)(f,{children:(0,l.jsx)(d,{drug:`Flumazenil`,dose:`0.01 mg/kg (max 0.2 mg) IV, may repeat q1 min to max 1 mg`,route:`IV`,notes:`Only for iatrogenic reversal in a benzo-naive patient with no TCAs, seizure disorder, or chronic benzo use. Can precipitate seizures.`})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[`In real-world ingestion, `,(0,l.jsx)(`strong`,{children:`supportive care (airway, monitoring)`}),` is usually safer than flumazenil.`]})]}),n===`organo`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Organophosphate / carbamate poisoning`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Cholinergic toxidrome: `,(0,l.jsx)(`strong`,{children:`SLUDGE-M`}),` (salivation, lacrimation, urination, defecation, GI distress, emesis, miosis) + muscle fasciculation, bradycardia, bronchorrhea. Decontamination critical (PPE for providers).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Atropine`,dose:`0.05 mg/kg IV, double q3-5 min until bronchial secretions dry`,route:`IV`,notes:`Endpoint = dry lungs, not dry mouth or heart rate. Can require huge doses.`}),(0,l.jsx)(d,{drug:`Pralidoxime (2-PAM)`,dose:`25-50 mg/kg IV over 30 min (max 2 g) → 10-20 mg/kg/hr`,route:`IV`,notes:`Only for organophosphates (not carbamates). Regenerates acetylcholinesterase.`}),(0,l.jsx)(d,{drug:`Diazepam / midazolam`,dose:`Standard seizure doses`,route:`IV`,notes:`For seizures or severe fasciculations.`})]})]}),n===`salicylate`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Salicylate overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Mixed respiratory alkalosis + anion gap metabolic acidosis. Tinnitus, tachypnea, diaphoresis, hyperthermia. Severe: CNS depression, seizures, pulmonary edema, cerebral edema.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Fluids`,dose:`Aggressive resuscitation`,route:`IV`,notes:`Dehydration common. Avoid fluid overload (risk of pulmonary edema).`}),(0,l.jsx)(d,{drug:`Sodium bicarb`,dose:`1-2 mEq/kg IV bolus → drip`,route:`IV`,notes:`Urinary alkalinization (goal urine pH >7.5). Prevents CNS entry.`}),(0,l.jsx)(d,{drug:`Glucose`,dose:`Maintain euglycemia even if BG normal`,route:`IV`,notes:`CNS hypoglycemia despite normal serum glucose.`}),(0,l.jsx)(d,{drug:`Hemodialysis`,dose:`—`,route:`—`,notes:`For severe: altered MS, pulmonary edema, renal failure, refractory acidosis, or level >100 mg/dL acute / >60 chronic.`})]})]}),n===`etoh`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Toxic alcohols (methanol / ethylene glycol)`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Anion gap metabolic acidosis + osmolar gap. Methanol → visual changes, blindness. Ethylene glycol → calcium oxalate crystals in urine, renal failure.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Fomepizole`,dose:`15 mg/kg IV load → 10 mg/kg q12h × 4 → 15 mg/kg q12h`,route:`IV`,notes:`First-line. Inhibits alcohol dehydrogenase.`}),(0,l.jsx)(d,{drug:`Ethanol (alternative)`,dose:`Load 600 mg/kg → maintain level 100-150 mg/dL`,route:`IV / PO`,notes:`If fomepizole unavailable. Monitor closely.`}),(0,l.jsx)(d,{drug:`Hemodialysis`,dose:`—`,route:`—`,notes:`For severe acidosis, end-organ damage, or high levels.`}),(0,l.jsx)(d,{drug:`Folate / thiamine / pyridoxine`,dose:`Standard doses`,route:`IV`,notes:`Methanol: folate. EG: thiamine + pyridoxine (divert to non-toxic metabolites).`})]})]}),n===`dialyzable`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Dialyzable drugs (ISTUMBLE)`}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm`,children:[[`I`,`Isopropyl alcohol, INH`],[`S`,`Salicylates`],[`T`,`Theophylline, Toxic alcohols`],[`U`,`Uremia-related drugs`],[`M`,`Methanol, Metformin, Methotrexate`],[`B`,`Barbiturates (long-acting)`],[`L`,`Lithium`],[`E`,`Ethylene glycol`]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsxs)(`strong`,{children:[e,`:`]}),` `,t]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Poor candidates for HD:`}),` Large Vd (TCAs, digoxin, BBs), highly protein-bound (benzos, CCBs), lipid-soluble (opioids, phenothiazines). EXTRIP recommendations are evidence-based — consult toxicology.`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Call Poison Control early: 1-800-222-1222 (US) · Refs: Goldfrank's Toxicologic Emergencies · EXTRIP workgroup.`})]})}function ee(e){switch(e){case`anaphylaxis`:return(0,l.jsx)(N,{});case`cardiac`:return(0,l.jsx)(P,{});case`seizure`:return(0,l.jsx)(I,{});case`airway`:return(0,l.jsx)(L,{});case`agitation`:return(0,l.jsx)(R,{});case`antiemetics`:return(0,l.jsx)(z,{});case`antimicrobials`:return(0,l.jsx)(U,{});case`trauma`:return(0,l.jsx)(W,{});case`sedation`:return(0,l.jsx)(q,{});case`toxicology`:return(0,l.jsx)(Y,{});case`neonatal`:return(0,l.jsx)(v,{});case`respiratory`:return(0,l.jsx)(y,{});case`ventilation`:return(0,l.jsx)(b,{});case`sepsis`:return(0,l.jsx)(x,{});case`burns`:return(0,l.jsx)(w,{});default:return null}}var te=new Set([`anaphylaxis`,`cardiac`,`seizure`,`airway`,`agitation`,`antiemetics`,`antimicrobials`,`trauma`,`sedation`,`toxicology`,`neonatal`,`respiratory`,`ventilation`,`sepsis`,`burns`]),X=`rounded-lg border border-border bg-card p-5 space-y-3`,ne=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,re=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,Z=`block text-xs font-medium text-muted-foreground`,Q=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,$=[{id:`neonatal`,label:`Neonatal`,icon:`👶`,summary:`GA classification, AGA/SGA/LGA, prematurity category (Fenton 2013 / WHO).`},{id:`airway`,label:`Airway / RSI`,icon:`💨`,summary:`ETT size + depth, RSI induction + paralytic dosing by weight.`},{id:`cardiac`,label:`Cardiac Arrest`,icon:`❤️`,summary:`PALS dosing (epinephrine, amiodarone, lidocaine), defibrillation J/kg.`},{id:`respiratory`,label:`Respiratory`,icon:`🫁`,summary:`Asthma, bronchiolitis, croup severity + dosing.`},{id:`ventilation`,label:`O₂ & Ventilation`,icon:`🌀`,summary:`NC / HFNC / CPAP / BiPAP flow + FiO₂ targets by age.`},{id:`seizure`,label:`Seizures`,icon:`🧠`,summary:`Benzodiazepine + second/third-line weight-based dosing.`},{id:`sepsis`,label:`Sepsis & Fever`,icon:`🦠`,summary:`Empirical antibiotics + fluid bolus dosing by weight.`},{id:`anaphylaxis`,label:`Anaphylaxis`,icon:`💉`,summary:`Epinephrine IM, IV infusion, steroid + antihistamine dosing.`},{id:`sedation`,label:`Sedation`,icon:`🛌`,summary:`Procedural sedation regimens — ketamine, propofol, midazolam.`},{id:`agitation`,label:`Agitation`,icon:`😤`,summary:`Weight-based haloperidol, olanzapine, lorazepam.`},{id:`antiemetics`,label:`Antiemetics`,icon:`💊`,summary:`Ondansetron, metoclopramide, promethazine dosing.`},{id:`antimicrobials`,label:`Antimicrobials`,icon:`🧫`,summary:`Common empirical regimens keyed to syndrome + weight.`},{id:`burns`,label:`Burns`,icon:`🔥`,summary:`TBSA % (Lund-Browder, Rule of Nines-children), Parkland fluids.`},{id:`toxicology`,label:`Toxicology`,icon:`☠️`,summary:`Common toxidromes + antidotes + decontamination windows.`},{id:`trauma`,label:`Trauma`,icon:`🩹`,summary:`PECARN, c-spine, blood-product dosing, TXA.`}];function ie(){let[e,t]=(0,c.useState)(``),[n,a]=(0,c.useState)(`apls`),[s,u]=(0,c.useState)(``),d=i(e),f=d==null?null:r(d),p=f?n===`bestguess`?f.all.bestGuess:f.all.apls:null,m=s.trim()||(p==null?``:String(p));function h(){t(``),a(`apls`),u(``)}return(0,l.jsxs)(`section`,{className:X,"data-testid":`bedside-weight-estimator`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Age → Weight Estimator`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Shared starting point for Bedside dosing. Uses the same APLS and Best Guess formulas as the legacy app.`})]}),(0,l.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1.2fr_1fr_1fr_auto] md:items-end`,children:[(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-age`,className:Z,children:`Age`}),(0,l.jsx)(`input`,{id:`bedside-react-age`,value:e,onChange:e=>t(e.target.value),placeholder:`e.g. "18m", "3y", "2y5m"`,className:Q,"data-testid":`bedside-age-input`})]}),(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-formula`,className:Z,children:`Formula`}),(0,l.jsxs)(`select`,{id:`bedside-react-formula`,value:n,onChange:e=>{a(e.target.value),u(``)},className:Q,"data-testid":`bedside-formula-select`,children:[(0,l.jsx)(`option`,{value:`apls`,children:`APLS`}),(0,l.jsx)(`option`,{value:`bestguess`,children:`Best Guess`})]})]}),(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-weight`,className:Z,children:`Weight (kg)`}),(0,l.jsx)(`input`,{id:`bedside-react-weight`,type:`number`,min:`0.3`,step:`0.1`,value:m,onChange:e=>u(e.target.value),className:Q,"data-testid":`bedside-weight-input`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:h,className:re,children:`Clear`})]}),e.trim()&&d==null?(0,l.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,children:`Could not parse age. Try "3y", "18 months", or "15 days".`}):null,f&&p!=null?(0,l.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-4 text-sm`,"data-testid":`bedside-estimate-result`,children:[(0,l.jsxs)(`div`,{className:`font-semibold`,children:[p,` kg estimated from `,o(d??0)]}),(0,l.jsxs)(`div`,{className:`text-muted-foreground`,children:[`APLS: `,f.all.apls,` kg · Best Guess: `,f.all.bestGuess,` kg. You can override the weight field.`]})]}):null]})}function ae({pill:e}){return(0,l.jsxs)(`section`,{className:X,"data-testid":`bedside-panel-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`span`,{className:`text-2xl`,"aria-hidden":!0,children:e.icon}),(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label})]}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary}),(0,l.jsx)(`div`,{className:`rounded-md border border-amber-300 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm space-y-2`,children:(0,l.jsx)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:`Weight-based calculators for this module run in the legacy viewer while the clinical data is verified for a direct React port. Open the legacy Bedside tab to use the full dosing flow.`})}),(0,l.jsx)(`a`,{href:`/#bedside`,className:ne+` inline-block`,children:`Open in legacy viewer`})]})}function oe(){let[e,t]=(0,c.useState)($[0].id),n=$.find(t=>t.id===e)??$[0];return(0,l.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-4`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Bedside`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Emergency and rapid-reference pediatric tools. Weight-based dosing throughout — always verify against institutional protocols.`})]}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`bedside-subnav`,children:$.map(n=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(e===n.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`bedside-pill-`+n.id,children:[(0,l.jsx)(`span`,{className:`mr-1`,"aria-hidden":!0,children:n.icon}),n.label]},n.id))}),(0,l.jsx)(ie,{}),te.has(n.id)?ee(n.id):(0,l.jsx)(ae,{pill:n})]})}export{oe as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,d as i,i as a,l as o,u as s}from"./fenton-BaYL-F22.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,f=`block text-xs font-medium text-muted-foreground`,p=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,m=`px-2 py-1.5 border-b border-border align-top text-sm`;function h({label:e}){let t=e.indexOf(`(`);return t<0?(0,l.jsx)(`span`,{className:`font-semibold`,children:e}):(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`span`,{className:`font-semibold`,children:e.slice(0,t).trim()}),` `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.slice(t)})]})}function g({children:e,notes:t=!0}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:p,children:`Drug`}),(0,l.jsx)(`th`,{className:p,children:`Dose`}),(0,l.jsx)(`th`,{className:p,children:`Route`}),t&&(0,l.jsx)(`th`,{className:p,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}function _({name:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:m+` font-semibold`,dangerouslySetInnerHTML:{__html:e}}),(0,l.jsx)(`td`,{className:m,children:t}),(0,l.jsx)(`td`,{className:m+` text-xs`,children:n}),r!==void 0&&(0,l.jsx)(`td`,{className:m+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}function v(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`0`),[i,o]=(0,c.useState)(``),[s,p]=(0,c.useState)(`male`),[m,v]=(0,c.useState)(``),[y,b]=(0,c.useState)({appearance:2,pulse:2,grimace:2,activity:2,respiration:2}),x=Number.parseInt(e,10),S=Number.parseInt(n,10)||0,C=Number.parseFloat(i),w=Number.isFinite(x)&&x>=22&&x<=44&&Number.isFinite(C)&&C>0?a(x,S,C,s):null,T=Number.parseFloat(m),E=Number.isFinite(T)&&T>0,D=E?Math.round(T*.01*100)/100:0,O=E?Math.round(T*.03*100)/100:0,k=E?Math.round(T*.05*100)/100:0,A=E?Math.round(T*.1*100)/100:0,j=E?Math.round(T*10):0,M=E?Math.round(T*2*10)/10:0,N=Object.values(y).reduce((e,t)=>e+t,0),P=N>=7?`Reassuring`:N>=4?`Moderately depressed`:`Severely depressed`,F=N>=7?`text-green-600 bg-green-50`:N>=4?`text-amber-600 bg-amber-50`:`text-destructive bg-red-50`,I=N>=7?`Routine newborn care. Continue reassessment. Repeat at 5 min.`:N>=4?`Stimulate, clear airway, warm. Give O₂ if cyanotic. Ventilate with PPV if HR <100 or apneic/gasping. Reassess q30 sec.`:`Full NRP pathway — PPV immediately. Intubate if PPV ineffective. Chest compressions if HR <60. Epinephrine and volume per NRP.`;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-neonatal`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Neonatal Assessment + NRP + Apgar`}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Gestational age + size assessment (Fenton 2013)`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-2 sm:grid-cols-4 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`GA weeks`}),(0,l.jsx)(`input`,{type:`number`,min:`22`,max:`44`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`neo-weeks`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`GA days (0-6)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`6`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`neo-days`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Birth wt (g)`}),(0,l.jsx)(`input`,{type:`number`,min:`200`,max:`7000`,className:d,value:i,onChange:e=>o(e.target.value),"data-testid":`neo-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Sex`}),(0,l.jsxs)(`select`,{className:d,value:s,onChange:e=>p(e.target.value),"data-testid":`neo-sex`,children:[(0,l.jsx)(`option`,{value:`male`,children:`Male`}),(0,l.jsx)(`option`,{value:`female`,children:`Female`})]})]})]}),w&&(0,l.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,"data-testid":`neo-result`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.gaClass.color+`55`,background:w.gaClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Gestational Age`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.gaClass.color},children:w.gaClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[x,` wk `,S,` d (`,w.gaDecimal.toFixed(1),` wk)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.weightClass.color+`55`,background:w.weightClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Weight for Gestational Age`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.weightClass.color},children:w.weightClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[w.percentile.toFixed(1),`th percentile · `,w.weightClass.detail]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,style:{borderColor:w.bwClass.color+`55`,background:w.bwClass.color+`10`},children:[(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Birth Weight Category`}),(0,l.jsx)(`div`,{className:`text-base font-bold`,style:{color:w.bwClass.color},children:w.bwClass.label}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[C,` g (`,(C/1e3).toFixed(2),` kg)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/40 p-3 text-xs`,children:[(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:[`Fenton (`,s,`)`]}),(0,l.jsxs)(`div`,{className:`space-y-0.5 mt-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Expected weight (M):`}),` `,w.expectedWeight,` g`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Z-score:`}),` `,w.z.toFixed(2)]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Percentile:`}),` `,w.percentile.toFixed(1),`%`]})]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`NRP pathway (AHA/AAP 8th ed 2020)`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`BIRTH — ASSESS (first 30 sec)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Term? Tone? Breathing/crying? All yes → routine care. Any no → warm, dry, stimulate, clear airway PRN, evaluate HR + resp.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <100 OR apneic/gasping (60 s)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Start PPV`}),` 40-60 breaths/min, room air for term / 21-30% for preterm. Attach SpO₂ (right hand) ± ECG. MR SOPA if ineffective.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <100 after 30 s effective PPV`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Reassess ventilation — ensure chest rise. Consider increasing FiO₂, intubation, or LMA. Continue PPV.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-red-500 bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <60 after 30 s effective PPV`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Intubate + chest compressions`}),` — 3:1 ratio (90 compressions + 30 breaths/min), FiO₂ 100%, lower 1/3 sternum, depth 1/3 AP chest.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-100 dark:bg-red-950/40 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`HR <60 despite compressions + PPV × 60 s`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`Epinephrine 1:10,000 (0.1 mg/mL):`}),` IV/IO 0.01-0.03 mg/kg (0.1-0.3 mL/kg) — preferred. ETT 0.05-0.1 mg/kg. Repeat q3-5 min. Hypovolemia: `,(0,l.jsx)(`strong`,{children:`NS 10 mL/kg IV/IO over 5-10 min`}),`.`]})]})]}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`Target SpO₂ (preductal):`}),(0,l.jsx)(`br`,{}),`1 min 60-65% · 2 min 65-70% · 3 min 70-75% · 4 min 75-80% · 5 min 80-85% · 10 min 85-95%`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`Initial ETT size:`}),(0,l.jsx)(`br`,{}),`<1 kg / <28 wk: 2.5 · 1-2 kg / 28-34 wk: 3.0 · 2-3 kg / 34-38 wk: 3.5 · >3 kg / >38 wk: 3.5-4.0`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`ETT depth (lip):`}),` ~6 + weight(kg) cm`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`NRP drug doses`}),(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:m,onChange:e=>v(e.target.value),"data-testid":`nrp-weight`})]}),E?(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Epinephrine 1:10,000`,dose:(0,l.jsx)(h,{label:`${D}-${O} mg, ${Math.round(D*10)/10}-${Math.round(O*10)/10} mL (0.01-0.03 mg/kg = 0.1-0.3 mL/kg)`}),route:`IV / IO`,notes:`Preferred route. Repeat q3-5 min.`}),(0,l.jsx)(_,{name:`Epinephrine 1:10,000`,dose:(0,l.jsx)(h,{label:`${k}-${A} mg, ${Math.round(k*10)/10}-${Math.round(A*10)/10} mL (0.05-0.1 mg/kg = 0.5-1 mL/kg)`}),route:`ETT`,notes:`While IV being placed.`}),(0,l.jsx)(_,{name:`Normal saline`,dose:(0,l.jsx)(h,{label:`${j} mL (10 mL/kg)`}),route:`IV / IO`,notes:`Over 5-10 min for volume. Repeat PRN.`}),(0,l.jsx)(_,{name:`Dextrose 10%`,dose:(0,l.jsx)(h,{label:`${M} mL (2 mL/kg = 0.2 g/kg)`}),route:`IV slow push`,notes:`For documented hypoglycemia. Then D10 infusion 4-6 mg/kg/min.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see NRP doses.`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Concentration note:`}),` NRP uses epinephrine `,(0,l.jsx)(`strong`,{children:`1:10,000`}),` (0.1 mg/mL). NOT 1:1000 (1 mg/mL) — that is IM for anaphylaxis / older patients.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Apgar score`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-5 text-xs`,children:[[`appearance`,`Appearance`,[`Blue/pale`,`Body pink, extremities blue`,`All pink`]],[`pulse`,`Pulse`,[`Absent`,`<100 bpm`,`≥100 bpm`]],[`grimace`,`Grimace`,[`No response`,`Grimace`,`Cough/sneeze`]],[`activity`,`Activity`,[`Limp`,`Some flexion`,`Active motion`]],[`respiration`,`Respiration`,[`Absent`,`Slow/irregular`,`Good/crying`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:y[e],onChange:t=>b({...y,[e]:Number(t.target.value)}),"data-testid":`apgar-`+e,children:n.map((e,t)=>(0,l.jsxs)(`option`,{value:t,children:[t,` — `,e]},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+F,"data-testid":`apgar-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`Apgar: `,N,`/10 — `,P]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:I})]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground italic`,children:[`Fenton TR, Kim JH. BMC Pediatr 2013;13:59 · NRP 8th ed (AHA/AAP 2020) · Apgar is a description of status — `,(0,l.jsx)(`strong`,{children:`never`}),` delay resuscitation while scoring.`]})]})}function y(){let[e,t]=(0,c.useState)(`asthma`),[n,r]=(0,c.useState)(``),i=Number.parseFloat(n),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,[p,m]=(0,c.useState)(null),[v,y]=(0,c.useState)({spo2:0,retractions:0,scalene:0,air:0,wheeze:0}),b=Object.values(v).reduce((e,t)=>e+t,0),x=b<=3?`Mild`:b<=7?`Moderate`:`Severe`,S=b<=3?`text-green-600 bg-green-50`:b<=7?`text-amber-600 bg-amber-50`:`text-destructive bg-red-50`,[C,w]=(0,c.useState)({conscious:0,cyanosis:0,stridor:0,air:0,retractions:0}),T=Object.values(C).reduce((e,t)=>e+t,0),E=T<=2?`Mild`:T<=5?`Moderate`:T<=11?`Severe`:`Impending Respiratory Failure`,D=T<=2?`text-green-600 bg-green-50`:T<=5?`text-amber-600 bg-amber-50`:T<=11?`text-destructive bg-red-50`:`text-red-900 bg-red-100`,[O,k]=(0,c.useState)({age:`gte12w`,spo2:`ok`,hydration:`ok`,distress:`mild`}),A=O.distress===`severe`||O.spo2===`low`||O.hydration===`poor`||O.age===`lt12w`;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-respiratory`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Respiratory`}),(0,l.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:[`asthma`,`pram`,`croup`,`bronch`].map(n=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:`px-3 py-1 rounded-full text-xs font-medium border `+(e===n?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),"data-testid":`resp-mode-`+n,children:n===`asthma`?`Asthma`:n===`pram`?`PRAM`:n===`croup`?`Croup (Westley)`:`Bronchiolitis`},n))}),e!==`pram`&&e!==`bronch`&&(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`resp-weight`})]}),e===`asthma`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`flex gap-2`,children:[`mild`,`moderate`,`severe`].map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`px-3 py-1 rounded text-xs font-medium border `+(p===e?e===`mild`?`bg-green-600 text-white`:e===`moderate`?`bg-amber-500 text-white`:`bg-destructive text-white`:`bg-muted`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),p&&!a&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`}),p===`mild`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in sentences, no accessory muscle use, SpO₂ ≥94%`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol (MDI)`,dose:`4-8 puffs via spacer`,route:`Inhaled`,notes:`q20min × 3 doses, then q1-4h`}),(0,l.jsx)(_,{name:`Albuterol (neb)`,dose:(0,l.jsx)(h,{label:`${o(.15,5,`mg`).label} (min 2.5 mg)`}),route:`Nebulized`,notes:`q20min × 3 doses`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`PO/IV`,notes:`Single dose, or 2 days`}),(0,l.jsx)(_,{name:`Prednisolone`,dose:(0,l.jsx)(h,{label:`${o(1,60).label}/day`}),route:`PO`,notes:`Alternative: 3-5 day course`})]})]}),p===`moderate`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in phrases, some accessory muscle use, SpO₂ 90-93%`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol (neb)`,dose:(0,l.jsx)(h,{label:`${o(.15,5,`mg`).label} (min 2.5 mg)`}),route:`Nebulized`,notes:`q20min × 3 doses, then continuous if needed`}),(0,l.jsx)(_,{name:`Ipratropium`,dose:i<20?`250 mcg`:`500 mcg`,route:`Nebulized`,notes:`q20min × 3 doses with albuterol`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`PO/IV/IM`,notes:`Single dose`}),(0,l.jsx)(_,{name:`O₂ supplemental`,dose:`Target SpO₂ ≥94%`,route:`NC/mask`,notes:`Titrate to effect`})]})]}),p===`severe`&&a&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Speaks in words only, significant accessory muscle use, SpO₂ <90%. Consider ICU.`}),(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Albuterol continuous`,dose:(0,l.jsx)(h,{label:`${o(.5,20,`mg`).label}/hr`}),route:`Continuous neb`,notes:`Or 0.15-0.3 mg/kg q20min`}),(0,l.jsx)(_,{name:`Ipratropium`,dose:i<20?`250 mcg`:`500 mcg`,route:`Nebulized`,notes:`q20min × 3 doses with albuterol`}),(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:`IV`,notes:`Or methylprednisolone 2 mg/kg IV (max 60 mg)`}),(0,l.jsx)(_,{name:`Magnesium sulfate`,dose:(0,l.jsx)(h,{label:`${o(50,2e3).label} IV over 20 min`}),route:`IV`,notes:`Single dose, monitor BP`}),(0,l.jsx)(_,{name:`Epinephrine (IM)`,dose:(0,l.jsx)(h,{label:`${o(.01,.5).label} (1:1000)`}),route:`IM`,notes:`If impending arrest / no IV access`}),(0,l.jsx)(_,{name:`Terbutaline`,dose:(0,l.jsx)(h,{label:`${o(.01,.4).label} SC/IV`}),route:`SC/IV`,notes:`Then 0.1-10 mcg/kg/min infusion`}),(0,l.jsx)(_,{name:`O₂ supplemental`,dose:`Target SpO₂ ≥94%`,route:`High flow / NIPPV`,notes:`Consider BiPAP/CPAP`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-100`,children:[(0,l.jsx)(`strong`,{children:`Continuous monitoring.`}),` Consider ICU admission. If no response to magnesium → terbutaline infusion. If impending respiratory failure → intubation (ketamine preferred induction agent).`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`NAEPP/GINA guidelines. Always use clinical judgment.`})]}),e===`pram`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric Respiratory Assessment Measure (PRAM) — for asthma exacerbation severity (0-12).`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2`,children:[[`spo2`,`SpO₂`,[`≥95% (0)`,`92-94% (1)`,`<92% (2)`]],[`retractions`,`Suprasternal retractions`,[`Absent (0)`,`Present (2)`]],[`scalene`,`Scalene muscle use`,[`Absent (0)`,`Present (2)`]],[`air`,`Air entry`,[`Normal (0)`,`Mild ↓ at bases (1)`,`Widespread ↓ (2)`,`Absent/minimal (3)`]],[`wheeze`,`Wheezing`,[`Absent (0)`,`Expiratory only (1)`,`Ins+exp (2)`,`Audible without stethoscope/silent chest (3)`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:v[e],onChange:t=>y({...v,[e]:Number(t.target.value)}),"data-testid":`pram-`+e,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:t,children:e},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+S,"data-testid":`pram-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`PRAM Score: `,b,`/12 — `,x]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Mild (0-3): outpatient management. Moderate (4-7): consider oral steroids + frequent bronchodilators. Severe (8-12): aggressive treatment, consider ICU.`})]})]}),e===`croup`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Westley croup score (0-17).`}),(0,l.jsx)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2`,children:[[`conscious`,`Level of consciousness`,[`Normal (0)`,`Disoriented (5)`]],[`cyanosis`,`Cyanosis`,[`None (0)`,`With agitation (4)`,`At rest (5)`]],[`stridor`,`Stridor`,[`None (0)`,`With agitation (1)`,`At rest (2)`]],[`air`,`Air entry`,[`Normal (0)`,`Decreased (1)`,`Severely decreased (2)`]],[`retractions`,`Retractions`,[`None (0)`,`Mild (1)`,`Moderate (2)`,`Severe (3)`]]].map(([e,t,n])=>(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:t}),(0,l.jsx)(`select`,{className:d,value:C[e],onChange:t=>w({...C,[e]:Number(t.target.value)}),"data-testid":`croup-`+e,children:n.map((e,t)=>(0,l.jsx)(`option`,{value:t,children:e},t))})]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+D,"data-testid":`croup-result`,children:[(0,l.jsxs)(`div`,{className:`text-base font-bold`,children:[`Westley: `,T,`/17 — `,E]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Mild ≤2 · Moderate 3-5 · Severe 6-11 · Impending failure ≥12.`})]}),a&&(0,l.jsxs)(g,{children:[(0,l.jsx)(_,{name:`Dexamethasone`,dose:(0,l.jsx)(h,{label:o(.6,16).label}),route:T<=2?`PO`:T<=5?`PO/IM`:`IV/IM`,notes:`Preferred corticosteroid; single dose`}),T>2&&(0,l.jsx)(_,{name:`Racemic epinephrine`,dose:`0.5 mL of 2.25% solution`,route:`Nebulized`,notes:`May repeat q15-20min, observe 2-4 h`}),T>2&&(0,l.jsx)(_,{name:`Nebulized epinephrine`,dose:`0.5 mL/kg of 1:1000 (max 5 mL)`,route:`Nebulized`,notes:`Alternative to racemic`}),T>5&&(0,l.jsx)(_,{name:`Heliox`,dose:`70:30 or 80:20`,route:`Face mask`,notes:`Consider if not responding`})]})]}),e===`bronch`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age`}),(0,l.jsxs)(`select`,{className:d,value:O.age,onChange:e=>k({...O,age:e.target.value}),children:[(0,l.jsx)(`option`,{value:`lt12w`,children:`<12 weeks (high risk)`}),(0,l.jsx)(`option`,{value:`gte12w`,children:`≥12 weeks`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`SpO₂`}),(0,l.jsxs)(`select`,{className:d,value:O.spo2,onChange:e=>k({...O,spo2:e.target.value}),children:[(0,l.jsx)(`option`,{value:`ok`,children:`≥90%`}),(0,l.jsx)(`option`,{value:`low`,children:`<90%`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Hydration`}),(0,l.jsxs)(`select`,{className:d,value:O.hydration,onChange:e=>k({...O,hydration:e.target.value}),children:[(0,l.jsx)(`option`,{value:`ok`,children:`Adequate`}),(0,l.jsx)(`option`,{value:`poor`,children:`Poor oral intake`})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Distress`}),(0,l.jsxs)(`select`,{className:d,value:O.distress,onChange:e=>k({...O,distress:e.target.value}),children:[(0,l.jsx)(`option`,{value:`mild`,children:`Mild`}),(0,l.jsx)(`option`,{value:`moderate`,children:`Moderate`}),(0,l.jsx)(`option`,{value:`severe`,children:`Severe`})]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md p-3 `+(A?`text-destructive bg-red-50`:`text-green-600 bg-green-50`),"data-testid":`bronch-result`,children:[(0,l.jsx)(`div`,{className:`text-base font-bold`,children:A?`Admit / Observe`:`Likely Safe for Discharge`}),O.age===`lt12w`&&(0,l.jsx)(`div`,{className:`text-xs text-destructive mt-1`,children:`⚠ Age <12 weeks — high risk for apnea. Monitor closely.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`NOT recommended (AAP 2014/2023):`}),` Albuterol/salbutamol (no benefit), epinephrine (no evidence), systemic corticosteroids (no benefit), antibiotics (unless bacterial co-infection), chest physiotherapy.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Clinical Practice Guideline: Management of Bronchiolitis in Infants and Children (2014, reaffirmed 2023). RSV most common (50-80%).`})]})]})}function b(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(``),i=Number.parseFloat(e),a=Number.parseFloat(n),o=Number.isFinite(i)&&i>0,s=o?Math.round(i*1*10)/10:0,p=o?Math.round(i*2*10)/10:0,m=o?Math.round(i*6*10)/10:0,h=o?Math.round(i*8*10)/10:0,v=Number.isFinite(a)&&a>=0?a<.1?`30-40`:a<1?`25-35`:a<5?`20-25`:a<12?`16-20`:`12-16`:``;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-ventilation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`O₂ & Ventilation`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-2 max-w-md`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`vent-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age (years)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,step:`0.5`,className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`vent-age`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Target SpO₂`}),(0,l.jsxs)(g,{notes:!0,children:[(0,l.jsx)(_,{name:`Most children`,dose:`94-98%`,route:`—`,notes:`Normal`}),(0,l.jsx)(_,{name:`Bronchiolitis (AAP 2014/2023)`,dose:`≥90%`,route:`—`,notes:`Don't chase higher saturations`}),(0,l.jsx)(_,{name:`Chronic lung disease / CF`,dose:`90-94%`,route:`—`,notes:`Avoid hyperoxia in CO₂ retainers`}),(0,l.jsx)(_,{name:`Preterm neonate`,dose:`90-95%`,route:`—`,notes:`Minimize ROP risk`}),(0,l.jsx)(_,{name:`Term neonate (min of life)`,dose:`Per NRP ladder`,route:`—`,notes:`1 min 60-65% · 10 min 85-95%`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Escalation ladder`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`1. Nasal cannula (low-flow)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`0.5-6 L/min`}),` · FiO₂ ~24-40% · comfortable, no humidification. Good for mild hypoxia.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`2. Simple face mask`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`6-10 L/min`}),` · FiO₂ 35-60%. Must keep flow >6 L/min to flush CO₂.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`3. Non-rebreather mask`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`10-15 L/min`}),` · FiO₂ 60-90%. Reservoir bag must stay inflated.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`4. High-flow nasal cannula (HFNC)`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:o?`1-2 L/kg/min = ${s}-${p} L/min`:`1-2 L/kg/min`}),` · heated + humidified · FiO₂ 30-100% titratable · generates ~2-5 cmH₂O PEEP. Reassess at 1-2 h.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-red-500 bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`5. Non-invasive (CPAP / BiPAP)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`CPAP 5-10 cmH₂O · BiPAP IPAP 10-14 / EPAP 5. Needs cooperative patient, intact airway reflexes, no copious secretions.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-100 dark:bg-red-950/40 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`6. Intubate + mechanical ventilation`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`When NIV fails, airway compromised, apnea, or GCS ≤8. See Airway tab for RSI drugs.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Bag-Valve-Mask (BVM)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`When:`}),` apnea, bradycardia (HR <60 neonate; inadequate breathing at any age), during resuscitation.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` Newborn 40-60/min · Infant-child 20-30/min · Adolescent 10-12/min (1 breath q5-6 sec).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` 6-8 mL/kg — gentle chest rise only. Avoid over-ventilation.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Technique:`}),` head tilt / jaw thrust, E-C or 2-thumb mask seal, squeeze 1 sec, release fully.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Not ventilating?`}),` MR SOPA — Mask reseal, Reposition airway, Suction, Open mouth, Pressure ↑, Alternative airway.`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Mechanical vent — starting settings`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Mode:`}),` Volume-control OR Pressure-control. PRVC / SIMV-PS hybrids.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` `,(0,l.jsx)(`strong`,{children:o?`${m}-${h} mL`:`6-8 mL/kg`}),` (6-8 mL/kg). Use 4-6 mL/kg for ARDS.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` `,v?`${v}/min (age ${a} yr)`:`Newborn 30-40 · Infant 25-35 · Child 16-20 · Adolescent 12-16`,`.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`PEEP:`}),` start 5 cmH₂O. Increase to 8-12+ for refractory hypoxia.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`FiO₂:`}),` start 100%, wean rapidly to lowest that maintains target SpO₂.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`I:E ratio:`}),` 1:2 normally; 1:3-4 for obstructive disease.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Plateau pressure:`}),` keep <30 cmH₂O (ideally <28).`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Adjusting for gas exchange`}),(0,l.jsxs)(g,{notes:!0,children:[(0,l.jsx)(_,{name:`Low SpO₂ (oxygenation)`,dose:`↑ FiO₂`,route:`—`,notes:`Then ↑ PEEP (recruits collapsed alveoli)`}),(0,l.jsx)(_,{name:`↑ PCO₂ (ventilation)`,dose:`↑ Rate`,route:`—`,notes:`Then ↑ Tidal volume`}),(0,l.jsx)(_,{name:`↓ PCO₂ (over-ventilating)`,dose:`↓ Rate`,route:`—`,notes:`Then ↓ Tidal volume`}),(0,l.jsx)(_,{name:`High peak pressure`,dose:`Check tube / compliance`,route:`—`,notes:`Suction, bronchodilator, lower TV`}),(0,l.jsx)(_,{name:`Auto-PEEP (asthma, bronch)`,dose:`↓ Rate, ↑ Te`,route:`—`,notes:`Disconnect + bag briefly if critical`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-xs text-green-900 dark:text-green-100`,children:[(0,l.jsx)(`strong`,{children:`Mental model:`}),` Oxygenation is mostly `,(0,l.jsx)(`strong`,{children:`FiO₂ + PEEP`}),`. Ventilation (CO₂) is mostly `,(0,l.jsx)(`strong`,{children:`rate + tidal volume`}),`. Obstructive (asthma, bronchiolitis) → long expiratory time, permissive hypercapnia. Restrictive (ARDS) → low TV, high PEEP, permissive hypercapnia + hypoxia.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP / PALS / AARC guidance.`})]})}function x(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`child`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,p=n===`neonate`?`Neonate (0-28 d)`:n===`infant`?`Young infant (29 d - 3 mo)`:`Older child / adolescent`,m=a?Math.round(i*20):null;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-sepsis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Sepsis & Fever`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-2 max-w-md`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`sepsis-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age band`}),(0,l.jsxs)(`select`,{className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`sepsis-age`,children:[(0,l.jsx)(`option`,{value:`neonate`,children:`Neonate (0-28 d)`}),(0,l.jsx)(`option`,{value:`infant`,children:`Infant (29 d - 3 mo)`}),(0,l.jsx)(`option`,{value:`child`,children:`Older child / adolescent`})]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,children:[`Sepsis approach — `,p,a?`, ${i} kg`:``]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Definition — Phoenix Sepsis Criteria (JAMA 2024)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Sepsis`}),` = suspected or confirmed infection + Phoenix Score ≥2 (organ dysfunction across respiratory, cardiovascular, coagulation, neurological).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Septic shock`}),` = sepsis + cardiovascular dysfunction (vasoactive support, or ↑lactate ≥5, or ↓MAP for age).`]}),(0,l.jsx)(`div`,{className:`text-muted-foreground italic`,children:`Previous SIRS-based criteria (Goldstein 2005) are now superseded.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Red flags`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-100`,children:[`Abnormal behavior / mentation · Fever + ill-appearance · Tachycardia out of proportion to fever · Prolonged cap refill (>3 s) · Cold/mottled extremities · Weak pulses or wide pulse pressure ("warm shock") · Hypotension is a `,(0,l.jsx)(`strong`,{children:`LATE`}),` sign · Any immune compromise / indwelling line.`]}),(0,l.jsxs)(`h3`,{className:`text-sm font-semibold mt-2`,children:[`Empirical therapy — `,p]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[n===`neonate`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Workup (full sepsis eval):`}),` CBC+diff, CRP, blood culture, UA+urine culture (cath), `,(0,l.jsx)(`strong`,{children:`LP`}),` (CSF+HSV PCR), CXR if respiratory sx, procalcitonin. `,(0,l.jsx)(`strong`,{children:`Early-onset`}),` (<72 h): GBS, E. coli, Listeria. `,(0,l.jsx)(`strong`,{children:`Late-onset`}),` (>72 h): CoNS, S. aureus, gram-negs, Candida.`]}),n===`infant`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Workup:`}),` Use validated rules — PECARN, Aronson, Rochester, Step-by-Step. CBC+ANC, procalcitonin/CRP, blood culture, UA+urine culture. Many warrant LP + admission + empiric abx. `,(0,l.jsx)(`strong`,{children:`Coverage:`}),` GBS, E. coli, Listeria (up to ~6 wk), S. pneumo, N. meningitidis, H. flu, Salmonella.`]}),n===`child`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Recognition:`}),` Phoenix score or clinical concern + suspected infection. `,(0,l.jsx)(`strong`,{children:`Workup:`}),` CBC, CRP, procalcitonin, blood cx (+site-specific), lactate, blood gas, glucose, electrolytes, coags, LP if CNS concern. Source-directed imaging.`]})]}),a&&(0,l.jsxs)(g,{children:[n===`neonate`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ampicillin`,dose:(0,l.jsx)(h,{label:o(100,2e3).label}),route:`IV`,notes:`q8-12h. Covers GBS, Listeria, Enterococcus.`}),(0,l.jsx)(_,{name:`Gentamicin`,dose:(0,l.jsx)(h,{label:o(4,120).label}),route:`IV`,notes:`q24-48h. Monitor levels.`}),(0,l.jsx)(_,{name:`Cefotaxime (add)`,dose:(0,l.jsx)(h,{label:o(50,2e3).label}),route:`IV`,notes:`If meningitis or gram-neg concern.`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`HSV risk: maternal lesions, vesicles, seizures, CSF pleocytosis.`})]}),n===`infant`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ceftriaxone`,dose:(0,l.jsx)(h,{label:o(75,2e3).label}),route:`IV / IM`,notes:`q24h (100 mg/kg/day divided q12h for meningitis). Avoid <28 d if hyperbilirubinemia.`}),(0,l.jsx)(_,{name:`Ampicillin`,dose:(0,l.jsx)(h,{label:o(100,2e3).label}),route:`IV`,notes:`If <6 wk: add for Listeria coverage.`}),(0,l.jsx)(_,{name:`Vancomycin`,dose:(0,l.jsx)(h,{label:o(15,1e3).label}),route:`IV`,notes:`If severe / MRSA risk / meningitis.`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`<6 wk with suspicion of HSV.`})]}),n===`child`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{name:`Ceftriaxone`,dose:(0,l.jsx)(h,{label:o(50,2e3).label}),route:`IV`,notes:`q24h (100 mg/kg/day divided for meningitis).`}),(0,l.jsx)(_,{name:`Vancomycin`,dose:(0,l.jsx)(h,{label:o(15,1e3).label}),route:`IV`,notes:`q6h. If severe, indwelling line, or MRSA prevalence >10%.`}),(0,l.jsx)(_,{name:`Piperacillin-tazobactam`,dose:(0,l.jsx)(h,{label:o(100,4500).label}),route:`IV`,notes:`If intra-abdominal / neutropenic.`}),(0,l.jsx)(_,{name:`Clindamycin`,dose:(0,l.jsx)(h,{label:o(10,900).label}),route:`IV`,notes:`Adjunct for toxic shock syndrome (toxin suppression).`}),(0,l.jsx)(_,{name:`Acyclovir`,dose:(0,l.jsx)(h,{label:o(20,1200).label}),route:`IV q8h`,notes:`If HSV CNS concern.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`First-hour bundle (SSC Peds 2020)`}),(0,l.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`0-5 min — Recognize`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Screen, sepsis huddle/activation, ABCs, O₂ to SpO₂ >94%, warm.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`5-15 min — Access & labs`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Two IVs or IO. Draw blood cx (ideally before abx), lactate, CBC, CMP, coags, blood gas, glucose. UA + culture. Source-specific cultures.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`15-30 min — Fluids`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[a?(0,l.jsxs)(l.Fragment,{children:[`NS or LR `,(0,l.jsxs)(`strong`,{children:[m,` mL`]}),` bolus (20 mL/kg) over 5-10 min.`]}):(0,l.jsx)(l.Fragment,{children:`NS/LR 10-20 mL/kg bolus over 5-10 min.`}),` Reassess HR, perfusion, lungs, liver. Repeat up to 40-60 mL/kg; stop if crackles/hepatomegaly.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`30-60 min — Antibiotics + reassess`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Broad-spectrum empiric abx within 1 hour (≤1 h in septic shock). Recheck lactate, perfusion.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`>60 min — Fluid-refractory shock`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Start vasoactive (`,(0,l.jsx)(`strong`,{children:`epinephrine 0.05-0.3 mcg/kg/min`}),` cold / `,(0,l.jsx)(`strong`,{children:`norepinephrine 0.05-0.3 mcg/kg/min`}),` warm). Central/IO access. Stress-dose hydrocortisone `,a?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`strong`,{children:[o(2,100).value,` mg`]}),` IV (2 mg/kg, max 100 mg)`]}):`2 mg/kg IV (max 100 mg)`,` if catecholamine-resistant. ICU.`]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Resuscitation targets`}),(0,l.jsx)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:`Normal mentation · Cap refill ≤2 s · Warm extremities · Strong peripheral pulses · UOP ≥1 mL/kg/hr · MAP ≥5th %ile for age (>65 mmHg adolescent) · SpO₂ ≥94% · Lactate trending down.`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Phoenix Sepsis Criteria (Schlapbach et al., JAMA 2024) · Surviving Sepsis Campaign Pediatric 2020 · AAP pediatric sepsis guidance.`})]})}var S=[{key:`head`,label:`Head`,vals:[18,13,11,9,7],ageSensitive:!0},{key:`neck`,label:`Neck`,vals:[2,2,2,2,2]},{key:`ant_trunk`,label:`Anterior trunk`,vals:[13,13,13,13,13]},{key:`post_trunk`,label:`Posterior trunk`,vals:[13,13,13,13,13]},{key:`r_buttock`,label:`Right buttock`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`l_buttock`,label:`Left buttock`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`genital`,label:`Genitalia`,vals:[1,1,1,1,1]},{key:`r_uparm`,label:`R upper arm`,vals:[4,4,4,4,4]},{key:`l_uparm`,label:`L upper arm`,vals:[4,4,4,4,4]},{key:`r_forearm`,label:`R forearm`,vals:[3,3,3,3,3]},{key:`l_forearm`,label:`L forearm`,vals:[3,3,3,3,3]},{key:`r_hand`,label:`R hand`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`l_hand`,label:`L hand`,vals:[2.5,2.5,2.5,2.5,2.5]},{key:`r_thigh`,label:`R thigh`,vals:[5.5,8,8.5,9,9.5],ageSensitive:!0},{key:`l_thigh`,label:`L thigh`,vals:[5.5,8,8.5,9,9.5],ageSensitive:!0},{key:`r_leg`,label:`R lower leg`,vals:[5,5.5,6,6.5,7],ageSensitive:!0},{key:`l_leg`,label:`L lower leg`,vals:[5,5.5,6,6.5,7],ageSensitive:!0},{key:`r_foot`,label:`R foot`,vals:[3.5,3.5,3.5,3.5,3.5]},{key:`l_foot`,label:`L foot`,vals:[3.5,3.5,3.5,3.5,3.5]}],C=[{id:`infant`,label:`Infant (<1 y)`},{id:`young`,label:`Young child (1-5 y)`},{id:`child`,label:`Child (5-10 y)`},{id:`adol`,label:`Adolescent (10-15 y)`},{id:`adult`,label:`Adult (>15 y)`}];function w(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`young`),[i,a]=(0,c.useState)(``),[o,s]=(0,c.useState)({}),p=C.findIndex(e=>e.id===n),m=S.reduce((e,t)=>e+t.vals[p]*Math.min(100,Math.max(0,o[t.key]??0))/100,0),h=i.trim()?Number(i):Math.round(m*10)/10,g=Number.parseFloat(e),_=Number.isFinite(g)&&g>0,v=Number.isFinite(h)&&h>0,y=_&&v?Math.round(4*g*h):0,b=Math.round(y/2),x=Math.round(b/8),w=y-b,T=Math.round(w/16),E=_?Math.round(g<=10?g*4:g<=20?40+(g-10)*2:60+(g-20)):0;return(0,l.jsxs)(`section`,{className:u,"data-testid":`bedside-panel-burns`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Burns — Lund-Browder + Parkland`}),(0,l.jsxs)(`div`,{className:`grid gap-2 grid-cols-1 sm:grid-cols-3 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Weight (kg)`}),(0,l.jsx)(`input`,{type:`number`,min:`0.3`,step:`0.1`,className:d,value:e,onChange:e=>t(e.target.value),"data-testid":`burn-weight`})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`Age band`}),(0,l.jsx)(`select`,{className:d,value:n,onChange:e=>r(e.target.value),"data-testid":`burn-age`,children:C.map(e=>(0,l.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:f,children:`TBSA override (%)`}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`100`,step:`1`,className:d,value:i,onChange:e=>a(e.target.value),placeholder:v?String(h):`auto`,"data-testid":`burn-tbsa`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Body parts — % of each region burned (2° or deeper)`}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2`,children:S.map(e=>{let t=e.vals[p];return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/30 rounded p-2`,children:[(0,l.jsxs)(`label`,{className:`flex-1 text-xs`,children:[e.label,` `,(0,l.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t,`%`,e.ageSensitive?`*`:``,`)`]})]}),(0,l.jsx)(`input`,{type:`number`,min:`0`,max:`100`,step:`5`,className:`w-16 rounded border border-input bg-background px-2 py-1 text-xs text-right`,value:o[e.key]??0,onChange:t=>s({...o,[e.key]:Number(t.target.value)}),"data-testid":`burn-region-`+e.key}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`%`})]},e.key)})}),v&&(0,l.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Computed TBSA: `,(0,l.jsxs)(`strong`,{children:[h,`%`]})]}),!_&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see Parkland + maintenance fluids.`}),!v&&_&&(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter % per region or override TBSA to compute fluids.`}),_&&v&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,"data-testid":`burn-result`,children:[`Burn fluid resuscitation — `,g,` kg, `,h,`% TBSA (2° or deeper)`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Parkland formula:`}),` 4 mL × kg × %TBSA = `,(0,l.jsxs)(`strong`,{children:[y,` mL LR over 24 hours`]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`First 8 h`}),` (from time of burn): `,b,` mL (~`,(0,l.jsxs)(`strong`,{children:[x,` mL/hr`]}),`)`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Next 16 h:`}),` `,w,` mL (~`,(0,l.jsxs)(`strong`,{children:[T,` mL/hr`]}),`)`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Plus maintenance (4-2-1):`}),` `,E,` mL/hr (D5 ½NS ± 20 mEq KCl/L once UOP established). Consider dextrose in children <30 kg.`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Titrate to UOP:`}),` target 1-2 mL/kg/hr (infants / children), 0.5-1 mL/kg/hr (adolescents). `,(0,l.jsx)(`strong`,{children:`Clinical response trumps formula.`})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Other pearls`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rule of palm:`}),` Patient's palm + fingers ≈ 1% TBSA — good for scattered burns.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`First-degree burns DO NOT count`}),` toward TBSA or Parkland.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Analgesia:`}),` Morphine 0.05-0.1 mg/kg IV q2h, or fentanyl 1-2 mcg/kg IV q30-60 min.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tetanus`}),` prophylaxis if indicated. Tdap/Td ± TIG.`]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Burn center referral (ABA)`}),(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`Partial-thickness >10% TBSA · any full-thickness · face/hands/feet/genital/perineum/major joints · electrical/chemical/inhalation · associated trauma · significant comorbidities · pediatric burns in non-pediatric center.`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ABA Advanced Burn Life Support 2018 · Parkland formula: Baxter 1968 · Lund-Browder 1944.`})]})}var T=`rounded-lg border border-border bg-card p-5 space-y-3`,E=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,D=`block text-xs font-medium text-muted-foreground`,O=`text-left px-2 py-1.5 border-b border-border font-semibold uppercase tracking-wide text-[10px] text-muted-foreground`,k=`px-2 py-1.5 border-b border-border align-top text-sm`;function A({id:e,value:t,onChange:n,testid:r}){return(0,l.jsxs)(`div`,{className:`max-w-xs`,children:[(0,l.jsx)(`label`,{htmlFor:e,className:D,children:`Weight (kg)`}),(0,l.jsx)(`input`,{id:e,type:`number`,min:`0.3`,step:`0.1`,className:E,value:t,onChange:e=>n(e.target.value),"data-testid":r})]})}function j({label:e}){let t=e.indexOf(`(`);if(t<0)return(0,l.jsx)(`span`,{className:`font-semibold`,children:e});let n=e.slice(0,t).trim(),r=e.slice(t);return(0,l.jsxs)(`span`,{children:[(0,l.jsx)(`span`,{className:`font-semibold`,children:n}),` `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})}var M={epi:{perKg:.01,max:.5,unit:`mg`},fluids:{perKg:20,max:null,unit:`mL`},dph:{perKg:1.25,max:50,unit:`mg`},ranitidine:{perKg:1,max:50,unit:`mg`},dex:{perKg:.6,max:16,unit:`mg`},mpn:{perKg:2,max:125,unit:`mg`},glucagon:{perKg:.02,max:1,unit:`mg`}};function N(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e);if(!Number.isFinite(n)||n<=0)return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-anaphylaxis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Anaphylaxis`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Emergency management. Epinephrine IM is the immediate and only proven lifesaving step.`}),(0,l.jsx)(A,{id:`anaph-wt`,value:e,onChange:t,testid:`anaph-weight`}),(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]});let r=s(n,M.epi.perKg,M.epi.max,M.epi.unit),i=Math.round(r.value*10)/10,a=n<10?`Draw up manually`:n<=25?`EpiPen Jr / Auvi-Q 0.15 mg`:`EpiPen / Auvi-Q 0.3 mg`,o=s(n,M.fluids.perKg,M.fluids.max,M.fluids.unit),u=s(n,M.dph.perKg,M.dph.max),d=s(n,M.ranitidine.perKg,M.ranitidine.max),f=s(n,M.dex.perKg,M.dex.max),p=s(n,M.mpn.perKg,M.mpn.max),m=s(n,M.glucagon.perKg,M.glucagon.max),h=[[`STEP 2`,`Position`,`Supine + legs elevated`,`—`,`If dyspneic: sitting position. If vomiting: recovery position`],[`STEP 3`,`O₂`,`High flow 10-15 L/min`,`Face mask`,`100% O₂. Prepare for airway management`],[`STEP 4`,`IV fluids`,`NS ${o.label} bolus`,`IV/IO`,`Repeat up to 60 mL/kg for hypotension`],[`STEP 5`,`Diphenhydramine`,u.label,`IV/IM/PO`,`H1 blocker. NOT first-line — adjunct only`],[``,`Ranitidine`,d.label,`IV over 5 min`,`H2 blocker. Optional adjunct`],[`STEP 6`,`Dexamethasone`,f.label,`IV/IM/PO`,`Prevents biphasic reaction (4-6 hrs later)`],[``,`Methylprednisolone`,p.label,`IV`,`Alternative steroid`],[`REFRACTORY`,`Epinephrine gtt`,`0.1-1 mcg/kg/min`,`IV infusion`,`For persistent hypotension despite fluids + IM epi`],[``,`Glucagon`,m.label,`IV/IM`,`For patients on beta-blockers not responding to epi`]];return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-anaphylaxis`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Anaphylaxis`}),(0,l.jsx)(A,{id:`anaph-wt`,value:e,onChange:t,testid:`anaph-weight`}),(0,l.jsxs)(`div`,{className:`rounded-lg border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-4 space-y-1`,children:[(0,l.jsx)(`div`,{className:`text-base font-bold text-destructive`,children:`STEP 1: Epinephrine IM — GIVE IMMEDIATELY`}),(0,l.jsxs)(`div`,{className:`text-sm font-semibold`,children:[`Epinephrine 1:1000 (1 mg/mL): `,(0,l.jsxs)(`span`,{className:`text-destructive`,children:[r.value,` mg (`,i,` mL)`]}),` IM to lateral thigh`]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[M.epi.perKg,` mg/kg (max `,M.epi.max,` mg) · Auto-injector: `,a]}),(0,l.jsx)(`div`,{className:`text-xs text-destructive`,children:`May repeat every 5-15 minutes if symptoms persist. No contraindications in anaphylaxis.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,"data-testid":`anaph-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Step`}),(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:h.map((e,t)=>(0,l.jsxs)(`tr`,{className:e[0]===`REFRACTORY`||t>0&&h[t-1][0]===`REFRACTORY`&&e[0]===``?`bg-amber-50 dark:bg-amber-950/30`:``,children:[(0,l.jsx)(`td`,{className:k+` font-semibold text-primary text-xs`,children:e[0]}),(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e[1]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:e[2]})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e[3]}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e[4]})]},t))})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Observe minimum 4-6 hours`}),` after last dose of epinephrine (biphasic reactions occur in 5-20% of cases). Discharge with EpiPen prescription and anaphylaxis action plan. Refer to allergist.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ASCIA Anaphylaxis Guidelines 2021 · WAO Anaphylaxis Guidance 2020 · AAP/ACAAI Practice Parameters.`})]})}function P(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`general`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n):null,u=[{id:`general`,label:`PALS General`},{id:`asystole`,label:`Asystole / PEA`},{id:`brady`,label:`Bradycardia`},{id:`svt`,label:`SVT`},{id:`vfib`,label:`VF / Pulseless VT`},{id:`vt`,label:`Stable VT`}];function d({name:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:r})]})}function f({children:e}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}function p(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.1,10,`mL`),n=o(.1,2.5,`mg`),r=o(5,300,`mg`),i=o(1,100,`mg`),s=o(.02,.5,`mg`),c=o(.1,6,`mg`),u=o(.2,12,`mg`),p=o(1,50,`mEq`),m=o(20,1e3,`mg`),h=o(.2,10,`mL`),g=o(60,3e3,`mg`),_=o(.6,30,`mL`),v=o(50,2e3,`mg`),y=o(2,null,`mL`);return(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Epinephrine 1:10,000`,dose:`${e.label} (${t.label})`,route:`IV / IO`,notes:`0.01 mg/kg = 0.1 mL/kg of 1:10,000. Max single dose 1 mg. Repeat q3-5 min.`}),(0,l.jsx)(d,{name:`Epinephrine ET`,dose:n.label,route:`ETT`,notes:`0.1 mg/kg (1 mL/kg of 1:10,000) if no IV/IO`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:r.label,route:`IV / IO bolus`,notes:`5 mg/kg for arrest. Max 300 mg. Repeat up to 2 times (max 15 mg/kg/day).`}),(0,l.jsx)(d,{name:`Lidocaine`,dose:i.label,route:`IV / IO bolus`,notes:`1 mg/kg. Alternative to amiodarone for VF/VT.`}),(0,l.jsx)(d,{name:`Atropine`,dose:`${s.label} (min 0.1 mg)`,route:`IV / IO`,notes:`0.02 mg/kg. Bradycardia from ↑vagal tone or AV block.`}),(0,l.jsx)(d,{name:`Adenosine (1st)`,dose:c.label,route:`IV push + flush`,notes:`0.1 mg/kg (max 6 mg). For SVT. Rapid push, double flush.`}),(0,l.jsx)(d,{name:`Adenosine (2nd)`,dose:u.label,route:`IV push + flush`,notes:`0.2 mg/kg (max 12 mg). Second dose if first unsuccessful.`}),(0,l.jsx)(d,{name:`Sodium bicarb 8.4%`,dose:p.label,route:`IV / IO`,notes:`1 mEq/kg. ONLY if severe metabolic acidosis, hyperK, or TCA OD. Not routine.`}),(0,l.jsx)(d,{name:`Calcium chloride 10%`,dose:`${m.label} (${h.label})`,route:`IV / IO (central preferred)`,notes:`For hyperK, hypoCa, Mg OD, CCB OD. 20 mg/kg = 0.2 mL/kg.`}),(0,l.jsx)(d,{name:`Calcium gluconate 10%`,dose:`${g.label} (${_.label})`,route:`IV / IO (peripheral OK)`,notes:`60 mg/kg = 0.6 mL/kg. Preferred peripherally.`}),(0,l.jsx)(d,{name:`Magnesium sulfate`,dose:v.label,route:`IV over 10-20 min`,notes:`25-50 mg/kg. Torsades, severe asthma. Max 2 g.`}),(0,l.jsx)(d,{name:`Dextrose 10%`,dose:`${y.label} (0.2 g/kg)`,route:`IV push`,notes:`For documented hypoglycemia`}),(0,l.jsx)(d,{name:`Defibrillation`,dose:`2 J/kg → 4 J/kg → 10 J/kg (max 10 J/kg or adult dose)`,route:`Pad`,notes:`For VF/pulseless VT. Resume CPR immediately after shock.`}),(0,l.jsx)(d,{name:`Cardioversion (sync)`,dose:`0.5-1 J/kg → 2 J/kg`,route:`Pad`,notes:`For unstable SVT/VT. Sedate if possible.`})]})}function m(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.1,2.5,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`CPR`,dose:`100-120/min, depth 1/3 AP`,route:`—`,notes:`15:2 (2 rescuer) or 30:2 (single). Rotate every 2 min.`}),(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`0.01 mg/kg 1:10,000 = 0.1 mL/kg. Q3-5 min. Start early.`}),(0,l.jsx)(d,{name:`Epinephrine ETT`,dose:t.label,route:`ETT`,notes:`0.1 mg/kg if no IV access`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Reversible causes (H's & T's)`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2 text-xs`,children:[(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`H's`}),` — Hypoxia, Hypovolemia, H+ (acidosis), Hypo/hyperK, Hypoglycemia, Hypothermia`]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsx)(`strong`,{children:`T's`}),` — Tension PTX, Tamponade, Toxins, Thrombosis (MI/PE), Trauma`]})]})]})}function h(){if(!a)return null;let e=o(.01,1,`mg`),t=o(.02,.5,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Bradycardia with poor perfusion (HR < 60)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Start CPR if HR < 60 with poor perfusion despite oxygenation and ventilation.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`First-line. Q3-5 min.`}),(0,l.jsx)(d,{name:`Atropine`,dose:`${t.label} (min 0.1 mg)`,route:`IV / IO`,notes:`If ↑ vagal tone or AV block. Max 1 mg child / 0.5 mg infant.`}),(0,l.jsx)(d,{name:`Transcutaneous pacing`,dose:`—`,route:`Pad`,notes:`For refractory bradycardia not responsive to drugs.`}),(0,l.jsx)(d,{name:`Consider`,dose:`—`,route:`—`,notes:`Hypoxia, tension pneumothorax, ↑ICP, toxic ingestion (organo, CCB, BB), heart block`})]})]})}function g(){if(!a)return null;let e=o(.1,6,`mg`),t=o(.2,12,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`SVT — narrow complex, rate usually >220 infant / >180 child`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Differentiate from sinus tach: abrupt onset/offset, no P waves or abnormal P axis, HR minimally variable.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`If STABLE`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Vagal maneuvers`,dose:`Ice to face, blow into syringe, Valsalva`,route:`—`,notes:`Try first in stable patient`}),(0,l.jsx)(d,{name:`Adenosine (1st)`,dose:e.label,route:`IV push (proximal) + flush`,notes:`Rapid push, 3-way stopcock with NS flush`}),(0,l.jsx)(d,{name:`Adenosine (2nd)`,dose:t.label,route:`IV push + flush`,notes:`If first dose unsuccessful`}),(0,l.jsx)(d,{name:`Procainamide`,dose:`15 mg/kg over 30-60 min`,route:`IV`,notes:`Expert consult. Avoid with amiodarone.`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:`5 mg/kg over 20-60 min`,route:`IV`,notes:`Expert consult.`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`If UNSTABLE`}),(0,l.jsx)(f,{children:(0,l.jsx)(d,{name:`Synchronized cardioversion`,dose:`0.5-1 J/kg → 2 J/kg`,route:`Pad`,notes:`Sedate if possible. Pre-treat with adenosine if IV available.`})})]})}function _(){if(!a)return null;let e=o(.01,1,`mg`),t=o(5,300,`mg`),n=o(1,100,`mg`),r=o(50,2e3,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-destructive`,children:`VF / Pulseless VT`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`High-quality CPR + defibrillation are key. Minimize interruptions.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Defibrillation (1st)`,dose:`2 J/kg`,route:`Pad`,notes:`Resume CPR immediately after shock.`}),(0,l.jsx)(d,{name:`Defibrillation (2nd)`,dose:`4 J/kg`,route:`Pad`,notes:`After 2 min CPR.`}),(0,l.jsx)(d,{name:`Defibrillation (3rd+)`,dose:`≥4 J/kg (max 10 J/kg or adult dose)`,route:`Pad`,notes:``}),(0,l.jsx)(d,{name:`Epinephrine`,dose:e.label,route:`IV / IO`,notes:`After 2nd shock. Q3-5 min.`}),(0,l.jsx)(d,{name:`Amiodarone`,dose:t.label,route:`IV / IO bolus`,notes:`Refractory VF/VT. Max 15 mg/kg/day.`}),(0,l.jsx)(d,{name:`Lidocaine`,dose:n.label,route:`IV / IO`,notes:`Alternative to amiodarone. Then 20-50 mcg/kg/min gtt.`}),(0,l.jsx)(d,{name:`Mg sulfate`,dose:r.label,route:`IV over 1-2 min`,notes:`For torsades or hypoMg.`})]})]})}function v(){if(!a)return null;let e=o(5,300,`mg`);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Stable monomorphic VT`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Expert consult. Avoid combining QT-prolonging agents.`})]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{name:`Amiodarone`,dose:`5 mg/kg over 20-60 min = ${e.value} mg over 20-60 min`,route:`IV`,notes:``}),(0,l.jsx)(d,{name:`Procainamide`,dose:`15 mg/kg over 30-60 min`,route:`IV`,notes:`Do not combine with amiodarone`}),(0,l.jsx)(d,{name:`Sync cardioversion`,dose:`0.5-1 → 2 J/kg`,route:`Pad`,notes:`If becomes unstable. Sedate.`})]})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-cardiac`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Cardiac Arrest / PALS`}),(0,l.jsx)(A,{id:`cardiac-wt`,value:e,onChange:t,testid:`cardiac-weight`}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(n===e.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`cardiac-view-`+e.id,children:e.label},e.id))}),a?(0,l.jsxs)(`div`,{className:`space-y-3`,children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm font-semibold text-destructive`,children:[u.find(e=>e.id===n)?.label,` — `,i,` kg`]}),n===`general`&&(0,l.jsx)(p,{}),n===`asystole`&&(0,l.jsx)(m,{}),n===`brady`&&(0,l.jsx)(h,{}),n===`svt`&&(0,l.jsx)(g,{}),n===`vfib`&&(0,l.jsx)(_,{}),n===`vt`&&(0,l.jsx)(v,{}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Concentrations:`}),` Epi 1:10,000 (0.1 mg/mL) for IV arrest. 1:1000 (1 mg/mL) for IM anaphylaxis. Atropine <0.1 mg can cause paradoxical bradycardia.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AHA PALS Guidelines 2020 · Always verify against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var F={lorazepam:{perKg:.1,max:4,unit:`mg`,route:`IV / IO`,note:`Slow push over 1-2 min.`,suffix:` (IV preferred)`},midazolam:{perKg:.2,max:10,unit:`mg`,route:`IM / IN / buccal`,note:`Use 5 mg/mL concentrate for IN; split between nares.`},diazepam:{perKg:.5,max:20,unit:`mg`,route:`PR`,note:`Only if no IV/IM/IN access.`},levetiracetam:{perKg:60,max:4500,unit:`mg`,route:`IV over 5-15 min`,note:`Best tolerability. No ECG monitoring needed.`,suffix:` (preferred)`},fosphenytoin:{perKg:20,max:1500,unit:`mg PE`,route:`IV over 10 min`,note:`Max rate 3 mg PE/kg/min. Monitor ECG, BP. Avoid if cardiac dysrhythmia.`},valproate:{perKg:40,max:3e3,unit:`mg`,route:`IV over 10 min`,note:`Avoid <2 yr, hepatic / mitochondrial disease, pregnancy.`},phenobarb:{perKg:20,max:1e3,unit:`mg`,route:`IV over 20 min`,note:`Last-choice 2nd line. High risk of resp depression + hypotension.`},midazGttBolus:{perKg:.2,max:10,unit:`mg`},midazGttLow:{perKg:.05,max:2,unit:`mg/hr`},midazGttHigh:{perKg:.5,max:18,unit:`mg/hr`},pentobarbBolus:{perKg:5,max:200,unit:`mg`},pentobarbGttLow:{perKg:1,max:null,unit:`mg/hr`},pentobarbGttHigh:{perKg:5,max:null,unit:`mg/hr`},propofolBolus:{perKg:2,max:100,unit:`mg`},propofolGttLow:{perKg:2,max:null,unit:`mg/hr`},propofolGttHigh:{perKg:5,max:null,unit:`mg/hr`},ketamineBolus:{perKg:2,max:100,unit:`mg`},ketamineGttLow:{perKg:1,max:null,unit:`mg/hr`},ketamineGttHigh:{perKg:5,max:null,unit:`mg/hr`}};function I(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=(e,t,i=`mg`)=>r?s(n,e,t,i):null,a=r?Math.round(n*2*10)/10:0,o=r?Math.round(n*5*10)/10:0;function u({time:e,color:t,title:n,children:r,last:i=!1}){return(0,l.jsxs)(`div`,{className:`flex gap-3`,children:[(0,l.jsxs)(`div`,{className:`flex flex-col items-center flex-shrink-0`,children:[(0,l.jsx)(`div`,{className:`w-16 py-1.5 rounded-full text-white text-xs font-bold text-center ${t}`,children:e}),!i&&(0,l.jsx)(`div`,{className:`w-0.5 flex-1 bg-border mt-1`})]}),(0,l.jsxs)(`div`,{className:`flex-1 rounded-r-md border-l-4 p-3 bg-muted/30`,style:{borderLeftColor:`currentColor`},children:[(0,l.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wide mb-2`,children:n}),(0,l.jsx)(`div`,{className:`text-sm space-y-2`,children:r})]})]})}function d({name:e,f:t,route:n,notes:r,suffix:i}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsxs)(`td`,{className:k+` font-semibold`,children:[e,i&&(0,l.jsx)(`span`,{className:`text-xs text-green-700 ml-1`,children:i})]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t.label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-seizure`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Seizures — Status Epilepticus Pathway`}),(0,l.jsx)(A,{id:`seizure-wt`,value:e,onChange:t,testid:`seizure-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-destructive bg-red-50 dark:bg-red-950/30 p-3`,children:[(0,l.jsxs)(`div`,{className:`font-bold text-destructive text-sm`,children:[`Status Epilepticus Pathway — `,n,` kg`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Time = 0 at seizure onset. Do not pause between steps for benzo to take effect — act on the clock.`})]}),(0,l.jsxs)(`div`,{className:`space-y-0`,children:[(0,l.jsxs)(u,{time:`0 min`,color:`bg-blue-500 text-white`,title:`Stabilize`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ABCs`}),` — position, 100% O₂ via NC / NRB, suction. `,(0,l.jsx)(`strong`,{children:`IV or IO`}),` × 2. Continuous SpO₂, ECG, BP.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`POC glucose`}),` — if <60 mg/dL: `,(0,l.jsxs)(`strong`,{children:[`D10W `,a,`-`,o,` mL IV`]}),` (2-5 mL/kg).`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Labs`}),`: CBC, CMP, Mg, Ca, Phos, VBG, lactate, AED levels, toxicology if unclear etiology.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Consider pyridoxine`}),` 100 mg IV in infants <18 mo or INH ingestion. Temperature: treat hyperthermia aggressively.`]})]}),(0,l.jsx)(u,{time:`5 min`,color:`bg-purple-500 text-white`,title:`1st benzodiazepine (give once, pick by access)`,children:(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsx)(d,{name:`Lorazepam`,f:i(F.lorazepam.perKg,F.lorazepam.max),route:`IV / IO`,notes:`Slow push over 1-2 min.`,suffix:` (IV preferred)`}),(0,l.jsx)(d,{name:`Midazolam`,f:i(F.midazolam.perKg,F.midazolam.max),route:`IM / IN / buccal`,notes:`Use 5 mg/mL concentrate for IN; split between nares.`}),(0,l.jsx)(d,{name:`Diazepam`,f:i(F.diazepam.perKg,F.diazepam.max),route:`PR`,notes:`Only if no IV/IM/IN access.`})]})]})})}),(0,l.jsxs)(u,{time:`10 min`,color:`bg-violet-500 text-white`,title:`2nd benzodiazepine — if still seizing`,children:[`Repeat same agent + dose `,(0,l.jsx)(`strong`,{children:`once`}),`. Prepare 2nd-line now (don't wait to see if benzo works). If apnea/airway compromise: BVM, consider advanced airway.`]}),(0,l.jsx)(u,{time:`20 min`,color:`bg-amber-500 text-white`,title:`2nd-line anti-epileptic — pick one (ESETT: equivalent efficacy)`,children:(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsx)(d,{name:`Levetiracetam`,f:i(F.levetiracetam.perKg,F.levetiracetam.max),route:`IV over 5-15 min`,notes:`Best tolerability. No ECG monitoring needed.`,suffix:` (preferred)`}),(0,l.jsx)(d,{name:`Fosphenytoin`,f:i(F.fosphenytoin.perKg,F.fosphenytoin.max,`mg PE`),route:`IV over 10 min`,notes:`Max rate 3 mg PE/kg/min. Monitor ECG, BP. Avoid if cardiac dysrhythmia.`}),(0,l.jsx)(d,{name:`Valproic acid`,f:i(F.valproate.perKg,F.valproate.max),route:`IV over 10 min`,notes:`Avoid <2 yr, hepatic / mitochondrial disease, pregnancy.`}),(0,l.jsx)(d,{name:`Phenobarbital`,f:i(F.phenobarb.perKg,F.phenobarb.max),route:`IV over 20 min`,notes:`Last-choice 2nd line. High risk of resp depression + hypotension.`})]})]})})}),(0,l.jsxs)(u,{time:`30 min`,color:`bg-red-500 text-white`,title:`Still seizing? Consider 2nd agent from 2nd-line OR proceed to refractory`,children:[`If the first 2nd-line drug failed, give a different 2nd-line agent `,(0,l.jsx)(`strong`,{children:`OR`}),` move directly to refractory therapy. Activate ICU, prepare for intubation. Confirm etiology not reversible (electrolytes, glucose, fever, toxin).`]}),(0,l.jsxs)(u,{time:`40 min`,color:`bg-destructive text-white`,title:`Refractory status — intubate + continuous infusion + continuous EEG`,last:!0,children:[(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsxs)(`td`,{className:k+` font-semibold`,children:[`Midazolam `,(0,l.jsx)(`span`,{className:`text-xs text-green-700`,children:`(1st-line infusion)`})]}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.midazGttBolus.perKg,F.midazGttBolus.max).value,` mg → gtt `,i(F.midazGttLow.perKg,F.midazGttLow.max,`mg/hr`).value,`–`,i(F.midazGttHigh.perKg,F.midazGttHigh.max,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 0.2 mg/kg, gtt 0.05-0.5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Titrate to seizure control / burst suppression.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Pentobarbital`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.pentobarbBolus.perKg,F.pentobarbBolus.max).value,` mg → gtt `,i(F.pentobarbGttLow.perKg,null,`mg/hr`).value,`–`,i(F.pentobarbGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 5 mg/kg, gtt 1-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Causes hypotension — often need pressors.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Propofol`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.propofolBolus.perKg,F.propofolBolus.max).value,` mg → gtt `,i(F.propofolGttLow.perKg,null,`mg/hr`).value,`–`,i(F.propofolGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 2 mg/kg, gtt 2-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsxs)(`td`,{className:k+` text-xs text-muted-foreground`,children:[(0,l.jsx)(`strong`,{children:`PRIS risk in children`}),` — limit to <4 mg/kg/hr and duration <48 h.`]})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ketamine`}),(0,l.jsxs)(`td`,{className:k+` text-sm`,children:[`Bolus `,i(F.ketamineBolus.perKg,F.ketamineBolus.max).value,` mg → gtt `,i(F.ketamineGttLow.perKg,null,`mg/hr`).value,`–`,i(F.ketamineGttHigh.perKg,null,`mg/hr`).value,` mg/hr `,(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(bolus 2 mg/kg, gtt 1-5 mg/kg/hr)`})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`NMDA antagonist — rescue. Good BP profile; useful if refractory to GABAergics.`})]})]})]})}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[(0,l.jsx)(`strong`,{children:`Continuous EEG within 1 h`}),` — target electrographic seizure suppression × 24-48 h, then wean. Reassess etiology: CNS imaging, LP, expanded workup.`]})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100 space-y-1`,children:[(0,l.jsx)(`div`,{className:`font-semibold`,children:`Key points`}),(0,l.jsxs)(`div`,{children:[`• Do `,(0,l.jsx)(`strong`,{children:`NOT`}),` wait for benzo response before starting the 2nd-line — parallel preparation.`]}),(0,l.jsxs)(`div`,{children:[`• Maximum `,(0,l.jsx)(`strong`,{children:`2 benzo doses`}),` total (1 pre-hospital + 1 in ED, or 2 in ED).`]}),(0,l.jsx)(`div`,{children:`• Respiratory depression is common — have BVM, airway equipment, naloxone, flumazenil accessible (but avoid flumazenil here).`}),(0,l.jsx)(`div`,{children:`• ESETT trial: levetiracetam = fosphenytoin = valproate for efficacy. Pick by tolerability / contraindications.`}),(0,l.jsx)(`div`,{children:`• Always reassess: ongoing seizure? Non-convulsive status? Pseudo-seizure? → continuous EEG if any doubt.`})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Based on AES Guidelines 2016 and ESETT (Kapur et al., NEJM 2019). Verify all doses against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function L(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(``),i=Number.parseFloat(e),a=Number.parseFloat(n),o=Number.isFinite(i)&&i>0,u=(e,t,n=`mg`)=>o?s(i,e,t,n):null,d=Number.isFinite(a)&&a>=0,f=d?Math.round((a/4+4)*2)/2:null,p=d?Math.round((a/4+3.5)*2)/2:null,m=f?Math.round(f*3*10)/10:null,h=d?a<1?`Miller 0-1`:a<2?`Miller 1 / Mac 1`:a<8?`Miller 2 / Mac 2`:`Miller/Mac 3`:`—`,g=o?i<5?`1`:i<10?`1.5`:i<20?`2`:i<30?`2.5`:i<50?`3`:i<70?`4`:`5`:`—`,_=o&&i<10?2:1.5,v=u(6,null,`mL`),y=u(8,null,`mL`);function b({title:e,rows:t}){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:e}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:t.map((e,t)=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e[0]}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:e[1]})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e[2]}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e[3]})]},t))})]})})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-airway`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Airway / RSI`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-md`,children:[(0,l.jsx)(A,{id:`airway-wt`,value:e,onChange:t,testid:`airway-weight`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`airway-age`,className:D,children:`Age (years)`}),(0,l.jsx)(`input`,{id:`airway-age`,type:`number`,min:`0`,step:`0.5`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`airway-age`})]})]}),o?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[`RSI doses & equipment — `,i,` kg`,d?`, ~${a} yr`:``]}),(0,l.jsx)(b,{title:`Pre-medication (optional)`,rows:[[`Atropine`,`${u(.02,1,`mg`).label} (min 0.1 mg)`,`IV`,`Consider <1 yr or if using succinylcholine, or bradycardia risk`],[`Lidocaine 2%`,u(1.5,100,`mg`).label,`IV over 1 min`,`For ↑ICP, asthma; give 2-3 min pre-induction`],[`Fentanyl`,`${u(2,150,`mcg`).label} (2-3 mcg/kg)`,`IV over 1 min`,`Blunts sympathetic response; avoid if hypotensive`]]}),(0,l.jsx)(b,{title:`Induction`,rows:[[`Ketamine`,`${u(1.5,150,`mg`).label} (1-2 mg/kg)`,`IV`,`Preserves BP. First-line for shock, asthma, sepsis`],[`Etomidate`,u(.3,30,`mg`).label,`IV`,`Hemodynamically neutral. Avoid in septic shock (adrenal suppression)`],[`Propofol`,`${u(2,200,`mg`).label} (1-2 mg/kg)`,`IV`,`Causes hypotension. Avoid in shock`],[`Midazolam`,u(.2,10,`mg`).label,`IV`,`Less optimal induction — slower onset`]]}),(0,l.jsx)(b,{title:`Paralytics`,rows:[[`Rocuronium`,`${u(1.2,100,`mg`).label} (1-1.2 mg/kg)`,`IV`,`30-60 sec onset; 30-45 min duration. First-line non-depolarizing.`],[`Succinylcholine`,u(_,150,`mg`).label,`IV`,`<10kg: 2 mg/kg; ≥10kg: 1.5 mg/kg. Avoid in burns/crush/hyperK/MH/NM dz. IM option: 4 mg/kg.`],[`Vecuronium`,u(.1,10,`mg`).label,`IV`,`2-3 min onset; longer duration than roc`]]}),(0,l.jsx)(b,{title:`Maintenance sedation / analgesia`,rows:[[`Midazolam gtt`,`${u(.05,2,`mg`).label}–${u(.2,10,`mg`).label}/hr`,`IV infusion`,`0.05-0.2 mg/kg/hr`],[`Fentanyl gtt`,`${u(1,100,`mcg`).label}–${u(4,200,`mcg`).label}/hr`,`IV infusion`,`1-4 mcg/kg/hr`],[`Ketamine gtt`,`${u(.5,30,`mg`).label}–${u(2,100,`mg`).label}/hr`,`IV infusion`,`0.5-2 mg/kg/hr. Good for asthma`],[`Dexmedetomidine gtt`,`0.2-1.4 mcg/kg/hr`,`IV infusion`,`No resp depression; causes bradycardia + hypotension`],[`Rocuronium gtt`,`10-12 mcg/kg/min`,`IV infusion`,`If continued paralysis needed — only with adequate sedation`]]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Equipment sizing`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 text-xs`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:d?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ETT (uncuffed):`}),` `,f,` mm`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`ETT (cuffed):`}),` `,p,` mm`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Depth at lip:`}),` ~`,m,` cm`]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{children:(0,l.jsx)(`em`,{children:`Enter age for ETT / blade sizing.`})}),(0,l.jsx)(`div`,{children:`ETT (uncuffed) = (age/4) + 4`}),(0,l.jsx)(`div`,{children:`ETT (cuffed) = (age/4) + 3.5`}),(0,l.jsx)(`div`,{children:`Depth = ETT size × 3`})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Laryngoscope blade:`}),` `,h]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`LMA size:`}),` `,g]}),(0,l.jsx)(`div`,{children:`OPA = corner mouth → angle mandible`}),(0,l.jsx)(`div`,{children:`NPA = tip nose → tragus`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 md:col-span-2`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Suction catheter (Fr):`}),` ETT size × 2`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`NG tube:`}),` ETT × 2`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Chest tube:`}),` 4 × ETT`]})]})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Ventilator — starting settings`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs space-y-1`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Mode:`}),` Volume or pressure control`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Tidal volume:`}),` 6-8 mL/kg (= `,v.value,`-`,y.value,` mL). Use lower (4-6 mL/kg) for ARDS.`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Rate:`}),` Infant 25-30, Child 15-25, Adolescent 12-16`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`PEEP:`}),` 5 cmH₂O (↑ for oxygenation problems)`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`FiO₂:`}),` Start 100%, wean to SpO₂ 92-97%`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`I:E ratio:`}),` 1:2 (1:3-4 for obstructive disease)`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook 23rd ed · PALS 2020. Always confirm doses against institutional protocols.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function R(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0;function i(e,t,n,r){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:t})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}let a=r?[i(`Lorazepam`,s(n,.05,2).label,`PO`,`0.05 mg/kg. May repeat in 30 min.`),i(`Midazolam`,s(n,.5,10).label,`PO`,`0.5 mg/kg (max 10 mg)`),i(`Midazolam`,s(n,.3,10).label,`IN (5 mg/mL)`,`0.3 mg/kg split between nares (max 10 mg)`),i(`Olanzapine (ODT)`,n<30?`2.5-5 mg`:`5-10 mg`,`PO / ODT`,`Age ≥6 yr. Avoid IM + benzo combo (risk of resp depression).`),i(`Diphenhydramine`,s(n,1,50).label,`PO`,`1 mg/kg. Adjunct only; sedating.`)]:null,o=r?[i(`Midazolam`,s(n,.1,5).label,`IV / IM`,`0.05-0.1 mg/kg IV, 0.1-0.15 mg/kg IM (max 10 mg)`),i(`Lorazepam`,s(n,.1,4).label,`IV / IM`,`0.05-0.1 mg/kg (max 4 mg). May cause resp depression.`),i(`Haloperidol`,n<40?`0.025-0.075 mg/kg = ${Math.round(n*.05*100)/100} mg`:`2.5-5 mg`,`IM / IV`,`Avoid <3 yr. Risk: QT, EPS, NMS. ECG if repeated.`),i(`Olanzapine`,n<40?`2.5-5 mg`:`5-10 mg`,`IM`,`Avoid benzo co-administration (resp depression, hypotension)`),i(`Ketamine`,s(n,4,500).label,`IM`,`4-5 mg/kg IM (rescue for severe excited delirium). Monitor airway.`),i(`Droperidol`,`0.03-0.07 mg/kg = ${Math.round(n*.05*100)/100} mg`,`IM / IV`,`Effective but QT concern — get ECG.`)]:null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-agitation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Agitation`}),(0,l.jsx)(A,{id:`agit-wt`,value:e,onChange:t,testid:`agit-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3 text-sm font-semibold text-purple-900 dark:text-purple-100`,children:[`Agitation management — `,n,` kg`]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-green-800 dark:text-green-200`,children:`Step 1 — Non-pharmacologic`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Dim lights, quiet room, familiar caregiver present, reduce stimulation. Rule out hypoglycemia, hypoxia, pain, ↑ICP, toxic ingestion, infection.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`Step 2 — Oral / intranasal (cooperative)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`First-line for moderate agitation if the patient will accept PO/IN.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:a})]})}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`Step 3 — IM / IV (severe, uncooperative, or safety risk)`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Require continuous monitoring. Consider restraints only as last resort.`})]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:o})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Monitoring:`}),` Continuous SpO₂ + HR after parenteral sedation. Have airway equipment, flumazenil, naloxone, and IV access ready.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Clinical Report on Pediatric Agitation · ACEP Guidelines for Acute Agitation.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}function z(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=(e,t,i=`mg`)=>r?s(n,e,t,i):null,a=r?n<15?`2 mg`:n<30?`4 mg`:`8 mg`:null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-antiemetics`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Antiemetics`}),(0,l.jsx)(A,{id:`emet-wt`,value:e,onChange:t,testid:`emet-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[`Antiemetic doses — `,n,` kg`]}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ondansetron`}),(0,l.jsxs)(`td`,{className:k+` text-xs`,children:[a,` (weight band) OR `,(0,l.jsx)(j,{label:i(.15,8).label})]}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / ODT / IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`First-line. Max single 8 mg. Repeat q8h. QT prolongation — avoid with other QT drugs. <6 mo: limited data.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Metoclopramide`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.15,10).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV / IM / PO`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`0.1-0.15 mg/kg (max 10 mg). Give with diphenhydramine to prevent EPS / dystonia.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Dimenhydrinate`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(1.25,50).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM / PR`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`1.25 mg/kg (max 50 mg) q6h. ≥2 yr.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Diphenhydramine`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(1,50).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`1 mg/kg (max 50 mg) q6h. Adjunct, sedating.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Promethazine`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.25,25).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`PO / IV / IM`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:`0.25-1 mg/kg. CONTRAINDICATED <2 yr (resp depression). Tissue injury if IV extrav.`}})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Dexamethasone`}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:i(.15,10).label})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV / PO`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Adjunct, esp. chemo-induced. 0.15 mg/kg (max 10 mg).`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Scopolamine patch`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`1.5 mg patch`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`Transdermal`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`≥12 yr. Motion sickness. Apply 4h before exposure.`})]})]})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Pearls:`}),` Ondansetron is first-line in ED for acute gastroenteritis vomiting — single PO/ODT dose increases oral rehydration success. Avoid anticholinergics + opioid combinations. Check QTc if stacking ondansetron + other QT drugs.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP gastroenteritis guidance · WHO essential medicines · Lexicomp.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var B={neonate:{sepsis:{first:`Ampicillin + gentamicin`,alt:`Add cefotaxime if meningitis suspected or gram-neg concern`,duration:`7-10 days; 21 days if confirmed meningitis`,notes:`Cover GBS, E. coli, Listeria. Add acyclovir if HSV risk (maternal lesions, vesicles, seizures).`},meningitis:{first:`Ampicillin + cefotaxime (or gentamicin) + acyclovir`,alt:`Add vancomycin if gram-positive cocci`,duration:`14-21 days depending on organism`,notes:`HSV coverage essential. LP + HSV PCR.`},pna:{first:`Ampicillin + gentamicin`,alt:`Add cefotaxime for gram-neg`,duration:`7-10 days`,notes:`Same as sepsis coverage.`},uti:{first:`Ampicillin + gentamicin`,alt:`Cefotaxime if sensitivities known`,duration:`10-14 days`,notes:`Evaluate for sepsis. Renal US and VCUG workup.`},skin:{first:`Ampicillin + gentamicin`,alt:`Add vancomycin if MRSA risk`,duration:`7-10 days`,notes:`Omphalitis, mastitis — broad coverage.`},ent:{first:`Discuss with infectious diseases`,alt:`—`,duration:`—`,notes:`Rare in neonates. Any ear/throat infection warrants sepsis eval.`},neutropenic:{first:`Cefepime or piperacillin-tazobactam`,alt:`Add vancomycin if indwelling line, severe mucositis, or MRSA`,duration:`Until ANC recovery + afebrile ≥48h`,notes:`Oncology/ID consult.`},ic:{first:`Ampicillin + gentamicin + metronidazole`,alt:`Or piperacillin-tazobactam`,duration:`7-14 days`,notes:`NEC: add metronidazole/clindamycin for anaerobes.`},bone:{first:`Ampicillin + gentamicin`,alt:`Vancomycin if MRSA risk`,duration:`3-6 weeks (IV then PO)`,notes:`Usually hematogenous. S. aureus, GBS, E. coli.`}},infant:{sepsis:{first:`Ampicillin + ceftriaxone (or gentamicin)`,alt:`+ vancomycin if MRSA / severe`,duration:`7-10 days`,notes:`Add acyclovir if HSV suspected (<6 wks). Fever in <90 days requires workup.`},meningitis:{first:`Ceftriaxone + vancomycin (± ampicillin if <6 wks for Listeria)`,alt:`+ acyclovir if HSV`,duration:`10-14 days (longer for Listeria/gram-neg)`,notes:`Dexamethasone if H. influenzae suspected.`},pna:{first:`Ampicillin (or ceftriaxone)`,alt:`Add azithromycin if atypical`,duration:`7-10 days`,notes:`S. pneumoniae most common. RSV/viral often primary.`},uti:{first:`Ceftriaxone or cefotaxime`,alt:`Ampicillin + gentamicin`,duration:`10-14 days`,notes:`US kidney/bladder if first febrile UTI.`},skin:{first:`Cefazolin or clindamycin`,alt:`Vancomycin if MRSA risk`,duration:`7-10 days`,notes:`Consider MRSA if purulent or local resistance >10%.`},ent:{first:`Amoxicillin (90 mg/kg/day) for AOM`,alt:`Amox-clav if recent abx/treatment failure`,duration:`AOM 10 days <2 yr; 7 days ≥2 yr`,notes:`Observe mild AOM if >6 mo and no severe features.`},neutropenic:{first:`Cefepime or piperacillin-tazobactam`,alt:`+ vancomycin for severe/mucositis/line`,duration:`Until ANC recovery + afebrile`,notes:`Oncology/ID consult.`},ic:{first:`Ceftriaxone + metronidazole`,alt:`Piperacillin-tazobactam`,duration:`5-7 days (uncomplicated), longer for complicated`,notes:`Appendicitis — surgical consult.`},bone:{first:`Cefazolin ± vancomycin`,alt:`Clindamycin`,duration:`3-4 weeks (IV then PO transition)`,notes:`S. aureus most common. Kingella in <4 yr.`}},child:{sepsis:{first:`Ceftriaxone + vancomycin`,alt:`Piperacillin-tazobactam if intra-abdominal`,duration:`7-14 days`,notes:`Expand if specific source. Add antifungal if prolonged neutropenia.`},meningitis:{first:`Ceftriaxone + vancomycin`,alt:`+ dexamethasone (Hib coverage)`,duration:`10-14 days`,notes:`Lumbar puncture. Dexamethasone 0.15 mg/kg q6h x 4 days.`},pna:{first:`Ampicillin OR amoxicillin (high dose)`,alt:`Ceftriaxone if hospitalized; add azithromycin for atypical`,duration:`5-7 days (uncomplicated)`,notes:`Mycoplasma if >5 yr. Consider viral causes.`},uti:{first:`Cephalexin or TMP-SMX (PO)`,alt:`Ceftriaxone if ill`,duration:`7-10 days (10-14 if pyelo)`,notes:`Culture-guided de-escalation.`},skin:{first:`Cephalexin or clindamycin`,alt:`TMP-SMX or doxycycline if MRSA`,duration:`5-10 days`,notes:`Abscess — incision & drainage primary tx.`},ent:{first:`Amoxicillin 90 mg/kg/day (AOM); Penicillin V for strep pharyngitis`,alt:`Amox-clav; cephalexin if non-anaphylactic PCN allergy`,duration:`AOM 5-10 days; strep 10 days`,notes:`Strep pharyngitis dose: PCN V 250 mg BID-TID (<27 kg) or 500 mg BID (≥27 kg).`},neutropenic:{first:`Cefepime OR piperacillin-tazobactam`,alt:`+ vancomycin`,duration:`Until ANC recovery + afebrile`,notes:`Add empiric antifungal if fever >4-7 days.`},ic:{first:`Ceftriaxone + metronidazole`,alt:`Piperacillin-tazobactam`,duration:`5-7 days (uncomplicated appendicitis)`,notes:`Surgical consult.`},bone:{first:`Cefazolin ± vancomycin`,alt:`Clindamycin`,duration:`3-4 weeks total`,notes:`S. aureus, group A strep. Consider MRSA if severe.`}}},V={neonate:`Neonate (0-28 d)`,infant:`Infant (1-3 mo)`,child:`Child (>3 mo)`},H=[[`sepsis`,`Sepsis / bacteremia`],[`meningitis`,`Meningitis`],[`pna`,`Pneumonia`],[`uti`,`Urinary tract infection`],[`skin`,`Skin / soft tissue`],[`ent`,`Ear / throat (ENT)`],[`neutropenic`,`Febrile neutropenia`],[`ic`,`Intra-abdominal`],[`bone`,`Bone / joint`]];function U(){let[e,t]=(0,c.useState)(`child`),[n,r]=(0,c.useState)(`sepsis`),i=B[e][n];return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-antimicrobials`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Antimicrobials (empirical)`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-xl`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`abx-age`,className:D,children:`Age band`}),(0,l.jsx)(`select`,{id:`abx-age`,className:E,value:e,onChange:e=>t(e.target.value),"data-testid":`abx-age`,children:Object.entries(V).map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`abx-infection`,className:D,children:`Infection`}),(0,l.jsx)(`select`,{id:`abx-infection`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`abx-infection`,children:H.map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold text-blue-900 dark:text-blue-100`,children:[V[e],` — `,H.find(([e])=>e===n)?.[1]]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{className:`text-green-800 dark:text-green-200`,children:`First-line:`}),` `,i.first]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Alternative / add:`}),` `,i.alt]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-sm`,children:[(0,l.jsx)(`strong`,{children:`Duration:`}),` `,i.duration]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Notes:`}),` `,i.notes]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Red Book · IDSA guidelines · Harriet Lane. Always tailor to local resistance patterns and culture results.`})]})}function W(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=r?Math.round(n*20):null;return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-trauma`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Trauma — primary survey + MTP`}),(0,l.jsx)(A,{id:`trauma-wt`,value:e,onChange:t,testid:`trauma-weight`}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-2`,children:`Primary Survey — ABCDE`}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-destructive bg-red-50 dark:bg-red-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-destructive`,children:`A — Airway + c-spine`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[`Maintain airway (jaw thrust, suction). `,(0,l.jsx)(`strong`,{children:`Manual inline stabilization`}),`; apply collar. Intubate if GCS ≤8, inadequate airway, or impending compromise. Avoid succinylcholine if burn/crush/prolonged immobilization.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-amber-800 dark:text-amber-200`,children:`B — Breathing`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`SpO₂, bilateral breath sounds, chest wall integrity. Identify tension PTX (needle decompression), open PTX (3-sided dressing), flail chest, massive hemothorax.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-green-500 bg-green-50 dark:bg-green-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-green-800 dark:text-green-200`,children:`C — Circulation`}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[`Two large-bore IVs / IO. Control hemorrhage (direct pressure, tourniquet, pelvic binder).`,` `,r?(0,l.jsxs)(l.Fragment,{children:[`NS or LR 20 mL/kg = `,(0,l.jsxs)(`strong`,{children:[i,` mL`]}),` bolus.`]}):(0,l.jsx)(l.Fragment,{children:`NS/LR 20 mL/kg bolus.`}),` `,`Consider blood after 40-60 mL/kg crystalloid or in Class III shock.`]})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-blue-500 bg-blue-50 dark:bg-blue-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-blue-800 dark:text-blue-200`,children:`D — Disability`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`GCS, pupils, glucose, gross motor. Consider ↑ICP (head up 30°, mannitol 0.5-1 g/kg or hypertonic saline 3% 3-5 mL/kg).`})]}),(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 border-violet-500 bg-violet-50 dark:bg-violet-950/30 p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold text-violet-800 dark:text-violet-200`,children:`E — Exposure + environment`}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`Fully expose; prevent hypothermia (warm blankets, fluids).`})]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Massive Transfusion Protocol (MTP)`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsxs)(`tbody`,{children:[(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Ratio`}),(0,l.jsx)(`td`,{className:k,children:`1:1:1 (pRBC : FFP : platelets)`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`—`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Activate early if ≥40 mL/kg transfused or ongoing hemorrhage. Avoid excessive crystalloid.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Tranexamic acid (TXA)`}),(0,l.jsx)(`td`,{className:k,children:`15 mg/kg IV (max 1 g) over 10 min → 2 mg/kg/hr × 8h`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Within 3 hr of injury. CRASH-2 / MATIC.`})]}),(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:`Calcium`}),(0,l.jsx)(`td`,{className:k,children:`20 mg/kg CaCl or 60 mg/kg Ca-gluconate IV per unit citrated blood`}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:`IV`}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:`Citrated blood chelates calcium.`})]})]})]})}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`C-spine clearance (NEXUS / CCR)`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[`Pediatric c-spine decision tools are imperfect. `,(0,l.jsx)(`strong`,{children:`Imaging if any:`}),` focal neurologic deficit, altered mental status, neck pain / tenderness, torticollis, substantial torso injury, high-risk mechanism (diving, MVC >55 mph, fall >10 ft). Plain films + CT if positive or equivocal.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Pediatric shock — signs`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-xs text-red-900 dark:text-red-200`,children:[`Children compensate well — `,(0,l.jsx)(`strong`,{children:`hypotension is a late finding`}),`. Early signs: tachycardia, cool extremities, weak peripheral pulses, prolonged cap refill (>3 sec), narrowed pulse pressure, altered mentation. Minimum SBP = 70 + (2 × age in years) for ages 1-10.`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold mt-3`,children:`Secondary survey — AMPLE + head-to-toe`}),(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[(0,l.jsx)(`strong`,{children:`AMPLE:`}),` Allergies, Medications, Past history, Last meal, Events of injury. Head-to-toe exam; log-roll for back; digital rectal; neurovascular checks of all extremities.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`ATLS 10th ed · PALS 2020 · PECARN c-spine rule · CRASH-2 trial (TXA).`})]})}var G=[{name:`Ketamine IV`,display:`Ketamine`,perKgLow:1.5,perKgHigh:2,maxLow:100,maxHigh:150,unit:`mg`,route:`IV`,onset:`1 min`,duration:`15-30 min`,notes:`Dissociative. Preserves airway reflexes.`},{name:`Ketamine IM`,display:null,perKgLow:4,perKgHigh:5,maxLow:300,maxHigh:400,unit:`mg`,route:`IM`,onset:`3-5 min`,duration:`30-60 min`,notes:`Give atropine 0.01 mg/kg to reduce secretions.`},{name:`Midazolam IV`,display:`Midazolam`,perKgLow:.05,perKgHigh:.1,maxLow:2,maxHigh:5,unit:`mg`,route:`IV`,onset:`2-3 min`,duration:`30-60 min`,notes:`Anxiolysis. Titrate q3-5 min.`},{name:`Midazolam IN/PO`,display:null,perKg:.5,max:20,unit:`mg`,route:`IN/PO`,onset:`10-15 min`,duration:`30-60 min`,notes:`IN (max 10 mg / naris) or PO (max 20 mg).`},{name:`Propofol`,display:`Propofol`,perKg:1,max:40,unit:`mg`,route:`IV`,onset:`30 sec`,duration:`5-10 min`,notes:`Short procedures. Causes apnea — manage airway.`},{name:`Fentanyl IV`,display:`Fentanyl`,perKg:1,max:100,unit:`mcg`,route:`IV`,onset:`2-3 min`,duration:`30-60 min`,notes:`Analgesic. Often combined with midazolam.`},{name:`Fentanyl IN`,display:null,perKg:2,max:100,unit:`mcg`,route:`IN`,onset:`5-10 min`,duration:`30-60 min`,notes:`Intranasal.`},{name:`Nitrous oxide`,display:`Nitrous oxide`,doseDisplay:`50:50 or 70:30 mix`,unit:`mix`,route:`Inhaled`,onset:`2-5 min`,duration:`5 min off`,notes:`Self-administered via demand valve. Anxiolysis + mild analgesia.`},{name:`Dexmedetomidine IN`,display:`Dexmedetomidine`,perKgLow:2,perKgHigh:3,maxLow:100,maxHigh:null,unit:`mcg`,route:`IN`,onset:`15-30 min`,duration:`60-90 min`,notes:`Intranasal. No respiratory depression. Good for imaging.`},{name:`Naloxone`,display:`Naloxone`,perKg:.1,max:2,unit:`mg`,route:`IV/IM/IN`,reverses:`Opioids (fentanyl, morphine)`,notes:`Max 2 mg. Repeat q2-3 min. Duration shorter than opioids — monitor for re-sedation.`},{name:`Flumazenil`,display:`Flumazenil`,perKg:.01,max:.2,unit:`mg`,route:`IV`,reverses:`Benzodiazepines (midazolam)`,notes:`Max 0.2 mg single dose. Repeat q1 min to max 1 mg total. Risk of seizures — use cautiously.`}];function K(e,t){if(t.doseDisplay)return t.doseDisplay;let n=t.unit===`mcg`?` mcg`:t.unit===`mix`?``:` mg`,r=t.unit===`mcg`?`mcg`:`mg`;if(t.perKgLow!=null){let i=s(e,t.perKgLow,t.maxLow??null).value;return t.perKgHigh==null?`${i}${n} (${t.perKgLow} ${r}/kg)`:`${i}-${s(e,t.perKgHigh,t.maxHigh??null).value}${n} (${t.perKgLow}-${t.perKgHigh} ${r}/kg)`}return t.perKg==null?``:`${s(e,t.perKg,t.max??null).value}${n} (${t.perKg} ${r}/kg)`}function q(){let[e,t]=(0,c.useState)(``),n=Number.parseFloat(e),r=Number.isFinite(n)&&n>0,i=G.filter(e=>!e.reverses),a=G.filter(e=>e.reverses);function o({dg:e}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e.display??``}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:K(n,e)})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.route}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.onset??``}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.duration??``}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.notes})]})}function s({dg:e}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e.display}),(0,l.jsx)(`td`,{className:k,children:(0,l.jsx)(j,{label:K(n,e)})}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.route}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:e.reverses}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,children:e.notes})]})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-sedation`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Procedural Sedation`}),(0,l.jsx)(A,{id:`sed-wt`,value:e,onChange:t,testid:`sed-weight`}),r?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{className:`rounded-md border-2 border-purple-500 bg-purple-50 dark:bg-purple-950/30 p-3 text-sm font-semibold text-purple-900 dark:text-purple-100`,children:[`Procedural Sedation — `,n,` kg patient`]}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Sedation Agents`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Onset`}),(0,l.jsx)(`th`,{className:O,children:`Duration`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:i.map(e=>(0,l.jsx)(o,{dg:e},e.name))})]})}),(0,l.jsx)(`h3`,{className:`text-sm font-semibold text-destructive`,children:`Reversal Agents`}),(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{className:`bg-red-50 dark:bg-red-950/30`,children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Reverses`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:a.map(e=>(0,l.jsx)(s,{dg:e},e.name))})]})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Pre-sedation checklist:`}),` NPO status (2h clear liquids, 6h solids), consent, monitoring equipment (pulse ox, capnography, BP), resuscitation equipment at bedside, suction ready, IV access. Minimum monitoring: continuous SpO₂, HR, capnography. Provider capable of managing airway must be present.`]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP Guidelines for Monitoring and Management of Pediatric Patients Before, During, and After Sedation · ASA Practice Guidelines for Sedation and Analgesia by Non-Anesthesiologists.`})]}):(0,l.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var J=[[`approach`,`General approach (stabilize → toxidrome → decon → antidote)`],[`acetaminophen`,`Acetaminophen overdose`],[`opioids`,`Opioid overdose`],[`iron`,`Iron overdose`],[`tca`,`Tricyclic antidepressant (TCA) overdose`],[`bbccb`,`β-blocker / CCB overdose`],[`benzo`,`Benzodiazepine overdose`],[`organo`,`Organophosphate / carbamate poisoning`],[`salicylate`,`Salicylate overdose`],[`etoh`,`Toxic alcohols (methanol / ethylene glycol)`],[`dialyzable`,`Dialyzable drugs (ISTUMBLE)`]];function Y(){let[e,t]=(0,c.useState)(``),[n,r]=(0,c.useState)(`approach`),i=Number.parseFloat(e),a=Number.isFinite(i)&&i>0,o=(e,t,n=`mg`)=>a?s(i,e,t,n).value:null;function u({color:e,title:t,body:n}){return(0,l.jsxs)(`div`,{className:`rounded-md border-l-4 ${e} p-3 text-sm`,children:[(0,l.jsx)(`div`,{className:`font-semibold mb-1`,children:t}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n})]})}function d({drug:e,dose:t,route:n,notes:r}){return(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`td`,{className:k+` font-semibold`,children:e}),(0,l.jsx)(`td`,{className:k,children:t}),(0,l.jsx)(`td`,{className:k+` text-xs`,children:n}),(0,l.jsx)(`td`,{className:k+` text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:r}})]})}function f({children:e}){return(0,l.jsx)(`div`,{className:`overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{className:O,children:`Drug`}),(0,l.jsx)(`th`,{className:O,children:`Dose`}),(0,l.jsx)(`th`,{className:O,children:`Route`}),(0,l.jsx)(`th`,{className:O,children:`Notes`})]})}),(0,l.jsx)(`tbody`,{children:e})]})})}return(0,l.jsxs)(`section`,{className:T,"data-testid":`bedside-panel-toxicology`,children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Toxicology`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-xl`,children:[(0,l.jsx)(A,{id:`tox-wt`,value:e,onChange:t,testid:`tox-weight`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`tox-topic`,className:D,children:`Topic`}),(0,l.jsx)(`select`,{id:`tox-topic`,className:E,value:n,onChange:e=>r(e.target.value),"data-testid":`tox-topic`,children:J.map(([e,t])=>(0,l.jsx)(`option`,{value:e,children:t},e))})]})]}),n===`approach`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(u,{color:`border-blue-500 bg-blue-50 dark:bg-blue-950/30`,title:`1. Stabilize (ABCDE)`,body:(0,l.jsx)(l.Fragment,{children:`Airway, breathing, circulation, disability (glucose, pupils, GCS), exposure. Naloxone if depressed LOC + resp depression. Dextrose if hypoglycemic. Thiamine in select cases.`})}),(0,l.jsx)(u,{color:`border-purple-500 bg-purple-50 dark:bg-purple-950/30`,title:`2. Identify toxidrome`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Sympathomimetic:`}),` HTN, tachy, mydriasis, diaphoresis (cocaine, meth). `,(0,l.jsx)(`strong`,{children:`Anticholinergic:`}),` hot/dry, mydriasis, tachy, delirium (antihistamines, TCAs). `,(0,l.jsx)(`strong`,{children:`Cholinergic:`}),` SLUDGE-M, miosis (organophosphates). `,(0,l.jsx)(`strong`,{children:`Opioid:`}),` miosis, resp depression, ↓LOC. `,(0,l.jsx)(`strong`,{children:`Sedative-hypnotic:`}),` ↓LOC, normal/low vitals.`]})}),(0,l.jsx)(u,{color:`border-amber-500 bg-amber-50 dark:bg-amber-950/30`,title:`3. Decontamination`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Activated charcoal`}),` 1 g/kg PO (max 50 g): within 1h of ingestion, intact airway, ingestion adsorbed (not Li, metals, alcohols). Avoid caustics/hydrocarbons. `,(0,l.jsx)(`strong`,{children:`Whole bowel irrigation:`}),` PEG for metals/iron/lithium/sustained release. `,(0,l.jsx)(`strong`,{children:`Gastric lavage:`}),` rarely indicated. `,(0,l.jsx)(`strong`,{children:`Ipecac:`}),` no longer recommended.`]})}),(0,l.jsx)(u,{color:`border-green-500 bg-green-50 dark:bg-green-950/30`,title:`4. Enhance elimination`,body:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`strong`,{children:`Urinary alkalinization`}),` (salicylates, phenobarbital). `,(0,l.jsx)(`strong`,{children:`Hemodialysis`}),` (see ISTUMBLE). `,(0,l.jsx)(`strong`,{children:`Lipid emulsion`}),` for lipid-soluble drug toxicity (LA, CCB, TCA).`]})}),(0,l.jsx)(u,{color:`border-destructive bg-red-50 dark:bg-red-950/30`,title:`5. Antidotes`,body:(0,l.jsxs)(l.Fragment,{children:[`See topic list. `,(0,l.jsx)(`strong`,{children:`Contact Poison Center`}),` (US: 1-800-222-1222) early for any significant exposure.`]})})]}),n===`acetaminophen`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Acetaminophen overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Acute toxic dose: >150 mg/kg (or 7.5 g total) single ingestion. Hepatotoxic after 24h; AST/ALT peak day 3-4.`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`strong`,{children:`Diagnosis:`}),` Draw level at 4h post-ingestion (or on arrival if >4h). Plot on `,(0,l.jsx)(`strong`,{children:`Rumack-Matthew nomogram`}),` (treatment line at 150 mcg/mL at 4h).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`N-acetylcysteine (NAC) — IV`,dose:`150 mg/kg over 1h → 50 mg/kg over 4h → 100 mg/kg over 16h (21h total)`,route:`IV`,notes:`Total 300 mg/kg. Most effective if started <8h post-ingestion.`}),(0,l.jsx)(d,{drug:`N-acetylcysteine — PO`,dose:`140 mg/kg load, then 70 mg/kg q4h × 17 doses`,route:`PO`,notes:`Alternative to IV. Unpleasant taste — often with juice.`}),(0,l.jsx)(d,{drug:`Activated charcoal`,dose:`1 g/kg (max 50 g)`,route:`PO`,notes:`If within 1-2h of ingestion and airway protected.`})]}),a&&(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3 text-xs`,children:[(0,l.jsxs)(`strong`,{children:[`For `,i,` kg:`]}),` IV loading = `,o(150,null),` mg over 1h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(150 mg/kg)`}),`; 2nd bag = `,o(50,null),` mg over 4h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(50 mg/kg)`}),`; 3rd bag = `,o(100,null),` mg over 16h `,(0,l.jsx)(`span`,{className:`text-muted-foreground`,children:`(100 mg/kg)`}),`. `,(0,l.jsx)(`em`,{children:`Total 300 mg/kg.`})]})]}),n===`opioids`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Opioid overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Triad: `,(0,l.jsx)(`strong`,{children:`miosis + respiratory depression + ↓ LOC`}),`. Fentanyl / synthetics may require repeated/higher doses.`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Naloxone (initial)`,dose:a?`0.01-0.1 mg/kg = ${o(.01,null)}-${o(.1,null)} mg`:`0.01-0.1 mg/kg`,route:`IV / IM / IN / IO`,notes:`Start low if chronic opioid use (avoid withdrawal). Titrate to respiratory effort, not consciousness.`}),(0,l.jsx)(d,{drug:`Naloxone (full reversal)`,dose:`2 mg IV/IM/IN`,route:`IV / IM / IN`,notes:`If no chronic use and severe resp depression. Repeat q2-3 min.`}),(0,l.jsx)(d,{drug:`Naloxone infusion`,dose:`2/3 of effective bolus per hour`,route:`IV`,notes:`For long-acting opioids (methadone, fentanyl patch, sustained release)`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[`Observe ≥4h after last dose; longer for long-acting agents. Duration of naloxone (30-90 min) is shorter than most opioids — `,(0,l.jsx)(`strong`,{children:`re-sedation is common`}),`.`]})]}),n===`iron`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Iron overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Toxic dose: elemental Fe ≥20 mg/kg. Severe ≥60 mg/kg. `,(0,l.jsx)(`strong`,{children:`Charcoal does NOT bind iron.`})]}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[(0,l.jsx)(`strong`,{children:`Stages:`}),` 1) GI (0-6h: vomiting, bloody diarrhea); 2) Latent (6-24h); 3) Shock/metabolic acidosis (12-24h); 4) Hepatotoxicity (2-5d); 5) Gastric scarring (2-8 wk).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Whole bowel irrigation`,dose:`PEG-ES 25-40 mL/kg/hr`,route:`NG`,notes:`For radiopaque pills on KUB or ingested sustained-release iron.`}),(0,l.jsx)(d,{drug:`Deferoxamine`,dose:`15 mg/kg/hr IV infusion`,route:`IV`,notes:`Max 6-8 g/day. Indications: shock, metabolic acidosis, Fe >500 mcg/dL, or severe symptoms. Urine turns 'vin rosé' color.`})]}),(0,l.jsx)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:`Iron level at 4-6h. <350 usually asymptomatic; 350-500 mild; >500 severe. Consider KUB for radiopaque pills.`})]}),n===`tca`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`TCA overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Anticholinergic + Na-channel blockade. `,(0,l.jsx)(`strong`,{children:`Risks:`}),` seizure, VT/VF, hypotension, coma. ECG: QRS >100 ms or R in aVR >3 mm predicts toxicity.`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Sodium bicarbonate 8.4%`,dose:`1-2 mEq/kg IV bolus → infusion`,route:`IV`,notes:`Goal pH 7.45-7.55 and narrowing QRS. Repeat bolus for QRS widening, hypotension, or arrhythmia.`}),(0,l.jsx)(d,{drug:`Mg sulfate`,dose:a?`${o(50,2e3)} mg`:`25-50 mg/kg (max 2 g)`,route:`IV over 10 min`,notes:`For torsades.`}),(0,l.jsx)(d,{drug:`IV lipid emulsion 20%`,dose:`1.5 mL/kg bolus → 0.25 mL/kg/min × 30-60 min`,route:`IV`,notes:`If refractory shock/arrest. Consult toxicology.`})]}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Avoid`}),` Class IA/IC antiarrhythmics, beta-blockers, physostigmine (risk of asystole with TCAs).`]})]}),n===`bbccb`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`β-blocker / Calcium-channel blocker overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Bradycardia + hypotension. CCBs (esp. verapamil, diltiazem, amlodipine) can be lethal in small pediatric doses.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`IV fluids`,dose:`20 mL/kg NS bolus`,route:`IV`,notes:`Cautious — avoid volume overload`}),(0,l.jsx)(d,{drug:`Calcium chloride 10% or gluconate`,dose:`CaCl 20 mg/kg / Ca-glu 60 mg/kg`,route:`IV`,notes:`First-line for CCB. Repeat q15-20 min.`}),(0,l.jsx)(d,{drug:`Glucagon`,dose:`50 mcg/kg IV bolus → 50-150 mcg/kg/hr`,route:`IV`,notes:`β-blocker antidote. GI side effects common.`}),(0,l.jsx)(d,{drug:`High-dose insulin (HIE)`,dose:`Regular insulin 1 U/kg bolus → 0.5-2 U/kg/hr + D25% infusion`,route:`IV`,notes:`Hyperinsulinemic euglycemia therapy. Monitor K+ and glucose closely.`}),(0,l.jsx)(d,{drug:`Vasopressors`,dose:`Epi / norepi infusion`,route:`IV`,notes:`Titrate to MAP.`}),(0,l.jsx)(d,{drug:`Lipid emulsion 20%`,dose:`1.5 mL/kg → 0.25 mL/kg/min`,route:`IV`,notes:`For lipid-soluble CCBs (verapamil) if refractory.`}),(0,l.jsx)(d,{drug:`Methylene blue / ECMO`,dose:`—`,route:`—`,notes:`Rescue therapy — toxicology/ICU consult.`})]})]}),n===`benzo`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Benzodiazepine overdose`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Sedation + resp depression. Usually supportive — intubation rarely needed alone. `,(0,l.jsx)(`strong`,{children:`Flumazenil caution.`})]}),(0,l.jsx)(f,{children:(0,l.jsx)(d,{drug:`Flumazenil`,dose:`0.01 mg/kg (max 0.2 mg) IV, may repeat q1 min to max 1 mg`,route:`IV`,notes:`Only for iatrogenic reversal in a benzo-naive patient with no TCAs, seizure disorder, or chronic benzo use. Can precipitate seizures.`})}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[`In real-world ingestion, `,(0,l.jsx)(`strong`,{children:`supportive care (airway, monitoring)`}),` is usually safer than flumazenil.`]})]}),n===`organo`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Organophosphate / carbamate poisoning`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Cholinergic toxidrome: `,(0,l.jsx)(`strong`,{children:`SLUDGE-M`}),` (salivation, lacrimation, urination, defecation, GI distress, emesis, miosis) + muscle fasciculation, bradycardia, bronchorrhea. Decontamination critical (PPE for providers).`]}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Atropine`,dose:`0.05 mg/kg IV, double q3-5 min until bronchial secretions dry`,route:`IV`,notes:`Endpoint = dry lungs, not dry mouth or heart rate. Can require huge doses.`}),(0,l.jsx)(d,{drug:`Pralidoxime (2-PAM)`,dose:`25-50 mg/kg IV over 30 min (max 2 g) → 10-20 mg/kg/hr`,route:`IV`,notes:`Only for organophosphates (not carbamates). Regenerates acetylcholinesterase.`}),(0,l.jsx)(d,{drug:`Diazepam / midazolam`,dose:`Standard seizure doses`,route:`IV`,notes:`For seizures or severe fasciculations.`})]})]}),n===`salicylate`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Salicylate overdose`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Mixed respiratory alkalosis + anion gap metabolic acidosis. Tinnitus, tachypnea, diaphoresis, hyperthermia. Severe: CNS depression, seizures, pulmonary edema, cerebral edema.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Fluids`,dose:`Aggressive resuscitation`,route:`IV`,notes:`Dehydration common. Avoid fluid overload (risk of pulmonary edema).`}),(0,l.jsx)(d,{drug:`Sodium bicarb`,dose:`1-2 mEq/kg IV bolus → drip`,route:`IV`,notes:`Urinary alkalinization (goal urine pH >7.5). Prevents CNS entry.`}),(0,l.jsx)(d,{drug:`Glucose`,dose:`Maintain euglycemia even if BG normal`,route:`IV`,notes:`CNS hypoglycemia despite normal serum glucose.`}),(0,l.jsx)(d,{drug:`Hemodialysis`,dose:`—`,route:`—`,notes:`For severe: altered MS, pulmonary edema, renal failure, refractory acidosis, or level >100 mg/dL acute / >60 chronic.`})]})]}),n===`etoh`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Toxic alcohols (methanol / ethylene glycol)`}),(0,l.jsx)(`p`,{className:`text-sm`,children:`Anion gap metabolic acidosis + osmolar gap. Methanol → visual changes, blindness. Ethylene glycol → calcium oxalate crystals in urine, renal failure.`}),(0,l.jsxs)(f,{children:[(0,l.jsx)(d,{drug:`Fomepizole`,dose:`15 mg/kg IV load → 10 mg/kg q12h × 4 → 15 mg/kg q12h`,route:`IV`,notes:`First-line. Inhibits alcohol dehydrogenase.`}),(0,l.jsx)(d,{drug:`Ethanol (alternative)`,dose:`Load 600 mg/kg → maintain level 100-150 mg/dL`,route:`IV / PO`,notes:`If fomepizole unavailable. Monitor closely.`}),(0,l.jsx)(d,{drug:`Hemodialysis`,dose:`—`,route:`—`,notes:`For severe acidosis, end-organ damage, or high levels.`}),(0,l.jsx)(d,{drug:`Folate / thiamine / pyridoxine`,dose:`Standard doses`,route:`IV`,notes:`Methanol: folate. EG: thiamine + pyridoxine (divert to non-toxic metabolites).`})]})]}),n===`dialyzable`&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsx)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-sm font-semibold`,children:`Dialyzable drugs (ISTUMBLE)`}),(0,l.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm`,children:[[`I`,`Isopropyl alcohol, INH`],[`S`,`Salicylates`],[`T`,`Theophylline, Toxic alcohols`],[`U`,`Uremia-related drugs`],[`M`,`Methanol, Metformin, Methotrexate`],[`B`,`Barbiturates (long-acting)`],[`L`,`Lithium`],[`E`,`Ethylene glycol`]].map(([e,t])=>(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-2`,children:[(0,l.jsxs)(`strong`,{children:[e,`:`]}),` `,t]},e))}),(0,l.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,l.jsx)(`strong`,{children:`Poor candidates for HD:`}),` Large Vd (TCAs, digoxin, BBs), highly protein-bound (benzos, CCBs), lipid-soluble (opioids, phenothiazines). EXTRIP recommendations are evidence-based — consult toxicology.`]})]}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Call Poison Control early: 1-800-222-1222 (US) · Refs: Goldfrank's Toxicologic Emergencies · EXTRIP workgroup.`})]})}function ee(e){switch(e){case`anaphylaxis`:return(0,l.jsx)(N,{});case`cardiac`:return(0,l.jsx)(P,{});case`seizure`:return(0,l.jsx)(I,{});case`airway`:return(0,l.jsx)(L,{});case`agitation`:return(0,l.jsx)(R,{});case`antiemetics`:return(0,l.jsx)(z,{});case`antimicrobials`:return(0,l.jsx)(U,{});case`trauma`:return(0,l.jsx)(W,{});case`sedation`:return(0,l.jsx)(q,{});case`toxicology`:return(0,l.jsx)(Y,{});case`neonatal`:return(0,l.jsx)(v,{});case`respiratory`:return(0,l.jsx)(y,{});case`ventilation`:return(0,l.jsx)(b,{});case`sepsis`:return(0,l.jsx)(x,{});case`burns`:return(0,l.jsx)(w,{});default:return null}}var te=new Set([`anaphylaxis`,`cardiac`,`seizure`,`airway`,`agitation`,`antiemetics`,`antimicrobials`,`trauma`,`sedation`,`toxicology`,`neonatal`,`respiratory`,`ventilation`,`sepsis`,`burns`]),X=`rounded-lg border border-border bg-card p-5 space-y-3`,ne=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,re=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,Z=`block text-xs font-medium text-muted-foreground`,Q=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,$=[{id:`neonatal`,label:`Neonatal`,icon:`👶`,summary:`GA classification, AGA/SGA/LGA, prematurity category (Fenton 2013 / WHO).`},{id:`airway`,label:`Airway / RSI`,icon:`💨`,summary:`ETT size + depth, RSI induction + paralytic dosing by weight.`},{id:`cardiac`,label:`Cardiac Arrest`,icon:`❤️`,summary:`PALS dosing (epinephrine, amiodarone, lidocaine), defibrillation J/kg.`},{id:`respiratory`,label:`Respiratory`,icon:`🫁`,summary:`Asthma, bronchiolitis, croup severity + dosing.`},{id:`ventilation`,label:`O₂ & Ventilation`,icon:`🌀`,summary:`NC / HFNC / CPAP / BiPAP flow + FiO₂ targets by age.`},{id:`seizure`,label:`Seizures`,icon:`🧠`,summary:`Benzodiazepine + second/third-line weight-based dosing.`},{id:`sepsis`,label:`Sepsis & Fever`,icon:`🦠`,summary:`Empirical antibiotics + fluid bolus dosing by weight.`},{id:`anaphylaxis`,label:`Anaphylaxis`,icon:`💉`,summary:`Epinephrine IM, IV infusion, steroid + antihistamine dosing.`},{id:`sedation`,label:`Sedation`,icon:`🛌`,summary:`Procedural sedation regimens — ketamine, propofol, midazolam.`},{id:`agitation`,label:`Agitation`,icon:`😤`,summary:`Weight-based haloperidol, olanzapine, lorazepam.`},{id:`antiemetics`,label:`Antiemetics`,icon:`💊`,summary:`Ondansetron, metoclopramide, promethazine dosing.`},{id:`antimicrobials`,label:`Antimicrobials`,icon:`🧫`,summary:`Common empirical regimens keyed to syndrome + weight.`},{id:`burns`,label:`Burns`,icon:`🔥`,summary:`TBSA % (Lund-Browder, Rule of Nines-children), Parkland fluids.`},{id:`toxicology`,label:`Toxicology`,icon:`☠️`,summary:`Common toxidromes + antidotes + decontamination windows.`},{id:`trauma`,label:`Trauma`,icon:`🩹`,summary:`PECARN, c-spine, blood-product dosing, TXA.`}];function ie(){let[e,t]=(0,c.useState)(``),[n,a]=(0,c.useState)(`apls`),[s,u]=(0,c.useState)(``),d=i(e),f=d==null?null:r(d),p=f?n===`bestguess`?f.all.bestGuess:f.all.apls:null,m=s.trim()||(p==null?``:String(p));function h(){t(``),a(`apls`),u(``)}return(0,l.jsxs)(`section`,{className:X,"data-testid":`bedside-weight-estimator`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Age → Weight Estimator`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Shared starting point for Bedside dosing. Uses the same APLS and Best Guess formulas as the legacy app.`})]}),(0,l.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1.2fr_1fr_1fr_auto] md:items-end`,children:[(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-age`,className:Z,children:`Age`}),(0,l.jsx)(`input`,{id:`bedside-react-age`,value:e,onChange:e=>t(e.target.value),placeholder:`e.g. "18m", "3y", "2y5m"`,className:Q,"data-testid":`bedside-age-input`})]}),(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-formula`,className:Z,children:`Formula`}),(0,l.jsxs)(`select`,{id:`bedside-react-formula`,value:n,onChange:e=>{a(e.target.value),u(``)},className:Q,"data-testid":`bedside-formula-select`,children:[(0,l.jsx)(`option`,{value:`apls`,children:`APLS`}),(0,l.jsx)(`option`,{value:`bestguess`,children:`Best Guess`})]})]}),(0,l.jsxs)(`div`,{className:`space-y-1`,children:[(0,l.jsx)(`label`,{htmlFor:`bedside-react-weight`,className:Z,children:`Weight (kg)`}),(0,l.jsx)(`input`,{id:`bedside-react-weight`,type:`number`,min:`0.3`,step:`0.1`,value:m,onChange:e=>u(e.target.value),className:Q,"data-testid":`bedside-weight-input`})]}),(0,l.jsx)(`button`,{type:`button`,onClick:h,className:re,children:`Clear`})]}),e.trim()&&d==null?(0,l.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,children:`Could not parse age. Try "3y", "18 months", or "15 days".`}):null,f&&p!=null?(0,l.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/40 p-4 text-sm`,"data-testid":`bedside-estimate-result`,children:[(0,l.jsxs)(`div`,{className:`font-semibold`,children:[p,` kg estimated from `,o(d??0)]}),(0,l.jsxs)(`div`,{className:`text-muted-foreground`,children:[`APLS: `,f.all.apls,` kg · Best Guess: `,f.all.bestGuess,` kg. You can override the weight field.`]})]}):null]})}function ae({pill:e}){return(0,l.jsxs)(`section`,{className:X,"data-testid":`bedside-panel-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`span`,{className:`text-2xl`,"aria-hidden":!0,children:e.icon}),(0,l.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label})]}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary}),(0,l.jsx)(`div`,{className:`rounded-md border border-amber-300 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm space-y-2`,children:(0,l.jsx)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:`Weight-based calculators for this module run in the legacy viewer while the clinical data is verified for a direct React port. Open the legacy Bedside tab to use the full dosing flow.`})}),(0,l.jsx)(`a`,{href:`/#bedside`,className:ne+` inline-block`,children:`Open in legacy viewer`})]})}function oe(){let[e,t]=(0,c.useState)($[0].id),n=$.find(t=>t.id===e)??$[0];return(0,l.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-4`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Bedside`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Emergency and rapid-reference pediatric tools. Weight-based dosing throughout — always verify against institutional protocols.`})]}),(0,l.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`bedside-subnav`,children:$.map(n=>(0,l.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(e===n.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`bedside-pill-`+n.id,children:[(0,l.jsx)(`span`,{className:`mr-1`,"aria-hidden":!0,children:n.icon}),n.label]},n.id))}),(0,l.jsx)(ie,{}),te.has(n.id)?ee(n.id):(0,l.jsx)(ae,{pill:n})]})}export{oe as default}; \ No newline at end of file diff --git a/public/app/assets/ByVisitAge-jMcNy23H.js b/public/app/assets/ByVisitAge-jMcNy23H.js new file mode 100644 index 0000000..3a88629 --- /dev/null +++ b/public/app/assets/ByVisitAge-jMcNy23H.js @@ -0,0 +1,2 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{i as r,l as i}from"./index-C9wKWOAN.js";var a=e(t(),1);function o(e,t){if(t[e])return e;let n={newborn:`newborn`,"3-5d":`newborn`,"1mo":`1mo`,"2mo":`2mo`,"4mo":`4mo`,"6mo":`6mo`,"9mo":`9mo`,"12mo":`12mo`,"15mo":`15mo`,"18mo":`18mo`,"24mo":`24mo`,"30mo":`30mo`,"3y":`3y`,"4y":`4y`,"5y":`5y`,"6y":`6y_to_10y`,"7y":`6y_to_10y`,"8y":`6y_to_10y`,"9y":`6y_to_10y`,"10y":`6y_to_10y`,"11y":`11y_to_14y`,"12y":`11y_to_14y`,"13y":`11y_to_14y`,"14y":`11y_to_14y`,"15y":`15y_to_21y`,"16y":`15y_to_21y`,"17y":`15y_to_21y`,"18y":`15y_to_21y`,"19y":`15y_to_21y`,"20y":`15y_to_21y`,"21y":`15y_to_21y`}[e];return n&&t[n]?n:null}function s(e,t){if(t[e])return e;let n={newborn:`newborn`,"3-5d":`newborn`,"1mo":`1mo`,"2mo":`2mo`,"4mo":`4mo`,"6mo":`6mo`,"9mo":`9mo`,"12mo":`12mo`,"15mo":`15mo`,"18mo":`18mo`,"24mo":`24mo`,"30mo":`30mo`,"3y":`3y_to_5y`,"4y":`3y_to_5y`,"5y":`3y_to_5y`,"6y":`6y_to_10y`,"7y":`6y_to_10y`,"8y":`6y_to_10y`,"9y":`6y_to_10y`,"10y":`6y_to_10y`,"11y":`11y_to_14y`,"12y":`11y_to_14y`,"13y":`11y_to_14y`,"14y":`11y_to_14y`,"15y":`15y_to_21y`,"16y":`15y_to_21y`,"17y":`15y_to_21y`,"18y":`15y_to_21y`,"19y":`15y_to_21y`,"20y":`15y_to_21y`,"21y":`15y_to_21y`}[e];return n&&t[n]?n:null}function c(e){let t=(e||``).toLowerCase();return t.includes(`absent / integrated`)||t===`absent`||t.includes(`integrated`)||t.includes(`present`)&&t.includes(`lifelong`)?`#059669`:t.includes(`present`)||t.includes(`peak`)?`#2563eb`:t.includes(`emerging`)?`#7c3aed`:t.includes(`fading`)||t.includes(`transition`)?`#d97706`:t.includes(`down-going`)?`#059669`:t.includes(`up-going`)?`#d97706`:t.includes(`2+`)?`#2563eb`:`#475569`}function l(e){return e?typeof e==`object`?e.status:e:``}var u=n(),d={maternalDepression:`Maternal/Caregiver Depression Screen (Edinburgh/PHQ)`,developmentalScreening:`Developmental Screening (ASQ / PEDS)`,autismScreening:`Autism Screening (M-CHAT-R)`,developmentalSurveillance:`Developmental Surveillance`,behavioralScreening:`Social-Emotional/Behavioral Screening (ASQ:SE)`,tobaccoAlcoholDrugs:`Tobacco / Alcohol / Drug Use Screening (CRAFFT/AUDIT)`,depressionSuicideRisk:`Depression & Suicide Risk Screening (PHQ-A)`},f={newbornBlood:`Newborn Blood Spot Screening (NBS)`,newbornBilirubin:`Newborn Bilirubin (TcB or TSB)`,criticalCHD:`Critical CHD Screening (Pulse Ox)`,immunization:`Immunizations Review & Update`,anemia:`Anemia Screening (Hgb/Hct)`,lead:`Lead Exposure Risk / Blood Lead Level`,tuberculosis:`Tuberculosis / Latent TB Risk Assessment`,dyslipidemia:`Dyslipidemia Screening (lipid panel)`,sti:`STI Screening (gonorrhea / chlamydia / syphilis)`,hiv:`HIV Screening`,hepB:`Hepatitis B Screening (HBsAg)`,hepC:`Hepatitis C Screening (anti-HCV)`,suddenCardiacArrest:`Sudden Cardiac Arrest Risk Assessment`,cervicalDysplasia:`Cervical Dysplasia Screening (Pap smear)`},p={lengthHeight:`Length / Height`,weight:`Weight`,headCircumference:`Head Circumference`,weightForLength:`Weight-for-Length`,bmi:`BMI`,bloodPressure:`Blood Pressure`},m={assessment:`Oral Health Risk Assessment`,fluorideVarnish:`Fluoride Varnish Application`,fluorideSupplementation:`Fluoride Supplementation (if water <0.6 ppm)`},h={vision:`Vision Screening`,hearing:`Hearing Screening`},g={prenatal:`Prenatal`,infancy:`Infancy (0–12 mo)`,earlyChildhood:`Early Childhood (1–5 y)`,middleChildhood:`Middle Childhood (6–11 y)`,adolescence:`Adolescence (11–21 y)`},_=`ped_visit_statuses`,v=[`Given`,`Refused`,`Deferred`,`Already Done`],y=[`Done`,`Refused`,`Not Due / N/A`];function b(){try{let e=localStorage.getItem(_);return e?JSON.parse(e):{}}catch{return{}}}function x(e){try{localStorage.setItem(_,JSON.stringify(e))}catch{}}function S(e){return(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.statuses.map(t=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>e.onPick(e.current===t?``:t),className:`text-[10px] uppercase tracking-wider px-2 py-0.5 rounded border `+(e.current===t?`bg-primary text-primary-foreground border-primary`:`bg-background border-border hover:bg-muted`),children:t},t))})}function C(e){return(0,u.jsxs)(`div`,{className:`rounded-lg border border-border bg-card overflow-hidden`,children:[(0,u.jsxs)(`div`,{className:`px-4 py-2 bg-muted/40 flex items-center gap-2 text-sm font-semibold`,children:[(0,u.jsx)(`span`,{children:e.icon}),(0,u.jsx)(`span`,{children:e.title})]}),(0,u.jsx)(`div`,{className:`p-3 space-y-2`,children:e.children})]})}function w(){let{data:e,isLoading:t,error:n}=i({queryKey:[`schedule-data`],queryFn:()=>r.get(`/api/schedule-data`)}),[_,y]=(0,a.useState)(`newborn`),[w,E]=(0,a.useState)(()=>b()),[D,O]=(0,a.useState)(null);(0,a.useEffect)(()=>{x(w)},[w]),(0,a.useEffect)(()=>{if(!e||!_)return;let t=e.visitAges.find(e=>e.id===_)?.label||_;try{sessionStorage.setItem(`ped_visit_age`,t)}catch{}},[e,_]);let k=(0,a.useMemo)(()=>{if(!e)return{};let t={};return e.visitAges.forEach(e=>{t[e.era]||(t[e.era]=[]),t[e.era].push(e)}),t},[e]);if(t)return(0,u.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading schedule…`});if(n)return(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:n.message});if(!e)return null;let A=e.periodicity[_],j=e.wellVisitCodes[_],M=o(_,e.growthReference),N=M?e.growthReference[M]:null,P=s(_,e.reflexesReference),F=P?e.reflexesReference[P]:null;function I(e,t){E(n=>{let r=n[e],i=typeof r==`object`&&r?r.note:``;return{...n,[e]:{status:t,note:i}}})}function L(e,t){E(n=>{let r=n[e],i=typeof r==`object`&&r?r.status:r||``;return{...n,[e]:{status:i,note:t}}})}function R(){E(e=>{let t={...e};return Object.keys(t).forEach(e=>{e.indexOf(_+`.`)===0&&delete t[e]}),t}),O(`Visit statuses cleared`)}function z(){if(!e)return;let t=[],n=e.visitAges.find(e=>e.id===_)?.label||_;t.push(`Visit: `+n),Object.keys(w).forEach(e=>{if(e.indexOf(_+`.`)!==0)return;let n=w[e],r=typeof n==`object`?n.status:n,i=typeof n==`object`?n.note:``;if(!r)return;let a=e.substring(_.length+1);t.push(` - `+a+`: `+r+(i?` (`+i+`)`:``))});try{sessionStorage.setItem(`wv-byvisit-statuses`,t.join(` +`)),O(`Copied to Visit Note — switch tabs to use it`)}catch{O(`Session storage unavailable`)}}function B(e,t,n=[]){return e?Object.keys(e).filter(e=>!n.includes(e)).filter(t=>e[t]===`dot`||e[t]===`range`||e[t]===`arrow`).map(n=>({key:n,label:t[n]||n,status:e[n]})):[]}let V=A?.measurements?Object.keys(A.measurements).filter(e=>A.measurements[e]===`dot`||A.measurements[e]===`range`):[],H=B(A?.sensory,h),U=B(A?.developmental,d),W=B(A?.procedures,f,[`immunization`]),G=B(A?.oralHealth,m);return(0,u.jsxs)(`div`,{className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`flex items-end gap-3 flex-wrap`,children:[(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Select visit age`}),(0,u.jsx)(`select`,{className:`rounded-md border border-input bg-background px-3 py-2 text-sm min-w-[260px]`,value:_,onChange:e=>y(e.target.value),"data-testid":`byvisit-select`,children:Object.keys(k).map(e=>(0,u.jsx)(`optgroup`,{label:g[e]||e,children:k[e].map(e=>(0,u.jsx)(`option`,{value:e.id,children:e.label},e.id))},e))})]}),(0,u.jsx)(`button`,{type:`button`,onClick:z,className:`rounded-md bg-primary text-primary-foreground px-3 py-2 text-xs font-semibold`,children:`📋 Copy to Visit Note`}),(0,u.jsx)(`button`,{type:`button`,onClick:R,className:`rounded-md border border-border bg-background px-3 py-2 text-xs text-destructive`,children:`↻ Clear this visit`}),D&&(0,u.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D})]}),!A&&(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No data for this visit.`}),A&&j&&(0,u.jsxs)(C,{icon:`🧾`,title:`Billing codes`,children:[(0,u.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[(0,u.jsxs)(`span`,{children:[(0,u.jsx)(`span`,{className:`text-xs text-muted-foreground mr-1`,children:`ICD-10:`}),(0,u.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded`,children:j.icd10})]}),(0,u.jsxs)(`span`,{children:[(0,u.jsx)(`span`,{className:`text-xs text-muted-foreground mr-1`,children:`CPT:`}),(0,u.jsx)(`code`,{className:`bg-muted px-1.5 py-0.5 rounded`,children:j.cpt})]})]}),(0,u.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:j.description})]}),V.length>0&&(0,u.jsx)(C,{icon:`📏`,title:`Measurements`,children:(0,u.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(e=>(0,u.jsxs)(`span`,{className:`text-xs px-2 py-1 rounded bg-muted`,children:[p[e]||e,A.measurements[e]===`range`?` (range)`:``]},e))})}),A?.vaccines&&A.vaccines.length>0&&(0,u.jsx)(C,{icon:`💉`,title:`Vaccines due`,children:(0,u.jsx)(`div`,{className:`space-y-2`,children:A.vaccines.map(t=>{let n=`vax_`+t.vaccine+`_d`+(t.dose||``),r=_+`.`+n,i=l(w[r]);return(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,u.jsxs)(`span`,{className:`flex-1 min-w-[200px]`,children:[(0,u.jsx)(`strong`,{children:e.vaccineFullNames[t.vaccine]||t.vaccine}),t.dose&&(0,u.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`Dose `,t.dose]}),t.notes&&(0,u.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.notes})]}),(0,u.jsx)(S,{statuses:v,current:i,onPick:e=>I(r,e)})]},n)})})}),H.length>0&&(0,u.jsx)(T,{title:`Sensory screens`,icon:`👁`,items:H,visitId:_,statuses:w,setStatus:I,setNote:L}),U.length>0&&(0,u.jsx)(T,{title:`Developmental / behavioral screens`,icon:`🧠`,items:U,visitId:_,statuses:w,setStatus:I,setNote:L}),W.length>0&&(0,u.jsx)(T,{title:`Labs & procedures`,icon:`🧪`,items:W,visitId:_,statuses:w,setStatus:I,setNote:L}),G.length>0&&(0,u.jsx)(T,{title:`Oral health`,icon:`🦷`,items:G,visitId:_,statuses:w,setStatus:I,setNote:L}),N&&(0,u.jsxs)(C,{icon:`📈`,title:`Expected growth`,children:[(0,u.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[N.weight&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:`⚖️ Weight: `}),N.weight]}),N.length&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:`📏 Length/Height: `}),N.length]}),N.headCirc&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:`🧠 Head circumference: `}),N.headCirc]})]}),N.feeding&&N.feeding.length>0&&(0,u.jsxs)(`div`,{className:`pt-2 border-t border-border mt-2`,children:[(0,u.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-1`,children:`🍽 Feeding & nutrition`}),(0,u.jsx)(`ul`,{className:`list-disc pl-5 text-sm space-y-0.5`,children:N.feeding.map((e,t)=>(0,u.jsx)(`li`,{children:e},t))})]})]}),F&&F.reflexes.length>0&&(0,u.jsxs)(C,{icon:`✋`,title:`Expected reflexes`,children:[F.intro&&(0,u.jsx)(`div`,{className:`text-xs text-muted-foreground mb-2`,children:F.intro}),(0,u.jsx)(`div`,{className:`space-y-2`,children:F.reflexes.map((e,t)=>{let n=c(e.status);return(0,u.jsxs)(`div`,{className:`text-sm`,children:[(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,u.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,u.jsx)(`span`,{className:`text-[11px] font-semibold px-2 py-0.5 rounded-full border`,style:{backgroundColor:n+`1a`,color:n,borderColor:n+`66`},children:e.status})]}),(0,u.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.note})]},t)})})]}),N?.bmiClassification&&e.bmiClassification?.categories&&(0,u.jsxs)(C,{icon:`⚖`,title:`BMI / weight classification (AAP 2023)`,children:[(0,u.jsx)(`div`,{className:`space-y-1`,children:e.bmiClassification.categories.map((e,t)=>(0,u.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_2fr] gap-2 text-sm border-l-4 pl-2 py-1`,style:{borderLeftColor:e.color},children:[(0,u.jsx)(`strong`,{children:e.label}),(0,u.jsx)(`span`,{className:`text-muted-foreground`,children:e.range}),(0,u.jsx)(`span`,{children:e.action})]},t))}),e.bmiClassification.notes&&(0,u.jsxs)(`div`,{className:`text-xs text-muted-foreground pt-1`,children:[`ℹ︎ `,e.bmiClassification.notes]})]}),A?.notes&&(0,u.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 p-3 text-sm`,children:[`ℹ︎ `,A.notes]})]})}function T(e){return(0,u.jsx)(C,{icon:e.icon,title:e.title,children:(0,u.jsx)(`div`,{className:`space-y-2`,children:e.items.map(t=>{let n=e.visitId+`.`+t.key,r=e.statuses[n],i=l(r),a=typeof r==`object`&&r?r.note:``;return(0,u.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,u.jsx)(`span`,{className:`flex-1 min-w-[200px]`,children:t.label}),(0,u.jsx)(S,{statuses:y,current:i,onPick:t=>e.setStatus(n,t)}),i===`Refused`||i===`Done`?(0,u.jsx)(`input`,{type:`text`,value:a,onChange:t=>e.setNote(n,t.target.value),placeholder:`note (optional)`,className:`rounded-md border border-input bg-background px-2 py-1 text-xs flex-1 min-w-[160px]`}):null]},t.key)})})})}export{w as default}; \ No newline at end of file diff --git a/public/app/assets/Calculators-hFcuewWL.js b/public/app/assets/Calculators-BLZD2bUs.js similarity index 99% rename from public/app/assets/Calculators-hFcuewWL.js rename to public/app/assets/Calculators-BLZD2bUs.js index 96694cb..87d0f29 100644 --- a/public/app/assets/Calculators-hFcuewWL.js +++ b/public/app/assets/Calculators-BLZD2bUs.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{a as r,n as i,o as a,r as o,s,t as c}from"./fenton-Dvwmge1q.js";var l=e(t(),1),u={p95:{6:6,12:7.2,18:8.5,24:9.6,30:11.2,36:12.8,42:13.8,48:14.8,54:15.6,60:16.2,66:16.8,72:17.4,84:18,96:18.4,108:18.8,120:19},p75:{6:4.5,12:5.5,18:6.6,24:7.8,30:9.2,36:10.6,42:11.6,48:12.6,54:13.4,60:14,66:14.6,72:15,84:15.4,96:15.6,108:15.8,120:16},p40:{6:3,12:4,18:5,24:6.2,30:7.2,36:8.4,42:9.2,48:10,54:10.6,60:11.2,66:11.8,72:12.2,84:12.6,96:12.8,108:13,120:13.2}},d={12:8.5,13:8.7,14:8.9,15:9,16:9.2,17:9.4,18:9.6,19:9.8,20:9.9,21:10.1,22:10.3,23:10.4,24:10.6,25:10.8,26:10.9,27:11.1,28:11.3,29:11.4,30:11.6,31:11.7,32:11.9,33:12,34:12.2,35:12.3,36:12.5,37:12.6,38:12.8,39:12.9,40:13.1,41:13.2,42:13.4,43:13.5,44:13.6,45:13.8,46:13.9,47:14,48:14.2,49:14.3,50:14.4,51:14.5,52:14.7,53:14.8,54:14.9,55:15,56:15.1,57:15.3,58:15.4,59:15.5,60:15.6,61:15.7,62:15.8,63:15.9,64:16,65:16.1,66:16.2,67:16.3,68:16.4,69:16.5,70:16.6,71:16.7,72:16.8,73:16.9,74:17,75:17.1,76:17.2,77:17.3,78:17.4,79:17.5,80:17.5,81:17.6,82:17.7,83:17.8,84:17.8,85:17.9,86:18,87:18.1,88:18.1,89:18.2,90:18.3,91:18.3,92:18.4,93:18.5,94:18.5,95:18.6,96:18.6},f={12:9,13:9.2,14:9.4,15:9.6,16:9.8,17:9.9,18:10.1,19:10.3,20:10.5,21:10.6,22:10.8,23:11,24:11.2,25:11.3,26:11.5,27:11.7,28:11.8,29:12,30:12.1,31:12.3,32:12.5,33:12.6,34:12.8,35:12.9,36:13.1,37:13.2,38:13.4,39:13.5,40:13.7,41:13.8,42:13.9,43:14.1,44:14.2,45:14.4,46:14.5,47:14.6,48:14.8,49:14.9,50:15,51:15.1,52:15.3,53:15.4,54:15.5,55:15.6,56:15.8,57:15.9,58:16,59:16.1,60:16.2,61:16.3,62:16.5,63:16.6,64:16.7,65:16.8,66:16.9,67:17,68:17.1,69:17.2,70:17.3,71:17.4,72:17.5,73:17.6,74:17.7,75:17.8,76:17.9,77:17.9,78:18,79:18.1,80:18.2,81:18.3,82:18.4,83:18.4,84:18.5,85:18.6,86:18.7,87:18.8,88:18.8,89:18.9,90:19,91:19,92:19.1,93:19.2,94:19.2,95:19.3,96:19.3},p={12:9.6,13:9.8,14:9.9,15:10.1,16:10.3,17:10.5,18:10.7,19:10.8,20:11,21:11.2,22:11.4,23:11.5,24:11.7,25:11.9,26:12.1,27:12.2,28:12.4,29:12.5,30:12.7,31:12.9,32:13,33:13.2,34:13.3,35:13.5,36:13.6,37:13.8,38:13.9,39:14.1,40:14.2,41:14.4,42:14.5,43:14.7,44:14.8,45:15,46:15.1,47:15.2,48:15.4,49:15.5,50:15.6,51:15.8,52:15.9,53:16,54:16.1,55:16.3,56:16.4,57:16.5,58:16.6,59:16.7,60:16.9,61:17,62:17.1,63:17.2,64:17.3,65:17.4,66:17.5,67:17.6,68:17.7,69:17.8,70:17.9,71:18,72:18.1,73:18.2,74:18.3,75:18.4,76:18.5,77:18.6,78:18.7,79:18.8,80:18.9,81:19,82:19,83:19.1,84:19.2,85:19.3,86:19.4,87:19.4,88:19.5,89:19.6,90:19.7,91:19.7,92:19.8,93:19.9,94:19.9,95:20,96:20},m={12:10.1,13:10.3,14:10.5,15:10.7,16:10.8,17:11,18:11.2,19:11.4,20:11.6,21:11.7,22:11.9,23:12.1,24:12.3,25:12.4,26:12.6,27:12.8,28:12.9,29:13.1,30:13.3,31:13.4,32:13.6,33:13.8,34:13.9,35:14.1,36:14.2,37:14.4,38:14.5,39:14.7,40:14.8,41:15,42:15.1,43:15.3,44:15.4,45:15.6,46:15.7,47:15.8,48:16,49:16.1,50:16.2,51:16.4,52:16.5,53:16.6,54:16.8,55:16.9,56:17,57:17.1,58:17.3,59:17.4,60:17.5,61:17.6,62:17.7,63:17.8,64:17.9,65:18.1,66:18.2,67:18.3,68:18.4,69:18.5,70:18.6,71:18.7,72:18.8,73:18.9,74:19,75:19.1,76:19.2,77:19.3,78:19.4,79:19.5,80:19.5,81:19.6,82:19.7,83:19.8,84:19.9,85:20,86:20,87:20.1,88:20.2,89:20.3,90:20.3,91:20.4,92:20.5,93:20.6,94:20.6,95:20.7,96:20.7},h={12:10.6,13:10.8,14:11,15:11.2,16:11.4,17:11.6,18:11.8,19:11.9,20:12.1,21:12.3,22:12.5,23:12.7,24:12.8,25:13,26:13.2,27:13.3,28:13.5,29:13.7,30:13.8,31:14,32:14.2,33:14.3,34:14.5,35:14.7,36:14.8,37:15,38:15.1,39:15.3,40:15.4,41:15.6,42:15.7,43:15.9,44:16,45:16.2,46:16.3,47:16.4,48:16.6,49:16.7,50:16.8,51:17,52:17.1,53:17.2,54:17.4,55:17.5,56:17.6,57:17.8,58:17.9,59:18,60:18.1,61:18.2,62:18.4,63:18.5,64:18.6,65:18.7,66:18.8,67:18.9,68:19,69:19.1,70:19.2,71:19.3,72:19.5,73:19.6,74:19.7,75:19.7,76:19.8,77:19.9,78:20,79:20.1,80:20.2,81:20.3,82:20.4,83:20.5,84:20.6,85:20.6,86:20.7,87:20.8,88:20.9,89:21,90:21,91:21.1,92:21.2,93:21.3,94:21.3,95:21.4,96:21.5},g={12:11.2,13:11.3,14:11.5,15:11.7,16:11.9,17:12.1,18:12.3,19:12.5,20:12.7,21:12.8,22:13,23:13.2,24:13.4,25:13.6,26:13.7,27:13.9,28:14.1,29:14.2,30:14.4,31:14.6,32:14.7,33:14.9,34:15.1,35:15.2,36:15.4,37:15.6,38:15.7,39:15.9,40:16,41:16.2,42:16.3,43:16.5,44:16.6,45:16.8,46:16.9,47:17.1,48:17.2,49:17.4,50:17.5,51:17.6,52:17.8,53:17.9,54:18.1,55:18.2,56:18.3,57:18.5,58:18.6,59:18.7,60:18.9,61:19,62:19.1,63:19.3,64:19.4,65:19.5,66:19.6,67:19.7,68:19.9,69:20,70:20.1,71:20.2,72:20.3,73:20.4,74:20.5,75:20.6,76:20.7,77:20.8,78:20.9,79:21,80:21.1,81:21.2,82:21.3,83:21.4,84:21.5,85:21.5,86:21.6,87:21.7,88:21.8,89:21.9,90:21.9,91:22,92:22.1,93:22.2,94:22.2,95:22.3,96:22.3},_={12:6.9,13:7.1,14:7.2,15:7.4,16:7.6,17:7.7,18:7.9,19:8.1,20:8.2,21:8.4,22:8.6,23:8.7,24:8.9,25:9,26:9.2,27:9.3,28:9.5,29:9.6,30:9.8,31:9.9,32:10.1,33:10.2,34:10.3,35:10.5,36:10.6,37:10.8,38:10.9,39:11,40:11.2,41:11.3,42:11.4,43:11.5,44:11.7,45:11.8,46:11.9,47:12,48:12.2,49:12.3,50:12.4,51:12.5,52:12.6,53:12.7,54:12.8,55:13,56:13.1,57:13.2,58:13.3,59:13.4,60:13.5,61:13.6,62:13.7,63:13.8,64:13.9,65:14,66:14.1,67:14.2,68:14.2,69:14.3,70:14.4,71:14.5,72:14.6,73:14.7,74:14.8,75:14.8,76:14.9,77:15,78:15.1,79:15.1,80:15.2,81:15.3,82:15.3,83:15.4,84:15.5,85:15.5,86:15.6,87:15.7,88:15.7,89:15.8,90:15.8,91:15.9,92:15.9,93:16,94:16.1,95:16.1,96:16.1},v={12:7.4,13:7.6,14:7.8,15:8,16:8.1,17:8.3,18:8.5,19:8.6,20:8.8,21:9,22:9.1,23:9.3,24:9.4,25:9.6,26:9.8,27:9.9,28:10.1,29:10.2,30:10.4,31:10.5,32:10.7,33:10.8,34:11,35:11.1,36:11.2,37:11.4,38:11.5,39:11.7,40:11.8,41:11.9,42:12.1,43:12.2,44:12.3,45:12.5,46:12.6,47:12.7,48:12.8,49:13,50:13.1,51:13.2,52:13.3,53:13.4,54:13.5,55:13.7,56:13.8,57:13.9,58:14,59:14.1,60:14.2,61:14.3,62:14.4,63:14.5,64:14.6,65:14.7,66:14.8,67:14.9,68:15,69:15.1,70:15.2,71:15.3,72:15.4,73:15.4,74:15.5,75:15.6,76:15.7,77:15.8,78:15.8,79:15.9,80:16,81:16.1,82:16.1,83:16.2,84:16.3,85:16.4,86:16.4,87:16.5,88:16.6,89:16.6,90:16.7,91:16.7,92:16.8,93:16.8,94:16.9,95:17,96:17},y={12:8,13:8.1,14:8.3,15:8.5,16:8.7,17:8.9,18:9,19:9.2,20:9.4,21:9.5,22:9.7,23:9.9,24:10,25:10.2,26:10.4,27:10.5,28:10.7,29:10.8,30:11,31:11.1,32:11.3,33:11.4,34:11.6,35:11.7,36:11.9,37:12,38:12.2,39:12.3,40:12.4,41:12.6,42:12.7,43:12.9,44:13,45:13.1,46:13.2,47:13.4,48:13.5,49:13.6,50:13.8,51:13.9,52:14,53:14.1,54:14.2,55:14.4,56:14.5,57:14.6,58:14.7,59:14.8,60:14.9,61:15,62:15.1,63:15.2,64:15.3,65:15.4,66:15.5,67:15.6,68:15.7,69:15.8,70:15.9,71:16,72:16.1,73:16.2,74:16.3,75:16.4,76:16.5,77:16.6,78:16.6,79:16.7,80:16.8,81:16.9,82:17,83:17,84:17.1,85:17.2,86:17.2,87:17.3,88:17.4,89:17.4,90:17.5,91:17.6,92:17.6,93:17.7,94:17.8,95:17.8,96:17.9},b={12:8.5,13:8.6,14:8.8,15:9,16:9.2,17:9.4,18:9.5,19:9.7,20:9.9,21:10,22:10.2,23:10.4,24:10.5,25:10.7,26:10.8,27:11,28:11.2,29:11.3,30:11.5,31:11.6,32:11.8,33:11.9,34:12.1,35:12.2,36:12.4,37:12.5,38:12.7,39:12.8,40:12.9,41:13.1,42:13.2,43:13.3,44:13.5,45:13.6,46:13.7,47:13.9,48:14,49:14.1,50:14.2,51:14.4,52:14.5,53:14.6,54:14.7,55:14.8,56:14.9,57:15.1,58:15.2,59:15.3,60:15.4,61:15.5,62:15.6,63:15.7,64:15.8,65:15.9,66:16,67:16.1,68:16.2,69:16.3,70:16.4,71:16.5,72:16.6,73:16.6,74:16.7,75:16.8,76:16.9,77:17,78:17.1,79:17.1,80:17.2,81:17.3,82:17.4,83:17.4,84:17.5,85:17.6,86:17.6,87:17.7,88:17.8,89:17.8,90:17.9,91:18,92:18,93:18.1,94:18.1,95:18.2,96:18.2},x={12:16.4,13:16.5,14:16.6,15:16.8,16:16.9,17:17,18:17.2,19:17.3,20:17.4,21:17.5,22:17.7,23:17.8,24:17.9,25:18,26:18.2,27:18.3,28:18.4,29:18.5,30:18.7,31:18.8,32:18.9,33:19,34:19.1,35:19.2,36:19.4,37:19.5,38:19.6,39:19.7,40:19.8,41:19.9,42:20,43:20.1,44:20.2,45:20.3,46:20.5,47:20.6,48:20.7,49:20.8,50:20.9,51:21,52:21.1,53:21.2,54:21.3,55:21.4,56:21.5,57:21.6,58:21.7,59:21.7,60:21.8,61:21.9,62:22,63:22.1,64:22.2,65:22.3,66:22.4,67:22.5,68:22.6,69:22.6,70:22.7,71:22.8,72:22.9,73:23,74:23.1,75:23.1,76:23.2,77:23.3,78:23.4,79:23.4,80:23.5,81:23.6,82:23.7,83:23.7,84:23.8,85:23.9,86:23.9,87:24,88:24.1,89:24.1,90:24.2,91:24.3,92:24.3,93:24.4,94:24.4,95:24.5,96:24.5},S={12:17.5,13:17.7,14:17.8,15:17.9,16:18.1,17:18.2,18:18.3,19:18.5,20:18.6,21:18.7,22:18.9,23:19,24:19.1,25:19.2,26:19.4,27:19.5,28:19.6,29:19.7,30:19.9,31:20,32:20.1,33:20.2,34:20.4,35:20.5,36:20.6,37:20.7,38:20.8,39:20.9,40:21,41:21.2,42:21.3,43:21.4,44:21.5,45:21.6,46:21.7,47:21.8,48:21.9,49:22,50:22.1,51:22.2,52:22.3,53:22.4,54:22.5,55:22.6,56:22.7,57:22.8,58:22.9,59:23,60:23.1,61:23.2,62:23.2,63:23.3,64:23.4,65:23.5,66:23.6,67:23.7,68:23.8,69:23.8,70:23.9,71:24,72:24.1,73:24.1,74:24.2,75:24.3,76:24.4,77:24.4,78:24.5,79:24.6,80:24.6,81:24.7,82:24.8,83:24.8,84:24.9,85:25,86:25,87:25.1,88:25.2,89:25.2,90:25.3,91:25.3,92:25.4,93:25.4,94:25.5,95:25.5,96:25.5},C={12:18.7,13:18.8,14:18.9,15:19.1,16:19.2,17:19.4,18:19.5,19:19.6,20:19.8,21:19.9,22:20.1,23:20.2,24:20.3,25:20.5,26:20.6,27:20.7,28:20.8,29:21,30:21.1,31:21.2,32:21.3,33:21.5,34:21.6,35:21.7,36:21.8,37:21.9,38:22.1,39:22.2,40:22.3,41:22.4,42:22.5,43:22.6,44:22.7,45:22.8,46:22.9,47:23,48:23.1,49:23.2,50:23.3,51:23.4,52:23.5,53:23.6,54:23.7,55:23.8,56:23.9,57:24,58:24.1,59:24.2,60:24.3,61:24.4,62:24.5,63:24.5,64:24.6,65:24.7,66:24.8,67:24.9,68:24.9,69:25,70:25.1,71:25.2,72:25.2,73:25.3,74:25.4,75:25.5,76:25.5,77:25.6,78:25.7,79:25.7,80:25.8,81:25.8,82:25.9,83:26,84:26,85:26.1,86:26.1,87:26.2,88:26.2,89:26.3,90:26.3,91:26.4,92:26.4,93:26.5,94:26.5,95:26.5,96:26.6},w={12:19.7,13:19.9,14:20,15:20.1,16:20.3,17:20.4,18:20.6,19:20.7,20:20.8,21:21,22:21.1,23:21.2,24:21.4,25:21.5,26:21.6,27:21.7,28:21.9,29:22,30:22.1,31:22.2,32:22.3,33:22.4,34:22.6,35:22.7,36:22.8,37:22.9,38:23,39:23.1,40:23.2,41:23.3,42:23.4,43:23.5,44:23.6,45:23.7,46:23.8,47:23.9,48:24,49:24.1,50:24.2,51:24.3,52:24.4,53:24.5,54:24.6,55:24.7,56:24.7,57:24.8,58:24.9,59:25,60:25.1,61:25.2,62:25.2,63:25.3,64:25.4,65:25.5,66:25.5,67:25.6,68:25.7,69:25.7,70:25.8,71:25.9,72:25.9,73:26,74:26,75:26.1,76:26.2,77:26.2,78:26.3,79:26.3,80:26.4,81:26.4,82:26.5,83:26.5,84:26.6,85:26.6,86:26.7,87:26.7,88:26.7,89:26.8,90:26.8,91:26.9,92:26.9,93:26.9,94:27,95:27,96:27},T={12:14.6,13:14.8,14:14.9,15:15,16:15.1,17:15.3,18:15.4,19:15.5,20:15.6,21:15.8,22:15.9,23:16,24:16.1,25:16.2,26:16.3,27:16.4,28:16.5,29:16.6,30:16.8,31:16.9,32:17,33:17.1,34:17.2,35:17.3,36:17.4,37:17.5,38:17.6,39:17.7,40:17.7,41:17.8,42:17.9,43:18,44:18.1,45:18.2,46:18.3,47:18.4,48:18.5,49:18.5,50:18.6,51:18.7,52:18.8,53:18.9,54:18.9,55:19,56:19.1,57:19.2,58:19.2,59:19.3,60:19.4,61:19.4,62:19.5,63:19.6,64:19.6,65:19.7,66:19.8,67:19.8,68:19.9,69:19.9,70:20,71:20.1,72:20.1,73:20.2,74:20.2,75:20.3,76:20.3,77:20.4,78:20.4,79:20.5,80:20.5,81:20.6,82:20.6,83:20.6,84:20.7,85:20.7,86:20.8,87:20.8,88:20.8,89:20.9,90:20.9,91:20.9,92:21,93:21,94:21,95:21.1,96:21.1},ee={12:15.2,13:15.3,14:15.4,15:15.6,16:15.7,17:15.8,18:15.9,19:16.1,20:16.2,21:16.3,22:16.4,23:16.5,24:16.6,25:16.8,26:16.9,27:17,28:17.1,29:17.2,30:17.3,31:17.4,32:17.5,33:17.6,34:17.7,35:17.8,36:17.9,37:18,38:18.1,39:18.2,40:18.3,41:18.4,42:18.5,43:18.6,44:18.7,45:18.8,46:18.9,47:19,48:19.1,49:19.2,50:19.2,51:19.3,52:19.4,53:19.5,54:19.6,55:19.7,56:19.7,57:19.8,58:19.9,59:20,60:20.1,61:20.1,62:20.2,63:20.3,64:20.3,65:20.4,66:20.5,67:20.6,68:20.6,69:20.7,70:20.8,71:20.8,72:20.9,73:20.9,74:21,75:21.1,76:21.1,77:21.2,78:21.2,79:21.3,80:21.4,81:21.4,82:21.5,83:21.5,84:21.6,85:21.6,86:21.7,87:21.7,88:21.8,89:21.8,90:21.9,91:21.9,92:22,93:22,94:22,95:22.1,96:22.1},te={12:15.7,13:15.9,14:16,15:16.1,16:16.2,17:16.4,18:16.5,19:16.6,20:16.7,21:16.8,22:17,23:17.1,24:17.2,25:17.3,26:17.4,27:17.5,28:17.7,29:17.8,30:17.9,31:18,32:18.1,33:18.2,34:18.3,35:18.4,36:18.5,37:18.6,38:18.7,39:18.8,40:18.9,41:19,42:19.1,43:19.2,44:19.3,45:19.4,46:19.5,47:19.6,48:19.7,49:19.8,50:19.9,51:20,52:20.1,53:20.1,54:20.2,55:20.3,56:20.4,57:20.5,58:20.6,59:20.7,60:20.7,61:20.8,62:20.9,63:21,64:21.1,65:21.1,66:21.2,67:21.3,68:21.4,69:21.4,70:21.5,71:21.6,72:21.7,73:21.7,74:21.8,75:21.9,76:21.9,77:22,78:22.1,79:22.1,80:22.2,81:22.3,82:22.3,83:22.4,84:22.5,85:22.5,86:22.6,87:22.6,88:22.7,89:22.8,90:22.8,91:22.9,92:22.9,93:23,94:23,95:23.1,96:23.1},ne={12:16.3,13:16.4,14:16.5,15:16.6,16:16.7,17:16.9,18:17,19:17.1,20:17.2,21:17.3,22:17.4,23:17.6,24:17.7,25:17.8,26:17.9,27:18,28:18.1,29:18.2,30:18.3,31:18.4,32:18.5,33:18.7,34:18.8,35:18.9,36:19,37:19.1,38:19.2,39:19.3,40:19.4,41:19.5,42:19.6,43:19.7,44:19.8,45:19.9,46:19.9,47:20,48:20.1,49:20.2,50:20.3,51:20.4,52:20.5,53:20.6,54:20.7,55:20.8,56:20.8,57:20.9,58:21,59:21.1,60:21.2,61:21.3,62:21.3,63:21.4,64:21.5,65:21.6,66:21.7,67:21.7,68:21.8,69:21.9,70:22,71:22,72:22.1,73:22.2,74:22.2,75:22.3,76:22.4,77:22.5,78:22.5,79:22.6,80:22.7,81:22.7,82:22.8,83:22.8,84:22.9,85:23,86:23,87:23.1,88:23.1,89:23.2,90:23.3,91:23.3,92:23.4,93:23.4,94:23.5,95:23.5,96:23.5};function E(e,t){let n=Object.keys(e).map(Number).sort((e,t)=>e-t);if(t<=n[0])return e[n[0]];if(t>=n[n.length-1])return e[n[n.length-1]];for(let r=0;r=n[r]&&t<=n[r+1]){let i=(t-n[r])/(n[r+1]-n[r]);return e[n[r]]+i*(e[n[r+1]]-e[n[r]])}return e[n[0]]}function re(e,t){let n=E(u.p95,e),r=E(u.p75,e),i=E(u.p40,e),a;return a=t>=n?`High-Risk`:t>=r?`High-Intermediate`:t>=i?`Low-Intermediate`:`Low-Risk`,{p95:n,p75:r,p40:i,zone:a}}function ie(e,t){return t===`medium`?e===35?_:e===36?v:e===37?y:b:e===35?d:e===36?f:e===37?p:e===38?m:e===39?h:g}function ae(e,t){return t===`medium`?e===35?T:e===36?ee:e===37?te:ne:e===35?x:e===36?S:e===37?C:w}function D(e,t,n,r){let i=E(ie(e,r),t),a=E(ae(e,r),t),o;return o=n>=a?`Above Exchange`:n>=i?`Above Phototherapy`:`Below Phototherapy`,{photoThreshold:i,exchangeThreshold:a,status:o}}var O={male:{24:{L:-1.982374,M:16.5478,S:.080127},30:{L:-1.642107,M:16.2497,S:.075499},36:{L:-1.419991,M:16.0003,S:.072634},42:{L:-1.438165,M:15.7941,S:.071495},48:{L:-1.714869,M:15.6282,S:.071889},54:{L:-2.155348,M:15.5026,S:.073491},60:{L:-2.615166,M:15.4191,S:.075992},66:{L:-2.981797,M:15.3795,S:.079211},72:{L:-3.211705,M:15.3835,S:.083048},78:{L:-3.314769,M:15.429,S:.0874},84:{L:-3.323189,M:15.5129,S:.092131},90:{L:-3.270455,M:15.6317,S:.097082},96:{L:-3.183058,M:15.7823,S:.102091},102:{L:-3.079383,M:15.9617,S:.107013},108:{L:-2.971148,M:16.1671,S:.111721},114:{L:-2.865311,M:16.3961,S:.116113},120:{L:-2.765648,M:16.6461,S:.120112},126:{L:-2.673903,M:16.9151,S:.123664},132:{L:-2.59056,M:17.2009,S:.126735},138:{L:-2.51532,M:17.5014,S:.129309},144:{L:-2.447426,M:17.8146,S:.131389},150:{L:-2.385858,M:18.1387,S:.132991},156:{L:-2.329457,M:18.4718,S:.134141},162:{L:-2.277017,M:18.812,S:.13488},168:{L:-2.227362,M:19.1576,S:.135251},174:{L:-2.179426,M:19.5067,S:.135309},180:{L:-2.132345,M:19.8577,S:.13511},186:{L:-2.085574,M:20.2086,S:.134718},192:{L:-2.039015,M:20.5576,S:.134198},198:{L:-1.99315,M:20.9029,S:.13362},204:{L:-1.949135,M:21.2425,S:.133057},210:{L:-1.908831,M:21.5742,S:.132585},216:{L:-1.87467,M:21.8959,S:.132286},222:{L:-1.849323,M:22.2054,S:.132249},228:{L:-1.835138,M:22.5007,S:.132566},234:{L:-1.833401,M:22.7799,S:.133339},240:{L:-1.843581,M:23.0414,S:.134675}},female:{24:{L:-1.024497,M:16.388,S:.085026},30:{L:-1.534542,M:16.0059,S:.080932},36:{L:-2.096829,M:15.6992,S:.078605},42:{L:-2.618733,M:15.4647,S:.077904},48:{L:-3.018522,M:15.2985,S:.078713},54:{L:-3.2593,M:15.1961,S:.080904},60:{L:-3.350078,M:15.1519,S:.0843},66:{L:-3.325522,M:15.1606,S:.08868},72:{L:-3.225607,M:15.2169,S:.093803},78:{L:-3.084291,M:15.3161,S:.099427},84:{L:-2.926187,M:15.4536,S:.105325},90:{L:-2.76731,M:15.6252,S:.111295},96:{L:-2.617192,M:15.827,S:.117159},102:{L:-2.480952,M:16.0552,S:.122771},108:{L:-2.360921,M:16.3061,S:.128014},114:{L:-2.257782,M:16.5763,S:.132797},120:{L:-2.171296,M:16.8623,S:.137057},126:{L:-2.100749,M:17.161,S:.140754},132:{L:-2.045235,M:17.4691,S:.143868},138:{L:-2.003802,M:17.7836,S:.146399},144:{L:-1.975521,M:18.1015,S:.148361},150:{L:-1.95952,M:18.42,S:.149783},156:{L:-1.954978,M:18.7364,S:.150705},162:{L:-1.9611,M:19.0481,S:.151176},168:{L:-1.977074,M:19.3526,S:.151256},174:{L:-2.002014,M:19.6475,S:.15101},180:{L:-2.034893,M:19.9306,S:.150512},186:{L:-2.07446,M:20.1998,S:.149843},192:{L:-2.119157,M:20.4533,S:.14909},198:{L:-2.167045,M:20.6891,S:.148349},204:{L:-2.215738,M:20.9058,S:.147723},210:{L:-2.262382,M:21.1016,S:.147323},216:{L:-2.303688,M:21.2753,S:.147269},222:{L:-2.336038,M:21.4255,S:.147689},228:{L:-2.355678,M:21.5508,S:.148724},234:{L:-2.35898,M:21.6501,S:.150521},240:{L:-2.342797,M:21.7219,S:.153241}}};function k(e){let t=e<0?-1:1,n=Math.abs(e)/Math.sqrt(2),r=1/(1+.3275911*n);return .5*(1+t*(1-((((1.061405429*r+-1.453152027)*r+1.421413741)*r+-.284496736)*r+.254829592)*r*Math.exp(-n*n)))}function oe(e,t,n,r){let i;i=Math.abs(t)<.001?Math.log(e/n)/r:((e/n)**+t-1)/(t*r);let a=k(i);return{z:i,percentile:Math.round(a*1e4)/100}}function se(e,t,n){let r=1.645,i=Math.abs(n.L)<.001?n.M*Math.exp(n.S*r):n.M*(1+n.L*n.S*r)**(1/n.L),a=t/i*100;return e>=95?a>=140?{label:`Class 3 Severe Obesity`,color:`#7f1d1d`,bg:`#fecaca`,pctOf95:a,bmi95:i}:a>=120?{label:`Class 2 Severe Obesity`,color:`#dc2626`,bg:`#fee2e2`,pctOf95:a,bmi95:i}:{label:`Obese (Class 1)`,color:`#ef4444`,bg:`#fee2e2`,pctOf95:a,bmi95:i}:e>=85?{label:`Overweight`,color:`#f97316`,bg:`#ffedd5`,pctOf95:a,bmi95:i}:e>=5?{label:`Healthy Weight`,color:`#10b981`,bg:`#d1fae5`,pctOf95:a,bmi95:i}:{label:`Underweight`,color:`#f59e0b`,bg:`#fef3c7`,pctOf95:a,bmi95:i}}function ce(e,t,n,r){let i=e/(t/100)**2,a=Math.max(24,Math.min(240,n)),s=o(O[r],a),{z:c,percentile:l}=oe(i,s.L,s.M,s.S),u=se(l,i,s);return{bmi:i,z:c,percentile:l,L:s.L,M:s.M,S:s.S,classification:u}}var le=[1.07244896,1.051272912,1.041951175,1.012592236,.970541909,.921129988,.868221392,.81454413,.761957977,.711660228,.664323379,.620285102,.57955631,.54198094,.511429832,.482799937,.455521041,.429150288,.403351725,.377878239,.352555862,.327270297,.301955463,.276583851,.251158446,.225705996,.20027145,.174913356,.149700081,.12470671,.100012514,.075698881,.051847635,.02853967,.005853853,-.016133871,-.037351181,-.057729947,-.077206672,-.09572283,-.113225128,-.129665689,-.145002179,-.159197885,-.172221748,-.184048358,-.194660215,-.204030559,-.212174408,-.219069129,-.224722166,-.229140412,-.232335686,-.234324563,-.235128195,-.234772114,-.233286033,-.230703633,-.227062344,-.222403111,-.216770161,-.210210748,-.202774891,-.194515104,-.185486099,-.175744476,-.165348396,-.15435722,-.142831123,-.130830669,-.118416354,-.105648092,-.092584657,-.079283065,-.065797888,-.0521805,-.03847825,-.024733545,-.010982868,.002744306,.016426655,.030052231,.043619747,.05713988,.070636605,.08414848,.097729873,.111452039,.125404005,.13969316,.154445482,.169805275,.185934346,.203010488,.2212252,.240780542,.261885086,.284748919,.309577733,.336566048,.365889711,.397699038,.432104409,.46917993,.508943272,.551354277,.596307363,.643626542,.693062173,.744289752,.79691098,.85045728,.904395871,.958138449,1.011054559,1.062474568,1.111727029,1.158135105,1.201050821,1.239852328,1.274006058,1.303044695,1.326605954,1.344443447,1.356437773,1.362602695,1.363085725,1.358162799,1.348227142,1.333772923,1.315374704,1.293664024,1.269304678,1.242968236,1.21531127,1.186955477,1.158471522,1.130367088,1.103079209,1.076970655,1.052329922,1.029374161,1.008254396,.989062282,.971837799,.95657215,.94324228,.931767062,.922058291,.914012643,.907516917,.902452436,.898698641,.896143482,.894659668,.89413892,.894475371,.895569834,.897330209,.899671635,.902516442,.905793969,.909440266,.913397733,.91761471,.922045055,.926647697,.931386217,.93622842,.941145943,.94611388,.95111043,.956116576,.961115792,.966093766,.971038162,.975938391,.980785418,.985571579,.99029042,.994936555,.999505539,1.003993753,1.0083983,1.012716921,1.016947912,1.021090055,1.025142554,1.029104983,1.032977233,1.036759475,1.040452117,1.044055774,1.047571238,1.050999451,1.054341482,1.057598512,1.060771808,1.063862715,1.066872639,1.069803036,1.072655401,1.075431258,1.078132156,1.080759655,1.083315329,1.085800751,1.088217496,1.090567133,1.092851222,1.095071313,1.097228939,1.099325619,1.101362852,1.103342119,1.105264876,1.107132561,1.108046193],ue=[84.97555512,85.3973169,86.29026318,87.15714182,87.9960184,88.8055115,89.58476689,90.33341722,91.0515436,91.7396352,92.39854429,93.02945392,93.63382278,94.21335709,94.79643239,95.37391918,95.94692677,96.51644912,97.08337211,97.6484807,98.21246579,98.77593069,99.33939735,99.9033122,100.4680516,101.033927,101.6011898,102.1700358,102.7406094,103.3130077,103.8872839,104.4634511,105.0414853,105.6213287,106.2028921,106.7860583,107.3706841,107.9566031,108.5436278,109.1315521,109.7201531,110.3091934,110.8984228,111.4875806,112.0763967,112.6645943,113.2518902,113.8380006,114.4226317,115.0054978,115.5863089,116.1647782,116.7406221,117.3135622,117.8833259,118.4496481,119.0122722,119.5709513,120.1254495,120.6755427,121.22102,121.7616844,122.2973542,122.827864,123.3530652,123.8728276,124.38704,124.8956114,125.398472,125.895574,126.3868929,126.8724284,127.3522056,127.8262759,128.2947187,128.757642,129.2151839,129.6675143,130.1148354,130.5573839,130.995432,131.4292887,131.8593015,132.2858574,132.7093845,133.1303527,133.5492749,133.9667073,134.3832499,134.7995463,135.2162826,135.634186,136.0540223,136.4765925,136.9027281,137.3332846,137.7691339,138.2111552,138.6602228,139.1171933,139.5828898,140.0580848,140.5434787,141.0396832,141.5471945,142.0663731,142.59742,143.1403553,143.6949981,144.2609497,144.8375809,145.4240246,146.0191748,146.621692,147.2300177,147.8423918,148.4568879,149.0714413,149.6838943,150.2920328,150.8936469,151.4865636,152.0686985,152.6380955,153.1929631,153.7317031,154.2529332,154.755501,155.2384904,155.7012216,156.1432438,156.564323,156.9644258,157.3436995,157.7024507,158.0411233,158.3602756,158.6605588,158.9426964,159.2074654,159.455679,159.688172,159.9057871,160.1093647,160.299733,160.4776996,160.6440526,160.7995428,160.9448916,161.0807857,161.2078755,161.3267744,161.4380593,161.5422726,161.639917,161.7314645,161.8173534,161.8979913,161.9737558,162.0449969,162.1120386,162.17518,162.2346979,162.2908474,162.343864,162.3939652,162.4413513,162.4862071,162.5287029,162.5689958,162.6072309,162.6435418,162.6780519,162.7108751,162.7421168,162.7718741,162.8002371,162.8272889,162.8531067,162.8777619,162.9013208,162.9238449,162.9453912,162.9660131,162.9857599,163.0046776,163.0228094,163.0401953,163.0568727,163.0728768,163.0882404,163.1029943,163.1171673,163.1307866,163.1438776,163.1564644,163.1685697,163.1802146,163.1914194,163.202203,163.2125835,163.2225779,163.2322024,163.2414722,163.2504019,163.2590052,163.2672954,163.2752848,163.2829854,163.2904086,163.297565,163.304465,163.3111185,163.3175349,163.3237231,163.3296918,163.3354491,163.338251],de=[.040791394,.040859727,.041142161,.041349399,.041500428,.041610508,.041691761,.04175368,.041803562,.041846882,.041887626,.041928568,.041971514,.042017509,.042104522,.042199507,.042300333,.042405225,.042512706,.042621565,.042730809,.042839638,.042947412,.043053626,.043157889,.043259907,.043359463,.043456406,.043550638,.043642107,.043730791,.043816701,.043899867,.043980337,.044058171,.04413344,.044206218,.044276588,.044344632,.044410436,.044474084,.044535662,.044595254,.044652942,.044708809,.044762936,.044815402,.044866288,.044915672,.044963636,.045010259,.045055624,.045099817,.045142924,.045185036,.045226249,.045266662,.045306383,.045345524,.045384203,.045422551,.045460702,.045498803,.045537012,.045575495,.045614432,.045654016,.04569445,.045735953,.045778759,.045823114,.04586928,.045917535,.045968169,.04602149,.046077818,.046137487,.046200842,.04626824,.046340046,.046416629,.046498361,.046585611,.046678741,.046778099,.04688401,.046996769,.047116633,.047243801,.047378413,.047520521,.047670085,.047826946,.04799081,.048161228,.04833757,.048519011,.048704503,.048892759,.049082239,.049271137,.049457371,.049638596,.049812203,.049975355,.050125012,.050257992,.050371024,.050460835,.050524236,.050558224,.050560083,.050527494,.050458634,.050352269,.050207825,.050025434,.049805967,.049551023,.049262895,.048944504,.048599314,.048231224,.047844442,.047443362,.04703243,.046616026,.046198356,.04578335,.045374597,.044975281,.044588148,.044215488,.043859135,.04352048,.043200497,.042899776,.042618565,.042356812,.042114211,.041890247,.04168424,.041495379,.041322765,.041165437,.041022401,.040892651,.040775193,.040669052,.040573288,.040487005,.040409354,.040339537,.040276811,.040220488,.040169932,.040124562,.040083845,.040047295,.040014473,.03998498,.039958458,.039934584,.039913066,.039893644,.039876087,.039860185,.039845754,.039832629,.039820663,.039809725,.0397997,.039790485,.039781991,.039774136,.03976685,.03976007,.039753741,.039747815,.039742249,.039737004,.039732048,.039727352,.03972289,.03971864,.039714581,.039710697,.039706971,.039703391,.039699945,.039696623,.039693415,.039690313,.039687311,.039684402,.039681581,.039678842,.039676182,.039673596,.039671082,.039668635,.039666254,.039663936,.039661679,.039659481,.039657339,.039655252,.039653218,.039651237,.039649306,.039647424,.039645591,.039643804,.039642063,.039640367,.039638715,.039637105,.039636316],A=[.941523967,1.00720807,.837251351,.681492975,.538779654,.407697153,.286762453,.174489485,.069444521,-.029720564,-.124251789,-.215288396,-.30385434,-.390918369,-.254801167,-.125654535,-.00316735,.11291221,.222754969,.326530126,.42436156,.516353108,.602595306,.683170764,.758158406,.827636736,.891686306,.95039153,1.003830006,1.05213569,1.0953669,1.133652119,1.167104213,1.195845353,1.220004233,1.239715856,1.255121285,1.266367398,1.273606657,1.276996893,1.276701119,1.272887366,1.265728536,1.255402281,1.242090871,1.225981067,1.207263978,1.186140222,1.162796198,1.137442868,1.110286487,1.081536236,1.05140374,1.020102497,.987847213,.954853043,.921334742,.887505723,.85357703,.819756239,.786246296,.753244292,.720940222,.689515708,.659142731,.629997853,.602203984,.575908038,.55123134,.528279901,.507143576,.487895344,.470590753,.455267507,.441945241,.430625458,.421291648,.413909588,.408427813,.404778262,.402877077,.402625561,.40391127,.406609232,.410583274,.415687443,.421767514,.428662551,.436206531,.44423,.45256176,.461030578,.469466904,.477704608,.48558272,.492947182,.499652617,.505564115,.510559047,.514528903,.517381177,.519041285,.519454524,.518588072,.516433004,.513006312,.508352901,.502547502,.495696454,.487939275,.479449924,.470437652,.461147305,.451858946,.442886661,.434576385,.427302633,.421464027,.417477538,.415771438,.416777012,.420919142,.428606007,.440218167,.456097443,.476536014,.501766234,.531951655,.567179725,.607456565,.652704121,.702759868,.757379106,.816239713,.878947416,.945053486,1.014046108,1.085383319,1.158487278,1.232768816,1.307628899,1.382473225,1.456720479,1.529810247,1.601219573,1.670433444,1.736995571,1.800483802,1.860518777,1.916765525,1.968934444,2.016781776,2.060109658,2.098765817,2.132642948,2.16167779,2.185849904,2.205180153,2.219728869,2.2295937,2.234907144,2.235833767,2.232567138,2.2253265,2.214353232,2.199905902,2.182262864,2.161704969,2.138524662,2.113023423,2.085490286,2.0562195,2.025496648,1.993598182,1.960789092,1.927320937,1.89343024,1.859337259,1.825245107,1.791339209,1.757787065,1.724738292,1.692324905,1.660661815,1.629847495,1.599964788,1.571081817,1.543252982,1.516519998,1.490912963,1.466451429,1.44314546,1.420996665,1.399999187,1.380140651,1.361403047,1.343763564,1.327195355,1.311668242,1.297149359,1.283603728,1.270994782,1.25928483,1.248435461,1.23840791,1.229163362,1.220663228,1.212869374,1.20574431,1.199251356,1.19335477,1.188019859,1.183213059,1.178901998,1.175055543,1.171643828,1.16863827,1.167279219],j=[86.45220101,86.86160934,87.65247282,88.42326434,89.17549228,89.91040853,90.62907762,91.33242379,92.02127167,92.69637946,93.35846546,94.00822923,94.64636981,95.27359106,95.91474929,96.54734328,97.17191309,97.78897727,98.3990283,99.00254338,99.599977,100.191764,100.7783198,101.3600411,101.9373058,102.5104735,103.0798852,103.645864,104.208713,104.7687256,105.3261638,105.8812823,106.4343146,106.9854769,107.534968,108.0829695,108.6296457,109.1751441,109.7195954,110.2631136,110.8057967,111.3477265,111.8889694,112.4295761,112.9695827,113.5090108,114.0478678,114.5861486,115.1238315,115.6608862,116.1972691,116.732925,117.2677879,117.8017819,118.3348215,118.8668123,119.397652,119.9272309,120.455433,120.9821362,121.5072136,122.0305342,122.5519634,123.0713645,123.588599,124.1035312,124.6160161,125.1259182,125.6331012,126.1374319,126.6387804,127.1370217,127.6320362,128.1237104,128.6119383,129.096622,129.5776723,130.0550101,130.5285669,130.9982857,131.4641218,131.9260439,132.3840348,132.838092,133.2882291,133.7344759,134.1768801,134.6155076,135.0504433,135.4817925,135.9096813,136.3342577,136.7556923,137.1741794,137.5899378,138.0032114,138.4142703,138.8234114,139.2309592,139.6372663,140.042714,140.4477127,140.8527022,141.2581515,141.6645592,142.072452,142.4823852,142.8949403,143.3107241,143.7303663,144.1545167,144.5838414,145.0190192,145.4607359,145.9096784,146.3665278,146.8319513,147.3065929,147.7910635,148.2859294,148.7917006,149.3088178,149.8376391,150.3784267,150.9313331,151.4963887,152.0734897,152.6623878,153.2626819,153.8738124,154.495058,155.1255365,155.7642086,156.4098858,157.0612415,157.7168289,158.3750929,159.034399,159.6930501,160.3493168,161.0014586,161.6477515,162.2865119,162.9161202,163.535045,164.1418486,164.7352199,165.3139755,165.8770715,166.4236087,166.9528354,167.4641466,167.9570814,168.4313175,168.8866644,169.3230548,169.7405351,170.139255,170.5194567,170.881464,171.2256717,171.5525345,171.8625576,172.1562865,172.4342983,172.6971935,172.9455898,173.180112,173.4013896,173.6100518,173.8067179,173.9919998,174.1664951,174.3307855,174.4854344,174.6309856,174.7679617,174.8968634,175.0181691,175.1323345,175.2397926,175.340954,175.4362071,175.5259191,175.6104358,175.690083,175.7651671,175.8359757,175.9027788,175.9658293,176.0253641,176.081605,176.1347593,176.1850208,176.2325707,176.2775781,176.3202008,176.3605864,176.3988725,176.4351874,176.469651,176.5023751,176.533464,176.5630153,176.5911197,176.6178621,176.6433219,176.6675729,176.6906844,176.712721,176.733743,176.753807,176.7729657,176.7912687,176.8087622,176.8254895,176.8414914,176.8492322],fe=[.040321528,.040395626,.040577525,.040723122,.040833194,.040909059,.040952433,.04096533,.040949976,.040908737,.040844062,.040758431,.040654312,.04053412,.040572876,.04061691,.040666414,.040721467,.040782045,.040848042,.040919281,.040995524,.041076485,.041161838,.041251224,.041344257,.041440534,.041539635,.041641136,.041744602,.041849607,.041955723,.042062532,.042169628,.042276619,.042383129,.042488804,.042593311,.042696342,.042797615,.042896877,.042993904,.043088503,.043180513,.043269806,.043356287,.043439893,.043520597,.043598407,.043673359,.043745523,.043815003,.043881929,.043946461,.044008785,.044069112,.044127675,.044184725,.044240532,.044295379,.044349559,.044403374,.04445713,.044511135,.044565693,.044621104,.044677662,.044735646,.044795322,.044856941,.04492073,.044986899,.045055632,.045127088,.045201399,.045278671,.045358979,.045442372,.045528869,.045618459,.045711105,.045806742,.045905281,.046006604,.046110573,.046217028,.04632579,.046436662,.04654943,.046663871,.046779748,.046896817,.047014827,.047133525,.047252654,.047371961,.047491194,.047610108,.047728463,.04784603,.047962592,.048077942,.048191889,.048304259,.048414893,.048523648,.048630402,.04873505,.048837504,.048937694,.049035564,.049131073,.049224189,.049314887,.049403145,.049488934,.049572216,.049652935,.049731004,.0498063,.04987865,.049947823,.050013518,.050075353,.050132858,.050185471,.050232532,.050273285,.050306885,.050332406,.05034886,.050355216,.050350423,.050333444,.050303283,.050259018,.050199837,.050125062,.05003418,.049926861,.049802977,.04966261,.049506051,.049333801,.049146553,.04894519,.048730749,.048504404,.048267442,.04802123,.047767192,.047506783,.047241456,.04697265,.046701759,.046430122,.046159004,.045889585,.045622955,.045360101,.045101913,.044849174,.044602566,.044362674,.044129985,.043904897,.043687723,.043478698,.043277987,.043085685,.042901835,.042726424,.042559396,.042400652,.042250063,.042107465,.041972676,.041845488,.041725679,.041613015,.041507249,.041408129,.041315398,.041228796,.04114806,.041072931,.04100315,.040938463,.040878617,.040823368,.040772475,.040725706,.040682834,.04064364,.040607913,.040575448,.040546051,.040519532,.040495713,.040474421,.040455493,.040438773,.040424111,.040411366,.040400405,.040391101,.040383334,.04037699,.040371962,.040368149,.040365456,.040363795,.04036308,.040363233,.040364179,.04036585,.04036818,.040369574],pe=[[-7.4855,-1.2252,1.2643,-6.8797,20.4744,.7114,-.0066,-.0667,.3564,-.0012,.5278,-.6927,.1388],[8.4462,-.9598,.9046,-5.1098,15.1548,.5919,-.0029,-.065,.2495,-.003,.4421,-.5724,.0997],[26.6223,-1.1479,1.2134,-8.4665,28.0408,.475,1e-4,-.0643,.2062,-.023,.5561,-.7467,.185],[31.8947,-.867,1.1693,-8.2932,26.0849,.4251,-2e-4,-.0535,.1718,-.008,.3954,-.5402,.1473],[30.9472,-1.1288,1.5926,-11.7371,34.5934,.4578,-.0019,-.0341,.1144,-.0167,.6897,-1.0025,.3867],[23.152,-1.1368,1.751,-13.8556,41.2104,.527,-.0048,-.0149,.0623,.0062,.4347,-.6509,.2798],[19.3036,-.923,1.6566,-14.2294,42.9522,.5494,-.0062,-.0051,.0555,.0242,.1295,-.1986,.0876],[20.0191,-1.0378,1.6928,-13.6476,40.8615,.5596,-.0071,.0146,-.03,.0135,.1632,-.2423,.1013],[21.6515,-.9745,1.5964,-13.0096,38.8309,.5462,-.0063,.0087,-.0183,.0093,.2644,-.3848,.1477],[22.6952,-.8665,1.4799,-11.8203,34.2277,.537,-.0066,.0176,-.0648,.0046,.3226,-.4689,.1811],[23.1615,-.8132,1.4422,-11.8893,34.8542,.5329,-.0063,.013,-.0367,.008,.34,-.5072,.2171],[27.9,-.8288,1.4257,-11.5803,33.7393,.4995,-.0049,.0013,.0117,-.0014,.4954,-.7333,.3051],[34.8678,-.801,1.429,-11.2835,32.3656,.4469,-.0037,-.0037,.0274,-4e-4,.3936,-.5873,.251],[37.7557,-.9638,1.5603,-11.545,31.5671,.4392,-.0035,.0024,-.0164,-.0087,.395,-.575,.2238],[39.9509,-1.0185,1.6189,-11.6485,31.009,.4284,-.0032,.0051,-.0452,-.0101,.3516,-.5073,.1906],[40.8576,-.9313,1.5386,-11.5031,31.8413,.418,-.0029,.0019,-.0291,-.0081,.3507,-.5094,.1968],[42.1455,-.9104,1.5356,-11.4411,31.5567,.4098,-.0029,.0038,-.0368,-.006,.2848,-.4155,.1642],[44.0009,-1.0103,1.6565,-11.8711,31.8672,.4038,-.0026,7e-4,-.0172,-.0017,.1877,-.2802,.1211],[42.9483,-.9479,1.6532,-12.4439,34.3937,.4097,-.0029,.0023,-.0231,-3e-4,.1892,-.2761,.1077],[43.4489,-.9355,1.5751,-11.4463,30.9525,.4076,-.0027,0,-.0199,.0013,.1619,-.2376,.0949],[42.0432,-.9668,1.5892,-11.2769,29.6658,.4235,-.003,9e-4,-.0194,.0051,.1181,-.1781,.0784],[43.3921,-.9251,1.5125,-10.669,27.8566,.4122,-.0025,-8e-4,-.0269,-3e-4,.178,-.2571,.0962],[43.1823,-.9153,1.5502,-11.2058,29.7148,.4154,-.0028,.0025,-.0386,.0053,.0679,-.0977,.0352],[43.5111,-.8427,1.4724,-10.8634,29.5168,.4107,-.0027,.0019,-.0416,-.0023,.1644,-.2282,.0711],[44.8115,-.9195,1.5496,-10.7815,27.8384,.4087,-.003,.012,-.0908,-.0063,.1451,-.1957,.053],[45.1153,-.8419,1.4685,-10.4821,27.7389,.404,-.003,.0148,-.1094,-.0047,.1524,-.2131,.0715],[45.0184,-.9109,1.4637,-9.8769,25.3956,.4124,-.0031,.0163,-.1196,-.0095,.2128,-.3015,.1084],[46.8396,-.9336,1.4913,-10.0409,25.5791,.4004,-.0025,.0087,-.0854,-.0083,.207,-.2945,.1065],[46.3627,-1.0691,1.6403,-10.8997,27.3749,.4156,-.003,.0128,-.0892,-.006,.1891,-.2783,.1168],[46.056,-1.0253,1.6174,-10.8914,27.6133,.4169,-.0032,.0134,-.0831,-.0015,.1168,-.1751,.0794],[45.8707,-1.0687,1.6929,-11.5282,29.3823,.4234,-.0035,.0189,-.1052,-.002,.0549,-.0766,.0279],[46.225,-1.0493,1.6305,-11.0002,28.295,.4212,-.0032,.015,-.0892,.001,.0192,-.0279,.014],[49.7043,-1.1168,1.6687,-10.6909,26.5418,.4005,-.0027,.0175,-.1166,-.0029,-.0064,.0124,-.0056],[52.501,-1.2283,1.7174,-10.288,24.6009,.39,-.0025,.0229,-.1413,-.0055,-.0773,.1151,-.0428],[52.638,-1.2668,1.7982,-10.7251,24.8323,.393,-.0027,.0233,-.1352,-.0037,-.1218,.1797,-.0678],[52.9451,-1.2987,1.8214,-10.8739,25.4383,.3952,-.0028,.0249,-.1365,-.0026,-.1753,.2588,-.1002],[51.6977,-1.2275,1.7723,-10.6355,24.5465,.4024,-.0032,.0273,-.1377,.0023,-.2334,.3428,-.1327],[51.5803,-1.1856,1.7323,-10.549,24.7169,.4027,-.0033,.029,-.1504,.004,-.2752,.4081,-.1658],[52.5542,-1.1951,1.7357,-10.3953,23.5706,.3978,-.0032,.0312,-.1661,5e-4,-.2249,.34,-.1482],[54.7146,-1.2604,1.8028,-10.773,24.4075,.3869,-.0029,.0332,-.1862,-.002,-.2181,.3306,-.1449],[56.735,-1.199,1.8011,-11.3328,26.8609,.3684,-.0025,.0319,-.1874,2e-4,-.2443,.3686,-.1611],[57.7385,-1.2515,1.8588,-11.3519,25.8098,.3657,-.0024,.0287,-.1704,-9e-4,-.2306,.3502,-.1567],[57.7098,-1.257,1.9037,-11.8077,27.0173,.3677,-.0024,.0271,-.1572,-.0012,-.1965,.298,-.1324],[58.0736,-1.2363,1.9353,-12.317,28.6066,.3643,-.0024,.0253,-.1507,.002,-.178,.2641,-.1092],[62.0223,-1.2128,1.9237,-12.157,27.903,.3343,-.0016,.0242,-.1555,-4e-4,-.21,.315,-.136],[62.1221,-1.1404,1.8555,-11.839,27.3698,.3308,-.0017,.026,-.1685,-.0024,-.1452,.2208,-.0993],[62.7962,-1.113,1.8421,-11.7266,26.7715,.3253,-.0016,.0282,-.1884,-.0019,-.1808,.2766,-.1276],[61.7073,-1.2183,1.9323,-12.0462,26.8742,.3435,-.0022,.0321,-.2009,-.0018,-.1943,.2958,-.1342],[61.7636,-1.1885,1.9597,-12.4946,27.9124,.342,-.0022,.0308,-.1956,.003,-.234,.3493,-.149],[63.7493,-1.2055,1.96,-12.5069,28.0089,.3283,-.0012,.0195,-.1595,-.002,-.1708,.2634,-.1258],[62.2586,-1.077,1.8646,-12.2702,27.8184,.3328,-.0012,.0137,-.1292,-.0024,-.0705,.1151,-.0646],[64.2911,-1.0805,1.8431,-11.8647,26.3816,.3191,-7e-4,.0088,-.1057,-.007,-.0325,.0621,-.0471],[68.9778,-1.2187,1.888,-11.2553,23.9127,.294,3e-4,.0053,-.0991,-.0123,-.0668,.1121,-.0648],[70.4806,-1.165,1.8218,-10.7395,22.4622,.2801,9e-4,1e-4,-.0853,-.0136,-.0702,.1225,-.0781],[70.6109,-1.1182,1.8262,-11.2854,24.8046,.2768,.001,-7e-4,-.084,-.01,-.1092,.1806,-.1041],[69.8975,-1.1611,1.8731,-11.7046,26.3452,.287,7e-4,.0018,-.0954,-.0067,-.1524,.2386,-.1185],[69.191,-1.1401,1.9015,-12.217,27.9129,.2928,3e-4,.0055,-.111,-.0035,-.2103,.3262,-.1586],[69.9619,-1.1195,1.8816,-11.9235,26.817,.2873,5e-4,.0046,-.1118,-.0053,-.1918,.3015,-.1525],[68.3161,-1.0128,1.7759,-11.6001,26.6764,.2951,3e-4,.0028,-.1008,-.0022,-.2321,.3639,-.1831],[68.0555,-.9162,1.6469,-10.7107,24.2868,.2927,6e-4,-.0014,-.0813,-4e-4,-.236,.3707,-.1882],[65.6124,-.7989,1.5036,-9.8072,21.9786,.3055,4e-4,-.0054,-.0567,-.0017,-.1403,.2328,-.1369],[65.1636,-.7707,1.457,-9.5828,21.8374,.3086,5e-4,-.0086,-.0391,-.0024,-.0941,.1647,-.109],[66.6766,-.913,1.5894,-9.8498,21.1477,.3073,8e-4,-.0116,-.029,-.0052,-.0645,.1189,-.0865],[65.4537,-.895,1.5329,-9.3616,19.7235,.3178,7e-4,-.0136,-.0176,-.0044,-.0173,.0444,-.0479],[64.8596,-.9404,1.6229,-9.8355,19.8054,.3274,2e-4,-.0077,-.0396,-.006,.0077,.0094,-.0359],[64.7808,-.935,1.5826,-9.392,18.2771,.3302,2e-4,-.0082,-.0324,-.009,.0629,-.0712,-.0032],[65.5762,-.9693,1.558,-8.833,16.6679,.3289,3e-4,-.009,-.0304,-.0092,.0526,-.0599,-.0011],[64.0451,-1.1203,1.7205,-9.4755,16.9051,.3537,-7e-4,.0019,-.0701,-.0041,-.1202,.1997,-.1156],[66.825,-1.1964,1.8333,-10.0226,17.9273,.3397,-6e-4,.0056,-.0822,-.0081,-.1245,.2047,-.1138],[65.6846,-1.2525,1.9018,-10.459,18.6882,.3537,-9e-4,.0036,-.066,-.0057,-.113,.1831,-.0985],[65.3052,-1.2617,1.9135,-10.5223,18.771,.3604,-.0013,.0085,-.0848,-.0046,-.1438,.2265,-.112],[64.899,-1.2245,1.8584,-10.1192,17.7416,.3641,-.0016,.0138,-.1073,-.0048,-.1372,.2161,-.1063],[65.3578,-1.2248,1.8289,-9.7674,16.8046,.3627,-.0014,.0124,-.1066,-.0057,-.1576,.2502,-.1263],[64.5514,-1.1783,1.7442,-9.4075,16.9106,.3687,-.0013,.0091,-.0924,-.0076,-.0787,.1365,-.0847],[66.0885,-1.1878,1.7936,-9.5264,16.3425,.3605,-.0016,.0179,-.1274,-.0072,-.185,.2994,-.1608],[67.302,-1.1912,1.725,-8.4639,12.8607,.3551,-.0016,.0212,-.1358,-.0076,-.2055,.3238,-.1601],[69.6151,-1.1726,1.7606,-8.9219,14.4437,.3387,-.0015,.026,-.1521,-.0094,-.1704,.2659,-.1257],[70.5901,-1.2426,1.8162,-8.921,13.7988,.3388,-.0016,.0283,-.1619,-.016,-.066,.1157,-.069],[74.0399,-1.3696,1.9736,-9.9705,16.4081,.322,-.001,.0261,-.1607,-.0211,.054,-.068,.017],[78.1837,-1.4118,1.9659,-9.2285,13.6521,.2962,-4e-4,.0279,-.176,-.0236,.0265,-.035,.0171],[77.8733,-1.5496,2.1217,-10.0164,15.085,.3117,-.0013,.041,-.234,-.0167,-.141,.2059,-.0717],[78.6258,-1.5819,2.1292,-10.2662,16.5876,.311,-.0011,.0374,-.2191,-.0181,-.0881,.1294,-.044],[78.1114,-1.6551,2.2258,-11.1197,18.7127,.3231,-.0016,.0421,-.2369,-.0174,-.0626,.0903,-.0264],[79.7562,-1.6836,2.2862,-11.9207,21.9312,.3146,-.0013,.038,-.2147,-.0164,-.0397,.0537,-.0083],[81.1825,-1.7413,2.3012,-11.7683,21.4169,.3106,-.0011,.0381,-.2099,-.0197,.0394,-.07,.0551],[82.4317,-1.7326,2.3369,-11.7377,20.8323,.3043,-.0014,.0468,-.2545,-.0145,-.1069,.1451,-.0329],[83.4279,-1.7479,2.3341,-12.1336,23.8773,.3009,-9e-4,.0394,-.2205,-.0159,-.0384,.039,.0189],[87.5318,-1.8801,2.4042,-11.8201,21.5,.2804,0,.0344,-.215,-.0208,-.0131,.0053,.0276],[91.5471,-1.9424,2.5247,-12.4507,21.7964,.2576,5e-4,.0374,-.2444,-.0294,-.0119,.0227,-.01],[92.4497,-1.8508,2.5523,-13.6421,26.226,.2495,0,.0494,-.305,-.0184,-.1813,.2673,-.1041],[92.8328,-1.7523,2.5128,-13.17,23.6191,.2436,5e-4,.0322,-.2188,-.0162,-.1657,.2435,-.0938],[100.346,-1.9852,2.7015,-12.334,16.8429,.2061,.0016,.0236,-.1616,-.0093,-.4796,.6954,-.2616],[106.8231,-1.8617,2.4704,-10.3756,11.994,.1537,.0038,.0071,-.1169,-.0192,-.4992,.7439,-.3113],[111.3953,-1.9833,2.5967,-11.4122,16.0199,.1324,.0046,.0068,-.1417,-.0242,-.6418,.9712,-.431],[117.6411,-2.0964,2.6981,-11.2572,13.4182,.0991,.0053,.0132,-.1836,-.0338,-.4799,.719,-.3037],[121.3735,-2.3828,2.9534,-12.2263,14.8292,.0974,.0055,.0085,-.1487,-.0205,-.6271,.9041,-.3313],[115.9126,-2.5317,3.2788,-15.2093,22.0287,.1601,.0028,.0231,-.181,6e-4,-.7258,1.0194,-.3341],[125.5877,-1.6743,2.6055,-13.4481,23.2621,.0405,.006,-9e-4,-.0707,.0296,-1.1873,1.6794,-.5743],[135.675,-1.8473,2.0605,-8.0487,16.9201,-.0112,.0136,-.0896,.1678,-.0337,.3359,-.5938,.4196]],me=[[36.3363,-.4513,-.2328,28.8499,-129.833,-.0182,7e-4,.0464,-.2691,-.0622,-.2979,.6276,-.5522],[30.6534,-1.0645,-.5369,30.836,-125.69,.1058,.0021,.039,-.2859,-.0568,-.8988,1.5116,-.9035],[46.6521,-.8427,-.8134,29.0051,-109.524,-.0091,.0049,.0484,-.379,-.0684,-.6066,1.0179,-.5945],[34.7995,-1.0943,-.5132,24.8976,-93.9462,.1143,6e-4,.0856,-.4757,-.03,-.9349,1.424,-.6362],[15.9095,-.3518,-.6484,19.5391,-72.0796,.2253,-.0045,.1041,-.5073,.007,-1.3455,2.0777,-.9953],[12.8878,-.0974,-1.0427,20.0319,-66.1203,.2379,-.002,.0402,-.2008,-.0112,-.4679,.7618,-.4226],[3.2759,-.1741,-.7763,16.2511,-53.8662,.3223,-.0044,.0485,-.2089,-.0061,-.2448,.4092,-.2385],[12.846,-.0649,-.8792,16.2183,-50.693,.2474,-.0022,.0311,-.123,-.0255,.239,-.3265,.1012],[12.8668,.1716,-1.0619,16.2814,-49.2028,.2361,-.002,.0293,-.1263,-.0322,.5303,-.7561,.2762],[9.112,.1408,-1.0811,16.1015,-48.0962,.2737,-.0032,.0416,-.1676,-.0278,.5837,-.8523,.3437],[11.7225,-.2667,-.674,14.1978,-45.5872,.284,-.0034,.0505,-.203,-.0368,.5673,-.8255,.3314],[19.5753,-.4609,-.4453,12.7133,-41.9359,.2384,-.002,.0503,-.2232,-.0503,.7475,-1.0987,.4581],[21.1297,-.7489,-.2784,12.1653,-40.6521,.2491,-.0015,.0462,-.2201,-.0415,.5736,-.8537,.3742],[17.5087,-.5589,-.5804,13.6135,-42.3595,.2699,-.0017,.0438,-.2286,-.0325,.5451,-.8138,.3581],[19.125,-.6931,-.358,11.3984,-35.5973,.2679,-9e-4,.0341,-.1992,-.0272,.3386,-.5034,.2204],[12.3312,-.7307,-.2314,9.1993,-27.9046,.3246,-.002,.0272,-.1474,-.0218,.4218,-.6267,.2695],[8.7933,-.5755,-.2574,8.5358,-26.1118,.3473,-.0031,.0313,-.1447,-.0249,.4514,-.6549,.2572],[6.8234,-.7262,-.0687,7.7821,-26.4927,.3781,-.0044,.0462,-.203,-.0214,.2612,-.3714,.1375],[6.5708,-.6226,-.1738,8.0763,-26.5849,.3759,-.0041,.0378,-.1688,-.0223,.3339,-.475,.1725],[12.4952,-.781,.0532,6.8239,-24.2698,.3431,-.0032,.0368,-.1732,-.0262,.1513,-.1909,.0331],[16.8254,-.4175,-.2206,7.4894,-23.9702,.2885,-.0021,.0295,-.1608,-.0154,-.0241,.0763,-.095],[17.8811,-.4367,-.1266,7.0389,-24.15,.2868,-.0028,.0392,-.1928,-.0081,-.278,.4577,-.2641],[16.5734,-.2666,-.2542,7.0108,-22.3832,.2899,-.0032,.0387,-.1806,-.0041,-.2653,.436,-.2519],[19.9011,-.2317,-.3427,7.6601,-23.4789,.2636,-.002,.0303,-.1519,-.0146,-.0788,.162,-.1394],[21.7218,-.2625,-.2345,6.6903,-20.9185,.2553,-.0023,.0347,-.1547,-.023,.0302,.0052,-.0801],[21.9955,-.4947,-.0505,6.3827,-21.7936,.2719,-.0028,.0392,-.1593,-.0334,.1394,-.1536,-.0152],[25.2014,-.5716,.0877,5.7268,-21.1119,.2566,-.0032,.0512,-.2028,-.0358,.0855,-.0747,-.0456],[24.9355,-.6578,.231,4.6551,-18.8514,.2671,-.0039,.0592,-.2224,-.0268,-.0489,.114,-.1096],[23.5259,-.5069,.1119,4.7744,-18.0734,.2698,-.004,.0557,-.2087,-.0263,.0265,.0098,-.0803],[22.6538,-.3685,-.0683,5.5225,-18.8175,.2682,-.0033,.0439,-.1629,-.0299,.2232,-.2808,.039],[25.1343,-.4732,.0854,3.9605,-13.912,.2571,-.0028,.0398,-.1488,-.038,.4146,-.5644,.1571],[26.0776,-.4748,.0973,4.2405,-15.6978,.2526,-.0028,.0409,-.1485,-.0398,.4214,-.5758,.1652],[27.7828,-.4017,.07,4.258,-15.4754,.2367,-.0027,.0432,-.1635,-.035,.3149,-.4222,.1074],[33.321,-.5491,.2782,3.9722,-17.4641,.2081,-.0028,.0559,-.2079,-.0453,.3091,-.4165,.114],[34.8309,-.6942,.426,3.3318,-16.8497,.2081,-.003,.0647,-.2508,-.0416,.1445,-.1779,.0236],[37.5926,-.6443,.3677,3.4067,-16.42,.1823,-.0015,.0474,-.1947,-.0411,.2234,-.2936,.0668],[39.4412,-.5625,.2263,4.2984,-18.3087,.1635,-3e-4,.0348,-.1585,-.0452,.3142,-.4246,.1158],[40.6765,-.6234,.3141,3.8208,-17.9457,.1599,-2e-4,.0372,-.1782,-.041,.1452,-.1684,-.0017],[38.5263,-.6294,.3817,3.0897,-16.2418,.1784,-7e-4,.0354,-.1608,-.0439,.2718,-.3597,.0853],[38.8799,-.7551,.4856,2.734,-15.7989,.186,-8e-4,.037,-.1615,-.0449,.292,-.3993,.1186],[41.2743,-.9011,.6699,2.2512,-16.8137,.1795,-9e-4,.042,-.1746,-.0484,.2216,-.293,.0726],[42.2558,-1.0062,.7158,2.6789,-19.1943,.1817,-9e-4,.0441,-.1858,-.0468,.0978,-.112,.002],[40.2612,-.9872,.7444,1.7973,-16.1566,.1974,-.0012,.0445,-.1857,-.0476,.1203,-.1402,.0055],[43.6457,-1.0069,.734,1.9082,-15.776,.1751,-5e-4,.0411,-.1774,-.054,.2098,-.2758,.0684],[37.4261,-1.0061,.8119,.7582,-12.6239,.2262,-.0023,.0517,-.2087,-.0439,.0866,-.0919,-.0122],[39.6219,-1.2657,1.1924,-1.7105,-7.6258,.228,-.0027,.0582,-.2341,-.047,-.0208,.0811,-.1069],[40.843,-1.2324,1.2238,-1.9885,-7.0689,.2204,-.0032,.0673,-.2749,-.0429,-.1374,.2503,-.1721],[43.5592,-1.2444,1.2281,-1.7233,-8.2869,.2012,-.0024,.0607,-.2564,-.0432,-.1732,.3033,-.1943],[44.6015,-1.2557,1.2143,-1.1069,-11.0077,.197,-.0025,.062,-.2557,-.0368,-.2817,.4521,-.2374],[43.431,-1.4836,1.4844,-2.8301,-7.691,.2221,-.0031,.0664,-.2718,-.0343,-.3518,.5529,-.2744],[40.2503,-1.5293,1.5113,-3.3498,-5.9574,.2524,-.0038,.0674,-.2644,-.0307,-.3766,.5899,-.2912],[38.7912,-1.4248,1.4482,-3.6476,-4.2826,.2581,-.0037,.0597,-.2243,-.033,-.308,.4967,-.266],[43.1602,-1.3762,1.3057,-2.4967,-6.1669,.2217,-.0018,.0357,-.1265,-.0409,-.031,.0745,-.0711],[44.7535,-1.2714,1.1636,-1.6742,-7.0124,.2031,-6e-4,.0171,-.0429,-.0436,.1573,-.2169,.0706],[44.9528,-1.1354,1.0103,-.6896,-9.5126,.1953,-5e-4,.0153,-.0298,-.0404,.1044,-.1372,.0343],[39.8113,-.9011,.8911,-1.1437,-6.6547,.2237,-.002,.0227,-.0406,-.0358,.093,-.1099,.0051],[37.8989,-1.0051,1.0055,-1.5428,-6.9588,.2482,-.0029,.031,-.0735,-.0328,-.0609,.1319,-.119],[35.1924,-.8104,.8253,-.5962,-9.35,.2601,-.0037,.0368,-.0925,-.0269,-.1549,.2764,-.1888],[35.6873,-.7372,.8448,-1.3541,-6.8503,.254,-.0041,.0431,-.1168,-.023,-.2589,.4332,-.2593],[32.6133,-.5491,.7277,-1.3961,-5.5317,.2691,-.0053,.0532,-.1439,-.0153,-.3595,.5813,-.3205],[34.8437,-.4711,.6905,-1.4542,-4.7991,.2492,-.0052,.0579,-.1655,-.0189,-.3396,.557,-.3175],[35.5381,-.4317,.6593,-1.2682,-5.2622,.2433,-.0053,.063,-.1896,-.0217,-.3173,.5302,-.316],[36.1777,-.4466,.641,-.9947,-5.8087,.2409,-.0052,.0631,-.1933,-.022,-.1927,.3323,-.2121],[41.2921,-.4612,.5856,-.5033,-6.0372,.2021,-.0034,.0497,-.1573,-.0331,.0525,-.035,-.0513],[43.0646,-.3308,.3256,1.3124,-9.9318,.1798,-.0016,.0281,-.0904,-.0459,.3232,-.4202,.0842],[44.3551,-.1948,.1835,1.9859,-10.8501,.1628,-.0011,.0241,-.0832,-.0524,.5032,-.684,.19],[41.152,.0212,-.0243,2.9817,-12.3905,.1771,-.0019,.0273,-.0838,-.047,.5514,-.7673,.2434],[40.7747,.1804,-.1901,4.1333,-15.4608,.1742,-.0025,.0343,-.0976,-.0441,.5815,-.8266,.2933],[42.6723,.2057,-.2093,4.492,-16.8094,.1599,-.0024,.0353,-.0956,-.0449,.6759,-.9819,.3834],[44.4726,.1842,-.1287,4.2111,-17.151,.1485,-.0024,.0365,-.0871,-.036,.5025,-.7363,.2978],[44.4307,.0412,.0455,3.5578,-17.0706,.1602,-.0031,.0461,-.1195,-.0272,.2636,-.3881,.1611],[46.146,-.1944,.3303,2.0667,-14.4506,.1634,-.0032,.0504,-.1357,-.0212,.0591,-.0927,.0497],[48.5522,-.2845,.4266,2.1896,-16.3502,.1537,-.0035,.0626,-.1955,-.0152,-.2111,.308,-.1179],[47.5272,-.3843,.5027,1.5489,-14.8051,.1683,-.0032,.0566,-.179,-.0162,-.1752,.2648,-.1172],[42.3688,-.2544,.359,1.5821,-13.3586,.2003,-.0031,.0394,-.1,-.023,.1762,-.2505,.0889],[40.419,-.1244,.2024,2.2651,-13.8723,.2085,-.0028,.0242,-.027,-.0263,.4803,-.717,.3102],[41.2786,-.4001,.5512,.3246,-9.9661,.2234,-.0037,.0333,-.0397,-.0258,.411,-.6274,.2957],[44.5475,-.4095,.5884,.3313,-11.0779,.202,-.0036,.0417,-.0815,-.024,.2501,-.3889,.1968],[48.1433,-.5054,.6845,.6598,-14.3615,.1854,-.0038,.0599,-.1887,-.0266,.0236,-.0355,.0216],[36.6027,-.2846,.4948,.5126,-11.9027,.2648,-.0058,.0611,-.1823,-.0318,.3126,-.4516,.177],[32.668,-.2953,.5385,-.5236,-7.6933,.2977,-.0064,.0584,-.1674,-.0333,.4917,-.7205,.2953],[34.2675,-.3725,.6712,-1.4456,-4.71,.2927,-.0065,.0568,-.1384,-.0262,.4807,-.7367,.354],[34.5736,-.5184,.8798,-2.5558,-3.2479,.3039,-.0074,.0666,-.1528,-.013,.1827,-.311,.2009],[38.2705,-.8498,1.178,-3.1281,-5.8888,.2993,-.0068,.0702,-.2122,-.0147,-.202,.2993,-.1195],[27.2619,-.709,1.1524,-4.729,.3025,.3797,-.0092,.0796,-.2446,-.0222,.1254,-.163,.0363],[30.6429,-.6031,1.1239,-5.8827,7.3287,.3476,-.0081,.0684,-.2186,-.027,.4252,-.6274,.2628],[38.2584,-.5815,1.057,-5.5212,7.7327,.2884,-.0057,.0424,-.1141,-.0255,.4732,-.7143,.3218],[34.2063,-.6992,1.3687,-7.5293,9.9367,.33,-.0072,.0412,-.0552,-.0037,.0265,-.062,.0645],[28.3761,-.5032,1.1656,-6.5035,7.3478,.3702,-.009,.0557,-.0992,.0012,-.2162,.3295,-.1511],[31.5473,-.191,.8482,-4.995,5.5448,.333,-.0093,.0772,-.2338,-.0012,-.3665,.5893,-.3214],[28.0599,-.1241,.7701,-4.7329,5.1931,.3597,-.0102,.0796,-.2161,-.0098,.0298,-.0073,-.0557],[23.6587,.3036,.2722,-3.1305,5.7577,.3693,-.0097,.0627,-.1368,-.0164,.4595,-.6438,.21],[30.6936,.0131,.6061,-3.5047,1.8377,.3406,-.0098,.0776,-.195,-.0166,.1956,-.2534,.0492],[36.2121,-.1094,.7833,-3.9736,.5351,.3083,-.0089,.0774,-.1975,-.0148,.091,-.0977,-.0189],[42.9427,-.2087,1.2659,-7.7504,8.427,.2634,-.0082,.0706,-.1836,.0138,-.4419,.6751,-.3217],[35.6163,-.3308,1.3791,-8.3941,8.0466,.3365,-.0098,.0787,-.2043,-5e-4,-.1455,.2492,-.1613],[52.6206,.342,.8903,-5.8391,3.6866,.1778,-.0082,.0886,-.2524,.0117,-.5949,.9156,-.4441],[73.797,-.1315,1.1805,-3.1333,-12.7158,.0592,-.0043,.0809,-.2789,-.052,.1674,-.2079,.0315],[106.9205,-.8638,1.9387,-5.949,-7.0235,-.131,.0011,.064,-.2761,-.1211,.5938,-.7577,.1352]],he=[[-15.1614,.1585,.7927,-16.2445,64.9588,.7016,-.0159,.0803,-.1501,.0109,.1002,-.1603,.0565],[7.1181,.1808,.1658,-8.1838,41.4072,.5512,-.0095,.054,-.1228,.0057,.0042,.0299,-.0661],[16.6833,-.0164,.2766,-6.0204,29.5897,.5,-.0072,.037,-.0808,-.0092,.0673,-.0993,.0246],[4.2312,.3344,.0389,-4.8857,26.2991,.583,-.0104,.0473,-.0885,9e-4,.0958,-.155,.0586],[7.5365,-.0042,.4065,-5.8405,25.1459,.5865,-.0109,.0523,-.0938,.001,.0934,-.1598,.0738],[9.1488,-.3319,.8441,-9.4288,35.3411,.6019,-.0121,.0661,-.1243,-.0028,.105,-.187,.0975],[8.942,-.0756,.7374,-10.0163,38.7888,.5921,-.0126,.0712,-.1373,.013,.076,-.1417,.0814],[7.6195,.0671,.6085,-8.8982,34.0775,.5961,-.0127,.0706,-.1365,.0147,.0961,-.1812,.1062],[4.7191,.0248,.8039,-10.5118,37.6146,.6241,-.014,.074,-.1321,.0285,.0747,-.1503,.0994],[-3.7807,.2569,.5926,-10.5763,40.4022,.6754,-.0144,.0649,-.1065,.0265,.1273,-.2395,.1377],[-4.3588,.5128,.4441,-11.0057,43.9366,.6643,-.0141,.0598,-.0914,.0297,.1526,-.2899,.1703],[.9793,.277,.5168,-10.2491,40.6962,.6426,-.0127,.0539,-.0858,.0133,.1639,-.2987,.1604],[4.1744,.2919,.5211,-10.2719,41.0334,.6197,-.0121,.0528,-.0869,.0122,.1661,-.3033,.1633],[6.8468,.1938,.5369,-9.8873,39.859,.6088,-.0115,.0517,-.0889,.0046,.1768,-.321,.1715],[11.1461,.2378,.3678,-8.151,35.8557,.5761,-.01,.044,-.0795,-7e-4,.1778,-.321,.1698],[12.4221,.276,.2488,-6.8316,31.9031,.5662,-.0092,.0391,-.073,-.0089,.2003,-.3583,.1859],[10.6386,.5028,.0451,-6.0581,30.8189,.5675,-.0093,.0395,-.0789,-.0048,.1885,-.3309,.1625],[11.895,.4259,.0403,-5.1913,27.4155,.5654,-.0088,.0351,-.0686,-.0151,.216,-.3783,.1854],[15.6199,.2947,.1255,-4.8706,25.2474,.5485,-.0083,.0349,-.0709,-.0153,.1958,-.3402,.1631],[19.1961,.2043,.1214,-4.058,22.8341,.5297,-.0074,.031,-.0656,-.025,.2093,-.3615,.171],[24.9014,.1164,.1324,-3.0351,18.7307,.4951,-.0063,.0283,-.0649,-.0265,.1862,-.3184,.1463],[27.7411,-2e-4,.251,-3.251,17.9354,.4835,-.0062,.0313,-.073,-.026,.1667,-.2835,.1289],[26.5408,-.0132,.3133,-3.6487,17.7499,.4961,-.0068,.0361,-.0837,-.0188,.1384,-.2306,.0976],[24.9608,.0679,.2933,-3.7963,17.8167,.5066,-.0077,.043,-.0991,-.0102,.1136,-.1873,.0762],[30.7628,-.0404,.3473,-3.514,16.9902,.4711,-.0065,.0402,-.0991,-.0135,.1043,-.172,.0705],[32.9166,-.0712,.3957,-3.9,17.9467,.4584,-.0062,.0397,-.0994,-.0111,.0905,-.1473,.0576],[35.8384,-.154,.4647,-4.0996,18.2022,.4447,-.0061,.0445,-.1155,-.0116,.0725,-.1148,.0406],[35.8936,-.2601,.5885,-4.4079,17.6393,.4551,-.0069,.0522,-.1317,-.0062,.042,-.0594,.0107],[35.6599,-.2948,.6396,-4.5403,17.3049,.4616,-.0074,.0559,-.1397,-.0065,.0482,-.0732,.0217],[34.2326,-.3816,.7322,-4.795,17.0262,.4801,-.0079,.0573,-.1393,-.0049,.0527,-.0851,.0332],[38.436,-.518,.8471,-5.2375,18.6249,.4592,-.0074,.0594,-.1493,-.0109,.0578,-.0961,.042],[37.4759,-.3108,.6669,-4.487,17.3228,.4543,-.0072,.0558,-.1401,-.0071,.0668,-.1148,.0546],[38.2626,-.2565,.595,-3.8813,15.733,.4471,-.0072,.0565,-.1436,-.0047,.058,-.0993,.0468],[40.1654,-.373,.7286,-4.669,17.4341,.4421,-.0071,.0576,-.1469,-5e-4,.0365,-.0612,.0272],[42.9794,-.5548,.8878,-5.2907,18.8227,.4348,-.0069,.0595,-.1514,-.0022,.033,-.0585,.0309],[45.6449,-.6118,.8823,-5.0487,18.8985,.4196,-.0061,.0555,-.1462,-.0051,.0381,-.069,.0387],[46.6551,-.5689,.866,-5.0611,19.3856,.41,-.0059,.0537,-.1435,-.0027,.039,-.0728,.0431],[47.5003,-.5697,.8793,-5.203,19.8144,.4057,-.0059,.0563,-.1527,-.0019,.0291,-.0538,.0314],[45.403,-.5065,.8608,-5.5153,21.0092,.4195,-.0064,.0585,-.1569,.0032,.0197,-.0361,.0204],[44.8971,-.395,.8017,-5.6222,21.9379,.4168,-.0064,.0554,-.147,.0027,.0376,-.069,.0382],[47.5247,-.4291,.8436,-5.8317,22.6883,.3999,-.0058,.0527,-.1421,.0015,.0382,-.0702,.0389],[46.463,-.3679,.8717,-6.4206,23.9766,.4049,-.006,.0518,-.1372,.0093,.0233,-.0445,.0258],[43.9842,-.1919,.792,-6.7209,25.4109,.4126,-.0063,.0508,-.1325,.0119,.037,-.0693,.0383],[43.2939,-.2722,.8627,-7.0319,25.6372,.4253,-.0066,.052,-.1346,.0151,.022,-.0414,.0222],[44.9267,-.3058,.9029,-7.1291,25.4723,.4173,-.0066,.054,-.1396,.0166,.008,-.0161,.0087],[45.3659,-.1577,.7596,-6.3854,23.8924,.4047,-.006,.0477,-.1258,.015,.0245,-.0444,.0212],[45.5821,-.0245,.5923,-5.4731,22.294,.3963,-.0056,.046,-.1251,.0164,.0239,-.0431,.0201],[47.1433,-.0461,.591,-5.2852,21.7529,.3877,-.0053,.0449,-.1222,.0153,.0223,-.0412,.0208],[51.495,-.1432,.644,-5.3385,21.775,.3619,-.0042,.0417,-.1223,.0089,.0218,-.0369,.0143],[49.2507,-.0452,.5634,-5.0092,21.3118,.3735,-.0044,.0403,-.1176,.0104,.0345,-.0607,.0278],[48.723,-.0088,.5464,-5.0086,21.4246,.3773,-.0046,.0403,-.114,.0144,.0211,-.0365,.0147],[46.2919,.137,.4328,-4.7097,21.0581,.387,-.0047,.0368,-.1041,.0171,.0335,-.0595,.027],[47.5969,.1489,.3829,-4.2807,20.076,.3772,-.0039,.0315,-.0941,.0134,.0397,-.0681,.0283],[48.5103,.1248,.3886,-4.0219,19.1219,.3741,-.0039,.0318,-.0943,.0115,.0417,-.0714,.03],[47.0617,.2003,.3427,-3.9935,19.2648,.3815,-.0041,.0313,-.0915,.0121,.0505,-.0878,.0394],[47.9002,.1572,.3732,-3.8154,17.8605,.3802,-.0041,.032,-.0944,.0113,.0408,-.067,.024],[49.115,.0782,.4887,-4.5668,19.8764,.3783,-.0042,.0339,-.0974,.0137,.0304,-.0508,.019],[49.9451,.1037,.4323,-3.9989,18.2108,.3716,-.0039,.0318,-.0942,.0126,.0354,-.0602,.0246],[50.1287,.2012,.3324,-3.2058,15.608,.3664,-.0039,.0327,-.0981,.0177,.0133,-.0189,1e-4],[49.51,.1993,.3903,-3.8043,17.1157,.3729,-.0042,.0344,-.1008,.0221,.0041,-.0038,-.0061],[47.0301,.2961,.3665,-3.9702,17.4284,.3864,-.0047,.0328,-.0906,.0207,.0246,-.0408,.0138],[46.9571,.2268,.4324,-4.3249,18.4933,.3932,-.0048,.0332,-.0914,.0225,.0162,-.0255,.0051],[45.7187,.319,.3143,-3.5355,16.3535,.3986,-.0048,.0327,-.0905,.0195,.039,-.0672,.0285],[46.6338,.3294,.3122,-3.6994,16.9404,.3928,-.0047,.0327,-.0892,.02,.0422,-.0754,.036],[46.796,.2184,.4173,-4.2913,18.3125,.4005,-.0048,.0316,-.0843,.0138,.0632,-.1146,.0591],[45.6059,.2609,.3536,-3.7119,16.4744,.409,-.005,.0313,-.0814,.0161,.0671,-.1239,.0669],[46.2843,.1969,.384,-3.6001,15.9912,.4103,-.005,.0321,-.0828,.0153,.0735,-.139,.08],[42.7066,.3391,.2772,-3.5789,16.5957,.4304,-.0057,.0333,-.0798,.0158,.0981,-.1852,.1067],[42.8015,.3061,.3293,-3.7417,16.4765,.4348,-.0061,.0357,-.0812,.0203,.0909,-.1775,.1098],[44.6588,.3589,.2756,-3.1211,14.5181,.4196,-.0059,.0374,-.0881,.0175,.0943,-.1832,.1126],[45.4978,.2369,.3198,-2.8753,12.9699,.4238,-.0058,.0377,-.09,.0126,.0997,-.1911,.1148],[44.3791,.247,.2747,-2.2776,10.7861,.4342,-.0061,.0387,-.0918,.0106,.1113,-.2121,.1265],[44.5213,.3308,.2335,-2.5761,12.6357,.4295,-.006,.0393,-.0953,.015,.1005,-.192,.1141],[43.3339,.3496,.2289,-2.6952,12.6151,.4397,-.0064,.0411,-.0987,.0118,.1138,-.2135,.1223],[45.7745,.2806,.323,-3.0124,12.5836,.4279,-.0062,.0429,-.1061,.0132,.0996,-.1888,.1104],[46.2858,.2501,.3239,-2.6897,11.1237,.4274,-.0059,.0399,-.1008,.0086,.1214,-.2293,.1336],[47.1461,.0565,.3804,-1.9028,7.5777,.4368,-.0058,.0399,-.1016,-.0042,.1495,-.2777,.1579],[49.8411,-.0213,.4353,-2.2574,9.0572,.4224,-.0051,.0374,-.0989,-.0067,.1499,-.2787,.1591],[54.41,-.2754,.6713,-3.3139,10.8614,.4065,-.0045,.0392,-.1059,-.0134,.1536,-.2881,.1687],[59.0571,-.3916,.714,-3.2563,11.6335,.3792,-.0031,.0313,-.0925,-.0235,.1848,-.3462,.2023],[61.5501,-.4923,.8257,-3.7049,12.2735,.3688,-.0028,.0301,-.0892,-.0258,.1974,-.3735,.2231],[62.0991,-.5602,.8523,-3.3702,9.855,.371,-.0025,.0277,-.085,-.0253,.1895,-.3572,.2113],[63.7402,-.7486,1.0333,-4.0639,10.5288,.3743,-.0026,.0296,-.0853,-.0264,.1907,-.3647,.2234],[63.1912,-.7684,1.0572,-4.1343,10.1666,.3825,-.0028,.0301,-.0846,-.0226,.1752,-.3347,.204],[65.29,-.9003,1.2109,-4.7056,10.0344,.3789,-.0031,.0353,-.0982,-.0171,.1415,-.2745,.173],[69.7586,-.9059,1.1421,-3.8514,8.3464,.3466,-.0015,.0272,-.0852,-.0254,.1633,-.3147,.1963],[68.7204,-.7413,1.161,-4.8929,11.4709,.347,-.0023,.0323,-.0945,-.0166,.1384,-.2677,.1676],[70.0709,-.7105,1.1845,-4.9763,11.0263,.3366,-.0017,.0271,-.0857,-.0132,.1197,-.2317,.1451],[71.2247,-.6095,1.0475,-4.2244,9.2028,.3239,-8e-4,.022,-.0796,-.0212,.1383,-.2581,.1496],[71.0728,-.5897,.954,-3.2255,5.828,.3275,-5e-4,.0181,-.0707,-.02,.1457,-.2721,.1573],[70.0217,-.3531,.6571,-1.1748,.806,.3265,-6e-4,.0201,-.0785,-.0091,.1053,-.1976,.115],[70.5203,-.3866,.7711,-1.2734,-1.0004,.3319,-.0017,.0287,-.092,.009,.0424,-.0915,.0678],[76.3547,-.7212,.9341,-1.3303,-1.6526,.314,-2e-4,.0247,-.0938,-.0122,.0896,-.174,.1101],[90.6025,-1.3557,1.1746,.1551,-7.729,.2521,.0034,.0132,-.0881,-.0357,.0885,-.1674,.1033],[102.6662,-1.2263,.8589,3.2534,-15.7885,.1576,.0072,-.0076,-.0516,-.0325,.0706,-.1432,.1009],[102.9154,-1.5899,1.4523,-.5061,-7.5933,.1871,.0055,.002,-.0596,-.0411,.1113,-.2264,.1604],[125.2207,-3.3398,2.9466,-5.4863,-1.908,.1438,.0076,.0111,-.0959,-.1006,.1222,-.2249,.1376],[125.8697,-3.2997,3.1051,-7.3155,3.4281,.1505,.0067,.0193,-.1148,-.0879,.0819,-.1569,.1076],[99.6314,-2.8535,3.065,-6.4997,-4.9829,.3473,-.001,.0499,-.1346,-.0354,-.0379,.0681,-.0284]],ge=[[-13.567,-1.1325,-1.7078,28.8607,-81.1719,.4118,3e-4,-.0263,.0507,-.0087,-.1202,.2977,-.2691],[-43.7777,1.9512,-3.8763,28.8717,-57.6407,.4741,-.0029,-.0496,.1518,-.0191,.1992,-.2879,.0508],[-35.5221,1.6542,-3.2001,22.4882,-41.299,.4425,-.0025,-.0428,.1269,-.0674,.3133,-.465,.1062],[-25.9772,2.0924,-3.8188,24.4956,-38.8551,.3556,3e-4,-.0543,.1499,-.0796,.4423,-.7299,.2906],[-16.9931,2.2497,-3.7873,23.1323,-35.1791,.2916,6e-4,-.0481,.1416,-.0641,.3962,-.6572,.2638],[-19.6683,2.3137,-3.7117,22.8638,-35.7152,.3203,-.0015,-.0388,.1406,-.0689,.4499,-.7699,.3469],[-33.2858,2.7679,-4.0941,22.3138,-27.6548,.3986,-.0021,-.0592,.2053,-.0938,.6243,-1.0803,.5056],[-42.522,3.0229,-4.2155,22.1584,-27.6854,.4632,-.0051,-.0392,.1567,-.0631,.512,-.8671,.3759],[-34.2517,2.7721,-3.6109,17.4453,-15.4161,.4233,-.0055,-.0269,.1286,-.0371,.366,-.6077,.2427],[-42.4833,3.1554,-3.8233,16.9605,-12.0012,.466,-.0072,-.0191,.1105,-.0294,.3572,-.5855,.2225],[-54.4375,3.0764,-3.5785,15.2542,-9.8518,.569,-.0112,-.0014,.0879,-.034,.4004,-.6627,.2631],[-38.5925,2.3768,-3.1326,15.4931,-14.1216,.5015,-.0094,.0059,.0528,-.0475,.355,-.5818,.2245],[-40.8119,2.5241,-3.3547,16.1453,-12.993,.5119,-.0092,.0039,.0554,-.0504,.3968,-.6637,.2771],[-46.3014,2.6717,-3.5156,16.4588,-11.9729,.5495,-.0106,.0106,.0468,-.0493,.4299,-.7314,.3246],[-47.6314,2.9586,-3.758,16.7192,-10.3567,.5434,-.0102,.0067,.0518,-.0595,.4837,-.8241,.3686],[-41.6665,2.9392,-3.8754,17.5857,-10.8233,.4983,-.0073,-.0149,.0964,-.0817,.5737,-.987,.4563],[-45.7369,2.9396,-3.8633,17.231,-10.561,.5321,-.008,-.0146,.1016,-.0765,.5824,-1.0084,.4748],[-51.929,2.9378,-3.7832,15.9238,-7.0752,.586,-.0101,-.0013,.0747,-.0647,.5498,-.9515,.4469],[-45.8559,3.0516,-3.9216,17.0729,-10.1336,.5356,-.0086,-.0063,.0786,-.0616,.5196,-.8956,.415],[-39.5605,2.8551,-3.5847,14.9465,-5.3128,.5025,-.0082,-.003,.0687,-.0683,.5134,-.8848,.4109],[-33.7657,2.9223,-3.533,14.1257,-2.6863,.4575,-.0075,-.0012,.0596,-.0664,.4876,-.8388,.3872],[-32.281,2.6018,-3.2278,12.8399,-.8793,.472,-.0081,.0063,.0419,-.062,.4496,-.7751,.3605],[-31.5797,2.3929,-2.9101,11.2038,1.5782,.4845,-.0091,.0143,.0265,-.0586,.4152,-.712,.3258],[-32.2816,2.6349,-3.0487,11.5875,.5188,.4779,-.0097,.0203,.0104,-.044,.3694,-.6297,.2818],[-25.44,2.7183,-3.2535,13.5284,-4.0414,.421,-.007,.0038,.0396,-.0469,.3676,-.6261,.2792],[-22.8873,2.5652,-3.2543,13.672,-3.1603,.4141,-.0056,-.0066,.0583,-.0566,.3787,-.6382,.2747],[-20.7911,2.6849,-3.4699,14.9131,-5.2628,.3921,-.0042,-.015,.0686,-.0663,.3974,-.6642,.2789],[-18.557,2.4292,-3.0989,12.2737,1.0228,.3937,-.0045,-.0121,.0655,-.073,.4005,-.667,.277],[-17.5306,2.5085,-3.1093,11.7413,3.3022,.3838,-.0047,-.009,.0598,-.0637,.3744,-.6243,.2595],[-14.3488,2.3673,-3.0068,11.4653,3.7471,.3712,-.004,-.0129,.0679,-.0681,.3759,-.6244,.2561],[-16.6395,2.3516,-2.9622,11.2382,3.1551,.3924,-.0047,-.0114,.0678,-.0675,.3777,-.6258,.2543],[-10.6475,2.2971,-2.8656,10.1755,7.4446,.3509,-.0034,-.0169,.0752,-.0763,.3958,-.6548,.2643],[-10.0847,2.4662,-2.9361,10.2311,6.9534,.3368,-.0033,-.0182,.08,-.073,.3922,-.6484,.2607],[-9.646,2.4037,-2.8587,10.171,5.6614,.3398,-.0036,-.0141,.0709,-.0667,.3688,-.6116,.2487],[-5.5,2.2058,-2.7946,11.4006,-.0691,.3246,-.003,-.0129,.0635,-.0713,.3492,-.5757,.231],[-3.1184,2.0845,-2.7566,11.9122,-2.7527,.3161,-.0025,-.0137,.0596,-.0779,.347,-.5661,.2186],[-1.8889,1.938,-2.5612,10.5284,.4557,.3178,-.0027,-.01,.0505,-.0868,.3703,-.6072,.2401],[1.3652,1.8159,-2.5509,11.3987,-2.5982,.3031,-.002,-.0117,.0496,-.095,.3856,-.6354,.2568],[4.1129,1.8155,-2.5332,11.0415,-.7368,.2849,-.0018,-.0081,.038,-.0883,.364,-.6035,.2493],[1.4862,1.9999,-2.7504,12.2222,-3.4789,.295,-.0018,-.0113,.0461,-.0881,.3736,-.6168,.2503],[-2.474,2.0859,-2.8319,12.5224,-3.8212,.3229,-.0028,-.0094,.0487,-.086,.392,-.6551,.2772],[-.415,1.9078,-2.6838,12.7489,-6.852,.3217,-.0029,-.0082,.0472,-.0801,.3635,-.6077,.2576],[-.0497,1.8113,-2.6253,12.8018,-7.7129,.3277,-.0029,-.0071,.0414,-.0794,.3497,-.5807,.2402],[-1.5833,1.7827,-2.6894,13.4925,-9.1732,.3439,-.003,-.0061,.0371,-.0845,.3665,-.6098,.2548],[1.209,1.7298,-2.6076,12.8518,-6.9268,.3277,-.0027,-.0052,.0323,-.087,.3703,-.6203,.2656],[1.2834,1.6318,-2.5106,12.1368,-4.9164,.335,-.0025,-.0086,.0415,-.0924,.386,-.6467,.2773],[-.4438,1.6936,-2.4801,11.7414,-4.8147,.3463,-.0031,-.0075,.0435,-.0895,.3834,-.6422,.2749],[-.2325,1.613,-2.4272,12.1673,-8.1046,.3529,-.0033,-.0065,.0434,-.0851,.3606,-.6019,.2545],[-2.1989,1.6982,-2.4926,12.7697,-10.7769,.3643,-.0037,-.0061,.0459,-.0859,.3821,-.6441,.2821],[-.8411,1.6919,-2.4301,12.0592,-8.667,.3572,-.004,-5e-4,.0305,-.0865,.3748,-.6317,.2776],[.1678,1.6387,-2.3829,11.423,-6.0839,.3552,-.0038,-4e-4,.0275,-.0933,.3894,-.6552,.2867],[.8079,1.7778,-2.4652,11.0582,-4.0097,.3404,-.0029,-.0096,.0477,-.0928,.4036,-.6792,.2963],[-1.1219,1.8103,-2.4361,10.7708,-4.1791,.3561,-.0036,-.0078,.0484,-.0819,.3736,-.6278,.2717],[-4.8133,1.8058,-2.331,9.8828,-2.9487,.3871,-.0049,-.0019,.0409,-.0736,.3513,-.5879,.2503],[-8.1979,2.0298,-2.494,10.6089,-5.3076,.4011,-.0058,.0028,.0321,-.0692,.3504,-.5851,.247],[-6.752,2.0613,-2.4814,10.131,-3.6573,.3884,-.0055,2e-4,.0371,-.0753,.3769,-.6294,.2655],[-3.566,1.8329,-2.2802,9.0883,-.4962,.3807,-.005,-7e-4,.0371,-.081,.3819,-.6401,.2738],[1.0387,1.7975,-2.2844,9.2486,-.6268,.3494,-.0037,-.0064,.0437,-.0821,.3621,-.6004,.2472],[1.6962,1.5592,-2.1909,9.9497,-4.5187,.3625,-.0033,-.0098,.0505,-.0904,.364,-.5976,.2383],[1.7174,1.6924,-2.3499,11.1189,-8.075,.3556,-.0029,-.0144,.0602,-.0871,.3514,-.5716,.2195],[-1.1808,1.896,-2.4788,11.4555,-8.5302,.3668,-.0036,-.0124,.0586,-.0775,.3326,-.5377,.2006],[-1.9286,1.8974,-2.4107,10.6569,-6.2357,.3747,-.0042,-.0079,.0509,-.0731,.3224,-.5217,.1951],[-.6762,1.6316,-2.0498,8.2301,-.4293,.3859,-.0052,.0017,.0314,-.0748,.3067,-.4907,.1753],[.0177,1.3931,-1.7224,6.2104,3.67,.398,-.006,.0074,.0231,-.0781,.3064,-.4907,.1763],[1.8242,1.4415,-1.8531,7.4867,.3209,.381,-.0045,-.0055,.0517,-.0808,.3148,-.504,.181],[3.3864,1.5296,-1.8957,8.1805,-2.714,.3667,-.0046,-.0044,.0516,-.0669,.2582,-.4028,.1272],[1.4518,1.5557,-2.0588,9.891,-7.5275,.3836,-.0047,-.0045,.0515,-.0676,.2556,-.3964,.1218],[-.2228,1.7851,-2.3148,11.3445,-10.9345,.3835,-.0048,-.0063,.0572,-.0663,.2738,-.4312,.1425],[-1.2686,1.848,-2.3626,11.0795,-8.9995,.3885,-.0049,-.0053,.0531,-.0765,.3143,-.5003,.1745],[-1.1771,1.9498,-2.33,9.7844,-3.6954,.382,-.0052,-.0022,.0473,-.0778,.3354,-.5421,.202],[-1.5905,1.9246,-2.2012,8.7588,-1.7051,.39,-.0063,.0071,.0279,-.0723,.315,-.5067,.1847],[1.3907,1.7403,-1.9434,6.9646,2.6064,.3789,-.006,.0072,.0262,-.0787,.3279,-.5282,.1939],[5.7059,1.724,-1.9265,7.7741,-2.061,.3493,-.0054,.0068,.0244,-.0694,.282,-.4467,.1515],[12.6597,1.3459,-1.7148,8.837,-8.9553,.3265,-.0048,.0144,-.0045,-.065,.1958,-.2892,.0669],[14.3993,1.3957,-1.9442,11.1527,-15.7051,.3118,-.0037,.0089,-4e-4,-.0745,.2201,-.3286,.0822],[17.6818,1.388,-1.9866,11.7883,-17.7697,.2899,-.0031,.0095,-.0089,-.0708,.1938,-.2807,.056],[11.917,1.6817,-2.3045,13.3873,-21.1645,.3206,-.0046,.0186,-.0278,-.0691,.2114,-.3145,.0776],[9.2777,1.6967,-2.2055,11.4045,-13.2029,.3418,-.0056,.0253,-.0412,-.0758,.2487,-.3832,.1165],[5.8584,1.6874,-2.0515,9.5688,-8.1664,.3719,-.0073,.0382,-.0675,-.0715,.2508,-.3923,.1289],[9.3245,1.5374,-1.8954,9.7989,-11.7858,.3581,-.0073,.0413,-.0754,-.063,.2057,-.3147,.0928],[16.2286,1.2597,-1.7964,11.1013,-18.2966,.3267,-.0058,.0385,-.0835,-.0656,.1577,-.2201,.0326],[15.2268,1.0841,-1.7857,12.168,-22.5467,.3504,-.0059,.0373,-.0777,-.0718,.1751,-.253,.0528],[10.4724,1.4733,-2.2295,13.8392,-23.1801,.3634,-.0056,.0276,-.0497,-.0848,.2636,-.4153,.1436],[5.2365,1.5165,-2.1802,12.4214,-17.9441,.4039,-.0071,.0317,-.0486,-.0919,.3179,-.5147,.1988],[10.1259,1.4465,-1.9666,11.6878,-19.1724,.3722,-.0063,.0273,-.0379,-.0743,.2451,-.3873,.1349],[8.7996,1.6042,-2.2123,13.8638,-26.1613,.3767,-.006,.0209,-.0216,-.0624,.2044,-.3117,.0907],[7.3808,1.9753,-2.5467,14.6551,-24.7762,.366,-.0058,.0184,-.0173,-.0685,.2633,-.4213,.1535],[8.2409,1.8093,-1.8703,8.5537,-10.4574,.3742,-.008,.033,-.0361,-.0481,.1904,-.2951,.0924],[16.3443,1.4613,-1.5844,8.5531,-13.7014,.3376,-.0067,.028,-.0305,-.0421,.1473,-.2208,.0564],[13.6814,1.7899,-2.0949,11.8906,-20.3017,.3408,-.0062,.0239,-.0268,-.0499,.1898,-.2958,.0953],[-2.2305,2.0458,-2.0636,8.7608,-9.0684,.4491,-.0095,.0277,-.0118,-.0522,.2641,-.4295,.1659],[7.1024,1.4245,-1.2884,5.4006,-5.1633,.4266,-.0107,.0507,-.0701,-.0223,.0801,-.0982,-.0105],[22.5224,1.2411,-1.1587,5.4827,-6.229,.3231,-.008,.0497,-.0852,-.035,.0837,-.1047,-.0066],[7.1688,2.0574,-2.1429,8.7073,-6.973,.3913,-.0079,.0285,-.027,-.0746,.3209,-.5246,.2072],[10.9219,1.7121,-1.5447,6.0756,-5.588,.3914,-.0095,.0458,-.0634,-.034,.1515,-.2269,.0567],[.0292,1.3826,-1.5163,7.1831,-10.5716,.5124,-.0137,.0821,-.1555,-.0443,.1613,-.2416,.0645],[-7.4708,1.924,-1.6304,5.8484,-7.4136,.5394,-.0152,.0752,-.1166,-.0193,.205,-.3492,.1599],[17.4158,1.6902,-1.3304,3.6898,3.0431,.3737,-.0096,.0478,-.0772,-.0183,.131,-.2054,.0662],[-2.725,3.8134,-2.3052,3.5243,8.0191,.4042,-.0133,.0238,.0586,.0627,.0422,-.052,-.018]];function M(e){let t=e<0?-1:1,n=Math.abs(e)/Math.sqrt(2),r=1/(1+.3275911*n);return .5*(1+t*(1-((((1.061405429*r+-1.453152027)*r+1.421413741)*r+-.284496736)*r+.254829592)*r*Math.exp(-n*n)))}function N(e,t,n){let r=Math.max(0,Math.min(217,Math.round(e*12)-24)),i,a,o;t===`female`?(i=le[r],a=ue[r],o=de[r]):(i=A[r],a=j[r],o=fe[r]);let s=((n/a)**+i-1)/(i*o);return{z:s,percentile:M(s)*100}}function P(e,t,n,r,i){let a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b;t===`female`?(a=106.7,o=140.7,s=154,c=160.5,l=168.9,u=5,d=10.7,f=13.16,p=14.51,m=17.33,h=6.701,g=16.438,_=46.8,v=84.46,y=203.608,b=(e-10)*(n-147)):(a=107.8,o=140,s=154.5,c=166.4,l=179.1,u=5.06,d=10.79,f=13.22,p=14.51,m=17.3,h=-15,g=8.9,_=50.375,v=112.684,y=250.04,b=(e-10)*(n-150));let x=n,S=e,C=Math.max(0,x-a),w=Math.max(0,x-c),T=Math.max(0,x-l),ee=C**3-w**3*(l-a)/(l-c)+T**3*(c-a)/(l-c),te=Math.max(0,x-o)**3-w**3*(l-o)/(l-c)+T**3*(c-o)/(l-c),ne=Math.max(0,x-s)**3-w**3*(l-s)/(l-c)+T**3*(c-s)/(l-c),E=ee/100,re=te/100,ie=ne/100,ae=Math.max(0,S-u),D=Math.max(0,S-p),O=Math.max(0,S-m),k=ae**3-D**3*(m-u)/(m-p)+O**3*(p-u)/(m-p),oe=Math.max(0,S-d)**3-D**3*(m-d)/(m-p)+O**3*(p-d)/(m-p),se=Math.max(0,S-f)**3-D**3*(m-f)/(m-p)+O**3*(p-f)/(m-p),ce=k/100,le=oe/100,ue=se/100,de=Math.max(0,b-h),A=Math.max(0,b-v),j=Math.max(0,b-y),fe=de**3-A**3*(y-h)/(y-v)+j**3*(v-h)/(y-v),M=Math.max(0,b-g)**3-A**3*(y-g)/(y-v)+j**3*(v-g)/(y-v),N=Math.max(0,b-_)**3-A**3*(y-_)/(y-v)+j**3*(v-_)/(y-v),P=fe/1e4,F=M/1e4,I=N/1e4,L;L=t===`female`?r===`sys`?pe:me:r===`sys`?he:ge;let R=Array(99);for(let e=0;e<99;e++)R[e]=L[e][0]+L[e][5]*x+L[e][6]*E+L[e][7]*re+L[e][8]*ie+L[e][1]*S+L[e][2]*ce+L[e][3]*le+L[e][4]*ue+L[e][9]*b+L[e][10]*P+L[e][11]*F+L[e][12]*I;let z=1/0,B=50;for(let e=0;e<99;e++){let t=Math.abs(i-R[e]);t=13?(a=r>=140?`stage2`:r>=130?`stage1`:r>=120?`elevated`:`normal`,o=i>=90?`stage2`:i>=80?`stage1`:`normal`):(a=t>=107||r>=140?`stage2`:t>=95||r>=130?`stage1`:t>=90||r>=120?`elevated`:`normal`,o=n>=107||i>=90?`stage2`:n>=95||i>=80?`stage1`:n>=90?`elevated`:`normal`);let s={normal:0,elevated:1,stage1:2,stage2:3},c=s[a]>=s[o]?a:o;return{sysClass:a,diaClass:o,classification:c}}function I(e,t,n,r,i){let a=N(e,t,n),o=P(e,t,n,`sys`,r),s=P(e,t,n,`dia`,i),c=F(e,o.percentile,s.percentile,r,i);return{sysPercentile:o.percentile,diaPercentile:s.percentile,heightPercentile:a.percentile,sysClass:c.sysClass,diaClass:c.diaClass,classification:c.classification}}var L=n(),R=`rounded-lg border border-border bg-card p-5 space-y-3`,z=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,B=`block text-xs font-medium text-muted-foreground`,_e=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,ve=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,ye=`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,V={normal:{label:`Normal`,color:`#10b981`,bg:`#d1fae5`},elevated:{label:`Elevated`,color:`#f59e0b`,bg:`#fef3c7`},stage1:{label:`Stage 1 Hypertension`,color:`#f97316`,bg:`#ffedd5`},stage2:{label:`Stage 2 Hypertension`,color:`#ef4444`,bg:`#fee2e2`}};function be(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(`female`),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(null);function h(){let t=Number.parseFloat(e),r=Number.parseFloat(i),a=Number.parseFloat(o),s=Number.parseFloat(c);if(!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(s)){f(`Fill in all fields.`),m(null);return}if(t<1||t>17){f(`Age must be 1-17 years.`),m(null);return}if(r<50||r>200){f(`Height must be 50-200 cm.`),m(null);return}f(``),m(I(t,n,r,a,s))}let g=p?V[p.classification]:null;return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-bp`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`BP Percentile (AAP 2017)`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Age (years)`}),(0,L.jsx)(`input`,{type:`number`,min:`1`,max:`17`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`bp-age`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Sex`}),(0,L.jsxs)(`select`,{className:z,value:n,onChange:e=>r(e.target.value),"data-testid":`bp-sex`,children:[(0,L.jsx)(`option`,{value:`female`,children:`Female`}),(0,L.jsx)(`option`,{value:`male`,children:`Male`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Height (cm)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`200`,step:`0.1`,className:z,value:i,onChange:e=>a(e.target.value),"data-testid":`bp-height`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`SBP (mmHg)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`220`,step:`1`,className:z,value:o,onChange:e=>s(e.target.value),"data-testid":`bp-sbp`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`DBP (mmHg)`}),(0,L.jsx)(`input`,{type:`number`,min:`30`,max:`150`,step:`1`,className:z,value:c,onChange:e=>u(e.target.value),"data-testid":`bp-dbp`})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:h,className:_e,"data-testid":`calc-bp-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{t(``),a(``),s(``),u(``),m(null),f(``)},className:ve,children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:ye,children:d}),p&&g&&(0,L.jsxs)(`div`,{className:`rounded-lg p-4 space-y-2`,style:{background:g.bg,borderLeft:`4px solid ${g.color}`},"data-testid":`calc-bp-result`,children:[(0,L.jsx)(`div`,{className:`text-base font-bold`,style:{color:g.color},children:g.label}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Systolic`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.sysPercentile,`th %ile`]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:V[p.sysClass].label})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Diastolic`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.diaPercentile,`th %ile`]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:V[p.diaClass].label})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Height`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.heightPercentile.toFixed(0),`th %ile`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Overall`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:g.label})]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Flynn JT et al. Clinical Practice Guideline for Screening and Management of High Blood Pressure in Children and Adolescents. Pediatrics 2017;140(3):e20171904.`})]})}function xe(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(`male`),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(null);function h(){let t=(Number.parseFloat(e)||0)+(Number.parseInt(n,10)||0)/12,r=Number.parseFloat(o),a=Number.parseFloat(c);if(!t||!Number.isFinite(r)||r<=0||!Number.isFinite(a)||a<=0){f(`Fill in all fields.`),m(null);return}if(t<2||t>20){f(`Age must be 2-20 years.`),m(null);return}f(``),m(ce(r,a,Math.round(t*12),i))}return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-bmi`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`BMI Percentile (CDC 2000)`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:col-span-1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Age (yr)`}),(0,L.jsx)(`input`,{type:`number`,min:`2`,max:`20`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`bmi-age-yr`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Months`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`11`,className:z,value:n,onChange:e=>r(e.target.value),"data-testid":`bmi-age-mo`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Sex`}),(0,L.jsxs)(`select`,{className:z,value:i,onChange:e=>a(e.target.value),"data-testid":`bmi-sex`,children:[(0,L.jsx)(`option`,{value:`male`,children:`Male`}),(0,L.jsx)(`option`,{value:`female`,children:`Female`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Weight (kg)`}),(0,L.jsx)(`input`,{type:`number`,min:`1`,max:`200`,step:`0.1`,className:z,value:o,onChange:e=>s(e.target.value),"data-testid":`bmi-weight`})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-1`,children:[(0,L.jsx)(`label`,{className:B,children:`Height (cm)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`220`,step:`0.1`,className:z,value:c,onChange:e=>u(e.target.value),"data-testid":`bmi-height`})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:h,className:_e,"data-testid":`calc-bmi-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{t(``),r(``),s(``),u(``),m(null),f(``)},className:ve,children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:ye,children:d}),p&&(0,L.jsxs)(`div`,{className:`rounded-lg p-4 space-y-2`,style:{background:p.classification.bg,borderLeft:`4px solid ${p.classification.color}`},"data-testid":`calc-bmi-result`,children:[(0,L.jsx)(`div`,{className:`text-base font-bold`,style:{color:p.classification.color},children:p.classification.label}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`BMI `,p.bmi.toFixed(1),` kg/m² — `,p.percentile,`th percentile`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`BMI`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.bmi.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Percentile`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.percentile,`th`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Z-Score`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.z.toFixed(2)})]}),p.percentile>=85&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`% of 95th`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.classification.pctOf95.toFixed(0),`%`]})]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`CDC 2000 LMS tables · Kuczmarski et al. Vital Health Stat 11. 2002;(246).`})]})}var Se={premie:{label:`Premie`,hr:{awake:`120-170`,sleeping:`100-150`},rr:`40-70`,sbp:`55-75`,dbp:`35-45`,temp:`36.5-37.5`,weight:`0.5-2.5 kg`,spo2:`88-95% (target)`,notes:[`HR and RR are highly variable and depend on gestational age`,`BP increases with gestational age and postnatal age`,`Target SpO2 88-95% to reduce retinopathy of prematurity risk`,`Temperature instability is common — use servo-controlled warmers`,`Bradycardia (<100 bpm) and apnea are common in premature infants`]},"0-3mo":{label:`0-3 Months`,hr:{awake:`100-150`,sleeping:`85-135`},rr:`35-55`,sbp:`65-85`,dbp:`45-55`,temp:`36.5-37.5`,weight:`2.5-6 kg`,spo2:`>95%`,notes:[`HR normally increases with crying (up to 180-190 bpm) — this is physiologic`,`Periodic breathing (pauses <10 sec) is normal in neonates`,`Acrocyanosis (blue hands/feet) is normal; central cyanosis is not`,`BP is best measured in the right arm (pre-ductal) in neonates`,`Normal weight loss of 5-7% in first 3-5 days; regain by 10-14 days`]},"3-6mo":{label:`3-6 Months`,hr:{awake:`90-120`,sleeping:`75-110`},rr:`30-45`,sbp:`70-90`,dbp:`50-65`,temp:`36.5-37.5`,weight:`5-8 kg`,spo2:`>95%`,notes:[`Expected weight gain: 20-30 g/day (150-200 g/week)`,`HR gradually decreases as vagal tone matures`,`RR >60 at rest may indicate lower respiratory tract disease`,`BP should be measured with appropriate cuff size (width 40% of arm circumference)`]},"6-12mo":{label:`6-12 Months`,hr:{awake:`80-120`,sleeping:`70-110`},rr:`25-40`,sbp:`80-100`,dbp:`55-65`,temp:`36.0-37.5`,weight:`8-10 kg`,spo2:`>95%`,notes:[`Expected weight: triple birth weight by 12 months (~10 kg average)`,`Weight gain slows to ~10-15 g/day`,`Sinus arrhythmia (HR varies with breathing) is normal`,`Febrile tachycardia: HR increases ~10 bpm per 1 degree C above 37`]},"1-3yr":{label:`1-3 Years`,hr:{awake:`70-110`,sleeping:`60-100`},rr:`20-30`,sbp:`90-105`,dbp:`55-70`,temp:`36.0-37.5`,weight:`10-15 kg`,spo2:`>95%`,notes:[`Expected weight gain: ~200-250 g/month (2-2.5 kg/year)`,`Tachycardia: HR >110 at rest warrants evaluation`,`Tachypnea: RR >30 at rest may indicate respiratory distress`,`BP screening begins at age 3 per AAP 2017 guidelines`,`Estimated weight: 2 x (age in years) + 8`]},"3-6yr":{label:`3-6 Years`,hr:{awake:`65-110`,sleeping:`55-100`},rr:`20-25`,sbp:`95-110`,dbp:`60-75`,temp:`36.0-37.5`,weight:`14-20 kg`,spo2:`>95%`,notes:[`Annual BP screening recommended from age 3`,`Normal BP <90th percentile for age, sex, and height`,`Elevated BP: 90th to <95th percentile (or 120/80 if lower)`,`Estimated weight: 2 x (age in years) + 8`,`ETT size (uncuffed): (age/4) + 4`]},"6-12yr":{label:`6-12 Years`,hr:{awake:`60-95`,sleeping:`50-85`},rr:`14-22`,sbp:`100-120`,dbp:`60-75`,temp:`36.0-37.5`,weight:`20-40 kg`,spo2:`>95%`,notes:[`Resting HR >95 or <60 warrants evaluation`,`BP should be measured at every clinical encounter`,`Stage 1 HTN: >=95th percentile on 3 separate occasions`,`Estimated weight: 3 x (age in years) + 7`,`ETT size (cuffed): (age/4) + 3.5`]},">12yr":{label:`>12 Years`,hr:{awake:`55-85`,sleeping:`45-75`},rr:`12-18`,sbp:`110-135`,dbp:`65-85`,temp:`36.0-37.5`,weight:`40-80 kg`,spo2:`>95%`,notes:[`Vital signs approach adult values`,`From age 13: use adult BP thresholds (AAP 2017)`,`Normal: <120/<80 mmHg; Elevated: 120-129/<80 mmHg`,`Stage 1 HTN: 130-139/80-89 mmHg; Stage 2 HTN: >=140/>=90 mmHg`,`Orthostatic vitals: measure lying, sitting, standing if dizzy`,`Athletic bradycardia (HR 45-60) may be normal in trained adolescents`]}},Ce=[`premie`,`0-3mo`,`3-6mo`,`6-12mo`,`1-3yr`,`3-6yr`,`6-12yr`,`>12yr`];function we(){let[e,t]=(0,l.useState)(`1-3yr`),n=Se[e];return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-vitals`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Vital Signs by Age`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Age group`}),(0,L.jsx)(`select`,{className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`vitals-age-select`,children:Ce.map(e=>(0,L.jsx)(`option`,{value:e,children:Se[e].label},e))})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-sm`,"data-testid":`vitals-result`,children:[(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Heart rate (awake)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.hr.awake,` bpm`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Heart rate (sleep)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.hr.sleeping,` bpm`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Respiratory rate`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.rr,` /min`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`SpO₂`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:n.spo2})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`SBP`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.sbp,` mmHg`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`DBP`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.dbp,` mmHg`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Temperature`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.temp,` °C`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Weight`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:n.weight})]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs`,children:[(0,L.jsx)(`div`,{className:`font-semibold mb-1`,children:`Clinical notes`}),(0,L.jsx)(`ul`,{className:`list-disc pl-5 space-y-0.5`,children:n.notes.map((e,t)=>(0,L.jsx)(`li`,{children:e},t))})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook 23rd ed · PALS · AAP 2017 BP guidelines.`})]})}var Te=[{name:`Adenosine`,indication:`SVT`,category:`cardiac`,route:`IV/IO rapid bolus`,calc:e=>{let t=+(e*.1).toFixed(2),n=+(e*.2).toFixed(2),r=+(e*.3).toFixed(2);return{dose:`${t} mg (0.1 mg/kg)`,extra:`May repeat: ${Math.min(n,12)} mg (0.2 mg/kg), then ${Math.min(r,12)} mg (0.3 mg/kg)`,max:`Max first dose 6 mg, max subsequent 12 mg`}}},{name:`Amiodarone`,indication:`VT / VF`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*5).toFixed(1);return{dose:`${Math.min(t,300)} mg (5 mg/kg)`,extra:`No pulse: push undiluted. Pulse: over 20-60 min. Subsequent max 150 mg.`,max:`Max first 300 mg, max total 15 mg/kg/24hr or 2200 mg`}}},{name:`Atropine`,indication:`Bradycardia`,category:`cardiac`,route:`IV/IO/IM`,calc:e=>{let t=+(e*.02).toFixed(3),n=`${(e*.04).toFixed(3)}-${(e*.06).toFixed(3)}`;return{dose:`${Math.min(t,.5)} mg (0.02 mg/kg)`,extra:`ETT dose: ${n} mg (0.04-0.06 mg/kg)`,max:`Max single 0.5 mg, max total 1 mg`}}},{name:`Calcium Chloride 10%`,indication:`Hypocalcemia / Hyperkalemia`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*20).toFixed(0);return{dose:`${Math.min(t,1e3)} mg (20 mg/kg)`,extra:`Give slowly. Central line preferred.`,max:`Max 1 g (1000 mg)`}}},{name:`Calcium Gluconate 10%`,indication:`Hypocalcemia / Hyperkalemia`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*60).toFixed(0);return{dose:`${Math.min(t,3e3)} mg (60 mg/kg)`,extra:`Give slowly over 10-20 min with cardiac monitoring.`,max:`Max 3 g (3000 mg)`}}},{name:`Dextrose`,indication:`Hypoglycemia`,category:`metabolic`,route:`IV`,calc:e=>{let t=`${+(e*.5).toFixed(1)}-${+(e*1).toFixed(1)}`,n=``;return n=e<5?`D10W: ${(e*5).toFixed(1)}-${(e*10).toFixed(1)} mL (5-10 mL/kg)`:e<45?`D25W: ${(e*2).toFixed(1)}-${(e*4).toFixed(1)} mL (2-4 mL/kg)`:`D50W: ${(e*1).toFixed(1)}-${(e*2).toFixed(1)} mL (1-2 mL/kg)`,{dose:`${t} g (0.5-1 g/kg)`,extra:n,max:`Max 25 g`}}},{name:`Epinephrine`,indication:`Pulseless arrest / Anaphylaxis`,category:`cardiac`,route:`IV/IO/IM/ETT`,calc:e=>{let t=+(e*.01).toFixed(3),n=+(e*.1).toFixed(2),r=+(e*.1).toFixed(2),i=+(e*.01).toFixed(3);return{dose:`${Math.min(t,1)} mg IV/IO (0.01 mg/kg of 0.1 mg/mL = ${Math.min(n,10)} mL) q3-5 min`,extra:`ETT: ${Math.min(r,2.5)} mg (0.1 mg/kg of 1 mg/mL). Anaphylaxis IM: ${Math.min(i,.5)} mg (0.01 mg/kg)`,max:`Max IV 1 mg, max ETT 2.5 mg, max IM 0.5 mg`}}},{name:`Hydrocortisone`,indication:`Adrenal crisis`,category:`metabolic`,route:`IV/IM/IO`,calc:e=>{let t=+(e*2).toFixed(1);return{dose:`${Math.min(t,100)} mg (2 mg/kg)`,extra:`Stress dosing for adrenal insufficiency.`,max:`Max 100 mg`}}},{name:`Insulin (Regular)`,indication:`Hyperkalemia`,category:`metabolic`,route:`IV`,calc:e=>{let t=+(e*.1).toFixed(2),n=+(e*.5).toFixed(1);return{dose:`${Math.min(t,5)} units (0.1 units/kg)`,extra:`Give with ${n} g/kg dextrose (0.5 g/kg). Monitor glucose closely.`,max:`Max 5 units`}}},{name:`Lidocaine`,indication:`Antiarrhythmic`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*1).toFixed(1),n=`${(e*2).toFixed(1)}-${(e*3).toFixed(1)}`;return{dose:`${Math.min(t,100)} mg (1 mg/kg)`,extra:`ETT: ${n} mg (2-3 mg/kg). May repeat q5 min.`,max:`Max 100 mg/dose, max total 3 mg/kg`}}},{name:`Magnesium Sulfate`,indication:`Torsades de Pointes`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*50).toFixed(0);return{dose:`${Math.min(t,2e3)} mg (50 mg/kg)`,extra:`Give over 10-20 min (faster if pulseless).`,max:`Max 2 g (2000 mg)`}}},{name:`Naloxone`,indication:`Opioid overdose`,category:`reversal`,route:`IV/IO/IM/IN/ETT`,calc:e=>{let t=`${+(e*.001).toFixed(4)}-${+(e*.005).toFixed(4)}`,n=+(e*.1).toFixed(3);return{dose:`Partial: ${t} mg (0.001-0.005 mg/kg)`,extra:`Full reversal: ${Math.min(n,2)} mg (0.1 mg/kg)`,max:`Max partial first dose 0.1 mg, max full 2 mg`}}},{name:`Sodium Bicarbonate`,indication:`Metabolic acidosis`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*1).toFixed(1);return{dose:`${Math.min(t,50)} mEq (1 mEq/kg)`,extra:e<10?`Dilute to 0.5 mEq/mL (use 4.2% solution) for neonates/small infants.`:`Use 8.4% solution (1 mEq/mL).`,max:`Max 50 mEq`}}}],H={cardiac:`#ef4444`,metabolic:`#3b82f6`,reversal:`#10b981`},Ee={cardiac:`Cardiac`,metabolic:`Metabolic`,reversal:`Reversal`};function De(){let[e,t]=(0,l.useState)(``),n=Number.parseFloat(e);return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-resus`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Resus Medications`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Weight (kg)`}),(0,L.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`resus-weight`})]}),Number.isFinite(n)&&n>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`text-sm font-semibold`,children:[`Doses for `,n,` kg patient`]}),(0,L.jsx)(`div`,{className:`flex gap-3 flex-wrap text-xs`,children:[`cardiac`,`metabolic`,`reversal`].map(e=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full`,style:{background:H[e]}}),Ee[e]]},e))}),(0,L.jsx)(`div`,{className:`grid gap-3 grid-cols-1 md:grid-cols-2 lg:grid-cols-3`,"data-testid":`resus-result`,children:Te.map(e=>{let t=e.calc(n),r=H[e.category];return(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card overflow-hidden`,style:{borderColor:r+`55`},children:[(0,L.jsxs)(`div`,{className:`px-3 py-2 border-b`,style:{background:r+`10`,borderColor:r+`22`},children:[(0,L.jsx)(`div`,{className:`text-sm font-bold`,style:{color:r},children:e.name}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.indication})]}),(0,L.jsxs)(`div`,{className:`p-3 text-sm space-y-1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:`Dose:`}),` `,t.dose]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.extra}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`strong`,{children:`Max:`}),` `,t.max]}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`strong`,{children:`Route:`}),` `,e.route]})]})]},e.name)})}),(0,L.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,L.jsx)(`strong`,{children:`Disclaimer:`}),` Always verify doses against institutional protocols and current guidelines.`]})]}):(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var Oe={premie:{label:`Premie (1-3 kg)`,bvm:`Infant`,nasal:`12 Fr`,oral:`Infant`,blade:`Miller 0`,ett:`2.5-3.0`,lma:`1`,glidescope:`1`,iv:`22-24 ga`,cvl:`3 Fr`,ngt:`5 Fr`,chest:`10-12 Fr`,foley:`6 Fr`},newborn:{label:`Newborn (2-4 kg)`,bvm:`Infant`,nasal:`14-16 Fr`,oral:`Small 50 mm`,blade:`Miller 0`,ett:`3.0-3.5`,lma:`1`,glidescope:`1`,iv:`22-24 ga`,cvl:`3-4 Fr`,ngt:`5-8 Fr`,chest:`10-12 Fr`,foley:`6 Fr`},"6mo":{label:`6 months (6-8 kg)`,bvm:`Infant`,nasal:`14-16 Fr`,oral:`Small 60 mm`,blade:`Miller 1`,ett:`3.5`,lma:`1.5`,glidescope:`2`,iv:`20-24 ga`,cvl:`4 Fr`,ngt:`8 Fr`,chest:`12-18 Fr`,foley:`8 Fr`},"1yr":{label:`1 year (10 kg)`,bvm:`Small child`,nasal:`14-18 Fr`,oral:`Small 60 mm`,blade:`Miller 1 / MAC 2`,ett:`4.0`,lma:`2`,glidescope:`2`,iv:`20-24 ga`,cvl:`4-5 Fr`,ngt:`10 Fr`,chest:`16-20 Fr`,foley:`8 Fr`},"2-3yr":{label:`2-3 years (12-16 kg)`,bvm:`Small child`,nasal:`14-18 Fr`,oral:`Small 70 mm`,blade:`Miller 1 / MAC 2`,ett:`4.0-4.5`,lma:`2`,glidescope:`2`,iv:`18-22 ga`,cvl:`4-5 Fr`,ngt:`10-12 Fr`,chest:`16-24 Fr`,foley:`8 Fr`},"4-6yr":{label:`4-6 years (20-25 kg)`,bvm:`Child`,nasal:`16-20 Fr`,oral:`Small 70-80 mm`,blade:`Miller 2 / MAC 2`,ett:`4.5-5.0`,lma:`2.5`,glidescope:`3`,iv:`18-22 ga`,cvl:`5 Fr`,ngt:`12-14 Fr`,chest:`20-28 Fr`,foley:`8 Fr`},"7-10yr":{label:`7-10 years (25-35 kg)`,bvm:`Child / Small adult`,nasal:`18-22 Fr`,oral:`Medium 80-90 mm`,blade:`Miller 2 / MAC 2`,ett:`5.5-6.0`,lma:`2.5-3`,glidescope:`3`,iv:`18-22 ga`,cvl:`5 Fr`,ngt:`12-14 Fr`,chest:`20-32 Fr`,foley:`8 Fr`},"11-15yr":{label:`11-15 years (40-50 kg)`,bvm:`Adult`,nasal:`22-36 Fr`,oral:`Medium 90 mm`,blade:`Miller 2 / MAC 3`,ett:`6.0-6.5`,lma:`3`,glidescope:`3 or 4`,iv:`18-20 ga`,cvl:`7 Fr`,ngt:`14-18 Fr`,chest:`28-38 Fr`,foley:`10 Fr`},"16yr":{label:`16+ years (>50 kg)`,bvm:`Adult`,nasal:`22-36 Fr`,oral:`Medium 90 mm`,blade:`Miller 2 / MAC 3`,ett:`7.0-8.0`,lma:`4`,glidescope:`3 or 4`,iv:`18-20 ga`,cvl:`7 Fr`,ngt:`14-18 Fr`,chest:`28-42 Fr`,foley:`12 Fr`}},ke=[`premie`,`newborn`,`6mo`,`1yr`,`2-3yr`,`4-6yr`,`7-10yr`,`11-15yr`,`16yr`];function Ae(){let[e,t]=(0,l.useState)(`1yr`),n=Oe[e],r=[[`BVM`,n.bvm],[`Nasopharyngeal`,n.nasal],[`Oropharyngeal`,n.oral],[`Laryngoscope`,n.blade],[`ETT`,n.ett],[`LMA`,n.lma],[`Glidescope`,n.glidescope],[`IV`,n.iv],[`Central line`,n.cvl],[`NG tube`,n.ngt],[`Chest tube`,n.chest],[`Foley`,n.foley]];return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-equipment`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Equipment Sizing`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Age / weight band`}),(0,L.jsx)(`select`,{className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`equip-age-select`,children:ke.map(e=>(0,L.jsx)(`option`,{value:e,children:Oe[e].label},e))})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3 text-sm`,"data-testid":`equip-result`,children:r.map(([e,t])=>(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:e}),(0,L.jsx)(`div`,{className:`font-semibold`,children:t})]},e))}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook · PALS · Broselow cross-reference.`})]})}var U=`rounded-lg border border-border bg-card p-5 space-y-3`,W=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,G=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,K=`space-y-1`,q=`block text-xs font-medium text-muted-foreground`,J=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,Y=`rounded-lg border border-border bg-muted/40 p-4`,X=`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,Z=[{id:`bp`,label:`BP Percentile`,summary:`AAP 2017 age/height/sex-adjusted BP percentiles (Rosner quantile splines).`,source:`AAP 2017 (Flynn) — Rosner splines`,ported:!0},{id:`bmi`,label:`BMI Percentile`,summary:`BMI-for-age (CDC 2000 z-score tables).`,source:`CDC 2000 LMS`,ported:!0},{id:`growth`,label:`Growth Charts`,summary:`Fenton 2013 preterm weight-for-GA with Z-score + percentile + SGA/AGA/LGA classification.`,source:`Fenton 2013 LMS`,ported:!0},{id:`bili`,label:`Bilirubin`,summary:`AAP 2022 phototherapy + exchange thresholds and Bhutani nomogram risk zones.`,source:`AAP 2022 (Kemper) + Bhutani 1999`,ported:!0},{id:`vitals`,label:`Vital Signs`,summary:`Normal HR / RR / BP ranges by age.`,source:`Harriet Lane + PALS + AHA`,ported:!0},{id:`bsa`,label:`Body Surface Area`,summary:`Mosteller body surface area formula.`,source:`Mosteller 1987`,ported:!0},{id:`dose`,label:`Weight-Based Dosing`,summary:`Generic mg/kg dosing with optional max-dose cap and concentration conversion.`,source:`Legacy calculator formula`,ported:!0},{id:`resus`,label:`Resus Meds`,summary:`Code-cart dosing (epinephrine, amiodarone, atropine, etc.).`,source:`PALS`,ported:!0},{id:`gcs`,label:`GCS`,summary:`Child/adult and infant Glasgow Coma Scale variants.`,source:`Teasdale + pediatric modification`,ported:!0},{id:`equipment`,label:`Equipment`,summary:`ETT size, blade, NG, Foley, suction by age/weight.`,source:`PALS + Broselow cross-reference`,ported:!0}];function je(e){if(!e.trim())return null;let t=Number(e);return Number.isFinite(t)?t:null}function Q({id:e,labelText:t,value:n,onChange:r,min:i,max:a,step:o=`0.1`,placeholder:s}){return(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:e,className:q,children:t}),(0,L.jsx)(`input`,{id:e,type:`number`,min:i,max:a,step:o,value:n,onChange:e=>r(e.target.value),placeholder:s,className:J})]})}function Me(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``);function u(){let t=a(Number(e),Number(n));if(t==null){c(`Enter a valid weight and height.`),o(null);return}c(``),o(t)}function d(){t(``),r(``),o(null),c(``)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-bsa`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Body Surface Area`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Mosteller formula: BSA (m2) = sqrt(height(cm) x weight(kg) / 3600).`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsx)(Q,{id:`react-bsa-weight`,labelText:`Weight (kg)`,value:e,onChange:t,min:`1`,max:`200`,placeholder:`20`}),(0,L.jsx)(Q,{id:`react-bsa-height`,labelText:`Height (cm)`,value:n,onChange:r,min:`30`,max:`220`,placeholder:`110`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:u,className:W,"data-testid":`calc-bsa-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:d,className:G,children:`Clear`})]}),s?(0,L.jsx)(`div`,{className:X,children:s}):null,i==null?null:(0,L.jsxs)(`div`,{className:Y,"data-testid":`calc-bsa-result`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Mosteller BSA`}),(0,L.jsxs)(`div`,{className:`text-2xl font-semibold`,children:[i.toFixed(3),` m²`]}),(0,L.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[e,` kg, `,n,` cm`]})]})]})}function Ne(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(`1`),[o,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(``);function g(){let t=s({weightKg:Number(e),dosePerKg:Number(n),frequencyPerDay:Number(i),maxSingleDoseMg:je(o),concentrationMgPerMl:je(u)});if(t==null){h(`Enter a valid weight, mg/kg dose, and frequency.`),p(null);return}h(``),p(t)}function _(){t(``),r(``),a(`1`),c(``),d(``),p(null),h(``)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-dose`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Weight-Based Dosing`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Generic mg/kg calculator. Always verify medication-specific dosing against formulary and local policy.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsx)(Q,{id:`react-dose-weight`,labelText:`Patient Weight (kg)`,value:e,onChange:t,min:`1`,max:`200`,placeholder:`15`}),(0,L.jsx)(Q,{id:`react-dose-per-kg`,labelText:`Dose (mg/kg)`,value:n,onChange:r,min:`0.01`,step:`0.01`,placeholder:`10`}),(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`react-dose-frequency`,className:q,children:`Frequency`}),(0,L.jsxs)(`select`,{id:`react-dose-frequency`,value:i,onChange:e=>a(e.target.value),className:J,children:[(0,L.jsx)(`option`,{value:`1`,children:`Once daily`}),(0,L.jsx)(`option`,{value:`2`,children:`Twice daily (BID)`}),(0,L.jsx)(`option`,{value:`3`,children:`Three times daily (TID)`}),(0,L.jsx)(`option`,{value:`4`,children:`Four times daily (QID)`}),(0,L.jsx)(`option`,{value:`6`,children:`Every 4 hours (Q4H)`})]})]}),(0,L.jsx)(Q,{id:`react-dose-max`,labelText:`Max single dose (mg, optional)`,value:o,onChange:c,min:`0`,step:`1`,placeholder:`500`}),(0,L.jsx)(Q,{id:`react-dose-concentration`,labelText:`Concentration (mg/mL, optional)`,value:u,onChange:d,min:`0`,placeholder:`40`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:g,className:W,"data-testid":`calc-dose-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:_,className:G,children:`Clear`})]}),m?(0,L.jsx)(`div`,{className:X,children:m}):null,f==null?null:(0,L.jsx)(`div`,{className:Y,"data-testid":`calc-dose-result`,children:(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Single Dose`}),(0,L.jsxs)(`div`,{className:`text-xl font-semibold`,children:[f.singleDoseMg.toFixed(1),` mg`]}),f.capped?(0,L.jsx)(`div`,{className:`text-xs text-red-600`,children:`Capped at max dose`}):null]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Daily Total`}),(0,L.jsxs)(`div`,{className:`text-xl font-semibold`,children:[f.dailyDoseMg.toFixed(1),` mg/day`]}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`x `,f.frequencyPerDay,`/day`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Volume`}),(0,L.jsx)(`div`,{className:`text-xl font-semibold`,children:f.volumeMl==null?`n/a`:`${f.volumeMl.toFixed(1)} mL`}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`per dose`})]})]})})]})}var Pe={child:{eye:[[`4`,`4 - Spontaneous`],[`3`,`3 - To speech`],[`2`,`2 - To pain`],[`1`,`1 - None`]],verbal:[[`5`,`5 - Oriented`],[`4`,`4 - Confused`],[`3`,`3 - Inappropriate words`],[`2`,`2 - Incomprehensible sounds`],[`1`,`1 - None`]],motor:[[`6`,`6 - Obeys commands`],[`5`,`5 - Localizes pain`],[`4`,`4 - Withdraws to pain`],[`3`,`3 - Abnormal flexion`],[`2`,`2 - Abnormal extension`],[`1`,`1 - None`]]},infant:{eye:[[`4`,`4 - Spontaneous`],[`3`,`3 - To speech/sound`],[`2`,`2 - To painful stimuli`],[`1`,`1 - None`]],verbal:[[`5`,`5 - Coos/babbles`],[`4`,`4 - Irritable cry`],[`3`,`3 - Cries to pain`],[`2`,`2 - Moans to pain`],[`1`,`1 - None`]],motor:[[`6`,`6 - Normal spontaneous movement`],[`5`,`5 - Withdraws to touch`],[`4`,`4 - Withdraws to pain`],[`3`,`3 - Abnormal flexion`],[`2`,`2 - Abnormal extension`],[`1`,`1 - None`]]}};function $({id:e,labelText:t,value:n,options:r,onChange:i}){return(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:e,className:q,children:t}),(0,L.jsx)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),className:J,children:r.map(([e,t])=>(0,L.jsx)(`option`,{value:e,children:t},e))})]})}function Fe(){let[e,t]=(0,l.useState)(`child`),[n,i]=(0,l.useState)(`4`),[a,o]=(0,l.useState)(`5`),[s,c]=(0,l.useState)(`6`),u=r(Number(n),Number(a),Number(s)),d=Pe[e];function f(e){t(e),i(`4`),o(`5`),c(`6`)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-gcs`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Glasgow Coma Scale`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select responses to calculate child/adult or infant-modified GCS. Total score 3-15.`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(`child`),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(e===`child`?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),children:`Child / Adult`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(`infant`),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(e===`infant`?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),children:`Infant`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsx)($,{id:`react-gcs-eye`,labelText:`Eye Opening`,value:n,options:d.eye,onChange:i}),(0,L.jsx)($,{id:`react-gcs-verbal`,labelText:`Verbal Response`,value:a,options:d.verbal,onChange:o}),(0,L.jsx)($,{id:`react-gcs-motor`,labelText:`Motor Response`,value:s,options:d.motor,onChange:c})]}),u==null?null:(0,L.jsxs)(`div`,{className:Y,"data-testid":`calc-gcs-result`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e===`infant`?`Infant-modified GCS`:`Child / adult GCS`}),(0,L.jsxs)(`div`,{className:`text-3xl font-semibold`,children:[`GCS: `,u.total,`/15`]}),(0,L.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u.severity}),(0,L.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:`Interpretation: 13-15 Mild, 9-12 Moderate, 3-8 Severe/Coma.`})]})]})}function Ie({pill:e}){return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-`+e.id,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary}),(0,L.jsxs)(`div`,{className:`rounded-md border border-amber-300 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm space-y-2`,children:[(0,L.jsxs)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:[(0,L.jsx)(`strong`,{children:`Source of truth:`}),` `,e.source,`.`]}),(0,L.jsx)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:`This calculator runs in the legacy viewer. A React port is gated on capturing test vectors from the vanilla implementation so the numerical output can be verified byte-for-byte — the migration checkpoint specifically flags this class of data as the one an LLM is most likely to silently simplify.`})]}),(0,L.jsx)(`a`,{href:`/#calculators`,className:W+` inline-block`,children:`Open in legacy viewer`})]})}function Le(){let[e,t]=(0,l.useState)(`aap`),[n,r]=(0,l.useState)(`38`),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(`low`),[d,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(``);function _(){let t=Number(i),r=Number(o);if(!Number.isFinite(t)||!Number.isFinite(r)||t<=0||r<=0){g(`Enter hours of life and TSB (mg/dL).`),f(null),m(null);return}if(g(``),e===`aap`){let e=Number(n);if(!Number.isFinite(e)||e<35){g(`AAP 2022 thresholds apply to GA ≥35 weeks.`),f(null);return}f(D(e,t,r,c)),m(null)}else m(re(t,r)),f(null)}let v=d?d.status===`Above Exchange`?`text-red-800 bg-red-100`:d.status===`Above Phototherapy`?`text-red-700 bg-red-50`:`text-green-700 bg-green-50`:``,y=p?p.zone===`High-Risk`?`text-red-800 bg-red-100`:p.zone===`High-Intermediate`?`text-orange-700 bg-orange-50`:p.zone===`Low-Intermediate`?`text-amber-700 bg-amber-50`:`text-green-700 bg-green-50`:``;return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-bili`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Bilirubin`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(`aap`),className:`px-3 py-1 rounded text-xs font-medium `+(e===`aap`?`bg-primary text-primary-foreground`:`bg-muted`),"data-testid":`bili-mode-aap`,children:`AAP 2022 Phototherapy`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(`bhutani`),className:`px-3 py-1 rounded text-xs font-medium `+(e===`bhutani`?`bg-primary text-primary-foreground`:`bg-muted`),"data-testid":`bili-mode-bhutani`,children:`Bhutani Nomogram`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e===`aap`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`bili-ga`,className:q,children:`GA (weeks)`}),(0,L.jsx)(`select`,{id:`bili-ga`,className:J,value:n,onChange:e=>r(e.target.value),children:[35,36,37,38,39,40].map(e=>(0,L.jsxs)(`option`,{value:e,children:[e,e===40?`+`:``]},e))})]}),(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`bili-risk`,className:q,children:`Neurotoxicity risk`}),(0,L.jsxs)(`select`,{id:`bili-risk`,className:J,value:c,onChange:e=>u(e.target.value),children:[(0,L.jsx)(`option`,{value:`low`,children:`No risk factors`}),(0,L.jsx)(`option`,{value:`medium`,children:`With risk factors`})]})]})]}),(0,L.jsx)(Q,{id:`bili-hours`,labelText:`Age (hours)`,value:i,onChange:a,min:`0`,max:`336`,placeholder:`48`}),(0,L.jsx)(Q,{id:`bili-tsb`,labelText:`TSB (mg/dL)`,value:o,onChange:s,min:`0`,max:`50`,placeholder:`15`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:W,onClick:_,"data-testid":`calc-bili-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,className:G,onClick:()=>{a(``),s(``),f(null),m(null),g(``)},children:`Clear`})]}),h&&(0,L.jsx)(`div`,{className:X,children:h}),d&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-bili-aap-result`,children:[(0,L.jsx)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+v,children:d.status}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`TSB `,o,` mg/dL at `,i,` hours of life (GA `,n,`w `,c===`medium`?`with`:`without`,` risk factors)`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Phototherapy`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[d.photoThreshold.toFixed(1),` mg/dL`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Exchange`}),(0,L.jsxs)(`div`,{className:`font-semibold text-red-800`,children:[d.exchangeThreshold.toFixed(1),` mg/dL`]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP 2022 CPG (Kemper et al.). Always use clinical judgment.`})]}),p&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-bili-bhutani-result`,children:[(0,L.jsxs)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+y,children:[p.zone,` Zone`]}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`TSB `,o,` mg/dL at `,i,` hours of life`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`40th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p40.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`75th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p75.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`95th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p95.toFixed(1)})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Bhutani 1999 hour-specific risk nomogram for infants ≥35 weeks GA.`})]})]})}function Re(){let[e,t]=(0,l.useState)(`male`),[n,r]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,u]=(0,l.useState)(null),[d,f]=(0,l.useState)(``);function p(){let t=Number(n),r=Number(a);if(!Number.isFinite(t)||!Number.isFinite(r)||t<22||t>50||r<=0){f(`Enter GA (22-50 weeks) and weight (grams).`),u(null);return}f(``),u(i(t,r,e))}let m=s?c(s.percentile):null,h=m===`SGA`?`text-orange-700 bg-orange-50`:m===`LGA`?`text-amber-700 bg-amber-50`:`text-green-700 bg-green-50`;return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-growth`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Fenton 2013 Preterm Growth`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Weight-for-gestational-age Z-score + percentile + SGA/AGA/LGA classification.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`fenton-sex`,className:q,children:`Sex`}),(0,L.jsxs)(`select`,{id:`fenton-sex`,className:J,value:e,onChange:e=>t(e.target.value),children:[(0,L.jsx)(`option`,{value:`male`,children:`Male`}),(0,L.jsx)(`option`,{value:`female`,children:`Female`})]})]}),(0,L.jsx)(Q,{id:`fenton-ga`,labelText:`GA (weeks)`,value:n,onChange:r,min:`22`,max:`50`,step:`0.1`,placeholder:`32`}),(0,L.jsx)(Q,{id:`fenton-weight`,labelText:`Weight (g)`,value:a,onChange:o,min:`200`,max:`7000`,step:`10`,placeholder:`1500`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:W,onClick:p,"data-testid":`calc-fenton-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,className:G,onClick:()=>{r(``),o(``),u(null),f(``)},children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:X,children:d}),s&&m&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-fenton-result`,children:[(0,L.jsx)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+h,children:m}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Percentile`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[s.percentile.toFixed(1),`%`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Z-score`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:s.z.toFixed(2)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Median (M)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[Math.round(s.M),` g`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`L / S`}),(0,L.jsxs)(`div`,{className:`font-mono text-xs`,children:[s.L.toFixed(3),` / `,s.S.toFixed(3)]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Fenton TR, Kim JH. Systematic review — revised Fenton growth chart for preterm infants. BMC Pediatr 2013;13:59.`})]})]})}function ze({pill:e}){return e.id===`bsa`?(0,L.jsx)(Me,{}):e.id===`dose`?(0,L.jsx)(Ne,{}):e.id===`gcs`?(0,L.jsx)(Fe,{}):e.id===`bili`?(0,L.jsx)(Le,{}):e.id===`growth`?(0,L.jsx)(Re,{}):e.id===`bmi`?(0,L.jsx)(xe,{}):e.id===`vitals`?(0,L.jsx)(we,{}):e.id===`resus`?(0,L.jsx)(De,{}):e.id===`equipment`?(0,L.jsx)(Ae,{}):e.id===`bp`?(0,L.jsx)(be,{}):(0,L.jsx)(Ie,{pill:e})}function Be(){let[e,t]=(0,l.useState)(Z[0].id),n=Z.find(t=>t.id===e)??Z[0];return(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-4`,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Calculators`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric calculators — BP percentiles, bilirubin thresholds, growth, dosing, equipment sizing. Simple pure-formula calculators run in React now; high-risk table-driven calculators remain legacy-gated until vectors are captured.`})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`calc-subnav`,children:Z.map(n=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(e===n.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`calc-pill-`+n.id,children:[n.label,n.ported?(0,L.jsx)(`span`,{className:`ml-1 text-[10px] opacity-80`,children:`React`}):null]},n.id))}),(0,L.jsx)(ze,{pill:n})]})}export{Be as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{a as r,n as i,o as a,r as o,s,t as c}from"./fenton-BaYL-F22.js";var l=e(t(),1),u={p95:{6:6,12:7.2,18:8.5,24:9.6,30:11.2,36:12.8,42:13.8,48:14.8,54:15.6,60:16.2,66:16.8,72:17.4,84:18,96:18.4,108:18.8,120:19},p75:{6:4.5,12:5.5,18:6.6,24:7.8,30:9.2,36:10.6,42:11.6,48:12.6,54:13.4,60:14,66:14.6,72:15,84:15.4,96:15.6,108:15.8,120:16},p40:{6:3,12:4,18:5,24:6.2,30:7.2,36:8.4,42:9.2,48:10,54:10.6,60:11.2,66:11.8,72:12.2,84:12.6,96:12.8,108:13,120:13.2}},d={12:8.5,13:8.7,14:8.9,15:9,16:9.2,17:9.4,18:9.6,19:9.8,20:9.9,21:10.1,22:10.3,23:10.4,24:10.6,25:10.8,26:10.9,27:11.1,28:11.3,29:11.4,30:11.6,31:11.7,32:11.9,33:12,34:12.2,35:12.3,36:12.5,37:12.6,38:12.8,39:12.9,40:13.1,41:13.2,42:13.4,43:13.5,44:13.6,45:13.8,46:13.9,47:14,48:14.2,49:14.3,50:14.4,51:14.5,52:14.7,53:14.8,54:14.9,55:15,56:15.1,57:15.3,58:15.4,59:15.5,60:15.6,61:15.7,62:15.8,63:15.9,64:16,65:16.1,66:16.2,67:16.3,68:16.4,69:16.5,70:16.6,71:16.7,72:16.8,73:16.9,74:17,75:17.1,76:17.2,77:17.3,78:17.4,79:17.5,80:17.5,81:17.6,82:17.7,83:17.8,84:17.8,85:17.9,86:18,87:18.1,88:18.1,89:18.2,90:18.3,91:18.3,92:18.4,93:18.5,94:18.5,95:18.6,96:18.6},f={12:9,13:9.2,14:9.4,15:9.6,16:9.8,17:9.9,18:10.1,19:10.3,20:10.5,21:10.6,22:10.8,23:11,24:11.2,25:11.3,26:11.5,27:11.7,28:11.8,29:12,30:12.1,31:12.3,32:12.5,33:12.6,34:12.8,35:12.9,36:13.1,37:13.2,38:13.4,39:13.5,40:13.7,41:13.8,42:13.9,43:14.1,44:14.2,45:14.4,46:14.5,47:14.6,48:14.8,49:14.9,50:15,51:15.1,52:15.3,53:15.4,54:15.5,55:15.6,56:15.8,57:15.9,58:16,59:16.1,60:16.2,61:16.3,62:16.5,63:16.6,64:16.7,65:16.8,66:16.9,67:17,68:17.1,69:17.2,70:17.3,71:17.4,72:17.5,73:17.6,74:17.7,75:17.8,76:17.9,77:17.9,78:18,79:18.1,80:18.2,81:18.3,82:18.4,83:18.4,84:18.5,85:18.6,86:18.7,87:18.8,88:18.8,89:18.9,90:19,91:19,92:19.1,93:19.2,94:19.2,95:19.3,96:19.3},p={12:9.6,13:9.8,14:9.9,15:10.1,16:10.3,17:10.5,18:10.7,19:10.8,20:11,21:11.2,22:11.4,23:11.5,24:11.7,25:11.9,26:12.1,27:12.2,28:12.4,29:12.5,30:12.7,31:12.9,32:13,33:13.2,34:13.3,35:13.5,36:13.6,37:13.8,38:13.9,39:14.1,40:14.2,41:14.4,42:14.5,43:14.7,44:14.8,45:15,46:15.1,47:15.2,48:15.4,49:15.5,50:15.6,51:15.8,52:15.9,53:16,54:16.1,55:16.3,56:16.4,57:16.5,58:16.6,59:16.7,60:16.9,61:17,62:17.1,63:17.2,64:17.3,65:17.4,66:17.5,67:17.6,68:17.7,69:17.8,70:17.9,71:18,72:18.1,73:18.2,74:18.3,75:18.4,76:18.5,77:18.6,78:18.7,79:18.8,80:18.9,81:19,82:19,83:19.1,84:19.2,85:19.3,86:19.4,87:19.4,88:19.5,89:19.6,90:19.7,91:19.7,92:19.8,93:19.9,94:19.9,95:20,96:20},m={12:10.1,13:10.3,14:10.5,15:10.7,16:10.8,17:11,18:11.2,19:11.4,20:11.6,21:11.7,22:11.9,23:12.1,24:12.3,25:12.4,26:12.6,27:12.8,28:12.9,29:13.1,30:13.3,31:13.4,32:13.6,33:13.8,34:13.9,35:14.1,36:14.2,37:14.4,38:14.5,39:14.7,40:14.8,41:15,42:15.1,43:15.3,44:15.4,45:15.6,46:15.7,47:15.8,48:16,49:16.1,50:16.2,51:16.4,52:16.5,53:16.6,54:16.8,55:16.9,56:17,57:17.1,58:17.3,59:17.4,60:17.5,61:17.6,62:17.7,63:17.8,64:17.9,65:18.1,66:18.2,67:18.3,68:18.4,69:18.5,70:18.6,71:18.7,72:18.8,73:18.9,74:19,75:19.1,76:19.2,77:19.3,78:19.4,79:19.5,80:19.5,81:19.6,82:19.7,83:19.8,84:19.9,85:20,86:20,87:20.1,88:20.2,89:20.3,90:20.3,91:20.4,92:20.5,93:20.6,94:20.6,95:20.7,96:20.7},h={12:10.6,13:10.8,14:11,15:11.2,16:11.4,17:11.6,18:11.8,19:11.9,20:12.1,21:12.3,22:12.5,23:12.7,24:12.8,25:13,26:13.2,27:13.3,28:13.5,29:13.7,30:13.8,31:14,32:14.2,33:14.3,34:14.5,35:14.7,36:14.8,37:15,38:15.1,39:15.3,40:15.4,41:15.6,42:15.7,43:15.9,44:16,45:16.2,46:16.3,47:16.4,48:16.6,49:16.7,50:16.8,51:17,52:17.1,53:17.2,54:17.4,55:17.5,56:17.6,57:17.8,58:17.9,59:18,60:18.1,61:18.2,62:18.4,63:18.5,64:18.6,65:18.7,66:18.8,67:18.9,68:19,69:19.1,70:19.2,71:19.3,72:19.5,73:19.6,74:19.7,75:19.7,76:19.8,77:19.9,78:20,79:20.1,80:20.2,81:20.3,82:20.4,83:20.5,84:20.6,85:20.6,86:20.7,87:20.8,88:20.9,89:21,90:21,91:21.1,92:21.2,93:21.3,94:21.3,95:21.4,96:21.5},g={12:11.2,13:11.3,14:11.5,15:11.7,16:11.9,17:12.1,18:12.3,19:12.5,20:12.7,21:12.8,22:13,23:13.2,24:13.4,25:13.6,26:13.7,27:13.9,28:14.1,29:14.2,30:14.4,31:14.6,32:14.7,33:14.9,34:15.1,35:15.2,36:15.4,37:15.6,38:15.7,39:15.9,40:16,41:16.2,42:16.3,43:16.5,44:16.6,45:16.8,46:16.9,47:17.1,48:17.2,49:17.4,50:17.5,51:17.6,52:17.8,53:17.9,54:18.1,55:18.2,56:18.3,57:18.5,58:18.6,59:18.7,60:18.9,61:19,62:19.1,63:19.3,64:19.4,65:19.5,66:19.6,67:19.7,68:19.9,69:20,70:20.1,71:20.2,72:20.3,73:20.4,74:20.5,75:20.6,76:20.7,77:20.8,78:20.9,79:21,80:21.1,81:21.2,82:21.3,83:21.4,84:21.5,85:21.5,86:21.6,87:21.7,88:21.8,89:21.9,90:21.9,91:22,92:22.1,93:22.2,94:22.2,95:22.3,96:22.3},_={12:6.9,13:7.1,14:7.2,15:7.4,16:7.6,17:7.7,18:7.9,19:8.1,20:8.2,21:8.4,22:8.6,23:8.7,24:8.9,25:9,26:9.2,27:9.3,28:9.5,29:9.6,30:9.8,31:9.9,32:10.1,33:10.2,34:10.3,35:10.5,36:10.6,37:10.8,38:10.9,39:11,40:11.2,41:11.3,42:11.4,43:11.5,44:11.7,45:11.8,46:11.9,47:12,48:12.2,49:12.3,50:12.4,51:12.5,52:12.6,53:12.7,54:12.8,55:13,56:13.1,57:13.2,58:13.3,59:13.4,60:13.5,61:13.6,62:13.7,63:13.8,64:13.9,65:14,66:14.1,67:14.2,68:14.2,69:14.3,70:14.4,71:14.5,72:14.6,73:14.7,74:14.8,75:14.8,76:14.9,77:15,78:15.1,79:15.1,80:15.2,81:15.3,82:15.3,83:15.4,84:15.5,85:15.5,86:15.6,87:15.7,88:15.7,89:15.8,90:15.8,91:15.9,92:15.9,93:16,94:16.1,95:16.1,96:16.1},v={12:7.4,13:7.6,14:7.8,15:8,16:8.1,17:8.3,18:8.5,19:8.6,20:8.8,21:9,22:9.1,23:9.3,24:9.4,25:9.6,26:9.8,27:9.9,28:10.1,29:10.2,30:10.4,31:10.5,32:10.7,33:10.8,34:11,35:11.1,36:11.2,37:11.4,38:11.5,39:11.7,40:11.8,41:11.9,42:12.1,43:12.2,44:12.3,45:12.5,46:12.6,47:12.7,48:12.8,49:13,50:13.1,51:13.2,52:13.3,53:13.4,54:13.5,55:13.7,56:13.8,57:13.9,58:14,59:14.1,60:14.2,61:14.3,62:14.4,63:14.5,64:14.6,65:14.7,66:14.8,67:14.9,68:15,69:15.1,70:15.2,71:15.3,72:15.4,73:15.4,74:15.5,75:15.6,76:15.7,77:15.8,78:15.8,79:15.9,80:16,81:16.1,82:16.1,83:16.2,84:16.3,85:16.4,86:16.4,87:16.5,88:16.6,89:16.6,90:16.7,91:16.7,92:16.8,93:16.8,94:16.9,95:17,96:17},y={12:8,13:8.1,14:8.3,15:8.5,16:8.7,17:8.9,18:9,19:9.2,20:9.4,21:9.5,22:9.7,23:9.9,24:10,25:10.2,26:10.4,27:10.5,28:10.7,29:10.8,30:11,31:11.1,32:11.3,33:11.4,34:11.6,35:11.7,36:11.9,37:12,38:12.2,39:12.3,40:12.4,41:12.6,42:12.7,43:12.9,44:13,45:13.1,46:13.2,47:13.4,48:13.5,49:13.6,50:13.8,51:13.9,52:14,53:14.1,54:14.2,55:14.4,56:14.5,57:14.6,58:14.7,59:14.8,60:14.9,61:15,62:15.1,63:15.2,64:15.3,65:15.4,66:15.5,67:15.6,68:15.7,69:15.8,70:15.9,71:16,72:16.1,73:16.2,74:16.3,75:16.4,76:16.5,77:16.6,78:16.6,79:16.7,80:16.8,81:16.9,82:17,83:17,84:17.1,85:17.2,86:17.2,87:17.3,88:17.4,89:17.4,90:17.5,91:17.6,92:17.6,93:17.7,94:17.8,95:17.8,96:17.9},b={12:8.5,13:8.6,14:8.8,15:9,16:9.2,17:9.4,18:9.5,19:9.7,20:9.9,21:10,22:10.2,23:10.4,24:10.5,25:10.7,26:10.8,27:11,28:11.2,29:11.3,30:11.5,31:11.6,32:11.8,33:11.9,34:12.1,35:12.2,36:12.4,37:12.5,38:12.7,39:12.8,40:12.9,41:13.1,42:13.2,43:13.3,44:13.5,45:13.6,46:13.7,47:13.9,48:14,49:14.1,50:14.2,51:14.4,52:14.5,53:14.6,54:14.7,55:14.8,56:14.9,57:15.1,58:15.2,59:15.3,60:15.4,61:15.5,62:15.6,63:15.7,64:15.8,65:15.9,66:16,67:16.1,68:16.2,69:16.3,70:16.4,71:16.5,72:16.6,73:16.6,74:16.7,75:16.8,76:16.9,77:17,78:17.1,79:17.1,80:17.2,81:17.3,82:17.4,83:17.4,84:17.5,85:17.6,86:17.6,87:17.7,88:17.8,89:17.8,90:17.9,91:18,92:18,93:18.1,94:18.1,95:18.2,96:18.2},x={12:16.4,13:16.5,14:16.6,15:16.8,16:16.9,17:17,18:17.2,19:17.3,20:17.4,21:17.5,22:17.7,23:17.8,24:17.9,25:18,26:18.2,27:18.3,28:18.4,29:18.5,30:18.7,31:18.8,32:18.9,33:19,34:19.1,35:19.2,36:19.4,37:19.5,38:19.6,39:19.7,40:19.8,41:19.9,42:20,43:20.1,44:20.2,45:20.3,46:20.5,47:20.6,48:20.7,49:20.8,50:20.9,51:21,52:21.1,53:21.2,54:21.3,55:21.4,56:21.5,57:21.6,58:21.7,59:21.7,60:21.8,61:21.9,62:22,63:22.1,64:22.2,65:22.3,66:22.4,67:22.5,68:22.6,69:22.6,70:22.7,71:22.8,72:22.9,73:23,74:23.1,75:23.1,76:23.2,77:23.3,78:23.4,79:23.4,80:23.5,81:23.6,82:23.7,83:23.7,84:23.8,85:23.9,86:23.9,87:24,88:24.1,89:24.1,90:24.2,91:24.3,92:24.3,93:24.4,94:24.4,95:24.5,96:24.5},S={12:17.5,13:17.7,14:17.8,15:17.9,16:18.1,17:18.2,18:18.3,19:18.5,20:18.6,21:18.7,22:18.9,23:19,24:19.1,25:19.2,26:19.4,27:19.5,28:19.6,29:19.7,30:19.9,31:20,32:20.1,33:20.2,34:20.4,35:20.5,36:20.6,37:20.7,38:20.8,39:20.9,40:21,41:21.2,42:21.3,43:21.4,44:21.5,45:21.6,46:21.7,47:21.8,48:21.9,49:22,50:22.1,51:22.2,52:22.3,53:22.4,54:22.5,55:22.6,56:22.7,57:22.8,58:22.9,59:23,60:23.1,61:23.2,62:23.2,63:23.3,64:23.4,65:23.5,66:23.6,67:23.7,68:23.8,69:23.8,70:23.9,71:24,72:24.1,73:24.1,74:24.2,75:24.3,76:24.4,77:24.4,78:24.5,79:24.6,80:24.6,81:24.7,82:24.8,83:24.8,84:24.9,85:25,86:25,87:25.1,88:25.2,89:25.2,90:25.3,91:25.3,92:25.4,93:25.4,94:25.5,95:25.5,96:25.5},C={12:18.7,13:18.8,14:18.9,15:19.1,16:19.2,17:19.4,18:19.5,19:19.6,20:19.8,21:19.9,22:20.1,23:20.2,24:20.3,25:20.5,26:20.6,27:20.7,28:20.8,29:21,30:21.1,31:21.2,32:21.3,33:21.5,34:21.6,35:21.7,36:21.8,37:21.9,38:22.1,39:22.2,40:22.3,41:22.4,42:22.5,43:22.6,44:22.7,45:22.8,46:22.9,47:23,48:23.1,49:23.2,50:23.3,51:23.4,52:23.5,53:23.6,54:23.7,55:23.8,56:23.9,57:24,58:24.1,59:24.2,60:24.3,61:24.4,62:24.5,63:24.5,64:24.6,65:24.7,66:24.8,67:24.9,68:24.9,69:25,70:25.1,71:25.2,72:25.2,73:25.3,74:25.4,75:25.5,76:25.5,77:25.6,78:25.7,79:25.7,80:25.8,81:25.8,82:25.9,83:26,84:26,85:26.1,86:26.1,87:26.2,88:26.2,89:26.3,90:26.3,91:26.4,92:26.4,93:26.5,94:26.5,95:26.5,96:26.6},w={12:19.7,13:19.9,14:20,15:20.1,16:20.3,17:20.4,18:20.6,19:20.7,20:20.8,21:21,22:21.1,23:21.2,24:21.4,25:21.5,26:21.6,27:21.7,28:21.9,29:22,30:22.1,31:22.2,32:22.3,33:22.4,34:22.6,35:22.7,36:22.8,37:22.9,38:23,39:23.1,40:23.2,41:23.3,42:23.4,43:23.5,44:23.6,45:23.7,46:23.8,47:23.9,48:24,49:24.1,50:24.2,51:24.3,52:24.4,53:24.5,54:24.6,55:24.7,56:24.7,57:24.8,58:24.9,59:25,60:25.1,61:25.2,62:25.2,63:25.3,64:25.4,65:25.5,66:25.5,67:25.6,68:25.7,69:25.7,70:25.8,71:25.9,72:25.9,73:26,74:26,75:26.1,76:26.2,77:26.2,78:26.3,79:26.3,80:26.4,81:26.4,82:26.5,83:26.5,84:26.6,85:26.6,86:26.7,87:26.7,88:26.7,89:26.8,90:26.8,91:26.9,92:26.9,93:26.9,94:27,95:27,96:27},T={12:14.6,13:14.8,14:14.9,15:15,16:15.1,17:15.3,18:15.4,19:15.5,20:15.6,21:15.8,22:15.9,23:16,24:16.1,25:16.2,26:16.3,27:16.4,28:16.5,29:16.6,30:16.8,31:16.9,32:17,33:17.1,34:17.2,35:17.3,36:17.4,37:17.5,38:17.6,39:17.7,40:17.7,41:17.8,42:17.9,43:18,44:18.1,45:18.2,46:18.3,47:18.4,48:18.5,49:18.5,50:18.6,51:18.7,52:18.8,53:18.9,54:18.9,55:19,56:19.1,57:19.2,58:19.2,59:19.3,60:19.4,61:19.4,62:19.5,63:19.6,64:19.6,65:19.7,66:19.8,67:19.8,68:19.9,69:19.9,70:20,71:20.1,72:20.1,73:20.2,74:20.2,75:20.3,76:20.3,77:20.4,78:20.4,79:20.5,80:20.5,81:20.6,82:20.6,83:20.6,84:20.7,85:20.7,86:20.8,87:20.8,88:20.8,89:20.9,90:20.9,91:20.9,92:21,93:21,94:21,95:21.1,96:21.1},ee={12:15.2,13:15.3,14:15.4,15:15.6,16:15.7,17:15.8,18:15.9,19:16.1,20:16.2,21:16.3,22:16.4,23:16.5,24:16.6,25:16.8,26:16.9,27:17,28:17.1,29:17.2,30:17.3,31:17.4,32:17.5,33:17.6,34:17.7,35:17.8,36:17.9,37:18,38:18.1,39:18.2,40:18.3,41:18.4,42:18.5,43:18.6,44:18.7,45:18.8,46:18.9,47:19,48:19.1,49:19.2,50:19.2,51:19.3,52:19.4,53:19.5,54:19.6,55:19.7,56:19.7,57:19.8,58:19.9,59:20,60:20.1,61:20.1,62:20.2,63:20.3,64:20.3,65:20.4,66:20.5,67:20.6,68:20.6,69:20.7,70:20.8,71:20.8,72:20.9,73:20.9,74:21,75:21.1,76:21.1,77:21.2,78:21.2,79:21.3,80:21.4,81:21.4,82:21.5,83:21.5,84:21.6,85:21.6,86:21.7,87:21.7,88:21.8,89:21.8,90:21.9,91:21.9,92:22,93:22,94:22,95:22.1,96:22.1},te={12:15.7,13:15.9,14:16,15:16.1,16:16.2,17:16.4,18:16.5,19:16.6,20:16.7,21:16.8,22:17,23:17.1,24:17.2,25:17.3,26:17.4,27:17.5,28:17.7,29:17.8,30:17.9,31:18,32:18.1,33:18.2,34:18.3,35:18.4,36:18.5,37:18.6,38:18.7,39:18.8,40:18.9,41:19,42:19.1,43:19.2,44:19.3,45:19.4,46:19.5,47:19.6,48:19.7,49:19.8,50:19.9,51:20,52:20.1,53:20.1,54:20.2,55:20.3,56:20.4,57:20.5,58:20.6,59:20.7,60:20.7,61:20.8,62:20.9,63:21,64:21.1,65:21.1,66:21.2,67:21.3,68:21.4,69:21.4,70:21.5,71:21.6,72:21.7,73:21.7,74:21.8,75:21.9,76:21.9,77:22,78:22.1,79:22.1,80:22.2,81:22.3,82:22.3,83:22.4,84:22.5,85:22.5,86:22.6,87:22.6,88:22.7,89:22.8,90:22.8,91:22.9,92:22.9,93:23,94:23,95:23.1,96:23.1},ne={12:16.3,13:16.4,14:16.5,15:16.6,16:16.7,17:16.9,18:17,19:17.1,20:17.2,21:17.3,22:17.4,23:17.6,24:17.7,25:17.8,26:17.9,27:18,28:18.1,29:18.2,30:18.3,31:18.4,32:18.5,33:18.7,34:18.8,35:18.9,36:19,37:19.1,38:19.2,39:19.3,40:19.4,41:19.5,42:19.6,43:19.7,44:19.8,45:19.9,46:19.9,47:20,48:20.1,49:20.2,50:20.3,51:20.4,52:20.5,53:20.6,54:20.7,55:20.8,56:20.8,57:20.9,58:21,59:21.1,60:21.2,61:21.3,62:21.3,63:21.4,64:21.5,65:21.6,66:21.7,67:21.7,68:21.8,69:21.9,70:22,71:22,72:22.1,73:22.2,74:22.2,75:22.3,76:22.4,77:22.5,78:22.5,79:22.6,80:22.7,81:22.7,82:22.8,83:22.8,84:22.9,85:23,86:23,87:23.1,88:23.1,89:23.2,90:23.3,91:23.3,92:23.4,93:23.4,94:23.5,95:23.5,96:23.5};function E(e,t){let n=Object.keys(e).map(Number).sort((e,t)=>e-t);if(t<=n[0])return e[n[0]];if(t>=n[n.length-1])return e[n[n.length-1]];for(let r=0;r=n[r]&&t<=n[r+1]){let i=(t-n[r])/(n[r+1]-n[r]);return e[n[r]]+i*(e[n[r+1]]-e[n[r]])}return e[n[0]]}function re(e,t){let n=E(u.p95,e),r=E(u.p75,e),i=E(u.p40,e),a;return a=t>=n?`High-Risk`:t>=r?`High-Intermediate`:t>=i?`Low-Intermediate`:`Low-Risk`,{p95:n,p75:r,p40:i,zone:a}}function ie(e,t){return t===`medium`?e===35?_:e===36?v:e===37?y:b:e===35?d:e===36?f:e===37?p:e===38?m:e===39?h:g}function ae(e,t){return t===`medium`?e===35?T:e===36?ee:e===37?te:ne:e===35?x:e===36?S:e===37?C:w}function D(e,t,n,r){let i=E(ie(e,r),t),a=E(ae(e,r),t),o;return o=n>=a?`Above Exchange`:n>=i?`Above Phototherapy`:`Below Phototherapy`,{photoThreshold:i,exchangeThreshold:a,status:o}}var O={male:{24:{L:-1.982374,M:16.5478,S:.080127},30:{L:-1.642107,M:16.2497,S:.075499},36:{L:-1.419991,M:16.0003,S:.072634},42:{L:-1.438165,M:15.7941,S:.071495},48:{L:-1.714869,M:15.6282,S:.071889},54:{L:-2.155348,M:15.5026,S:.073491},60:{L:-2.615166,M:15.4191,S:.075992},66:{L:-2.981797,M:15.3795,S:.079211},72:{L:-3.211705,M:15.3835,S:.083048},78:{L:-3.314769,M:15.429,S:.0874},84:{L:-3.323189,M:15.5129,S:.092131},90:{L:-3.270455,M:15.6317,S:.097082},96:{L:-3.183058,M:15.7823,S:.102091},102:{L:-3.079383,M:15.9617,S:.107013},108:{L:-2.971148,M:16.1671,S:.111721},114:{L:-2.865311,M:16.3961,S:.116113},120:{L:-2.765648,M:16.6461,S:.120112},126:{L:-2.673903,M:16.9151,S:.123664},132:{L:-2.59056,M:17.2009,S:.126735},138:{L:-2.51532,M:17.5014,S:.129309},144:{L:-2.447426,M:17.8146,S:.131389},150:{L:-2.385858,M:18.1387,S:.132991},156:{L:-2.329457,M:18.4718,S:.134141},162:{L:-2.277017,M:18.812,S:.13488},168:{L:-2.227362,M:19.1576,S:.135251},174:{L:-2.179426,M:19.5067,S:.135309},180:{L:-2.132345,M:19.8577,S:.13511},186:{L:-2.085574,M:20.2086,S:.134718},192:{L:-2.039015,M:20.5576,S:.134198},198:{L:-1.99315,M:20.9029,S:.13362},204:{L:-1.949135,M:21.2425,S:.133057},210:{L:-1.908831,M:21.5742,S:.132585},216:{L:-1.87467,M:21.8959,S:.132286},222:{L:-1.849323,M:22.2054,S:.132249},228:{L:-1.835138,M:22.5007,S:.132566},234:{L:-1.833401,M:22.7799,S:.133339},240:{L:-1.843581,M:23.0414,S:.134675}},female:{24:{L:-1.024497,M:16.388,S:.085026},30:{L:-1.534542,M:16.0059,S:.080932},36:{L:-2.096829,M:15.6992,S:.078605},42:{L:-2.618733,M:15.4647,S:.077904},48:{L:-3.018522,M:15.2985,S:.078713},54:{L:-3.2593,M:15.1961,S:.080904},60:{L:-3.350078,M:15.1519,S:.0843},66:{L:-3.325522,M:15.1606,S:.08868},72:{L:-3.225607,M:15.2169,S:.093803},78:{L:-3.084291,M:15.3161,S:.099427},84:{L:-2.926187,M:15.4536,S:.105325},90:{L:-2.76731,M:15.6252,S:.111295},96:{L:-2.617192,M:15.827,S:.117159},102:{L:-2.480952,M:16.0552,S:.122771},108:{L:-2.360921,M:16.3061,S:.128014},114:{L:-2.257782,M:16.5763,S:.132797},120:{L:-2.171296,M:16.8623,S:.137057},126:{L:-2.100749,M:17.161,S:.140754},132:{L:-2.045235,M:17.4691,S:.143868},138:{L:-2.003802,M:17.7836,S:.146399},144:{L:-1.975521,M:18.1015,S:.148361},150:{L:-1.95952,M:18.42,S:.149783},156:{L:-1.954978,M:18.7364,S:.150705},162:{L:-1.9611,M:19.0481,S:.151176},168:{L:-1.977074,M:19.3526,S:.151256},174:{L:-2.002014,M:19.6475,S:.15101},180:{L:-2.034893,M:19.9306,S:.150512},186:{L:-2.07446,M:20.1998,S:.149843},192:{L:-2.119157,M:20.4533,S:.14909},198:{L:-2.167045,M:20.6891,S:.148349},204:{L:-2.215738,M:20.9058,S:.147723},210:{L:-2.262382,M:21.1016,S:.147323},216:{L:-2.303688,M:21.2753,S:.147269},222:{L:-2.336038,M:21.4255,S:.147689},228:{L:-2.355678,M:21.5508,S:.148724},234:{L:-2.35898,M:21.6501,S:.150521},240:{L:-2.342797,M:21.7219,S:.153241}}};function k(e){let t=e<0?-1:1,n=Math.abs(e)/Math.sqrt(2),r=1/(1+.3275911*n);return .5*(1+t*(1-((((1.061405429*r+-1.453152027)*r+1.421413741)*r+-.284496736)*r+.254829592)*r*Math.exp(-n*n)))}function oe(e,t,n,r){let i;i=Math.abs(t)<.001?Math.log(e/n)/r:((e/n)**+t-1)/(t*r);let a=k(i);return{z:i,percentile:Math.round(a*1e4)/100}}function se(e,t,n){let r=1.645,i=Math.abs(n.L)<.001?n.M*Math.exp(n.S*r):n.M*(1+n.L*n.S*r)**(1/n.L),a=t/i*100;return e>=95?a>=140?{label:`Class 3 Severe Obesity`,color:`#7f1d1d`,bg:`#fecaca`,pctOf95:a,bmi95:i}:a>=120?{label:`Class 2 Severe Obesity`,color:`#dc2626`,bg:`#fee2e2`,pctOf95:a,bmi95:i}:{label:`Obese (Class 1)`,color:`#ef4444`,bg:`#fee2e2`,pctOf95:a,bmi95:i}:e>=85?{label:`Overweight`,color:`#f97316`,bg:`#ffedd5`,pctOf95:a,bmi95:i}:e>=5?{label:`Healthy Weight`,color:`#10b981`,bg:`#d1fae5`,pctOf95:a,bmi95:i}:{label:`Underweight`,color:`#f59e0b`,bg:`#fef3c7`,pctOf95:a,bmi95:i}}function ce(e,t,n,r){let i=e/(t/100)**2,a=Math.max(24,Math.min(240,n)),s=o(O[r],a),{z:c,percentile:l}=oe(i,s.L,s.M,s.S),u=se(l,i,s);return{bmi:i,z:c,percentile:l,L:s.L,M:s.M,S:s.S,classification:u}}var le=[1.07244896,1.051272912,1.041951175,1.012592236,.970541909,.921129988,.868221392,.81454413,.761957977,.711660228,.664323379,.620285102,.57955631,.54198094,.511429832,.482799937,.455521041,.429150288,.403351725,.377878239,.352555862,.327270297,.301955463,.276583851,.251158446,.225705996,.20027145,.174913356,.149700081,.12470671,.100012514,.075698881,.051847635,.02853967,.005853853,-.016133871,-.037351181,-.057729947,-.077206672,-.09572283,-.113225128,-.129665689,-.145002179,-.159197885,-.172221748,-.184048358,-.194660215,-.204030559,-.212174408,-.219069129,-.224722166,-.229140412,-.232335686,-.234324563,-.235128195,-.234772114,-.233286033,-.230703633,-.227062344,-.222403111,-.216770161,-.210210748,-.202774891,-.194515104,-.185486099,-.175744476,-.165348396,-.15435722,-.142831123,-.130830669,-.118416354,-.105648092,-.092584657,-.079283065,-.065797888,-.0521805,-.03847825,-.024733545,-.010982868,.002744306,.016426655,.030052231,.043619747,.05713988,.070636605,.08414848,.097729873,.111452039,.125404005,.13969316,.154445482,.169805275,.185934346,.203010488,.2212252,.240780542,.261885086,.284748919,.309577733,.336566048,.365889711,.397699038,.432104409,.46917993,.508943272,.551354277,.596307363,.643626542,.693062173,.744289752,.79691098,.85045728,.904395871,.958138449,1.011054559,1.062474568,1.111727029,1.158135105,1.201050821,1.239852328,1.274006058,1.303044695,1.326605954,1.344443447,1.356437773,1.362602695,1.363085725,1.358162799,1.348227142,1.333772923,1.315374704,1.293664024,1.269304678,1.242968236,1.21531127,1.186955477,1.158471522,1.130367088,1.103079209,1.076970655,1.052329922,1.029374161,1.008254396,.989062282,.971837799,.95657215,.94324228,.931767062,.922058291,.914012643,.907516917,.902452436,.898698641,.896143482,.894659668,.89413892,.894475371,.895569834,.897330209,.899671635,.902516442,.905793969,.909440266,.913397733,.91761471,.922045055,.926647697,.931386217,.93622842,.941145943,.94611388,.95111043,.956116576,.961115792,.966093766,.971038162,.975938391,.980785418,.985571579,.99029042,.994936555,.999505539,1.003993753,1.0083983,1.012716921,1.016947912,1.021090055,1.025142554,1.029104983,1.032977233,1.036759475,1.040452117,1.044055774,1.047571238,1.050999451,1.054341482,1.057598512,1.060771808,1.063862715,1.066872639,1.069803036,1.072655401,1.075431258,1.078132156,1.080759655,1.083315329,1.085800751,1.088217496,1.090567133,1.092851222,1.095071313,1.097228939,1.099325619,1.101362852,1.103342119,1.105264876,1.107132561,1.108046193],ue=[84.97555512,85.3973169,86.29026318,87.15714182,87.9960184,88.8055115,89.58476689,90.33341722,91.0515436,91.7396352,92.39854429,93.02945392,93.63382278,94.21335709,94.79643239,95.37391918,95.94692677,96.51644912,97.08337211,97.6484807,98.21246579,98.77593069,99.33939735,99.9033122,100.4680516,101.033927,101.6011898,102.1700358,102.7406094,103.3130077,103.8872839,104.4634511,105.0414853,105.6213287,106.2028921,106.7860583,107.3706841,107.9566031,108.5436278,109.1315521,109.7201531,110.3091934,110.8984228,111.4875806,112.0763967,112.6645943,113.2518902,113.8380006,114.4226317,115.0054978,115.5863089,116.1647782,116.7406221,117.3135622,117.8833259,118.4496481,119.0122722,119.5709513,120.1254495,120.6755427,121.22102,121.7616844,122.2973542,122.827864,123.3530652,123.8728276,124.38704,124.8956114,125.398472,125.895574,126.3868929,126.8724284,127.3522056,127.8262759,128.2947187,128.757642,129.2151839,129.6675143,130.1148354,130.5573839,130.995432,131.4292887,131.8593015,132.2858574,132.7093845,133.1303527,133.5492749,133.9667073,134.3832499,134.7995463,135.2162826,135.634186,136.0540223,136.4765925,136.9027281,137.3332846,137.7691339,138.2111552,138.6602228,139.1171933,139.5828898,140.0580848,140.5434787,141.0396832,141.5471945,142.0663731,142.59742,143.1403553,143.6949981,144.2609497,144.8375809,145.4240246,146.0191748,146.621692,147.2300177,147.8423918,148.4568879,149.0714413,149.6838943,150.2920328,150.8936469,151.4865636,152.0686985,152.6380955,153.1929631,153.7317031,154.2529332,154.755501,155.2384904,155.7012216,156.1432438,156.564323,156.9644258,157.3436995,157.7024507,158.0411233,158.3602756,158.6605588,158.9426964,159.2074654,159.455679,159.688172,159.9057871,160.1093647,160.299733,160.4776996,160.6440526,160.7995428,160.9448916,161.0807857,161.2078755,161.3267744,161.4380593,161.5422726,161.639917,161.7314645,161.8173534,161.8979913,161.9737558,162.0449969,162.1120386,162.17518,162.2346979,162.2908474,162.343864,162.3939652,162.4413513,162.4862071,162.5287029,162.5689958,162.6072309,162.6435418,162.6780519,162.7108751,162.7421168,162.7718741,162.8002371,162.8272889,162.8531067,162.8777619,162.9013208,162.9238449,162.9453912,162.9660131,162.9857599,163.0046776,163.0228094,163.0401953,163.0568727,163.0728768,163.0882404,163.1029943,163.1171673,163.1307866,163.1438776,163.1564644,163.1685697,163.1802146,163.1914194,163.202203,163.2125835,163.2225779,163.2322024,163.2414722,163.2504019,163.2590052,163.2672954,163.2752848,163.2829854,163.2904086,163.297565,163.304465,163.3111185,163.3175349,163.3237231,163.3296918,163.3354491,163.338251],de=[.040791394,.040859727,.041142161,.041349399,.041500428,.041610508,.041691761,.04175368,.041803562,.041846882,.041887626,.041928568,.041971514,.042017509,.042104522,.042199507,.042300333,.042405225,.042512706,.042621565,.042730809,.042839638,.042947412,.043053626,.043157889,.043259907,.043359463,.043456406,.043550638,.043642107,.043730791,.043816701,.043899867,.043980337,.044058171,.04413344,.044206218,.044276588,.044344632,.044410436,.044474084,.044535662,.044595254,.044652942,.044708809,.044762936,.044815402,.044866288,.044915672,.044963636,.045010259,.045055624,.045099817,.045142924,.045185036,.045226249,.045266662,.045306383,.045345524,.045384203,.045422551,.045460702,.045498803,.045537012,.045575495,.045614432,.045654016,.04569445,.045735953,.045778759,.045823114,.04586928,.045917535,.045968169,.04602149,.046077818,.046137487,.046200842,.04626824,.046340046,.046416629,.046498361,.046585611,.046678741,.046778099,.04688401,.046996769,.047116633,.047243801,.047378413,.047520521,.047670085,.047826946,.04799081,.048161228,.04833757,.048519011,.048704503,.048892759,.049082239,.049271137,.049457371,.049638596,.049812203,.049975355,.050125012,.050257992,.050371024,.050460835,.050524236,.050558224,.050560083,.050527494,.050458634,.050352269,.050207825,.050025434,.049805967,.049551023,.049262895,.048944504,.048599314,.048231224,.047844442,.047443362,.04703243,.046616026,.046198356,.04578335,.045374597,.044975281,.044588148,.044215488,.043859135,.04352048,.043200497,.042899776,.042618565,.042356812,.042114211,.041890247,.04168424,.041495379,.041322765,.041165437,.041022401,.040892651,.040775193,.040669052,.040573288,.040487005,.040409354,.040339537,.040276811,.040220488,.040169932,.040124562,.040083845,.040047295,.040014473,.03998498,.039958458,.039934584,.039913066,.039893644,.039876087,.039860185,.039845754,.039832629,.039820663,.039809725,.0397997,.039790485,.039781991,.039774136,.03976685,.03976007,.039753741,.039747815,.039742249,.039737004,.039732048,.039727352,.03972289,.03971864,.039714581,.039710697,.039706971,.039703391,.039699945,.039696623,.039693415,.039690313,.039687311,.039684402,.039681581,.039678842,.039676182,.039673596,.039671082,.039668635,.039666254,.039663936,.039661679,.039659481,.039657339,.039655252,.039653218,.039651237,.039649306,.039647424,.039645591,.039643804,.039642063,.039640367,.039638715,.039637105,.039636316],A=[.941523967,1.00720807,.837251351,.681492975,.538779654,.407697153,.286762453,.174489485,.069444521,-.029720564,-.124251789,-.215288396,-.30385434,-.390918369,-.254801167,-.125654535,-.00316735,.11291221,.222754969,.326530126,.42436156,.516353108,.602595306,.683170764,.758158406,.827636736,.891686306,.95039153,1.003830006,1.05213569,1.0953669,1.133652119,1.167104213,1.195845353,1.220004233,1.239715856,1.255121285,1.266367398,1.273606657,1.276996893,1.276701119,1.272887366,1.265728536,1.255402281,1.242090871,1.225981067,1.207263978,1.186140222,1.162796198,1.137442868,1.110286487,1.081536236,1.05140374,1.020102497,.987847213,.954853043,.921334742,.887505723,.85357703,.819756239,.786246296,.753244292,.720940222,.689515708,.659142731,.629997853,.602203984,.575908038,.55123134,.528279901,.507143576,.487895344,.470590753,.455267507,.441945241,.430625458,.421291648,.413909588,.408427813,.404778262,.402877077,.402625561,.40391127,.406609232,.410583274,.415687443,.421767514,.428662551,.436206531,.44423,.45256176,.461030578,.469466904,.477704608,.48558272,.492947182,.499652617,.505564115,.510559047,.514528903,.517381177,.519041285,.519454524,.518588072,.516433004,.513006312,.508352901,.502547502,.495696454,.487939275,.479449924,.470437652,.461147305,.451858946,.442886661,.434576385,.427302633,.421464027,.417477538,.415771438,.416777012,.420919142,.428606007,.440218167,.456097443,.476536014,.501766234,.531951655,.567179725,.607456565,.652704121,.702759868,.757379106,.816239713,.878947416,.945053486,1.014046108,1.085383319,1.158487278,1.232768816,1.307628899,1.382473225,1.456720479,1.529810247,1.601219573,1.670433444,1.736995571,1.800483802,1.860518777,1.916765525,1.968934444,2.016781776,2.060109658,2.098765817,2.132642948,2.16167779,2.185849904,2.205180153,2.219728869,2.2295937,2.234907144,2.235833767,2.232567138,2.2253265,2.214353232,2.199905902,2.182262864,2.161704969,2.138524662,2.113023423,2.085490286,2.0562195,2.025496648,1.993598182,1.960789092,1.927320937,1.89343024,1.859337259,1.825245107,1.791339209,1.757787065,1.724738292,1.692324905,1.660661815,1.629847495,1.599964788,1.571081817,1.543252982,1.516519998,1.490912963,1.466451429,1.44314546,1.420996665,1.399999187,1.380140651,1.361403047,1.343763564,1.327195355,1.311668242,1.297149359,1.283603728,1.270994782,1.25928483,1.248435461,1.23840791,1.229163362,1.220663228,1.212869374,1.20574431,1.199251356,1.19335477,1.188019859,1.183213059,1.178901998,1.175055543,1.171643828,1.16863827,1.167279219],j=[86.45220101,86.86160934,87.65247282,88.42326434,89.17549228,89.91040853,90.62907762,91.33242379,92.02127167,92.69637946,93.35846546,94.00822923,94.64636981,95.27359106,95.91474929,96.54734328,97.17191309,97.78897727,98.3990283,99.00254338,99.599977,100.191764,100.7783198,101.3600411,101.9373058,102.5104735,103.0798852,103.645864,104.208713,104.7687256,105.3261638,105.8812823,106.4343146,106.9854769,107.534968,108.0829695,108.6296457,109.1751441,109.7195954,110.2631136,110.8057967,111.3477265,111.8889694,112.4295761,112.9695827,113.5090108,114.0478678,114.5861486,115.1238315,115.6608862,116.1972691,116.732925,117.2677879,117.8017819,118.3348215,118.8668123,119.397652,119.9272309,120.455433,120.9821362,121.5072136,122.0305342,122.5519634,123.0713645,123.588599,124.1035312,124.6160161,125.1259182,125.6331012,126.1374319,126.6387804,127.1370217,127.6320362,128.1237104,128.6119383,129.096622,129.5776723,130.0550101,130.5285669,130.9982857,131.4641218,131.9260439,132.3840348,132.838092,133.2882291,133.7344759,134.1768801,134.6155076,135.0504433,135.4817925,135.9096813,136.3342577,136.7556923,137.1741794,137.5899378,138.0032114,138.4142703,138.8234114,139.2309592,139.6372663,140.042714,140.4477127,140.8527022,141.2581515,141.6645592,142.072452,142.4823852,142.8949403,143.3107241,143.7303663,144.1545167,144.5838414,145.0190192,145.4607359,145.9096784,146.3665278,146.8319513,147.3065929,147.7910635,148.2859294,148.7917006,149.3088178,149.8376391,150.3784267,150.9313331,151.4963887,152.0734897,152.6623878,153.2626819,153.8738124,154.495058,155.1255365,155.7642086,156.4098858,157.0612415,157.7168289,158.3750929,159.034399,159.6930501,160.3493168,161.0014586,161.6477515,162.2865119,162.9161202,163.535045,164.1418486,164.7352199,165.3139755,165.8770715,166.4236087,166.9528354,167.4641466,167.9570814,168.4313175,168.8866644,169.3230548,169.7405351,170.139255,170.5194567,170.881464,171.2256717,171.5525345,171.8625576,172.1562865,172.4342983,172.6971935,172.9455898,173.180112,173.4013896,173.6100518,173.8067179,173.9919998,174.1664951,174.3307855,174.4854344,174.6309856,174.7679617,174.8968634,175.0181691,175.1323345,175.2397926,175.340954,175.4362071,175.5259191,175.6104358,175.690083,175.7651671,175.8359757,175.9027788,175.9658293,176.0253641,176.081605,176.1347593,176.1850208,176.2325707,176.2775781,176.3202008,176.3605864,176.3988725,176.4351874,176.469651,176.5023751,176.533464,176.5630153,176.5911197,176.6178621,176.6433219,176.6675729,176.6906844,176.712721,176.733743,176.753807,176.7729657,176.7912687,176.8087622,176.8254895,176.8414914,176.8492322],fe=[.040321528,.040395626,.040577525,.040723122,.040833194,.040909059,.040952433,.04096533,.040949976,.040908737,.040844062,.040758431,.040654312,.04053412,.040572876,.04061691,.040666414,.040721467,.040782045,.040848042,.040919281,.040995524,.041076485,.041161838,.041251224,.041344257,.041440534,.041539635,.041641136,.041744602,.041849607,.041955723,.042062532,.042169628,.042276619,.042383129,.042488804,.042593311,.042696342,.042797615,.042896877,.042993904,.043088503,.043180513,.043269806,.043356287,.043439893,.043520597,.043598407,.043673359,.043745523,.043815003,.043881929,.043946461,.044008785,.044069112,.044127675,.044184725,.044240532,.044295379,.044349559,.044403374,.04445713,.044511135,.044565693,.044621104,.044677662,.044735646,.044795322,.044856941,.04492073,.044986899,.045055632,.045127088,.045201399,.045278671,.045358979,.045442372,.045528869,.045618459,.045711105,.045806742,.045905281,.046006604,.046110573,.046217028,.04632579,.046436662,.04654943,.046663871,.046779748,.046896817,.047014827,.047133525,.047252654,.047371961,.047491194,.047610108,.047728463,.04784603,.047962592,.048077942,.048191889,.048304259,.048414893,.048523648,.048630402,.04873505,.048837504,.048937694,.049035564,.049131073,.049224189,.049314887,.049403145,.049488934,.049572216,.049652935,.049731004,.0498063,.04987865,.049947823,.050013518,.050075353,.050132858,.050185471,.050232532,.050273285,.050306885,.050332406,.05034886,.050355216,.050350423,.050333444,.050303283,.050259018,.050199837,.050125062,.05003418,.049926861,.049802977,.04966261,.049506051,.049333801,.049146553,.04894519,.048730749,.048504404,.048267442,.04802123,.047767192,.047506783,.047241456,.04697265,.046701759,.046430122,.046159004,.045889585,.045622955,.045360101,.045101913,.044849174,.044602566,.044362674,.044129985,.043904897,.043687723,.043478698,.043277987,.043085685,.042901835,.042726424,.042559396,.042400652,.042250063,.042107465,.041972676,.041845488,.041725679,.041613015,.041507249,.041408129,.041315398,.041228796,.04114806,.041072931,.04100315,.040938463,.040878617,.040823368,.040772475,.040725706,.040682834,.04064364,.040607913,.040575448,.040546051,.040519532,.040495713,.040474421,.040455493,.040438773,.040424111,.040411366,.040400405,.040391101,.040383334,.04037699,.040371962,.040368149,.040365456,.040363795,.04036308,.040363233,.040364179,.04036585,.04036818,.040369574],pe=[[-7.4855,-1.2252,1.2643,-6.8797,20.4744,.7114,-.0066,-.0667,.3564,-.0012,.5278,-.6927,.1388],[8.4462,-.9598,.9046,-5.1098,15.1548,.5919,-.0029,-.065,.2495,-.003,.4421,-.5724,.0997],[26.6223,-1.1479,1.2134,-8.4665,28.0408,.475,1e-4,-.0643,.2062,-.023,.5561,-.7467,.185],[31.8947,-.867,1.1693,-8.2932,26.0849,.4251,-2e-4,-.0535,.1718,-.008,.3954,-.5402,.1473],[30.9472,-1.1288,1.5926,-11.7371,34.5934,.4578,-.0019,-.0341,.1144,-.0167,.6897,-1.0025,.3867],[23.152,-1.1368,1.751,-13.8556,41.2104,.527,-.0048,-.0149,.0623,.0062,.4347,-.6509,.2798],[19.3036,-.923,1.6566,-14.2294,42.9522,.5494,-.0062,-.0051,.0555,.0242,.1295,-.1986,.0876],[20.0191,-1.0378,1.6928,-13.6476,40.8615,.5596,-.0071,.0146,-.03,.0135,.1632,-.2423,.1013],[21.6515,-.9745,1.5964,-13.0096,38.8309,.5462,-.0063,.0087,-.0183,.0093,.2644,-.3848,.1477],[22.6952,-.8665,1.4799,-11.8203,34.2277,.537,-.0066,.0176,-.0648,.0046,.3226,-.4689,.1811],[23.1615,-.8132,1.4422,-11.8893,34.8542,.5329,-.0063,.013,-.0367,.008,.34,-.5072,.2171],[27.9,-.8288,1.4257,-11.5803,33.7393,.4995,-.0049,.0013,.0117,-.0014,.4954,-.7333,.3051],[34.8678,-.801,1.429,-11.2835,32.3656,.4469,-.0037,-.0037,.0274,-4e-4,.3936,-.5873,.251],[37.7557,-.9638,1.5603,-11.545,31.5671,.4392,-.0035,.0024,-.0164,-.0087,.395,-.575,.2238],[39.9509,-1.0185,1.6189,-11.6485,31.009,.4284,-.0032,.0051,-.0452,-.0101,.3516,-.5073,.1906],[40.8576,-.9313,1.5386,-11.5031,31.8413,.418,-.0029,.0019,-.0291,-.0081,.3507,-.5094,.1968],[42.1455,-.9104,1.5356,-11.4411,31.5567,.4098,-.0029,.0038,-.0368,-.006,.2848,-.4155,.1642],[44.0009,-1.0103,1.6565,-11.8711,31.8672,.4038,-.0026,7e-4,-.0172,-.0017,.1877,-.2802,.1211],[42.9483,-.9479,1.6532,-12.4439,34.3937,.4097,-.0029,.0023,-.0231,-3e-4,.1892,-.2761,.1077],[43.4489,-.9355,1.5751,-11.4463,30.9525,.4076,-.0027,0,-.0199,.0013,.1619,-.2376,.0949],[42.0432,-.9668,1.5892,-11.2769,29.6658,.4235,-.003,9e-4,-.0194,.0051,.1181,-.1781,.0784],[43.3921,-.9251,1.5125,-10.669,27.8566,.4122,-.0025,-8e-4,-.0269,-3e-4,.178,-.2571,.0962],[43.1823,-.9153,1.5502,-11.2058,29.7148,.4154,-.0028,.0025,-.0386,.0053,.0679,-.0977,.0352],[43.5111,-.8427,1.4724,-10.8634,29.5168,.4107,-.0027,.0019,-.0416,-.0023,.1644,-.2282,.0711],[44.8115,-.9195,1.5496,-10.7815,27.8384,.4087,-.003,.012,-.0908,-.0063,.1451,-.1957,.053],[45.1153,-.8419,1.4685,-10.4821,27.7389,.404,-.003,.0148,-.1094,-.0047,.1524,-.2131,.0715],[45.0184,-.9109,1.4637,-9.8769,25.3956,.4124,-.0031,.0163,-.1196,-.0095,.2128,-.3015,.1084],[46.8396,-.9336,1.4913,-10.0409,25.5791,.4004,-.0025,.0087,-.0854,-.0083,.207,-.2945,.1065],[46.3627,-1.0691,1.6403,-10.8997,27.3749,.4156,-.003,.0128,-.0892,-.006,.1891,-.2783,.1168],[46.056,-1.0253,1.6174,-10.8914,27.6133,.4169,-.0032,.0134,-.0831,-.0015,.1168,-.1751,.0794],[45.8707,-1.0687,1.6929,-11.5282,29.3823,.4234,-.0035,.0189,-.1052,-.002,.0549,-.0766,.0279],[46.225,-1.0493,1.6305,-11.0002,28.295,.4212,-.0032,.015,-.0892,.001,.0192,-.0279,.014],[49.7043,-1.1168,1.6687,-10.6909,26.5418,.4005,-.0027,.0175,-.1166,-.0029,-.0064,.0124,-.0056],[52.501,-1.2283,1.7174,-10.288,24.6009,.39,-.0025,.0229,-.1413,-.0055,-.0773,.1151,-.0428],[52.638,-1.2668,1.7982,-10.7251,24.8323,.393,-.0027,.0233,-.1352,-.0037,-.1218,.1797,-.0678],[52.9451,-1.2987,1.8214,-10.8739,25.4383,.3952,-.0028,.0249,-.1365,-.0026,-.1753,.2588,-.1002],[51.6977,-1.2275,1.7723,-10.6355,24.5465,.4024,-.0032,.0273,-.1377,.0023,-.2334,.3428,-.1327],[51.5803,-1.1856,1.7323,-10.549,24.7169,.4027,-.0033,.029,-.1504,.004,-.2752,.4081,-.1658],[52.5542,-1.1951,1.7357,-10.3953,23.5706,.3978,-.0032,.0312,-.1661,5e-4,-.2249,.34,-.1482],[54.7146,-1.2604,1.8028,-10.773,24.4075,.3869,-.0029,.0332,-.1862,-.002,-.2181,.3306,-.1449],[56.735,-1.199,1.8011,-11.3328,26.8609,.3684,-.0025,.0319,-.1874,2e-4,-.2443,.3686,-.1611],[57.7385,-1.2515,1.8588,-11.3519,25.8098,.3657,-.0024,.0287,-.1704,-9e-4,-.2306,.3502,-.1567],[57.7098,-1.257,1.9037,-11.8077,27.0173,.3677,-.0024,.0271,-.1572,-.0012,-.1965,.298,-.1324],[58.0736,-1.2363,1.9353,-12.317,28.6066,.3643,-.0024,.0253,-.1507,.002,-.178,.2641,-.1092],[62.0223,-1.2128,1.9237,-12.157,27.903,.3343,-.0016,.0242,-.1555,-4e-4,-.21,.315,-.136],[62.1221,-1.1404,1.8555,-11.839,27.3698,.3308,-.0017,.026,-.1685,-.0024,-.1452,.2208,-.0993],[62.7962,-1.113,1.8421,-11.7266,26.7715,.3253,-.0016,.0282,-.1884,-.0019,-.1808,.2766,-.1276],[61.7073,-1.2183,1.9323,-12.0462,26.8742,.3435,-.0022,.0321,-.2009,-.0018,-.1943,.2958,-.1342],[61.7636,-1.1885,1.9597,-12.4946,27.9124,.342,-.0022,.0308,-.1956,.003,-.234,.3493,-.149],[63.7493,-1.2055,1.96,-12.5069,28.0089,.3283,-.0012,.0195,-.1595,-.002,-.1708,.2634,-.1258],[62.2586,-1.077,1.8646,-12.2702,27.8184,.3328,-.0012,.0137,-.1292,-.0024,-.0705,.1151,-.0646],[64.2911,-1.0805,1.8431,-11.8647,26.3816,.3191,-7e-4,.0088,-.1057,-.007,-.0325,.0621,-.0471],[68.9778,-1.2187,1.888,-11.2553,23.9127,.294,3e-4,.0053,-.0991,-.0123,-.0668,.1121,-.0648],[70.4806,-1.165,1.8218,-10.7395,22.4622,.2801,9e-4,1e-4,-.0853,-.0136,-.0702,.1225,-.0781],[70.6109,-1.1182,1.8262,-11.2854,24.8046,.2768,.001,-7e-4,-.084,-.01,-.1092,.1806,-.1041],[69.8975,-1.1611,1.8731,-11.7046,26.3452,.287,7e-4,.0018,-.0954,-.0067,-.1524,.2386,-.1185],[69.191,-1.1401,1.9015,-12.217,27.9129,.2928,3e-4,.0055,-.111,-.0035,-.2103,.3262,-.1586],[69.9619,-1.1195,1.8816,-11.9235,26.817,.2873,5e-4,.0046,-.1118,-.0053,-.1918,.3015,-.1525],[68.3161,-1.0128,1.7759,-11.6001,26.6764,.2951,3e-4,.0028,-.1008,-.0022,-.2321,.3639,-.1831],[68.0555,-.9162,1.6469,-10.7107,24.2868,.2927,6e-4,-.0014,-.0813,-4e-4,-.236,.3707,-.1882],[65.6124,-.7989,1.5036,-9.8072,21.9786,.3055,4e-4,-.0054,-.0567,-.0017,-.1403,.2328,-.1369],[65.1636,-.7707,1.457,-9.5828,21.8374,.3086,5e-4,-.0086,-.0391,-.0024,-.0941,.1647,-.109],[66.6766,-.913,1.5894,-9.8498,21.1477,.3073,8e-4,-.0116,-.029,-.0052,-.0645,.1189,-.0865],[65.4537,-.895,1.5329,-9.3616,19.7235,.3178,7e-4,-.0136,-.0176,-.0044,-.0173,.0444,-.0479],[64.8596,-.9404,1.6229,-9.8355,19.8054,.3274,2e-4,-.0077,-.0396,-.006,.0077,.0094,-.0359],[64.7808,-.935,1.5826,-9.392,18.2771,.3302,2e-4,-.0082,-.0324,-.009,.0629,-.0712,-.0032],[65.5762,-.9693,1.558,-8.833,16.6679,.3289,3e-4,-.009,-.0304,-.0092,.0526,-.0599,-.0011],[64.0451,-1.1203,1.7205,-9.4755,16.9051,.3537,-7e-4,.0019,-.0701,-.0041,-.1202,.1997,-.1156],[66.825,-1.1964,1.8333,-10.0226,17.9273,.3397,-6e-4,.0056,-.0822,-.0081,-.1245,.2047,-.1138],[65.6846,-1.2525,1.9018,-10.459,18.6882,.3537,-9e-4,.0036,-.066,-.0057,-.113,.1831,-.0985],[65.3052,-1.2617,1.9135,-10.5223,18.771,.3604,-.0013,.0085,-.0848,-.0046,-.1438,.2265,-.112],[64.899,-1.2245,1.8584,-10.1192,17.7416,.3641,-.0016,.0138,-.1073,-.0048,-.1372,.2161,-.1063],[65.3578,-1.2248,1.8289,-9.7674,16.8046,.3627,-.0014,.0124,-.1066,-.0057,-.1576,.2502,-.1263],[64.5514,-1.1783,1.7442,-9.4075,16.9106,.3687,-.0013,.0091,-.0924,-.0076,-.0787,.1365,-.0847],[66.0885,-1.1878,1.7936,-9.5264,16.3425,.3605,-.0016,.0179,-.1274,-.0072,-.185,.2994,-.1608],[67.302,-1.1912,1.725,-8.4639,12.8607,.3551,-.0016,.0212,-.1358,-.0076,-.2055,.3238,-.1601],[69.6151,-1.1726,1.7606,-8.9219,14.4437,.3387,-.0015,.026,-.1521,-.0094,-.1704,.2659,-.1257],[70.5901,-1.2426,1.8162,-8.921,13.7988,.3388,-.0016,.0283,-.1619,-.016,-.066,.1157,-.069],[74.0399,-1.3696,1.9736,-9.9705,16.4081,.322,-.001,.0261,-.1607,-.0211,.054,-.068,.017],[78.1837,-1.4118,1.9659,-9.2285,13.6521,.2962,-4e-4,.0279,-.176,-.0236,.0265,-.035,.0171],[77.8733,-1.5496,2.1217,-10.0164,15.085,.3117,-.0013,.041,-.234,-.0167,-.141,.2059,-.0717],[78.6258,-1.5819,2.1292,-10.2662,16.5876,.311,-.0011,.0374,-.2191,-.0181,-.0881,.1294,-.044],[78.1114,-1.6551,2.2258,-11.1197,18.7127,.3231,-.0016,.0421,-.2369,-.0174,-.0626,.0903,-.0264],[79.7562,-1.6836,2.2862,-11.9207,21.9312,.3146,-.0013,.038,-.2147,-.0164,-.0397,.0537,-.0083],[81.1825,-1.7413,2.3012,-11.7683,21.4169,.3106,-.0011,.0381,-.2099,-.0197,.0394,-.07,.0551],[82.4317,-1.7326,2.3369,-11.7377,20.8323,.3043,-.0014,.0468,-.2545,-.0145,-.1069,.1451,-.0329],[83.4279,-1.7479,2.3341,-12.1336,23.8773,.3009,-9e-4,.0394,-.2205,-.0159,-.0384,.039,.0189],[87.5318,-1.8801,2.4042,-11.8201,21.5,.2804,0,.0344,-.215,-.0208,-.0131,.0053,.0276],[91.5471,-1.9424,2.5247,-12.4507,21.7964,.2576,5e-4,.0374,-.2444,-.0294,-.0119,.0227,-.01],[92.4497,-1.8508,2.5523,-13.6421,26.226,.2495,0,.0494,-.305,-.0184,-.1813,.2673,-.1041],[92.8328,-1.7523,2.5128,-13.17,23.6191,.2436,5e-4,.0322,-.2188,-.0162,-.1657,.2435,-.0938],[100.346,-1.9852,2.7015,-12.334,16.8429,.2061,.0016,.0236,-.1616,-.0093,-.4796,.6954,-.2616],[106.8231,-1.8617,2.4704,-10.3756,11.994,.1537,.0038,.0071,-.1169,-.0192,-.4992,.7439,-.3113],[111.3953,-1.9833,2.5967,-11.4122,16.0199,.1324,.0046,.0068,-.1417,-.0242,-.6418,.9712,-.431],[117.6411,-2.0964,2.6981,-11.2572,13.4182,.0991,.0053,.0132,-.1836,-.0338,-.4799,.719,-.3037],[121.3735,-2.3828,2.9534,-12.2263,14.8292,.0974,.0055,.0085,-.1487,-.0205,-.6271,.9041,-.3313],[115.9126,-2.5317,3.2788,-15.2093,22.0287,.1601,.0028,.0231,-.181,6e-4,-.7258,1.0194,-.3341],[125.5877,-1.6743,2.6055,-13.4481,23.2621,.0405,.006,-9e-4,-.0707,.0296,-1.1873,1.6794,-.5743],[135.675,-1.8473,2.0605,-8.0487,16.9201,-.0112,.0136,-.0896,.1678,-.0337,.3359,-.5938,.4196]],me=[[36.3363,-.4513,-.2328,28.8499,-129.833,-.0182,7e-4,.0464,-.2691,-.0622,-.2979,.6276,-.5522],[30.6534,-1.0645,-.5369,30.836,-125.69,.1058,.0021,.039,-.2859,-.0568,-.8988,1.5116,-.9035],[46.6521,-.8427,-.8134,29.0051,-109.524,-.0091,.0049,.0484,-.379,-.0684,-.6066,1.0179,-.5945],[34.7995,-1.0943,-.5132,24.8976,-93.9462,.1143,6e-4,.0856,-.4757,-.03,-.9349,1.424,-.6362],[15.9095,-.3518,-.6484,19.5391,-72.0796,.2253,-.0045,.1041,-.5073,.007,-1.3455,2.0777,-.9953],[12.8878,-.0974,-1.0427,20.0319,-66.1203,.2379,-.002,.0402,-.2008,-.0112,-.4679,.7618,-.4226],[3.2759,-.1741,-.7763,16.2511,-53.8662,.3223,-.0044,.0485,-.2089,-.0061,-.2448,.4092,-.2385],[12.846,-.0649,-.8792,16.2183,-50.693,.2474,-.0022,.0311,-.123,-.0255,.239,-.3265,.1012],[12.8668,.1716,-1.0619,16.2814,-49.2028,.2361,-.002,.0293,-.1263,-.0322,.5303,-.7561,.2762],[9.112,.1408,-1.0811,16.1015,-48.0962,.2737,-.0032,.0416,-.1676,-.0278,.5837,-.8523,.3437],[11.7225,-.2667,-.674,14.1978,-45.5872,.284,-.0034,.0505,-.203,-.0368,.5673,-.8255,.3314],[19.5753,-.4609,-.4453,12.7133,-41.9359,.2384,-.002,.0503,-.2232,-.0503,.7475,-1.0987,.4581],[21.1297,-.7489,-.2784,12.1653,-40.6521,.2491,-.0015,.0462,-.2201,-.0415,.5736,-.8537,.3742],[17.5087,-.5589,-.5804,13.6135,-42.3595,.2699,-.0017,.0438,-.2286,-.0325,.5451,-.8138,.3581],[19.125,-.6931,-.358,11.3984,-35.5973,.2679,-9e-4,.0341,-.1992,-.0272,.3386,-.5034,.2204],[12.3312,-.7307,-.2314,9.1993,-27.9046,.3246,-.002,.0272,-.1474,-.0218,.4218,-.6267,.2695],[8.7933,-.5755,-.2574,8.5358,-26.1118,.3473,-.0031,.0313,-.1447,-.0249,.4514,-.6549,.2572],[6.8234,-.7262,-.0687,7.7821,-26.4927,.3781,-.0044,.0462,-.203,-.0214,.2612,-.3714,.1375],[6.5708,-.6226,-.1738,8.0763,-26.5849,.3759,-.0041,.0378,-.1688,-.0223,.3339,-.475,.1725],[12.4952,-.781,.0532,6.8239,-24.2698,.3431,-.0032,.0368,-.1732,-.0262,.1513,-.1909,.0331],[16.8254,-.4175,-.2206,7.4894,-23.9702,.2885,-.0021,.0295,-.1608,-.0154,-.0241,.0763,-.095],[17.8811,-.4367,-.1266,7.0389,-24.15,.2868,-.0028,.0392,-.1928,-.0081,-.278,.4577,-.2641],[16.5734,-.2666,-.2542,7.0108,-22.3832,.2899,-.0032,.0387,-.1806,-.0041,-.2653,.436,-.2519],[19.9011,-.2317,-.3427,7.6601,-23.4789,.2636,-.002,.0303,-.1519,-.0146,-.0788,.162,-.1394],[21.7218,-.2625,-.2345,6.6903,-20.9185,.2553,-.0023,.0347,-.1547,-.023,.0302,.0052,-.0801],[21.9955,-.4947,-.0505,6.3827,-21.7936,.2719,-.0028,.0392,-.1593,-.0334,.1394,-.1536,-.0152],[25.2014,-.5716,.0877,5.7268,-21.1119,.2566,-.0032,.0512,-.2028,-.0358,.0855,-.0747,-.0456],[24.9355,-.6578,.231,4.6551,-18.8514,.2671,-.0039,.0592,-.2224,-.0268,-.0489,.114,-.1096],[23.5259,-.5069,.1119,4.7744,-18.0734,.2698,-.004,.0557,-.2087,-.0263,.0265,.0098,-.0803],[22.6538,-.3685,-.0683,5.5225,-18.8175,.2682,-.0033,.0439,-.1629,-.0299,.2232,-.2808,.039],[25.1343,-.4732,.0854,3.9605,-13.912,.2571,-.0028,.0398,-.1488,-.038,.4146,-.5644,.1571],[26.0776,-.4748,.0973,4.2405,-15.6978,.2526,-.0028,.0409,-.1485,-.0398,.4214,-.5758,.1652],[27.7828,-.4017,.07,4.258,-15.4754,.2367,-.0027,.0432,-.1635,-.035,.3149,-.4222,.1074],[33.321,-.5491,.2782,3.9722,-17.4641,.2081,-.0028,.0559,-.2079,-.0453,.3091,-.4165,.114],[34.8309,-.6942,.426,3.3318,-16.8497,.2081,-.003,.0647,-.2508,-.0416,.1445,-.1779,.0236],[37.5926,-.6443,.3677,3.4067,-16.42,.1823,-.0015,.0474,-.1947,-.0411,.2234,-.2936,.0668],[39.4412,-.5625,.2263,4.2984,-18.3087,.1635,-3e-4,.0348,-.1585,-.0452,.3142,-.4246,.1158],[40.6765,-.6234,.3141,3.8208,-17.9457,.1599,-2e-4,.0372,-.1782,-.041,.1452,-.1684,-.0017],[38.5263,-.6294,.3817,3.0897,-16.2418,.1784,-7e-4,.0354,-.1608,-.0439,.2718,-.3597,.0853],[38.8799,-.7551,.4856,2.734,-15.7989,.186,-8e-4,.037,-.1615,-.0449,.292,-.3993,.1186],[41.2743,-.9011,.6699,2.2512,-16.8137,.1795,-9e-4,.042,-.1746,-.0484,.2216,-.293,.0726],[42.2558,-1.0062,.7158,2.6789,-19.1943,.1817,-9e-4,.0441,-.1858,-.0468,.0978,-.112,.002],[40.2612,-.9872,.7444,1.7973,-16.1566,.1974,-.0012,.0445,-.1857,-.0476,.1203,-.1402,.0055],[43.6457,-1.0069,.734,1.9082,-15.776,.1751,-5e-4,.0411,-.1774,-.054,.2098,-.2758,.0684],[37.4261,-1.0061,.8119,.7582,-12.6239,.2262,-.0023,.0517,-.2087,-.0439,.0866,-.0919,-.0122],[39.6219,-1.2657,1.1924,-1.7105,-7.6258,.228,-.0027,.0582,-.2341,-.047,-.0208,.0811,-.1069],[40.843,-1.2324,1.2238,-1.9885,-7.0689,.2204,-.0032,.0673,-.2749,-.0429,-.1374,.2503,-.1721],[43.5592,-1.2444,1.2281,-1.7233,-8.2869,.2012,-.0024,.0607,-.2564,-.0432,-.1732,.3033,-.1943],[44.6015,-1.2557,1.2143,-1.1069,-11.0077,.197,-.0025,.062,-.2557,-.0368,-.2817,.4521,-.2374],[43.431,-1.4836,1.4844,-2.8301,-7.691,.2221,-.0031,.0664,-.2718,-.0343,-.3518,.5529,-.2744],[40.2503,-1.5293,1.5113,-3.3498,-5.9574,.2524,-.0038,.0674,-.2644,-.0307,-.3766,.5899,-.2912],[38.7912,-1.4248,1.4482,-3.6476,-4.2826,.2581,-.0037,.0597,-.2243,-.033,-.308,.4967,-.266],[43.1602,-1.3762,1.3057,-2.4967,-6.1669,.2217,-.0018,.0357,-.1265,-.0409,-.031,.0745,-.0711],[44.7535,-1.2714,1.1636,-1.6742,-7.0124,.2031,-6e-4,.0171,-.0429,-.0436,.1573,-.2169,.0706],[44.9528,-1.1354,1.0103,-.6896,-9.5126,.1953,-5e-4,.0153,-.0298,-.0404,.1044,-.1372,.0343],[39.8113,-.9011,.8911,-1.1437,-6.6547,.2237,-.002,.0227,-.0406,-.0358,.093,-.1099,.0051],[37.8989,-1.0051,1.0055,-1.5428,-6.9588,.2482,-.0029,.031,-.0735,-.0328,-.0609,.1319,-.119],[35.1924,-.8104,.8253,-.5962,-9.35,.2601,-.0037,.0368,-.0925,-.0269,-.1549,.2764,-.1888],[35.6873,-.7372,.8448,-1.3541,-6.8503,.254,-.0041,.0431,-.1168,-.023,-.2589,.4332,-.2593],[32.6133,-.5491,.7277,-1.3961,-5.5317,.2691,-.0053,.0532,-.1439,-.0153,-.3595,.5813,-.3205],[34.8437,-.4711,.6905,-1.4542,-4.7991,.2492,-.0052,.0579,-.1655,-.0189,-.3396,.557,-.3175],[35.5381,-.4317,.6593,-1.2682,-5.2622,.2433,-.0053,.063,-.1896,-.0217,-.3173,.5302,-.316],[36.1777,-.4466,.641,-.9947,-5.8087,.2409,-.0052,.0631,-.1933,-.022,-.1927,.3323,-.2121],[41.2921,-.4612,.5856,-.5033,-6.0372,.2021,-.0034,.0497,-.1573,-.0331,.0525,-.035,-.0513],[43.0646,-.3308,.3256,1.3124,-9.9318,.1798,-.0016,.0281,-.0904,-.0459,.3232,-.4202,.0842],[44.3551,-.1948,.1835,1.9859,-10.8501,.1628,-.0011,.0241,-.0832,-.0524,.5032,-.684,.19],[41.152,.0212,-.0243,2.9817,-12.3905,.1771,-.0019,.0273,-.0838,-.047,.5514,-.7673,.2434],[40.7747,.1804,-.1901,4.1333,-15.4608,.1742,-.0025,.0343,-.0976,-.0441,.5815,-.8266,.2933],[42.6723,.2057,-.2093,4.492,-16.8094,.1599,-.0024,.0353,-.0956,-.0449,.6759,-.9819,.3834],[44.4726,.1842,-.1287,4.2111,-17.151,.1485,-.0024,.0365,-.0871,-.036,.5025,-.7363,.2978],[44.4307,.0412,.0455,3.5578,-17.0706,.1602,-.0031,.0461,-.1195,-.0272,.2636,-.3881,.1611],[46.146,-.1944,.3303,2.0667,-14.4506,.1634,-.0032,.0504,-.1357,-.0212,.0591,-.0927,.0497],[48.5522,-.2845,.4266,2.1896,-16.3502,.1537,-.0035,.0626,-.1955,-.0152,-.2111,.308,-.1179],[47.5272,-.3843,.5027,1.5489,-14.8051,.1683,-.0032,.0566,-.179,-.0162,-.1752,.2648,-.1172],[42.3688,-.2544,.359,1.5821,-13.3586,.2003,-.0031,.0394,-.1,-.023,.1762,-.2505,.0889],[40.419,-.1244,.2024,2.2651,-13.8723,.2085,-.0028,.0242,-.027,-.0263,.4803,-.717,.3102],[41.2786,-.4001,.5512,.3246,-9.9661,.2234,-.0037,.0333,-.0397,-.0258,.411,-.6274,.2957],[44.5475,-.4095,.5884,.3313,-11.0779,.202,-.0036,.0417,-.0815,-.024,.2501,-.3889,.1968],[48.1433,-.5054,.6845,.6598,-14.3615,.1854,-.0038,.0599,-.1887,-.0266,.0236,-.0355,.0216],[36.6027,-.2846,.4948,.5126,-11.9027,.2648,-.0058,.0611,-.1823,-.0318,.3126,-.4516,.177],[32.668,-.2953,.5385,-.5236,-7.6933,.2977,-.0064,.0584,-.1674,-.0333,.4917,-.7205,.2953],[34.2675,-.3725,.6712,-1.4456,-4.71,.2927,-.0065,.0568,-.1384,-.0262,.4807,-.7367,.354],[34.5736,-.5184,.8798,-2.5558,-3.2479,.3039,-.0074,.0666,-.1528,-.013,.1827,-.311,.2009],[38.2705,-.8498,1.178,-3.1281,-5.8888,.2993,-.0068,.0702,-.2122,-.0147,-.202,.2993,-.1195],[27.2619,-.709,1.1524,-4.729,.3025,.3797,-.0092,.0796,-.2446,-.0222,.1254,-.163,.0363],[30.6429,-.6031,1.1239,-5.8827,7.3287,.3476,-.0081,.0684,-.2186,-.027,.4252,-.6274,.2628],[38.2584,-.5815,1.057,-5.5212,7.7327,.2884,-.0057,.0424,-.1141,-.0255,.4732,-.7143,.3218],[34.2063,-.6992,1.3687,-7.5293,9.9367,.33,-.0072,.0412,-.0552,-.0037,.0265,-.062,.0645],[28.3761,-.5032,1.1656,-6.5035,7.3478,.3702,-.009,.0557,-.0992,.0012,-.2162,.3295,-.1511],[31.5473,-.191,.8482,-4.995,5.5448,.333,-.0093,.0772,-.2338,-.0012,-.3665,.5893,-.3214],[28.0599,-.1241,.7701,-4.7329,5.1931,.3597,-.0102,.0796,-.2161,-.0098,.0298,-.0073,-.0557],[23.6587,.3036,.2722,-3.1305,5.7577,.3693,-.0097,.0627,-.1368,-.0164,.4595,-.6438,.21],[30.6936,.0131,.6061,-3.5047,1.8377,.3406,-.0098,.0776,-.195,-.0166,.1956,-.2534,.0492],[36.2121,-.1094,.7833,-3.9736,.5351,.3083,-.0089,.0774,-.1975,-.0148,.091,-.0977,-.0189],[42.9427,-.2087,1.2659,-7.7504,8.427,.2634,-.0082,.0706,-.1836,.0138,-.4419,.6751,-.3217],[35.6163,-.3308,1.3791,-8.3941,8.0466,.3365,-.0098,.0787,-.2043,-5e-4,-.1455,.2492,-.1613],[52.6206,.342,.8903,-5.8391,3.6866,.1778,-.0082,.0886,-.2524,.0117,-.5949,.9156,-.4441],[73.797,-.1315,1.1805,-3.1333,-12.7158,.0592,-.0043,.0809,-.2789,-.052,.1674,-.2079,.0315],[106.9205,-.8638,1.9387,-5.949,-7.0235,-.131,.0011,.064,-.2761,-.1211,.5938,-.7577,.1352]],he=[[-15.1614,.1585,.7927,-16.2445,64.9588,.7016,-.0159,.0803,-.1501,.0109,.1002,-.1603,.0565],[7.1181,.1808,.1658,-8.1838,41.4072,.5512,-.0095,.054,-.1228,.0057,.0042,.0299,-.0661],[16.6833,-.0164,.2766,-6.0204,29.5897,.5,-.0072,.037,-.0808,-.0092,.0673,-.0993,.0246],[4.2312,.3344,.0389,-4.8857,26.2991,.583,-.0104,.0473,-.0885,9e-4,.0958,-.155,.0586],[7.5365,-.0042,.4065,-5.8405,25.1459,.5865,-.0109,.0523,-.0938,.001,.0934,-.1598,.0738],[9.1488,-.3319,.8441,-9.4288,35.3411,.6019,-.0121,.0661,-.1243,-.0028,.105,-.187,.0975],[8.942,-.0756,.7374,-10.0163,38.7888,.5921,-.0126,.0712,-.1373,.013,.076,-.1417,.0814],[7.6195,.0671,.6085,-8.8982,34.0775,.5961,-.0127,.0706,-.1365,.0147,.0961,-.1812,.1062],[4.7191,.0248,.8039,-10.5118,37.6146,.6241,-.014,.074,-.1321,.0285,.0747,-.1503,.0994],[-3.7807,.2569,.5926,-10.5763,40.4022,.6754,-.0144,.0649,-.1065,.0265,.1273,-.2395,.1377],[-4.3588,.5128,.4441,-11.0057,43.9366,.6643,-.0141,.0598,-.0914,.0297,.1526,-.2899,.1703],[.9793,.277,.5168,-10.2491,40.6962,.6426,-.0127,.0539,-.0858,.0133,.1639,-.2987,.1604],[4.1744,.2919,.5211,-10.2719,41.0334,.6197,-.0121,.0528,-.0869,.0122,.1661,-.3033,.1633],[6.8468,.1938,.5369,-9.8873,39.859,.6088,-.0115,.0517,-.0889,.0046,.1768,-.321,.1715],[11.1461,.2378,.3678,-8.151,35.8557,.5761,-.01,.044,-.0795,-7e-4,.1778,-.321,.1698],[12.4221,.276,.2488,-6.8316,31.9031,.5662,-.0092,.0391,-.073,-.0089,.2003,-.3583,.1859],[10.6386,.5028,.0451,-6.0581,30.8189,.5675,-.0093,.0395,-.0789,-.0048,.1885,-.3309,.1625],[11.895,.4259,.0403,-5.1913,27.4155,.5654,-.0088,.0351,-.0686,-.0151,.216,-.3783,.1854],[15.6199,.2947,.1255,-4.8706,25.2474,.5485,-.0083,.0349,-.0709,-.0153,.1958,-.3402,.1631],[19.1961,.2043,.1214,-4.058,22.8341,.5297,-.0074,.031,-.0656,-.025,.2093,-.3615,.171],[24.9014,.1164,.1324,-3.0351,18.7307,.4951,-.0063,.0283,-.0649,-.0265,.1862,-.3184,.1463],[27.7411,-2e-4,.251,-3.251,17.9354,.4835,-.0062,.0313,-.073,-.026,.1667,-.2835,.1289],[26.5408,-.0132,.3133,-3.6487,17.7499,.4961,-.0068,.0361,-.0837,-.0188,.1384,-.2306,.0976],[24.9608,.0679,.2933,-3.7963,17.8167,.5066,-.0077,.043,-.0991,-.0102,.1136,-.1873,.0762],[30.7628,-.0404,.3473,-3.514,16.9902,.4711,-.0065,.0402,-.0991,-.0135,.1043,-.172,.0705],[32.9166,-.0712,.3957,-3.9,17.9467,.4584,-.0062,.0397,-.0994,-.0111,.0905,-.1473,.0576],[35.8384,-.154,.4647,-4.0996,18.2022,.4447,-.0061,.0445,-.1155,-.0116,.0725,-.1148,.0406],[35.8936,-.2601,.5885,-4.4079,17.6393,.4551,-.0069,.0522,-.1317,-.0062,.042,-.0594,.0107],[35.6599,-.2948,.6396,-4.5403,17.3049,.4616,-.0074,.0559,-.1397,-.0065,.0482,-.0732,.0217],[34.2326,-.3816,.7322,-4.795,17.0262,.4801,-.0079,.0573,-.1393,-.0049,.0527,-.0851,.0332],[38.436,-.518,.8471,-5.2375,18.6249,.4592,-.0074,.0594,-.1493,-.0109,.0578,-.0961,.042],[37.4759,-.3108,.6669,-4.487,17.3228,.4543,-.0072,.0558,-.1401,-.0071,.0668,-.1148,.0546],[38.2626,-.2565,.595,-3.8813,15.733,.4471,-.0072,.0565,-.1436,-.0047,.058,-.0993,.0468],[40.1654,-.373,.7286,-4.669,17.4341,.4421,-.0071,.0576,-.1469,-5e-4,.0365,-.0612,.0272],[42.9794,-.5548,.8878,-5.2907,18.8227,.4348,-.0069,.0595,-.1514,-.0022,.033,-.0585,.0309],[45.6449,-.6118,.8823,-5.0487,18.8985,.4196,-.0061,.0555,-.1462,-.0051,.0381,-.069,.0387],[46.6551,-.5689,.866,-5.0611,19.3856,.41,-.0059,.0537,-.1435,-.0027,.039,-.0728,.0431],[47.5003,-.5697,.8793,-5.203,19.8144,.4057,-.0059,.0563,-.1527,-.0019,.0291,-.0538,.0314],[45.403,-.5065,.8608,-5.5153,21.0092,.4195,-.0064,.0585,-.1569,.0032,.0197,-.0361,.0204],[44.8971,-.395,.8017,-5.6222,21.9379,.4168,-.0064,.0554,-.147,.0027,.0376,-.069,.0382],[47.5247,-.4291,.8436,-5.8317,22.6883,.3999,-.0058,.0527,-.1421,.0015,.0382,-.0702,.0389],[46.463,-.3679,.8717,-6.4206,23.9766,.4049,-.006,.0518,-.1372,.0093,.0233,-.0445,.0258],[43.9842,-.1919,.792,-6.7209,25.4109,.4126,-.0063,.0508,-.1325,.0119,.037,-.0693,.0383],[43.2939,-.2722,.8627,-7.0319,25.6372,.4253,-.0066,.052,-.1346,.0151,.022,-.0414,.0222],[44.9267,-.3058,.9029,-7.1291,25.4723,.4173,-.0066,.054,-.1396,.0166,.008,-.0161,.0087],[45.3659,-.1577,.7596,-6.3854,23.8924,.4047,-.006,.0477,-.1258,.015,.0245,-.0444,.0212],[45.5821,-.0245,.5923,-5.4731,22.294,.3963,-.0056,.046,-.1251,.0164,.0239,-.0431,.0201],[47.1433,-.0461,.591,-5.2852,21.7529,.3877,-.0053,.0449,-.1222,.0153,.0223,-.0412,.0208],[51.495,-.1432,.644,-5.3385,21.775,.3619,-.0042,.0417,-.1223,.0089,.0218,-.0369,.0143],[49.2507,-.0452,.5634,-5.0092,21.3118,.3735,-.0044,.0403,-.1176,.0104,.0345,-.0607,.0278],[48.723,-.0088,.5464,-5.0086,21.4246,.3773,-.0046,.0403,-.114,.0144,.0211,-.0365,.0147],[46.2919,.137,.4328,-4.7097,21.0581,.387,-.0047,.0368,-.1041,.0171,.0335,-.0595,.027],[47.5969,.1489,.3829,-4.2807,20.076,.3772,-.0039,.0315,-.0941,.0134,.0397,-.0681,.0283],[48.5103,.1248,.3886,-4.0219,19.1219,.3741,-.0039,.0318,-.0943,.0115,.0417,-.0714,.03],[47.0617,.2003,.3427,-3.9935,19.2648,.3815,-.0041,.0313,-.0915,.0121,.0505,-.0878,.0394],[47.9002,.1572,.3732,-3.8154,17.8605,.3802,-.0041,.032,-.0944,.0113,.0408,-.067,.024],[49.115,.0782,.4887,-4.5668,19.8764,.3783,-.0042,.0339,-.0974,.0137,.0304,-.0508,.019],[49.9451,.1037,.4323,-3.9989,18.2108,.3716,-.0039,.0318,-.0942,.0126,.0354,-.0602,.0246],[50.1287,.2012,.3324,-3.2058,15.608,.3664,-.0039,.0327,-.0981,.0177,.0133,-.0189,1e-4],[49.51,.1993,.3903,-3.8043,17.1157,.3729,-.0042,.0344,-.1008,.0221,.0041,-.0038,-.0061],[47.0301,.2961,.3665,-3.9702,17.4284,.3864,-.0047,.0328,-.0906,.0207,.0246,-.0408,.0138],[46.9571,.2268,.4324,-4.3249,18.4933,.3932,-.0048,.0332,-.0914,.0225,.0162,-.0255,.0051],[45.7187,.319,.3143,-3.5355,16.3535,.3986,-.0048,.0327,-.0905,.0195,.039,-.0672,.0285],[46.6338,.3294,.3122,-3.6994,16.9404,.3928,-.0047,.0327,-.0892,.02,.0422,-.0754,.036],[46.796,.2184,.4173,-4.2913,18.3125,.4005,-.0048,.0316,-.0843,.0138,.0632,-.1146,.0591],[45.6059,.2609,.3536,-3.7119,16.4744,.409,-.005,.0313,-.0814,.0161,.0671,-.1239,.0669],[46.2843,.1969,.384,-3.6001,15.9912,.4103,-.005,.0321,-.0828,.0153,.0735,-.139,.08],[42.7066,.3391,.2772,-3.5789,16.5957,.4304,-.0057,.0333,-.0798,.0158,.0981,-.1852,.1067],[42.8015,.3061,.3293,-3.7417,16.4765,.4348,-.0061,.0357,-.0812,.0203,.0909,-.1775,.1098],[44.6588,.3589,.2756,-3.1211,14.5181,.4196,-.0059,.0374,-.0881,.0175,.0943,-.1832,.1126],[45.4978,.2369,.3198,-2.8753,12.9699,.4238,-.0058,.0377,-.09,.0126,.0997,-.1911,.1148],[44.3791,.247,.2747,-2.2776,10.7861,.4342,-.0061,.0387,-.0918,.0106,.1113,-.2121,.1265],[44.5213,.3308,.2335,-2.5761,12.6357,.4295,-.006,.0393,-.0953,.015,.1005,-.192,.1141],[43.3339,.3496,.2289,-2.6952,12.6151,.4397,-.0064,.0411,-.0987,.0118,.1138,-.2135,.1223],[45.7745,.2806,.323,-3.0124,12.5836,.4279,-.0062,.0429,-.1061,.0132,.0996,-.1888,.1104],[46.2858,.2501,.3239,-2.6897,11.1237,.4274,-.0059,.0399,-.1008,.0086,.1214,-.2293,.1336],[47.1461,.0565,.3804,-1.9028,7.5777,.4368,-.0058,.0399,-.1016,-.0042,.1495,-.2777,.1579],[49.8411,-.0213,.4353,-2.2574,9.0572,.4224,-.0051,.0374,-.0989,-.0067,.1499,-.2787,.1591],[54.41,-.2754,.6713,-3.3139,10.8614,.4065,-.0045,.0392,-.1059,-.0134,.1536,-.2881,.1687],[59.0571,-.3916,.714,-3.2563,11.6335,.3792,-.0031,.0313,-.0925,-.0235,.1848,-.3462,.2023],[61.5501,-.4923,.8257,-3.7049,12.2735,.3688,-.0028,.0301,-.0892,-.0258,.1974,-.3735,.2231],[62.0991,-.5602,.8523,-3.3702,9.855,.371,-.0025,.0277,-.085,-.0253,.1895,-.3572,.2113],[63.7402,-.7486,1.0333,-4.0639,10.5288,.3743,-.0026,.0296,-.0853,-.0264,.1907,-.3647,.2234],[63.1912,-.7684,1.0572,-4.1343,10.1666,.3825,-.0028,.0301,-.0846,-.0226,.1752,-.3347,.204],[65.29,-.9003,1.2109,-4.7056,10.0344,.3789,-.0031,.0353,-.0982,-.0171,.1415,-.2745,.173],[69.7586,-.9059,1.1421,-3.8514,8.3464,.3466,-.0015,.0272,-.0852,-.0254,.1633,-.3147,.1963],[68.7204,-.7413,1.161,-4.8929,11.4709,.347,-.0023,.0323,-.0945,-.0166,.1384,-.2677,.1676],[70.0709,-.7105,1.1845,-4.9763,11.0263,.3366,-.0017,.0271,-.0857,-.0132,.1197,-.2317,.1451],[71.2247,-.6095,1.0475,-4.2244,9.2028,.3239,-8e-4,.022,-.0796,-.0212,.1383,-.2581,.1496],[71.0728,-.5897,.954,-3.2255,5.828,.3275,-5e-4,.0181,-.0707,-.02,.1457,-.2721,.1573],[70.0217,-.3531,.6571,-1.1748,.806,.3265,-6e-4,.0201,-.0785,-.0091,.1053,-.1976,.115],[70.5203,-.3866,.7711,-1.2734,-1.0004,.3319,-.0017,.0287,-.092,.009,.0424,-.0915,.0678],[76.3547,-.7212,.9341,-1.3303,-1.6526,.314,-2e-4,.0247,-.0938,-.0122,.0896,-.174,.1101],[90.6025,-1.3557,1.1746,.1551,-7.729,.2521,.0034,.0132,-.0881,-.0357,.0885,-.1674,.1033],[102.6662,-1.2263,.8589,3.2534,-15.7885,.1576,.0072,-.0076,-.0516,-.0325,.0706,-.1432,.1009],[102.9154,-1.5899,1.4523,-.5061,-7.5933,.1871,.0055,.002,-.0596,-.0411,.1113,-.2264,.1604],[125.2207,-3.3398,2.9466,-5.4863,-1.908,.1438,.0076,.0111,-.0959,-.1006,.1222,-.2249,.1376],[125.8697,-3.2997,3.1051,-7.3155,3.4281,.1505,.0067,.0193,-.1148,-.0879,.0819,-.1569,.1076],[99.6314,-2.8535,3.065,-6.4997,-4.9829,.3473,-.001,.0499,-.1346,-.0354,-.0379,.0681,-.0284]],ge=[[-13.567,-1.1325,-1.7078,28.8607,-81.1719,.4118,3e-4,-.0263,.0507,-.0087,-.1202,.2977,-.2691],[-43.7777,1.9512,-3.8763,28.8717,-57.6407,.4741,-.0029,-.0496,.1518,-.0191,.1992,-.2879,.0508],[-35.5221,1.6542,-3.2001,22.4882,-41.299,.4425,-.0025,-.0428,.1269,-.0674,.3133,-.465,.1062],[-25.9772,2.0924,-3.8188,24.4956,-38.8551,.3556,3e-4,-.0543,.1499,-.0796,.4423,-.7299,.2906],[-16.9931,2.2497,-3.7873,23.1323,-35.1791,.2916,6e-4,-.0481,.1416,-.0641,.3962,-.6572,.2638],[-19.6683,2.3137,-3.7117,22.8638,-35.7152,.3203,-.0015,-.0388,.1406,-.0689,.4499,-.7699,.3469],[-33.2858,2.7679,-4.0941,22.3138,-27.6548,.3986,-.0021,-.0592,.2053,-.0938,.6243,-1.0803,.5056],[-42.522,3.0229,-4.2155,22.1584,-27.6854,.4632,-.0051,-.0392,.1567,-.0631,.512,-.8671,.3759],[-34.2517,2.7721,-3.6109,17.4453,-15.4161,.4233,-.0055,-.0269,.1286,-.0371,.366,-.6077,.2427],[-42.4833,3.1554,-3.8233,16.9605,-12.0012,.466,-.0072,-.0191,.1105,-.0294,.3572,-.5855,.2225],[-54.4375,3.0764,-3.5785,15.2542,-9.8518,.569,-.0112,-.0014,.0879,-.034,.4004,-.6627,.2631],[-38.5925,2.3768,-3.1326,15.4931,-14.1216,.5015,-.0094,.0059,.0528,-.0475,.355,-.5818,.2245],[-40.8119,2.5241,-3.3547,16.1453,-12.993,.5119,-.0092,.0039,.0554,-.0504,.3968,-.6637,.2771],[-46.3014,2.6717,-3.5156,16.4588,-11.9729,.5495,-.0106,.0106,.0468,-.0493,.4299,-.7314,.3246],[-47.6314,2.9586,-3.758,16.7192,-10.3567,.5434,-.0102,.0067,.0518,-.0595,.4837,-.8241,.3686],[-41.6665,2.9392,-3.8754,17.5857,-10.8233,.4983,-.0073,-.0149,.0964,-.0817,.5737,-.987,.4563],[-45.7369,2.9396,-3.8633,17.231,-10.561,.5321,-.008,-.0146,.1016,-.0765,.5824,-1.0084,.4748],[-51.929,2.9378,-3.7832,15.9238,-7.0752,.586,-.0101,-.0013,.0747,-.0647,.5498,-.9515,.4469],[-45.8559,3.0516,-3.9216,17.0729,-10.1336,.5356,-.0086,-.0063,.0786,-.0616,.5196,-.8956,.415],[-39.5605,2.8551,-3.5847,14.9465,-5.3128,.5025,-.0082,-.003,.0687,-.0683,.5134,-.8848,.4109],[-33.7657,2.9223,-3.533,14.1257,-2.6863,.4575,-.0075,-.0012,.0596,-.0664,.4876,-.8388,.3872],[-32.281,2.6018,-3.2278,12.8399,-.8793,.472,-.0081,.0063,.0419,-.062,.4496,-.7751,.3605],[-31.5797,2.3929,-2.9101,11.2038,1.5782,.4845,-.0091,.0143,.0265,-.0586,.4152,-.712,.3258],[-32.2816,2.6349,-3.0487,11.5875,.5188,.4779,-.0097,.0203,.0104,-.044,.3694,-.6297,.2818],[-25.44,2.7183,-3.2535,13.5284,-4.0414,.421,-.007,.0038,.0396,-.0469,.3676,-.6261,.2792],[-22.8873,2.5652,-3.2543,13.672,-3.1603,.4141,-.0056,-.0066,.0583,-.0566,.3787,-.6382,.2747],[-20.7911,2.6849,-3.4699,14.9131,-5.2628,.3921,-.0042,-.015,.0686,-.0663,.3974,-.6642,.2789],[-18.557,2.4292,-3.0989,12.2737,1.0228,.3937,-.0045,-.0121,.0655,-.073,.4005,-.667,.277],[-17.5306,2.5085,-3.1093,11.7413,3.3022,.3838,-.0047,-.009,.0598,-.0637,.3744,-.6243,.2595],[-14.3488,2.3673,-3.0068,11.4653,3.7471,.3712,-.004,-.0129,.0679,-.0681,.3759,-.6244,.2561],[-16.6395,2.3516,-2.9622,11.2382,3.1551,.3924,-.0047,-.0114,.0678,-.0675,.3777,-.6258,.2543],[-10.6475,2.2971,-2.8656,10.1755,7.4446,.3509,-.0034,-.0169,.0752,-.0763,.3958,-.6548,.2643],[-10.0847,2.4662,-2.9361,10.2311,6.9534,.3368,-.0033,-.0182,.08,-.073,.3922,-.6484,.2607],[-9.646,2.4037,-2.8587,10.171,5.6614,.3398,-.0036,-.0141,.0709,-.0667,.3688,-.6116,.2487],[-5.5,2.2058,-2.7946,11.4006,-.0691,.3246,-.003,-.0129,.0635,-.0713,.3492,-.5757,.231],[-3.1184,2.0845,-2.7566,11.9122,-2.7527,.3161,-.0025,-.0137,.0596,-.0779,.347,-.5661,.2186],[-1.8889,1.938,-2.5612,10.5284,.4557,.3178,-.0027,-.01,.0505,-.0868,.3703,-.6072,.2401],[1.3652,1.8159,-2.5509,11.3987,-2.5982,.3031,-.002,-.0117,.0496,-.095,.3856,-.6354,.2568],[4.1129,1.8155,-2.5332,11.0415,-.7368,.2849,-.0018,-.0081,.038,-.0883,.364,-.6035,.2493],[1.4862,1.9999,-2.7504,12.2222,-3.4789,.295,-.0018,-.0113,.0461,-.0881,.3736,-.6168,.2503],[-2.474,2.0859,-2.8319,12.5224,-3.8212,.3229,-.0028,-.0094,.0487,-.086,.392,-.6551,.2772],[-.415,1.9078,-2.6838,12.7489,-6.852,.3217,-.0029,-.0082,.0472,-.0801,.3635,-.6077,.2576],[-.0497,1.8113,-2.6253,12.8018,-7.7129,.3277,-.0029,-.0071,.0414,-.0794,.3497,-.5807,.2402],[-1.5833,1.7827,-2.6894,13.4925,-9.1732,.3439,-.003,-.0061,.0371,-.0845,.3665,-.6098,.2548],[1.209,1.7298,-2.6076,12.8518,-6.9268,.3277,-.0027,-.0052,.0323,-.087,.3703,-.6203,.2656],[1.2834,1.6318,-2.5106,12.1368,-4.9164,.335,-.0025,-.0086,.0415,-.0924,.386,-.6467,.2773],[-.4438,1.6936,-2.4801,11.7414,-4.8147,.3463,-.0031,-.0075,.0435,-.0895,.3834,-.6422,.2749],[-.2325,1.613,-2.4272,12.1673,-8.1046,.3529,-.0033,-.0065,.0434,-.0851,.3606,-.6019,.2545],[-2.1989,1.6982,-2.4926,12.7697,-10.7769,.3643,-.0037,-.0061,.0459,-.0859,.3821,-.6441,.2821],[-.8411,1.6919,-2.4301,12.0592,-8.667,.3572,-.004,-5e-4,.0305,-.0865,.3748,-.6317,.2776],[.1678,1.6387,-2.3829,11.423,-6.0839,.3552,-.0038,-4e-4,.0275,-.0933,.3894,-.6552,.2867],[.8079,1.7778,-2.4652,11.0582,-4.0097,.3404,-.0029,-.0096,.0477,-.0928,.4036,-.6792,.2963],[-1.1219,1.8103,-2.4361,10.7708,-4.1791,.3561,-.0036,-.0078,.0484,-.0819,.3736,-.6278,.2717],[-4.8133,1.8058,-2.331,9.8828,-2.9487,.3871,-.0049,-.0019,.0409,-.0736,.3513,-.5879,.2503],[-8.1979,2.0298,-2.494,10.6089,-5.3076,.4011,-.0058,.0028,.0321,-.0692,.3504,-.5851,.247],[-6.752,2.0613,-2.4814,10.131,-3.6573,.3884,-.0055,2e-4,.0371,-.0753,.3769,-.6294,.2655],[-3.566,1.8329,-2.2802,9.0883,-.4962,.3807,-.005,-7e-4,.0371,-.081,.3819,-.6401,.2738],[1.0387,1.7975,-2.2844,9.2486,-.6268,.3494,-.0037,-.0064,.0437,-.0821,.3621,-.6004,.2472],[1.6962,1.5592,-2.1909,9.9497,-4.5187,.3625,-.0033,-.0098,.0505,-.0904,.364,-.5976,.2383],[1.7174,1.6924,-2.3499,11.1189,-8.075,.3556,-.0029,-.0144,.0602,-.0871,.3514,-.5716,.2195],[-1.1808,1.896,-2.4788,11.4555,-8.5302,.3668,-.0036,-.0124,.0586,-.0775,.3326,-.5377,.2006],[-1.9286,1.8974,-2.4107,10.6569,-6.2357,.3747,-.0042,-.0079,.0509,-.0731,.3224,-.5217,.1951],[-.6762,1.6316,-2.0498,8.2301,-.4293,.3859,-.0052,.0017,.0314,-.0748,.3067,-.4907,.1753],[.0177,1.3931,-1.7224,6.2104,3.67,.398,-.006,.0074,.0231,-.0781,.3064,-.4907,.1763],[1.8242,1.4415,-1.8531,7.4867,.3209,.381,-.0045,-.0055,.0517,-.0808,.3148,-.504,.181],[3.3864,1.5296,-1.8957,8.1805,-2.714,.3667,-.0046,-.0044,.0516,-.0669,.2582,-.4028,.1272],[1.4518,1.5557,-2.0588,9.891,-7.5275,.3836,-.0047,-.0045,.0515,-.0676,.2556,-.3964,.1218],[-.2228,1.7851,-2.3148,11.3445,-10.9345,.3835,-.0048,-.0063,.0572,-.0663,.2738,-.4312,.1425],[-1.2686,1.848,-2.3626,11.0795,-8.9995,.3885,-.0049,-.0053,.0531,-.0765,.3143,-.5003,.1745],[-1.1771,1.9498,-2.33,9.7844,-3.6954,.382,-.0052,-.0022,.0473,-.0778,.3354,-.5421,.202],[-1.5905,1.9246,-2.2012,8.7588,-1.7051,.39,-.0063,.0071,.0279,-.0723,.315,-.5067,.1847],[1.3907,1.7403,-1.9434,6.9646,2.6064,.3789,-.006,.0072,.0262,-.0787,.3279,-.5282,.1939],[5.7059,1.724,-1.9265,7.7741,-2.061,.3493,-.0054,.0068,.0244,-.0694,.282,-.4467,.1515],[12.6597,1.3459,-1.7148,8.837,-8.9553,.3265,-.0048,.0144,-.0045,-.065,.1958,-.2892,.0669],[14.3993,1.3957,-1.9442,11.1527,-15.7051,.3118,-.0037,.0089,-4e-4,-.0745,.2201,-.3286,.0822],[17.6818,1.388,-1.9866,11.7883,-17.7697,.2899,-.0031,.0095,-.0089,-.0708,.1938,-.2807,.056],[11.917,1.6817,-2.3045,13.3873,-21.1645,.3206,-.0046,.0186,-.0278,-.0691,.2114,-.3145,.0776],[9.2777,1.6967,-2.2055,11.4045,-13.2029,.3418,-.0056,.0253,-.0412,-.0758,.2487,-.3832,.1165],[5.8584,1.6874,-2.0515,9.5688,-8.1664,.3719,-.0073,.0382,-.0675,-.0715,.2508,-.3923,.1289],[9.3245,1.5374,-1.8954,9.7989,-11.7858,.3581,-.0073,.0413,-.0754,-.063,.2057,-.3147,.0928],[16.2286,1.2597,-1.7964,11.1013,-18.2966,.3267,-.0058,.0385,-.0835,-.0656,.1577,-.2201,.0326],[15.2268,1.0841,-1.7857,12.168,-22.5467,.3504,-.0059,.0373,-.0777,-.0718,.1751,-.253,.0528],[10.4724,1.4733,-2.2295,13.8392,-23.1801,.3634,-.0056,.0276,-.0497,-.0848,.2636,-.4153,.1436],[5.2365,1.5165,-2.1802,12.4214,-17.9441,.4039,-.0071,.0317,-.0486,-.0919,.3179,-.5147,.1988],[10.1259,1.4465,-1.9666,11.6878,-19.1724,.3722,-.0063,.0273,-.0379,-.0743,.2451,-.3873,.1349],[8.7996,1.6042,-2.2123,13.8638,-26.1613,.3767,-.006,.0209,-.0216,-.0624,.2044,-.3117,.0907],[7.3808,1.9753,-2.5467,14.6551,-24.7762,.366,-.0058,.0184,-.0173,-.0685,.2633,-.4213,.1535],[8.2409,1.8093,-1.8703,8.5537,-10.4574,.3742,-.008,.033,-.0361,-.0481,.1904,-.2951,.0924],[16.3443,1.4613,-1.5844,8.5531,-13.7014,.3376,-.0067,.028,-.0305,-.0421,.1473,-.2208,.0564],[13.6814,1.7899,-2.0949,11.8906,-20.3017,.3408,-.0062,.0239,-.0268,-.0499,.1898,-.2958,.0953],[-2.2305,2.0458,-2.0636,8.7608,-9.0684,.4491,-.0095,.0277,-.0118,-.0522,.2641,-.4295,.1659],[7.1024,1.4245,-1.2884,5.4006,-5.1633,.4266,-.0107,.0507,-.0701,-.0223,.0801,-.0982,-.0105],[22.5224,1.2411,-1.1587,5.4827,-6.229,.3231,-.008,.0497,-.0852,-.035,.0837,-.1047,-.0066],[7.1688,2.0574,-2.1429,8.7073,-6.973,.3913,-.0079,.0285,-.027,-.0746,.3209,-.5246,.2072],[10.9219,1.7121,-1.5447,6.0756,-5.588,.3914,-.0095,.0458,-.0634,-.034,.1515,-.2269,.0567],[.0292,1.3826,-1.5163,7.1831,-10.5716,.5124,-.0137,.0821,-.1555,-.0443,.1613,-.2416,.0645],[-7.4708,1.924,-1.6304,5.8484,-7.4136,.5394,-.0152,.0752,-.1166,-.0193,.205,-.3492,.1599],[17.4158,1.6902,-1.3304,3.6898,3.0431,.3737,-.0096,.0478,-.0772,-.0183,.131,-.2054,.0662],[-2.725,3.8134,-2.3052,3.5243,8.0191,.4042,-.0133,.0238,.0586,.0627,.0422,-.052,-.018]];function M(e){let t=e<0?-1:1,n=Math.abs(e)/Math.sqrt(2),r=1/(1+.3275911*n);return .5*(1+t*(1-((((1.061405429*r+-1.453152027)*r+1.421413741)*r+-.284496736)*r+.254829592)*r*Math.exp(-n*n)))}function N(e,t,n){let r=Math.max(0,Math.min(217,Math.round(e*12)-24)),i,a,o;t===`female`?(i=le[r],a=ue[r],o=de[r]):(i=A[r],a=j[r],o=fe[r]);let s=((n/a)**+i-1)/(i*o);return{z:s,percentile:M(s)*100}}function P(e,t,n,r,i){let a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b;t===`female`?(a=106.7,o=140.7,s=154,c=160.5,l=168.9,u=5,d=10.7,f=13.16,p=14.51,m=17.33,h=6.701,g=16.438,_=46.8,v=84.46,y=203.608,b=(e-10)*(n-147)):(a=107.8,o=140,s=154.5,c=166.4,l=179.1,u=5.06,d=10.79,f=13.22,p=14.51,m=17.3,h=-15,g=8.9,_=50.375,v=112.684,y=250.04,b=(e-10)*(n-150));let x=n,S=e,C=Math.max(0,x-a),w=Math.max(0,x-c),T=Math.max(0,x-l),ee=C**3-w**3*(l-a)/(l-c)+T**3*(c-a)/(l-c),te=Math.max(0,x-o)**3-w**3*(l-o)/(l-c)+T**3*(c-o)/(l-c),ne=Math.max(0,x-s)**3-w**3*(l-s)/(l-c)+T**3*(c-s)/(l-c),E=ee/100,re=te/100,ie=ne/100,ae=Math.max(0,S-u),D=Math.max(0,S-p),O=Math.max(0,S-m),k=ae**3-D**3*(m-u)/(m-p)+O**3*(p-u)/(m-p),oe=Math.max(0,S-d)**3-D**3*(m-d)/(m-p)+O**3*(p-d)/(m-p),se=Math.max(0,S-f)**3-D**3*(m-f)/(m-p)+O**3*(p-f)/(m-p),ce=k/100,le=oe/100,ue=se/100,de=Math.max(0,b-h),A=Math.max(0,b-v),j=Math.max(0,b-y),fe=de**3-A**3*(y-h)/(y-v)+j**3*(v-h)/(y-v),M=Math.max(0,b-g)**3-A**3*(y-g)/(y-v)+j**3*(v-g)/(y-v),N=Math.max(0,b-_)**3-A**3*(y-_)/(y-v)+j**3*(v-_)/(y-v),P=fe/1e4,F=M/1e4,I=N/1e4,L;L=t===`female`?r===`sys`?pe:me:r===`sys`?he:ge;let R=Array(99);for(let e=0;e<99;e++)R[e]=L[e][0]+L[e][5]*x+L[e][6]*E+L[e][7]*re+L[e][8]*ie+L[e][1]*S+L[e][2]*ce+L[e][3]*le+L[e][4]*ue+L[e][9]*b+L[e][10]*P+L[e][11]*F+L[e][12]*I;let z=1/0,B=50;for(let e=0;e<99;e++){let t=Math.abs(i-R[e]);t=13?(a=r>=140?`stage2`:r>=130?`stage1`:r>=120?`elevated`:`normal`,o=i>=90?`stage2`:i>=80?`stage1`:`normal`):(a=t>=107||r>=140?`stage2`:t>=95||r>=130?`stage1`:t>=90||r>=120?`elevated`:`normal`,o=n>=107||i>=90?`stage2`:n>=95||i>=80?`stage1`:n>=90?`elevated`:`normal`);let s={normal:0,elevated:1,stage1:2,stage2:3},c=s[a]>=s[o]?a:o;return{sysClass:a,diaClass:o,classification:c}}function I(e,t,n,r,i){let a=N(e,t,n),o=P(e,t,n,`sys`,r),s=P(e,t,n,`dia`,i),c=F(e,o.percentile,s.percentile,r,i);return{sysPercentile:o.percentile,diaPercentile:s.percentile,heightPercentile:a.percentile,sysClass:c.sysClass,diaClass:c.diaClass,classification:c.classification}}var L=n(),R=`rounded-lg border border-border bg-card p-5 space-y-3`,z=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,B=`block text-xs font-medium text-muted-foreground`,_e=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,ve=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,ye=`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,V={normal:{label:`Normal`,color:`#10b981`,bg:`#d1fae5`},elevated:{label:`Elevated`,color:`#f59e0b`,bg:`#fef3c7`},stage1:{label:`Stage 1 Hypertension`,color:`#f97316`,bg:`#ffedd5`},stage2:{label:`Stage 2 Hypertension`,color:`#ef4444`,bg:`#fee2e2`}};function be(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(`female`),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(null);function h(){let t=Number.parseFloat(e),r=Number.parseFloat(i),a=Number.parseFloat(o),s=Number.parseFloat(c);if(!Number.isFinite(t)||!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(s)){f(`Fill in all fields.`),m(null);return}if(t<1||t>17){f(`Age must be 1-17 years.`),m(null);return}if(r<50||r>200){f(`Height must be 50-200 cm.`),m(null);return}f(``),m(I(t,n,r,a,s))}let g=p?V[p.classification]:null;return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-bp`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`BP Percentile (AAP 2017)`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Age (years)`}),(0,L.jsx)(`input`,{type:`number`,min:`1`,max:`17`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`bp-age`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Sex`}),(0,L.jsxs)(`select`,{className:z,value:n,onChange:e=>r(e.target.value),"data-testid":`bp-sex`,children:[(0,L.jsx)(`option`,{value:`female`,children:`Female`}),(0,L.jsx)(`option`,{value:`male`,children:`Male`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Height (cm)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`200`,step:`0.1`,className:z,value:i,onChange:e=>a(e.target.value),"data-testid":`bp-height`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`SBP (mmHg)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`220`,step:`1`,className:z,value:o,onChange:e=>s(e.target.value),"data-testid":`bp-sbp`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`DBP (mmHg)`}),(0,L.jsx)(`input`,{type:`number`,min:`30`,max:`150`,step:`1`,className:z,value:c,onChange:e=>u(e.target.value),"data-testid":`bp-dbp`})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:h,className:_e,"data-testid":`calc-bp-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{t(``),a(``),s(``),u(``),m(null),f(``)},className:ve,children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:ye,children:d}),p&&g&&(0,L.jsxs)(`div`,{className:`rounded-lg p-4 space-y-2`,style:{background:g.bg,borderLeft:`4px solid ${g.color}`},"data-testid":`calc-bp-result`,children:[(0,L.jsx)(`div`,{className:`text-base font-bold`,style:{color:g.color},children:g.label}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Systolic`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.sysPercentile,`th %ile`]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:V[p.sysClass].label})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Diastolic`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.diaPercentile,`th %ile`]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:V[p.diaClass].label})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Height`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.heightPercentile.toFixed(0),`th %ile`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Overall`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:g.label})]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Flynn JT et al. Clinical Practice Guideline for Screening and Management of High Blood Pressure in Children and Adolescents. Pediatrics 2017;140(3):e20171904.`})]})}function xe(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(`male`),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(null);function h(){let t=(Number.parseFloat(e)||0)+(Number.parseInt(n,10)||0)/12,r=Number.parseFloat(o),a=Number.parseFloat(c);if(!t||!Number.isFinite(r)||r<=0||!Number.isFinite(a)||a<=0){f(`Fill in all fields.`),m(null);return}if(t<2||t>20){f(`Age must be 2-20 years.`),m(null);return}f(``),m(ce(r,a,Math.round(t*12),i))}return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-bmi`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`BMI Percentile (CDC 2000)`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:col-span-1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Age (yr)`}),(0,L.jsx)(`input`,{type:`number`,min:`2`,max:`20`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`bmi-age-yr`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Months`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`11`,className:z,value:n,onChange:e=>r(e.target.value),"data-testid":`bmi-age-mo`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Sex`}),(0,L.jsxs)(`select`,{className:z,value:i,onChange:e=>a(e.target.value),"data-testid":`bmi-sex`,children:[(0,L.jsx)(`option`,{value:`male`,children:`Male`}),(0,L.jsx)(`option`,{value:`female`,children:`Female`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:B,children:`Weight (kg)`}),(0,L.jsx)(`input`,{type:`number`,min:`1`,max:`200`,step:`0.1`,className:z,value:o,onChange:e=>s(e.target.value),"data-testid":`bmi-weight`})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-1`,children:[(0,L.jsx)(`label`,{className:B,children:`Height (cm)`}),(0,L.jsx)(`input`,{type:`number`,min:`50`,max:`220`,step:`0.1`,className:z,value:c,onChange:e=>u(e.target.value),"data-testid":`bmi-height`})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:h,className:_e,"data-testid":`calc-bmi-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{t(``),r(``),s(``),u(``),m(null),f(``)},className:ve,children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:ye,children:d}),p&&(0,L.jsxs)(`div`,{className:`rounded-lg p-4 space-y-2`,style:{background:p.classification.bg,borderLeft:`4px solid ${p.classification.color}`},"data-testid":`calc-bmi-result`,children:[(0,L.jsx)(`div`,{className:`text-base font-bold`,style:{color:p.classification.color},children:p.classification.label}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`BMI `,p.bmi.toFixed(1),` kg/m² — `,p.percentile,`th percentile`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`BMI`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.bmi.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Percentile`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.percentile,`th`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Z-Score`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.z.toFixed(2)})]}),p.percentile>=85&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`% of 95th`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[p.classification.pctOf95.toFixed(0),`%`]})]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`CDC 2000 LMS tables · Kuczmarski et al. Vital Health Stat 11. 2002;(246).`})]})}var Se={premie:{label:`Premie`,hr:{awake:`120-170`,sleeping:`100-150`},rr:`40-70`,sbp:`55-75`,dbp:`35-45`,temp:`36.5-37.5`,weight:`0.5-2.5 kg`,spo2:`88-95% (target)`,notes:[`HR and RR are highly variable and depend on gestational age`,`BP increases with gestational age and postnatal age`,`Target SpO2 88-95% to reduce retinopathy of prematurity risk`,`Temperature instability is common — use servo-controlled warmers`,`Bradycardia (<100 bpm) and apnea are common in premature infants`]},"0-3mo":{label:`0-3 Months`,hr:{awake:`100-150`,sleeping:`85-135`},rr:`35-55`,sbp:`65-85`,dbp:`45-55`,temp:`36.5-37.5`,weight:`2.5-6 kg`,spo2:`>95%`,notes:[`HR normally increases with crying (up to 180-190 bpm) — this is physiologic`,`Periodic breathing (pauses <10 sec) is normal in neonates`,`Acrocyanosis (blue hands/feet) is normal; central cyanosis is not`,`BP is best measured in the right arm (pre-ductal) in neonates`,`Normal weight loss of 5-7% in first 3-5 days; regain by 10-14 days`]},"3-6mo":{label:`3-6 Months`,hr:{awake:`90-120`,sleeping:`75-110`},rr:`30-45`,sbp:`70-90`,dbp:`50-65`,temp:`36.5-37.5`,weight:`5-8 kg`,spo2:`>95%`,notes:[`Expected weight gain: 20-30 g/day (150-200 g/week)`,`HR gradually decreases as vagal tone matures`,`RR >60 at rest may indicate lower respiratory tract disease`,`BP should be measured with appropriate cuff size (width 40% of arm circumference)`]},"6-12mo":{label:`6-12 Months`,hr:{awake:`80-120`,sleeping:`70-110`},rr:`25-40`,sbp:`80-100`,dbp:`55-65`,temp:`36.0-37.5`,weight:`8-10 kg`,spo2:`>95%`,notes:[`Expected weight: triple birth weight by 12 months (~10 kg average)`,`Weight gain slows to ~10-15 g/day`,`Sinus arrhythmia (HR varies with breathing) is normal`,`Febrile tachycardia: HR increases ~10 bpm per 1 degree C above 37`]},"1-3yr":{label:`1-3 Years`,hr:{awake:`70-110`,sleeping:`60-100`},rr:`20-30`,sbp:`90-105`,dbp:`55-70`,temp:`36.0-37.5`,weight:`10-15 kg`,spo2:`>95%`,notes:[`Expected weight gain: ~200-250 g/month (2-2.5 kg/year)`,`Tachycardia: HR >110 at rest warrants evaluation`,`Tachypnea: RR >30 at rest may indicate respiratory distress`,`BP screening begins at age 3 per AAP 2017 guidelines`,`Estimated weight: 2 x (age in years) + 8`]},"3-6yr":{label:`3-6 Years`,hr:{awake:`65-110`,sleeping:`55-100`},rr:`20-25`,sbp:`95-110`,dbp:`60-75`,temp:`36.0-37.5`,weight:`14-20 kg`,spo2:`>95%`,notes:[`Annual BP screening recommended from age 3`,`Normal BP <90th percentile for age, sex, and height`,`Elevated BP: 90th to <95th percentile (or 120/80 if lower)`,`Estimated weight: 2 x (age in years) + 8`,`ETT size (uncuffed): (age/4) + 4`]},"6-12yr":{label:`6-12 Years`,hr:{awake:`60-95`,sleeping:`50-85`},rr:`14-22`,sbp:`100-120`,dbp:`60-75`,temp:`36.0-37.5`,weight:`20-40 kg`,spo2:`>95%`,notes:[`Resting HR >95 or <60 warrants evaluation`,`BP should be measured at every clinical encounter`,`Stage 1 HTN: >=95th percentile on 3 separate occasions`,`Estimated weight: 3 x (age in years) + 7`,`ETT size (cuffed): (age/4) + 3.5`]},">12yr":{label:`>12 Years`,hr:{awake:`55-85`,sleeping:`45-75`},rr:`12-18`,sbp:`110-135`,dbp:`65-85`,temp:`36.0-37.5`,weight:`40-80 kg`,spo2:`>95%`,notes:[`Vital signs approach adult values`,`From age 13: use adult BP thresholds (AAP 2017)`,`Normal: <120/<80 mmHg; Elevated: 120-129/<80 mmHg`,`Stage 1 HTN: 130-139/80-89 mmHg; Stage 2 HTN: >=140/>=90 mmHg`,`Orthostatic vitals: measure lying, sitting, standing if dizzy`,`Athletic bradycardia (HR 45-60) may be normal in trained adolescents`]}},Ce=[`premie`,`0-3mo`,`3-6mo`,`6-12mo`,`1-3yr`,`3-6yr`,`6-12yr`,`>12yr`];function we(){let[e,t]=(0,l.useState)(`1-3yr`),n=Se[e];return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-vitals`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Vital Signs by Age`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Age group`}),(0,L.jsx)(`select`,{className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`vitals-age-select`,children:Ce.map(e=>(0,L.jsx)(`option`,{value:e,children:Se[e].label},e))})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3 text-sm`,"data-testid":`vitals-result`,children:[(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Heart rate (awake)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.hr.awake,` bpm`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Heart rate (sleep)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.hr.sleeping,` bpm`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Respiratory rate`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.rr,` /min`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`SpO₂`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:n.spo2})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`SBP`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.sbp,` mmHg`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`DBP`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.dbp,` mmHg`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Temperature`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[n.temp,` °C`]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Weight`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:n.weight})]})]}),(0,L.jsxs)(`div`,{className:`rounded-md bg-blue-50 dark:bg-blue-950/30 p-3 text-xs`,children:[(0,L.jsx)(`div`,{className:`font-semibold mb-1`,children:`Clinical notes`}),(0,L.jsx)(`ul`,{className:`list-disc pl-5 space-y-0.5`,children:n.notes.map((e,t)=>(0,L.jsx)(`li`,{children:e},t))})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook 23rd ed · PALS · AAP 2017 BP guidelines.`})]})}var Te=[{name:`Adenosine`,indication:`SVT`,category:`cardiac`,route:`IV/IO rapid bolus`,calc:e=>{let t=+(e*.1).toFixed(2),n=+(e*.2).toFixed(2),r=+(e*.3).toFixed(2);return{dose:`${t} mg (0.1 mg/kg)`,extra:`May repeat: ${Math.min(n,12)} mg (0.2 mg/kg), then ${Math.min(r,12)} mg (0.3 mg/kg)`,max:`Max first dose 6 mg, max subsequent 12 mg`}}},{name:`Amiodarone`,indication:`VT / VF`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*5).toFixed(1);return{dose:`${Math.min(t,300)} mg (5 mg/kg)`,extra:`No pulse: push undiluted. Pulse: over 20-60 min. Subsequent max 150 mg.`,max:`Max first 300 mg, max total 15 mg/kg/24hr or 2200 mg`}}},{name:`Atropine`,indication:`Bradycardia`,category:`cardiac`,route:`IV/IO/IM`,calc:e=>{let t=+(e*.02).toFixed(3),n=`${(e*.04).toFixed(3)}-${(e*.06).toFixed(3)}`;return{dose:`${Math.min(t,.5)} mg (0.02 mg/kg)`,extra:`ETT dose: ${n} mg (0.04-0.06 mg/kg)`,max:`Max single 0.5 mg, max total 1 mg`}}},{name:`Calcium Chloride 10%`,indication:`Hypocalcemia / Hyperkalemia`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*20).toFixed(0);return{dose:`${Math.min(t,1e3)} mg (20 mg/kg)`,extra:`Give slowly. Central line preferred.`,max:`Max 1 g (1000 mg)`}}},{name:`Calcium Gluconate 10%`,indication:`Hypocalcemia / Hyperkalemia`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*60).toFixed(0);return{dose:`${Math.min(t,3e3)} mg (60 mg/kg)`,extra:`Give slowly over 10-20 min with cardiac monitoring.`,max:`Max 3 g (3000 mg)`}}},{name:`Dextrose`,indication:`Hypoglycemia`,category:`metabolic`,route:`IV`,calc:e=>{let t=`${+(e*.5).toFixed(1)}-${+(e*1).toFixed(1)}`,n=``;return n=e<5?`D10W: ${(e*5).toFixed(1)}-${(e*10).toFixed(1)} mL (5-10 mL/kg)`:e<45?`D25W: ${(e*2).toFixed(1)}-${(e*4).toFixed(1)} mL (2-4 mL/kg)`:`D50W: ${(e*1).toFixed(1)}-${(e*2).toFixed(1)} mL (1-2 mL/kg)`,{dose:`${t} g (0.5-1 g/kg)`,extra:n,max:`Max 25 g`}}},{name:`Epinephrine`,indication:`Pulseless arrest / Anaphylaxis`,category:`cardiac`,route:`IV/IO/IM/ETT`,calc:e=>{let t=+(e*.01).toFixed(3),n=+(e*.1).toFixed(2),r=+(e*.1).toFixed(2),i=+(e*.01).toFixed(3);return{dose:`${Math.min(t,1)} mg IV/IO (0.01 mg/kg of 0.1 mg/mL = ${Math.min(n,10)} mL) q3-5 min`,extra:`ETT: ${Math.min(r,2.5)} mg (0.1 mg/kg of 1 mg/mL). Anaphylaxis IM: ${Math.min(i,.5)} mg (0.01 mg/kg)`,max:`Max IV 1 mg, max ETT 2.5 mg, max IM 0.5 mg`}}},{name:`Hydrocortisone`,indication:`Adrenal crisis`,category:`metabolic`,route:`IV/IM/IO`,calc:e=>{let t=+(e*2).toFixed(1);return{dose:`${Math.min(t,100)} mg (2 mg/kg)`,extra:`Stress dosing for adrenal insufficiency.`,max:`Max 100 mg`}}},{name:`Insulin (Regular)`,indication:`Hyperkalemia`,category:`metabolic`,route:`IV`,calc:e=>{let t=+(e*.1).toFixed(2),n=+(e*.5).toFixed(1);return{dose:`${Math.min(t,5)} units (0.1 units/kg)`,extra:`Give with ${n} g/kg dextrose (0.5 g/kg). Monitor glucose closely.`,max:`Max 5 units`}}},{name:`Lidocaine`,indication:`Antiarrhythmic`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*1).toFixed(1),n=`${(e*2).toFixed(1)}-${(e*3).toFixed(1)}`;return{dose:`${Math.min(t,100)} mg (1 mg/kg)`,extra:`ETT: ${n} mg (2-3 mg/kg). May repeat q5 min.`,max:`Max 100 mg/dose, max total 3 mg/kg`}}},{name:`Magnesium Sulfate`,indication:`Torsades de Pointes`,category:`cardiac`,route:`IV/IO`,calc:e=>{let t=+(e*50).toFixed(0);return{dose:`${Math.min(t,2e3)} mg (50 mg/kg)`,extra:`Give over 10-20 min (faster if pulseless).`,max:`Max 2 g (2000 mg)`}}},{name:`Naloxone`,indication:`Opioid overdose`,category:`reversal`,route:`IV/IO/IM/IN/ETT`,calc:e=>{let t=`${+(e*.001).toFixed(4)}-${+(e*.005).toFixed(4)}`,n=+(e*.1).toFixed(3);return{dose:`Partial: ${t} mg (0.001-0.005 mg/kg)`,extra:`Full reversal: ${Math.min(n,2)} mg (0.1 mg/kg)`,max:`Max partial first dose 0.1 mg, max full 2 mg`}}},{name:`Sodium Bicarbonate`,indication:`Metabolic acidosis`,category:`metabolic`,route:`IV/IO`,calc:e=>{let t=+(e*1).toFixed(1);return{dose:`${Math.min(t,50)} mEq (1 mEq/kg)`,extra:e<10?`Dilute to 0.5 mEq/mL (use 4.2% solution) for neonates/small infants.`:`Use 8.4% solution (1 mEq/mL).`,max:`Max 50 mEq`}}}],H={cardiac:`#ef4444`,metabolic:`#3b82f6`,reversal:`#10b981`},Ee={cardiac:`Cardiac`,metabolic:`Metabolic`,reversal:`Reversal`};function De(){let[e,t]=(0,l.useState)(``),n=Number.parseFloat(e);return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-resus`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Resus Medications`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Weight (kg)`}),(0,L.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.1`,className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`resus-weight`})]}),Number.isFinite(n)&&n>0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`text-sm font-semibold`,children:[`Doses for `,n,` kg patient`]}),(0,L.jsx)(`div`,{className:`flex gap-3 flex-wrap text-xs`,children:[`cardiac`,`metabolic`,`reversal`].map(e=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full`,style:{background:H[e]}}),Ee[e]]},e))}),(0,L.jsx)(`div`,{className:`grid gap-3 grid-cols-1 md:grid-cols-2 lg:grid-cols-3`,"data-testid":`resus-result`,children:Te.map(e=>{let t=e.calc(n),r=H[e.category];return(0,L.jsxs)(`div`,{className:`rounded-lg border bg-card overflow-hidden`,style:{borderColor:r+`55`},children:[(0,L.jsxs)(`div`,{className:`px-3 py-2 border-b`,style:{background:r+`10`,borderColor:r+`22`},children:[(0,L.jsx)(`div`,{className:`text-sm font-bold`,style:{color:r},children:e.name}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.indication})]}),(0,L.jsxs)(`div`,{className:`p-3 text-sm space-y-1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`strong`,{children:`Dose:`}),` `,t.dose]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.extra}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`strong`,{children:`Max:`}),` `,t.max]}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(`strong`,{children:`Route:`}),` `,e.route]})]})]},e.name)})}),(0,L.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,L.jsx)(`strong`,{children:`Disclaimer:`}),` Always verify doses against institutional protocols and current guidelines.`]})]}):(0,L.jsx)(`p`,{className:`text-xs text-destructive`,children:`Enter weight (kg) to see doses.`})]})}var Oe={premie:{label:`Premie (1-3 kg)`,bvm:`Infant`,nasal:`12 Fr`,oral:`Infant`,blade:`Miller 0`,ett:`2.5-3.0`,lma:`1`,glidescope:`1`,iv:`22-24 ga`,cvl:`3 Fr`,ngt:`5 Fr`,chest:`10-12 Fr`,foley:`6 Fr`},newborn:{label:`Newborn (2-4 kg)`,bvm:`Infant`,nasal:`14-16 Fr`,oral:`Small 50 mm`,blade:`Miller 0`,ett:`3.0-3.5`,lma:`1`,glidescope:`1`,iv:`22-24 ga`,cvl:`3-4 Fr`,ngt:`5-8 Fr`,chest:`10-12 Fr`,foley:`6 Fr`},"6mo":{label:`6 months (6-8 kg)`,bvm:`Infant`,nasal:`14-16 Fr`,oral:`Small 60 mm`,blade:`Miller 1`,ett:`3.5`,lma:`1.5`,glidescope:`2`,iv:`20-24 ga`,cvl:`4 Fr`,ngt:`8 Fr`,chest:`12-18 Fr`,foley:`8 Fr`},"1yr":{label:`1 year (10 kg)`,bvm:`Small child`,nasal:`14-18 Fr`,oral:`Small 60 mm`,blade:`Miller 1 / MAC 2`,ett:`4.0`,lma:`2`,glidescope:`2`,iv:`20-24 ga`,cvl:`4-5 Fr`,ngt:`10 Fr`,chest:`16-20 Fr`,foley:`8 Fr`},"2-3yr":{label:`2-3 years (12-16 kg)`,bvm:`Small child`,nasal:`14-18 Fr`,oral:`Small 70 mm`,blade:`Miller 1 / MAC 2`,ett:`4.0-4.5`,lma:`2`,glidescope:`2`,iv:`18-22 ga`,cvl:`4-5 Fr`,ngt:`10-12 Fr`,chest:`16-24 Fr`,foley:`8 Fr`},"4-6yr":{label:`4-6 years (20-25 kg)`,bvm:`Child`,nasal:`16-20 Fr`,oral:`Small 70-80 mm`,blade:`Miller 2 / MAC 2`,ett:`4.5-5.0`,lma:`2.5`,glidescope:`3`,iv:`18-22 ga`,cvl:`5 Fr`,ngt:`12-14 Fr`,chest:`20-28 Fr`,foley:`8 Fr`},"7-10yr":{label:`7-10 years (25-35 kg)`,bvm:`Child / Small adult`,nasal:`18-22 Fr`,oral:`Medium 80-90 mm`,blade:`Miller 2 / MAC 2`,ett:`5.5-6.0`,lma:`2.5-3`,glidescope:`3`,iv:`18-22 ga`,cvl:`5 Fr`,ngt:`12-14 Fr`,chest:`20-32 Fr`,foley:`8 Fr`},"11-15yr":{label:`11-15 years (40-50 kg)`,bvm:`Adult`,nasal:`22-36 Fr`,oral:`Medium 90 mm`,blade:`Miller 2 / MAC 3`,ett:`6.0-6.5`,lma:`3`,glidescope:`3 or 4`,iv:`18-20 ga`,cvl:`7 Fr`,ngt:`14-18 Fr`,chest:`28-38 Fr`,foley:`10 Fr`},"16yr":{label:`16+ years (>50 kg)`,bvm:`Adult`,nasal:`22-36 Fr`,oral:`Medium 90 mm`,blade:`Miller 2 / MAC 3`,ett:`7.0-8.0`,lma:`4`,glidescope:`3 or 4`,iv:`18-20 ga`,cvl:`7 Fr`,ngt:`14-18 Fr`,chest:`28-42 Fr`,foley:`12 Fr`}},ke=[`premie`,`newborn`,`6mo`,`1yr`,`2-3yr`,`4-6yr`,`7-10yr`,`11-15yr`,`16yr`];function Ae(){let[e,t]=(0,l.useState)(`1yr`),n=Oe[e],r=[[`BVM`,n.bvm],[`Nasopharyngeal`,n.nasal],[`Oropharyngeal`,n.oral],[`Laryngoscope`,n.blade],[`ETT`,n.ett],[`LMA`,n.lma],[`Glidescope`,n.glidescope],[`IV`,n.iv],[`Central line`,n.cvl],[`NG tube`,n.ngt],[`Chest tube`,n.chest],[`Foley`,n.foley]];return(0,L.jsxs)(`section`,{className:R,"data-testid":`calc-panel-equipment`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Equipment Sizing`}),(0,L.jsxs)(`div`,{className:`max-w-xs`,children:[(0,L.jsx)(`label`,{className:B,children:`Age / weight band`}),(0,L.jsx)(`select`,{className:z,value:e,onChange:e=>t(e.target.value),"data-testid":`equip-age-select`,children:ke.map(e=>(0,L.jsx)(`option`,{value:e,children:Oe[e].label},e))})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3 text-sm`,"data-testid":`equip-result`,children:r.map(([e,t])=>(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/40 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:e}),(0,L.jsx)(`div`,{className:`font-semibold`,children:t})]},e))}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Harriet Lane Handbook · PALS · Broselow cross-reference.`})]})}var U=`rounded-lg border border-border bg-card p-5 space-y-3`,W=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium`,G=`rounded-md border border-border bg-background px-4 py-2 text-sm font-medium hover:bg-muted`,K=`space-y-1`,q=`block text-xs font-medium text-muted-foreground`,J=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,Y=`rounded-lg border border-border bg-muted/40 p-4`,X=`rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/30 dark:text-red-200`,Z=[{id:`bp`,label:`BP Percentile`,summary:`AAP 2017 age/height/sex-adjusted BP percentiles (Rosner quantile splines).`,source:`AAP 2017 (Flynn) — Rosner splines`,ported:!0},{id:`bmi`,label:`BMI Percentile`,summary:`BMI-for-age (CDC 2000 z-score tables).`,source:`CDC 2000 LMS`,ported:!0},{id:`growth`,label:`Growth Charts`,summary:`Fenton 2013 preterm weight-for-GA with Z-score + percentile + SGA/AGA/LGA classification.`,source:`Fenton 2013 LMS`,ported:!0},{id:`bili`,label:`Bilirubin`,summary:`AAP 2022 phototherapy + exchange thresholds and Bhutani nomogram risk zones.`,source:`AAP 2022 (Kemper) + Bhutani 1999`,ported:!0},{id:`vitals`,label:`Vital Signs`,summary:`Normal HR / RR / BP ranges by age.`,source:`Harriet Lane + PALS + AHA`,ported:!0},{id:`bsa`,label:`Body Surface Area`,summary:`Mosteller body surface area formula.`,source:`Mosteller 1987`,ported:!0},{id:`dose`,label:`Weight-Based Dosing`,summary:`Generic mg/kg dosing with optional max-dose cap and concentration conversion.`,source:`Legacy calculator formula`,ported:!0},{id:`resus`,label:`Resus Meds`,summary:`Code-cart dosing (epinephrine, amiodarone, atropine, etc.).`,source:`PALS`,ported:!0},{id:`gcs`,label:`GCS`,summary:`Child/adult and infant Glasgow Coma Scale variants.`,source:`Teasdale + pediatric modification`,ported:!0},{id:`equipment`,label:`Equipment`,summary:`ETT size, blade, NG, Foley, suction by age/weight.`,source:`PALS + Broselow cross-reference`,ported:!0}];function je(e){if(!e.trim())return null;let t=Number(e);return Number.isFinite(t)?t:null}function Q({id:e,labelText:t,value:n,onChange:r,min:i,max:a,step:o=`0.1`,placeholder:s}){return(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:e,className:q,children:t}),(0,L.jsx)(`input`,{id:e,type:`number`,min:i,max:a,step:o,value:n,onChange:e=>r(e.target.value),placeholder:s,className:J})]})}function Me(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``);function u(){let t=a(Number(e),Number(n));if(t==null){c(`Enter a valid weight and height.`),o(null);return}c(``),o(t)}function d(){t(``),r(``),o(null),c(``)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-bsa`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Body Surface Area`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Mosteller formula: BSA (m2) = sqrt(height(cm) x weight(kg) / 3600).`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,L.jsx)(Q,{id:`react-bsa-weight`,labelText:`Weight (kg)`,value:e,onChange:t,min:`1`,max:`200`,placeholder:`20`}),(0,L.jsx)(Q,{id:`react-bsa-height`,labelText:`Height (cm)`,value:n,onChange:r,min:`30`,max:`220`,placeholder:`110`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:u,className:W,"data-testid":`calc-bsa-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:d,className:G,children:`Clear`})]}),s?(0,L.jsx)(`div`,{className:X,children:s}):null,i==null?null:(0,L.jsxs)(`div`,{className:Y,"data-testid":`calc-bsa-result`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Mosteller BSA`}),(0,L.jsxs)(`div`,{className:`text-2xl font-semibold`,children:[i.toFixed(3),` m²`]}),(0,L.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[e,` kg, `,n,` cm`]})]})]})}function Ne(){let[e,t]=(0,l.useState)(``),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(`1`),[o,c]=(0,l.useState)(``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(null),[m,h]=(0,l.useState)(``);function g(){let t=s({weightKg:Number(e),dosePerKg:Number(n),frequencyPerDay:Number(i),maxSingleDoseMg:je(o),concentrationMgPerMl:je(u)});if(t==null){h(`Enter a valid weight, mg/kg dose, and frequency.`),p(null);return}h(``),p(t)}function _(){t(``),r(``),a(`1`),c(``),d(``),p(null),h(``)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-dose`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Weight-Based Dosing`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Generic mg/kg calculator. Always verify medication-specific dosing against formulary and local policy.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsx)(Q,{id:`react-dose-weight`,labelText:`Patient Weight (kg)`,value:e,onChange:t,min:`1`,max:`200`,placeholder:`15`}),(0,L.jsx)(Q,{id:`react-dose-per-kg`,labelText:`Dose (mg/kg)`,value:n,onChange:r,min:`0.01`,step:`0.01`,placeholder:`10`}),(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`react-dose-frequency`,className:q,children:`Frequency`}),(0,L.jsxs)(`select`,{id:`react-dose-frequency`,value:i,onChange:e=>a(e.target.value),className:J,children:[(0,L.jsx)(`option`,{value:`1`,children:`Once daily`}),(0,L.jsx)(`option`,{value:`2`,children:`Twice daily (BID)`}),(0,L.jsx)(`option`,{value:`3`,children:`Three times daily (TID)`}),(0,L.jsx)(`option`,{value:`4`,children:`Four times daily (QID)`}),(0,L.jsx)(`option`,{value:`6`,children:`Every 4 hours (Q4H)`})]})]}),(0,L.jsx)(Q,{id:`react-dose-max`,labelText:`Max single dose (mg, optional)`,value:o,onChange:c,min:`0`,step:`1`,placeholder:`500`}),(0,L.jsx)(Q,{id:`react-dose-concentration`,labelText:`Concentration (mg/mL, optional)`,value:u,onChange:d,min:`0`,placeholder:`40`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:g,className:W,"data-testid":`calc-dose-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,onClick:_,className:G,children:`Clear`})]}),m?(0,L.jsx)(`div`,{className:X,children:m}):null,f==null?null:(0,L.jsx)(`div`,{className:Y,"data-testid":`calc-dose-result`,children:(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Single Dose`}),(0,L.jsxs)(`div`,{className:`text-xl font-semibold`,children:[f.singleDoseMg.toFixed(1),` mg`]}),f.capped?(0,L.jsx)(`div`,{className:`text-xs text-red-600`,children:`Capped at max dose`}):null]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Daily Total`}),(0,L.jsxs)(`div`,{className:`text-xl font-semibold`,children:[f.dailyDoseMg.toFixed(1),` mg/day`]}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`x `,f.frequencyPerDay,`/day`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Volume`}),(0,L.jsx)(`div`,{className:`text-xl font-semibold`,children:f.volumeMl==null?`n/a`:`${f.volumeMl.toFixed(1)} mL`}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`per dose`})]})]})})]})}var Pe={child:{eye:[[`4`,`4 - Spontaneous`],[`3`,`3 - To speech`],[`2`,`2 - To pain`],[`1`,`1 - None`]],verbal:[[`5`,`5 - Oriented`],[`4`,`4 - Confused`],[`3`,`3 - Inappropriate words`],[`2`,`2 - Incomprehensible sounds`],[`1`,`1 - None`]],motor:[[`6`,`6 - Obeys commands`],[`5`,`5 - Localizes pain`],[`4`,`4 - Withdraws to pain`],[`3`,`3 - Abnormal flexion`],[`2`,`2 - Abnormal extension`],[`1`,`1 - None`]]},infant:{eye:[[`4`,`4 - Spontaneous`],[`3`,`3 - To speech/sound`],[`2`,`2 - To painful stimuli`],[`1`,`1 - None`]],verbal:[[`5`,`5 - Coos/babbles`],[`4`,`4 - Irritable cry`],[`3`,`3 - Cries to pain`],[`2`,`2 - Moans to pain`],[`1`,`1 - None`]],motor:[[`6`,`6 - Normal spontaneous movement`],[`5`,`5 - Withdraws to touch`],[`4`,`4 - Withdraws to pain`],[`3`,`3 - Abnormal flexion`],[`2`,`2 - Abnormal extension`],[`1`,`1 - None`]]}};function $({id:e,labelText:t,value:n,options:r,onChange:i}){return(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:e,className:q,children:t}),(0,L.jsx)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),className:J,children:r.map(([e,t])=>(0,L.jsx)(`option`,{value:e,children:t},e))})]})}function Fe(){let[e,t]=(0,l.useState)(`child`),[n,i]=(0,l.useState)(`4`),[a,o]=(0,l.useState)(`5`),[s,c]=(0,l.useState)(`6`),u=r(Number(n),Number(a),Number(s)),d=Pe[e];function f(e){t(e),i(`4`),o(`5`),c(`6`)}return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-gcs`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Glasgow Coma Scale`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select responses to calculate child/adult or infant-modified GCS. Total score 3-15.`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(`child`),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(e===`child`?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),children:`Child / Adult`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(`infant`),className:`px-3 py-1.5 rounded-full text-xs font-medium border `+(e===`infant`?`bg-primary text-primary-foreground border-primary`:`bg-muted border-border`),children:`Infant`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsx)($,{id:`react-gcs-eye`,labelText:`Eye Opening`,value:n,options:d.eye,onChange:i}),(0,L.jsx)($,{id:`react-gcs-verbal`,labelText:`Verbal Response`,value:a,options:d.verbal,onChange:o}),(0,L.jsx)($,{id:`react-gcs-motor`,labelText:`Motor Response`,value:s,options:d.motor,onChange:c})]}),u==null?null:(0,L.jsxs)(`div`,{className:Y,"data-testid":`calc-gcs-result`,children:[(0,L.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:e===`infant`?`Infant-modified GCS`:`Child / adult GCS`}),(0,L.jsxs)(`div`,{className:`text-3xl font-semibold`,children:[`GCS: `,u.total,`/15`]}),(0,L.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:u.severity}),(0,L.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:`Interpretation: 13-15 Mild, 9-12 Moderate, 3-8 Severe/Coma.`})]})]})}function Ie({pill:e}){return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-`+e.id,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.label}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.summary}),(0,L.jsxs)(`div`,{className:`rounded-md border border-amber-300 bg-amber-50 dark:bg-amber-950/30 p-3 text-sm space-y-2`,children:[(0,L.jsxs)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:[(0,L.jsx)(`strong`,{children:`Source of truth:`}),` `,e.source,`.`]}),(0,L.jsx)(`p`,{className:`text-amber-900 dark:text-amber-100`,children:`This calculator runs in the legacy viewer. A React port is gated on capturing test vectors from the vanilla implementation so the numerical output can be verified byte-for-byte — the migration checkpoint specifically flags this class of data as the one an LLM is most likely to silently simplify.`})]}),(0,L.jsx)(`a`,{href:`/#calculators`,className:W+` inline-block`,children:`Open in legacy viewer`})]})}function Le(){let[e,t]=(0,l.useState)(`aap`),[n,r]=(0,l.useState)(`38`),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(`low`),[d,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(null),[h,g]=(0,l.useState)(``);function _(){let t=Number(i),r=Number(o);if(!Number.isFinite(t)||!Number.isFinite(r)||t<=0||r<=0){g(`Enter hours of life and TSB (mg/dL).`),f(null),m(null);return}if(g(``),e===`aap`){let e=Number(n);if(!Number.isFinite(e)||e<35){g(`AAP 2022 thresholds apply to GA ≥35 weeks.`),f(null);return}f(D(e,t,r,c)),m(null)}else m(re(t,r)),f(null)}let v=d?d.status===`Above Exchange`?`text-red-800 bg-red-100`:d.status===`Above Phototherapy`?`text-red-700 bg-red-50`:`text-green-700 bg-green-50`:``,y=p?p.zone===`High-Risk`?`text-red-800 bg-red-100`:p.zone===`High-Intermediate`?`text-orange-700 bg-orange-50`:p.zone===`Low-Intermediate`?`text-amber-700 bg-amber-50`:`text-green-700 bg-green-50`:``;return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-bili`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Bilirubin`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(`aap`),className:`px-3 py-1 rounded text-xs font-medium `+(e===`aap`?`bg-primary text-primary-foreground`:`bg-muted`),"data-testid":`bili-mode-aap`,children:`AAP 2022 Phototherapy`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(`bhutani`),className:`px-3 py-1 rounded text-xs font-medium `+(e===`bhutani`?`bg-primary text-primary-foreground`:`bg-muted`),"data-testid":`bili-mode-bhutani`,children:`Bhutani Nomogram`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e===`aap`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`bili-ga`,className:q,children:`GA (weeks)`}),(0,L.jsx)(`select`,{id:`bili-ga`,className:J,value:n,onChange:e=>r(e.target.value),children:[35,36,37,38,39,40].map(e=>(0,L.jsxs)(`option`,{value:e,children:[e,e===40?`+`:``]},e))})]}),(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`bili-risk`,className:q,children:`Neurotoxicity risk`}),(0,L.jsxs)(`select`,{id:`bili-risk`,className:J,value:c,onChange:e=>u(e.target.value),children:[(0,L.jsx)(`option`,{value:`low`,children:`No risk factors`}),(0,L.jsx)(`option`,{value:`medium`,children:`With risk factors`})]})]})]}),(0,L.jsx)(Q,{id:`bili-hours`,labelText:`Age (hours)`,value:i,onChange:a,min:`0`,max:`336`,placeholder:`48`}),(0,L.jsx)(Q,{id:`bili-tsb`,labelText:`TSB (mg/dL)`,value:o,onChange:s,min:`0`,max:`50`,placeholder:`15`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:W,onClick:_,"data-testid":`calc-bili-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,className:G,onClick:()=>{a(``),s(``),f(null),m(null),g(``)},children:`Clear`})]}),h&&(0,L.jsx)(`div`,{className:X,children:h}),d&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-bili-aap-result`,children:[(0,L.jsx)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+v,children:d.status}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`TSB `,o,` mg/dL at `,i,` hours of life (GA `,n,`w `,c===`medium`?`with`:`without`,` risk factors)`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Phototherapy`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[d.photoThreshold.toFixed(1),` mg/dL`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Exchange`}),(0,L.jsxs)(`div`,{className:`font-semibold text-red-800`,children:[d.exchangeThreshold.toFixed(1),` mg/dL`]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`AAP 2022 CPG (Kemper et al.). Always use clinical judgment.`})]}),p&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-bili-bhutani-result`,children:[(0,L.jsxs)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+y,children:[p.zone,` Zone`]}),(0,L.jsxs)(`div`,{className:`text-sm`,children:[`TSB `,o,` mg/dL at `,i,` hours of life`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`40th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p40.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`75th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p75.toFixed(1)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`95th %ile`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:p.p95.toFixed(1)})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Bhutani 1999 hour-specific risk nomogram for infants ≥35 weeks GA.`})]})]})}function Re(){let[e,t]=(0,l.useState)(`male`),[n,r]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,u]=(0,l.useState)(null),[d,f]=(0,l.useState)(``);function p(){let t=Number(n),r=Number(a);if(!Number.isFinite(t)||!Number.isFinite(r)||t<22||t>50||r<=0){f(`Enter GA (22-50 weeks) and weight (grams).`),u(null);return}f(``),u(i(t,r,e))}let m=s?c(s.percentile):null,h=m===`SGA`?`text-orange-700 bg-orange-50`:m===`LGA`?`text-amber-700 bg-amber-50`:`text-green-700 bg-green-50`;return(0,L.jsxs)(`section`,{className:U,"data-testid":`calc-panel-growth`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Fenton 2013 Preterm Growth`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Weight-for-gestational-age Z-score + percentile + SGA/AGA/LGA classification.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:K,children:[(0,L.jsx)(`label`,{htmlFor:`fenton-sex`,className:q,children:`Sex`}),(0,L.jsxs)(`select`,{id:`fenton-sex`,className:J,value:e,onChange:e=>t(e.target.value),children:[(0,L.jsx)(`option`,{value:`male`,children:`Male`}),(0,L.jsx)(`option`,{value:`female`,children:`Female`})]})]}),(0,L.jsx)(Q,{id:`fenton-ga`,labelText:`GA (weeks)`,value:n,onChange:r,min:`22`,max:`50`,step:`0.1`,placeholder:`32`}),(0,L.jsx)(Q,{id:`fenton-weight`,labelText:`Weight (g)`,value:a,onChange:o,min:`200`,max:`7000`,step:`10`,placeholder:`1500`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:W,onClick:p,"data-testid":`calc-fenton-calculate`,children:`Calculate`}),(0,L.jsx)(`button`,{type:`button`,className:G,onClick:()=>{r(``),o(``),u(null),f(``)},children:`Clear`})]}),d&&(0,L.jsx)(`div`,{className:X,children:d}),s&&m&&(0,L.jsxs)(`div`,{className:Y+` space-y-2`,"data-testid":`calc-fenton-result`,children:[(0,L.jsx)(`div`,{className:`inline-block px-2 py-1 rounded text-sm font-bold `+h,children:m}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Percentile`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[s.percentile.toFixed(1),`%`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Z-score`}),(0,L.jsx)(`div`,{className:`font-semibold`,children:s.z.toFixed(2)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`Median (M)`}),(0,L.jsxs)(`div`,{className:`font-semibold`,children:[Math.round(s.M),` g`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-xs uppercase text-muted-foreground`,children:`L / S`}),(0,L.jsxs)(`div`,{className:`font-mono text-xs`,children:[s.L.toFixed(3),` / `,s.S.toFixed(3)]})]})]}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Fenton TR, Kim JH. Systematic review — revised Fenton growth chart for preterm infants. BMC Pediatr 2013;13:59.`})]})]})}function ze({pill:e}){return e.id===`bsa`?(0,L.jsx)(Me,{}):e.id===`dose`?(0,L.jsx)(Ne,{}):e.id===`gcs`?(0,L.jsx)(Fe,{}):e.id===`bili`?(0,L.jsx)(Le,{}):e.id===`growth`?(0,L.jsx)(Re,{}):e.id===`bmi`?(0,L.jsx)(xe,{}):e.id===`vitals`?(0,L.jsx)(we,{}):e.id===`resus`?(0,L.jsx)(De,{}):e.id===`equipment`?(0,L.jsx)(Ae,{}):e.id===`bp`?(0,L.jsx)(be,{}):(0,L.jsx)(Ie,{pill:e})}function Be(){let[e,t]=(0,l.useState)(Z[0].id),n=Z.find(t=>t.id===e)??Z[0];return(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-4`,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Calculators`}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric calculators — BP percentiles, bilirubin thresholds, growth, dosing, equipment sizing. Simple pure-formula calculators run in React now; high-risk table-driven calculators remain legacy-gated until vectors are captured.`})]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`calc-subnav`,children:Z.map(n=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(e===n.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`calc-pill-`+n.id,children:[n.label,n.ported?(0,L.jsx)(`span`,{className:`ml-1 text-[10px] opacity-80`,children:`React`}):null]},n.id))}),(0,L.jsx)(ze,{pill:n})]})}export{Be as default}; \ No newline at end of file diff --git a/public/app/assets/Catchup--869idMv.js b/public/app/assets/Catchup-DCX8L2yV.js similarity index 97% rename from public/app/assets/Catchup--869idMv.js rename to public/app/assets/Catchup-DCX8L2yV.js index 0f14eb0..3b76375 100644 --- a/public/app/assets/Catchup--869idMv.js +++ b/public/app/assets/Catchup-DCX8L2yV.js @@ -1 +1 @@ -import{t as e}from"./jsx-runtime-ByY1xr43.js";import{i as t,l as n}from"./index-BuU36CvS.js";var r=e();function i(){let{data:e,isLoading:i,error:a}=n({queryKey:[`schedule-data`],queryFn:()=>t.get(`/api/schedule-data`)});return i?(0,r.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):a?(0,r.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:a.message}):e?(0,r.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,r.jsxs)(`header`,{children:[(0,r.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Catch-Up Schedule`}),(0,r.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`CDC 2025 catch-up immunization schedule — minimum ages and intervals per vaccine.`})]}),Object.entries(e.catchUpSchedule).map(([t,n])=>{let i=e.vaccineFullNames[t]||t,a=n.catchUpNotes?Array.isArray(n.catchUpNotes)?n.catchUpNotes:[n.catchUpNotes]:[];return(0,r.jsxs)(`section`,{className:`rounded-lg border border-border bg-card overflow-hidden`,children:[(0,r.jsxs)(`header`,{className:`px-4 py-2 border-b border-border bg-muted/40 flex items-center justify-between`,children:[(0,r.jsx)(`h2`,{className:`text-sm font-semibold`,children:i}),n.minimumAgeForDose1&&(0,r.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Min age dose 1: `,(0,r.jsx)(`strong`,{children:n.minimumAgeForDose1})]})]}),n.series&&n.series.length>0&&(0,r.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,r.jsx)(`thead`,{className:`bg-muted/20`,children:(0,r.jsxs)(`tr`,{children:[(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Dose`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Min age`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Min interval from prev`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Notes`})]})}),(0,r.jsx)(`tbody`,{children:n.series.map(e=>(0,r.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,r.jsxs)(`td`,{className:`px-3 py-2 font-semibold`,children:[`Dose `,e.dose]}),(0,r.jsx)(`td`,{className:`px-3 py-2`,children:e.minimumAge||`—`}),(0,r.jsx)(`td`,{className:`px-3 py-2`,children:e.minimumIntervalToPrev||`—`}),(0,r.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.notes||``})]},String(e.dose)))})]}),a.length>0&&(0,r.jsx)(`ul`,{className:`list-disc pl-8 py-2 text-xs text-muted-foreground space-y-1`,children:a.map((e,t)=>(0,r.jsx)(`li`,{children:e},t))})]},t)})]}):null}export{i as default}; \ No newline at end of file +import{t as e}from"./jsx-runtime-ByY1xr43.js";import{i as t,l as n}from"./index-C9wKWOAN.js";var r=e();function i(){let{data:e,isLoading:i,error:a}=n({queryKey:[`schedule-data`],queryFn:()=>t.get(`/api/schedule-data`)});return i?(0,r.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading…`}):a?(0,r.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:a.message}):e?(0,r.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,r.jsxs)(`header`,{children:[(0,r.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Catch-Up Schedule`}),(0,r.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`CDC 2025 catch-up immunization schedule — minimum ages and intervals per vaccine.`})]}),Object.entries(e.catchUpSchedule).map(([t,n])=>{let i=e.vaccineFullNames[t]||t,a=n.catchUpNotes?Array.isArray(n.catchUpNotes)?n.catchUpNotes:[n.catchUpNotes]:[];return(0,r.jsxs)(`section`,{className:`rounded-lg border border-border bg-card overflow-hidden`,children:[(0,r.jsxs)(`header`,{className:`px-4 py-2 border-b border-border bg-muted/40 flex items-center justify-between`,children:[(0,r.jsx)(`h2`,{className:`text-sm font-semibold`,children:i}),n.minimumAgeForDose1&&(0,r.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Min age dose 1: `,(0,r.jsx)(`strong`,{children:n.minimumAgeForDose1})]})]}),n.series&&n.series.length>0&&(0,r.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,r.jsx)(`thead`,{className:`bg-muted/20`,children:(0,r.jsxs)(`tr`,{children:[(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Dose`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Min age`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Min interval from prev`}),(0,r.jsx)(`th`,{className:`text-left px-3 py-2`,children:`Notes`})]})}),(0,r.jsx)(`tbody`,{children:n.series.map(e=>(0,r.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,r.jsxs)(`td`,{className:`px-3 py-2 font-semibold`,children:[`Dose `,e.dose]}),(0,r.jsx)(`td`,{className:`px-3 py-2`,children:e.minimumAge||`—`}),(0,r.jsx)(`td`,{className:`px-3 py-2`,children:e.minimumIntervalToPrev||`—`}),(0,r.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e.notes||``})]},String(e.dose)))})]}),a.length>0&&(0,r.jsx)(`ul`,{className:`list-disc pl-8 py-2 text-xs text-muted-foreground space-y-1`,children:a.map((e,t)=>(0,r.jsx)(`li`,{children:e},t))})]},t)})]}):null}export{i as default}; \ No newline at end of file diff --git a/public/app/assets/ChartReview-95oCueTc.js b/public/app/assets/ChartReview-95oCueTc.js deleted file mode 100644 index 2e6f69a..0000000 --- a/public/app/assets/ChartReview-95oCueTc.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-BuU36CvS.js";var a=e(t(),1),o=n();function s(){return{date:``,content:``,labs:``}}function c(){let[e,t]=(0,a.useState)(`outpatient`),[n,c]=(0,a.useState)(``),[l,u]=(0,a.useState)(``),[d,f]=(0,a.useState)(``),[p,m]=(0,a.useState)([s()]),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(null),y=r({mutationFn:e=>i.post(`/api/generate-chart-review`,e),onSuccess:e=>v(e.review)});function b(e,t){m(n=>n.map((n,r)=>r===e?{...n,...t}:n))}function x(t){t.preventDefault(),v(null);let r=p.filter(e=>e.content.trim());y.mutate({type:e,patientAge:n,patientGender:l,pmh:d,visits:e===`outpatient`?r:void 0,subspecialty:e===`subspecialty`?r:void 0,edVisits:e===`ed`?r:void 0,additionalInstructions:h||void 0})}let S=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,o.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,o.jsxs)(`header`,{children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Chart Review`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Past visits → summary for pre-charting.`})]}),(0,o.jsxs)(`form`,{onSubmit:x,className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Review type`}),(0,o.jsxs)(`select`,{className:S,value:e,onChange:e=>t(e.target.value),children:[(0,o.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,o.jsx)(`option`,{value:`subspecialty`,children:`Subspecialty`}),(0,o.jsx)(`option`,{value:`ed`,children:`ED`})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,o.jsx)(`input`,{className:S,value:n,onChange:e=>c(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,o.jsxs)(`select`,{className:S,value:l,onChange:e=>u(e.target.value),children:[(0,o.jsx)(`option`,{value:``,children:`Select`}),(0,o.jsx)(`option`,{children:`Male`}),(0,o.jsx)(`option`,{children:`Female`})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`PMH`}),(0,o.jsx)(`input`,{className:S,value:d,onChange:e=>f(e.target.value)})]})]}),(0,o.jsxs)(`div`,{className:`space-y-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsx)(`span`,{className:`text-sm font-semibold`,children:`Visits`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>m(e=>[...e,s()]),className:`text-xs rounded-md border border-border px-2 py-1`,children:`+ Add visit`})]}),p.map((e,t)=>(0,o.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-2 bg-card`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`input`,{type:`date`,className:S+` max-w-xs`,value:e.date,onChange:e=>b(t,{date:e.target.value})}),p.length>1&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e.filter((e,n)=>n!==t)),className:`text-xs text-destructive`,children:`Remove`})]}),(0,o.jsx)(`textarea`,{className:S+` min-h-[100px] font-mono text-sm`,placeholder:`Visit note content — paste here.`,value:e.content,onChange:e=>b(t,{content:e.target.value})}),(0,o.jsx)(`textarea`,{className:S+` min-h-[60px] font-mono text-xs`,placeholder:`Labs from this visit (optional)`,value:e.labs,onChange:e=>b(t,{labs:e.target.value})})]},t))]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Additional instructions`}),(0,o.jsx)(`textarea`,{className:S+` min-h-[60px] text-sm`,placeholder:`e.g. 'Focus on thyroid management', 'Highlight medication changes'`,value:h,onChange:e=>g(e.target.value)})]}),y.error&&(0,o.jsx)(`div`,{className:`text-sm text-destructive`,children:y.error.message}),(0,o.jsx)(`button`,{type:`submit`,disabled:y.isPending||!p.some(e=>e.content.trim()),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:y.isPending?`Generating…`:`Generate Chart Review`})]}),_&&(0,o.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,o.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,o.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Chart Review`}),(0,o.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(_),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,o.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:_})]})]})}export{c as default}; \ No newline at end of file diff --git a/public/app/assets/ChartReview-BvAH_gpU.js b/public/app/assets/ChartReview-BvAH_gpU.js new file mode 100644 index 0000000..f70ab23 --- /dev/null +++ b/public/app/assets/ChartReview-BvAH_gpU.js @@ -0,0 +1,3 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-C9wKWOAN.js";import{n as a,t as o}from"./EditableResult-DaHQp1Pv.js";import{n as s,t as c}from"./LabsList-CVygta6B.js";var l=e(t(),1),u=n(),d=`chart`;function f(){return{date:``,visitType:`outpatient`,content:``,labs:``}}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,m=`rounded-md border border-input bg-background px-2 py-1 text-sm`,h=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`;function g(){let[e,t]=(0,l.useState)(``),[n,g]=(0,l.useState)(`outpatient`),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(``),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)([f()]),[T,E]=(0,l.useState)([s()]),[D,O]=(0,l.useState)(``),[k,A]=(0,l.useState)(null),j=r({mutationFn:e=>i.post(`/api/generate-chart-review`,e),onSuccess:e=>A(e.review)});function M(e,t){w(n=>n.map((n,r)=>r===e?{...n,...t}:n))}function N(e){e.preventDefault(),A(null);let t=C.filter(e=>e.content.trim()),r=e=>({date:e.date,content:e.content,labs:e.labs});j.mutate({type:n,patientAge:_,patientGender:y,pmh:x,visits:t.filter(e=>e.visitType===`outpatient`).map(r),subspecialty:t.filter(e=>e.visitType===`subspecialty`).map(e=>({date:e.date,content:e.content,labs:e.labs,specialistName:e.specialistName,specialty:e.specialty})),edVisits:t.filter(e=>e.visitType===`ed`).map(r),labs:T.filter(e=>e.values.trim()),additionalInstructions:D||void 0})}return(0,u.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Chart Review`}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Past visits + labs → summary for pre-charting. Mix of outpatient, subspecialty, and ED visits supported.`})]}),(0,u.jsx)(a,{type:d,label:e,setLabel:t,transcript:JSON.stringify({visits:C,extraLabs:T}),generatedNote:k||``,partialData:{reviewType:n,age:_,gender:y,pmh:x,additionalInstructions:D},onLoad:e=>{try{let t=e.transcript?JSON.parse(e.transcript):null;Array.isArray(t?.visits)&&t.visits.length&&w(t.visits),Array.isArray(t?.extraLabs)&&t.extraLabs.length&&E(t.extraLabs)}catch{try{let t=e.transcript?JSON.parse(e.transcript):null;Array.isArray(t)&&w(t)}catch{}}A(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.reviewType&&g(t.reviewType),t?.age&&v(t.age),t?.gender&&b(t.gender),t?.pmh&&S(t.pmh),t?.additionalInstructions&&O(t.additionalInstructions)}catch{}t(e.label||``)},onClear:()=>{w([f()]),E([s()]),A(null),g(`outpatient`),v(``),b(``),S(``),O(``)}}),(0,u.jsxs)(`form`,{onSubmit:N,className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Review type`}),(0,u.jsxs)(`select`,{className:p,value:n,onChange:e=>g(e.target.value),children:[(0,u.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,u.jsx)(`option`,{value:`subspecialty`,children:`Subspecialty`}),(0,u.jsx)(`option`,{value:`ed`,children:`ED`})]})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,u.jsx)(`input`,{className:p,value:_,onChange:e=>v(e.target.value)})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,u.jsxs)(`select`,{className:p,value:y,onChange:e=>b(e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:`Select`}),(0,u.jsx)(`option`,{children:`Male`}),(0,u.jsx)(`option`,{children:`Female`})]})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`PMH`}),(0,u.jsx)(`input`,{className:p,value:x,onChange:e=>S(e.target.value)})]})]}),(0,u.jsxs)(`div`,{className:`space-y-3`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,u.jsx)(`span`,{className:`text-sm font-semibold`,children:`Visits / Notes`}),(0,u.jsx)(`button`,{type:`button`,onClick:()=>w(e=>[...e,f()]),className:h,children:`+ Add visit / note`})]}),C.map((e,t)=>(0,u.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-2 bg-card`,"data-testid":`cr-visit-`+t,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,u.jsxs)(`strong`,{className:`text-sm`,children:[`Visit / Note #`,t+1]}),(0,u.jsx)(`input`,{type:`date`,className:m+` w-40`,value:e.date,onChange:e=>M(t,{date:e.target.value})}),(0,u.jsxs)(`select`,{className:m,value:e.visitType,onChange:e=>M(t,{visitType:e.target.value}),"data-testid":`cr-visit-type-`+t,children:[(0,u.jsx)(`option`,{value:`outpatient`,children:`Outpatient Visit`}),(0,u.jsx)(`option`,{value:`subspecialty`,children:`Subspecialty Note`}),(0,u.jsx)(`option`,{value:`ed`,children:`ED Visit`})]}),e.visitType===`subspecialty`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`input`,{type:`text`,className:m+` flex-1 min-w-[140px]`,placeholder:`Specialist name`,value:e.specialistName||``,onChange:e=>M(t,{specialistName:e.target.value})}),(0,u.jsx)(`input`,{type:`text`,className:m+` flex-1 min-w-[140px]`,placeholder:`Specialty (e.g. Endocrinology)`,value:e.specialty||``,onChange:e=>M(t,{specialty:e.target.value})})]}),C.length>1&&(0,u.jsx)(`button`,{type:`button`,onClick:()=>w(e=>e.filter((e,n)=>n!==t)),className:`ml-auto text-xs text-destructive`,title:`Remove`,children:`🗑`})]}),(0,u.jsx)(`textarea`,{className:p+` min-h-[120px] font-mono text-sm`,placeholder:`Paste note here…`,value:e.content,onChange:e=>M(t,{content:e.target.value})}),(0,u.jsx)(`textarea`,{className:p+` min-h-[60px] font-mono text-xs`,placeholder:`Labs from this visit (optional)`,value:e.labs,onChange:e=>M(t,{labs:e.target.value})})]},t))]}),(0,u.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,u.jsx)(`strong`,{className:`text-sm`,children:`🧪 Additional Labs`}),(0,u.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Labs not tied to a specific visit.`}),(0,u.jsx)(c,{value:T,onChange:E,placeholder:`e.g. TSH 4.1, Free T4 1.2`,testIdPrefix:`cr-extra-labs`})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Instructions (optional)`}),(0,u.jsx)(`textarea`,{className:p+` min-h-[60px] text-sm`,placeholder:`e.g. 'Focus on thyroid management', 'Highlight medication changes'`,value:D,onChange:e=>O(e.target.value)})]}),j.error&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:j.error.message}),(0,u.jsx)(`button`,{type:`submit`,disabled:j.isPending||!C.some(e=>e.content.trim()),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:j.isPending?`Generating…`:`✨ Generate Chart Review`})]}),k!==null&&(0,u.jsx)(o,{text:k,onChange:A,section:null,title:`Chart Review`,exportLabel:`chart-review`,exportType:`chart-review`,sourceContext:C.map(e=>e.content).filter(Boolean).join(` + +`)})]})}export{g as default}; \ No newline at end of file diff --git a/public/app/assets/Cms-BmSRdQI9.js b/public/app/assets/Cms-BmSRdQI9.js new file mode 100644 index 0000000..70bef2a --- /dev/null +++ b/public/app/assets/Cms-BmSRdQI9.js @@ -0,0 +1,143 @@ +import{i as e,n as t,r as n,t as r}from"./jsx-runtime-ByY1xr43.js";import{c as i,d as a,i as o,l as s,u as c}from"./index-C9wKWOAN.js";import{t as l}from"./ConfirmModal-CIfDDoVq.js";var u=e(t(),1),d=r();function f(){let{data:e}=s({queryKey:[`cms-stats`],queryFn:()=>o.get(`/api/learning-admin/stats`),refetchInterval:3e4}),t=e?.stats;return(0,d.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2`,"data-testid":`cms-stats-bar`,children:[{k:`Published`,v:t?.publishedContent??`–`},{k:`All content`,v:t?.totalContent??`–`},{k:`Categories`,v:t?.totalCategories??`–`},{k:`Quizzes`,v:t?.totalQuizzes??`–`},{k:`Attempts`,v:t?.totalAttempts??`–`},{k:`Embeddings`,v:t?.embeddingsEnabled?t?.withEmbeddings??`–`:`off`}].map(e=>(0,d.jsxs)(`div`,{className:`rounded-md border border-border bg-card px-3 py-2`,children:[(0,d.jsx)(`div`,{className:`text-lg font-semibold`,children:e.v}),(0,d.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:e.k})]},e.k))})}var p=`rounded-md border border-input bg-background px-2 py-1 text-xs`;function m(e){let t=c(),[n,r]=(0,u.useState)(``),[a,f]=(0,u.useState)(null),[m,h]=(0,u.useState)(null),{data:g}=s({queryKey:[`cms-categories`],queryFn:()=>o.get(`/api/learning-admin/categories`)}),_=i({mutationFn:e=>o.post(`/api/learning-admin/categories`,{name:e}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cms-categories`]}),t.invalidateQueries({queryKey:[`cms-stats`]}),r(``)},onError:e=>f(e.message||`Failed`)}),v=i({mutationFn:e=>o.delete(`/api/learning-admin/categories/`+e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cms-categories`]}),t.invalidateQueries({queryKey:[`cms-content`]}),t.invalidateQueries({queryKey:[`cms-stats`]})}});function y(e){e.preventDefault(),f(null),n.trim()&&_.mutate(n.trim())}let b=g?.categories||[];return(0,d.jsxs)(`aside`,{className:`w-64 shrink-0 space-y-3`,"data-testid":`cms-sidebar`,children:[(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Categories`}),(0,d.jsxs)(`ul`,{className:`space-y-1 max-h-64 overflow-auto`,children:[(0,d.jsx)(`li`,{children:(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onCategoryFilter(`all`),className:`w-full text-left text-sm px-2 py-1 rounded `+(e.categoryFilter===`all`?`bg-primary text-primary-foreground`:`hover:bg-muted`),children:`All categories`})}),b.map(t=>(0,d.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>e.onCategoryFilter(t.id),className:`flex-1 text-left text-sm px-2 py-1 rounded `+(e.categoryFilter===t.id?`bg-primary text-primary-foreground`:`hover:bg-muted`),"data-testid":`cms-cat-`+t.id,children:[t.name,typeof t.content_count==`number`&&(0,d.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`(`,t.content_count,`)`]})]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>h(t),className:`text-xs text-destructive hover:text-red-700 px-1`,title:`Delete category`,children:`×`})]},t.id))]}),(0,d.jsxs)(`form`,{onSubmit:y,className:`flex gap-1`,children:[(0,d.jsx)(`input`,{type:`text`,placeholder:`New category…`,value:n,onChange:e=>r(e.target.value),className:p+` flex-1`,"data-testid":`cms-new-cat-name`}),(0,d.jsx)(`button`,{type:`submit`,disabled:_.isPending,className:`rounded-md bg-primary text-primary-foreground px-2 py-1 text-xs`,children:`+`})]}),a&&(0,d.jsx)(`div`,{className:`text-xs text-destructive`,children:a})]}),(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Filter`}),(0,d.jsxs)(`select`,{className:p+` w-full`,value:e.statusFilter,onChange:t=>e.onStatusFilter(t.target.value),"data-testid":`cms-filter-status`,children:[(0,d.jsx)(`option`,{value:`all`,children:`All status`}),(0,d.jsx)(`option`,{value:`published`,children:`Published`}),(0,d.jsx)(`option`,{value:`draft`,children:`Drafts`})]})]}),(0,d.jsx)(l,{open:!!m,title:`Delete category?`,body:m?`Delete "`+m.name+`"? Its content moves to uncategorized.`:``,confirmText:`Delete`,danger:!0,busy:v.isPending,onCancel:()=>h(null),onConfirm:()=>{m&&v.mutate(m.id,{onSettled:()=>h(null)})}})]})}var h=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,g=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`,_=`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded border`,v={article:`bg-blue-100 text-blue-700 border-blue-300`,quiz:`bg-amber-100 text-amber-800 border-amber-300`,pearl:`bg-purple-100 text-purple-700 border-purple-300`,presentation:`bg-emerald-100 text-emerald-800 border-emerald-300`};function y(e){let t=c(),[n,r]=(0,u.useState)(``),[a,f]=(0,u.useState)(null),{data:p,isLoading:m}=s({queryKey:[`cms-content`],queryFn:()=>o.get(`/api/learning-admin/content`)}),y=i({mutationFn:({id:e,published:t})=>o.put(`/api/learning-admin/content/`+e,{published:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cms-content`]}),t.invalidateQueries({queryKey:[`cms-stats`]})}}),b=i({mutationFn:e=>o.delete(`/api/learning-admin/content/`+e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cms-content`]}),t.invalidateQueries({queryKey:[`cms-stats`]})}}),x=(0,u.useMemo)(()=>(p?.content||[]).filter(t=>{if(e.statusFilter===`published`&&!t.published||e.statusFilter===`draft`&&t.published||e.categoryFilter!==`all`&&t.category_id!==e.categoryFilter)return!1;if(n.trim()){let e=n.trim().toLowerCase();if(!(t.title+` `+(t.subject||``)+` `+(t.category_name||``)).toLowerCase().includes(e))return!1}return!0}),[p,e.statusFilter,e.categoryFilter,n]);return(0,d.jsxs)(`div`,{className:`flex-1 space-y-3 min-w-0`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onCreate(`article`),className:g,"data-testid":`cms-new-article`,children:`+ Article`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onCreate(`quiz`),className:h,"data-testid":`cms-new-quiz`,children:`+ Quiz`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onCreate(`pearl`),className:h,"data-testid":`cms-new-pearl`,children:`+ Pearl`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onCreate(`presentation`),className:h,"data-testid":`cms-new-presentation`,children:`+ Presentation`}),(0,d.jsx)(`div`,{className:`ml-auto`,children:(0,d.jsx)(`input`,{type:`search`,placeholder:`Search content…`,className:`rounded-md border border-input bg-background px-3 py-1.5 text-xs min-w-[220px]`,value:n,onChange:e=>r(e.target.value),"data-testid":`cms-search`})})]}),(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card overflow-hidden`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-[1fr_120px_90px_90px_120px_120px] gap-2 px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted/40 border-b border-border`,children:[(0,d.jsx)(`span`,{children:`Title`}),(0,d.jsx)(`span`,{children:`Category`}),(0,d.jsx)(`span`,{children:`Type`}),(0,d.jsx)(`span`,{children:`Status`}),(0,d.jsx)(`span`,{children:`Updated`}),(0,d.jsx)(`span`,{className:`text-right`,children:`Actions`})]}),m&&(0,d.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground text-center`,children:`Loading…`}),!m&&x.length===0&&(0,d.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground italic text-center`,children:`No content matches.`}),x.map(t=>(0,d.jsxs)(`div`,{className:`grid grid-cols-[1fr_120px_90px_90px_120px_120px] gap-2 px-3 py-2 text-sm items-center border-b border-border last:border-0 hover:bg-muted/30`,"data-testid":`cms-row-`+t.id,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>e.onEdit(t.id),className:`text-left truncate hover:underline`,children:[(0,d.jsx)(`strong`,{children:t.title}),t.subject&&(0,d.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground truncate`,children:[`· `,t.subject]}),t.content_type===`quiz`&&typeof t.question_count==`number`&&(0,d.jsxs)(`span`,{className:`ml-2 text-[10px] text-muted-foreground`,children:[t.question_count,` Q`]})]}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:t.category_name||`—`}),(0,d.jsx)(`span`,{className:_+` `+v[t.content_type],children:t.content_type}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>y.mutate({id:t.id,published:!t.published}),className:_+` `+(t.published?`bg-green-100 text-green-700 border-green-300`:`bg-muted text-muted-foreground border-border`),title:`Toggle published`,children:t.published?`Published`:`Draft`}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(t.updated_at).toLocaleDateString()}),(0,d.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>e.onEdit(t.id),className:h,children:`Edit`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>f(t),className:h+` text-destructive`,children:`Del`})]})]},t.id))]}),(0,d.jsx)(l,{open:!!a,title:`Delete content?`,body:a?`Delete "`+a.title+`"? This cannot be undone.`:``,confirmText:`Delete`,danger:!0,busy:b.isPending,onCancel:()=>f(null),onConfirm:()=>{a&&b.mutate(a.id,{onSettled:()=>f(null)})}})]})}var b=n((e=>{var n=t();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useState,o=n.useEffect,s=n.useLayoutEffect,c=n.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=n.useSyncExternalStore===void 0?f:n.useSyncExternalStore})),x=n(((e,t)=>{t.exports=b()}));function S(e){this.content=e}S.prototype={constructor:S,find:function(e){for(var t=0;t>1}},S.from=function(e){if(e instanceof S)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new S(t)};function ee(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=ee(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function te(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?re(t+1,i):re(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};T.none=[];var ie=class extends Error{},E=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=oe(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ae(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(C.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};E.empty=new E(C.empty,0,0);function ae(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ae(a.content,t-i-1,n-i-1)))}function oe(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=oe(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function se(e,t,n){if(n.openStart>e.depth)throw new ie(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ie(`Inconsistent open depths`);return ce(e,t,n,0)}function ce(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function fe(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(de(e.nodeAfter,r),a++));for(let e=a;ei&&ue(e,t,i+1),o=r.depth>i&&ue(n,r,i+1),s=[];return fe(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(le(a,o),de(pe(a,me(e,t,n,r,i+1)),s)):(a&&de(pe(a,he(e,t,i+1)),s),fe(t,n,i,s),o&&de(pe(o,he(n,r,i+1)),s)),fe(r,null,i,s),new C(s)}function he(e,t,n){let r=[];return fe(null,e,n,r),e.depth>n&&de(pe(ue(e,t,n+1),he(e,t,n+1)),r),fe(t,null,n,r),new C(r)}function ge(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(C.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var _e=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new xe(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=be.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Te(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=C.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=C.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Ce.prototype.text=void 0;var we=class e extends Ce{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Te(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Te(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Ee=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new De(t,n);if(r.next==null)return e.empty;let i=Oe(r);r.next&&r.err(`Unexpected trailing text`);let a=Re(Fe(i));return ze(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` +`)}};Ee.empty=new Ee(!0);var De=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Oe(e){let t=[];do t.push(ke(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function ke(e){let t=[];do t.push(Ae(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Ae(e){let t=Pe(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Me(e,t);else break;return t}function je(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Me(e,t){let n=je(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:je(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Ne(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Pe(e){if(e.eat(`(`)){let t=Oe(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Ne(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Fe(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Ee(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ve(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Ce(this,this.computeAttrs(e),C.from(t),T.setFrom(n))}createChecked(e=null,t,n){return t=C.from(t),this.checkContent(t),new Ce(this,this.computeAttrs(e),t,T.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=C.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(C.empty,!0);return i?new Ce(this,e,t.append(i),T.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Ge(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Ke=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Ge(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},qe=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ue(e,r.attrs),this.excluded=null;let i=Be(this.attrs);this.instance=i?new T(this,i):null}create(e=null){return!e&&this.instance?this.instance:new T(this,Ve(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},Je=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=S.from(e.nodes),t.marks=S.from(e.marks||{}),this.nodes=We.compile(this.spec.nodes,this),this.marks=qe.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Ee.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Ye(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Ye(this,n.split(` `))}this.nodeFromJSON=e=>Ce.fromJSON(this,e),this.markFromJSON=e=>T.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof We))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new we(n,n.defaultAttrs,e,T.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Ye(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Xe(e){return e.tag!=null}function Ze(e){return e.style!=null}var Qe=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Xe(e))this.tags.push(e);else if(Ze(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new st(this,t,!1);return n.addAll(e,T.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new st(this,t,!0);return n.addAll(e,T.none,t.from,t.to),E.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=ut(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ut(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},$e={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},et={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},tt={ol:!0,ul:!0},nt=1,rt=2,it=4;function at(e,t,n){return t==null?e&&e.whitespace==`pre`?nt|rt:n&~it:(t?nt:0)|(t===`full`?rt:0)}var ot=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=T.none,this.match=i||(a&it?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&nt)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!$e.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},st=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=at(null,t.preserveWhitespace,0)|(n?it:0);i=r?new ot(r.type,r.attrs,T.none,!0,t.topMatch||r.type.contentMatch,a):n?new ot(null,null,T.none,!0,null,a):new ot(e.schema.topNodeType,null,T.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&rt?`full`:this.localPreserveWS||(r.options&nt)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` +`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e(a.type?a.type.allowsMarkType(t.type):dt(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new ot(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=nt);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function ct(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&tt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function lt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ut(e){let t={};for(let n in e)t[n]=e[n];return t}function dt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&vt(mt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return vt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=pt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return pt(e.marks)}};function pt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function mt(e){return e.document||window.document}var ht=new WeakMap;function gt(e){let t=ht.get(e);return t===void 0&&ht.set(e,t=_t(e)),t}function _t(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=vt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var yt=65535,bt=2**16;function xt(e,t){return e+t*bt}function St(e){return e&yt}function Ct(e){return(e-(e&yt))/bt}var wt=1,Tt=2,Et=4,Dt=8,Ot=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Dt)>0}get deletedBefore(){return(this.delInfo&(wt|Et))>0}get deletedAfter(){return(this.delInfo&(Tt|Et))>0}get deletedAcross(){return(this.delInfo&Et)>0}},kt=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=St(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:xt(o/3,e-s),f=e==s?Tt:e==u?wt:Et;return(t<0?e!=s:e!=u)&&(f|=Dt),new Ot(a,f,d)}r+=l-c}return n?e+r:new Ot(e+r,0,null)}touches(e,t){let n=0,r=St(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return O.fromReplace(e,this.from,this.to,i)}invert(){return new Pt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};D.jsonID(`addMark`,Nt);var Pt=class e extends D{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new E(Mt(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return O.fromReplace(e,this.from,this.to,n)}invert(){return new Nt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};D.jsonID(`removeMark`,Pt);var Ft=class e extends D{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return O.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return O.fromReplace(e,this.pos,this.pos+1,new E(C.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,E.fromJSON(t,n.slice),n.insert,!!n.structure)}};D.jsonID(`replaceAround`,k);function Rt(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function zt(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function Bt(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof qe){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new Pt(t.from,t.to,t.style)))}function Vt(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function Ht(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ut(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=C.from(r.node(e).copy(u)),d++):c--;let f=C.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=C.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new k(i,a,i,a,new E(r,0,0),n.length,!0))}function Xt(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&$t(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Qt(e,t,n,a),Vt(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new k(c,l,c+1,l-1,new E(C.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Zt(e,t,n,a),!1}})}function Zt(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Qt(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` +`))}})}function $t(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function en(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new k(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new E(C.from(o),0,0),1,!0))}function tn(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function nn(e,t,n=1,r){let i=e.doc.resolve(t),a=C.empty,o=C.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=C.from(i.node(e).copy(a));let t=r&&r[s];o=C.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Lt(t,t,new E(a.append(o),n,n),!0))}function rn(e,t){let n=e.resolve(t),r=n.index();return on(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function an(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&on(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function cn(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Qt(e,r.node(),r.before(),s)}o.inlineContent&&Vt(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Lt(l,c.map(t+n,-1),E.empty,!0)),r===!0){let t=e.doc.resolve(l);Zt(e,t.node(),t.before(),e.steps.length)}return e}function ln(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function dn(e,t,n=t,r=E.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return fn(i,a,r)?new Lt(t,n,r):new pn(i,a,r).fit()}function fn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var pn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=C.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=C.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new E(i,a,o);return e>-1?new k(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Lt(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=gn(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(C.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=gn(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=gn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new E(mn(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new E(mn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(_n(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=hn(this.placed,t,C.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=vn(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=hn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=hn(this.placed,this.depth,C.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(C.empty,!0);e.childCount&&(this.placed=hn(this.placed,this.frontier.length,e))}};function mn(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(mn(e.firstChild.content,t-1,n)))}function hn(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(hn(e.lastChild.content,t-1,n)))}function gn(e,t){for(let n=0;n1&&(r=r.replaceChild(0,_n(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),e.copy(r)}function vn(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!yn(n,a.content,o)?s:null}function yn(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=bn(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Sn(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(C.empty,!0))}return e}function Cn(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=ln(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new E(C.from(r),0,0))}function wn(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=Tn(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Tn(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var En=class e extends D{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return O.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return O.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,+!t.isLeaf))}getMap(){return kt.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};D.jsonID(`attr`,En);var Dn=class e extends D{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return O.ok(n)}getMap(){return kt.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};D.jsonID(`docAttr`,Dn);var On=class extends Error{};On=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},On.prototype=Object.create(Error.prototype),On.prototype.constructor=On,On.prototype.name=`TransformError`;var kn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new At}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new On(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=E.empty){let r=dn(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new E(C.from(n),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return xn(this,e,t,n),this}replaceRangeWith(e,t,n){return Cn(this,e,t,n),this}deleteRange(e,t){return wn(this,e,t),this}lift(e,t){return Wt(this,e,t),this}join(e,t=1){return cn(this,e,t),this}wrap(e,t){return Yt(this,e,t),this}setBlockType(e,t=e,n,r=null){return Xt(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return en(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new En(e,t,n)),this}setDocAttribute(e,t){return this.step(new Dn(e,t)),this}addNodeMark(e,t){return this.step(new Ft(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof T)t.isInSet(n.marks)&&this.step(new It(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new It(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return nn(this,e,t,n),this}addMark(e,t,n){return zt(this,e,t,n),this}removeMark(e,t,n){return Bt(this,e,t,n),this}clearIncompatible(e,t,n){return Vt(this,e,t,n),this}},An=Object.create(null),A=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new jn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?Rn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Rn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new In(e.node(0))}static atStart(e){return Rn(e,e,0,0,1)||new In(e)}static atEnd(e){return Rn(e,e,e.content.size,e.childCount,-1)||new In(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=An[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in An)throw RangeError(`Duplicate use of selection JSON ID `+e);return An[e]=t,t.prototype.jsonID=e,t}getBookmark(){return j.between(this.$anchor,this.$head).getBookmark()}};A.prototype.visible=!0;var jn=class{constructor(e,t){this.$from=e,this.$to=t}},Mn=!1;function Nn(e){!Mn&&!e.parent.inlineContent&&(Mn=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var j=class e extends A{constructor(e,t=e){Nn(e),Nn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return A.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Pn(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=A.findFrom(n,r,!0)||A.findFrom(n,-r,!0);if(e)n=e.$head;else return A.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(A.findFrom(t,-r,!0)||A.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Rn(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&M.isSelectable(r))return M.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function zn(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(A.near(e.doc.resolve(o),n))}var Bn=1,Vn=2,Hn=4,Un=class extends kn{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Vn,this}ensureMarks(e){return T.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Vn)>0}addStep(e,t){super.addStep(e,t),this.updated&=~Vn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||T.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(A.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Hn,this}get scrolledIntoView(){return(this.updated&Hn)>0}};function Wn(e,t){return!t||!e?e:e.bind(t)}var Gn=class{constructor(e,t,n){this.name=e,this.init=Wn(t.init,n),this.apply=Wn(t.apply,n)}},Kn=[new Gn(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Gn(`selection`,{init(e,t){return e.selection||A.atStart(t.doc)},apply(e){return e.selection}}),new Gn(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Gn(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],qn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Kn.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Gn(e.key,e.spec.state,e))})}},Jn=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new qn(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Ce.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=A.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Yn(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Yn(i,t,{})),n[r]=i}return n}var N=class{constructor(e){this.spec=e,this.props={},e.props&&Yn(e.props,this,this.props),this.key=e.key?e.key.key:Zn(`plugin`)}getState(e){return e[this.key]}},Xn=Object.create(null);function Zn(e){return e in Xn?e+`$`+ ++Xn[e]:(Xn[e]=0,e+`$`)}var P=class{constructor(e=`key`){this.key=Zn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Qn=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function $n(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var er=(e,t,n)=>{let r=$n(e,n);if(!r)return!1;let i=or(r);if(!i){let n=r.blockRange(),i=n&&Ut(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(wr(e,i,t,-1))return!0;if(r.parent.content.size==0&&(ir(a,`end`)||M.isSelectable(a)))for(let n=r.depth;;n--){let o=dn(e.doc,r.before(n),r.after(n),E.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},tr=(e,t,n)=>{let r=$n(e,n);if(!r)return!1;let i=or(r);return i?rr(e,i,t):!1},nr=(e,t,n)=>{let r=sr(e,n);if(!r)return!1;let i=ur(r);return i?rr(e,i,t):!1};function rr(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=dn(e.doc,i,o,E.empty);if(!s||s.from!=i||s instanceof Lt&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(j.create(t.doc,i)),n(t.scrollIntoView())}return!0}function ir(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var ar=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=or(r)}let o=a&&a.nodeBefore;return!o||!M.isSelectable(o)?!1:(t&&t(e.tr.setSelection(M.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function or(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function sr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=sr(e,n);if(!r)return!1;let i=ur(r);if(!i)return!1;let a=i.nodeAfter;if(wr(e,i,t,1))return!0;if(r.parent.content.size==0&&(ir(a,`start`)||M.isSelectable(a))){let n=dn(e.doc,r.before(),r.after(),E.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof M,i;if(r){if(n.node.isTextblock||!rn(e.doc,n.from))return!1;i=n.from}else if(i=sn(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(M.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},fr=(e,t)=>{let n=e.selection,r;if(n instanceof M){if(n.node.isTextblock||!rn(e.doc,n.to))return!1;r=n.to}else if(r=sn(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},pr=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&Ut(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},mr=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` +`).scrollIntoView()),!0)};function hr(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=hr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(A.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},_r=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof In||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=hr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(tn(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ut(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function yr(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof M&&t.selection.node.isBlock)return!r.parentOffset||!tn(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=hr(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof j||t.selection instanceof In)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=tn(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,tn(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var br=yr(),xr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(M.create(e.doc,i))),!0)},Sr=(e,t)=>(t&&t(e.tr.setSelection(new In(e.doc))),!0);function Cr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||rn(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function wr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Cr(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=C.empty;for(let e=o.length-1;e>=0;e--)s=C.from(o[e].create(null,s));s=C.from(i.copy(s));let c=e.tr.step(new k(t.pos-1,r,t.pos,r,new E(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&rn(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:A.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&Ut(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&ir(a,`start`,!0)&&ir(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=C.empty;for(let e=o.length-1;e>=0;e--)r=C.from(o[e].copy(r));n(e.tr.step(new k(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new E(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Tr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(j.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var Er=Tr(-1),Dr=Tr(1);function Or(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Gt(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function kr(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new xe(e,e,t.depth),t.endIndex=0;e--)a=C.from(n[e].type.create(n[e].attrs,a));e.step(new k(t.start-(r?2:0),t.end,t.start,t.end,new E(a,0,0),n.length,!0));let o=0;for(let e=0;et.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?zr(t,n,e,a):Br(t,n,a):!0:!1}}function zr(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?C.empty:C.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new k(d-+!!s,f+ +!!c,d+1,f-1,new E((s?C.empty:C.from(i.copy(C.empty))).append(c?C.empty:C.from(i.copy(C.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Vr(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=C.from(r?e.create():null),o=new E(C.from(e.create(null,C.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new k(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var F=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Hr=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Ur=null,Wr=function(e,t,n){let r=Ur||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Gr=function(){Ur=null},Kr=function(e,t,n,r){return n&&(Jr(e,t,n,r,-1)||Jr(e,t,n,r,1))},qr=/^(img|br|input|textarea|hr)$/i;function Jr(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Yr(e))){let n=e.parentNode;if(!n||n.nodeType!=1||$r(e)||qr.test(e.nodeName)||e.contentEditable==`false`)return!1;t=F(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?Yr(e):0}else return!1}}function Yr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Xr(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Yr(e)}else if(e.parentNode&&!$r(e))t=F(e),e=e.parentNode;else return null}}function Zr(e,t){for(;;){if(e.nodeType==3&&t2),hi=mi||(ii?/Mac/.test(ii.platform):!1),gi=ii?/Win/.test(ii.platform):!1,_i=/Android \d/.test(oi),vi=!!ai&&`webkitFontSmoothing`in ai.documentElement.style,yi=vi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bi(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function xi(e,t){return typeof e==`number`?e:e[t]}function Si(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function Ci(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Hr(o);continue}let e=o,n=e==a.body,s=n?bi(a):Si(e),c=0,l=0;if(t.tops.bottom-xi(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+xi(i,`top`)-s.top:t.bottom-s.bottom+xi(i,`bottom`)),t.lefts.right-xi(r,`right`)&&(c=t.right-s.right+xi(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Hr(o)}}function wi(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:Ti(e.dom)}}function Ti(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Hr(r));return t}function Ei({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;Di(n,r==0?0:r-t)}function Di(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?ji(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:Ai(n,i)}function ji(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function Mi(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ni(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Fi(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function Ii(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;vi&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=Fi(e,r,i,t))}s??=Pi(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Ri(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Hi(zi(Wr(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Yr(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return Ui(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Yr(r))){let e=r.childNodes[i-1],t=e.nodeType==3?Wr(e,Yr(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Hi(zi(t,1),!1)}if(a==null&&i=0)}function Hi(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ui(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Wi(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Gi(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Wi(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Vi(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=Wr(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Ki=/[\u0590-\u08ac]/;function qi(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Ki.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Wi(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Ji=null,Yi=null,Xi=!1;function Zi(e,t,n){return Ji==t&&Yi==n?Xi:(Ji=t,Yi=n,Xi=n==`up`||n==`down`?Gi(e,t,n):qi(e,t,n))}var Qi=0,$i=1,ea=2,ta=3,na=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Qi,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tF(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te||i instanceof la){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof ra&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?F(e.dom)+1:0}}else{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=F(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?ea:$i,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ta:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?ea:ta}n=a}this.dirty=ea}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?ea:$i;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Qi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ia=class extends na{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},aa=class e extends na{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=ft.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ta||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ta&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Qi){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=Ea(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=ft.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=_a(u,r,n),l?c=new ua(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new ca(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,n){return this.dirty==Qi&&e.eq(this.node)&&va(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new ba(this,a&&a.node,e);Ca(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?T.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==ea)&&(a&&this.protectLocalComposition(e,a),da(this.contentDOM,this.children,e),mi&&wa(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof j)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=Ta(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new ia(this,i,t,r);e.input.compositionNodes.push(a),this.children=Ea(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==ta||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Qi}updateOuterDeco(e){if(va(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=ha(this.dom,this.nodeDOM,ma(this.outerDeco,this.node,t),ma(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function sa(e,t,n,r,i){_a(r,t,e);let a=new oa(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var ca=class e extends oa{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==ta||this.dirty!=Qi&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Qi||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Qi,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ta)}get domAtom(){return!1}isText(e){return this.node.text==e}},la=class extends na{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qi&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},ua=class extends oa{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==ta)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function da(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=aa.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof aa)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function Sa(e,t){return e.type.side-t.type.side}function Ca(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function wa(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function Ta(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function Ea(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function Da(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(ei(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&M.isSelectable(e)&&i.parent&&!(e.isInline&&Qr(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new M(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!Oa(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Fa(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,F(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&I&&ui<=11&&(n.disabled=!0,n.disabled=!1)}function Ia(e,t){if(t instanceof M){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(La(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else La(e)}function La(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Ra(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||j.between(t,n,r)}function za(e){return e.editable&&!e.hasFocus()?!1:Ba(e)}function Ba(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function Va(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Kr(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Ha(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&A.findFrom(a,t)}function Ua(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Wa(e,t,n){let r=e.state.selection;if(r instanceof j){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Ua(e,new j(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Ha(e.state,t);return n&&n instanceof M?Ua(e,n):!1}else if(!(hi&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?M.isSelectable(i)?Ua(e,new M(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):vi?Ua(e,new j(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof M&&r.node.isInline)return Ua(e,new j(t>0?r.$to:r.$from));else{let n=Ha(e.state,t);return n?Ua(e,n):!1}}function Ga(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ka(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function qa(e,t){return t<0?Ja(e):Ya(e)}function Ja(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(di&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(Ka(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Xa(n))break;else{let t=n.previousSibling;for(;t&&Ka(t,-1);)i=n.parentNode,a=F(t),t=t.previousSibling;if(t)n=t,r=Ga(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?$a(e,n,r):i&&$a(e,i,a)}function Ya(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Ga(n),a,o;for(;;)if(r{e.state==i&&ka(e)},50)}function eo(e,t){let n=e.state.doc.resolve(t);if(!(L||gi)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function to(e,t,n){let r=e.state.selection;if(r instanceof j&&!r.empty||n.indexOf(`s`)>-1||hi&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Ha(e.state,t);if(n&&n instanceof M)return Ua(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof In?A.near(n,t):A.findFrom(n,t);return o?Ua(e,o):!1}return!1}function no(e,t){if(!(e.state.selection instanceof j))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function ro(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function io(e){if(!R||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;ro(e,n,`true`),setTimeout(()=>ro(e,n,`false`),20)}return!1}function ao(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function oo(e,t){let n=t.keyCode,r=ao(t);if(n==8||hi&&n==72&&r==`c`)return no(e,-1)||qa(e,-1);if(n==46&&!t.shiftKey||hi&&n==68&&r==`c`)return no(e,1)||qa(e,1);if(n==13||n==27)return!0;if(n==37||hi&&n==66&&r==`c`){let t=n==37?eo(e,e.state.selection.from)==`ltr`?-1:1:-1;return Wa(e,t,r)||qa(e,t)}else if(n==39||hi&&n==70&&r==`c`){let t=n==39?eo(e,e.state.selection.from)==`ltr`?1:-1:1;return Wa(e,t,r)||qa(e,t)}else if(n==38||hi&&n==80&&r==`c`)return to(e,-1,r)||qa(e,-1);else if(n==40||hi&&n==78&&r==`c`)return io(e)||to(e,1,r)||qa(e,1);else if(r==(hi?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function so(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||ft.fromSchema(e.state.schema),s=yo(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=_o[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` + +`),slice:t}}function co(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new E(C.from(e.state.schema.text(t.replace(/\r\n?/g,` +`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=ft.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=So(n),vi&&Co(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Qe.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!lo.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=wo(go(s,+u[1],+u[2]),u[4]);else if(s=E.maxOpen(uo(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var lo=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function uo(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&po(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=mo(a[a.length-1],i.length));let n=fo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return C.from(a)}return e}function fo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,C.from(e));return e}function po(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(C.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function go(e,t,n){return te}),bo.createHTML(e)):e}function So(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=yo().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&_o[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>``).reverse().join(``)),n.innerHTML=xo(e),i)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=C.from(t.create(r[e+1],i)),a++,o++}return new E(i,a,o)}var z={},B={},To={touchstart:!0,touchmove:!0},Eo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Do(e){for(let t in z){let n=z[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Mo(e,t)&&!jo(e,t)&&(e.editable||!(t.type in B))&&n(e,t)},To[t]?{passive:!0}:void 0)}R&&e.dom.addEventListener(`input`,()=>null),Ao(e)}function Oo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ko(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Ao(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>jo(e,t))})}function jo(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Mo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function No(e,t){!jo(e,t)&&z[t.type]&&(e.editable||!(t.type in B))&&z[t.type](e,t)}B.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!qo(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(_i&&L&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),mi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,ti(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||oo(e,n)?n.preventDefault():Oo(e,`key`)},B.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},B.keypress=(e,t)=>{let n=t;if(qo(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||hi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof j)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Po(e){return{left:e.clientX,top:e.clientY}}function Fo(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Io(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Lo(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function Ro(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&M.isSelectable(r)?(Lo(e,new M(n),`pointer`),!0):!1}function zo(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof M&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(M.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(Lo(e,M.create(e.state.doc,i),`pointer`),!0)}function Bo(e,t,n,r,i){return Io(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?zo(e,n):Ro(e,n))}function Vo(e,t,n,r){return Io(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Ho(e,t,n,r){return Io(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Uo(e,n,r)}function Uo(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(Lo(e,j.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)Lo(e,j.create(r,a+1,a+1+n.content.size),`pointer`);else if(M.isSelectable(n))Lo(e,M.create(r,a),`pointer`);else continue;return!0}}function Wo(e){return es(e)}var Go=hi?`metaKey`:`ctrlKey`;z.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Wo(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Fo(n,e.input.lastClick)&&!n[Go]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(Po(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Ko(e,o,n,!!r)):(a==`doubleClick`?Vo:Ho)(e,o.pos,o.inside,n)?n.preventDefault():Oo(e,`pointer`))};var Ko=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Go],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof M&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&di&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),Oo(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ka(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Po(e))),this.updateAllowDefault(e),this.allowDefault||!t?Oo(this.view,`pointer`):Bo(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||R&&this.mightDrag&&!this.mightDrag.node.isAtom||L&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Lo(this.view,A.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):Oo(this.view,`pointer`)}move(e){this.updateAllowDefault(e),Oo(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};z.touchstart=e=>{e.input.lastTouch=Date.now(),Wo(e),Oo(e,`pointer`)},z.touchmove=e=>{e.input.lastTouch=Date.now(),Oo(e,`pointer`)},z.contextmenu=e=>Wo(e);function qo(e,t){return e.composing?!0:R&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Jo=_i?5e3:-1;B.compositionstart=B.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof j&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||L&&gi&&Yo(e)))e.markCursor=e.state.storedMarks||n.marks(),es(e,!0),e.markCursor=null;else if(es(e,!t.selection.empty),di&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Xo(e,Jo)};function Yo(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}B.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Xo(e,20))};function Xo(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>es(e),t))}function Zo(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=$o());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Qo(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Xr(t.focusNode,t.focusOffset),r=Zr(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function $o(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function es(e,t=!1){if(!(_i&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Zo(e),t||e.docView&&e.docView.dirty){let n=Da(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function ts(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var ns=I&&ui<15||mi&&yi<604;z.copy=B.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=ns?null:n.clipboardData,{dom:o,text:s}=so(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):ts(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function rs(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function is(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?as(e,r.value,null,i,t):as(e,r.textContent,r.innerHTML,i,t)},50)}function as(e,t,n,r,i){let a=co(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||E.empty)))return!0;if(!a)return!1;let o=rs(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function ss(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}B.paste=(e,t)=>{let n=t;if(e.composing&&!_i)return;let r=ns?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&as(e,ss(r),r.getData(`text/html`),i,n)?n.preventDefault():is(e,n)};var cs=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ls=hi?`altKey`:`ctrlKey`;function us(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ls]:!n}z.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Po(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof M?i.to-1:i.to))){if(r&&r.mightDrag)o=M.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=M.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=so(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!L||pi>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ns?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,ns||n.dataTransfer.setData(`text/plain`,c),e.dragging=new cs(l,us(e,n),o)},z.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},B.dragover=B.dragenter=(e,t)=>t.preventDefault(),B.drop=(e,t)=>{try{ds(e,t,e.dragging)}finally{e.dragging=null}};function ds(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Po(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=co(e,ss(t.dataTransfer),ns?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&us(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||E.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?un(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&M.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new M(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Ra(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}z.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ka(e)},20))},z.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},z.beforeinput=(e,t)=>{if(L&&_i&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,ti(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in B)z[e]=B[e];function fs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ps=class e{constructor(e,t){this.toDOM=e,this.spec=t||vs,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new gs(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&fs(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},ms=class e{constructor(e,t){this.attrs=e,this.spec=t||vs}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new gs(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==H||e.maps.length==0?this:this.mapInner(e,t,0,0,n||vs)}mapInner(t,n,r,i,a){let o;for(let e=0;e{let o=t+r,s;if(s=Cs(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof ms){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,vs));return e.from(r)}forChild(t,n){if(n.isLeaf)return V.empty;let r=[];for(let i=0;ie instanceof V)?t:t.reduce((e,t)=>e.concat(t instanceof V?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==H?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Ts(Ss(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=Cs(e,t,o+n);if(s){a=!0;let e=Ts(s,t,n+o+1,r);e!=H&&i.push(o,o+t.nodeSize,e)}});let o=xs(a?ws(e):e,-n).sort(Es);for(let e=0;e0;)t++;e.splice(t,0,n)}function ks(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=H&&t.push(r)}),e.cursorWrapper&&t.push(V.create(e.state.doc,[e.cursorWrapper.deco])),ys.from(t)}var As={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},js=I&&ui<=11,Ms=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Ns=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ms,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():R&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),js&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,As)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(za(this.view)){if(this.suppressingSelectionUpdates)return ka(this.view);if(I&&ui<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Kr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Hr(n))t.add(n);for(let r=e.anchorNode;r;r=Hr(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&za(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(di&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||zs(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Is(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Bs(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ka(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;ni;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||Qe.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Hs,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function Hs(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(R&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||R&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Us=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ws(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Da(e,t);if(n&&!e.state.selection.eq(n)){if(L&&_i&&e.input.lastKeyCode===13&&Date.now()-100t(e,ti(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=Vs(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||_i)&&i.some(e=>e.nodeType==1&&!Us.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,ti(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof j&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Gs(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),I&&ui<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((mi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.post(e,ti(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&qs(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,ti(8,`Backspace`)))){_i&&L&&e.domObserver.suppressSelectionUpdates();return}L&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),_i&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,ti(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Gs(e,n.doc,l.sel);t&&!(L&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteka(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Ks(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function Gs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Ra(e,t.resolve(n.anchor),t.resolve(n.head))}function Ks(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||Js(o,!0,!1)0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Ys(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o=o?a-r:0;a-=e,a&&a=s?a-r:0;a-=t,a&&a=56320&&t<=57343&&n>=55296&&n<=56319}var Zs=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Eo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ic),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ec(this),$s(this),this.nodeViews=nc(this),this.docView=sa(this.state.doc,Qs(this),ks(this),this.dom,this),this.domObserver=new Ns(this,(e,t,n,r)=>Ws(this,e,t,n,r)),this.domObserver.start(),Do(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ao(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ic),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Zo(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=nc(this);rc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ao(this),this.editable=ec(this),$s(this);let o=ks(this),s=Qs(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&wi(this);if(i){this.domObserver.stop();let t=l&&(I||L)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&tc(n.selection,e.selection);if(l){let n=L?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Qo(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=sa(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Va(this))?ka(this,t):(Ia(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&Ei(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ci(this,t.getBoundingClientRect(),e)}else Ci(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Li(this,e)}coordsAtPos(e,t=1){return Vi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Zi(this,t||this.state,e)}pasteHTML(e,t){return as(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return as(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return so(this,e)}destroy(){this.docView&&(ko(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ks(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Gr())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return No(this,e)}domSelectionRange(){let e=this.domSelection();return e?R&&this.root.nodeType===11&&ni(this.dom.ownerDocument)==this.dom&&Rs(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Zs.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Qs(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[gs.node(0,e.state.doc.content.size,t)]}function $s(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:gs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function ec(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function tc(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function nc(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function rc(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function ic(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var ac={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},oc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},sc=typeof navigator<`u`&&/Mac/.test(navigator.platform),cc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),U=0;U<10;U++)ac[48+U]=ac[96+U]=String(U);for(var U=1;U<=24;U++)ac[U+111]=`F`+U;for(var U=65;U<=90;U++)ac[U]=String.fromCharCode(U+32),oc[U]=String.fromCharCode(U);for(var lc in ac)oc.hasOwnProperty(lc)||(oc[lc]=ac[lc]);function uc(e){var t=!(sc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||cc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?oc:ac)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var dc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fc=typeof navigator<`u`&&/Win/.test(navigator.platform);function pc(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e{for(var n in t)bc(e,n,{get:t[n],enumerable:!0})};function Sc(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Cc=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Sc({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},wc={};xc(wc,{blur:()=>Tc,clearContent:()=>Ec,clearNodes:()=>Dc,command:()=>Oc,createParagraphNear:()=>kc,cut:()=>Ac,deleteCurrentNode:()=>jc,deleteNode:()=>Mc,deleteRange:()=>Nc,deleteSelection:()=>Pc,enter:()=>Fc,exitCode:()=>Ic,extendMarkRange:()=>Uc,first:()=>Wc,focus:()=>Zc,forEach:()=>Qc,insertContent:()=>$c,insertContentAt:()=>al,joinBackward:()=>cl,joinDown:()=>sl,joinForward:()=>ll,joinItemBackward:()=>ul,joinItemForward:()=>dl,joinTextblockBackward:()=>fl,joinTextblockForward:()=>pl,joinUp:()=>ol,keyboardShortcut:()=>gl,lift:()=>vl,liftEmptyBlock:()=>yl,liftListItem:()=>bl,newlineInCode:()=>xl,resetAttributes:()=>wl,scrollIntoView:()=>Tl,selectAll:()=>El,selectNodeBackward:()=>Dl,selectNodeForward:()=>Ol,selectParentNode:()=>kl,selectTextblockEnd:()=>Al,selectTextblockStart:()=>jl,setContent:()=>Nl,setMark:()=>Ou,setMeta:()=>ku,setNode:()=>Au,setNodeSelection:()=>ju,setTextDirection:()=>Mu,setTextSelection:()=>Nu,sinkListItem:()=>Pu,splitBlock:()=>Iu,splitListItem:()=>Lu,toggleList:()=>Vu,toggleMark:()=>Hu,toggleNode:()=>Uu,toggleWrap:()=>Wu,undoInputRule:()=>Gu,unsetAllMarks:()=>Ku,unsetMark:()=>qu,unsetTextDirection:()=>Ju,updateAttributes:()=>Yu,wrapIn:()=>Xu,wrapInList:()=>Zu});var Tc=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),Ec=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Dc=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=Ut(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},Oc=e=>t=>e(t),kc=()=>({state:e,dispatch:t})=>_r(e,t),Ac=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new j(r.doc.resolve(Math.max(o-1,0)))),!0},jc=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function W(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Mc=e=>({tr:t,state:n,dispatch:r})=>{let i=W(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Nc=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},Pc=()=>({state:e,dispatch:t})=>Qn(e,t),Fc=()=>({commands:e})=>e.keyboardShortcut(`Enter`),Ic=()=>({state:e,dispatch:t})=>gr(e,t);function Lc(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function Rc(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:Lc(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function zc(e,t,n={}){return e.find(e=>e.type===t&&Rc(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function Bc(e,t,n={}){return!!zc(e,t,n)}function Vc(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!zc([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&Bc([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=Hc(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=Vc(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=j.create(o,e.from,e.to);n.setSelection(t)}}return!0},Wc=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(Yc()||Jc())&&r.dom.focus(),Xc()&&!Yc()&&!Jc()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!Gc(n.state.selection))return o(),!0;let s=qc(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Qc=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),$c=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),el=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&el(r)}return e};function tl(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return el(n)}function nl(e,t,n){if(e instanceof Ce||e instanceof C)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return C.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),nl(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Je({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Qe.fromSchema(a).parseSlice(tl(e),n.parseOptions):Qe.fromSchema(a).parse(tl(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Qe.fromSchema(t);return n.slice?r.parseSlice(tl(e),n.parseOptions).content:r.parse(tl(e),n.parseOptions)}return nl(``,t,n)}function rl(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(A.near(e.doc.resolve(o),n))}var il=e=>!(`type`in e),al=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{nl(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=nl(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((il(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof C){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&rl(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},ol=()=>({state:e,dispatch:t})=>dr(e,t),sl=()=>({state:e,dispatch:t})=>fr(e,t),cl=()=>({state:e,dispatch:t})=>er(e,t),ll=()=>({state:e,dispatch:t})=>cr(e,t),ul=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sn(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},dl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=sn(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},fl=()=>({state:e,dispatch:t})=>tr(e,t),pl=()=>({state:e,dispatch:t})=>nr(e,t);function ml(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function hl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=hl(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function _l(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?W(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>Rc(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var vl=(e,t={})=>({state:n,dispatch:r})=>_l(n,W(e,n.schema),t)?pr(n,r):!1,yl=()=>({state:e,dispatch:t})=>vr(e,t),bl=e=>({state:t,dispatch:n})=>Rr(W(e,t.schema))(t,n),xl=()=>({state:e,dispatch:t})=>mr(e,t);function Sl(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function Cl(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var wl=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Sl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=W(e,r.schema)),s===`mark`&&(o=Hc(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,Cl(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(Cl(a.attrs,t))))})})}),c},Tl=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),El=()=>({tr:e,dispatch:t})=>{if(t){let t=new In(e.doc);e.setSelection(t)}return!0},Dl=()=>({state:e,dispatch:t})=>ar(e,t),Ol=()=>({state:e,dispatch:t})=>lr(e,t),kl=()=>({state:e,dispatch:t})=>xr(e,t),Al=()=>({state:e,dispatch:t})=>Dr(e,t),jl=()=>({state:e,dispatch:t})=>Er(e,t);function Ml(e,t,n={},r={}){return nl(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Nl=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=Ml(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function Pl(e,t){let n=Hc(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function Fl(e,t){let n=new kn(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function Il(e){for(let t=0;t{n(e)&&r.push({node:e,pos:t})}),r}function Rl(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function zl(e){return t=>Rl(t.$from,e)}function G(e,t,n){return e.config[t]===void 0&&e.parent?G(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?G(e.parent,t,n):null}):e.config[t]}function Bl(e){return e.map(e=>{let t=G(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...Bl(t())]:e}).flat(10)}function Vl(e,t){let n=ft.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function Hl(e){return typeof e==`function`}function K(e,t=void 0,...n){return Hl(e)?t?e.bind(t)(...n):e(...n):e}function Ul(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Wl(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function Gl(e){let t=[],{nodeExtensions:n,markExtensions:r}=Wl(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=G(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=G(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function Kl(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}return n&&t.push(n),t}function ql(e){let t=[],n=Kl(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...ql(n[e]),...ql(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function Jl(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>q(e,t),{})}function Yl(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function Xl(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):Yl(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function Zl(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&Ul(t)?!1:t!=null))}function Ql(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function $l(e,t){let n=Gl(e),{nodeExtensions:r,markExtensions:i}=Wl(e);return new Je({topNode:r.find(e=>G(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Zl({...e.reduce((e,t)=>{let n=G(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:K(G(r,`content`,a)),marks:K(G(r,`marks`,a)),group:K(G(r,`group`,a)),inline:K(G(r,`inline`,a)),atom:K(G(r,`atom`,a)),selectable:K(G(r,`selectable`,a)),draggable:K(G(r,`draggable`,a)),code:K(G(r,`code`,a)),whitespace:K(G(r,`whitespace`,a)),linebreakReplacement:K(G(r,`linebreakReplacement`,a)),defining:K(G(r,`defining`,a)),isolating:K(G(r,`isolating`,a)),attrs:Object.fromEntries(i.map(Ql))}),s=K(G(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Xl(e,i)));let c=G(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:Jl(e,i)}));let l=G(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Zl({...e.reduce((e,t)=>{let n=G(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:K(G(r,`inclusive`,a)),excludes:K(G(r,`excludes`,a)),group:K(G(r,`group`,a)),spanning:K(G(r,`spanning`,a)),code:K(G(r,`code`,a)),attrs:Object.fromEntries(i.map(Ql))}),s=K(G(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Xl(e,i)));let c=G(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:Jl(e,i)})),[r.name,o]}))})}function eu(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function tu(e){return e.sort((e,t)=>{let n=G(e,`priority`)||100,r=G(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function ru(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` + +`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function iu(e,t){return ru(e,{from:0,to:e.content.size},t)}function au(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function ou(e,t){let n=W(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function su(e,t){let n=Sl(typeof t==`string`?t:t.name,e.schema);return n===`node`?ou(e,t):n===`mark`?Pl(e,t):{}}function cu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function lu(e){let t=cu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function uu(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),lu(r)}function du(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=Vc(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var fu=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function pu(e,t){return t.nodes[e]||t.marks[e]||null}function mu(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var hu=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function gu(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?Hc(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>Rc(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>Rc(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function _u(e,t,n={}){if(!t)return _l(e,null,n)||gu(e,null,n);let r=Sl(t,e.schema);return r===`node`?_l(e,t,n):r===`mark`?gu(e,t,n):!1}var vu=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=zl(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function bu(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function xu(e,t){let{nodeExtensions:n}=Wl(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=K(G(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function Su(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(Su(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function Cu(e){return e instanceof M}var wu=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function Tu(e,t){let n=t.mapping.mapResult(e.position);return{position:new wu(n.pos),mapResult:n}}function Eu(e){return new wu(e)}function Du(e,t,n){let{selection:r}=t,i=null;if(Gc(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var Ou=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=Hc(e,r.schema);if(i)if(o){let e=Pl(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return Du(r,n,c)},ku=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Au=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=W(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>kr(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>kr(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},ju=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=Kc(e,0,n.content.size),i=M.create(n,r);t.setSelection(i)}return!0},Mu=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},Nu=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=j.atStart(n).from,o=j.atEnd(n).to,s=Kc(r,a,o),c=Kc(i,a,o),l=j.create(n,s,c);t.setSelection(l)}return!0},Pu=e=>({state:t,dispatch:n})=>Vr(W(e,t.schema))(t,n);function Fu(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var Iu=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=mu(l,s.node().type.name,s.node().attrs);if(a instanceof M&&a.node.isBlock)return!s.parentOffset||!tn(o,s.pos)?!1:(r&&(e&&Fu(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:Il(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=tn(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&tn(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof j&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&Fu(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},Lu=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=W(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=C.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=C.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(j.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...mu(d,u.type.name,u.attrs),...t},m={...mu(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!tn(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},Ru=(e,t)=>{let n=zl(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&rn(e.doc,n.pos)&&e.join(n.pos),!0},zu=(e,t)=>{let n=zl(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&rn(e.doc,r)&&e.join(r),!0};function Bu(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return j.between(r,i)}var Vu=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=W(e,o.schema),m=W(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=zl(e=>xu(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,ee=o.doc.content.content,te=ee.length===1?ee[0]:null,C=S&&te&&xu(te.type.name,d)?{node:te,pos:0,depth:0}:null,ne=x??C,re=!!x&&y.depth>=1&&y.depth-x.depth<=1,w=!!C;if((re||w)&&ne){if(ne.node.type===p)return S&&w?c().command(({tr:e,dispatch:t})=>{let n=Bu(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(xu(ne.node.type.name,d)&&p.validContent(ne.node.content))return c().command(()=>(a.setNodeMarkup(ne.pos,p),!0)).command(()=>Ru(a,p)).command(()=>zu(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>Ru(a,p)).command(()=>zu(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>Ru(a,p)).command(()=>zu(a,p)).run()},Hu=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=Hc(e,r.schema);return gu(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Uu=(e,t,n={})=>({state:r,commands:i})=>{let a=W(e,r.schema),o=W(t,r.schema),s=_l(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Wu=(e,t={})=>({state:n,commands:r})=>{let i=W(e,n.schema);return _l(n,i,t)?r.lift(i):r.wrapIn(i,t)},Gu=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},Ku=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},qu=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=Hc(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=Vc(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},Ju=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Yu=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Sl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=W(e,r.schema)),s===`mark`&&(o=Hc(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Xu=(e,t={})=>({state:n,dispatch:r})=>Or(W(e,n.schema),t)(n,r),Zu=(e,t={})=>({state:n,dispatch:r})=>Fr(W(e,n.schema),t)(n,r),Qu=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},$u=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},ed=(e,t)=>{if(Lc(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function td(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=hu(c)+i;return a.forEach(e=>{if(l)return;let a=ed(u,e.find);if(!a)return;let c=s.state.tr,d=Sc({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new Cc({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function nd(e){let{editor:t,rules:n}=e,r=new N({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:Vl(C.from(e),a.schema);let{from:i}=s;td({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return td({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&td({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?td({editor:t,from:a.pos,to:a.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function rd(e){return Object.prototype.toString.call(e).slice(8,-1)}function id(e){return rd(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function ad(e,t){let n={...e};return id(e)&&id(t)&&Object.keys(t).forEach(r=>{id(t[r])&&id(e[r])?n[r]=ad(e[r],t[r]):n[r]=t[r]}),n}var od=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...K(G(this,`addOptions`,{name:this.name}))||{}}}get storage(){return{...K(G(this,`addStorage`,{name:this.name,options:this.options}))||{}}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ad(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},sd=class e extends od{constructor(){super(...arguments),this.type=`mark`}static create(t={}){return new e(typeof t==`function`?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function cd(e){return typeof e==`number`}var ld=class{constructor(e){this.find=e.find,this.handler=e.handler}},ud=(e,t,n)=>{if(Lc(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function dd(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Cc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(e.type?.spec?.code||!(e.isText||e.isTextblock||e.isInline))return;let f=e.content?.size??e.nodeSize??0,p=Math.max(r,t),m=Math.min(i,t+f);p>=m||ud(e.isText?e.text||``:e.textBetween(p-t,m-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var fd=null,pd=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function md(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!dd({editor:t,state:Sc({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new N({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(fd=t)},i=()=>{fd&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=fd;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:Vl(C.from(t),r.schema);let{from:n}=d,i=n+t.length,a=pd(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!cd(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var hd=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=nu(e),this.schema=$l(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=G(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:pu(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this;return tu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:pu(t.name,this.schema)},r=[],i=G(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&G(t,`exitable`,n)&&(a.ArrowRight=()=>sd.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=gc(a);r.push(o);let s=G(t,`addInputRules`,n);if(bu(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=nd({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=G(t,`addPasteRules`,n);if(bu(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=md({editor:e,rules:t});r.push(...n)}}let l=G(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r})}get attributes(){return Gl(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Wl(this.extensions);return Object.fromEntries(t.filter(e=>!!G(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=G(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:W(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:Jl(r,n)})]:[]}))}dispatchTransaction(e){let{editor:t}=this;return tu([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pu(n.name,this.schema)},i=G(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return tu([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pu(n.name,this.schema)},i=G(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=Wl(this.extensions);return Object.fromEntries(t.filter(e=>!!G(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=G(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Hc(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=Jl(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{Gd(i,e,t)}})}]:[]}))}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:pu(e.name,this.schema)};e.type===`mark`&&(K(G(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=G(e,`onBeforeCreate`,t),r=G(e,`onCreate`,t),i=G(e,`onUpdate`,t),a=G(e,`onSelectionUpdate`,t),o=G(e,`onTransaction`,t),s=G(e,`onFocus`,t),c=G(e,`onBlur`,t),l=G(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};hd.resolve=nu,hd.sort=tu,hd.flatten=Bl,xc({},{ClipboardTextSerializer:()=>gd,Commands:()=>_d,Delete:()=>vd,Drop:()=>yd,Editable:()=>bd,FocusEvents:()=>Sd,Keymap:()=>Cd,Paste:()=>wd,Tabindex:()=>Td,TextDirection:()=>Ed,focusEventsPluginKey:()=>xd});var J=class e extends od{constructor(){super(...arguments),this.type=`extension`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},gd=J.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new N({key:new P(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=au(n);return ru(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),_d=J.create({name:`commands`,addCommands(){return{...wc}}}),vd=J.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){let n=()=>{var n;if(((n=this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n,e)??e.getMeta(`y-sync$`))return;let r=Fl(e.before,[e,...t]);uu(r).forEach(t=>{r.mapping.mapResult(t.oldRange.from).deletedAfter&&r.mapping.mapResult(t.oldRange.to).deletedBefore&&r.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,i)=>{let a=i+n.nodeSize-2,o=t.oldRange.from<=i&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:i,to:a,newFrom:r.mapping.map(i),newTo:r.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:r})})});let i=r.mapping;r.steps.forEach((t,n)=>{if(t instanceof Pt){let a=i.slice(n).map(t.from,-1),o=i.slice(n).map(t.to),s=i.invert().map(a,-1),c=i.invert().map(o),l=a>0?r.doc.nodeAt(a-1)?.marks.some(e=>e.eq(t.mark)):!1,u=r.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:a,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:r})}})};this.editor.options.coreExtensionOptions?.delete?.async??!0?setTimeout(n,0):n()}}),yd=J.create({name:`drop`,addProseMirrorPlugins(){return[new N({key:new P(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),bd=J.create({name:`editable`,addProseMirrorPlugins(){return[new N({key:new P(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),xd=new P(`focusEvents`),Sd=J.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new N({key:xd,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Cd=J.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:A.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Yc()||ml()?i:r},addProseMirrorPlugins(){return[new N({key:new P(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=A.atStart(t.doc).from,l=A.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!Su(n.doc))return;let u=n.tr,d=Sc({state:n,transaction:u}),{commands:f}=new Cc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),wd=J.create({name:`paste`,addProseMirrorPlugins(){return[new N({key:new P(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Td=J.create({name:`tabindex`,addProseMirrorPlugins(){return[new N({key:new P(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),Ed=J.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Wl(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new N({key:new P(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Dd=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},Od=`.ProseMirror { + position: relative; +} + +.ProseMirror { + word-wrap: break-word; + white-space: pre-wrap; + white-space: break-spaces; + -webkit-font-variant-ligatures: none; + font-variant-ligatures: none; + font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ +} + +.ProseMirror [contenteditable="false"] { + white-space: normal; +} + +.ProseMirror [contenteditable="false"] [contenteditable="true"] { + white-space: pre-wrap; +} + +.ProseMirror pre { + white-space: pre-wrap; +} + +img.ProseMirror-separator { + display: inline !important; + border: none !important; + margin: 0 !important; + width: 0 !important; + height: 0 !important; +} + +.ProseMirror-gapcursor { + display: none; + pointer-events: none; + position: absolute; + margin: 0; +} + +.ProseMirror-gapcursor:after { + content: ""; + display: block; + position: absolute; + top: -2px; + width: 20px; + border-top: 1px solid black; + animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; +} + +@keyframes ProseMirror-cursor-blink { + to { + visibility: hidden; + } +} + +.ProseMirror-hideselection *::selection { + background: transparent; +} + +.ProseMirror-hideselection *::-moz-selection { + background: transparent; +} + +.ProseMirror-hideselection * { + caret-color: transparent; +} + +.ProseMirror-focused .ProseMirror-gapcursor { + display: block; +}`;function kd(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var Ad=class extends Qu{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Tu,createMappablePosition:Eu},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc(),n=qc(t,this.options.autofocus);this.editorState=Jn.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=kd(Od,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Hl(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[bd,gd.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),_d,Sd,Cd,Td,yd,wd,vd,Ed.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new hd(e,this)}createCommandManager(){this.commandManager=new Cc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Ml(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=Ml(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new Zs(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return su(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return _u(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Vl(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` + +`,textSerializers:n={}}=e||{};return iu(this.state.doc,{blockSeparator:t,textSerializers:{...au(this.schema),...n}})}get isEmpty(){return Su(this.state.doc)}destroy(){this.emit(`destroy`),this.unmount(),this.removeAllListeners()}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new Dd(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function jd(e){return new $u({find:e.find,handler:({state:t,range:n,match:r})=>{let i=K(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(du(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Md(e){return new $u({find:e.find,handler:({state:t,range:n,match:r})=>{let i=K(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Nd(e){return new $u({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=K(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Pd(e){return new $u({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=K(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Gt(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&rn(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}function Fd(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof M){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}xc({},{createAtomBlockMarkdownSpec:()=>Rd,createBlockMarkdownSpec:()=>zd,createInlineMarkdownSpec:()=>Hd,parseAttributes:()=>Id,parseIndentedBlocks:()=>Ud,renderNestedMarkdownContent:()=>Wd,serializeAttributes:()=>Ld});function Id(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function Ld(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function Rd(e){let{nodeName:t,name:n,parseAttributes:r=Id,serializeAttributes:i=Ld,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function zd(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Id,serializeAttributes:a=Ld,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``} + +${t.renderChildren(e.content||[],` + +`)} + +:::`}}}function Bd(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i]=a||o,r=n.exec(e)}return t}function Vd(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function Hd(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Bd,serializeAttributes:a=Vd,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=a(u(e.attrs||{})),i=n?` ${n}`:``;return s?`[${l}${i}]`:`[${l}${i}]${t}[/${l}]`}}}function Ud(e,t,n){let r=e.split(` +`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e} +`;continue}else return}let l=t.extractItemData(c),{indentLevel:u,mainContent:d}=l;a=`${a}${e} +`;let f=[d];for(o+=1;oe.trim()!==``);if(t===-1)break;if((r[o+1+t].match(/^(\s*)/)?.[1]?.length||0)>u){f.push(e),a=`${a}${e} +`,o+=1;continue}else break}if((e.match(/^(\s*)/)?.[1]?.length||0)>u)f.push(e),a=`${a}${e} +`,o+=1;else break}let p,m=f.slice(1);if(m.length>0){let e=m.map(e=>e.slice(u+s)).join(` +`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function Wd(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=`${i}${t.renderChildren([a])}`;return o&&o.length>0&&o.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=r.split(` +`).map(e=>e?t.indent(e):t.indent(``)).join(` +`);s+=e.type===`paragraph`?` + +${n}`:` +${n}`}}),s}function Gd(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var Kd=class e extends od{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function qd(e){return new ld({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=K(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(du(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:Jd,getOwnPropertySymbols:Yd}=Object,{hasOwnProperty:Xd}=Object.prototype;function Zd(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function Qd(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function $d(e){return e?.[Symbol.toStringTag]}function ef(e){return Jd(e).concat(Yd(e))}var tf=Object.hasOwn||((e,t)=>Xd.call(e,t));function nf(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var rf=`__v`,af=`__o`,of=`_owner`,{getOwnPropertyDescriptor:sf,keys:cf}=Object;function lf(e,t){return e.byteLength===t.byteLength&&Sf(new Uint8Array(e),new Uint8Array(t))}function uf(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function df(e,t){return e.byteLength===t.byteLength&&Sf(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function ff(e,t){return nf(e.getTime(),t.getTime())}function pf(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function mf(e,t){return e===t}function hf(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var gf=nf;function _f(e,t,n){let r=cf(e),i=r.length;if(cf(t).length!==i)return!1;for(;i-- >0;)if(!wf(e,t,n,r[i]))return!1;return!0}function vf(e,t,n){let r=ef(e),i=r.length;if(ef(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!wf(e,t,n,a)||(o=sf(e,a),s=sf(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function yf(e,t){return nf(e.valueOf(),t.valueOf())}function bf(e,t){return e.source===t.source&&e.flags===t.flags}function xf(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function Sf(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function Cf(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function wf(e,t,n,r){return(r===of||r===af||r===rf)&&(e.$$typeof||t.$$typeof)?!0:tf(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var Tf=`[object ArrayBuffer]`,Ef=`[object Arguments]`,Df=`[object Boolean]`,Of=`[object DataView]`,kf=`[object Date]`,Af=`[object Error]`,jf=`[object Map]`,Mf=`[object Number]`,Nf=`[object Object]`,Pf=`[object RegExp]`,Ff=`[object Set]`,If=`[object String]`,Lf={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},Rf=`[object URL]`,zf=Object.prototype.toString;function Bf({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=zf.call(h);if(b===kf)return r(h,g,_);if(b===Pf)return u(h,g,_);if(b===jf)return o(h,g,_);if(b===Ff)return d(h,g,_);if(b===Nf)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===Rf)return p(h,g,_);if(b===Af)return i(h,g,_);if(b===Ef)return c(h,g,_);if(Lf[b])return f(h,g,_);if(b===Tf)return e(h,g,_);if(b===Of)return n(h,g,_);if(b===Df||b===Mf||b===If)return l(h,g,_);if(m){let e=m[b];if(!e){let t=$d(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Vf({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:lf,areArraysEqual:n?vf:uf,areDataViewsEqual:df,areDatesEqual:ff,areErrorsEqual:pf,areFunctionsEqual:mf,areMapsEqual:n?Zd(hf,vf):hf,areNumbersEqual:gf,areObjectsEqual:n?vf:_f,arePrimitiveWrappersEqual:yf,areRegExpsEqual:bf,areSetsEqual:n?Zd(xf,vf):xf,areTypedArraysEqual:n?Zd(Sf,vf):Sf,areUrlsEqual:Cf,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=Qd(r.areArraysEqual),t=Qd(r.areMapsEqual),n=Qd(r.areObjectsEqual),i=Qd(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Hf(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Uf({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Wf=Gf();Gf({strict:!0}),Gf({circular:!0}),Gf({circular:!0,strict:!0}),Gf({createInternalComparator:()=>nf}),Gf({strict:!0,createInternalComparator:()=>nf}),Gf({circular:!0,createInternalComparator:()=>nf}),Gf({circular:!0,createInternalComparator:()=>nf,strict:!0});function Gf(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=Bf(Vf(e));return Uf({circular:t,comparator:a,createState:r,equals:n?n(a):Hf(a),strict:i})}var Kf=n((e=>{var n=t(),r=x();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=n.useRef,c=n.useEffect,l=n.useMemo,u=n.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),qf=n(((e,t)=>{t.exports=Kf()}))(),Jf=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Yf=({contentComponent:e})=>{let t=(0,yc.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,d.jsx)(d.Fragment,{children:Object.values(t)})};function Xf(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:vc.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Zf=class extends u.Component{constructor(e){super(e),this.editorContentRef=u.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Xf(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{ref:Jf(t,this.editorContentRef),...n}),e?.contentComponent&&(0,d.jsx)(Yf,{contentComponent:e.contentComponent})]})}},Qf=(0,u.forwardRef)((e,t)=>{let n=u.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return u.createElement(Zf,{key:n,innerRef:t,...e})}),$f=u.memo(Qf),ep=typeof window<`u`?u.useLayoutEffect:u.useEffect,tp=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function np(e){let[t]=(0,u.useState)(()=>new tp(e.editor)),n=(0,qf.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Wf);return ep(()=>t.watch(e.editor),[e.editor,t]),(0,u.useDebugValue)(n),n}var rp=!1,ip=typeof window>`u`,ap=ip||!!(typeof window<`u`&&window.next),op=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(ip||ap){if(rp)throw Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&ip&&rp)throw Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){return new Ad({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length?e.extensions.every((e,n)=>e===t.extensions?.[n]):!1:e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function sp(e={},t=[]){let n=(0,u.useRef)(e);n.current=e;let[r]=(0,u.useState)(()=>new op(n)),i=(0,yc.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,u.useDebugValue)(i),(0,u.useEffect)(r.onRender(t)),np({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var cp=(0,u.createContext)({editor:null});cp.Consumer;var lp=(0,u.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),up=()=>(0,u.useContext)(lp);u.forwardRef((e,t)=>{let{onDragStart:n}=up();return(0,d.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),u.createContext({markViewContentRef:()=>{}});var dp=(0,u.createContext)({get editor(){throw Error(`useTiptap must be used within a provider`)}});dp.displayName=`TiptapContext`;var fp=()=>(0,u.useContext)(dp);function pp({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,u.useMemo)(()=>({editor:r}),[r]),a=(0,u.useMemo)(()=>({editor:r}),[r]);return(0,d.jsx)(cp.Provider,{value:a,children:(0,d.jsx)(dp.Provider,{value:i,children:n})})}pp.displayName=`Tiptap`;function mp({...e}){let{editor:t}=fp();return(0,d.jsx)($f,{editor:t,...e})}mp.displayName=`Tiptap.Content`,Object.assign(pp,{Content:mp});var hp=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},gp=/^\s*>\s$/,_p=Kd.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return hp(`blockquote`,{...q(this.options.HTMLAttributes,e),children:hp(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` +`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(` +`))}),n.join(` +> +`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Pd({find:gp,type:this.type})]}}),vp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,yp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,bp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Sp=sd.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return hp(`strong`,{...q(this.options.HTMLAttributes,e),children:hp(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[jd({find:vp,type:this.type}),jd({find:bp,type:this.type})]},addPasteRules(){return[qd({find:yp,type:this.type}),qd({find:xp,type:this.type})]}}),Cp=/(^|[^`])`([^`]+)`(?!`)$/,wp=/(^|[^`])`([^`]+)`(?!`)/g,Tp=sd.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[jd({find:Cp,type:this.type})]},addPasteRules(){return[qd({find:wp,type:this.type})]}}),Ep=4,Dp=/^```([a-z]+)?[\s\n]$/,Op=/^~~~([a-z]+)?[\s\n]$/,kp=Kd.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ep,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,q(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` +`):`\`\`\`${r} + +\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ep,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` +`,` +`).split(` +`).map(e=>o+e).join(` +`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ep,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` +`,` +`).split(` +`),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` +`,` +`).split(` +`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(` +`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` + +`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(A.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Nd({find:Dp,type:this.type,getAttributes:e=>({language:e[1]})}),Nd({find:Op,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new N({key:new P(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` +`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(j.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Ap=Kd.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` + +`):``}),jp=Kd.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,q(this.options.HTMLAttributes,e)]},renderText(){return` +`},renderMarkdown:()=>` +`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Mp=Kd.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,q(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Nd({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Np=Kd.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,q(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Fd(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return Cu(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(j.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(M.create(t.doc,n.pos)):t.setSelection(j.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(j.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Md({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Pp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Fp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ip=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Lp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Rp=sd.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,q(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[jd({find:Pp,type:this.type}),jd({find:Ip,type:this.type})]},addPasteRules(){return[qd({find:Fp,type:this.type}),qd({find:Lp,type:this.type})]}}),zp=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Bp=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Vp=`numeric`,Hp=`ascii`,Up=`alpha`,Wp=`asciinumeric`,Gp=`alphanumeric`,Kp=`domain`,qp=`emoji`,Jp=`scheme`,Yp=`slashscheme`,Xp=`whitespace`;function Zp(e,t){return e in t||(t[e]=[]),t[e]}function Qp(e,t,n){t[Vp]&&(t[Wp]=!0,t[Gp]=!0),t[Hp]&&(t[Wp]=!0,t[Up]=!0),t[Wp]&&(t[Gp]=!0),t[Up]&&(t[Gp]=!0),t[Gp]&&(t[Kp]=!0),t[qp]&&(t[Kp]=!0);for(let r in t){let t=Zp(r,n);t.indexOf(e)<0&&t.push(e)}}function $p(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function em(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}em.groups={},em.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),X=(e,t,n,r,i)=>e.tr(t,n,r,i),tm=(e,t,n,r,i)=>e.ts(t,n,r,i),Z=(e,t,n,r,i)=>e.tt(t,n,r,i),nm=`WORD`,rm=`UWORD`,im=`ASCIINUMERICAL`,am=`ALPHANUMERICAL`,om=`LOCALHOST`,sm=`TLD`,cm=`UTLD`,lm=`SCHEME`,um=`SLASH_SCHEME`,dm=`NUM`,fm=`WS`,pm=`NL`,mm=`OPENBRACE`,hm=`CLOSEBRACE`,gm=`OPENBRACKET`,_m=`CLOSEBRACKET`,vm=`OPENPAREN`,ym=`CLOSEPAREN`,bm=`OPENANGLEBRACKET`,xm=`CLOSEANGLEBRACKET`,Sm=`FULLWIDTHLEFTPAREN`,Cm=`FULLWIDTHRIGHTPAREN`,wm=`LEFTCORNERBRACKET`,Tm=`RIGHTCORNERBRACKET`,Em=`LEFTWHITECORNERBRACKET`,Dm=`RIGHTWHITECORNERBRACKET`,Om=`FULLWIDTHLESSTHAN`,km=`FULLWIDTHGREATERTHAN`,Am=`AMPERSAND`,jm=`APOSTROPHE`,Mm=`ASTERISK`,Nm=`AT`,Pm=`BACKSLASH`,Fm=`BACKTICK`,Im=`CARET`,Lm=`COLON`,Rm=`COMMA`,zm=`DOLLAR`,Bm=`DOT`,Vm=`EQUALS`,Hm=`EXCLAMATION`,Um=`HYPHEN`,Wm=`PERCENT`,Gm=`PIPE`,Km=`PLUS`,qm=`POUND`,Jm=`QUERY`,Ym=`QUOTE`,Xm=`FULLWIDTHMIDDLEDOT`,Zm=`SEMI`,Qm=`SLASH`,$m=`TILDE`,eh=`UNDERSCORE`,th=`EMOJI`,nh=`SYM`,rh=Object.freeze({__proto__:null,ALPHANUMERICAL:am,AMPERSAND:Am,APOSTROPHE:jm,ASCIINUMERICAL:im,ASTERISK:Mm,AT:Nm,BACKSLASH:Pm,BACKTICK:Fm,CARET:Im,CLOSEANGLEBRACKET:xm,CLOSEBRACE:hm,CLOSEBRACKET:_m,CLOSEPAREN:ym,COLON:Lm,COMMA:Rm,DOLLAR:zm,DOT:Bm,EMOJI:th,EQUALS:Vm,EXCLAMATION:Hm,FULLWIDTHGREATERTHAN:km,FULLWIDTHLEFTPAREN:Sm,FULLWIDTHLESSTHAN:Om,FULLWIDTHMIDDLEDOT:Xm,FULLWIDTHRIGHTPAREN:Cm,HYPHEN:Um,LEFTCORNERBRACKET:wm,LEFTWHITECORNERBRACKET:Em,LOCALHOST:om,NL:pm,NUM:dm,OPENANGLEBRACKET:bm,OPENBRACE:mm,OPENBRACKET:gm,OPENPAREN:vm,PERCENT:Wm,PIPE:Gm,PLUS:Km,POUND:qm,QUERY:Jm,QUOTE:Ym,RIGHTCORNERBRACKET:Tm,RIGHTWHITECORNERBRACKET:Dm,SCHEME:lm,SEMI:Zm,SLASH:Qm,SLASH_SCHEME:um,SYM:nh,TILDE:$m,TLD:sm,UNDERSCORE:eh,UTLD:cm,UWORD:rm,WORD:nm,WS:fm}),ih=/[a-z]/,ah=/\p{L}/u,oh=/\p{Emoji}/u,sh=/\d/,ch=/\s/,lh=`\r`,uh=` +`,dh=`️`,fh=`‍`,ph=``,mh=null,hh=null;function gh(e=[]){let t={};em.groups=t;let n=new em;mh??=bh(zp),hh??=bh(Bp),Z(n,`'`,jm),Z(n,`{`,mm),Z(n,`}`,hm),Z(n,`[`,gm),Z(n,`]`,_m),Z(n,`(`,vm),Z(n,`)`,ym),Z(n,`<`,bm),Z(n,`>`,xm),Z(n,`(`,Sm),Z(n,`)`,Cm),Z(n,`「`,wm),Z(n,`」`,Tm),Z(n,`『`,Em),Z(n,`』`,Dm),Z(n,`<`,Om),Z(n,`>`,km),Z(n,`&`,Am),Z(n,`*`,Mm),Z(n,`@`,Nm),Z(n,"`",Fm),Z(n,`^`,Im),Z(n,`:`,Lm),Z(n,`,`,Rm),Z(n,`$`,zm),Z(n,`.`,Bm),Z(n,`=`,Vm),Z(n,`!`,Hm),Z(n,`-`,Um),Z(n,`%`,Wm),Z(n,`|`,Gm),Z(n,`+`,Km),Z(n,`#`,qm),Z(n,`?`,Jm),Z(n,`"`,Ym),Z(n,`/`,Qm),Z(n,`;`,Zm),Z(n,`~`,$m),Z(n,`_`,eh),Z(n,`\\`,Pm),Z(n,`・`,Xm);let r=X(n,sh,dm,{[Vp]:!0});X(r,sh,r);let i=X(r,ih,im,{[Wp]:!0}),a=X(r,ah,am,{[Gp]:!0}),o=X(n,ih,nm,{[Hp]:!0});X(o,sh,i),X(o,ih,o),X(i,sh,i),X(i,ih,i);let s=X(n,ah,rm,{[Up]:!0});X(s,ih),X(s,sh,a),X(s,ah,s),X(a,sh,a),X(a,ih),X(a,ah,a);let c=Z(n,uh,pm,{[Xp]:!0}),l=Z(n,lh,fm,{[Xp]:!0}),u=X(n,ch,fm,{[Xp]:!0});Z(n,ph,u),Z(l,uh,c),Z(l,ph,u),X(l,ch,u),Z(u,lh),Z(u,uh),X(u,ch,u),Z(u,ph,u);let d=X(n,oh,th,{[qp]:!0});Z(d,`#`),X(d,oh,d),Z(d,dh,d);let f=Z(d,fh);Z(f,`#`),X(f,oh,d);let p=[[ih,o],[sh,i]],m=[[ih,null],[ah,s],[sh,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[Kp]=!0:ih.test(r)?sh.test(r)?i[Wp]=!0:i[Hp]=!0:i[Vp]=!0,tm(n,r,r,i)}return tm(n,`localhost`,om,{ascii:!0}),n.jd=new em(nh),{start:n,tokens:Object.assign({groups:t},rh)}}function _h(e,t){let n=vh(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function vh(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function yh(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var xh={defaultProtocol:`http`,events:null,format:Ch,formatHref:Ch,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Sh(e,t=null){let n=Object.assign({},xh);e&&(n=Object.assign(n,e instanceof Sh?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;en?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=xh.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Th(e,t){class n extends wh{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Eh=Th(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Dh=Th(`text`),Oh=Th(`nl`),kh=Th(`url`,{isLink:!0,toHref(e=xh.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==om&&e[1].t===Lm}}),Ah=e=>new em(e);function jh({groups:e}){let t=e.domain.concat([Am,Mm,Nm,Pm,Fm,Im,zm,Vm,Um,dm,Wm,Gm,Km,qm,Qm,nh,$m,eh]),n=[jm,Lm,Rm,Bm,Hm,Wm,Jm,Ym,Zm,bm,xm,mm,hm,_m,gm,vm,ym,Sm,Cm,wm,Tm,Em,Dm,Om,km],r=[Am,jm,Mm,Pm,Fm,Im,zm,Vm,Um,mm,hm,Wm,Gm,Km,qm,Jm,Qm,nh,$m,eh],i=Ah(),a=Z(i,$m);Y(a,r,a),Y(a,e.domain,a);let o=Ah(),s=Ah(),c=Ah();Y(i,e.domain,o),Y(i,e.scheme,s),Y(i,e.slashscheme,c),Y(o,r,a),Y(o,e.domain,o);let l=Z(o,Nm);Z(a,Nm,l),Z(s,Nm,l),Z(c,Nm,l);let u=Z(a,Bm);Y(u,r,a),Y(u,e.domain,a);let d=Ah();Y(l,e.domain,d),Y(d,e.domain,d);let f=Z(d,Bm);Y(f,e.domain,d);let p=Ah(Eh);Y(f,e.tld,p),Y(f,e.utld,p),Z(l,om,p);let m=Z(d,Um);Z(m,Um,m),Y(m,e.domain,d),Y(p,e.domain,d),Z(p,Bm,f),Z(p,Um,m),Y(Z(p,Lm),e.numeric,Eh);let h=Z(o,Um),g=Z(o,Bm);Z(h,Um,h),Y(h,e.domain,o),Y(g,r,a),Y(g,e.domain,o);let _=Ah(kh);Y(g,e.tld,_),Y(g,e.utld,_),Y(_,e.domain,o),Y(_,r,a),Z(_,Bm,g),Z(_,Um,h),Z(_,Nm,l);let v=Z(_,Lm),y=Ah(kh);Y(v,e.numeric,y);let b=Ah(kh),x=Ah();Y(b,t,b),Y(b,n,x),Y(x,t,b),Y(x,n,x),Z(_,Qm,b),Z(y,Qm,b);let S=Z(s,Lm),ee=Z(Z(Z(c,Lm),Qm),Qm);Y(s,e.domain,o),Z(s,Bm,g),Z(s,Um,h),Y(c,e.domain,o),Z(c,Bm,g),Z(c,Um,h),Y(S,e.domain,b),Z(S,Qm,b),Z(S,Jm,b),Y(ee,e.domain,b),Y(ee,t,b),Z(ee,Qm,b);let te=[[mm,hm],[gm,_m],[vm,ym],[bm,xm],[Sm,Cm],[wm,Tm],[Em,Dm],[Om,km]];for(let e=0;e=0&&f++,i++,u++;if(f<0)i-=u,i0&&(a.push(Nh(Dh,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Nh(e,t,r))}}return o.length>0&&a.push(Nh(Dh,t,o)),a}function Nh(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Ph=typeof console<`u`&&console&&console.warn||(()=>{}),Fh=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Ih(){return em.groups={},Q.scanner=null,Q.parser=null,Q.tokenQueue=[],Q.pluginQueue=[],Q.customSchemes=[],Q.initialized=!1,Q}function Lh(e,t=!1){if(Q.initialized&&Ph(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Fh}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. +1. Must only contain digits, lowercase ASCII letters or "-" +2. Cannot start or end with "-" +3. "-" cannot repeat`);Q.customSchemes.push([e,t])}function Rh(){Q.scanner=gh(Q.customSchemes);for(let e=0;e{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(uu(Fl(n.doc,[...t])).forEach(({newRange:t})=>{let n=Ll(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Uh.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Hh).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=zh(n).map(t=>t.toObject(e.defaultProtocol));if(!Gh(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{du(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function qh(e){return new N({key:new P(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=su(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}function Jh(e){return new N({key:new P(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Bh(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function Yh(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(Wh,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,`i`))}var Xh=sd.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){Lh(e);return}Lh(e.scheme,e.optionalSlashes)})},onDestroy(){Ih()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!Yh(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!Yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!Yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,q(this.options.HTMLAttributes,e),0]:[`a`,q(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!Yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!Yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[qd({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=Bh(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!Yh(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(Kh({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!Yh(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(qh({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(Jh({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),Zh=Xh,Qh=Object.defineProperty,$h=(e,t)=>{for(var n in t)Qh(e,n,{get:t[n],enumerable:!0})},eg=`listItem`,tg=`textStyle`,ng=/^\s*([-+*])\s$/,rg=Kd.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(eg,this.editor.getAttributes(tg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Pd({find:ng,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Pd({find:ng,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(tg),editor:this.editor})),[e]}}),ig=Kd.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0)if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>Wd(e,t,e=>e.parentType===`bulletList`?`- `:e.parentType===`orderedList`?`${(e.meta?.parentAttrs?.start||1)+e.index}. `:`- `,n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});$h({},{findListItemPos:()=>ag,getNextListDepth:()=>og,handleBackspace:()=>ug,handleDelete:()=>pg,hasListBefore:()=>sg,hasListItemAfter:()=>mg,hasListItemBefore:()=>cg,listItemHasSubList:()=>lg,nextListIsDeeper:()=>dg,nextListIsHigher:()=>fg});var ag=(e,t)=>{let{$from:n}=t.selection,r=W(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},og=(e,t)=>{let n=ag(e,t);if(!n)return!1;let[,r]=fu(t,e,n.$pos.pos+4);return r},sg=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},cg=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return!(r.index()===0||r.nodeBefore?.type.name!==e)},lg=(e,t,n)=>{if(!n)return!1;let r=W(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},ug=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!_l(e.state,t)&&sg(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!_l(e.state,t)||!yu(e.state))return!1;let r=ag(t,e.state);if(!r)return!1;let i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=lg(t,e.state,i);return cg(t,e.state)&&!a?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},dg=(e,t)=>{let n=og(e,t),r=ag(e,t);return!r||!n?!1:n>r.depth},fg=(e,t)=>{let n=og(e,t),r=ag(e,t);return!r||!n?!1:n{if(!_l(e.state,t)||!vu(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:dg(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():fg(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},mg=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return!(r.index()===r.parent.childCount-1||r.nodeAfter?.type.name!==e)},hg=J.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&pg(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&pg(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&ug(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&ug(e,n,r)&&(t=!0)}),t}}}}),gg=/^(\s*)(\d+)\.\s+(.*)$/,_g=/^\s/;function vg(e){let t=e.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}function yg(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&vg(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function bg(e){let t=[],n=0,r=0;for(;nt;)f.push(e[d]),d+=1;if(f.length>0){let e=xg(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,items:e,raw:f.map(e=>e.raw).join(` +`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function Sg(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var Cg=`listItem`,wg=`textStyle`,Tg=/^(\d+)\.\s$/,Eg=Kd.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,q(this.options.HTMLAttributes,n),0]:[`ol`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.items?Sg(e.items,t):[];return n===1?{type:`orderedList`,content:r}:{type:`orderedList`,attrs:{start:n},content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(` +`),[i,a]=bg(r);if(i.length===0)return;let o=xg(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Cg,this.editor.getAttributes(wg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=Pd({find:Tg,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Pd({find:Tg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(wg)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),Dg=/^\s*(\[([( |x])?\])\s$/,Og=Kd.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,q(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>Wd(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Jl(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Pd({find:Dg,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),kg=Kd.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,q(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=Ud(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=Ud(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});J.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(rg.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ig.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(hg.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Eg.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Og.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(kg.configure(this.options.taskList)),e}});var Ag=` `,jg=`\xA0`,Mg=Kd.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,q(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Ag||n[0].text===Ag||n[0].raw===jg||n[0].text===jg)&&r.length===1&&r[0].type===`text`&&(r[0].text===Ag||r[0].text===jg)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?Ag:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ng=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Pg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Fg=sd.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[jd({find:Ng,type:this.type})]},addPasteRules(){return[qd({find:Pg,type:this.type})]}}),Ig=Kd.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Lg=sd.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,q(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Rg=Lg;function zg(e={}){return new N({view(t){return new Bg(t,e)}})}var Bg=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=un(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},Vg=class e extends A{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):A.near(r)}content(){return E.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Hg(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Wg(e)||!Gg(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!M.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};Vg.prototype.visible=!1,Vg.findFrom=Vg.findGapCursorFrom,A.jsonID(`gapcursor`,Vg);var Hg=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Vg.valid(t)?new Vg(t):A.near(t)}};function Ug(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Wg(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Ug(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Gg(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Ug(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Kg(){return new N({props:{decorations:Zg,createSelectionBetween(e,t,n){return t.pos==n.pos&&Vg.valid(n)?new Vg(n):null},handleClick:Yg,handleKeyDown:qg,handleDOMEvents:{beforeinput:Xg}}})}var qg=_c({ArrowLeft:Jg(`horiz`,-1),ArrowRight:Jg(`horiz`,1),ArrowUp:Jg(`vert`,-1),ArrowDown:Jg(`vert`,1)});function Jg(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof j){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=Vg.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Vg(c))),!0):!1}}function Yg(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Vg.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&M.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Vg(r))),!0)}function Xg(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Vg))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=C.empty;for(let e=r.length-1;e>=0;e--)i=C.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new E(i,0,0));return a.setSelection(j.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Zg(e){if(!(e.selection instanceof Vg))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,V.create(e.doc,[gs.widget(e.selection.head,t,{key:`gapcursor`})])}var Qg=200,$=function(){};$.prototype.append=function(e){return e.length?(e=$.from(e),!this.length&&e||e.length=t?$.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},$.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},$.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},$.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},$.from=function(e){return e instanceof $?e:e&&e.length?new $g(e):$.empty};var $g=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Qg)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Qg)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}($);$.empty=new $g([]);var e_=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}($),t_=500,n_=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new i_(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new i_(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;eo_&&(s=r_(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new At;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new i_(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new i_(i,o,l))}else r.push(new i_(i))},i);let l=[];for(let e=n;et_&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new i_(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e($.from(i.reverse()),a)}};n_.empty=new n_($.empty,0);function r_(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var i_=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},a_=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},o_=20;function s_(e,t,n,r){let i=n.getMeta(h_),a;if(i)return i.historyState;n.getMeta(g_)&&(e=new a_(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(h_))return o.getMeta(h_).redo?new a_(e.done.addTransform(n,void 0,r,m_(t)),e.undone,l_(n.mapping.maps),e.prevTime,e.prevComposition):new a_(e.done,e.undone.addTransform(n,void 0,r,m_(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!c_(n,e.prevRanges)),s=o?u_(e.prevRanges,n.mapping):l_(n.mapping.maps);return new a_(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,m_(t)),n_.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new a_(e.done.rebased(n,a),e.undone.rebased(n,a),u_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new a_(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),u_(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function c_(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function l_(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function u_(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=h_.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=d_(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var y_=v_(!1,!0),b_=v_(!0,!0);J.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new N({key:new P(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var x_=J.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[zg(this.options)]}});J.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new N({key:new P(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return V.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(gs.node(t,t+e.nodeSize,{class:this.options.className}))}),V.create(e,a)}}})]}});var S_=J.create({name:`gapCursor`,addProseMirrorPlugins(){return[Kg()]},extendNodeSchema(e){return{allowGapCursor:K(G(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),C_=`placeholder`;function w_(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}J.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:C_,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${w_(this.options.dataAttribute)}`:`data-${C_}`;return[new N({key:new P(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&Su(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=gs.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),V.create(t,a)}}})]}}),J.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new N({key:new P(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||Cu(n.selection)||e.view.dragging?null:V.create(n.doc,[gs.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function T_({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var E_=J.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new P(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new N({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!T_({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!T_({node:r,types:n})}}})]}}),D_=J.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>y_(e,t),redo:()=>({state:e,dispatch:t})=>b_(e,t)}},addProseMirrorPlugins(){return[__(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),O_=J.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(Sp.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(_p.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(rg.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Tp.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(kp.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Ap.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(x_.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(S_.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(jp.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Mp.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(D_.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Np.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Rp.configure(this.options.italic)),this.options.listItem!==!1&&e.push(ig.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(hg.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(Xh.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(Eg.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(Mg.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(Fg.configure(this.options.strike)),this.options.text!==!1&&e.push(Ig.configure(this.options.text)),this.options.underline!==!1&&e.push(Lg.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(E_.configure(this.options?.trailingNode)),e}}),k_=`inline-flex items-center justify-center min-w-[28px] h-7 px-2 rounded text-xs border border-transparent hover:bg-muted`,A_=k_+` bg-muted border-border`,j_=`inline-block w-px h-5 bg-border mx-1 align-middle`;function M_({on:e,active:t,title:n,children:r}){return(0,d.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),e()},className:t?A_:k_,title:n,children:r})}function N_({editor:e,open:t,setOpen:n}){let[r,i]=(0,u.useState)(``);if((0,u.useEffect)(()=>{t&&i(e.getAttributes(`link`).href||``)},[t,e]),!t)return null;function a(){let t=r.trim();t&&e.chain().focus().extendMarkRange(`link`).setLink({href:t}).run(),n(!1)}function o(){e.chain().focus().unsetLink().run(),n(!1)}return(0,d.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 border-t border-border bg-muted/30`,children:[(0,d.jsx)(`input`,{type:`url`,autoFocus:!0,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a()),e.key===`Escape`&&(e.preventDefault(),n(!1))},placeholder:`https://`,className:`flex-1 rounded border border-input bg-background px-2 py-1 text-xs`}),(0,d.jsx)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),a()},className:`rounded bg-primary text-primary-foreground px-2 py-1 text-xs`,children:`Apply`}),(0,d.jsx)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),o()},className:`rounded border border-border px-2 py-1 text-xs`,children:`Remove`}),(0,d.jsx)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),n(!1)},className:`rounded border border-border px-2 py-1 text-xs`,children:`✕`})]})}function P_({editor:e,variant:t}){let[n,r]=(0,u.useState)(!1),i=(0,u.useCallback)(()=>r(e=>!e),[]),a=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleBold().run(),active:e.isActive(`bold`),title:`Bold`,children:(0,d.jsx)(`strong`,{children:`B`})}),o=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleItalic().run(),active:e.isActive(`italic`),title:`Italic`,children:(0,d.jsx)(`em`,{children:`I`})}),s=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleUnderline().run(),active:e.isActive(`underline`),title:`Underline`,children:(0,d.jsx)(`span`,{style:{textDecoration:`underline`},children:`U`})}),c=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleStrike().run(),active:e.isActive(`strike`),title:`Strike`,children:(0,d.jsx)(`span`,{style:{textDecoration:`line-through`},children:`S`})}),l=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleHeading({level:2}).run(),active:e.isActive(`heading`,{level:2}),title:`Heading 2`,children:`H2`}),f=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleHeading({level:3}).run(),active:e.isActive(`heading`,{level:3}),title:`Heading 3`,children:`H3`}),p=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleBulletList().run(),active:e.isActive(`bulletList`),title:`Bullet list`,children:`•`}),m=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleOrderedList().run(),active:e.isActive(`orderedList`),title:`Numbered list`,children:`1.`}),h=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleBlockquote().run(),active:e.isActive(`blockquote`),title:`Quote`,children:`❝`}),g=(0,d.jsx)(M_,{on:()=>e.chain().focus().toggleCodeBlock().run(),active:e.isActive(`codeBlock`),title:`Code`,children:``}),_=(0,d.jsx)(M_,{on:i,active:e.isActive(`link`),title:`Link`,children:`🔗`}),v=(0,d.jsx)(M_,{on:()=>e.chain().focus().unsetAllMarks().clearNodes().run(),active:!1,title:`Clear formatting`,children:`⌫`}),y;return y=t===`option`?(0,d.jsxs)(d.Fragment,{children:[a,o,_]}):t===`mini`?(0,d.jsxs)(d.Fragment,{children:[a,o,p,_]}):(0,d.jsxs)(d.Fragment,{children:[a,o,s,c,(0,d.jsx)(`span`,{className:j_}),l,f,(0,d.jsx)(`span`,{className:j_}),p,m,h,g,(0,d.jsx)(`span`,{className:j_}),_,(0,d.jsx)(`span`,{className:j_}),v]}),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`flex flex-wrap items-center gap-0.5 px-2 py-1 bg-muted/40 border-b border-border`,children:y}),(0,d.jsx)(N_,{editor:e,open:n,setOpen:r})]})}function F_({value:e,onChange:t,variant:n=`default`,placeholder:r,minHeight:i=`min-h-[240px]`,testId:a}){let o=sp({extensions:[O_.configure({heading:{levels:[2,3]}}),Rg,Zh.configure({openOnClick:!1,HTMLAttributes:{rel:`noopener noreferrer`,target:`_blank`}})],content:e,onUpdate:({editor:e})=>t(e.getHTML()),editorProps:{attributes:{class:`prose prose-sm max-w-none dark:prose-invert px-3 py-2 `+i+` focus:outline-none`,"data-placeholder":r||``}}});return(0,u.useEffect)(()=>{o&&e!==o.getHTML()&&o.commands.setContent(e||``,{emitUpdate:!1})},[e,o]),o?(0,d.jsxs)(`div`,{className:`rounded-md border border-input bg-background overflow-hidden`,"data-testid":a,children:[(0,d.jsx)(P_,{editor:o,variant:n}),(0,d.jsx)($f,{editor:o})]}):null}var I_=`rounded-md border border-input bg-background px-2 py-1 text-sm`,L_=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-medium hover:bg-muted disabled:opacity-50`,R_=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-2 py-1 text-xs font-medium disabled:opacity-50`;function z_(){return{question_text:``,question_type:`mcq`,explanation:``,options:[{option_text:``,is_correct:!0},{option_text:``,is_correct:!1}]}}function B_(e){let t=c(),[n,r]=(0,u.useState)(null),a=i({mutationFn:t=>o.post(`/api/learning-admin/content/`+e.contentId+`/questions`,t),onSuccess:()=>t.invalidateQueries({queryKey:[`cms-content-detail`,e.contentId]})}),s=i({mutationFn:e=>o.put(`/api/learning-admin/questions/`+e.id,e),onSuccess:()=>t.invalidateQueries({queryKey:[`cms-content-detail`,e.contentId]})}),f=i({mutationFn:e=>o.delete(`/api/learning-admin/questions/`+e),onSuccess:()=>t.invalidateQueries({queryKey:[`cms-content-detail`,e.contentId]})});function p(t,n){e.onChange(e.questions.map((e,r)=>r===t?{...e,...n}:e))}function m(t,n,r){e.onChange(e.questions.map((e,i)=>{if(i!==t)return e;let a=(e.options||[]).map((e,t)=>t===n?{...e,...r}:e);return{...e,options:a}}))}function h(){e.onChange([...e.questions,z_()])}function g(t){e.onChange(e.questions.map((e,n)=>n===t?{...e,options:[...e.options||[],{option_text:``,is_correct:!1}]}:e))}function _(t,n){e.onChange(e.questions.map((e,r)=>r===t?{...e,options:(e.options||[]).filter((e,t)=>t!==n)}:e))}function v(t){let n=e.questions[t];n.id?s.mutate(n):a.mutate(n)}function y(t){let n=e.questions[t];n.id&&f.mutate(n.id),e.onChange(e.questions.filter((e,n)=>n!==t)),r(null)}return(0,d.jsxs)(`div`,{className:`space-y-3`,"data-testid":`cms-questions-editor`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`h4`,{className:`text-sm font-semibold`,children:[`Questions (`,e.questions.length,`)`]}),(0,d.jsx)(`button`,{type:`button`,onClick:h,className:R_,children:`+ Add question`})]}),e.questions.length===0&&(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground italic`,children:`No questions yet.`}),e.questions.map((t,n)=>(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/20 p-3 space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsxs)(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:[`Q`,n+1]}),(0,d.jsxs)(`select`,{className:I_+` text-xs`,value:t.question_type,onChange:e=>p(n,{question_type:e.target.value}),children:[(0,d.jsx)(`option`,{value:`mcq`,children:`MCQ (single answer)`}),(0,d.jsx)(`option`,{value:`multi`,children:`Multi-select`}),(0,d.jsx)(`option`,{value:`true_false`,children:`True/False`})]}),(0,d.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>v(n),className:R_,disabled:a.isPending||s.isPending,children:`Save Q`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(n),className:L_+` text-destructive`,children:`Del`})]})]}),(0,d.jsx)(F_,{value:t.question_text,onChange:e=>p(n,{question_text:e}),variant:`mini`,minHeight:`min-h-[60px]`,placeholder:`Question text`}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(t.options||[]).map((r,i)=>(0,d.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,d.jsx)(`input`,{type:t.question_type===`multi`?`checkbox`:`radio`,name:`q-`+n+`-correct`,checked:r.is_correct,onChange:r=>{t.question_type===`multi`?m(n,i,{is_correct:r.target.checked}):e.onChange(e.questions.map((e,t)=>{if(t!==n)return e;let r=(e.options||[]).map((e,t)=>({...e,is_correct:t===i}));return{...e,options:r}}))},className:`mt-2`}),(0,d.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,d.jsx)(F_,{value:r.option_text,onChange:e=>m(n,i,{option_text:e}),variant:`option`,minHeight:`min-h-[40px]`,placeholder:`Option `+(i+1)}),(0,d.jsx)(F_,{value:r.explanation||``,onChange:e=>m(n,i,{explanation:e}),variant:`option`,minHeight:`min-h-[32px]`,placeholder:`Per-option explanation (optional)`})]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(n,i),className:`text-xs text-destructive mt-2`,children:`×`})]},i)),(0,d.jsx)(`button`,{type:`button`,onClick:()=>g(n),className:L_,children:`+ Option`})]}),(0,d.jsx)(F_,{value:t.explanation||``,onChange:e=>p(n,{explanation:e}),variant:`mini`,minHeight:`min-h-[40px]`,placeholder:`Question explanation (shown after answering)`})]},n)),(0,d.jsx)(l,{open:n!==null,title:`Delete question?`,body:`The question and its options will be removed.`,confirmText:`Delete`,danger:!0,busy:f.isPending,onCancel:()=>r(null),onConfirm:()=>{n!==null&&y(n)}})]})}var V_=` +--- +`,H_=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,U_=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`;function W_(e){return e?e.split(/\n-{3,}\n/):[``]}function G_({value:e,onChange:t}){let n=(0,u.useMemo)(()=>W_(e),[e]),[r,i]=(0,u.useState)(0),a=Math.min(r,n.length-1);function o(e){t(e.join(V_))}function s(e,t){let r=n.slice();r[e]=t,o(r)}function c(e){let t=n.slice();t.splice(e+1,0,``),o(t),i(e+1)}function l(e){if(n.length<=1){o([``]),i(0);return}let t=n.slice();t.splice(e,1),o(t),i(Math.max(0,Math.min(r,t.length-1)))}function f(e,t){let r=e+t;if(r<0||r>=n.length)return;let a=n.slice();[a[e],a[r]]=[a[r],a[e]],o(a),i(r)}return(0,d.jsxs)(`div`,{className:`rounded-md border border-input bg-background`,"data-testid":`cms-slide-editor`,children:[(0,d.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 border-b border-border bg-muted/40`,children:[(0,d.jsxs)(`span`,{className:`text-xs font-semibold text-muted-foreground`,children:[`Slide `,a+1,` of `,n.length]}),(0,d.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 ml-2`,children:n.map((e,t)=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>i(t),className:`w-7 h-7 rounded text-xs border `+(t===a?`bg-primary text-primary-foreground border-primary`:`bg-background border-border hover:bg-muted`),"aria-label":`Slide `+(t+1),children:t+1},t))}),(0,d.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>f(a,-1),disabled:a===0,className:H_,children:`← Move`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>f(a,1),disabled:a===n.length-1,className:H_,children:`Move →`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>c(a),className:U_,children:`+ Slide`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>l(a),className:H_+` text-destructive`,children:`Remove`})]})]}),(0,d.jsx)(F_,{value:n[a]||``,onChange:e=>s(a,e),variant:`default`,minHeight:`min-h-[260px]`,placeholder:`Slide content…`},a)]})}var K_=`rounded-md border border-input bg-background px-2 py-1 text-sm`,q_=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,J_=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`;function Y_(e){let[t,n]=(0,u.useState)(`topic`),[r,i]=(0,u.useState)(``),[a,c]=(0,u.useState)(``),[l,f]=(0,u.useState)(``),[p,m]=(0,u.useState)([]),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(!1),[ee,te]=(0,u.useState)(5),[C,ne]=(0,u.useState)(!1),[re,w]=(0,u.useState)(null),T=(0,u.useRef)(null),ie=!!s({queryKey:[`auth-me`],queryFn:()=>o.get(`/api/auth/me`)}).data?.user?.nextcloud_url,E=e.contentType!==`quiz`&&e.contentType!==`presentation`,ae=e.contentType===`presentation`,oe=e.contentType===`quiz`,se=oe||x;(0,u.useEffect)(()=>{oe&&S(!0)},[oe]);async function ce(){w(null);let n=new FormData;if(n.append(`contentType`,e.contentType),n.append(`questionCount`,String(se?ee:0)),h.trim()&&n.append(`refinement`,h.trim()),E&&_&&n.append(`wordCount`,_),ae&&y&&n.append(`slideCount`,y),t===`topic`){if(!r.trim()){w(`Describe what you want AI to create`);return}n.append(`topic`,r.trim())}else if(t===`upload`){if(p.length===0){w(`Select at least one file`);return}for(let e of p)n.append(`files`,e);a.trim()&&n.append(`topic`,a.trim())}else{if(!he){w(`Select a file from Nextcloud`);return}n.append(`webdavPath`,he),l.trim()&&n.append(`topic`,l.trim())}ne(!0);try{let t=await(await fetch(`/api/admin/learning/ai-generate`,{method:`POST`,credentials:`include`,body:n})).json();if(!t.success)throw Error(t.error||`Generation failed`);let r=t.contentType===`presentation`?{marpMarkdown:t.marpMarkdown,questions:t.questions}:t.content||{};e.onGenerated(r,e.contentType)}catch(e){w(e.message||`Generation failed`)}finally{ne(!1)}}let[le,ue]=(0,u.useState)(`/`),[de,fe]=(0,u.useState)(null),[pe,me]=(0,u.useState)(null),[he,ge]=(0,u.useState)(``),[_e,ve]=(0,u.useState)(``);return(0,u.useEffect)(()=>{t!==`webdav`||!ie||(me(null),o.get(`/api/admin/learning/webdav-browse?path=`+encodeURIComponent(le)).then(fe).catch(e=>me(e.message||`WebDAV browse failed`)))},[t,le,ie]),(0,d.jsxs)(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4 space-y-3`,"data-testid":`cms-ai-panel`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`strong`,{className:`text-sm`,children:`✨ Generate with AI`}),(0,d.jsx)(`button`,{type:`button`,onClick:e.onCancel,className:q_+` ml-auto`,children:`✕ Close`})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`text-[11px] uppercase font-semibold text-muted-foreground`,children:`Type`}),(0,d.jsxs)(`select`,{className:K_+` w-full`,value:e.contentType,onChange:t=>e.onChangeType(t.target.value),"data-testid":`cms-ai-ctype`,children:[(0,d.jsx)(`option`,{value:`article`,children:`Article`}),(0,d.jsx)(`option`,{value:`pearl`,children:`Pearl`}),(0,d.jsx)(`option`,{value:`quiz`,children:`Quiz`}),(0,d.jsx)(`option`,{value:`presentation`,children:`Presentation`})]})]}),E&&(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`text-[11px] uppercase font-semibold text-muted-foreground`,children:`Target word count (optional)`}),(0,d.jsx)(`input`,{type:`number`,min:100,value:_,onChange:e=>v(e.target.value),className:K_+` w-full`,placeholder:`e.g. 800`})]}),ae&&(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`text-[11px] uppercase font-semibold text-muted-foreground`,children:`Slide count`}),(0,d.jsx)(`input`,{type:`number`,min:3,max:40,value:y,onChange:e=>b(e.target.value),className:K_+` w-full`,placeholder:`e.g. 10`})]})]}),!oe&&(0,d.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),`Also generate quiz questions`]}),se&&(0,d.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,d.jsx)(`span`,{children:`Question count:`}),(0,d.jsx)(`input`,{type:`number`,min:1,max:20,value:ee,onChange:e=>te(Math.max(1,Math.min(20,Number(e.target.value)||1))),className:K_+` w-20`})]}),(0,d.jsxs)(`div`,{className:`flex gap-1 border-b border-border`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>n(`topic`),className:`px-3 py-1.5 text-xs border-b-2 -mb-px `+(t===`topic`?`border-primary text-primary font-semibold`:`border-transparent hover:bg-muted`),children:`Topic`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>n(`upload`),className:`px-3 py-1.5 text-xs border-b-2 -mb-px `+(t===`upload`?`border-primary text-primary font-semibold`:`border-transparent hover:bg-muted`),children:`Upload files`}),ie&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>n(`webdav`),className:`px-3 py-1.5 text-xs border-b-2 -mb-px `+(t===`webdav`?`border-primary text-primary font-semibold`:`border-transparent hover:bg-muted`),children:`Nextcloud`})]}),t===`topic`&&(0,d.jsx)(`textarea`,{className:K_+` w-full min-h-[100px] font-mono text-sm`,placeholder:`Describe what you want AI to create (e.g. 'Bronchiolitis management for attending teaching rounds, high school education level')`,value:r,onChange:e=>i(e.target.value),"data-testid":`cms-ai-topic`}),t===`upload`&&(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`input`,{ref:T,type:`file`,multiple:!0,accept:`.pdf,.docx,.odt,.rtf,.txt,.md,.html,.htm,.pptx,.epub,image/*`,onChange:e=>m(Array.from(e.target.files||[])),className:`text-xs`,"data-testid":`cms-ai-files`}),p.length>0&&(0,d.jsx)(`ul`,{className:`text-xs text-muted-foreground`,children:p.map((e,t)=>(0,d.jsxs)(`li`,{children:[`📄 `,e.name,` `,(0,d.jsxs)(`span`,{className:`opacity-60`,children:[`(`,Math.round(e.size/1024),` KB)`]})]},t))}),(0,d.jsx)(`textarea`,{className:K_+` w-full min-h-[60px] text-sm`,placeholder:`Optional: extra context / framing for the AI`,value:a,onChange:e=>c(e.target.value)})]}),t===`webdav`&&(0,d.jsxs)(`div`,{className:`space-y-2`,children:[pe&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:pe}),de&&(0,d.jsxs)(`div`,{className:`rounded-md border border-border bg-background`,children:[(0,d.jsxs)(`div`,{className:`px-2 py-1 flex items-center gap-2 text-xs border-b border-border bg-muted/40`,children:[(0,d.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:de.path}),le!==`/`&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>ue(de.parentPath),className:q_+` ml-auto`,children:`⬆ Up`})]}),(0,d.jsxs)(`div`,{className:`max-h-60 overflow-auto`,children:[de.items.length===0&&(0,d.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground italic`,children:`Empty folder.`}),de.items.map(e=>(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{e.isDir?(ue(e.path),ge(``),ve(``)):(ge(e.path),ve(e.name))},className:`w-full text-left px-2 py-1.5 text-sm flex items-center gap-2 border-b border-border last:border-0 hover:bg-muted `+(he===e.path?`bg-primary/10`:``),children:[(0,d.jsx)(`span`,{children:e.isDir?`📁`:`📄`}),(0,d.jsx)(`span`,{className:`truncate`,children:e.name}),!e.isDir&&typeof e.size==`number`&&(0,d.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[Math.round((e.size||0)/1024),` KB`]})]},e.path))]})]}),he&&(0,d.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Selected: `,(0,d.jsx)(`span`,{className:`font-semibold`,children:_e})]}),(0,d.jsx)(`textarea`,{className:K_+` w-full min-h-[60px] text-sm`,placeholder:`Optional: extra context / framing for the AI`,value:l,onChange:e=>f(e.target.value)})]}),(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`text-[11px] uppercase font-semibold text-muted-foreground`,children:`Refinement (optional)`}),(0,d.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),className:K_+` w-full`,placeholder:`e.g. 'Keep it under 500 words', 'Focus on outpatient management'`})]}),re&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:re}),(0,d.jsx)(`div`,{className:`flex gap-2`,children:(0,d.jsx)(`button`,{type:`button`,onClick:ce,disabled:C,className:J_,"data-testid":`cms-ai-run`,children:C?`⌛ Generating…`:`✨ Generate content`})})]})}var X_=`rounded-md border border-input bg-background px-3 py-2 text-sm`,Z_=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,Q_=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`;function $_({id:e,initialType:t,onClose:n}){let r=c(),a=e==null,[l,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(t),[x,S]=(0,u.useState)(!1),[ee,te]=(0,u.useState)([]),[C,ne]=(0,u.useState)(null),[re,w]=(0,u.useState)(!1);function T(e,t){if(b(t),t===`presentation`&&e.marpMarkdown){g(e.marpMarkdown);let t=e.marpMarkdown.match(/^#\s+(.+)$/m);t&&f(t[1])}else e.title&&f(e.title),e.subject!==void 0&&m(e.subject),e.body!==void 0&&g(e.body);e.questions&&e.questions.length&&te(e.questions),w(!1),ne({kind:`ok`,text:`Content generated — review, then save.`})}let ie=s({queryKey:[`cms-categories`],queryFn:()=>o.get(`/api/learning-admin/categories`)}),E=s({queryKey:[`cms-content-detail`,e],queryFn:()=>o.get(`/api/learning-admin/content/`+e),enabled:!a});(0,u.useEffect)(()=>{if(!E.data?.content)return;let e=E.data.content;f(e.title),m(e.subject||``),g(e.body||``),v(e.category_id??``),b(e.content_type),S(!!e.published),te(e.questions||[])},[E.data]);let ae=i({mutationFn:async()=>{let t={title:l,subject:p,body:h,category_id:_===``?null:_,content_type:y,published:x};return a?o.post(`/api/learning-admin/content`,t):(await o.put(`/api/learning-admin/content/`+e,t),{success:!0,id:e})},onSuccess:e=>{r.invalidateQueries({queryKey:[`cms-content`]}),r.invalidateQueries({queryKey:[`cms-stats`]}),r.invalidateQueries({queryKey:[`cms-content-detail`,e.id]}),ne({kind:`ok`,text:a?`Created — switch to the list to add questions`:`Saved`})},onError:e=>ne({kind:`err`,text:e.message||`Save failed`})});return(0,d.jsxs)(`div`,{className:`flex-1 space-y-3 min-w-0`,"data-testid":`cms-editor`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:a?`New `+y:`Edit `+y}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsxs)(`button`,{type:`button`,onClick:()=>w(e=>!e),className:Q_,"data-testid":`cms-open-ai`,children:[`✨ `,re?`Hide AI`:`Generate with AI`]}),(0,d.jsx)(`button`,{type:`button`,onClick:n,className:Z_,children:`← Back to list`})]})]}),re&&(0,d.jsx)(Y_,{contentType:y,onChangeType:b,onGenerated:T,onCancel:()=>w(!1)}),(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-3`,children:[(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1`,children:`Title`}),(0,d.jsx)(`input`,{type:`text`,className:X_+` w-full`,value:l,onChange:e=>f(e.target.value),"data-testid":`cms-edit-title`})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3`,children:[(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1`,children:`Type`}),(0,d.jsxs)(`select`,{className:X_+` w-full`,value:y,onChange:e=>b(e.target.value),"data-testid":`cms-edit-type`,children:[(0,d.jsx)(`option`,{value:`article`,children:`Article`}),(0,d.jsx)(`option`,{value:`pearl`,children:`Pearl`}),(0,d.jsx)(`option`,{value:`quiz`,children:`Quiz`}),(0,d.jsx)(`option`,{value:`presentation`,children:`Presentation`})]})]}),(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1`,children:`Category`}),(0,d.jsxs)(`select`,{className:X_+` w-full`,value:_,onChange:e=>v(e.target.value===``?``:Number(e.target.value)),"data-testid":`cms-edit-category`,children:[(0,d.jsx)(`option`,{value:``,children:`Uncategorized`}),(ie.data?.categories||[]).map(e=>(0,d.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,d.jsxs)(`label`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`h-4 w-4`,"data-testid":`cms-edit-published`}),(0,d.jsx)(`span`,{className:`text-sm`,children:`Published`})]})]}),(0,d.jsxs)(`label`,{className:`block`,children:[(0,d.jsx)(`span`,{className:`block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1`,children:`Subject (optional)`}),(0,d.jsx)(`input`,{type:`text`,className:X_+` w-full`,value:p,onChange:e=>m(e.target.value),placeholder:`e.g. Asthma, Bronchiolitis`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`span`,{className:`block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1`,children:`Body`}),y===`presentation`?(0,d.jsx)(G_,{value:h,onChange:g}):(0,d.jsx)(F_,{value:h,onChange:g,variant:`default`,minHeight:`min-h-[320px]`,placeholder:`Write the content body…`,testId:`cms-edit-body`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>ae.mutate(),disabled:ae.isPending||!l.trim(),className:Q_,"data-testid":`cms-save`,children:ae.isPending?`Saving…`:a?`Create`:`Save changes`}),C&&(0,d.jsx)(`span`,{className:`text-xs `+(C.kind===`ok`?`text-green-600`:`text-destructive`),children:C.text})]})]}),!a&&y===`quiz`&&(0,d.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4`,children:(0,d.jsx)(B_,{contentId:e,questions:ee,onChange:te})})]})}function ev(){let[e,t]=(0,u.useState)(`all`),[n,r]=(0,u.useState)(`all`),[i,a]=(0,u.useState)({kind:`list`});return(0,d.jsxs)(`div`,{className:`max-w-6xl mx-auto p-6 space-y-4`,children:[(0,d.jsxs)(`header`,{children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Content Manager`}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Create and manage Learning Hub content, quizzes, and categories.`})]}),(0,d.jsx)(f,{}),(0,d.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,d.jsx)(m,{statusFilter:e,onStatusFilter:t,categoryFilter:n,onCategoryFilter:r}),i.kind===`list`?(0,d.jsx)(y,{statusFilter:e,categoryFilter:n,onEdit:e=>a({kind:`edit`,id:e,type:`article`}),onCreate:e=>a({kind:`edit`,id:null,type:e})}):(0,d.jsx)($_,{id:i.id,initialType:i.type,onClose:()=>a({kind:`list`})})]})]})}export{ev as default}; \ No newline at end of file diff --git a/public/app/assets/ConfirmModal-zYA0ebt6.js b/public/app/assets/ConfirmModal-CIfDDoVq.js similarity index 100% rename from public/app/assets/ConfirmModal-zYA0ebt6.js rename to public/app/assets/ConfirmModal-CIfDDoVq.js diff --git a/public/app/assets/Dictation-D10JY0ar.js b/public/app/assets/Dictation-D10JY0ar.js new file mode 100644 index 0000000..9399999 --- /dev/null +++ b/public/app/assets/Dictation-D10JY0ar.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,t as a}from"./index-C9wKWOAN.js";import{n as o,t as s}from"./EditableResult-DaHQp1Pv.js";import{t as c}from"./Recorder-DdXTjnSC.js";var l=e(t(),1),u=n(),d=`dictation`;function f(){let[e,t]=(0,l.useState)(``),[n,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(`outpatient`),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(``),[x,S]=(0,l.useState)(null),[C,w]=(0,l.useState)(null),[T,E]=(0,l.useState)(null),D=r({mutationFn:e=>i.post(`/api/generate-hpi-dictation`,e),onSuccess:e=>S(e.hpi),onError:()=>S(null)});function O(e){e.preventDefault(),w(null);let t={transcript:(y||_).trim(),patientAge:n,patientGender:p,setting:h},r=a.safeParse(t);if(!r.success){w(r.error.issues.map(e=>e.message).join(`, `));return}S(null),D.mutate(r.data)}function k(){v(``),b(``),S(null),w(null)}let A=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,j=y||_;return(0,u.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Voice Dictation → HPI`}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Dictate your narrative → AI restructures into polished HPI.`})]}),(0,u.jsx)(o,{type:d,label:e,setLabel:t,transcript:_,generatedNote:x||``,partialData:{age:n,gender:p,setting:h},onLoad:e=>{v(e.transcript||``),b(``),S(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&f(t.age),t?.gender&&m(t.gender),t?.setting&&g(t.setting)}catch{}t(e.label||``)},onClear:()=>{k(),f(``),m(``),g(`outpatient`)}}),(0,u.jsxs)(`form`,{onSubmit:O,className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,u.jsx)(`input`,{className:A,placeholder:`e.g. 8 months`,value:n,onChange:e=>f(e.target.value)})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,u.jsxs)(`select`,{className:A,value:p,onChange:e=>m(e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:`Select`}),(0,u.jsx)(`option`,{children:`Male`}),(0,u.jsx)(`option`,{children:`Female`})]})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Setting`}),(0,u.jsxs)(`select`,{className:A,value:h,onChange:e=>g(e.target.value),children:[(0,u.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,u.jsx)(`option`,{value:`inpatient`,children:`Inpatient / Floors`})]})]})]}),(0,u.jsx)(c,{module:`dictation`,onTranscript:(e,t)=>{v(n=>t.appended&&n?n+` `+e:e),b(``),E(null)},onInterim:e=>b(e?_?_+` `+e:e:``),onError:e=>E(e)}),T&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:T}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,u.jsx)(`button`,{type:`button`,onClick:k,className:`text-xs text-muted-foreground underline`,children:`Clear`})]}),(0,u.jsx)(`textarea`,{className:A+` min-h-[200px] font-mono text-sm`,placeholder:`Click Start recording, or type / paste your dictation here.`,value:j,onChange:e=>{v(e.target.value),b(``)}})]}),C&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:C}),D.error&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:D.error.message}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:(0,u.jsx)(`button`,{type:`submit`,disabled:D.isPending||!j.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:D.isPending?`Generating…`:`Generate HPI`})})]}),x!==null&&(0,u.jsx)(s,{text:x,onChange:S,section:`hpi`,title:`Generated HPI`,exportLabel:`hpi-dictation`,exportType:`hpi`,sourceContext:j})]})}export{f as default}; \ No newline at end of file diff --git a/public/app/assets/Dictation-Dk3CctmR.js b/public/app/assets/Dictation-Dk3CctmR.js deleted file mode 100644 index 64c89d6..0000000 --- a/public/app/assets/Dictation-Dk3CctmR.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,t as a}from"./index-BuU36CvS.js";var o=e(t(),1),s=n();function c(){let[e,t]=(0,o.useState)(``),[n,c]=(0,o.useState)(``),[l,u]=(0,o.useState)(`outpatient`),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(null),_=r({mutationFn:e=>i.post(`/api/generate-hpi-dictation`,e),onSuccess:e=>m(e.hpi),onError:()=>m(null)});function v(t){t.preventDefault(),g(null);let r={transcript:d,patientAge:e,patientGender:n,setting:l},i=a.safeParse(r);if(!i.success){g(i.error.issues.map(e=>e.message).join(`, `));return}m(null),_.mutate(i.data)}function y(){f(``),m(null),g(null)}let b=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,s.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,s.jsxs)(`header`,{children:[(0,s.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Voice Dictation → HPI`}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Dictate your narrative → AI restructures into polished HPI. Audio-capture UI is a follow-up; this minimal form supports typed/pasted transcripts.`})]}),(0,s.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,s.jsx)(`input`,{className:b,placeholder:`e.g. 8 months`,value:e,onChange:e=>t(e.target.value)})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,s.jsxs)(`select`,{className:b,value:n,onChange:e=>c(e.target.value),children:[(0,s.jsx)(`option`,{value:``,children:`Select`}),(0,s.jsx)(`option`,{children:`Male`}),(0,s.jsx)(`option`,{children:`Female`})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Setting`}),(0,s.jsxs)(`select`,{className:b,value:l,onChange:e=>u(e.target.value),children:[(0,s.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,s.jsx)(`option`,{value:`inpatient`,children:`Inpatient / Floors`})]})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,s.jsx)(`button`,{type:`button`,onClick:y,className:`text-xs text-muted-foreground underline`,children:`Clear`})]}),(0,s.jsx)(`textarea`,{className:b+` min-h-[200px] font-mono text-sm`,placeholder:`Type or paste your dictation here, then click Generate.`,value:d,onChange:e=>f(e.target.value)})]}),h&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:h}),_.error&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:_.error.message}),(0,s.jsx)(`div`,{className:`flex gap-2`,children:(0,s.jsx)(`button`,{type:`submit`,disabled:_.isPending||!d.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:_.isPending?`Generating…`:`Generate HPI`})})]}),p&&(0,s.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,s.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,s.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Generated HPI`}),(0,s.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(p),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,s.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:p})]})]})}export{c as default}; \ No newline at end of file diff --git a/public/app/assets/DxPicker-CCeyfxop.js b/public/app/assets/DxPicker-CCeyfxop.js new file mode 100644 index 0000000..b1f463d --- /dev/null +++ b/public/app/assets/DxPicker-CCeyfxop.js @@ -0,0 +1,4 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";var r=n();function i(e,t){let n={...t};for(let t of e)n[t.key]={status:`wnl`,note:n[t.key]?.note};return n}function a(e,t){let n={...e};for(let e of t)n[e.key]={};return n}var o={wnl:`WNL`,abnormal:`Abnormal`,notrev:`Not reviewed`};function s(e,t){return e?t===`wnl`?`bg-green-100 text-green-800 border-green-300`:t===`abnormal`?`bg-red-100 text-red-800 border-red-300`:`bg-muted text-muted-foreground border-border`:`bg-background border-border hover:bg-muted`}function c({systems:e,data:t,onChange:n,btnLabels:i,testIdPrefix:a=`ros`}){let c=i||o;function l(e,r){let i=(t[e]?.status||``)===r?``:r;n({...t,[e]:{status:i,note:t[e]?.note||``}})}function u(e,r){n({...t,[e]:{status:t[e]?.status||``,note:r}})}return(0,r.jsx)(`div`,{className:`divide-y divide-border`,"data-testid":a+`-table`,children:e.map(e=>{let n=t[e.key]||{},i=n.status||``;return(0,r.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2 py-1.5`,"data-testid":a+`-row-`+e.key,children:[(0,r.jsxs)(`div`,{className:`flex-1 min-w-[180px]`,title:e.detail,children:[(0,r.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),(0,r.jsxs)(`span`,{className:`ml-1 text-[10px] text-muted-foreground`,children:[`(`,e.detail,`)`]})]}),(0,r.jsx)(`div`,{className:`flex gap-1 shrink-0`,children:[`wnl`,`abnormal`,`notrev`].map(t=>(0,r.jsx)(`button`,{type:`button`,onClick:()=>l(e.key,t),className:`text-[10px] uppercase tracking-wider px-2 py-1 rounded border `+s(i===t,t),"data-testid":a+`-btn-`+e.key+`-`+t,children:c[t]},t))}),i===`abnormal`&&(0,r.jsx)(`input`,{type:`text`,value:n.note||``,onChange:t=>u(e.key,t.target.value),placeholder:`Describe finding…`,className:`flex-1 min-w-[200px] rounded-md border border-input bg-background px-2 py-1 text-xs`,"data-testid":a+`-note-`+e.key})]},e.key)})})}var l=e(t(),1),u=[{key:`constitutional`,label:`Constitutional`,detail:`fever, fatigue, weight loss/gain, appetite`},{key:`eyes`,label:`Eyes`,detail:`vision changes, discharge, redness`},{key:`ent`,label:`ENT`,detail:`ear pain, congestion, sore throat, mouth sores`},{key:`cardiovascular`,label:`Cardiovascular`,detail:`chest pain, palpitations, murmur`},{key:`respiratory`,label:`Respiratory`,detail:`cough, wheeze, dyspnea`},{key:`gastrointestinal`,label:`Gastrointestinal`,detail:`nausea, vomiting, diarrhea, constipation, abdominal pain`},{key:`genitourinary`,label:`Genitourinary`,detail:`dysuria, frequency, discharge, menstrual`},{key:`musculoskeletal`,label:`Musculoskeletal`,detail:`joint pain, swelling, gait issues, back pain`},{key:`skin`,label:`Skin`,detail:`rash, lesions, itch, hair/nail changes`},{key:`neurological`,label:`Neurological`,detail:`headache, dizziness, seizures, numbness`},{key:`psychiatric`,label:`Psychiatric`,detail:`mood, anxiety, sleep, behavior changes`},{key:`endocrine`,label:`Endocrine`,detail:`polyuria/polydipsia, heat/cold intolerance, growth concerns`},{key:`hematologic`,label:`Hematologic/Lymphatic`,detail:`bruising, bleeding, lymph nodes`},{key:`allergic`,label:`Allergic/Immunologic`,detail:`allergic reactions, frequent infections`},{key:`developmental`,label:`Developmental/Behavioral`,detail:`milestones, school, social`}],d=[{key:`general`,label:`General Appearance`,detail:`WDWN, alert, NAD, etc.`},{key:`peEyes`,label:`Eyes`,detail:`PERRL, conjunctiva, EOM`},{key:`ears`,label:`Ears`,detail:`TMs, canals, hearing`},{key:`nose`,label:`Nose`,detail:`mucosa, septum, turbinates`},{key:`mouthThroat`,label:`Mouth/Throat`,detail:`lips, gums, teeth, tonsils, pharynx`},{key:`neck`,label:`Neck`,detail:`lymph nodes, thyroid, masses`},{key:`chestLungs`,label:`Chest/Lungs`,detail:`air entry, wheezing, retractions`},{key:`peCv`,label:`Cardiovascular`,detail:`S1/S2, murmur, pulses, cap refill`},{key:`abdomen`,label:`Abdomen`,detail:`soft, tenderness, organomegaly, BS`},{key:`guTanner`,label:`Genitourinary/Tanner`,detail:`Tanner stage, genitalia, hernias`},{key:`msk`,label:`Musculoskeletal`,detail:`strength, ROM, gait, spine`},{key:`extremities`,label:`Extremities`,detail:`tone, reflexes, clubbing, edema`},{key:`peSkin`,label:`Skin`,detail:`rashes, lesions, cafe au lait, bruises`},{key:`peNeuro`,label:`Neurological`,detail:`CN intact, DTRs, coordination`},{key:`lymphatic`,label:`Lymphatic`,detail:`cervical, axillary, inguinal nodes`},{key:`breast`,label:`Breast`,detail:`if indicated by age/Tanner`},{key:`pePsych`,label:`Psychiatric`,detail:`affect, mood, behavior during exam`}],f=[{code:`Z00.129`,name:`Routine child health exam, no abnormal findings`},{code:`Z00.121`,name:`Routine child health exam, with abnormal findings`},{code:`J06.9`,name:`Upper Respiratory Infection, NOS`},{code:`J02.9`,name:`Acute pharyngitis, NOS`},{code:`J03.90`,name:`Acute tonsillitis, NOS`},{code:`H66.90`,name:`Otitis media, NOS`},{code:`J20.9`,name:`Acute bronchitis`},{code:`J45.20`,name:`Mild intermittent asthma, uncomplicated`},{code:`J45.30`,name:`Mild persistent asthma`},{code:`A09`,name:`Gastroenteritis/colitis`},{code:`L20.9`,name:`Atopic dermatitis, NOS`},{code:`L30.9`,name:`Dermatitis NOS`},{code:`R50.9`,name:`Fever NOS`},{code:`R10.9`,name:`Abdominal pain NOS`},{code:`R05.9`,name:`Cough`},{code:`B34.9`,name:`Viral infection NOS`},{code:`Z23`,name:`Immunization encounter`},{code:`Z41.9`,name:`Procedure for non-remedial reason`},{code:`K21.0`,name:`GERD with esophagitis`},{code:`K21.9`,name:`GERD without esophagitis`},{code:`F90.0`,name:`ADHD, predominantly inattentive`},{code:`F90.2`,name:`ADHD, combined type`},{code:`F41.1`,name:`Generalized anxiety disorder`},{code:`F32.9`,name:`Major depressive episode NOS`},{code:`E11.9`,name:`Type 2 diabetes`},{code:`E03.9`,name:`Hypothyroidism NOS`},{code:`M54.5`,name:`Low back pain`},{code:`G43.909`,name:`Migraine NOS`}];function p(e,t,n){let r=[n+`:`],i=!1;for(let n of e){let e=t[n.key]||{};e.status&&(i=!0,e.status===`wnl`?r.push(` `+n.label+`: NORMAL [domain: `+n.detail+`]`):e.status===`abnormal`?r.push(` `+n.label+`: ABNORMAL`+(e.note?` — `+e.note:``)+` [domain: `+n.detail+`]`):r.push(` `+n.label+`: Not reviewed`))}return i?r.join(` +`):``}function m(e,t){let n=[];for(let t of e)n.push((t.code?t.code+` `:``)+t.name);let r=(t||``).trim();return r&&n.push(r),n.length?`Diagnoses: +`+n.map(e=>` - `+e).join(` +`):``}var h=`rounded-md border border-input bg-background px-2 py-1 text-sm`;async function g(e,t){let n=`https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name&terms=`+encodeURIComponent(e)+`&maxList=12`;return((await(await fetch(n,{signal:t})).json())[3]||[]).map(([e,t])=>({code:e,name:t}))}function _({value:e,onChange:t,testIdPrefix:n=`dx`}){let[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)([]),[c,u]=(0,l.useState)(!1),d=(0,l.useRef)(null),p=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(!i.trim()||i.trim().length<2){s([]),u(!1);return}return p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current&&d.current.abort();let e=new AbortController;d.current=e,g(i.trim(),e.signal).then(e=>{s(e),u(e.length>0)}).catch(()=>{})},280),()=>{p.current&&window.clearTimeout(p.current)}},[i]);function m(n){e.some(e=>e.code===n.code&&e.name===n.name)||t([...e,n])}function _(n){t(e.filter((e,t)=>t!==n))}return(0,r.jsxs)(`div`,{className:`space-y-2`,"data-testid":n+`-picker`,children:[(0,r.jsxs)(`div`,{className:`relative`,children:[(0,r.jsx)(`input`,{type:`text`,placeholder:`Search ICD-10 (e.g. "otitis", "J06")…`,autoComplete:`off`,value:i,onChange:e=>a(e.target.value),onFocus:()=>o.length&&u(!0),onBlur:()=>setTimeout(()=>u(!1),150),onKeyDown:e=>{e.key===`Escape`&&u(!1),e.key===`Enter`&&o[0]&&(e.preventDefault(),m(o[0]),a(``),u(!1))},className:h+` w-full`,"data-testid":n+`-search`}),c&&o.length>0&&(0,r.jsx)(`div`,{className:`absolute z-30 left-0 right-0 mt-1 max-h-60 overflow-auto rounded-md border border-border bg-card shadow-lg`,children:o.map(e=>(0,r.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),m(e),a(``),u(!1)},className:`w-full text-left px-3 py-2 text-sm hover:bg-muted border-b border-border last:border-0`,"data-testid":n+`-result-`+e.code,children:[(0,r.jsx)(`span`,{className:`inline-block w-20 text-xs font-mono text-muted-foreground`,children:e.code}),(0,r.jsx)(`span`,{children:e.name})]},e.code))})]}),e.length>0&&(0,r.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,"data-testid":n+`-tags`,children:e.map((e,t)=>(0,r.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-primary/10 border border-primary/30 text-primary px-2 py-0.5 text-xs`,children:[e.code&&(0,r.jsx)(`strong`,{className:`font-semibold`,children:e.code}),(0,r.jsx)(`span`,{children:e.name}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>_(t),className:`text-xs text-muted-foreground hover:text-destructive`,title:`Remove`,children:`×`})]},t))}),(0,r.jsxs)(`div`,{children:[(0,r.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:`Common pediatric diagnoses:`}),(0,r.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:f.map(e=>(0,r.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`text-[11px] rounded border border-border bg-background px-2 py-0.5 hover:bg-muted`,title:e.name,"data-testid":n+`-chip-`+e.code,children:[(0,r.jsx)(`span`,{className:`font-mono text-muted-foreground mr-1`,children:e.code}),e.name]},e.code))})]})]})}export{p as a,a as c,m as i,d as n,c as o,u as r,i as s,_ as t}; \ No newline at end of file diff --git a/public/app/assets/EditableResult-DaHQp1Pv.js b/public/app/assets/EditableResult-DaHQp1Pv.js new file mode 100644 index 0000000..9bb9122 --- /dev/null +++ b/public/app/assets/EditableResult-DaHQp1Pv.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{i as r}from"./index-C9wKWOAN.js";import{t as i}from"./OutputActions-6XZlmtIw.js";var a=e(t(),1),o=e=>`_savedEncId_`+e,s=e=>`_idempKey_`+e;function c(e){try{let t=sessionStorage.getItem(o(e));return t?Number(t):null}catch{return null}}function l(e,t){try{t==null?sessionStorage.removeItem(o(e)):sessionStorage.setItem(o(e),String(t))}catch{}}function u(e){try{let t=sessionStorage.getItem(s(e));if(t)return t}catch{}let t=typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)});try{sessionStorage.setItem(s(e),t)}catch{}return t}function d(e){try{sessionStorage.removeItem(s(e))}catch{}}var f=new Map;async function p(e){if(!e.label.trim())throw Error(`Enter a patient label first`);let t=c(e.type),n={label:e.label.trim(),enc_type:e.type,transcript:e.transcript,generated_note:e.generatedNote,partial_data:e.partialData==null?void 0:JSON.stringify(e.partialData),idempotency_key:u(e.type)};if(t!=null){n.id=t;let e=f.get(t);e!=null&&(n.expected_version=e)}let r=await fetch(`/api/encounters/saved`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),i=await r.json();if(r.status===409)throw Error(`Someone else edited this encounter. Reload to see the latest version.`);if(!i.success)throw Error(i.error||`Save failed`);return i.id!=null&&(l(e.type,i.id),i.version!=null&&f.set(i.id,i.version)),{id:i.id,version:i.version}}async function m(e){let t=await(await fetch(`/api/encounters/saved/`+e,{credentials:`include`})).json();if(!t.success)throw Error(t.error||`Load failed`);return t.encounter&&t.encounter.version!=null&&f.set(e,t.encounter.version),t.encounter}async function h(){return(await(await fetch(`/api/encounters/saved`,{credentials:`include`})).json()).encounters||[]}function g(e){l(e,null),d(e)}var _=n(),v=`rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`,y=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,b=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`;function x({type:e,label:t,setLabel:n,transcript:r,generatedNote:i,partialData:o,onLoad:s,onClear:l}){let[u,d]=(0,a.useState)(null),[f,x]=(0,a.useState)(!1),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)([]),[E,D]=(0,a.useState)(!1),[O,k]=(0,a.useState)(``),[A,j]=(0,a.useState)(c(e));(0,a.useEffect)(()=>{j(c(e))},[r,i]);async function M(){if(!t.trim()){d({kind:`err`,text:`Enter a patient label first`});return}d(null),x(!0);try{j((await p({type:e,label:t,transcript:r,generatedNote:i,partialData:o})).id),d({kind:`ok`,text:`Saved (`+t+`)`})}catch(e){d({kind:`err`,text:e.message})}finally{x(!1)}}function N(){g(e),j(null),n(``),l(),d({kind:`info`,text:`New patient — fields cleared.`})}async function P(){if(S){C(!1);return}C(!0),D(!0);try{T((await h()).filter(t=>t.enc_type===e))}finally{D(!1)}}async function F(e){try{let t=await m(e);j(e),s(t),C(!1),d({kind:`ok`,text:`Loaded `+(t.label||``)})}catch(e){d({kind:`err`,text:e.message})}}let I=O?w.filter(e=>(e.label||``).toLowerCase().includes(O.toLowerCase())):w;return(0,_.jsxs)(`div`,{className:`space-y-2`,"data-testid":`enc-toolbar-`+e,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,_.jsx)(`input`,{className:v+` flex-1 min-w-[180px] max-w-md`,placeholder:`Patient label (e.g. JD-2026-04-24)`,value:t,onChange:e=>n(e.target.value),"data-testid":`enc-label`}),(0,_.jsxs)(`button`,{type:`button`,onClick:M,disabled:f,className:b,"data-testid":`enc-save`,children:[`💾 `,f?`Saving…`:A==null?`Save`:`Save (update)`]}),(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:P,className:y,"data-testid":`enc-load-toggle`,children:`📂 Load`}),S&&(0,_.jsxs)(`div`,{className:`absolute z-30 mt-1 right-0 w-80 max-h-96 overflow-auto rounded-md border border-border bg-card shadow-lg`,children:[(0,_.jsx)(`div`,{className:`sticky top-0 bg-card p-2 border-b border-border`,children:(0,_.jsx)(`input`,{type:`search`,placeholder:`Filter saved encounters…`,className:v+` w-full text-xs`,value:O,onChange:e=>k(e.target.value),autoFocus:!0,"data-testid":`enc-load-search`})}),E&&(0,_.jsx)(`div`,{className:`p-3 text-xs text-muted-foreground`,children:`Loading…`}),!E&&I.length===0&&(0,_.jsxs)(`div`,{className:`p-3 text-xs text-muted-foreground italic`,children:[`No saved `,e,` encounters.`]}),I.map(e=>(0,_.jsxs)(`button`,{type:`button`,onClick:()=>F(e.id),className:`w-full text-left px-3 py-2 hover:bg-muted border-b border-border last:border-0`,"data-testid":`enc-load-pick-`+e.id,children:[(0,_.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.label}),(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,new Date(e.updated_at).toLocaleString(),` · expires `,new Date(e.expires_at).toLocaleDateString()]})]},e.id))]})]}),(0,_.jsx)(`button`,{type:`button`,onClick:N,className:y,"data-testid":`enc-new`,children:`🆕 New patient`}),A!=null&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Draft #`,A]})]}),u&&(0,_.jsx)(`div`,{className:`text-sm `+(u.kind===`ok`?`text-green-600`:u.kind===`err`?`text-destructive`:`text-muted-foreground`),children:u.text})]})}function S(e,t){if(!e||!t||e.trim()===t.trim())return!1;let n=e.split(/\s+/).length,r=t.split(/\s+/).length;return!(Math.abs(n-r)<2&&e.length>100&&Math.abs(e.length-t.length)<20)}function C({text:e,onChange:t,section:n,exportLabel:o,exportType:s,sourceContext:c,title:l}){let u=(0,a.useRef)(e);(0,a.useEffect)(()=>{!u.current&&e&&(u.current=e)},[e]);async function d(){if(n&&S(u.current,e))try{await r.post(`/api/memories/correction`,{section:n,original_snippet:u.current,corrected_snippet:e}),u.current=e}catch{}}return(0,_.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,"data-testid":`editable-result-`+s,children:[(0,_.jsx)(`header`,{className:`px-4 py-2 border-b border-border bg-muted/40`,children:(0,_.jsx)(`h2`,{className:`text-sm font-semibold`,children:l})}),(0,_.jsx)(`textarea`,{className:`w-full p-4 text-sm bg-transparent resize-y min-h-[200px] focus:outline-none focus:ring-0 border-0 whitespace-pre-wrap`,value:e,onChange:e=>t(e.target.value),onBlur:d,"data-testid":`editable-result-body-`+s,spellCheck:!0}),(0,_.jsx)(`div`,{className:`px-4 pb-4`,children:(0,_.jsx)(i,{text:e,onUpdate:e=>{u.current=e,t(e)},sourceContext:c,exportLabel:o,exportType:s})})]})}export{x as n,C as t}; \ No newline at end of file diff --git a/public/app/assets/Encounter-Br_IbTDu.js b/public/app/assets/Encounter-Br_IbTDu.js new file mode 100644 index 0000000..98cb82f --- /dev/null +++ b/public/app/assets/Encounter-Br_IbTDu.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,t as a}from"./index-C9wKWOAN.js";import{n as o,t as s}from"./EditableResult-DaHQp1Pv.js";import{t as c}from"./Recorder-DdXTjnSC.js";var l=e(t(),1),u=n(),d=`encounter`;function f(){let[e,t]=(0,l.useState)(``),[n,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(`outpatient`),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(``),[x,S]=(0,l.useState)(null),[C,w]=(0,l.useState)(null),[T,E]=(0,l.useState)(null),D=r({mutationFn:e=>i.post(`/api/generate-hpi-encounter`,e),onSuccess:e=>S(e.hpi)});function O(e){e.preventDefault(),w(null);let t={transcript:(y||_).trim(),patientAge:n,patientGender:p,setting:h},r=a.safeParse(t);if(!r.success){w(r.error.issues.map(e=>e.message).join(`, `));return}S(null),D.mutate(r.data)}let k=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,A=y||_;return(0,u.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Live Encounter → HPI`}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Record or paste an encounter transcript; generate a structured HPI.`})]}),(0,u.jsx)(o,{type:d,label:e,setLabel:t,transcript:_,generatedNote:x||``,partialData:{age:n,gender:p,setting:h},onLoad:e=>{v(e.transcript||``),b(``),S(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&f(t.age),t?.gender&&m(t.gender),t?.setting&&g(t.setting)}catch{}t(e.label||``)},onClear:()=>{v(``),b(``),S(null),f(``),m(``),g(`outpatient`)}}),(0,u.jsxs)(`form`,{onSubmit:O,className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,u.jsx)(`input`,{className:k,placeholder:`e.g. 5 years`,value:n,onChange:e=>f(e.target.value)})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,u.jsxs)(`select`,{className:k,value:p,onChange:e=>m(e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:`Select`}),(0,u.jsx)(`option`,{children:`Male`}),(0,u.jsx)(`option`,{children:`Female`})]})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Setting`}),(0,u.jsxs)(`select`,{className:k,value:h,onChange:e=>g(e.target.value),children:[(0,u.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,u.jsx)(`option`,{value:`inpatient`,children:`Inpatient / Floors`})]})]})]}),(0,u.jsx)(c,{module:`encounter`,onTranscript:(e,t)=>{v(n=>t.appended&&n?n+` `+e:e),b(``),E(null)},onInterim:e=>b(e?_?_+` `+e:e:``),onError:e=>E(e)}),T&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:T}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript`}),(0,u.jsx)(`textarea`,{className:k+` min-h-[220px] font-mono text-sm`,placeholder:`Click Start recording, or type / paste an encounter transcript here.`,value:A,onChange:e=>{v(e.target.value),b(``)}})]}),C&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:C}),D.error&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:D.error.message}),(0,u.jsx)(`button`,{type:`submit`,disabled:D.isPending||!A.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:D.isPending?`Generating…`:`Generate HPI`})]}),x!==null&&(0,u.jsx)(s,{text:x,onChange:S,section:`encounter`,title:`Generated HPI`,exportLabel:`hpi-encounter`,exportType:`hpi`,sourceContext:A})]})}export{f as default}; \ No newline at end of file diff --git a/public/app/assets/Encounter-CbwLX_2x.js b/public/app/assets/Encounter-CbwLX_2x.js deleted file mode 100644 index 05b2253..0000000 --- a/public/app/assets/Encounter-CbwLX_2x.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,t as a}from"./index-BuU36CvS.js";var o=e(t(),1),s=n();function c(){let[e,t]=(0,o.useState)(``),[n,c]=(0,o.useState)(``),[l,u]=(0,o.useState)(`outpatient`),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(null),_=r({mutationFn:e=>i.post(`/api/generate-hpi-encounter`,e),onSuccess:e=>m(e.hpi)});function v(t){t.preventDefault(),g(null);let r={transcript:d,patientAge:e,patientGender:n,setting:l},i=a.safeParse(r);if(!i.success){g(i.error.issues.map(e=>e.message).join(`, `));return}m(null),_.mutate(i.data)}let y=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,s.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,s.jsxs)(`header`,{children:[(0,s.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Live Encounter → HPI`}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Record or paste an encounter transcript; generate a structured HPI.`})]}),(0,s.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,s.jsx)(`input`,{className:y,placeholder:`e.g. 5 years`,value:e,onChange:e=>t(e.target.value)})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,s.jsxs)(`select`,{className:y,value:n,onChange:e=>c(e.target.value),children:[(0,s.jsx)(`option`,{value:``,children:`Select`}),(0,s.jsx)(`option`,{children:`Male`}),(0,s.jsx)(`option`,{children:`Female`})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Setting`}),(0,s.jsxs)(`select`,{className:y,value:l,onChange:e=>u(e.target.value),children:[(0,s.jsx)(`option`,{value:`outpatient`,children:`Outpatient`}),(0,s.jsx)(`option`,{value:`inpatient`,children:`Inpatient / Floors`})]})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript`}),(0,s.jsx)(`textarea`,{className:y+` min-h-[220px] font-mono text-sm`,placeholder:`Type or paste an encounter transcript, then click Generate.`,value:d,onChange:e=>f(e.target.value)})]}),h&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:h}),_.error&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:_.error.message}),(0,s.jsx)(`button`,{type:`submit`,disabled:_.isPending||!d.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:_.isPending?`Generating…`:`Generate HPI`})]}),p&&(0,s.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,s.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,s.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Generated HPI`}),(0,s.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(p),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,s.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:p})]})]})}export{c as default}; \ No newline at end of file diff --git a/public/app/assets/HospitalCourse-BeNFIL_Z.js b/public/app/assets/HospitalCourse-BeNFIL_Z.js deleted file mode 100644 index 0c2a06c..0000000 --- a/public/app/assets/HospitalCourse-BeNFIL_Z.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-BuU36CvS.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(``),[n,s]=(0,a.useState)(``),[c,l]=(0,a.useState)(``),[u,d]=(0,a.useState)(`floor`),[f,p]=(0,a.useState)(``),[m,h]=(0,a.useState)(`auto`),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(``),[S,C]=(0,a.useState)(null),w=r({mutationFn:e=>i.post(`/api/generate-hospital-course`,e),onSuccess:e=>C({hospitalCourse:e.hospitalCourse,format:e.format||`auto`})});function T(t){t.preventDefault(),C(null);let r=v.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map((e,t)=>({date:`Day ${t+1}`,type:`Progress Note`,content:e}));w.mutate({notes:r,hAndP:g?{date:`Admission`,content:g}:void 0,patientAge:e,patientGender:n,pmh:c,setting:u,los:f?parseInt(f):void 0,formatPreference:m,additionalInstructions:b||void 0})}let E=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,o.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,o.jsxs)(`header`,{children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Hospital Course`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Progress notes + H&P → hospital course summary (prose, day-by-day, or organ-system format).`})]}),(0,o.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,o.jsx)(`input`,{className:E,value:e,onChange:e=>t(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,o.jsxs)(`select`,{className:E,value:n,onChange:e=>s(e.target.value),children:[(0,o.jsx)(`option`,{value:``,children:`Select`}),(0,o.jsx)(`option`,{children:`Male`}),(0,o.jsx)(`option`,{children:`Female`})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Setting`}),(0,o.jsxs)(`select`,{className:E,value:u,onChange:e=>d(e.target.value),children:[(0,o.jsx)(`option`,{value:`floor`,children:`Floor`}),(0,o.jsx)(`option`,{value:`picu`,children:`PICU`}),(0,o.jsx)(`option`,{value:`nicu`,children:`NICU`}),(0,o.jsx)(`option`,{value:`psych`,children:`Psych`})]})]})]}),(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1 col-span-2`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`PMH`}),(0,o.jsx)(`input`,{className:E,placeholder:`e.g. Asthma, hypothyroidism`,value:c,onChange:e=>l(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`LOS (days)`}),(0,o.jsx)(`input`,{className:E,type:`number`,value:f,onChange:e=>p(e.target.value)})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Format`}),(0,o.jsxs)(`select`,{className:E,value:m,onChange:e=>h(e.target.value),children:[(0,o.jsx)(`option`,{value:`auto`,children:`Auto (infer from setting + LOS)`}),(0,o.jsx)(`option`,{value:`prose`,children:`Prose summary`}),(0,o.jsx)(`option`,{value:`dayByDay`,children:`Day-by-day`}),(0,o.jsx)(`option`,{value:`organSystem`,children:`Organ-system (ICU)`})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`H&P`}),(0,o.jsx)(`textarea`,{className:E+` min-h-[120px] font-mono text-sm`,value:g,onChange:e=>_(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsxs)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[`Progress notes `,(0,o.jsx)(`span`,{className:`normal-case font-normal text-muted-foreground`,children:`(separate each note with a blank line)`})]}),(0,o.jsx)(`textarea`,{className:E+` min-h-[200px] font-mono text-sm`,value:v,onChange:e=>y(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Additional instructions`}),(0,o.jsx)(`textarea`,{className:E+` min-h-[60px] text-sm`,value:b,onChange:e=>x(e.target.value)})]}),w.error&&(0,o.jsx)(`div`,{className:`text-sm text-destructive`,children:w.error.message}),(0,o.jsx)(`button`,{type:`submit`,disabled:w.isPending||!v.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:w.isPending?`Generating…`:`Generate Hospital Course`})]}),S&&(0,o.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,o.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,o.jsxs)(`h2`,{className:`text-sm font-semibold`,children:[`Hospital Course `,(0,o.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,S.format,`)`]})]}),(0,o.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(S.hospitalCourse),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,o.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:S.hospitalCourse})]})]})}export{s as default}; \ No newline at end of file diff --git a/public/app/assets/HospitalCourse-CzXNLHTv.js b/public/app/assets/HospitalCourse-CzXNLHTv.js new file mode 100644 index 0000000..7da8916 --- /dev/null +++ b/public/app/assets/HospitalCourse-CzXNLHTv.js @@ -0,0 +1,3 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-C9wKWOAN.js";import{n as a,t as o}from"./EditableResult-DaHQp1Pv.js";import{n as s,t as c}from"./LabsList-CVygta6B.js";import{t as l}from"./Recorder-DdXTjnSC.js";var u=e(t(),1),d=n(),f=`rounded-md border border-input bg-background px-2 py-1 text-sm`;function p({title:e,date:t,onDateChange:n,content:r,onContentChange:i,placeholder:a,moduleName:o,onRemove:s,children:c,testId:p}){let[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(null),v=m||r;return(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,"data-testid":p,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,d.jsx)(`strong`,{className:`text-sm`,children:e}),(0,d.jsx)(`input`,{type:`date`,value:t,onChange:e=>n(e.target.value),className:f+` w-40`}),c,s&&(0,d.jsx)(`button`,{type:`button`,onClick:s,className:`ml-auto text-xs text-destructive hover:text-red-700`,title:`Remove`,children:`🗑`})]}),(0,d.jsx)(l,{module:o,onTranscript:(e,t)=>{i(r?r+(t.appended?` +`:``)+e:e),h(``),_(null)},onInterim:e=>h(e?r?r+` +`+e:e:``),onError:e=>_(e)}),g&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:g}),(0,d.jsx)(`textarea`,{className:f+` w-full min-h-[120px] font-mono text-sm`,placeholder:a||`Paste or type the note…`,value:v,onChange:e=>{i(e.target.value),h(``)}})]})}var m=`inline-flex items-center gap-1 rounded-md border border-amber-400 bg-amber-50 text-amber-900 px-3 py-1.5 text-xs font-medium hover:bg-amber-100 disabled:opacity-50`;function h({currentDraft:e,notes:t,disabled:n}){let[r,i]=(0,u.useState)(!1),[a,o]=(0,u.useState)(null),[s,c]=(0,u.useState)(null);async function l(){i(!0),c(null),o(null);try{let n=await(await fetch(`/api/hospital-course-clarify`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({currentDraft:e,notes:t})})).json();if(!n.success)throw Error(n.error||`Request failed`);o(n.questions)}catch(e){c(e.message)}finally{i(!1)}}return(0,d.jsxs)(`div`,{className:`space-y-2`,"data-testid":`clarify-bar`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:l,disabled:r||n,className:m,"data-testid":`clarify-run`,children:r?`⌛ Asking…`:`❓ What's Missing?`}),s&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:s}),a&&(0,d.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 dark:bg-amber-950/30 p-3 whitespace-pre-wrap text-sm`,children:a})]})}var g=`hospital`;function _(){return{date:``,type:`progress-attending`,content:``}}var v=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,y=`rounded-md border border-input bg-background px-2 py-1 text-sm`;function b(){let[e,t]=(0,u.useState)(``),[n,l]=(0,u.useState)(``),[f,m]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(`floor`),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(`auto`),[O,k]=(0,u.useState)(``),[A,j]=(0,u.useState)(``),[M,N]=(0,u.useState)(``),[P,F]=(0,u.useState)(``),[I,L]=(0,u.useState)(``),[R,z]=(0,u.useState)([_()]),[B,V]=(0,u.useState)([s()]),[H,U]=(0,u.useState)(``),[W,G]=(0,u.useState)(null),K=r({mutationFn:e=>i.post(`/api/generate-hospital-course`,e),onSuccess:e=>G({hospitalCourse:e.hospitalCourse,format:e.format||`auto`})});function q(e,t){z(n=>n.map((n,r)=>r===e?{...n,...t}:n))}function J(){z(e=>[...e,_()])}function Y(e){z(t=>t.filter((t,n)=>n!==e))}function X(e){e.preventDefault(),G(null);let t=R.filter(e=>e.content.trim());t.length!==0&&K.mutate({notes:t,edNote:M.trim()?{date:O,content:M,labs:A}:void 0,hAndP:I.trim()?{date:P,content:I}:void 0,labs:B.filter(e=>e.values.trim()),patientAge:n,patientGender:f,pmh:b,setting:S,los:w?parseInt(w):void 0,formatPreference:E,additionalInstructions:H||void 0})}function Z(){G(null),l(``),m(``),x(``),C(`floor`),T(``),D(`auto`),k(``),j(``),N(``),F(``),L(``),z([_()]),V([s()]),U(``)}let Q=JSON.stringify({edNote:{date:O,labs:A,content:M},hAndP:{date:P,content:I},notes:R,labs:B});return(0,d.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,d.jsxs)(`header`,{children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Hospital Course Generator`}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Upload ED note, H&P, progress notes, labs → AI generates an organized hospital course (prose, day-by-day, or organ-system format).`})]}),(0,d.jsx)(a,{type:g,label:e,setLabel:t,transcript:Q,generatedNote:W?.hospitalCourse||``,partialData:{age:n,gender:f,pmh:b,setting:S,los:w,format:E,additionalInstructions:H},onLoad:e=>{try{let t=e.transcript?JSON.parse(e.transcript):null;t?.edNote&&(k(t.edNote.date||``),j(t.edNote.labs||``),N(t.edNote.content||``)),t?.hAndP&&(F(t.hAndP.date||``),L(t.hAndP.content||``)),Array.isArray(t?.notes)&&t.notes.length&&z(t.notes),Array.isArray(t?.labs)&&t.labs.length&&V(t.labs)}catch{}G(e.generated_note?{hospitalCourse:e.generated_note,format:`auto`}:null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&l(t.age),t?.gender&&m(t.gender),t?.pmh&&x(t.pmh),t?.setting&&C(t.setting),t?.los&&T(t.los),t?.format&&D(t.format),t?.additionalInstructions&&U(t.additionalInstructions)}catch{}t(e.label||``)},onClear:Z}),(0,d.jsxs)(`form`,{onSubmit:X,className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,d.jsx)(`input`,{className:v,value:n,onChange:e=>l(e.target.value)})]}),(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,d.jsxs)(`select`,{className:v,value:f,onChange:e=>m(e.target.value),children:[(0,d.jsx)(`option`,{value:``,children:`Select`}),(0,d.jsx)(`option`,{children:`Male`}),(0,d.jsx)(`option`,{children:`Female`})]})]}),(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Unit`}),(0,d.jsxs)(`select`,{className:v,value:S,onChange:e=>C(e.target.value),children:[(0,d.jsx)(`option`,{value:`floor`,children:`General Floor`}),(0,d.jsx)(`option`,{value:`picu`,children:`PICU`}),(0,d.jsx)(`option`,{value:`nicu`,children:`NICU`}),(0,d.jsx)(`option`,{value:`psych`,children:`Psych/Behavioral`})]})]})]}),(0,d.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,d.jsxs)(`label`,{className:`flex flex-col gap-1 col-span-2`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`PMH`}),(0,d.jsx)(`input`,{className:v,placeholder:`e.g. Asthma, hypothyroidism`,value:b,onChange:e=>x(e.target.value)})]}),(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`LOS (days)`}),(0,d.jsx)(`input`,{className:v,type:`number`,min:1,value:w,onChange:e=>T(e.target.value)})]})]}),(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Format`}),(0,d.jsxs)(`select`,{className:v,value:E,onChange:e=>D(e.target.value),children:[(0,d.jsx)(`option`,{value:`auto`,children:`Auto (infer from setting + LOS)`}),(0,d.jsx)(`option`,{value:`prose`,children:`Prose summary`}),(0,d.jsx)(`option`,{value:`dayByDay`,children:`Day-by-day`}),(0,d.jsx)(`option`,{value:`organSystem`,children:`Organ-system (ICU)`})]})]}),(0,d.jsx)(p,{title:`🚑 ED Note (before admission)`,date:O,onDateChange:k,content:M,onContentChange:N,placeholder:`Paste or type ED note here…`,moduleName:`hospital-ed`,testId:`hc-ed-card`,children:(0,d.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:`ED Labs (e.g. WBC 15, BMP normal…)`,className:y+` flex-1 min-w-[180px]`})}),(0,d.jsx)(p,{title:`📋 H&P (Admission Note)`,date:P,onDateChange:F,content:I,onContentChange:L,placeholder:`Paste or type H&P here…`,moduleName:`hospital-hp`,testId:`hc-hp-card`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`strong`,{className:`text-sm`,children:`📝 Progress Notes`}),(0,d.jsx)(`button`,{type:`button`,onClick:J,className:`rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted`,children:`+ Add progress note`})]}),R.map((e,t)=>(0,d.jsx)(p,{title:`Progress Note #`+(t+1),date:e.date,onDateChange:e=>q(t,{date:e}),content:e.content,onContentChange:e=>q(t,{content:e}),placeholder:`Paste or type note…`,moduleName:`hospital-progress-`+t,onRemove:R.length>1?()=>Y(t):void 0,testId:`hc-progress-`+t,children:(0,d.jsxs)(`select`,{value:e.type,onChange:e=>q(t,{type:e.target.value}),className:y,children:[(0,d.jsx)(`option`,{value:`progress-attending`,children:`Progress — Attending`}),(0,d.jsx)(`option`,{value:`progress-resident`,children:`Progress — Resident`}),(0,d.jsx)(`option`,{value:`progress-np`,children:`Progress — NP/PA`}),(0,d.jsx)(`option`,{value:`consult`,children:`Consult Note`}),(0,d.jsx)(`option`,{value:`procedure`,children:`Procedure Note`}),(0,d.jsx)(`option`,{value:`discharge-summary`,children:`Discharge Summary`})]})},t))]}),(0,d.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,d.jsx)(`strong`,{className:`text-sm`,children:`🧪 Labs`}),(0,d.jsx)(c,{value:B,onChange:V,placeholder:`e.g. WBC 12.5, H/H 10.2/31, BMP: Na 138, K 3.5`,testIdPrefix:`hc-labs`})]}),(0,d.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Additional instructions (optional)`}),(0,d.jsx)(`textarea`,{className:v+` min-h-[60px] text-sm`,value:H,onChange:e=>U(e.target.value),placeholder:`e.g. 'Focus on respiratory course', 'Patient was transferred from outside hospital'`})]}),K.error&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:K.error.message}),(0,d.jsx)(`button`,{type:`submit`,disabled:K.isPending||R.every(e=>!e.content.trim()),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:K.isPending?`Generating…`:`✨ Generate Hospital Course`})]}),W&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o,{text:W.hospitalCourse,onChange:e=>G({hospitalCourse:e,format:W.format}),section:null,title:`Hospital Course (`+W.format+`)`,exportLabel:`hospital-course`,exportType:`hospital-course`,sourceContext:JSON.stringify(R.map(e=>e.content))}),(0,d.jsx)(h,{currentDraft:W.hospitalCourse,notes:R.filter(e=>e.content.trim())})]})]})}export{b as default}; \ No newline at end of file diff --git a/public/app/assets/LabsList-CVygta6B.js b/public/app/assets/LabsList-CVygta6B.js new file mode 100644 index 0000000..bd81d79 --- /dev/null +++ b/public/app/assets/LabsList-CVygta6B.js @@ -0,0 +1 @@ +import{t as e}from"./jsx-runtime-ByY1xr43.js";var t=e(),n=`rounded-md border border-input bg-background px-2 py-1 text-sm`,r=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted`;function i(){return{date:``,values:``}}function a({value:e,onChange:a,placeholder:o,testIdPrefix:s=`labs`}){function c(t,n){a(e.map((e,r)=>r===t?{...e,...n}:e))}function l(){a([...e,i()])}function u(t){a(e.filter((e,n)=>n!==t))}return(0,t.jsxs)(`div`,{className:`space-y-2`,"data-testid":s,children:[e.length===0&&(0,t.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No labs added.`}),e.map((e,r)=>(0,t.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start gap-2`,"data-testid":s+`-row-`+r,children:[(0,t.jsx)(`input`,{type:`date`,value:e.date,onChange:e=>c(r,{date:e.target.value}),className:n+` w-40 shrink-0`}),(0,t.jsx)(`textarea`,{value:e.values,onChange:e=>c(r,{values:e.target.value}),placeholder:o||`e.g. WBC 12.5, H/H 10.2/31, BMP Na 138, K 3.5`,className:n+` flex-1 min-h-[60px] font-mono text-xs`}),(0,t.jsx)(`button`,{type:`button`,onClick:()=>u(r),className:`text-xs text-destructive hover:text-red-700`,title:`Remove`,children:`🗑`})]},r)),(0,t.jsx)(`button`,{type:`button`,onClick:l,className:r,children:`+ Add lab`})]})}export{i as n,a as t}; \ No newline at end of file diff --git a/public/app/assets/Learning-BRd1B0-L.js b/public/app/assets/Learning-CYutu0C6.js similarity index 99% rename from public/app/assets/Learning-BRd1B0-L.js rename to public/app/assets/Learning-CYutu0C6.js index 80e9b03..230a6fc 100644 --- a/public/app/assets/Learning-BRd1B0-L.js +++ b/public/app/assets/Learning-CYutu0C6.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-BuU36CvS.js";var s=e(t(),1),c=new Set([`script`,`style`,`iframe`,`object`,`embed`,`link`,`meta`,`base`,`form`,`input`,`button`,`select`,`textarea`]);function l(e){if(c.has(e.tagName.toLowerCase())){e.remove();return}let t=[];for(let n of Array.from(e.attributes)){let e=n.name.toLowerCase(),r=(n.value||``).trim().toLowerCase();(e.startsWith(`on`)||(e===`href`||e===`src`||e===`xlink:href`)&&(r.startsWith(`javascript:`)||r.startsWith(`data:text/html`))||r.includes(`javascript:`))&&t.push(n.name)}t.forEach(t=>e.removeAttribute(t));for(let t of Array.from(e.children))l(t)}function u(e){if(!e)return``;try{let t=new DOMParser().parseFromString(``+e+``,`text/html`);for(let e of Array.from(t.body.children))l(e);return t.body.innerHTML}catch{return e.replace(/[<>&"']/g,e=>({"<":`<`,">":`>`,"&":`&`,'"':`"`,"'":`'`})[e]||e)}}var d=n(),f=`rounded-lg border border-border bg-card p-5 space-y-3`,p=`px-3 py-1 rounded-full text-xs font-medium border transition-colors cursor-pointer`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,h=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,g=`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`;function _(e){switch(e){case`quiz`:return`Quiz`;case`pearl`:return`Pearl`;case`presentation`:return`Slides`;default:return`Article`}}function v({row:e,onOpen:t}){return(0,d.jsxs)(`button`,{type:`button`,onClick:t,className:`w-full text-left rounded-lg border border-border bg-card hover:bg-muted/60 p-4 transition-colors`,"data-testid":`lh-feed-item-`+e.slug,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground uppercase tracking-wide mb-1`,children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:_(e.content_type)}),e.category_name&&(0,d.jsxs)(`span`,{children:[`· `,e.category_name]}),e.question_count?(0,d.jsxs)(`span`,{children:[`· `,e.question_count,` Q`]}):null]}),(0,d.jsx)(`div`,{className:`text-sm font-semibold`,children:e.title}),e.subject&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.subject})]})}function y({filter:e,query:t,onOpen:n}){let{data:r,isLoading:o,error:s}=a({queryKey:t?[`learning-search`,t]:e?[`learning-category`,e]:[`learning-feed`],queryFn:()=>t?i.get(`/api/learning/search?q=`+encodeURIComponent(t)):e?i.get(`/api/learning/category/`+encodeURIComponent(e)):i.get(`/api/learning/feed?limit=30`)});if(o)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});if(s)return(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:s.message});let c=r?.content||[];return c.length===0?(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground italic py-4`,children:`No content found.`}):(0,d.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,"data-testid":`lh-feed`,children:c.map(e=>(0,d.jsx)(v,{row:e,onOpen:()=>n(e.slug)},e.id))})}function b(e){let t={};for(let n of e)t[n.id]={optionIds:new Set};return t}function x({content:e,onReset:t}){let n=o(),[a,c]=(0,s.useState)(()=>b(e.questions)),[l,u]=(0,s.useState)(null),[p,m]=(0,s.useState)(null),_=r({mutationFn:e=>i.post(`/api/learning/submit-quiz`,e),onSuccess:t=>{u(t),n.invalidateQueries({queryKey:[`learning-content`,e.slug]})},onError:e=>m(e.message||`Submit failed`)});function v(t){t.preventDefault(),m(null);let n=e.questions.map(e=>{let t=a[e.id];return e.question_type===`multi`?{questionId:e.id,optionIds:Array.from(t?.optionIds||[])}:{questionId:e.id,optionId:t?.optionId??null}});_.mutate({contentId:e.id,answers:n})}function y(e,t){c(n=>({...n,[e.id]:{optionId:t,optionIds:new Set}}))}function x(e,t){c(n=>{let r=new Set(n[e.id]?.optionIds||[]);return r.has(t)?r.delete(t):r.add(t),{...n,[e.id]:{optionIds:r}}})}if(l){let n=l.percentage>=80?`bg-green-600`:l.percentage>=50?`bg-amber-500`:`bg-destructive`;return(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-quiz-results`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Results`}),(0,d.jsxs)(`span`,{className:`px-2 py-0.5 rounded text-xs font-semibold text-white `+n,"data-testid":`lh-quiz-score`,children:[l.score,`/`,l.total,` (`,l.percentage,`%)`]})]}),(0,d.jsx)(`div`,{className:`space-y-3`,children:l.results.map((e,t)=>(0,d.jsxs)(`div`,{className:`rounded-md border border-border p-3 bg-muted/30`,children:[(0,d.jsxs)(`div`,{className:`text-sm font-medium`,children:[(0,d.jsx)(`span`,{className:e.isCorrect?`text-green-600`:`text-destructive`,children:e.isCorrect?`✓`:`✗`}),` `,`Q`,t+1,`: `,e.questionText]}),!e.isCorrect&&e.correctOptionText&&(0,d.jsxs)(`div`,{className:`text-xs text-green-700 mt-1`,children:[(0,d.jsx)(`strong`,{children:`Correct:`}),` `,e.correctOptionText]}),!e.isCorrect&&e.selectedExplanation&&(0,d.jsxs)(`div`,{className:`text-xs text-destructive mt-1`,children:[(0,d.jsx)(`strong`,{children:`Why incorrect:`}),` `,e.selectedExplanation]}),e.generalExplanation&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.generalExplanation})]},e.questionId))}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:g,onClick:()=>{u(null),c(b(e.questions))},children:`Retake`}),(0,d.jsx)(`button`,{type:`button`,className:h,onClick:t,children:`Back to Feed`})]})]})}return(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-quiz`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Quiz`}),(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.questions.length,` question`,e.questions.length===1?``:`s`]})]}),(0,d.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[e.questions.map((e,t)=>{let n=e.question_type===`multi`,r=e.question_type===`true_false`?`True / False`:n?`Multiple Select`:`Single Choice`;return(0,d.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2 bg-muted/30`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{className:`font-semibold`,children:[`Q`,t+1]}),(0,d.jsx)(`span`,{children:r})]}),(0,d.jsx)(`div`,{className:`text-sm font-medium`,children:e.question_text}),n&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Select all that apply`}),(0,d.jsx)(`div`,{className:`space-y-1`,children:e.options.map(t=>{let r=a[e.id],i=n?r?.optionIds.has(t.id)===!0:r?.optionId===t.id;return(0,d.jsxs)(`label`,{className:`flex items-start gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-2 py-1`,children:[(0,d.jsx)(`input`,{type:n?`checkbox`:`radio`,name:`q-`+e.id,checked:i,onChange:()=>n?x(e,t.id):y(e,t.id),className:`mt-0.5`}),(0,d.jsx)(`span`,{children:t.option_text})]},t.id)})})]},e.id)}),p&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:p}),(0,d.jsx)(`button`,{type:`submit`,className:h,disabled:_.isPending,"data-testid":`btn-lh-submit-quiz`,children:_.isPending?`Submitting…`:`Submit Answers`})]})]})}function S({slug:e,title:t}){let[n,r]=(0,s.useState)(0),[o,c]=(0,s.useState)(!1),{data:l,isLoading:f,error:p}=a({queryKey:[`learning-slides`,e],queryFn:()=>i.get(`/api/learning/content/`+encodeURIComponent(e)+`/slides`)});if((0,s.useEffect)(()=>{function e(e){l&&((e.key===`ArrowRight`||e.key===`PageDown`)&&r(e=>Math.min(e+1,l.slides.length-1)),(e.key===`ArrowLeft`||e.key===`PageUp`)&&r(e=>Math.max(0,e-1)),e.key===`Escape`&&o&&c(!1))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,o]),f)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading slides…`});if(p)return(0,d.jsxs)(`div`,{className:`text-sm text-destructive`,children:[`Failed to load slides: `,p.message]});if(!l||l.slides.length===0)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No slides in this presentation.`});let m=l.css?u(``):``,h=u(l.slides[n]||``);return(0,d.jsxs)(`div`,{className:o?`fixed inset-0 z-50 bg-background flex flex-col`:`rounded-lg border border-border bg-white dark:bg-black flex flex-col`,"data-testid":`lh-slides`,children:[m&&(0,d.jsx)(`div`,{dangerouslySetInnerHTML:{__html:m}}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2 text-xs`,children:[(0,d.jsxs)(`span`,{className:`text-muted-foreground truncate`,children:[`📊 `,t]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsxs)(`span`,{children:[n+1,` / `,l.slides.length]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>c(!o),className:`px-2 py-1 rounded bg-muted text-xs`,"data-testid":`lh-slides-fullscreen`,children:o?`Exit fullscreen`:`Fullscreen`})]})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto p-4 flex items-center justify-center`,style:{minHeight:o?void 0:`480px`},children:(0,d.jsx)(`div`,{dangerouslySetInnerHTML:{__html:h},"data-testid":`lh-slide-current`})}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e=>Math.max(0,e-1)),disabled:n===0,className:g,"data-testid":`lh-slides-prev`,children:`← Previous`}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`← → to navigate`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e=>Math.min(e+1,l.slides.length-1)),disabled:n>=l.slides.length-1,className:g,"data-testid":`lh-slides-next`,children:`Next →`})]})]})}function C({slug:e,onBack:t}){let{data:n,isLoading:r,error:o}=a({queryKey:[`learning-content`,e],queryFn:()=>i.get(`/api/learning/content/`+encodeURIComponent(e))});if(r)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});if(o)return(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:o.message});if(!n)return null;let s=n.content;return(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`button`,{type:`button`,className:g,onClick:t,"data-testid":`btn-lh-back`,children:`← Back to Feed`}),(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-viewer`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,d.jsx)(`h2`,{className:`text-xl font-semibold`,"data-testid":`lh-viewer-title`,children:s.title}),(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[_(s.content_type),s.category_name?` · `+s.category_name:``,s.author_name?` · `+s.author_name:``]})]}),s.content_type===`presentation`?(0,d.jsx)(S,{slug:s.slug,title:s.title}):(0,d.jsx)(`div`,{className:`text-sm leading-relaxed prose prose-sm dark:prose-invert max-w-none`,"data-testid":`lh-viewer-body`,dangerouslySetInnerHTML:{__html:u(s.body||``)}})]}),s.progress&&s.progress.length>0&&(0,d.jsxs)(`section`,{className:f,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Your past attempts`}),(0,d.jsx)(`div`,{className:`space-y-1 text-sm`,children:s.progress.map((e,t)=>{let n=e.total>0?Math.round(e.score/e.total*100):0,r=n>=70?`text-green-600`:`text-amber-600`;return(0,d.jsxs)(`div`,{className:`flex justify-between border-b border-border py-1`,children:[(0,d.jsx)(`span`,{children:new Date(e.completed_at).toLocaleDateString()}),(0,d.jsxs)(`span`,{className:`font-semibold `+r,children:[e.score,`/`,e.total,` (`,n,`%)`]})]},t)})})]}),s.questions&&s.questions.length>0&&(0,d.jsx)(x,{content:s,onReset:t})]})}function w(){let[e,t]=(0,s.useState)(``),[n,r]=(0,s.useState)(``),[o,c]=(0,s.useState)(null),{data:l}=a({queryKey:[`learning-categories`],queryFn:()=>i.get(`/api/learning/categories`)});return o?(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto p-6`,children:(0,d.jsx)(C,{slug:o,onBack:()=>c(null)})}):(0,d.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,d.jsxs)(`header`,{children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Learning Hub`}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric education, clinical pearls, and self-assessment quizzes.`})]}),(0,d.jsx)(`div`,{className:f,children:(0,d.jsx)(`input`,{type:`search`,className:m,placeholder:`Search topics, subjects…`,value:e,onChange:e=>t(e.target.value),"data-testid":`lh-search`})}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`lh-categories`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(``),className:p+(n===``?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80`),children:`All`}),l?.categories.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e.slug),className:p+(n===e.slug?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80`),"data-testid":`lh-cat-`+e.slug,children:e.name},e.id))]}),(0,d.jsx)(y,{filter:n,query:e.trim(),onOpen:e=>c(e)})]})}export{w as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-C9wKWOAN.js";var s=e(t(),1),c=new Set([`script`,`style`,`iframe`,`object`,`embed`,`link`,`meta`,`base`,`form`,`input`,`button`,`select`,`textarea`]);function l(e){if(c.has(e.tagName.toLowerCase())){e.remove();return}let t=[];for(let n of Array.from(e.attributes)){let e=n.name.toLowerCase(),r=(n.value||``).trim().toLowerCase();(e.startsWith(`on`)||(e===`href`||e===`src`||e===`xlink:href`)&&(r.startsWith(`javascript:`)||r.startsWith(`data:text/html`))||r.includes(`javascript:`))&&t.push(n.name)}t.forEach(t=>e.removeAttribute(t));for(let t of Array.from(e.children))l(t)}function u(e){if(!e)return``;try{let t=new DOMParser().parseFromString(``+e+``,`text/html`);for(let e of Array.from(t.body.children))l(e);return t.body.innerHTML}catch{return e.replace(/[<>&"']/g,e=>({"<":`<`,">":`>`,"&":`&`,'"':`"`,"'":`'`})[e]||e)}}var d=n(),f=`rounded-lg border border-border bg-card p-5 space-y-3`,p=`px-3 py-1 rounded-full text-xs font-medium border transition-colors cursor-pointer`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,h=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,g=`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`;function _(e){switch(e){case`quiz`:return`Quiz`;case`pearl`:return`Pearl`;case`presentation`:return`Slides`;default:return`Article`}}function v({row:e,onOpen:t}){return(0,d.jsxs)(`button`,{type:`button`,onClick:t,className:`w-full text-left rounded-lg border border-border bg-card hover:bg-muted/60 p-4 transition-colors`,"data-testid":`lh-feed-item-`+e.slug,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground uppercase tracking-wide mb-1`,children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:_(e.content_type)}),e.category_name&&(0,d.jsxs)(`span`,{children:[`· `,e.category_name]}),e.question_count?(0,d.jsxs)(`span`,{children:[`· `,e.question_count,` Q`]}):null]}),(0,d.jsx)(`div`,{className:`text-sm font-semibold`,children:e.title}),e.subject&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5 truncate`,children:e.subject})]})}function y({filter:e,query:t,onOpen:n}){let{data:r,isLoading:o,error:s}=a({queryKey:t?[`learning-search`,t]:e?[`learning-category`,e]:[`learning-feed`],queryFn:()=>t?i.get(`/api/learning/search?q=`+encodeURIComponent(t)):e?i.get(`/api/learning/category/`+encodeURIComponent(e)):i.get(`/api/learning/feed?limit=30`)});if(o)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});if(s)return(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:s.message});let c=r?.content||[];return c.length===0?(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground italic py-4`,children:`No content found.`}):(0,d.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,"data-testid":`lh-feed`,children:c.map(e=>(0,d.jsx)(v,{row:e,onOpen:()=>n(e.slug)},e.id))})}function b(e){let t={};for(let n of e)t[n.id]={optionIds:new Set};return t}function x({content:e,onReset:t}){let n=o(),[a,c]=(0,s.useState)(()=>b(e.questions)),[l,u]=(0,s.useState)(null),[p,m]=(0,s.useState)(null),_=r({mutationFn:e=>i.post(`/api/learning/submit-quiz`,e),onSuccess:t=>{u(t),n.invalidateQueries({queryKey:[`learning-content`,e.slug]})},onError:e=>m(e.message||`Submit failed`)});function v(t){t.preventDefault(),m(null);let n=e.questions.map(e=>{let t=a[e.id];return e.question_type===`multi`?{questionId:e.id,optionIds:Array.from(t?.optionIds||[])}:{questionId:e.id,optionId:t?.optionId??null}});_.mutate({contentId:e.id,answers:n})}function y(e,t){c(n=>({...n,[e.id]:{optionId:t,optionIds:new Set}}))}function x(e,t){c(n=>{let r=new Set(n[e.id]?.optionIds||[]);return r.has(t)?r.delete(t):r.add(t),{...n,[e.id]:{optionIds:r}}})}if(l){let n=l.percentage>=80?`bg-green-600`:l.percentage>=50?`bg-amber-500`:`bg-destructive`;return(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-quiz-results`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Results`}),(0,d.jsxs)(`span`,{className:`px-2 py-0.5 rounded text-xs font-semibold text-white `+n,"data-testid":`lh-quiz-score`,children:[l.score,`/`,l.total,` (`,l.percentage,`%)`]})]}),(0,d.jsx)(`div`,{className:`space-y-3`,children:l.results.map((e,t)=>(0,d.jsxs)(`div`,{className:`rounded-md border border-border p-3 bg-muted/30`,children:[(0,d.jsxs)(`div`,{className:`text-sm font-medium`,children:[(0,d.jsx)(`span`,{className:e.isCorrect?`text-green-600`:`text-destructive`,children:e.isCorrect?`✓`:`✗`}),` `,`Q`,t+1,`: `,e.questionText]}),!e.isCorrect&&e.correctOptionText&&(0,d.jsxs)(`div`,{className:`text-xs text-green-700 mt-1`,children:[(0,d.jsx)(`strong`,{children:`Correct:`}),` `,e.correctOptionText]}),!e.isCorrect&&e.selectedExplanation&&(0,d.jsxs)(`div`,{className:`text-xs text-destructive mt-1`,children:[(0,d.jsx)(`strong`,{children:`Why incorrect:`}),` `,e.selectedExplanation]}),e.generalExplanation&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.generalExplanation})]},e.questionId))}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsx)(`button`,{type:`button`,className:g,onClick:()=>{u(null),c(b(e.questions))},children:`Retake`}),(0,d.jsx)(`button`,{type:`button`,className:h,onClick:t,children:`Back to Feed`})]})]})}return(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-quiz`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Quiz`}),(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.questions.length,` question`,e.questions.length===1?``:`s`]})]}),(0,d.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[e.questions.map((e,t)=>{let n=e.question_type===`multi`,r=e.question_type===`true_false`?`True / False`:n?`Multiple Select`:`Single Choice`;return(0,d.jsxs)(`div`,{className:`rounded-md border border-border p-3 space-y-2 bg-muted/30`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{className:`font-semibold`,children:[`Q`,t+1]}),(0,d.jsx)(`span`,{children:r})]}),(0,d.jsx)(`div`,{className:`text-sm font-medium`,children:e.question_text}),n&&(0,d.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Select all that apply`}),(0,d.jsx)(`div`,{className:`space-y-1`,children:e.options.map(t=>{let r=a[e.id],i=n?r?.optionIds.has(t.id)===!0:r?.optionId===t.id;return(0,d.jsxs)(`label`,{className:`flex items-start gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-2 py-1`,children:[(0,d.jsx)(`input`,{type:n?`checkbox`:`radio`,name:`q-`+e.id,checked:i,onChange:()=>n?x(e,t.id):y(e,t.id),className:`mt-0.5`}),(0,d.jsx)(`span`,{children:t.option_text})]},t.id)})})]},e.id)}),p&&(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:p}),(0,d.jsx)(`button`,{type:`submit`,className:h,disabled:_.isPending,"data-testid":`btn-lh-submit-quiz`,children:_.isPending?`Submitting…`:`Submit Answers`})]})]})}function S({slug:e,title:t}){let[n,r]=(0,s.useState)(0),[o,c]=(0,s.useState)(!1),{data:l,isLoading:f,error:p}=a({queryKey:[`learning-slides`,e],queryFn:()=>i.get(`/api/learning/content/`+encodeURIComponent(e)+`/slides`)});if((0,s.useEffect)(()=>{function e(e){l&&((e.key===`ArrowRight`||e.key===`PageDown`)&&r(e=>Math.min(e+1,l.slides.length-1)),(e.key===`ArrowLeft`||e.key===`PageUp`)&&r(e=>Math.max(0,e-1)),e.key===`Escape`&&o&&c(!1))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,o]),f)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading slides…`});if(p)return(0,d.jsxs)(`div`,{className:`text-sm text-destructive`,children:[`Failed to load slides: `,p.message]});if(!l||l.slides.length===0)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No slides in this presentation.`});let m=l.css?u(``):``,h=u(l.slides[n]||``);return(0,d.jsxs)(`div`,{className:o?`fixed inset-0 z-50 bg-background flex flex-col`:`rounded-lg border border-border bg-white dark:bg-black flex flex-col`,"data-testid":`lh-slides`,children:[m&&(0,d.jsx)(`div`,{dangerouslySetInnerHTML:{__html:m}}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2 text-xs`,children:[(0,d.jsxs)(`span`,{className:`text-muted-foreground truncate`,children:[`📊 `,t]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsxs)(`span`,{children:[n+1,` / `,l.slides.length]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>c(!o),className:`px-2 py-1 rounded bg-muted text-xs`,"data-testid":`lh-slides-fullscreen`,children:o?`Exit fullscreen`:`Fullscreen`})]})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto p-4 flex items-center justify-center`,style:{minHeight:o?void 0:`480px`},children:(0,d.jsx)(`div`,{dangerouslySetInnerHTML:{__html:h},"data-testid":`lh-slide-current`})}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-2`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e=>Math.max(0,e-1)),disabled:n===0,className:g,"data-testid":`lh-slides-prev`,children:`← Previous`}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`← → to navigate`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e=>Math.min(e+1,l.slides.length-1)),disabled:n>=l.slides.length-1,className:g,"data-testid":`lh-slides-next`,children:`Next →`})]})]})}function C({slug:e,onBack:t}){let{data:n,isLoading:r,error:o}=a({queryKey:[`learning-content`,e],queryFn:()=>i.get(`/api/learning/content/`+encodeURIComponent(e))});if(r)return(0,d.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`});if(o)return(0,d.jsx)(`div`,{className:`text-sm text-destructive`,children:o.message});if(!n)return null;let s=n.content;return(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`button`,{type:`button`,className:g,onClick:t,"data-testid":`btn-lh-back`,children:`← Back to Feed`}),(0,d.jsxs)(`section`,{className:f,"data-testid":`lh-viewer`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,d.jsx)(`h2`,{className:`text-xl font-semibold`,"data-testid":`lh-viewer-title`,children:s.title}),(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[_(s.content_type),s.category_name?` · `+s.category_name:``,s.author_name?` · `+s.author_name:``]})]}),s.content_type===`presentation`?(0,d.jsx)(S,{slug:s.slug,title:s.title}):(0,d.jsx)(`div`,{className:`text-sm leading-relaxed prose prose-sm dark:prose-invert max-w-none`,"data-testid":`lh-viewer-body`,dangerouslySetInnerHTML:{__html:u(s.body||``)}})]}),s.progress&&s.progress.length>0&&(0,d.jsxs)(`section`,{className:f,children:[(0,d.jsx)(`h3`,{className:`text-base font-semibold`,children:`Your past attempts`}),(0,d.jsx)(`div`,{className:`space-y-1 text-sm`,children:s.progress.map((e,t)=>{let n=e.total>0?Math.round(e.score/e.total*100):0,r=n>=70?`text-green-600`:`text-amber-600`;return(0,d.jsxs)(`div`,{className:`flex justify-between border-b border-border py-1`,children:[(0,d.jsx)(`span`,{children:new Date(e.completed_at).toLocaleDateString()}),(0,d.jsxs)(`span`,{className:`font-semibold `+r,children:[e.score,`/`,e.total,` (`,n,`%)`]})]},t)})})]}),s.questions&&s.questions.length>0&&(0,d.jsx)(x,{content:s,onReset:t})]})}function w(){let[e,t]=(0,s.useState)(``),[n,r]=(0,s.useState)(``),[o,c]=(0,s.useState)(null),{data:l}=a({queryKey:[`learning-categories`],queryFn:()=>i.get(`/api/learning/categories`)});return o?(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto p-6`,children:(0,d.jsx)(C,{slug:o,onBack:()=>c(null)})}):(0,d.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,d.jsxs)(`header`,{children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Learning Hub`}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pediatric education, clinical pearls, and self-assessment quizzes.`})]}),(0,d.jsx)(`div`,{className:f,children:(0,d.jsx)(`input`,{type:`search`,className:m,placeholder:`Search topics, subjects…`,value:e,onChange:e=>t(e.target.value),"data-testid":`lh-search`})}),(0,d.jsxs)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`lh-categories`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(``),className:p+(n===``?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80`),children:`All`}),l?.categories.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>r(e.slug),className:p+(n===e.slug?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80`),"data-testid":`lh-cat-`+e.slug,children:e.name},e.id))]}),(0,d.jsx)(y,{filter:n,query:e.trim(),onOpen:e=>c(e)})]})}export{w as default}; \ No newline at end of file diff --git a/public/app/assets/Milestones-BIwzyW98.js b/public/app/assets/Milestones-BIwzyW98.js new file mode 100644 index 0000000..9005d29 --- /dev/null +++ b/public/app/assets/Milestones-BIwzyW98.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a}from"./index-C9wKWOAN.js";import{t as o}from"./OutputActions-6XZlmtIw.js";var s=e(t(),1),c=n(),l={"Gross Motor":{icon:`🏃`,className:`border-l-4 border-l-blue-500`},"Fine Motor":{icon:`✋`,className:`border-l-4 border-l-purple-500`},Language:{icon:`💬`,className:`border-l-4 border-l-emerald-500`},"Social/Emotional":{icon:`😊`,className:`border-l-4 border-l-amber-500`},Cognitive:{icon:`🧠`,className:`border-l-4 border-l-pink-500`},"Self-Help":{icon:`🧒`,className:`border-l-4 border-l-indigo-500`},Feeding:{icon:`🍼`,className:`border-l-4 border-l-cyan-500`},Sleep:{icon:`💤`,className:`border-l-4 border-l-slate-500`}},u={icon:`📋`,className:`border-l-4 border-l-border`},d=[`Newborn / 1 month`,`2 months`,`4 months`,`6 months`,`9 months`,`12 months`,`15 months`,`18 months`,`24 months`,`30 months`,`36 months`,`48 months`,`60 months`,`6 years`,`7 years`,`8 years`,`9 years`,`10 years`,`11 years`],f=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,p=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,m=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-sm font-semibold disabled:opacity-50`;function h(){let[e,t]=(0,s.useState)(``),[n,h]=(0,s.useState)(``),[g,_]=(0,s.useState)(``),[v,y]=(0,s.useState)(`narrative`),[b,x]=(0,s.useState)({}),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(void 0),[E,D]=(0,s.useState)(null),[O,k]=(0,s.useState)(null),{data:A,isLoading:j}=a({queryKey:[`milestones-data`],queryFn:()=>i.get(`/api/milestones-data`)}),M=(0,s.useMemo)(()=>{let e=A?.milestones?Object.keys(A.milestones):[],t=d.filter(t=>e.includes(t)),n=e.filter(e=>!d.includes(e));return[...t,...n]},[A]);(0,s.useEffect)(()=>{if(!g||!A?.milestones?.[g]){x({});return}let e={},t=A.milestones[g];Object.keys(t).forEach(n=>{t[n].forEach((t,r)=>{e[n+`-`+r]={domain:n,milestone:t,status:null}})}),x(e),C(null),T(void 0),D(null)},[g,A]);let N=r({mutationFn:async()=>{let t={milestones:Object.values(b),ageGroup:g,patientAge:e,patientGender:n,format:v};return i.post(`/api/generate-milestone-narrative`,t)},onSuccess:e=>{C(e.narrative),T(e.summary),D(null),k({kind:`ok`,text:`Generated`})},onError:e=>k({kind:`err`,text:e.message||`Failed`})}),P=r({mutationFn:async()=>i.post(`/api/generate-milestone-summary`,{narrative:S,ageGroup:g,patientAge:e,patientGender:n}),onSuccess:e=>{D(e.summary),k({kind:`ok`,text:`Summary generated`})},onError:e=>k({kind:`err`,text:e.message||`Failed`})});function F(e,t){x(n=>{let r=n[e];if(!r)return n;let i=r.status===t?null:t;return{...n,[e]:{...r,status:i}}})}function I(){x(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,status:`yes`}])))}function L(){x(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,status:null}]))),C(null),T(void 0),D(null)}function R(){if(!g){k({kind:`err`,text:`Select age group`});return}if(!Object.values(b).filter(e=>e.status!==null).length){k({kind:`err`,text:`Assess at least one milestone`});return}k(null),N.mutate()}function z(){if(S)try{sessionStorage.setItem(`wv-milestones-narrative`,S),k({kind:`ok`,text:`Copied to Visit Note — switch to that tab`})}catch{k({kind:`err`,text:`Session storage unavailable`})}}let B=(0,s.useMemo)(()=>{let e={};return Object.entries(b).forEach(([t,n])=>{e[n.domain]||(e[n.domain]=[]),e[n.domain].push({id:t,text:n.milestone,status:n.status})}),e},[b]),V=(0,s.useMemo)(()=>{let e={};return Object.values(b).forEach(t=>{let n=e[t.domain]||(e[t.domain]={total:0,yes:0,no:0});n.total++,t.status===`yes`&&n.yes++,t.status===`no`&&n.no++}),e},[b]);return(0,c.jsxs)(`div`,{className:`space-y-4`,children:[(0,c.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-3`,children:[(0,c.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:[(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Patient age`}),(0,c.jsx)(`input`,{className:f,value:e,onChange:e=>t(e.target.value),placeholder:`e.g. 9 months`})]}),(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Gender`}),(0,c.jsxs)(`select`,{className:f,value:n,onChange:e=>h(e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Select`}),(0,c.jsx)(`option`,{children:`Male`}),(0,c.jsx)(`option`,{children:`Female`})]})]}),(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Age group`}),(0,c.jsxs)(`select`,{className:f,value:g,onChange:e=>_(e.target.value),"data-testid":`ms-age-group`,children:[(0,c.jsx)(`option`,{value:``,children:`-- Select --`}),M.map(e=>(0,c.jsx)(`option`,{value:e,children:e},e))]})]}),(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Output format`}),(0,c.jsxs)(`select`,{className:f,value:v,onChange:e=>y(e.target.value),children:[(0,c.jsx)(`option`,{value:`narrative`,children:`Narrative`}),(0,c.jsx)(`option`,{value:`list`,children:`Structured list`})]})]})]}),(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,c.jsxs)(`span`,{children:[(0,c.jsx)(`span`,{className:`inline-block w-4 h-4 align-middle bg-green-100 text-green-700 text-center rounded mr-1`,children:`✓`}),` Achieved`]}),(0,c.jsxs)(`span`,{children:[(0,c.jsx)(`span`,{className:`inline-block w-4 h-4 align-middle bg-red-100 text-red-700 text-center rounded mr-1`,children:`✗`}),` Not achieved`]}),(0,c.jsxs)(`span`,{children:[(0,c.jsx)(`span`,{className:`inline-block w-4 h-4 align-middle bg-muted text-center rounded mr-1`,children:`—`}),` Not assessed (omitted)`]})]})]}),j&&(0,c.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading milestones…`}),g&&Object.keys(B).length===0&&!j&&(0,c.jsx)(`div`,{className:`text-sm text-muted-foreground italic`,children:`No data for this age group.`}),Object.entries(B).map(([e,t])=>{let n=l[e]||u,r=V[e];return(0,c.jsxs)(`div`,{className:`rounded-lg bg-card p-0 overflow-hidden `+n.className,children:[(0,c.jsxs)(`div`,{className:`px-4 py-2 flex items-center gap-2 bg-muted/40`,children:[(0,c.jsx)(`span`,{children:n.icon}),(0,c.jsx)(`span`,{className:`font-semibold`,children:e}),(0,c.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,"data-testid":`ms-badge-`+e.replace(/\W/g,`_`),children:r&&r.yes+r.no>0?r.yes+`✓ `+r.no+`✗ / `+r.total:r.total+` items`})]}),(0,c.jsx)(`div`,{className:`divide-y divide-border`,children:t.map(e=>(0,c.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 text-sm`,children:[(0,c.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:()=>F(e.id,`yes`),className:`w-8 h-8 rounded border text-xs font-bold `+(e.status===`yes`?`bg-green-100 text-green-700 border-green-400`:`bg-background border-border hover:bg-muted`),"aria-label":`Achieved: `+e.text,children:`✓`}),(0,c.jsx)(`button`,{type:`button`,onClick:()=>F(e.id,`no`),className:`w-8 h-8 rounded border text-xs font-bold `+(e.status===`no`?`bg-red-100 text-red-700 border-red-400`:`bg-background border-border hover:bg-muted`),"aria-label":`Not achieved: `+e.text,children:`✗`})]}),(0,c.jsx)(`span`,{className:e.status===`yes`?`text-green-700`:e.status===`no`?`text-red-700 line-through decoration-red-400`:``,children:e.text})]},e.id))})]},e)}),Object.keys(B).length>0&&(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:I,className:p,children:`✓ All yes`}),(0,c.jsx)(`button`,{type:`button`,onClick:L,className:p,children:`🧹 Clear all`}),(0,c.jsx)(`button`,{type:`button`,onClick:R,disabled:N.isPending,className:m,children:N.isPending?`Generating…`:`✨ Generate narrative`})]}),O&&(0,c.jsx)(`div`,{className:`text-sm `+(O.kind===`ok`?`text-green-600`:`text-destructive`),children:O.text}),S&&(0,c.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,c.jsxs)(`header`,{className:`px-4 py-2 border-b border-border bg-muted/40 flex items-center justify-between`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Developmental assessment`}),(0,c.jsx)(`button`,{type:`button`,onClick:z,className:p,children:`📋 Copy to Note`})]}),w&&(0,c.jsxs)(`div`,{className:`flex gap-4 text-xs px-4 py-2 border-b border-border bg-background text-muted-foreground`,children:[(0,c.jsxs)(`span`,{children:[`✓ Achieved: `,w.achieved]}),(0,c.jsxs)(`span`,{children:[`✗ Not yet: `,w.notAchieved]}),(0,c.jsxs)(`span`,{children:[`— Not assessed: `,w.notAssessed,` (omitted)`]})]}),(0,c.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:S}),(0,c.jsx)(`div`,{className:`px-4 pb-3`,children:(0,c.jsx)(o,{text:S,onUpdate:C,exportLabel:`milestones`,exportType:`milestones`})}),(0,c.jsxs)(`div`,{className:`px-4 pb-4 pt-2 border-t border-border space-y-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:()=>P.mutate(),disabled:P.isPending,className:p,"data-testid":`ms-summary-btn`,children:P.isPending?`Summarizing…`:E?`↻ Regenerate summary`:`📏 3-sentence summary`}),E&&(0,c.jsx)(`div`,{className:`rounded-md bg-muted/40 p-3 whitespace-pre-wrap text-sm`,children:E})]})]})]})}export{h as default}; \ No newline at end of file diff --git a/public/app/assets/OutputActions-6XZlmtIw.js b/public/app/assets/OutputActions-6XZlmtIw.js new file mode 100644 index 0000000..0a93d32 --- /dev/null +++ b/public/app/assets/OutputActions-6XZlmtIw.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{i as r}from"./index-C9wKWOAN.js";var i=e(t(),1),a=n();function o({text:e,onUpdate:t,sourceContext:n,exportLabel:o,exportType:s}){let[c,l]=(0,i.useState)(``),[u,d]=(0,i.useState)(null),[f,p]=(0,i.useState)(null),m=(0,i.useRef)(null),h=(0,i.useRef)(null);async function g(){try{await navigator.clipboard.writeText(e),p({kind:`ok`,text:`Copied`})}catch{p({kind:`err`,text:`Copy failed`})}}async function _(){if(!e.trim()){p({kind:`err`,text:`Nothing to read`});return}if(m.current&&!m.current.paused){m.current.pause(),m.current=null,h.current&&=(URL.revokeObjectURL(h.current),null);return}d(`tts`),p(null);try{let t=await fetch(`/api/text-to-speech`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e})});if(!t.ok){let e=(t.headers.get(`content-type`)||``).includes(`json`)&&(await t.json()).error||`TTS failed`;throw Error(e)}let n=await t.blob(),r=URL.createObjectURL(n);h.current=r;let i=new Audio(r);m.current=i,i.onended=()=>{URL.revokeObjectURL(r),h.current===r&&(h.current=null),m.current===i&&(m.current=null)},await i.play()}catch(e){p({kind:`err`,text:e.message})}finally{d(null)}}async function v(){if(!e.trim()){p({kind:`err`,text:`Nothing to export`});return}d(`export`),p(null);try{let t=o+`-`+Date.now();p({kind:`ok`,text:(await r.post(`/api/nextcloud/export`,{content:e,filename:t,type:s})).message||`Exported`})}catch(e){p({kind:`err`,text:e.message||`Nextcloud not connected`})}finally{d(null)}}async function y(){if(!e.trim()){p({kind:`err`,text:`No document to refine`});return}if(!c.trim()){p({kind:`err`,text:`Enter instructions`});return}d(`refine`),p(null);try{t((await r.post(`/api/refine`,{currentDocument:e,instructions:c.trim(),sourceContext:n||void 0})).refined),l(``),p({kind:`ok`,text:`Refined`})}catch(e){p({kind:`err`,text:e.message||`Refine failed`})}finally{d(null)}}async function b(){if(!e.trim()){p({kind:`err`,text:`Nothing to shorten`});return}d(`shorten`),p(null);try{t((await r.post(`/api/shorten`,{document:e})).shortened),p({kind:`ok`,text:`Shortened`})}catch(e){p({kind:`err`,text:e.message||`Shorten failed`})}finally{d(null)}}let x=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,S=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-1.5 text-xs font-medium disabled:opacity-50`;return(0,a.jsxs)(`div`,{className:`space-y-2`,"data-testid":`output-actions-`+s,children:[(0,a.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:g,className:S,"data-testid":`out-copy`,children:`📋 Copy`}),(0,a.jsx)(`button`,{type:`button`,onClick:_,disabled:u===`tts`,className:x,"data-testid":`out-read`,children:u===`tts`?`⌛ Loading…`:m.current&&!m.current.paused?`⏹ Stop`:`🔊 Read`}),(0,a.jsx)(`button`,{type:`button`,onClick:v,disabled:u===`export`,className:x,"data-testid":`out-export`,children:u===`export`?`⌛ Exporting…`:`☁️ Export to Nextcloud`})]}),(0,a.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,a.jsx)(`textarea`,{className:`flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px]`,placeholder:`Tell AI how to modify (e.g., 'make it shorter', 'add that patient has asthma history')`,value:c,onChange:e=>l(e.target.value),"data-testid":`out-refine-input`}),(0,a.jsxs)(`div`,{className:`flex sm:flex-col gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,onClick:y,disabled:u===`refine`||!c.trim(),className:S,"data-testid":`out-refine`,children:u===`refine`?`⌛ Refining…`:`✏️ Refine`}),(0,a.jsx)(`button`,{type:`button`,onClick:b,disabled:u===`shorten`,className:x,"data-testid":`out-shorten`,children:u===`shorten`?`⌛ Shortening…`:`📏 Shorter`})]})]}),f&&(0,a.jsx)(`div`,{className:`text-xs `+(f.kind===`ok`?`text-green-600`:`text-destructive`),children:f.text})]})}export{o as t}; \ No newline at end of file diff --git a/public/app/assets/PeGuide-eWPZEjQC.js b/public/app/assets/PeGuide-DChX9qua.js similarity index 99% rename from public/app/assets/PeGuide-eWPZEjQC.js rename to public/app/assets/PeGuide-DChX9qua.js index c884176..e4e9b7b 100644 --- a/public/app/assets/PeGuide-eWPZEjQC.js +++ b/public/app/assets/PeGuide-DChX9qua.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-BuU36CvS.js";var a=e(t(),1),o=[`newborn`,`infant`,`toddler`,`preschool`,`school`,`adolescent`],s=[`msk`,`neuro`,`resp`,`cv`],c={msk:`Musculoskeletal`,neuro:`Neuro`,resp:`Respiratory`,cv:`Cardiovascular`},l={newborn:{label:`Newborn (0–28 days)`,msk:{overview:`Exam done warm, quiet, undressed. Focus: birth injury, DDH, congenital anomaly. All steps symmetric.`,components:[{name:`Resting posture`,steps:[{label:`Observe posture`,method:`Place supine and undisturbed for 30s`,normal:`Symmetric flexion at hips, knees, elbows`},{label:`Hand position`,method:`Inspect resting hands`,normal:`Loosely fisted; opens intermittently`},{label:`Symmetry`,method:`Compare left vs right side at rest`,normal:`Mirror-image posture`}],abnormalHints:[`Frog-leg (hypotonia)`,`Asymmetric arm (brachial plexus/clavicle fx)`,`Opisthotonos (CNS)`,`Persistent fisting with thumb in palm`]},{name:`Clavicles`,steps:[{label:`Palpate right clavicle`,method:`Trace from sternoclavicular joint to acromion with index finger`,normal:`Smooth, continuous, no step-off`},{label:`Palpate left clavicle`,method:`Same technique on left side`,normal:`Smooth, continuous`},{label:`Crepitus check`,method:`Light pressure along length of clavicle while gently abducting arm`,normal:`No crepitus, no pain response`}],abnormalHints:[`Palpable step-off or callus (fracture — LGA, shoulder dystocia)`,`Asymmetric Moro on affected side`]},{name:`Hips — DDH screen`,steps:[{label:`Thigh/gluteal folds`,method:`Undress completely; compare skin-fold symmetry`,normal:`Symmetric thigh and gluteal folds`},{label:`Abduction`,method:`Flex hips 90°, abduct simultaneously`,normal:`Both hips abduct to ≥75° symmetrically`},{label:`Barlow maneuver`,method:`Thumb on medial thigh, flex hip 90°, adduct, apply gentle posterior pressure`,normal:`No clunk or movement felt (negative)`},{label:`Ortolani maneuver`,method:`From Barlow position: abduct and lift with fingers on greater trochanter`,normal:`No clunk as hip returns (negative)`},{label:`Galeazzi sign`,method:`Knees flexed together with feet on table; compare knee heights`,normal:`Knees level — no leg-length discrepancy`}],abnormalHints:[`Palpable Ortolani clunk (dislocated, reducible)`,`Barlow clunk (dislocatable)`,`Limited abduction`,`Positive Galeazzi (shortened femur)`]},{name:`Spine and back`,steps:[{label:`Position prone`,method:`Turn infant prone, support chest`,normal:`Tolerates position, lifts head briefly`},{label:`Palpate midline`,method:`Run finger from C-spine to coccyx`,normal:`Straight midline, no step-offs or gaps`},{label:`Sacral inspection`,method:`Inspect sacral dimple if present; measure depth, distance from anus`,normal:`No dimple, or dimple <5mm deep and <2.5cm from anus`},{label:`Cutaneous markers`,method:`Inspect midline skin from neck to coccyx`,normal:`No hair tuft, hemangioma, lipoma, or sinus tract`}],abnormalHints:[`Deep sacral dimple (>5mm) or >2.5cm from anus — imaging`,`Hair tuft, hemangioma, lipoma (occult dysraphism)`,`Palpable defect`]},{name:`Upper extremities`,steps:[{label:`Spontaneous movement`,method:`Observe both arms for 30s`,normal:`Symmetric antigravity movement`},{label:`Digits`,method:`Count and inspect fingers both hands`,normal:`5 digits each, no webbing or duplication`},{label:`Palmar creases`,method:`Inspect palmar creases`,normal:`Normal triradiate creases`}],abnormalHints:[`Erb/Klumpke palsy (paucity of movement)`,`Polydactyly, syndactyly`,`Single transverse (simian) palmar crease`]},{name:`Lower extremities / feet`,steps:[{label:`Hip and knee range`,method:`Gently flex, extend, internally/externally rotate each`,normal:`Full symmetric range, no contracture`},{label:`Foot alignment`,method:`Inspect resting foot position`,normal:`Midline or mildly adducted forefoot`},{label:`Passive correction`,method:`Gently attempt to bring foot to neutral`,normal:`Fully correctable to neutral`},{label:`Stroke test`,method:`Stroke lateral border of foot`,normal:`Foot dorsiflexes and everts reflexively`}],abnormalHints:[`Rigid clubfoot (non-correctable talipes equinovarus)`,`Fixed metatarsus adductus`,`Rocker-bottom foot (trisomy 18)`,`Calcaneovalgus`]}]},neuro:{overview:`Primitive reflexes present and symmetric. Tone assessed passively and actively. Full exam 3–5 min on a quiet, fed infant.`,components:[{name:`Alertness and behavior`,steps:[{label:`State cycling`,method:`Observe over 1–2 min for alert periods`,normal:`Alert periods with spontaneous eye opening`},{label:`Response to voice`,method:`Speak softly near ear`,normal:`Quiets to voice or turns toward sound`},{label:`Consolability`,method:`If crying, attempt to soothe with swaddling or voice`,normal:`Consolable within 1–2 min`}],abnormalHints:[`Lethargy`,`Jitteriness not stopped by passive flexion`,`Irritability unrelieved by feeding`]},{name:`Cranial nerves`,steps:[{label:`CN II — pupil response`,method:`Shine light in each eye`,normal:`Pupils equal, reactive to light, direct and consensual`},{label:`CN II — blink to light`,method:`Bright light in the line of sight`,normal:`Reflex blink`},{label:`CN VII — facial symmetry at rest`,method:`Observe resting face`,normal:`Symmetric nasolabial folds`},{label:`CN VII — facial symmetry with cry`,method:`Note face during a cry`,normal:`Symmetric grimace`},{label:`CN IX, X, XII — suck and swallow`,method:`Offer clean gloved finger, pacifier, or during feed`,normal:`Strong coordinated suck-swallow, no choking`}],abnormalHints:[`Asymmetric face (CN VII injury — usually forceps)`,`Poor suck or uncoordinated swallow`,`Fixed or unequal pupil`]},{name:`Tone — passive`,steps:[{label:`Pull-to-sit`,method:`Grasp hands/wrists, pull smoothly to sit`,normal:`Brief head lag at term; not dramatic`},{label:`Ventral suspension`,method:`Suspend prone over hand at chest`,normal:`Head briefly lifts to horizontal; extremities flexed`},{label:`Arm recoil`,method:`Extend both arms fully at elbows, release`,normal:`Rapid return to flexion`},{label:`Popliteal angle`,method:`Hip flexed 90°, extend knee maximally`,normal:`≤110°`}],abnormalHints:[`Marked head lag (hypotonia)`,`Slip-through on vertical suspension`,`Hypertonia / scissoring`,`Floppy limbs with no recoil`]},{name:`Spontaneous movement`,steps:[{label:`Observe limbs`,method:`Undisturbed over 1 min, note movement`,normal:`Symmetric antigravity movement of all 4 limbs`},{label:`Quality of movement`,method:`Note smoothness vs jitteriness`,normal:`Smooth, mildly variable movements`}],abnormalHints:[`Paucity of movement in one limb`,`Coarse jitteriness`,`Clonic jerks`,`Tonic posturing`]},{name:`Primitive reflexes`,steps:[{label:`Moro`,method:`Support head; allow 30° head drop or loud clap`,normal:`Symmetric arm abduction then flexion, often cry`},{label:`Rooting`,method:`Stroke cheek at corner of mouth`,normal:`Turns head toward stroke and opens mouth`},{label:`Palmar grasp`,method:`Press into palm with finger`,normal:`Strong, symmetric finger flexion`},{label:`Plantar grasp`,method:`Press ball of foot below toes`,normal:`Toes flex around finger symmetrically`},{label:`Stepping`,method:`Hold upright with feet touching surface`,normal:`Alternating stepping movements`},{label:`Tonic neck (fencing)`,method:`Turn head to one side with infant supine`,normal:`Same-side arm extends, opposite flexes (not obligate)`},{label:`Galant`,method:`Stroke paravertebrally from shoulder to buttock, one side`,normal:`Trunk curves toward stroked side`}],abnormalHints:[`Absent or asymmetric Moro — CNS injury, brachial plexus, clavicle fx`,`Absent grasps — CNS depression`,`Obligate tonic neck is abnormal`]},{name:`Babinski (plantar response)`,steps:[{label:`Stroke lateral sole`,method:`Firm stroke from heel toward toes along lateral plantar border`,normal:`Up-going great toe with fanning (normal in newborn)`},{label:`Symmetry check`,method:`Repeat opposite foot`,normal:`Symmetric response`}],abnormalHints:[`Asymmetric response is always abnormal`]}]},resp:{overview:`Newborn respiratory transition — RDS, TTN, pneumonia, meconium aspiration dominate the differential. Normal RR ≤ 60. Grunting is an alarm sign.`,components:[{name:`Inspection`,significance:`Detects distress and localises cause. Silverman score quantifies retraction severity.`,pearl:`Grunting is physiologic PEEP against a partially closed glottis — always a sign of significant lung pathology in a newborn. Never dismiss it as fussy breathing.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s, quiet and undisturbed.`,normal:`40–60 /min; tachypnea > 60`},{label:`Work of breathing (Silverman)`,method:`Inspect for upper-chest retraction, lower-chest retraction, xiphoid retraction, nasal flaring, grunting. Score 0–2 for each.`,normal:`Total Silverman 0 — no distress`},{label:`Audible sounds`,method:`Listen without stethoscope — stridor? grunting? wheeze across the room?`,normal:`Quiet respirations`},{label:`Colour`,method:`Inspect trunk and mucous membranes for central cyanosis; acrocyanosis (blue hands/feet) is normal in the first days.`,normal:`Pink trunk and mucous membranes`},{label:`Chest shape`,method:`Inspect AP:transverse diameter and symmetry.`,normal:`Slightly barrel-shaped is normal; symmetric`}],abnormalHints:[`Grunting — RDS, pneumonia, sepsis, CHD`,`Retractions + tachypnea — RDS, TTN, pneumothorax`,`Central cyanosis — cyanotic CHD, severe lung disease, persistent pulmonary HTN`,`Asymmetric chest movement — pneumothorax, diaphragmatic hernia`]},{name:`Auscultation`,significance:`Short stethoscope time in neonates because they fuss easily — get the most important zones first.`,pearl:`Listen at the axilla, not just the anterior chest — pneumothorax can sound normal anteriorly. Auscultate both axillae systematically.`,steps:[{label:`Air entry — anterior`,method:`Listen bilaterally at the upper and lower anterior chest.`,normal:`Symmetric bilateral air entry`},{label:`Air entry — axillary`,method:`Listen bilaterally at each axilla — this is the most sensitive area for detecting a small pneumothorax.`,normal:`Clear and symmetric`},{label:`Adventitious sounds`,method:`Listen for transmitted upper-airway sounds, crackles (RDS, pneumonia), grunting sounds.`,normal:`No crackles, no wheeze, clear sounds`},{label:`Inspiration:expiration ratio`,method:`Observe breath-sound timing.`,normal:`Inspiration > expiration in length`}],abnormalHints:[`Asymmetric air entry — pneumothorax, diaphragmatic hernia, endobronchial intubation`,`Fine crackles — RDS, TTN, pneumonia`,`Absent breath sounds unilaterally — pneumothorax or selective intubation`]}]},cv:{overview:`Neonatal CV exam screens for CHD — the window of presentation is short and some lesions (duct-dependent) decompensate within hours of birth. Pre/postductal saturations + femoral pulses are the two fastest screens.`,components:[{name:`Inspection and pre/postductal saturations`,significance:`Pre/postductal SpO₂ differential > 3% suggests a duct-dependent lesion or persistent pulmonary HTN. Universal CCHD screening uses this.`,pearl:`Pulse ox on the right hand = preductal (proximal to PDA insertion). Foot = postductal. Both arms and both legs should match; a differential is a red flag for critical CHD.`,steps:[{label:`Central cyanosis`,method:`Inspect tongue, lips, oral mucosa.`,normal:`Pink mucous membranes`},{label:`Pre/postductal SpO₂`,method:`Measure SpO₂ in right hand (preductal) AND either foot (postductal). Baby must be ≥24 hr old for CCHD screening.`,normal:`Both ≥ 95% AND difference < 3%`},{label:`Peripheral perfusion`,method:`Capillary refill on sternum; note mottling or distal cyanosis.`,normal:`Capillary refill < 2 s, warm pink extremities`},{label:`Precordial activity`,method:`Inspect anterior chest for hyperactive precordium.`,normal:`Not visible or minimally visible`}],abnormalHints:[`Central cyanosis with SpO₂ < 95% → cyanotic CHD workup (4-extremity BP, ECG, hyperoxia test, echo)`,`Differential > 3% (pre > post) → duct-dependent systemic flow (HLHS, coarctation, interrupted arch)`,`Preductal < postductal — persistent pulmonary HTN with reversed shunt`]},{name:`Palpation and auscultation`,significance:`Absent femoral pulses + arm-leg BP gradient = coarctation. Many CHD lesions manifest murmurs only after ductus closes (48–72 h).`,pearl:`Always palpate femoral pulses before discharging any newborn. Absent femorals in a well-appearing baby can be the only finding in a ductal-dependent coarctation — catastrophic if missed.`,steps:[{label:`Apex beat`,method:`Palpate at the 4th ICS left of sternum (apex is higher in newborns).`,normal:`Palpable at 4th ICS, mid-clavicular or just lateral`},{label:`Femoral pulses`,method:`Palpate both femoral pulses at the mid-inguinal point while simultaneously feeling the right brachial pulse — detects delay.`,normal:`Present, symmetric, equal timing with brachial`},{label:`Auscultate each cardiac area`,method:`Use pediatric diaphragm at each classic point; baby quiet if possible.`,normal:`S1 S2 crisp; physiologic flow murmur sometimes present in the first 24–48 h`},{label:`Continuous murmur`,method:`Listen below the left clavicle for a continuous ("machinery") murmur of PDA.`,normal:`No continuous murmur after the first day of life in a term baby`},{label:`Four-limb BP (if any concern)`,method:`Right arm, left arm, both legs.`,normal:`Within 10 mmHg across limbs`}],abnormalHints:[`Absent femoral pulses — coarctation of the aorta (surgical emergency if duct-dependent)`,`Harsh holosystolic at LLSB — VSD`,`Continuous machinery murmur — PDA (expected in preterm; in term > 48 h is abnormal)`,`Gallop S3/S4 — heart failure`,`Single S2 — transposition, truncus, severe AS/PS`]}]}},infant:{label:`Infant (1–12 months)`,msk:{overview:`Continued DDH screen through 6 months. Watch motor progression and symmetry of tone/movement.`,components:[{name:`Hips — continued DDH screen`,steps:[{label:`Thigh-fold symmetry`,method:`Inspect with infant supine, thighs flexed`,normal:`Symmetric folds`},{label:`Barlow/Ortolani (through 3mo)`,method:`As in newborn — thumb medial, flex 90°, adduct+push then abduct+lift`,normal:`Negative bilaterally`},{label:`Abduction (any age)`,method:`Flex 90°, abduct simultaneously`,normal:`≥70° symmetric abduction`},{label:`Galeazzi`,method:`Knees flexed feet flat on exam table`,normal:`Knees equal height`}],abnormalHints:[`Clunk on Barlow/Ortolani (<3mo)`,`Limited abduction`,`Asymmetric folds`,`Positive Galeazzi`]},{name:`Gross-motor milestones (age-appropriate)`,steps:[{label:`Head control`,method:`Prone, pull-to-sit, held upright`,normal:`Age-appropriate: 2mo lifts head 45°; 4mo no head lag`},{label:`Rolling`,method:`Observe on flat surface`,normal:`Rolls back-to-front by 5–6mo`},{label:`Sitting`,method:`Place in sitting position`,normal:`Tripod sit by 6mo; sits without support by 7–8mo`},{label:`Standing`,method:`Support under arms`,normal:`Bears weight by 6mo; pulls to stand by 9mo`}],abnormalHints:[`Milestone delay by ≥2mo`,`Loss of previously attained milestone`,`Asymmetric use of limbs`]},{name:`Spine`,steps:[{label:`Palpate seated`,method:`Run finger along spine with infant sitting or held upright`,normal:`Midline, no step-offs`},{label:`Back curvature`,method:`Inspect sitting and lying`,normal:`Physiologic gentle kyphosis in early infancy; lumbar lordosis as sitting develops`}],abnormalHints:[`Fixed kyphoscoliosis`,`Sacral dimple with cutaneous marker`,`Step-off`]},{name:`Extremities`,steps:[{label:`Passive range`,method:`Through each major joint`,normal:`Full symmetric range`},{label:`Joint inspection`,method:`Inspect for swelling, warmth, effusion`,normal:`No swelling, warmth, or effusion`},{label:`Feet alignment`,method:`Observe standing if pulling up, else passive positioning`,normal:`Correctable or aligned feet; flexible`}],abnormalHints:[`Joint swelling/warmth (septic vs reactive arthritis)`,`Rigid clubfoot`,`Persistent asymmetric tone`]}]},neuro:{overview:`Primitive reflexes fading on schedule; protective reflexes emerging; gross motor and tone interlinked.`,components:[{name:`Alertness and social engagement`,steps:[{label:`Social smile`,method:`Face-to-face interaction`,normal:`Social smile by 6–8 weeks`},{label:`Tracking`,method:`Move object across visual field`,normal:`180° horizontal tracking by 3mo`},{label:`Engagement`,method:`Face-to-face, voice, toys`,normal:`Age-appropriate reciprocal interaction`}],abnormalHints:[`No social smile by 3mo`,`Absent tracking past 3mo`,`Poor engagement (developmental concern)`]},{name:`Cranial nerves`,steps:[{label:`Pupils`,method:`Light response each eye`,normal:`Equal reactive`},{label:`Eye alignment`,method:`Inspect with gaze forward and in all directions`,normal:`No strabismus past 4mo`},{label:`Facial symmetry`,method:`Observe smile and cry`,normal:`Symmetric`},{label:`Suck and swallow`,method:`Observe feeding`,normal:`Coordinated, no choking`}],abnormalHints:[`Persistent nystagmus`,`Strabismus past 4mo`,`Asymmetric face`]},{name:`Tone`,steps:[{label:`Pull-to-sit`,method:`Gently pull wrists/hands`,normal:`No head lag by 4mo`},{label:`Ventral suspension`,method:`Support prone, observe`,normal:`Head above horizontal, extremities actively flexed (age-dependent)`},{label:`Vertical suspension`,method:`Support under arms, lift`,normal:`Does not slip through hands`}],abnormalHints:[`Persistent head lag past 4mo (hypotonia)`,`Hypertonia / scissoring (UMN)`,`Slip-through on vertical suspension`]},{name:`Primitive reflex integration`,steps:[{label:`Moro`,method:`Head drop or clap`,normal:`Absent by 6mo`},{label:`Palmar grasp`,method:`Press into palm`,normal:`Integrated by 5–6mo; replaced by voluntary grasp`},{label:`Tonic neck`,method:`Turn head to side`,normal:`Absent by 6mo`},{label:`Rooting`,method:`Stroke cheek`,normal:`Absent by 3–4mo`}],abnormalHints:[`Persistence of any primitive reflex past 6mo warrants eval (CP, CNS injury)`]},{name:`Protective and postural reflexes`,steps:[{label:`Parachute`,method:`Held prone, tilt head downward suddenly`,normal:`Symmetric arm extension protectively by 9mo (emerges 6–9mo)`},{label:`Lateral propping`,method:`Seated infant, gentle tilt to one side`,normal:`Arm extends to catch by 6–7mo`},{label:`Landau`,method:`Suspend prone`,normal:`Extends head, spine, legs by 6mo`}],abnormalHints:[`Absent parachute after 12mo (concerning)`,`Asymmetric lateral propping`,`Absent Landau`]}]},resp:{overview:`Infant respiratory disease centers on bronchiolitis, reactive airways, and pneumonia. Normal RR ≤ 50 (< 2 mo: ≤ 60). Infants are obligate nose-breathers — nasal congestion alone can cause significant WOB.`,components:[{name:`Inspection`,significance:`Infant distress signs escalate fast. Nasal flaring, tracheal tug, head bobbing = significant WOB. Apnea in an infant < 2 mo is an emergency.`,pearl:`A quiet infant with retractions is more worrying than a crying one — exhausted infants stop crying and become hypoxic silently.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s while quiet.`,normal:`< 2 mo: ≤ 60; 2–12 mo: ≤ 50`},{label:`Work of breathing`,method:`Inspect nasal flaring, subcostal/intercostal/suprasternal retractions, tracheal tug, head-bobbing, accessory muscle use.`,normal:`No retractions, effortless breathing`},{label:`Audible sounds`,method:`Stridor? Wheeze across the room? Grunting? Prolonged expiration?`,normal:`Quiet respirations`},{label:`Colour and feeding history`,method:`Central cyanosis? Poor feeding (feeding is an effort marker in infants)?`,normal:`Pink, feeds well`},{label:`Apnea observation`,method:`Watch for ≥ 20-s pauses or pauses < 20 s with bradycardia/cyanosis.`,normal:`No apneas`}],abnormalHints:[`Grunting / persistent retractions — pneumonia, bronchiolitis, CHF`,`Wheeze — bronchiolitis (RSV), asthma, foreign body`,`Stridor — croup (6 mo–6 y), laryngomalacia (infant), foreign body`,`Apnea — bronchiolitis, sepsis, pertussis, seizure`]},{name:`Auscultation`,significance:`Infants have a thin chest wall — sounds transmit widely. Symmetry, wheeze, and crackles are the main findings.`,pearl:`In bronchiolitis, the classical finding is widespread end-inspiratory fine crackles PLUS expiratory wheeze. Tachypnea + retractions in an RSV-season infant confirms.`,steps:[{label:`Air entry — bilateral`,method:`Warm stethoscope; listen at anterior chest and both axillae, both sides.`,normal:`Symmetric air entry`},{label:`Wheeze`,method:`Listen in expiration. Diffuse wheeze = lower airway; focal wheeze = foreign body or local obstruction.`,normal:`No wheeze`},{label:`Crackles`,method:`Listen in late inspiration. Focal = pneumonia; diffuse fine = bronchiolitis.`,normal:`No crackles`},{label:`Prolonged expiration`,method:`Note expiration:inspiration length ratio.`,normal:`Inspiration ≥ expiration`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse wheeze + fine crackles in an RSV-season infant — bronchiolitis`,`Silent chest with extreme WOB — impending respiratory failure`]}]},cv:{overview:`Most CHD manifests in the first year as pulmonary blood-flow changes and the ductus closes. Infant CV exam = growth review + inspection + femoral pulses + auscultation. A harsh pan-systolic LLSB murmur in a 6-week-old = VSD until proven otherwise.`,components:[{name:`Inspection and functional assessment`,significance:`Heart failure in infants presents as poor feeding, sweating during feeds (diaphoresis), tachypnea, and poor weight gain. These historical features predict bad exam findings.`,pearl:`Ask "Does the baby sweat while feeding?" — infant CHF presents with diaphoresis on the forehead during feeds, well before peripheral edema appears.`,steps:[{label:`Growth trajectory`,method:`Plot weight-for-age on WHO chart. Failure to thrive raises CHD concern.`,normal:`Tracking ≥ 10th percentile or stable on personal curve`},{label:`Feeding history`,method:`Ask about feed duration, sweating with feeds, tachypnea with feeds, tiring easily.`,normal:`Feeds < 20 min, no diaphoresis, no tachypnea`},{label:`Central cyanosis`,method:`Inspect tongue and oral mucosa.`,normal:`Pink`},{label:`Clubbing`,method:`Inspect finger nail beds (subtle in infants).`,normal:`No clubbing`},{label:`Peripheral perfusion`,method:`Cap refill, warmth of extremities.`,normal:`Cap refill < 2 s, warm extremities`}],abnormalHints:[`Poor weight gain — consider CHF from L-to-R shunt (VSD, PDA, AVSD)`,`Diaphoresis with feeds — infant CHF`,`Tiring with feeds — significant CHD`,`Central cyanosis — cyanotic CHD (ToF, TGA, TA, etc.)`]},{name:`Palpation and auscultation`,significance:`Femoral pulses + 4-limb BP screen coarctation. A harsh holosystolic murmur at LLSB is almost always a VSD in this age.`,pearl:`Listen over each of the 5 classic points as in the adult exam — the locations shift slightly with infant chest size but relative positions are the same. Also listen at the back: coarctation murmurs radiate there.`,steps:[{label:`Apex beat`,method:`Palpate at 4th ICS mid-clavicular line.`,normal:`Palpable at 4th ICS in infants`},{label:`Femoral pulses`,method:`Palpate bilaterally, simultaneously with right brachial.`,normal:`Present, equal, no delay vs brachial`},{label:`Listen at each classic area (APTM)`,method:`See APTM diagram. Use pediatric stethoscope with both diaphragm and bell.`,normal:`S1 and S2 crisp, no murmur or physiologic only`},{label:`Listen over the back (interscapular)`,method:`Check for radiation of coarctation murmurs.`,normal:`No radiating murmur`}],abnormalHints:[`Harsh holosystolic LLSB murmur — VSD`,`Continuous "machinery" murmur below left clavicle — PDA`,`Systolic ejection at ULSB + fixed split S2 — ASD`,`Ejection murmur at ULSB + cyanosis — tetralogy of Fallot`,`Absent femorals + radio-femoral delay — coarctation`,`Gallop + tachycardia — heart failure`]}]}},toddler:{label:`Toddler (1–3 years)`,msk:{overview:`Gait, physiologic alignment changes, in-toeing, joint range. Cooperation unpredictable — use play.`,components:[{name:`Gait`,steps:[{label:`Base of support`,method:`Have child walk ~10 feet`,normal:`Wide-based initially, narrowing by 2y`},{label:`Heel-strike`,method:`Observe foot contact pattern`,normal:`Heel-strike developing by 18mo, consistent by 2y`},{label:`Arm swing`,method:`Observe reciprocal arm swing`,normal:`Reciprocal arm swing by 18mo`},{label:`Symmetry`,method:`Watch both sides in stance and swing`,normal:`Symmetric stride length and cadence`}],abnormalHints:[`Toe-walking past 2y (idiopathic vs CP vs DMD)`,`Limp (Legg-Calvé-Perthes, transient synovitis, trauma)`,`Wide-based ataxia`]},{name:`Knee alignment`,steps:[{label:`Stand feet together`,method:`Feet/medial malleoli touching; inspect knees`,normal:`Genu varum resolving by 18–24mo; mild genu valgum common by 2–3y`},{label:`Intercondylar or intermalleolar distance`,method:`Measure if alignment appears abnormal`,normal:`<5cm intercondylar (varum) or <8cm intermalleolar (valgum)`},{label:`Symmetry`,method:`Compare sides`,normal:`Symmetric`}],abnormalHints:[`Persistent varum past 2y`,`Severe valgum >8cm`,`Unilateral (Blount disease, rickets)`]},{name:`Feet alignment`,steps:[{label:`In-toeing / out-toeing`,method:`Observe foot angle during gait`,normal:`Mild in-toeing common (tibial torsion, femoral anteversion)`},{label:`Arch during stance`,method:`Stand flat, then on tiptoes`,normal:`Flexible flat foot that forms arch on tiptoe`},{label:`Heel alignment`,method:`View from behind standing`,normal:`Neutral or mildly valgus heel`}],abnormalHints:[`Rigid flat foot (tarsal coalition)`,`Fixed metatarsus adductus`,`Severe in-toeing >15°`]},{name:`Joint range`,steps:[{label:`Hips`,method:`Flex, abduct, rotate each hip`,normal:`Full symmetric range, no pain`},{label:`Knees`,method:`Flex, extend; palpate for effusion`,normal:`Full range, no effusion, stable`},{label:`Ankles`,method:`Dorsiflex, plantarflex, invert, evert`,normal:`Full range`},{label:`Shoulders, elbows, wrists`,method:`Through full range each`,normal:`Full symmetric range`}],abnormalHints:[`Joint effusion (septic vs reactive)`,`Guarded or painful motion`,`Asymmetric limitation`]},{name:`Spine`,steps:[{label:`Inspect standing`,method:`View spine from behind`,normal:`Midline, no prominent curve`},{label:`Palpate midline`,method:`Run finger along spinous processes`,normal:`Midline, no step-off, no tenderness`},{label:`Shoulder/hip symmetry`,method:`Compare shoulder and hip heights`,normal:`Symmetric`}],abnormalHints:[`Fixed scoliosis`,`Abnormal kyphosis`,`Asymmetric shoulder/hip`,`Midline tenderness`]}]},neuro:{overview:`Shifting to adult-pattern exam. Primitive reflexes should be absent. Use play-based techniques.`,components:[{name:`Mental status and language`,steps:[{label:`Engagement`,method:`Interaction with examiner/parent`,normal:`Alert, interactive, age-appropriate`},{label:`Language — expressive`,method:`Note spontaneous utterances`,normal:`1y: 1–3 words; 2y: 2-word phrases; 3y: short sentences`},{label:`Language — receptive`,method:`Ask to point to body parts or follow simple commands`,normal:`Follows age-appropriate commands`}],abnormalHints:[`Language regression (autism, epileptic encephalopathy)`,`Poor engagement`,`No 2-word phrases by 2y`]},{name:`Cranial nerves`,steps:[{label:`CN II — pupil response`,method:`Shine light each eye`,normal:`Pupils equal reactive`},{label:`CN III, IV, VI — EOM`,method:`Follow toy in H pattern`,normal:`Full smooth tracking, no strabismus`},{label:`CN V — facial sensation`,method:`Light touch on forehead, cheek, jaw`,normal:`Responds to touch, symmetric`},{label:`CN VII — face`,method:`Elicit smile, watch eye closure during cry`,normal:`Symmetric face`},{label:`CN IX, X, XII — mouth`,method:`Say "ahh"; stick out tongue`,normal:`Palate rises symmetrically; tongue midline`}],abnormalHints:[`Strabismus`,`Facial asymmetry`,`Tongue deviation`,`Absent palate elevation`]},{name:`Motor — tone and bulk`,steps:[{label:`Passive tone`,method:`Move each limb through full range`,normal:`Normal resistance throughout`},{label:`Bulk inspection`,method:`Inspect muscle bulk of thighs, calves, glutes`,normal:`Symmetric, age-appropriate bulk`},{label:`Contracture check`,method:`Test for heel-cord tightness, hamstring tightness`,normal:`No contractures`}],abnormalHints:[`Spasticity (especially catch in ankles)`,`Hypotonia`,`Calf pseudo-hypertrophy (DMD)`]},{name:`Motor — functional strength`,steps:[{label:`Rising from floor`,method:`Place flat on back; ask to stand up`,normal:`Rises without using hands to push off thighs (no Gowers)`},{label:`Climbing stairs`,method:`Observe or history`,normal:`Climbs holding rail`},{label:`Squatting/getting up`,method:`Encourage via play`,normal:`Squats and rises without help`}],abnormalHints:[`Gowers sign (proximal weakness — DMD)`,`Unable to climb stairs at age expected`,`Calf pain on walking (myositis)`]},{name:`Deep tendon reflexes`,steps:[{label:`Patellar`,method:`Sitting or supine with distraction (toy)`,normal:`2+ symmetric`},{label:`Biceps`,method:`Arm at rest, strike thumb on tendon`,normal:`2+ symmetric`},{label:`Achilles`,method:`With distraction`,normal:`2+ symmetric`}],abnormalHints:[`Hyperreflexia or clonus (UMN, CP)`,`Absent reflexes (LMN, neuropathy)`,`Asymmetry`]},{name:`Coordination and gait`,steps:[{label:`Run`,method:`Watch run ~10 feet`,normal:`Runs with reciprocal arm swing by 2y`},{label:`Stairs`,method:`Observe`,normal:`Climbs with rail`},{label:`Kick ball`,method:`Place ball; observe kick`,normal:`Kicks by 2y`},{label:`Ataxia check`,method:`Watch for fluency of movement`,normal:`Smooth, no tremor`}],abnormalHints:[`Ataxic gait`,`Intention tremor`,`Clumsiness beyond age`]},{name:`Plantar response`,steps:[{label:`Stroke lateral sole`,method:`Firm stroke from heel to toes`,normal:`Down-going great toe (plantar flexion) by age 2`}],abnormalHints:[`Up-going toe after age 2 = UMN sign (Babinski positive)`]}]},resp:{overview:`Toddler respiratory disease: viral URIs, reactive airways, croup (6 mo–6 y classical age), foreign-body aspiration (age 1–3 is peak). Normal RR ≤ 40.`,components:[{name:`Inspection`,pearl:`Sudden onset of unilateral wheeze + choking history in a toddler = foreign body until proven otherwise. CXR in expiration (or decubitus) helps show the trapped air.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s if possible.`,normal:`≤ 40 /min`},{label:`Work of breathing`,method:`Retractions, nasal flaring, tracheal tug.`,normal:`No retractions`},{label:`Audible sounds`,method:`Stridor (croup), wheeze, barking cough.`,normal:`Quiet respirations`},{label:`Drooling / posture`,method:`Tripod positioning, drooling (epiglottitis in unvaccinated child).`,normal:`No drooling, normal posture`}],abnormalHints:[`Barking cough + stridor — croup`,`Drooling + tripod + toxic — epiglottitis (emergency)`,`Sudden unilateral wheeze — foreign body aspiration`]},{name:`Auscultation`,steps:[{label:`Air entry`,method:`Cooperation variable — listen quickly and systematically.`,normal:`Symmetric`},{label:`Adventitious sounds`,method:`Wheeze, crackles, stridor at the neck.`,normal:`Clear lung fields`},{label:`Unilateral findings`,method:`Focal wheeze, decreased air entry, or asymmetry — think foreign body or pneumonia.`,normal:`Symmetric bilateral`}],abnormalHints:[`Unilateral decreased breath sounds + wheeze — foreign body`,`Focal crackles — pneumonia`,`Diffuse wheeze — asthma/RAD`]}]},cv:{overview:`Most hemodynamically significant CHD has been detected by this age. Innocent murmurs peak here (Still's murmur, venous hum). The exam is adult-pattern but with smaller chest and less cooperation.`,components:[{name:`Inspection and palpation`,pearl:`Innocent murmurs are a normal finding in well toddlers — soft, systolic, at the LLSB, musical, and they change with position. Anything that doesn't fit that pattern deserves referral.`,steps:[{label:`General appearance + growth`,method:`Happy, active, tracking growth.`,normal:`Normal growth and activity`},{label:`Colour and clubbing`,method:`Inspect tongue, nail beds.`,normal:`Pink, no clubbing`},{label:`Apex beat`,method:`Palpate at 5th ICS mid-clavicular line.`,normal:`Located at 5th ICS MCL, tapping quality`},{label:`Peripheral pulses`,method:`Brachial + femoral, symmetric and simultaneous.`,normal:`Symmetric, no delay`}],abnormalHints:[`Tiring with play, poor growth — missed CHD`,`Cyanosis + clubbing — cyanotic CHD`,`Absent femorals — coarctation`]},{name:`Auscultation`,steps:[{label:`All 5 classic points`,method:`See APTM diagram above — Aortic, Pulmonic, Erb's, Tricuspid, Mitral.`,normal:`Crisp S1, S2 with physiologic split at pulmonic area`},{label:`Evaluate any murmur`,method:`Timing, location, radiation, grade. Apply the "7 S" innocent-murmur criteria.`,normal:`No murmur, or soft (≤ grade 2) innocent murmur`},{label:`Change with position`,method:`Have toddler sit, stand, lie down — does the murmur change? Innocent murmurs typically disappear or soften with standing.`,normal:`Murmur (if any) changes with position`}],abnormalHints:[`Harsh, loud (≥3/6), radiating, or diastolic murmur — not innocent, refer`,`Cyanosis + murmur — CHD workup`,`Fixed split S2 — ASD`]}]}},preschool:{label:`Preschool (3–5 years)`,msk:{overview:`Functional gait maneuvers, scoliosis screen, resolving physiologic alignment.`,components:[{name:`Gait — multiple patterns`,steps:[{label:`Normal gait`,method:`Walk ~15 feet barefoot`,normal:`Symmetric, smooth, reciprocal arm swing`},{label:`Heel walking`,method:`Walk on heels only`,normal:`Able by 4y`},{label:`Toe walking`,method:`Walk on toes only`,normal:`Able by 4y`},{label:`Tandem walking`,method:`Heel-to-toe along a line for 5 steps`,normal:`Able by 4y with minimal deviation`},{label:`Hopping`,method:`Hop on one foot`,normal:`3–5 hops on preferred foot by 4y`}],abnormalHints:[`Persistent toe-walking`,`Asymmetric stance/stride`,`Difficulty with any pattern`]},{name:`Alignment`,steps:[{label:`Knee alignment`,method:`Stand feet together`,normal:`Mild residual valgus resolving; neutral by 6–7y`},{label:`Foot arch`,method:`Standing, then tiptoe`,normal:`Arch forms on tiptoe (flexible flat foot)`},{label:`Heel position`,method:`View from behind standing`,normal:`Neutral or mild valgus`}],abnormalHints:[`Persistent unilateral varum`,`Rigid flat foot (no arch on tiptoe)`,`Pes cavus`]},{name:`Scoliosis screen (Adam forward-bend)`,steps:[{label:`Position`,method:`Feet together, bend forward at waist, arms hanging, palms together`,normal:`Arms and head relaxed`},{label:`View from behind`,method:`Examiner at same height; look along back`,normal:`Symmetric paraspinal contour`},{label:`View from side`,method:`Side view for kyphosis`,normal:`Smooth thoracic curve`}],abnormalHints:[`Rib hump (thoracic scoliosis)`,`Lumbar prominence`,`Asymmetric scapular height`]},{name:`Joint range and stability`,steps:[{label:`Active range`,method:`Ask to perform full range at hips, knees, ankles, shoulders, elbows, wrists`,normal:`Full symmetric range, no pain`},{label:`Knee stability`,method:`Palpate for effusion; assess stability if complaint`,normal:`Stable, no effusion`},{label:`Carrying angle (elbows)`,method:`Arms at sides, palms forward`,normal:`Normal valgus carrying angle`}],abnormalHints:[`Joint hypermobility (Beighton score)`,`Effusion`,`Pain with motion`,`Valgus >15°`]},{name:`Feet`,steps:[{label:`Standing inspection`,method:`View from front and behind`,normal:`Symmetric feet, neutral heel, flexible flat feet common`},{label:`Tiptoe`,method:`Stand on tiptoes`,normal:`Arch forms, symmetric`},{label:`Pes planus vs cavus`,method:`Note arch height`,normal:`Flexible flat foot or mild arch`}],abnormalHints:[`Rigid flat foot`,`Pes cavus (Charcot-Marie-Tooth)`,`Pain`]}]},neuro:{overview:`Formal pediatric neuro exam now feasible — most 4- and 5-year-olds cooperate with structured testing.`,components:[{name:`Mental status and language`,steps:[{label:`Orientation (age-appropriate)`,method:`Ask name, age, where you are`,normal:`Knows name and age by 3y; location by 4–5y`},{label:`Speech intelligibility`,method:`Listen to spontaneous speech`,normal:`Strangers understand by 4y`},{label:`Receptive language`,method:`2- and 3-step commands`,normal:`Follows 3-step commands by 4–5y`}],abnormalHints:[`Dysarthria`,`Expressive or receptive language delay`,`Inattention`]},{name:`Cranial nerves (II–XII)`,steps:[{label:`CN II — visual acuity`,method:`HOTV chart or pictures at 10ft, each eye`,normal:`20/30 or better by 4y; 20/25 by 5y`},{label:`CN II — visual fields`,method:`Confrontation with toys from periphery`,normal:`Full fields`},{label:`CN II — pupils`,method:`Light response each eye`,normal:`PERRL`},{label:`CN III, IV, VI — EOM`,method:`Follow toy in H pattern; include convergence`,normal:`Full EOM, convergence present`},{label:`CN V — sensation`,method:`Light touch forehead, cheek, jaw each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench teeth, palpate masseter`,normal:`Symmetric strong bulk`},{label:`CN VII — face`,method:`Smile, wrinkle forehead, close eyes, puff cheeks`,normal:`Symmetric movement of all regions`},{label:`CN VIII — hearing`,method:`Finger rub each ear or whispered words`,normal:`Intact bilaterally`},{label:`CN IX, X — palate`,method:`Open mouth, say "ahh"`,normal:`Palate rises symmetrically, uvula midline`},{label:`CN XI — SCM/trapezius`,method:`Shrug shoulders, turn head against resistance`,normal:`Symmetric strength`},{label:`CN XII — tongue`,method:`Stick tongue out, move side to side`,normal:`Midline, no atrophy, full movement`}],abnormalHints:[`Strabismus (amblyopia risk)`,`Facial weakness`,`Tongue deviation/fasciculations`,`Uvula off-midline`]},{name:`Motor — tone, bulk, strength`,steps:[{label:`Tone inspection`,method:`Passive range all four limbs`,normal:`Normal tone throughout`},{label:`Bulk inspection`,method:`Observe muscle bulk symmetry`,normal:`Symmetric, age-appropriate`},{label:`Strength — shoulder abduction`,method:`Arms out, push down against resistance`,normal:`5/5 bilaterally`},{label:`Strength — elbow flexion`,method:`Flex elbow against resistance`,normal:`5/5 bilaterally`},{label:`Strength — grip`,method:`Squeeze examiner's fingers`,normal:`5/5 symmetric`},{label:`Strength — hip flexion`,method:`Lift leg off table against resistance`,normal:`5/5 bilaterally`},{label:`Strength — knee extension`,method:`Straighten knee against resistance`,normal:`5/5 bilaterally`},{label:`Strength — dorsiflexion`,method:`Pull toes up against resistance`,normal:`5/5 bilaterally`}],abnormalHints:[`Focal weakness`,`Gowers sign`,`Pseudohypertrophy (DMD)`,`Atrophy`]},{name:`Deep tendon reflexes`,steps:[{label:`Biceps`,method:`Thumb on biceps tendon, strike`,normal:`2+ symmetric`},{label:`Patellar`,method:`Knees hanging, strike patellar tendon`,normal:`2+ symmetric`},{label:`Achilles`,method:`Slight dorsiflexion, strike Achilles tendon`,normal:`2+ symmetric`},{label:`Plantar response`,method:`Stroke lateral sole heel-to-toes`,normal:`Down-going great toe`}],abnormalHints:[`Hyperreflexia or clonus (UMN)`,`Hyporeflexia (LMN)`,`Up-going plantar (Babinski — abnormal past 2y)`,`Asymmetry`]},{name:`Coordination`,steps:[{label:`Finger-to-nose`,method:`Touch examiner's finger then own nose, repeat`,normal:`Smooth, no dysmetria`},{label:`Heel-to-shin`,method:`Run heel down opposite shin`,normal:`Smooth bilaterally`},{label:`Rapid alternating movements`,method:`Tap palm with opposite hand alternating palm/back`,normal:`Rhythmic, symmetric`},{label:`Tandem walk`,method:`Heel-to-toe for 5 steps`,normal:`Minimal deviation`}],abnormalHints:[`Dysmetria`,`Dysdiadochokinesia`,`Intention tremor`,`Ataxic tandem`]},{name:`Sensory`,steps:[{label:`Light touch — hands`,method:`Cotton wisp on palm/dorsum, eyes closed`,normal:`Feels each touch`},{label:`Light touch — feet`,method:`Same on dorsum of foot bilaterally`,normal:`Feels each touch`}],abnormalHints:[`Focal sensory loss`,`Stocking-glove loss`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk ~20 feet`,normal:`Smooth, symmetric`},{label:`Heel walk`,method:`Walk on heels`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe`,normal:`Intact`},{label:`Romberg (5y+)`,method:`Feet together, eyes closed, stand 10s`,normal:`Stable without sway`}],abnormalHints:[`Ataxic gait (cerebellar)`,`Romberg positive (dorsal column)`,`Circumduction (UMN)`]}]},resp:{overview:`Adult-pattern but shorter. Cooperation better than toddler. RR ≤ 30. Common: asthma/RAD, pneumonia, URIs.`,components:[{name:`Inspection`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s quietly.`,normal:`≤ 30 /min`},{label:`Work of breathing`,method:`Retractions, nasal flaring, accessory muscle use.`,normal:`Effortless breathing`},{label:`Audible sounds`,method:`Wheeze, stridor, cough quality (barking = croup).`,normal:`Quiet`},{label:`Chest shape`,method:`AP:transverse, hyperinflation signs.`,normal:`Not barrel-chested`}],abnormalHints:[`Barrel chest — chronic asthma, cystic fibrosis`,`Retractions + wheeze — asthma exacerbation`]},{name:`Auscultation`,steps:[{label:`Systematic zones`,method:`Upper, mid, lower fields anteriorly and posteriorly; axillae bilaterally. Cooperative deep breaths through mouth.`,normal:`Symmetric vesicular sounds`},{label:`Wheeze`,method:`Expiratory, diffuse (asthma) or focal (foreign body, rare at this age).`,normal:`No wheeze`},{label:`Crackles`,method:`Focal = pneumonia; diffuse fine = interstitial disease (rare in kids).`,normal:`No crackles`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse wheeze — asthma`,`Prolonged expiration with wheeze — lower airway obstruction`]}]},cv:{overview:`Most CHD is detected by this age. Innocent murmurs peak in this range. Sports participation exams require thorough CV screening.`,components:[{name:`Inspection and palpation`,steps:[{label:`General and growth`,method:`Track on growth curve; activity tolerance.`,normal:`Normal growth, active`},{label:`Apex beat`,method:`5th ICS mid-clavicular line.`,normal:`Normal position and character`},{label:`Peripheral pulses`,method:`Brachial + femoral simultaneously. BP in arm and leg if HTN.`,normal:`Symmetric, no delay`}],abnormalHints:[`Absent femorals or arm-leg BP gradient — coarctation (always check in HTN screening)`,`Displaced apex — cardiomegaly`]},{name:`Auscultation`,pearl:`The 7 "S" criteria and the 5 classic innocent murmurs (see panel above) handle most murmurs you'll find in this age group. Still's murmur is the single most common.`,steps:[{label:`All 5 classic points`,method:`Walk through A → P → E → T → M with diaphragm then bell.`,normal:`S1 S2 clear, physiologic S2 split at pulmonic, no added sounds`},{label:`Any murmur`,method:`Characterise: timing, location, radiation, grade, character. Apply 7 S criteria + compare to innocent-murmur panel.`,normal:`No murmur, or innocent flow murmur meeting all 7 S criteria`},{label:`Position change`,method:`Standing vs supine. Innocent murmurs typically soften or disappear on standing.`,normal:`Murmur (if any) changes with position`},{label:`Sports screening extras (if applicable)`,method:`Screen for HOCM — murmur intensifies with Valsalva and standing (opposite of most).`,normal:`No murmur worsening on Valsalva`}],abnormalHints:[`Murmur breaking any of the 7 S criteria — refer`,`Harsh systolic at LUSB + fixed split S2 — ASD`,`Murmur louder with Valsalva — HOCM (sports participation risk)`,`Diastolic murmur — always pathologic`]}]}},school:{label:`School-age (6–11 years)`,msk:{overview:`Scoliosis screening peri-puberty, sports overuse injuries, resolving alignment.`,components:[{name:`Scoliosis screen (forward-bend + scoliometer)`,steps:[{label:`Standing inspection`,method:`Shoulders and iliac crest heights`,normal:`Symmetric shoulder and pelvic heights`},{label:`Forward bend (Adam test)`,method:`Feet together, bend forward at waist, arms hanging palms together`,normal:`Symmetric paraspinal contour`},{label:`Rib hump`,method:`View tangentially from behind at level of curve`,normal:`No rib hump`},{label:`Lumbar prominence`,method:`Same view at lumbar level`,normal:`No prominence`},{label:`Scoliometer (if available)`,method:`Place scoliometer across rib hump, read angle of trunk rotation`,normal:`ATR < 5°; ≥7° → refer`}],abnormalHints:[`Rib hump`,`ATR ≥7°`,`Asymmetric shoulders or pelvis`,`Decompensation (plumb line offset)`]},{name:`Back and spine`,steps:[{label:`Posture inspection`,method:`Standing, view front/back/side`,normal:`Normal spinal curves; plumb line centered`},{label:`Palpate spinous processes`,method:`From C2 to S1`,normal:`No tenderness, no step-off`},{label:`Range of motion`,method:`Flex, extend, lateral bend, rotate`,normal:`Full painless range`}],abnormalHints:[`Midline tenderness`,`Step-off (spondylolisthesis)`,`Limited motion with pain`]},{name:`Alignment`,steps:[{label:`Knees`,method:`Feet together, inspect`,normal:`Neutral alignment by 6–7y`},{label:`Feet`,method:`Stand, then tiptoes`,normal:`Medial arch present, symmetric`},{label:`Leg lengths`,method:`Supine, measure ASIS to medial malleolus if asymmetric`,normal:`Equal within 1cm`}],abnormalHints:[`Residual valgum`,`Pes cavus`,`Leg-length discrepancy >1cm`]},{name:`Joint stability and sports exam (if active)`,steps:[{label:`Active range all joints`,method:`Through full range`,normal:`Full symmetric range, no pain or crepitus`},{label:`Knee — Lachman (if sports-active)`,method:`Knee 20° flexion, stabilize femur, pull tibia forward`,normal:`Firm endpoint, no laxity`},{label:`Knee — McMurray`,method:`Flexed knee, rotate tibia while extending`,normal:`No pain or click`},{label:`Shoulder — impingement (Neer/Hawkins)`,method:`Passive shoulder flexion with arm in internal rotation`,normal:`No pain`},{label:`Ankle stability`,method:`Anterior drawer and talar tilt`,normal:`No laxity`}],abnormalHints:[`ACL laxity (positive Lachman)`,`Meniscal click`,`Shoulder impingement`,`Ankle instability`]},{name:`Gait and functional movement`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Smooth, symmetric`},{label:`Single-leg stance`,method:`Stand on one foot 10s each side`,normal:`Stable without Trendelenburg drop`},{label:`Squat`,method:`Full squat and rise`,normal:`Full squat without pain or asymmetry`},{label:`Hop on one foot`,method:`5 hops each side`,normal:`Able and symmetric`}],abnormalHints:[`Trendelenburg sign (hip abductor weakness)`,`Antalgic gait`,`Asymmetric squat`,`Pain with hop`]}]},neuro:{overview:`Adult-pattern six-component exam: mental status, CN, motor, reflexes, sensory, coordination/gait.`,components:[{name:`Mental status`,steps:[{label:`Orientation`,method:`Name, age, school, city, day of week`,normal:`Oriented x 4`},{label:`Attention`,method:`Count backward from 20; days of week backward`,normal:`Intact`},{label:`3-item recall`,method:`Ball-flag-tree; ask at 3 and 5 min`,normal:`3/3 recall at 5 min`},{label:`Language`,method:`Name common objects; repeat a sentence`,normal:`Fluent, no paraphasia`}],abnormalHints:[`Inattention (ADHD features)`,`Memory deficits`,`Word-finding difficulty`,`Perseveration`]},{name:`Cranial nerves (II–XII)`,steps:[{label:`CN II — acuity`,method:`Snellen at 20ft each eye with corrective lenses if worn`,normal:`20/20 or baseline`},{label:`CN II — fields`,method:`Confrontation, 4 quadrants each eye`,normal:`Full fields`},{label:`CN II — fundoscopy (if indicated)`,method:`Direct ophthalmoscopy — disc, vessels, macula`,normal:`Sharp disc, normal cup-disc ratio, no papilledema`},{label:`CN II, III — pupils`,method:`Direct and consensual light, accommodation`,normal:`PERRLA`},{label:`CN III, IV, VI — EOM`,method:`Follow finger in H pattern; convergence`,normal:`Full EOM, no nystagmus, convergence intact`},{label:`CN V — sensation`,method:`Light touch V1 (forehead), V2 (cheek), V3 (jaw) each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench teeth, palpate masseter/temporalis; jaw opening`,normal:`Symmetric strength`},{label:`CN VII`,method:`Raise eyebrows, close eyes tight, smile/show teeth, puff cheeks`,normal:`Symmetric movement, all regions`},{label:`CN VIII`,method:`Finger rub each ear; Weber/Rinne if deficit`,normal:`Hears bilaterally`},{label:`CN IX, X`,method:`Palate elevation with "ahh"; uvula midline; voice quality`,normal:`Symmetric elevation, uvula midline, normal voice`},{label:`CN XI`,method:`Shrug shoulders against resistance; head turn against resistance`,normal:`5/5 SCM and trapezius`},{label:`CN XII`,method:`Stick tongue out; side-to-side`,normal:`Midline, no atrophy or fasciculations`}],abnormalHints:[`Papilledema (increased ICP)`,`Focal cranial nerve deficit — any warrants workup`,`Tongue fasciculations (LMN/MND)`]},{name:`Motor — bulk, tone, strength`,steps:[{label:`Bulk inspection`,method:`Shoulders, thighs, calves, intrinsic hand muscles`,normal:`Symmetric, no atrophy`},{label:`Tone`,method:`Passive range at elbows, wrists, knees, ankles`,normal:`Normal resistance throughout`},{label:`Strength — deltoids`,method:`Shoulder abduction against resistance`,normal:`5/5 bilaterally`},{label:`Strength — biceps`,method:`Elbow flexion against resistance`,normal:`5/5`},{label:`Strength — triceps`,method:`Elbow extension against resistance`,normal:`5/5`},{label:`Strength — grip`,method:`Squeeze 2 fingers`,normal:`5/5 symmetric`},{label:`Strength — finger abduction`,method:`Spread fingers against resistance`,normal:`5/5`},{label:`Strength — hip flexion`,method:`Lift leg supine against resistance`,normal:`5/5`},{label:`Strength — knee extension`,method:`Straighten knee against resistance`,normal:`5/5`},{label:`Strength — dorsiflexion`,method:`Pull toes up against resistance`,normal:`5/5`},{label:`Strength — plantarflexion`,method:`Push foot down against resistance`,normal:`5/5`}],abnormalHints:[`Focal weakness (localize)`,`Spasticity (UMN)`,`Atrophy`,`Fasciculations`]},{name:`Deep tendon reflexes`,steps:[{label:`Biceps (C5-C6)`,method:`Thumb on tendon, strike`,normal:`2+ symmetric`},{label:`Triceps (C7-C8)`,method:`Strike triceps tendon`,normal:`2+ symmetric`},{label:`Brachioradialis (C5-C6)`,method:`Strike distal radius`,normal:`2+ symmetric`},{label:`Patellar (L3-L4)`,method:`Knees hanging, strike tendon`,normal:`2+ symmetric`},{label:`Achilles (S1)`,method:`Slight dorsiflexion, strike tendon`,normal:`2+ symmetric`},{label:`Plantar response`,method:`Stroke lateral sole heel-to-toes`,normal:`Down-going bilaterally`},{label:`Clonus`,method:`Rapid dorsiflexion at ankle`,normal:`No sustained clonus`}],abnormalHints:[`Hyperreflexia with clonus (UMN: stroke, MS, cord lesion)`,`Hyporeflexia (LMN, neuropathy, myopathy)`,`Asymmetry`,`Up-going Babinski`,`Sustained clonus`]},{name:`Sensory`,steps:[{label:`Light touch — upper`,method:`Cotton wisp dorsum of hands, eyes closed`,normal:`Intact, symmetric`},{label:`Light touch — lower`,method:`Same on dorsum of feet`,normal:`Intact, symmetric`},{label:`Pain — upper`,method:`Broken Q-tip or pin on hands`,normal:`Intact, symmetric`},{label:`Pain — lower`,method:`Same on feet`,normal:`Intact, symmetric`},{label:`Vibration`,method:`128 Hz tuning fork at distal IP joint of great toes`,normal:`Feels vibration; counts down seconds`},{label:`Proprioception`,method:`Move great toe up/down with eyes closed`,normal:`Identifies direction correctly`}],abnormalHints:[`Dermatomal loss (nerve root)`,`Stocking-glove (neuropathy)`,`Loss of vibration/proprioception (dorsal column — B12, tabes, MS)`]},{name:`Coordination`,steps:[{label:`Finger-nose-finger`,method:`Touch examiner finger then own nose, examiner moves target`,normal:`Smooth, accurate, no dysmetria`},{label:`Heel-to-shin`,method:`Supine: heel down opposite shin`,normal:`Smooth, on-target`},{label:`Rapid alternating movements`,method:`Supinate/pronate hand on knee rapidly`,normal:`Rhythmic, symmetric`},{label:`Fine motor`,method:`Finger tapping (thumb to each finger in sequence)`,normal:`Rhythmic, accurate`}],abnormalHints:[`Dysmetria (past-pointing, overshoot)`,`Intention tremor`,`Dysdiadochokinesia`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Narrow-based, smooth, reciprocal arm swing`},{label:`Heel walk`,method:`Walk on heels`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe along a line`,normal:`Minimal deviation, 10+ steps`},{label:`Romberg`,method:`Feet together, eyes closed, 30s`,normal:`Stable without fall or significant sway`}],abnormalHints:[`Wide-based (cerebellar)`,`Steppage (peripheral neuropathy)`,`Scissoring (UMN)`,`Romberg positive (dorsal column)`,`Circumduction`]}]},resp:{overview:`Nearly adult-pattern. Exam the same as adolescent with slightly more flexibility in cooperation. RR ≤ 30 in younger school-age, ≤ 20 in older. Sports history relevant (exercise-induced asthma).`,components:[{name:`Inspection`,steps:[{label:`Respiratory rate`,method:`Count over 60 s.`,normal:`≤ 30 (6–11 y)`},{label:`Work of breathing`,method:`Retractions, accessory muscles.`,normal:`Effortless`},{label:`Audible sounds`,method:`Listen for wheeze, stridor.`,normal:`Quiet`},{label:`Chest shape`,method:`Barrel chest, pectus deformities.`,normal:`Normal shape`},{label:`Clubbing`,method:`Schamroth window test.`,normal:`No clubbing`}],abnormalHints:[`Clubbing — CF, chronic hypoxemia, bronchiectasis`,`Barrel chest — chronic asthma, CF`]},{name:`Palpation and percussion`,steps:[{label:`Tracheal position`,method:`Middle finger in suprasternal notch.`,normal:`Midline`},{label:`Chest expansion`,method:`Hands laterally, thumbs meeting at spine. Deep breath.`,normal:`Symmetric 3–5 cm`},{label:`Tactile fremitus`,method:`Ulnar side of hand; "ninety-nine". Compare sides.`,normal:`Symmetric`},{label:`Percussion`,method:`Pleximeter + plexor technique. Compare sides.`,normal:`Resonant throughout`}],abnormalHints:[`Deviated trachea — pneumothorax, effusion, collapse`,`Dull percussion — consolidation, effusion`,`Hyper-resonant — pneumothorax, hyperinflation`]},{name:`Auscultation`,steps:[{label:`Systematic zones`,method:`Six anterior + four lateral + six posterior zones, compare side-to-side.`,normal:`Symmetric vesicular sounds`},{label:`Adventitious sounds`,method:`Wheeze, crackles, rhonchi, rub, stridor at neck. Use sounds library for reference.`,normal:`No added sounds`},{label:`Cough re-listen`,method:`Secretions (rhonchi, coarse crackles) should clear; fibrosis crackles do not.`,normal:`Secretion-based sounds clear with cough`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse fine crackles — early interstitial disease`,`Expiratory wheeze — asthma / RAD`]}]},cv:{overview:`Nearly adult-pattern. Sports participation screening is a key indication in this age. HOCM screening (family history of sudden cardiac death, exertional syncope, murmur louder with Valsalva) is specifically relevant.`,components:[{name:`Inspection and palpation`,pearl:`For sports participation exams, always ask about exertional symptoms (syncope, chest pain, unexpected fatigue) AND family history of sudden cardiac death before age 50. Screening exam alone catches only ~3% of HOCM.`,steps:[{label:`General and growth`,method:`Track on growth curve; review activity tolerance.`,normal:`Normal growth, age-appropriate activity`},{label:`Colour and clubbing`,method:`Inspect mucous membranes and nail beds.`,normal:`Pink, no clubbing`},{label:`Apex beat`,method:`Palpate at 5th ICS mid-clavicular line.`,normal:`Normal position, tapping character`},{label:`Peripheral pulses`,method:`Simultaneous brachial + femoral.`,normal:`Symmetric, no delay`},{label:`Blood pressure`,method:`Measure BP with appropriately sized cuff. If elevated, check both arms and one leg.`,normal:`Age-appropriate (< 120/80 roughly by 10+ years)`}],abnormalHints:[`Exertional syncope — HOCM, arrhythmia, LQTS`,`BP differential — coarctation`,`Displaced apex — cardiomegaly`]},{name:`Auscultation`,steps:[{label:`All 5 classic points`,method:`See APTM diagram. A → P → E → T → M with diaphragm and bell.`,normal:`S1, S2 clear with physiologic split at P, no added sounds`},{label:`Grade any murmur`,method:`Levine 1–6 (see scales above); characterise timing, location, radiation.`,normal:`No murmur, or innocent flow murmur meeting all 7 S criteria`},{label:`Innocent vs pathologic`,method:`Apply 7 S criteria; compare to innocent-murmur panel.`,normal:`Innocent murmur (if present) clearly fits all 7 S features`},{label:`Dynamic maneuvers`,method:`Standing: HOCM louder; most others soften. Valsalva: HOCM louder.`,normal:`Murmur (if any) softens on standing and Valsalva`}],abnormalHints:[`Murmur louder with Valsalva / standing — HOCM (sports disqualification considerations)`,`Any diastolic murmur`,`Murmur ≥ grade 3, radiating, or with thrill`]}]}},adolescent:{label:`Adolescent (12–21 years)`,msk:{overview:`Sports-related injuries, adolescent scoliosis, apophyseal overuse, hypermobility screening.`,components:[{name:`Scoliosis screen`,steps:[{label:`Standing inspection`,method:`Patient undressed to waist (keep privacy); compare shoulders, iliac crests, scapular heights`,normal:`Symmetric shoulders and pelvis`},{label:`Forward bend (Adam)`,method:`Feet together, bend forward, arms hanging palms together`,normal:`Symmetric paraspinal contour`},{label:`Scoliometer`,method:`Place across thoracic and lumbar regions at maximum prominence`,normal:`ATR <5°; 5–6° monitor; ≥7° refer`},{label:`Plumb line check`,method:`Drop plumb from C7; note where it falls`,normal:`Passes through gluteal cleft (compensated)`},{label:`Leg lengths`,method:`Supine; ASIS to medial malleolus each side`,normal:`Within 1cm`}],abnormalHints:[`Rib/lumbar hump`,`ATR ≥7°`,`Decompensation (plumb off gluteal cleft)`,`Leg-length discrepancy driving apparent curve`]},{name:`Back pain evaluation (if complaint)`,steps:[{label:`Inspect and palpate`,method:`Spinous processes, paraspinal muscles, SI joints`,normal:`Non-tender`},{label:`Range of motion`,method:`Flex, extend, lateral bend, rotate`,normal:`Full painless range`},{label:`Single-leg hyperextension (stork)`,method:`Stand on one foot, extend back — each side`,normal:`No pain (negative for spondylolysis)`},{label:`Straight-leg raise`,method:`Supine, lift straight leg to 70°+`,normal:`No radicular pain to 70°`},{label:`SI joint tests`,method:`FABER, SI compression`,normal:`No pain`}],abnormalHints:[`Spondylolysis (positive stork test)`,`Radicular pain (disc herniation)`,`SI joint pathology`,`Inflammatory back pain pattern`]},{name:`Joint stability — sports-specific`,steps:[{label:`Knee — Lachman`,method:`Knee 20° flexion, stabilize femur, pull tibia anteriorly`,normal:`Firm endpoint, no laxity (ACL intact)`},{label:`Knee — anterior drawer`,method:`Knee 90°, pull tibia forward`,normal:`No excess anterior translation`},{label:`Knee — varus/valgus stress`,method:`Stress at 0 and 30° flexion`,normal:`No gap opening (LCL/MCL intact)`},{label:`Knee — McMurray`,method:`Flex, rotate tibia while extending`,normal:`No pain or click`},{label:`Shoulder — apprehension`,method:`Abduct and externally rotate`,normal:`No apprehension`},{label:`Shoulder — Neer/Hawkins`,method:`Passive flexion with internal rotation`,normal:`No pain`},{label:`Ankle — anterior drawer`,method:`Pull heel forward with tibia stabilized`,normal:`No laxity`},{label:`Ankle — talar tilt`,method:`Invert heel with tibia stabilized`,normal:`No excess tilt`}],abnormalHints:[`ACL/PCL tear`,`MCL/LCL laxity`,`Meniscal injury`,`Shoulder instability/impingement`,`Ankle ligament laxity`]},{name:`Apophysitis and overuse screen`,steps:[{label:`Tibial tubercle`,method:`Palpate with knee flexed`,normal:`Non-tender`},{label:`Calcaneal apophysis`,method:`Palpate posterior calcaneus`,normal:`Non-tender`},{label:`Iliac apophyses`,method:`Palpate ASIS, AIIS, iliac crest`,normal:`Non-tender`},{label:`Rotator cuff`,method:`Empty-can (Jobe) test`,normal:`No pain or weakness`}],abnormalHints:[`Osgood-Schlatter (tibial tubercle tender)`,`Sever (calcaneal tender)`,`Iliac apophysitis`,`Rotator cuff tendinopathy`]},{name:`Hypermobility screen (Beighton)`,steps:[{label:`Fifth finger extension`,method:`Passive extension of fifth MCP to >90°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Thumb to forearm`,method:`Passive flexion of thumb to touch forearm`,normal:`Does not reach (1 pt each side if positive)`},{label:`Elbow hyperextension`,method:`Hyperextension >10°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Knee hyperextension`,method:`Hyperextension >10°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Palms to floor`,method:`Feet together, bend forward, palms flat on floor with knees straight`,normal:`Cannot reach (1 pt if positive)`}],abnormalHints:[`Beighton ≥5/9 suggests hypermobility spectrum (hEDS workup if with other features)`]},{name:`Alignment and gait`,steps:[{label:`Standing alignment`,method:`View knees, feet`,normal:`Neutral alignment, medial arch`},{label:`Normal gait`,method:`Walk 20 feet`,normal:`Symmetric, smooth`},{label:`Functional movements`,method:`Squat, single-leg stance, hop`,normal:`Full symmetric function`}],abnormalHints:[`Antalgic gait`,`Trendelenburg`,`Asymmetric squat`]}]},neuro:{overview:`Full adult-pattern neuro exam across six pillars: mental status, cranial nerves, motor, reflexes, sensory, coordination/gait. In adolescents, screen concussion sequelae if sports-active; frontal release signs must be absent.`,components:[{name:`Mental status`,significance:`Detects cognitive change (concussion, substance use, mood disorder, rare neurodegenerative disease).`,pearl:`Attention precedes memory. A patient who can't attend (serial 7s, months backward) will fail memory even with intact hippocampus — distinguish before calling it a memory problem.`,steps:[{label:`Orientation`,method:`Name, age, date, location, situation`,normal:`Oriented x 4`},{label:`Attention`,method:`Count backward from 100 by 7s (serial 7s) or months of year backward`,normal:`Intact`},{label:`Short-term memory`,method:`3-item registration and recall at 5 min`,normal:`3/3 recall`},{label:`Language`,method:`Object naming; sentence repetition; reading; writing`,normal:`Fluent, no paraphasia, comprehends written and spoken`},{label:`Executive function`,method:`Similarities (apple/orange); interpret proverb`,normal:`Abstract, age-appropriate`}],abnormalHints:[`Post-concussion cognitive changes`,`Mood or personality changes`,`Subtle executive dysfunction`,`Word-finding difficulty`]},{name:`Cranial nerves (II–XII, full formal exam)`,significance:`Localises brainstem, base-of-skull, and specific nerve pathology. Subtle deficits (RAPD, mild facial weakness, Horner) are easily missed — exam discipline matters.`,pearl:`The fastest screen for a CN deficit is asking the patient to speak, smile, look around, and swallow water. What's preserved in everyday function tells you what's likely intact — then examine formally to confirm and to catch the subtle.`,steps:[{label:`CN I (if indicated)`,method:`Coffee or cinnamon each nostril separately`,normal:`Identifies both`},{label:`CN II — acuity`,method:`Snellen at 20ft each eye; corrective lenses if worn`,normal:`20/20 or baseline`},{label:`CN II — fields`,method:`Confrontation, 4 quadrants each eye`,normal:`Full fields`},{label:`CN II — fundoscopy`,method:`Direct ophthalmoscopy — disc, vessels, macula`,normal:`Sharp disc, normal cup/disc, no papilledema`},{label:`CN II, III — pupils`,method:`Direct, consensual, swinging flashlight, accommodation`,normal:`PERRLA, no RAPD`},{label:`CN III, IV, VI — EOM`,method:`H pattern, convergence, note nystagmus or ptosis`,normal:`Full conjugate movement, no nystagmus, convergence intact`},{label:`CN V — sensation`,method:`Light touch V1, V2, V3 each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench jaw, palpate masseter/temporalis; lateral jaw movement`,normal:`Symmetric strength and bulk`},{label:`CN V — corneal reflex (if indicated)`,method:`Cotton wisp to cornea`,normal:`Blinks bilaterally`},{label:`CN VII`,method:`Wrinkle forehead, close eyes against resistance, smile/bare teeth, puff cheeks`,normal:`Symmetric all four movements`},{label:`CN VIII — hearing`,method:`Finger rub each ear; Weber (midline) + Rinne (air > bone) if deficit`,normal:`Equal bilaterally`},{label:`CN IX, X`,method:`Palate elevation with "ahh"; uvula midline; voice; gag (if indicated)`,normal:`Symmetric palate, uvula midline, normal voice`},{label:`CN XI`,method:`Shoulder shrug and head turn against resistance`,normal:`5/5 SCM and trapezius bilaterally`},{label:`CN XII`,method:`Tongue protrusion, side to side; inspect for fasciculations/atrophy`,normal:`Midline, no atrophy or fasciculations, full movement`}],abnormalHints:[`Any focal cranial nerve deficit`,`Papilledema`,`RAPD`,`Nystagmus`,`Facial asymmetry`,`Tongue deviation`]},{name:`Motor — bulk, tone, strength`,significance:`Localises lesion to UMN vs LMN vs muscle vs junction. Pattern of weakness (proximal vs distal, symmetric vs focal) narrows differential.`,pearl:`Pronator drift is the most sensitive screen for subtle UMN weakness — a normal-feeling arm that drifts down with eyes closed still has corticospinal tract dysfunction. Always do it even when formal strength is 5/5.`,steps:[{label:`Bulk inspection`,method:`Inspect shoulders, biceps, thighs, calves, dorsal interossei (between metacarpals) of hands.`,normal:`Symmetric bulk; no atrophy, no pseudohypertrophy`},{label:`Tone — upper`,method:`Passive flex-extend elbow and pronate-supinate wrist at slow then quick speeds. Then pronator drift: arms outstretched, palms up, eyes closed for 10 s.`,normal:`Smooth passive range; no drift, no pronation of the outstretched hand`},{label:`Tone — lower`,method:`Passive knee flexion-extension; quick ankle dorsiflexion to check for catch. Heel-slap test: roll thigh and watch for ankle swing.`,normal:`Normal resistance, no catch, symmetric`},{label:`Strength — deltoid (C5)`,method:`Patient abducts both arms to 90°. Examiner pushes down on each arm just above the elbow while patient resists. Compare sides.`,normal:`Holds against full resistance — MRC 5/5 bilaterally`},{label:`Strength — biceps (C5–C6)`,method:`Elbow flexed 90°, supinated. Examiner grasps wrist and pulls to extend while patient resists.`,normal:`Holds against full resistance — 5/5`},{label:`Strength — triceps (C7)`,method:`Elbow flexed 90°. Examiner pushes wrist toward shoulder while patient extends against resistance.`,normal:`Extends against full resistance — 5/5`},{label:`Strength — wrist extension (C6–C7)`,method:`Patient makes fist, extends wrist. Examiner pushes down on knuckles while patient holds wrist up.`,normal:`Holds against full resistance — 5/5`},{label:`Strength — finger flexion / grip (C8)`,method:`Patient grips two of examiner's crossed fingers as hard as possible. Compare sides.`,normal:`Strong symmetric grip — 5/5`},{label:`Strength — finger abduction (T1)`,method:`Patient spreads fingers wide. Examiner squeezes index and little fingers together while patient resists.`,normal:`Holds fingers apart — 5/5`},{label:`Strength — hip flexion (L2–L3)`,method:`Supine. Patient lifts straight leg 30° off table. Examiner pushes down on thigh just above knee while patient resists.`,normal:`Holds thigh up against full resistance — 5/5`},{label:`Strength — knee extension (L3–L4)`,method:`Sitting, knee 90°. Patient straightens knee while examiner pushes distal shin down.`,normal:`Extends against full resistance — 5/5`},{label:`Strength — ankle dorsiflexion (L4–L5)`,method:`Patient pulls toes and foot up toward shin. Examiner pushes foot down at the dorsum.`,normal:`Holds dorsiflexion against full resistance — 5/5; preserved heel-walk`},{label:`Strength — great toe extension (L5)`,method:`Patient extends great toe up while examiner pushes it down with thumb.`,normal:`Holds against full resistance — 5/5 (classic L5 test)`},{label:`Strength — ankle plantarflexion (S1)`,method:`Patient pushes foot down against examiner's hand at the ball. OR ask patient to toe-walk 10 steps (more sensitive — unilateral plantarflexion weakness shows immediately).`,normal:`Full power; toe-walks symmetrically — 5/5`}],abnormalHints:[`Focal weakness → localise by myotome`,`Pronator drift (subtle UMN, always check even with 5/5)`,`Spasticity / catch (UMN)`,`Atrophy (LMN, disuse)`,`Fasciculations (MND, ALS)`,`Pseudohypertrophy of calves (DMD in a young male)`]},{name:`Deep tendon reflexes`,significance:`Reflex pattern (increased, decreased, asymmetric) localises UMN vs LMN vs root vs peripheral nerve. Inexpensive and fast, but asymmetry is the most informative finding.`,pearl:`A reinforced reflex is still a reflex. If you can't elicit it initially, use Jendrassik (teeth clench or pull interlocked fingers apart) to boost — absent reflexes without reinforcement aren't truly absent.`,steps:[{label:`Biceps (C5–C6)`,method:`Patient's arm relaxed across lap. Examiner places thumb firmly on biceps tendon at the cubital fossa, strikes thumb with reflex hammer. Compare both sides sequentially.`,normal:`2+ symmetric — visible contraction of biceps, slight elbow flexion`},{label:`Brachioradialis (C5–C6)`,method:`Arm relaxed. Strike the distal radius about 3 cm proximal to the wrist, on its radial (thumb) side.`,normal:`2+ symmetric — elbow flexion and slight forearm supination`},{label:`Triceps (C7)`,method:`Support the patient's arm at the wrist with elbow at 90°. Strike the triceps tendon just above the olecranon.`,normal:`2+ symmetric — triceps contraction, slight elbow extension`},{label:`Finger flexors — Hoffmann sign`,method:`Grasp the middle finger's distal phalanx, flick it downward quickly and release. Watch the thumb and index finger.`,normal:`Negative — no thumb flexion, no index flexion (positive = corticospinal tract dysfunction)`},{label:`Patellar (L3–L4)`,method:`Patient sits with knees hanging freely off the table. Strike the patellar tendon just below the patella.`,normal:`2+ symmetric — quadriceps contraction with knee extension`},{label:`Achilles (S1)`,method:`Patient's knee slightly flexed and leg externally rotated, or kneeling on a chair. Slightly dorsiflex the foot and strike the Achilles tendon.`,normal:`2+ symmetric — plantar flexion of the foot`},{label:`Plantar response (Babinski)`,method:`Stroke the lateral aspect of the sole firmly from the heel toward the little toe, then curve across the ball of the foot.`,normal:`Toes flex downward (plantar flexion, "down-going") bilaterally in anyone ≥ 2 years`},{label:`Ankle clonus`,method:`Knee slightly bent. Support the shin with one hand, quickly and sharply dorsiflex the foot with the other, hold in dorsiflexion.`,normal:`≤ 3 non-sustained beats is acceptable; sustained rhythmic oscillation = pathological clonus (UMN)`}],abnormalHints:[`Hyperreflexia + sustained clonus = UMN (MS, myelopathy, cord lesion, stroke)`,`Symmetric hyporeflexia = peripheral polyneuropathy, GBS, myopathy, hypothyroid, B12 deficiency`,`Asymmetric hyporeflexia = radiculopathy at that segment`,`Hoffmann positive = corticospinal tract dysfunction at cervical cord or above`,`Up-going Babinski after age 2 = UMN (always abnormal)`]},{name:`Sensory`,steps:[{label:`Light touch — upper`,method:`Cotton wisp, dorsum of hands, eyes closed`,normal:`Intact, symmetric`},{label:`Light touch — lower`,method:`Dorsum of feet`,normal:`Intact, symmetric`},{label:`Pain — upper`,method:`Broken Q-tip sharp end, hands`,normal:`Intact, symmetric`},{label:`Pain — lower`,method:`Same on feet`,normal:`Intact, symmetric`},{label:`Temperature (if indicated)`,method:`Cold tuning fork each area`,normal:`Intact`},{label:`Vibration`,method:`128 Hz tuning fork at distal IP of great toes; count seconds to fade`,normal:`Feels vibration; appropriate duration`},{label:`Proprioception`,method:`Move great toe up/down with eyes closed`,normal:`Identifies direction correctly`},{label:`Two-point discrimination (if indicated)`,method:`Blunt calipers on fingertip`,normal:`<5mm on fingertip`},{label:`Stereognosis (if indicated)`,method:`Identify coin/key in hand with eyes closed`,normal:`Correct identification`}],abnormalHints:[`Dermatomal loss (nerve root)`,`Stocking-glove loss (length-dependent neuropathy)`,`Dorsal column loss (B12, tabes, MS — positive Romberg, vibration loss)`,`Cortical deficit (astereognosis, impaired 2-pt)`]},{name:`Coordination`,steps:[{label:`Finger-nose-finger`,method:`Alternate examiner's finger and own nose; examiner moves target`,normal:`Smooth, accurate bilaterally`},{label:`Heel-to-shin`,method:`Supine: heel down opposite shin and back`,normal:`Smooth, accurate`},{label:`Rapid alternating (Dysdiadochokinesis)`,method:`Supinate/pronate hand rapidly on thigh`,normal:`Rhythmic, symmetric`},{label:`Finger tapping`,method:`Thumb to each finger in sequence rapidly`,normal:`Rhythmic, smooth, symmetric`}],abnormalHints:[`Dysmetria (cerebellar)`,`Intention tremor`,`Dysdiadochokinesia`,`Decomposed movement`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Narrow-based, smooth, reciprocal arm swing`},{label:`Heel walk`,method:`Walk on heels only`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes only`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe along a line, 10+ steps`,normal:`Minimal deviation`},{label:`Romberg`,method:`Feet together, eyes open then closed, 30s`,normal:`Stable — no significant sway or fall with eyes closed`},{label:`Single-leg stance`,method:`10s each side, eyes open`,normal:`Stable without drift`}],abnormalHints:[`Ataxic (wide-based — cerebellar)`,`Steppage (peripheral neuropathy / foot drop)`,`Circumduction (UMN hemiparesis)`,`Scissoring`,`Romberg positive (dorsal column)`]},{name:`Frontal release / primitive reflexes`,steps:[{label:`Grasp reflex`,method:`Stroke palm`,normal:`Absent`},{label:`Snout reflex`,method:`Tap upper lip`,normal:`No lip pucker`},{label:`Glabellar tap`,method:`Tap between eyebrows — should habituate after 3–4 taps`,normal:`Habituates (no sustained blink)`},{label:`Palmomental`,method:`Stroke thenar eminence`,normal:`No ipsilateral chin twitch`}],abnormalHints:[`Presence suggests frontal lobe pathology, neurodegenerative disease, or severe TBI — rare in adolescence but relevant in post-concussion workup`]}]},resp:{overview:`Systematic respiratory exam: inspection → palpation → percussion → auscultation → special maneuvers. Always start from observation — rate, pattern, work of breathing, and audible sounds (stridor, grunting) can be diagnostic before the stethoscope touches the chest.`,components:[{name:`Inspection — observation before touching`,significance:`Detects respiratory distress and localises the level of airway compromise before any equipment is used. High yield: RR, WOB, audible sounds, chest shape, colour.`,pearl:`Audible stridor at rest from across the room = upper-airway obstruction, often urgent. Grunting in an infant = significant distress — never dismiss as fussiness.`,steps:[{label:`Respiratory rate`,method:`Count over a full 60 seconds (not 15×4) — children normally breathe irregularly. Count while the patient is calm, before any interaction.`,normal:`Within age-appropriate range (see scales card above)`},{label:`Respiratory pattern`,method:`Observe depth, regularity, and inspiration:expiration ratio. Watch for prolonged expiration, paradoxical chest-abdominal movement, or apneas.`,normal:`Regular, I:E ratio ~1:2, no pauses > 10 s in an infant`},{label:`Work of breathing`,method:`Inspect for nasal flaring, suprasternal/intercostal/subcostal retractions, accessory muscle use (SCM, abdominals), tripod positioning, head-bobbing in infants.`,normal:`No retractions; breathing effortless`},{label:`Audible sounds (no stethoscope)`,method:`Listen at the bedside without the stethoscope. Grunting? Stridor? Wheezing audible across the room? Hoarse voice?`,normal:`No audible stridor, grunting, or wheeze`},{label:`Chest shape and symmetry`,method:`Inspect from front and lateral. Note AP-to-transverse diameter, pectus excavatum/carinatum, chest wall asymmetry.`,normal:`AP:transverse ~1:2 (not barrel-chested); symmetric`},{label:`Colour and perfusion`,method:`Inspect lips, tongue, nail beds for central cyanosis. Check peripheral perfusion (capillary refill, mottling).`,normal:`Pink, cap refill < 2 s, no cyanosis`},{label:`Clubbing`,method:`Inspect fingernails: Schamroth sign (reverse a finger against its mirror — normal forms a diamond-shaped window, clubbed does not).`,normal:`Normal nail angle, Schamroth window present`}],abnormalHints:[`Audible stridor — upper airway (croup, epiglottitis, foreign body, laryngomalacia)`,`Grunting in infant — significant distress`,`Tripod positioning, accessory muscle use — severe distress`,`Barrel chest — chronic air-trapping (asthma, CF)`,`Central cyanosis — significant hypoxemia`,`Clubbing in a child — cystic fibrosis, chronic hypoxemia, bronchiectasis, cyanotic CHD`]},{name:`Palpation`,significance:`Localises pathology: consolidation increases tactile fremitus; pneumothorax/effusion decreases it. Trachea deviates AWAY from expanding lesions and TOWARD collapsing ones.`,pearl:`Tracheal deviation is one of the fastest bedside clues to mediastinal shift — tension pneumothorax pushes it away, lobar collapse pulls it toward. Palpate with the middle finger in the suprasternal notch.`,steps:[{label:`Tracheal position`,method:`Patient sitting upright, neck slightly extended. Place middle finger in the suprasternal notch, check equal distance to each SCM.`,normal:`Midline`},{label:`Chest expansion — symmetry`,method:`Hands on lateral chest wall with thumbs meeting at the spine (posterior) or xiphoid (anterior). Patient takes a deep breath. Watch thumbs separate symmetrically.`,normal:`Symmetric 3–5 cm separation`},{label:`Tactile fremitus`,method:`Ulnar surface of hand on chest wall. Ask patient to say "ninety-nine" repeatedly. Move hand systematically across each zone, comparing sides.`,normal:`Equal mild vibration bilaterally over lung fields`},{label:`Chest wall tenderness`,method:`Palpate ribs, costochondral junctions, sternum, and intercostal spaces.`,normal:`No tenderness`},{label:`Subcutaneous emphysema`,method:`Gentle palpation along clavicles, neck, chest wall.`,normal:`No crepitus under skin`}],abnormalHints:[`Tracheal deviation — tension pneumothorax, large pleural effusion (away); upper lobe collapse (toward)`,`Asymmetric expansion — pneumothorax, large effusion, lobar collapse, phrenic palsy`,`Increased fremitus — consolidation (pneumonia), lobar pneumonia`,`Decreased/absent fremitus — pleural effusion, pneumothorax, obstruction`,`Costochondral tenderness — costochondritis, trauma`,`Subcutaneous emphysema — pneumothorax, tracheobronchial injury`]},{name:`Percussion`,significance:`Differentiates air (hyper-resonant), fluid (dull), and consolidated lung (dull) without imaging. Well-performed percussion detects a pleural effusion > 300 mL or a pneumothorax with ~90% sensitivity.`,pearl:`Pleximeter fingertip must be flat against the chest wall — lift other fingers off. The "feel" of a percussion note is as informative as the sound: dullness has a dense, reflected quality; hyper-resonance feels hollow and springy.`,steps:[{label:`Technique`,method:`Place middle finger of non-dominant hand (pleximeter) flat on chest wall; strike distal IP joint with tip of dominant middle finger (plexor) using a quick wrist flick.`,normal:`N/A — technique step`},{label:`Systematic zones`,method:`Percuss from apex to base, comparing side-to-side at each level. Include anterior, lateral (mid-axillary), and posterior fields.`,normal:`Resonant throughout lung fields`},{label:`Cardiac dullness`,method:`Percuss from resonant lung toward the heart border. Left sternal border dullness starts at the 3rd–5th ICS.`,normal:`Dullness beginning at the expected cardiac border`},{label:`Hepatic dullness`,method:`Right 5th–6th ICS mid-clavicular line transitions from resonant to dull.`,normal:`Liver edge dullness at expected level`},{label:`Diaphragmatic excursion`,method:`Patient inhales fully then exhales fully; mark level of dullness at each end. Difference is diaphragm excursion.`,normal:`3–5 cm excursion bilaterally`}],abnormalHints:[`Hyper-resonant — pneumothorax, emphysematous bulla, severe asthma attack`,`Dull — consolidation, pleural effusion (stony dull), atelectasis, pleural thickening, large mass`,`Raised diaphragm (loss of excursion) — effusion, paralysis, subdiaphragmatic pathology`]},{name:`Auscultation — normal breath sounds`,significance:`Breath sound quality varies by location. Bronchial sounds heard peripherally = consolidation; absent breath sounds = pneumothorax, effusion, obstruction.`,pearl:`Always compare corresponding points side-to-side sequentially — your ear calibrates to "normal" one side and immediately hears asymmetry. Listen through a full respiratory cycle at each zone.`,steps:[{label:`Technique`,method:`Diaphragm of stethoscope directly on skin (not over clothing). Patient breathes slowly and deeply through an open mouth.`,normal:`N/A — technique`},{label:`Vesicular sounds (peripheral)`,method:`Listen over lung fields away from the sternum. Play the "Normal vesicular" sample above for reference.`,normal:`Soft, low-pitched, inspiration > expiration in length and loudness`},{label:`Bronchovesicular (over main bronchi)`,method:`Listen at the 1st–2nd ICS anteriorly and between scapulae posteriorly.`,normal:`Intermediate pitch, inspiration = expiration`},{label:`Bronchial (over trachea)`,method:`Listen directly over the manubrium or trachea.`,normal:`Harsh, high-pitched, expiration > inspiration`},{label:`Systematic comparison`,method:`Six zones anteriorly (upper/mid/lower × L/R), four lateral, six posterior. Compare side-to-side at each zone.`,normal:`Symmetric breath sounds at every paired zone`}],abnormalHints:[`Bronchial sounds heard peripherally — consolidation (pneumonia)`,`Absent/diminished breath sounds — pneumothorax, effusion, severe obstruction, obesity / muscular chest`,`Prolonged expiration — lower airway obstruction (asthma, bronchiolitis)`]},{name:`Auscultation — adventitious sounds`,significance:`Adventitious (added) sounds are the key diagnostic finding. Timing (inspiratory vs expiratory vs biphasic), character (continuous vs discontinuous), and location are all informative.`,pearl:`Ask the patient to cough and re-listen. Secretions (rhonchi, some coarse crackles) clear or change; fine crackles of fibrosis or early pneumonia do not. The cough test separates two differential groups in one maneuver.`,steps:[{label:`Listen for wheeze`,method:`Continuous musical sounds, typically expiratory. Use the "Wheeze" sample for reference.`,normal:`No wheeze`},{label:`Listen for crackles — fine`,method:`Short, high-pitched, discontinuous "Velcro" sounds. Typically end-inspiratory, bibasilar. Use the "Fine crackles" sample.`,normal:`No crackles`},{label:`Listen for crackles — coarse`,method:`Longer, lower-pitched, louder than fine. Use the "Coarse crackles" sample.`,normal:`No crackles`},{label:`Listen for rhonchi`,method:`Low-pitched, continuous, snore-like. Often change with cough. Use the "Rhonchi" sample.`,normal:`No rhonchi`},{label:`Listen for pleural rub`,method:`Grating, creaky, biphasic, does NOT clear with cough. Use the "Pleural rub" sample.`,normal:`No pleural rub`},{label:`Listen at the neck (for stridor)`,method:`Place stethoscope over the anterior neck. Stridor is loudest here and differentiates from wheeze (loudest over chest). Use the "Stridor" sample.`,normal:`No stridor`},{label:`Listen for expiratory grunting (infants)`,method:`Often audible without a stethoscope at the bedside — short, low-pitched sound at the end of each expiration (glottal closure against exhaled air).`,normal:`No grunting`},{label:`Cough re-listen`,method:`Have patient cough forcefully; re-listen to any abnormal area. Note if the sound clears or changes.`,normal:`Any secretion-based sound should clear or change with cough`}],abnormalHints:[`Wheeze — asthma, bronchiolitis, foreign body (localised), anaphylaxis`,`Fine crackles — pulmonary edema, interstitial lung disease, early pneumonia`,`Coarse crackles — bronchitis, pneumonia, bronchiectasis, aspiration`,`Rhonchi — large-airway secretions`,`Pleural rub — pleurisy, PE, pneumonia with pleural involvement`,`Stridor — upper airway obstruction (croup, epiglottitis, FB)`]},{name:`Special maneuvers — transmitted voice sounds`,significance:`Vocal resonance tests detect consolidation (increased transmission) and effusion/pneumothorax (decreased). Useful when auscultation suggests asymmetry.`,pearl:`Whispered pectoriloquy is the most sensitive of the three — whispered words transmitted clearly through consolidated lung. If "one, two, three" whispered becomes clearly audible over one lung zone, there is consolidation underneath.`,steps:[{label:`Bronchophony`,method:`Patient says "ninety-nine" in normal voice. Listen at each lung zone with the stethoscope.`,normal:`Muffled, indistinct sound`},{label:`Egophony`,method:`Patient says "ee" continuously. Listen over any suspicious area.`,normal:`"Ee" sounds like "ee" (no change)`},{label:`Whispered pectoriloquy`,method:`Patient whispers "one, two, three" or "ninety-nine". Listen over each zone.`,normal:`Whisper is faint and indistinct`}],abnormalHints:[`Bronchophony increased — consolidation`,`Egophony positive ("ee" → "A" / "ay") — consolidation, sometimes top of an effusion`,`Whispered pectoriloquy positive (whisper clearly audible) — consolidation`]}]},cv:{overview:`Systematic cardiovascular exam: inspection → palpation → auscultation at the five classic points → peripheral vascular exam. Always palpate the apex BEFORE auscultating — knowing where the apex lies tells you where to put the stethoscope and flags cardiomegaly immediately.`,components:[{name:`Inspection`,significance:`Detects obvious precordial activity, chest-wall signs of congenital heart disease, and systemic markers (cyanosis, clubbing, dysmorphic features).`,pearl:`Clubbing + central cyanosis in a well-appearing adolescent = cyanotic congenital heart disease until proven otherwise. Inspect the fingernails before reaching for the stethoscope.`,steps:[{label:`General appearance`,method:`Observe body habitus, features suggesting syndromic CHD (Turner, Down, Marfan, Williams).`,normal:`No dysmorphic features, appropriate growth`},{label:`Central cyanosis`,method:`Inspect lips, tongue, and oral mucosa for bluish discoloration.`,normal:`Pink oral mucosa, no cyanosis`},{label:`Peripheral cyanosis / clubbing`,method:`Inspect nail beds; do Schamroth's window (oppose nails of 4th fingers — normally forms a diamond-shaped window).`,normal:`Pink nail beds, Schamroth window present`},{label:`Precordial bulge`,method:`Inspect anterior chest wall tangentially for asymmetric prominence over the heart.`,normal:`Symmetric chest, no bulge`},{label:`Visible apex beat`,method:`Inspect for a visible cardiac impulse at the 5th ICS mid-clavicular line.`,normal:`Apex may be visible in thin patients; should not be displaced`},{label:`Neck veins (JVP)`,method:`Patient reclined 45°, head turned slightly left. Observe the right internal jugular pulsation; measure vertical height above the sternal angle.`,normal:`≤ 4 cm above sternal angle (≤ 9 cm H₂O from right atrium)`}],abnormalHints:[`Central cyanosis — right-to-left shunt, severe hypoxemia`,`Clubbing — cyanotic CHD, chronic hypoxemia`,`Precordial bulge — long-standing cardiomegaly (grew during skeletal growth)`,`Visible apex displaced lateral/inferior — cardiomegaly`,`Elevated JVP — right-heart failure, fluid overload, cardiac tamponade`]},{name:`Palpation`,significance:`Localises the apex (confirms cardiac size), detects thrills (loud murmurs), and identifies a parasternal heave (RV hypertrophy).`,pearl:`If you feel a thrill, the murmur is at least grade 4/6 — grade your murmur as ≥4 even if it sounds less impressive. Thrill = loud, palpable turbulence.`,steps:[{label:`Apex beat — localise`,method:`Feel with the tips of the fingers at the 5th ICS mid-clavicular line. If not found, roll the patient to the left lateral decubitus position.`,normal:`Located at 5th ICS, mid-clavicular line, less than 2 cm in diameter`},{label:`Apex character`,method:`Describe: tapping (normal), heaving (pressure overload, e.g. AS/HTN), thrusting (volume overload, e.g. AR/MR), dyskinetic (MI/aneurysm).`,normal:`Brief tapping quality`},{label:`Parasternal heave`,method:`Place the heel of the hand along the left sternal border. Sustained outward movement with each systole = heave.`,normal:`No heave`},{label:`Thrills`,method:`Use the palmar aspect of the hand at each of the 5 auscultation areas (A, P, E, T, M). A thrill = palpable turbulence.`,normal:`No thrills`},{label:`Peripheral pulses — upper`,method:`Palpate radial pulses bilaterally, then brachial. Note rate, rhythm, volume, and symmetry.`,normal:`Symmetric 2+ pulses, regular rhythm, age-appropriate rate`},{label:`Peripheral pulses — lower`,method:`Palpate femoral pulses. Compare to brachial — radio-femoral or brachio-femoral delay suggests coarctation of the aorta.`,normal:`Femoral pulses 2+ symmetric, no delay relative to radial`}],abnormalHints:[`Apex displaced laterally/inferiorly — cardiomegaly`,`Heaving apex — pressure overload (AS, HTN)`,`Thrusting apex — volume overload (AR, MR)`,`Thrill over precordium — always pathological; at least grade 4/6 murmur`,`Parasternal heave — RV hypertrophy (pulmonary HTN, pulmonary stenosis, VSD with Eisenmenger)`,`Radio-femoral delay — coarctation of the aorta (always check in a hypertensive adolescent)`]},{name:`Auscultation — approach`,significance:`Systematic technique ensures every relevant finding is detected. Listen at all 5 points, with both diaphragm and bell, in supine/sitting/left-lateral positions as needed.`,pearl:`Time every murmur by simultaneously palpating the carotid pulse with the fingers of your free hand. Pulse = systole. Murmur heard during the pulse = systolic; in between pulses = diastolic.`,steps:[{label:`Positioning`,method:`Patient supine, head of bed at 30°. Exam room quiet, patient relaxed. Warm the stethoscope first.`,normal:`N/A — technique`},{label:`Diaphragm technique`,method:`Firm contact with skin. Detects HIGH-pitched sounds: S1, S2, systolic ejection murmurs, AR, MR.`,normal:`N/A — technique`},{label:`Bell technique`,method:`Very light contact — enough to make a seal but not stretch the skin. Detects LOW-pitched sounds: S3, S4, mitral stenosis rumble.`,normal:`N/A — technique`},{label:`Listen at each of the 5 points`,method:`A → P → E → T → M in order, each with diaphragm then bell. Spend a full cycle at each zone.`,normal:`S1 crisp, S2 clear (splits physiologically on inspiration at P), no added sounds, no murmur`},{label:`Left lateral decubitus position`,method:`If apex murmur suspected. Roll patient to left side. Listen at the apex with the BELL for mitral stenosis rumble or S3/S4.`,normal:`No added sounds, no diastolic rumble`},{label:`Sitting forward, held expiration`,method:`Patient leans forward, exhales fully, holds. Listen at left lower sternal border and Erb's point with the DIAPHRAGM for aortic regurgitation (soft early diastolic decrescendo).`,normal:`No early-diastolic murmur`}],abnormalHints:[`Fixed split S2 (no change with respiration) — ASD`,`Loud S2 at pulmonic area — pulmonary HTN`,`S3 — volume overload, CHF (can be normal in young athletes)`,`S4 — stiff ventricle (HTN, HCM, ischemia)`,`Audible opening snap — mitral stenosis (rare in children)`]},{name:`Auscultation — heart sounds and murmurs`,significance:`Characterising a murmur by timing, location, radiation, pitch, quality, and dynamic maneuvers narrows the differential.`,pearl:`Innocent murmurs in children share 7 "S" features: Soft (≤ grade 2), Systolic, Short, Single (no added S3/S4), Small (localised, non-radiating), Sweet (musical), Sensitive to position/respiration (louder supine, softer standing). Anything breaking this pattern deserves workup.`,steps:[{label:`S1`,method:`Listen at the apex (mitral). Coincides with the carotid pulse upstroke. Mitral + tricuspid closure.`,normal:`Single, crisp, single-component sound`},{label:`S2`,method:`Listen at the pulmonic area in HELD INSPIRATION and HELD EXPIRATION. Note whether S2 splits physiologically (wider in inspiration, narrower/absent in expiration).`,normal:`Physiologic split (widens on inspiration, narrows on expiration)`},{label:`S3 / S4 gallops`,method:`Bell at the apex in left lateral decubitus. S3 = early diastole (after S2), low-pitched. S4 = late diastole (just before S1).`,normal:`Absent in adults; S3 can be normal in young athletes under age 30`},{label:`Identify murmur — timing`,method:`Time vs carotid pulse. Systolic (during pulse) vs diastolic (between pulses) vs continuous.`,normal:`No murmur, or only soft innocent flow murmur`},{label:`Identify murmur — location + radiation`,method:`Where loudest? Does it radiate? AS → carotids. MR → axilla. Coarctation → back.`,normal:`N/A — characterise only if murmur present`},{label:`Identify murmur — character`,method:`Crescendo-decrescendo (ejection) vs holosystolic (plateau) vs decrescendo early-diastolic (AR, PR) vs mid-diastolic rumble (MS, TS).`,normal:`N/A — characterise only if murmur present`},{label:`Grade intensity`,method:`Levine 1–6 scale (see scales card above).`,normal:`No murmur, or grade ≤ 2 soft innocent flow murmur`},{label:`Dynamic maneuvers`,method:`Standing: ↑HOCM, ↑MVP click (earlier). Squatting: opposite. Valsalva: ↑HOCM, most others decrease.`,normal:`No significant change with posture`}],abnormalHints:[`Holosystolic murmur at apex → axilla — mitral regurgitation`,`Holosystolic at lower left sternal border (LLSB) — VSD, tricuspid regurgitation`,`Systolic ejection at upper right sternal border → carotids — aortic stenosis`,`Systolic ejection at upper left sternal border — pulmonary stenosis`,`Continuous "machinery" below left clavicle — PDA`,`Early diastolic at Erb's point, leaning forward — aortic regurgitation`,`Diastolic rumble at apex, bell in left-lateral — mitral stenosis`,`Fixed split S2 + systolic flow murmur — ASD`]},{name:`Peripheral vascular exam`,significance:`Coarctation of the aorta hides until BP and pulses are checked in all four extremities. Differential diagnosis of a hypertensive adolescent should include this in the first 60 seconds.`,pearl:`Four-limb BP measurement is mandatory in any adolescent with hypertension or a murmur. Upper-extremity BP > lower-extremity BP (or brachio-femoral delay) = coarctation until excluded.`,steps:[{label:`Four-limb blood pressure`,method:`Measure BP in right arm, left arm, and at least one leg. Use appropriately sized cuff (bladder width 40% of limb circumference, length 80–100%).`,normal:`Arm BPs within 10 mmHg of each other; leg systolic within 20 mmHg of arm systolic (may be higher)`},{label:`Radial pulses`,method:`Palpate both radials simultaneously — note any delay or asymmetry.`,normal:`Simultaneous, symmetric, 2+`},{label:`Radio-femoral delay`,method:`Palpate radial and femoral simultaneously. Feel the femoral as clearly "after" the radial = delay.`,normal:`No delay`},{label:`Femoral pulses`,method:`Palpate both femoral pulses at the mid-inguinal point. Compare amplitude to radials.`,normal:`Symmetric 2+ pulses, equal amplitude to radial`},{label:`Dorsalis pedis + posterior tibialis`,method:`Palpate in both feet.`,normal:`2+ pulses bilaterally`},{label:`Capillary refill`,method:`Press and release the nail bed; time to normal colour.`,normal:`< 2 sec`}],abnormalHints:[`Asymmetric upper-extremity BP (> 10 mmHg) — subclavian stenosis or coarctation at the origin`,`Upper >> lower-extremity BP — coarctation of the aorta`,`Diminished or absent femoral pulses with brachio-femoral delay — coarctation`,`Bounding pulses with wide pulse pressure — AR, PDA, arteriovenous fistula, thyrotoxicosis, anemia`,`Weak thready pulses — low output state (heart failure, shock, hypovolemia)`,`Prolonged capillary refill — dehydration, shock, cold stress`]}]}}},u={mrc:{title:`MRC strength grade (0–5)`,icon:`fa-hand-fist`,rows:[[`5`,`Normal power — holds against full resistance`],[`4`,`Reduced — moves against gravity + some resistance`],[`3`,`Moves against gravity only (no added resistance)`],[`2`,`Full range with gravity eliminated (horizontal plane)`],[`1`,`Flicker / trace contraction, no joint movement`],[`0`,`No contraction`]]},dtr:{title:`Deep-tendon reflex grade (0–4+)`,icon:`fa-circle-dot`,rows:[[`0`,`Absent`],[`1+`,`Hypoactive — trace, only with reinforcement`],[`2+`,`Normal`],[`3+`,`Brisk — may still be normal in anxious patients`],[`4+`,`Hyperactive with sustained clonus — always abnormal`]]},plantar:{title:`Plantar response (Babinski)`,icon:`fa-shoe-prints`,rows:[[`Down-going`,`Normal in anyone ≥ 2 years`],[`Up-going`,`Normal < 2 years; abnormal after — UMN lesion`],[`Asymmetric`,`Always abnormal at any age`]]},beighton:{title:`Beighton hypermobility score (0–9)`,icon:`fa-hands`,rows:[[`≤ 3`,`Normal flexibility`],[`4`,`Borderline — consider in context`],[`≥ 5`,`Hypermobility spectrum; screen for hEDS if other features present`]]},atr:{title:`Scoliometer — angle of trunk rotation`,icon:`fa-ruler`,rows:[[`< 5°`,`Normal, no follow-up`],[`5–6°`,`Borderline — re-check at each visit`],[`≥ 7°`,`Refer for PA/lateral spine x-ray + orthopedic evaluation`]]},rr:{title:`Respiratory rate — upper limit by age (awake)`,icon:`fa-lungs`,rows:[[`Newborn`,`≤ 60 /min`],[`< 2 months`,`≤ 60 /min (WHO tachypnea cutoff)`],[`2–12 months`,`≤ 50 /min (WHO tachypnea cutoff)`],[`1–5 years`,`≤ 40 /min (WHO tachypnea cutoff)`],[`6–11 years`,`≤ 30 /min`],[`≥ 12 years`,`≤ 20 /min (adult pattern)`]]},spo2:{title:`Pulse oximetry (SpO₂) — at room air`,icon:`fa-heart-pulse`,rows:[[`≥ 95%`,`Normal`],[`92–94%`,`Mild hypoxemia — investigate cause`],[`< 92%`,`Moderate hypoxemia — supplemental O₂`],[`< 88%`,`Severe — urgent intervention; target ≥ 90% acutely`]]},silverman:{title:`Silverman–Andersen retraction score (neonatal, 0–10)`,icon:`fa-baby`,rows:[[`0`,`No respiratory distress`],[`1–3`,`Mild — close observation`],[`4–6`,`Moderate distress — consider CPAP / support`],[`7–10`,`Severe — imminent respiratory failure, intubate`]]},westley:{title:`Westley croup severity score`,icon:`fa-stethoscope`,rows:[[`≤ 2`,`Mild — home management, cool mist, oral dexamethasone`],[`3–5`,`Moderate — nebulised epinephrine + dexamethasone`],[`6–11`,`Severe — admit, continuous monitoring`],[`≥ 12`,`Impending respiratory failure — ICU / airway management`]]},murmurGrade:{title:`Heart-murmur grading (Levine 1–6)`,icon:`fa-wave-square`,rows:[[`1/6`,`Very faint — heard only with concentration`],[`2/6`,`Soft but readily heard`],[`3/6`,`Moderately loud, no thrill`],[`4/6`,`Loud WITH a palpable thrill`],[`5/6`,`Very loud; audible with stethoscope just off the chest`],[`6/6`,`Audible without the stethoscope touching the chest`]]},pulseAmp:{title:`Pulse amplitude grade (0–4)`,icon:`fa-heart-pulse`,rows:[[`0`,`Absent`],[`1+`,`Diminished, thready`],[`2+`,`Normal`],[`3+`,`Bounding`],[`4+`,`Bounding with visible pulsation (e.g., aortic regurgitation)`]]},capRefill:{title:`Capillary refill time`,icon:`fa-hand`,rows:[[`< 2 sec`,`Normal`],[`2–3 sec`,`Borderline — consider hydration / perfusion`],[`≥ 3 sec`,`Delayed — dehydration, shock, low cardiac output`]]}},d={msk:[`atr`,`beighton`],neuro:[`mrc`,`dtr`,`plantar`],resp:[`rr`,`spo2`,`silverman`,`westley`],cv:[`murmurGrade`,`pulseAmp`,`capRefill`]},f=[{letter:`A`,color:`#dc2626`,title:`Aortic area`,location:`2nd ICS, right sternal border`,listen:`S2 (aortic component), aortic stenosis, aortic regurgitation`},{letter:`P`,color:`#2563eb`,title:`Pulmonic area`,location:`2nd ICS, left sternal border`,listen:`S2 (pulmonic component), pulmonic stenosis, PDA, physiologic split of S2`,innocent:`Pulmonary flow murmur (children, adolescents) — upper left sternal border`},{letter:`E`,color:`#059669`,title:`Erb's point`,location:`3rd ICS, left sternal border`,listen:`Aortic regurgitation (best here), transitional zone murmurs`,innocent:`Still's murmur classically radiates to Erb's / LLSB`},{letter:`T`,color:`#d97706`,title:`Tricuspid area`,location:`4th–5th ICS, lower left sternal border`,listen:`Tricuspid regurgitation, VSD, S3/S4, holosystolic murmurs`,innocent:`Still's murmur — vibratory, musical, age 3–7 y (loudest between LLSB and apex)`},{letter:`M`,color:`#7c3aed`,title:`Mitral area (apex)`,location:`5th ICS, mid-clavicular line`,listen:`S1, mitral regurgitation, mitral stenosis (with bell, left-lateral decubitus)`}],p=[{name:`Still's (vibratory) murmur`,age:`3–7 y (most common in children)`,location:`LLSB, radiating to apex`,character:`Low-frequency vibratory / musical systolic, grade 2–3/6, mid-systolic, "twanging-string" quality`,confirm:`Louder supine, softer or disappears on standing or Valsalva. No radiation to neck/back. Normal S2.`},{name:`Pulmonary flow murmur`,age:`School-age and adolescents, thin chest`,location:`Upper left sternal border (2nd–3rd ICS)`,character:`Soft blowing early systolic ejection, grade 1–2/6, higher-pitched`,confirm:`No ejection click. Physiologic split of S2. Louder supine, softer on standing. No radiation.`},{name:`Venous hum`,age:`Ages 3–8, disappears by adolescence`,location:`Supraclavicular or infraclavicular area, usually right`,character:`Soft continuous hum, louder in diastole. Only innocent continuous murmur.`,confirm:`Disappears when supine OR when jugular vein is gently compressed (key maneuver). Turning head to opposite side also alters it.`},{name:`Carotid bruit / supraclavicular bruit`,age:`Children and adolescents`,location:`Supraclavicular fossa, right > left; may radiate to carotid`,character:`Brief early systolic, grade 2–3/6, higher-pitched than Still's`,confirm:`Softer or disappears with hyperextension of the shoulders. Normal cardiac exam otherwise. No radiation below the clavicles.`},{name:`Peripheral pulmonary stenosis (PPS, neonatal)`,age:`Newborns and infants < 6–12 months`,location:`Upper LSB, radiates to BOTH axillae and the back`,character:`Soft systolic ejection murmur, grade 1–2/6`,confirm:`Typical age + radiation to back/axillae. Resolves by age 1 as branch pulmonary arteries grow. Persistence or louder grade warrants echo.`}],m=[{key:`normal`,src:`/audio/respiratory/normal-vesicular.ogg`,title:`Normal vesicular breath sounds`,where:`Peripheral lung fields`,features:`Soft, rustling. Inspiration louder and longer than expiration.`,clinical:`Baseline — deviation elsewhere is what you listen for.`},{key:`wheeze`,src:`/audio/respiratory/wheeze.ogg`,title:`Wheeze`,where:`Diffuse in asthma; localised in foreign body`,features:`Continuous, high-pitched, musical. Usually expiratory; biphasic if severe.`,clinical:`Lower-airway narrowing — asthma, bronchiolitis, foreign body, bronchomalacia. Silent chest in severe asthma is an ominous sign.`},{key:`stridor`,src:`/audio/respiratory/stridor.ogg`,title:`Stridor`,where:`Louder over neck than chest — upper airway`,features:`Continuous, high-pitched, harsh. Classically inspiratory (extrathoracic obstruction); biphasic if fixed.`,clinical:`Croup, epiglottitis, foreign body, laryngomalacia (infant). Distinguish from wheeze by auscultating the neck — stridor is loudest there.`},{key:`finecrackles`,src:`/audio/respiratory/crackles-fine.ogg`,title:`Fine (end-inspiratory) crackles`,where:`Bibasilar in pulmonary edema/fibrosis; focal in pneumonia`,features:`Discontinuous, brief, high-pitched. "Velcro" quality. Late inspiratory, do NOT clear with cough.`,clinical:`Alveolar opening — pulmonary fibrosis, pulmonary edema, early pneumonia, atelectasis.`},{key:`coarsecrackles`,src:`/audio/respiratory/crackles-coarse.ogg`,title:`Coarse crackles`,where:`Lower lobes; either side`,features:`Discontinuous, longer and louder than fine crackles. Lower-pitched. Can be early or late inspiratory; often clear partly with cough.`,clinical:`Secretions in larger airways — bronchitis, later pneumonia, bronchiectasis, aspiration.`},{key:`rhonchi`,src:`/audio/respiratory/rhonchi.ogg`,title:`Rhonchi`,where:`Central or anywhere with airway secretions`,features:`Continuous, low-pitched, snore-like. Typically expiratory. Clear or change with cough.`,clinical:`Large-airway secretions — bronchitis, pneumonia with large-airway involvement, cystic fibrosis, bronchiectasis.`},{key:`pleuralrub`,src:`/audio/respiratory/pleural-rub.ogg`,title:`Pleural friction rub`,where:`Focal, often lateral or posterior lower chest`,features:`Grating, creaky — "leather on leather". Biphasic (heard in inspiration and expiration). Does NOT clear with cough.`,clinical:`Pleural inflammation — pleuritis, pulmonary embolism, pneumonia with pleural involvement, viral pleurisy.`}],h=[{key:`normal`,src:`/audio/cardiac/normal.ogg`,title:`Normal heart sounds (S1, S2)`,where:`All four classic auscultation points`,rate:`~61 bpm reference`,features:`"lub-dub": S1 (closure of mitral + tricuspid) louder at apex; S2 (closure of aortic + pulmonic) louder at base. Physiologic S2 split on inspiration.`,clinical:`Reference for rhythm, rate, and the normal S1–S2 interval. Listen for what's changed — not just what's added.`},{key:`infant-normal`,src:`/audio/cardiac/infant-normal.ogg`,title:`Infant normal heart sounds`,where:`Infant chest — rate will be higher than adult`,rate:`Pediatric reference (120–160 bpm range)`,features:`Same S1–S2 pattern, faster rate. Short diastole makes murmurs easier to miss — careful auscultation needed.`,clinical:`Reference for neonatal/infant rhythm. Any murmur in the first 72 h should prompt pre/postductal sat screening.`},{key:`vsd`,src:`/audio/cardiac/vsd.wav`,title:`Ventricular septal defect (VSD)`,where:`Lower left sternal border (4th ICS)`,features:`Harsh, blowing, holosystolic (pansystolic) murmur — plateau shape through all of systole. Often accompanied by a thrill if large.`,clinical:`Most common congenital heart defect. Small VSD: loud murmur, usually asymptomatic, may close spontaneously. Large VSD: softer murmur (less pressure gradient) but signs of heart failure, pulmonary hypertension.`},{key:`mvp`,src:`/audio/cardiac/mitral-prolapse.wav`,title:`Mitral valve prolapse (MVP) — click + late systolic murmur`,where:`Apex (5th ICS, mid-clavicular line)`,features:`Mid-systolic click followed by a late-systolic crescendo murmur. Timing of click changes with maneuvers: earlier with standing or Valsalva, later with squatting.`,clinical:`Often benign, especially in thin young women. Features suggesting need for echo: thickened/redundant leaflets, associated MR, symptoms (palpitations, chest pain), arrhythmias.`},{key:`stills`,src:`/audio/cardiac/stills-murmur.ogg`,title:`Still's murmur (innocent)`,where:`LLSB, radiating to apex`,rate:`Classic age 3–7 y (this recording is a toddler)`,features:`Low-frequency vibratory / musical systolic, grade 2–3/6, mid-systolic, "twanging-string" quality.`,clinical:`The most common innocent murmur of childhood. Louder supine, softer or disappears on standing or Valsalva. Normal S2. No radiation to neck or back. No workup needed when classic.`},{key:`functional`,src:`/audio/cardiac/functional-murmur.wav`,title:`Functional (innocent) murmur — adult female`,where:`Left sternal border, soft systolic`,features:`Soft systolic murmur in a structurally normal heart — often from increased cardiac output, thin chest wall, anemia, hyperthyroidism, or pregnancy.`,clinical:`Benign if it meets the 7 S criteria. Investigate if loud (≥3/6), holosystolic, diastolic, radiating, or with thrill / symptoms.`}],g=n(),_=`rounded-lg border border-border bg-card p-5 space-y-3`,v=`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors cursor-pointer`,y=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,b=`rounded-md border border-border bg-background px-3 py-2 text-sm font-medium hover:bg-muted disabled:opacity-50`,x=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`;function S(e,t,n,r){return`${e}/${t}/${n}/${r}`}function C({id:e,scale:t}){return(0,g.jsxs)(`section`,{className:`rounded-md border border-border bg-background p-3`,"data-testid":`scale-`+e,children:[(0,g.jsx)(`h4`,{className:`text-sm font-semibold mb-2`,children:t.title}),(0,g.jsx)(`table`,{className:`w-full text-xs`,children:(0,g.jsx)(`tbody`,{children:t.rows.map(([e,t],n)=>(0,g.jsxs)(`tr`,{className:`border-b border-border last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-1 pr-3 font-mono font-semibold whitespace-nowrap`,children:e}),(0,g.jsx)(`td`,{className:`py-1 text-muted-foreground`,children:t})]},n))})})]})}function w({entry:e}){return(0,g.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3 space-y-2`,"data-testid":`sound-`+e.key,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold`,children:e.title}),(0,g.jsx)(`audio`,{controls:!0,preload:`none`,className:`w-full`,children:(0,g.jsx)(`source`,{src:e.src})}),(0,g.jsxs)(`div`,{className:`text-xs space-y-0.5 text-muted-foreground`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Where:`}),` `,e.where]}),e.rate&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Rate:`}),` `,e.rate]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Features:`}),` `,e.features]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Clinical:`}),` `,e.clinical]})]})]})}function T({step:e,status:t,onStatus:n}){let r=`text-xs font-medium px-2 py-1 rounded border`;return(0,g.jsxs)(`div`,{className:`flex items-start gap-2 py-2 border-b border-border last:border-0`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Method:`}),` `,e.method]}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Normal:`}),` `,e.normal]})]}),(0,g.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-1 flex-shrink-0`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>n(t===`normal`?null:`normal`),className:r+` `+(t===`normal`?`bg-green-600 text-white border-green-600`:`border-green-600 text-green-700 hover:bg-green-50 dark:hover:bg-green-950/30`),children:`Normal`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>n(t===`abnormal`?null:`abnormal`),className:r+` `+(t===`abnormal`?`bg-destructive text-white border-destructive`:`border-destructive text-destructive hover:bg-red-50 dark:hover:bg-red-950/30`),children:`Abnormal`})]})]})}function E({age:e,sys:t,idx:n,comp:r,getStatus:i,setStatus:a}){return(0,g.jsxs)(`div`,{className:_,"data-testid":`pe-component-${e}-${t}-${n}`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:r.name}),(0,g.jsx)(`div`,{children:r.steps.map((r,o)=>{let s=S(e,t,n,o);return(0,g.jsx)(T,{step:r,status:i(s),onStatus:e=>a(s,e)},o)})}),r.abnormalHints.length>0&&(0,g.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-destructive mb-1`,children:`Watch for`}),(0,g.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-red-900 dark:text-red-200 space-y-0.5`,children:r.abnormalHints.map((e,t)=>(0,g.jsx)(`li`,{children:e},t))})]}),r.pearl&&(0,g.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-300 dark:border-amber-800 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Pearl:`}),` `,r.pearl]}),r.significance&&(0,g.jsxs)(`div`,{className:`rounded-md bg-sky-50 dark:bg-sky-950/30 border border-sky-200 dark:border-sky-900 p-3 text-xs text-sky-900 dark:text-sky-100`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Significance:`}),` `,r.significance]})]})}function D(){let[e,t]=(0,a.useState)(`toddler`),[n,T]=(0,a.useState)(`msk`),[D,O]=(0,a.useState)(``),[k,A]=(0,a.useState)(``),[j,M]=(0,a.useState)(`narrative`),[N,P]=(0,a.useState)({}),[F,I]=(0,a.useState)(null),L=l[e],R=L[n],z=r({mutationFn:e=>i.post(`/api/generate-pe-narrative`,e),onSuccess:e=>I(e.narrative),onError:e=>I(`Generation failed: `+e.message)}),B=(0,a.useMemo)(()=>{let t=0,r=0,i=0;return R.components.forEach((a,o)=>a.steps.forEach((a,s)=>{let c=N[S(e,n,o,s)]??null;c===`normal`?t++:c===`abnormal`?r++:i++})),{normal:t,abnormal:r,notAssessed:i}},[e,n,R,N]);function V(){P(t=>{let r={...t};return R.components.forEach((t,i)=>t.steps.forEach((t,a)=>{delete r[S(e,n,i,a)]})),r}),I(null)}function H(){P(t=>{let r={...t};return R.components.forEach((t,i)=>t.steps.forEach((t,a)=>{r[S(e,n,i,a)]=`normal`})),r})}function U(){I(null);let t=[];R.components.forEach((r,i)=>r.steps.forEach((a,o)=>{t.push({component:r.name,label:a.label,method:a.method,normal:a.normal,status:N[S(e,n,i,o)]??null})})),z.mutate({steps:t,ageGroup:e,system:n,patientAge:D||void 0,patientGender:k||void 0,format:j})}let W=B.normal+B.abnormal;return(0,g.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-5`,children:[(0,g.jsxs)(`header`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Physical Exam Guide`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Age-group and system-specific exam checklist with abnormal-finding hints. Toggle normal / abnormal on each step, then generate a narrative for your note.`})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Age group`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`pe-age-group-pills`,children:o.map(n=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:v+(e===n?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80 border-border`),"data-testid":`pe-age-`+n,children:l[n].label},n))})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`System`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`pe-system-pills`,children:s.map(e=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:v+(n===e?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80 border-border`),"data-testid":`pe-system-`+e,children:c[e]},e))})]}),(0,g.jsxs)(`section`,{className:_+` border-l-4 border-l-primary`,"data-testid":`pe-overview`,children:[(0,g.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[L.label,` — `,c[n]]}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:R.overview})]}),n===`cv`&&(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-cv-aptm`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:`Auscultation landmarks (APTM + Erb's)`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:f.map(e=>(0,g.jsxs)(`div`,{className:`flex gap-3 items-start rounded-md border border-border p-3`,children:[(0,g.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center font-bold text-white flex-shrink-0`,style:{background:e.color},children:e.letter}),(0,g.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,g.jsx)(`div`,{className:`font-semibold`,children:e.title}),(0,g.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.location}),(0,g.jsxs)(`div`,{className:`text-xs mt-1`,children:[(0,g.jsx)(`strong`,{children:`Listen for:`}),` `,e.listen]}),e.innocent&&(0,g.jsxs)(`div`,{className:`text-xs text-green-700 dark:text-green-300 mt-1`,children:[(0,g.jsx)(`em`,{children:`Innocent:`}),` `,e.innocent]})]})]},e.letter))}),(0,g.jsx)(`h3`,{className:`text-base font-semibold mt-3`,children:`Cardiac sounds library`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:h.map(e=>(0,g.jsx)(w,{entry:e},e.key))}),(0,g.jsx)(`h3`,{className:`text-base font-semibold mt-3`,children:`Classic innocent murmurs`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:p.map(e=>(0,g.jsxs)(`div`,{className:`rounded-md border border-green-200 dark:border-green-900 bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1`,children:[(0,g.jsx)(`div`,{className:`font-semibold`,children:e.name}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Age: `,e.age,` · Location: `,e.location]}),(0,g.jsxs)(`div`,{className:`text-xs`,children:[(0,g.jsx)(`strong`,{children:`Sound:`}),` `,e.character]}),(0,g.jsxs)(`div`,{className:`text-xs`,children:[(0,g.jsx)(`strong`,{children:`Confirm innocent:`}),` `,e.confirm]})]},e.name))})]}),n===`resp`&&(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-resp-sounds`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:`Respiratory sounds library`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:m.map(e=>(0,g.jsx)(w,{entry:e},e.key))})]}),d[n]&&d[n].length>0&&(0,g.jsxs)(`details`,{className:_,"data-testid":`pe-scales`,children:[(0,g.jsx)(`summary`,{className:`cursor-pointer font-semibold text-sm`,children:`Grading scales & reference`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mt-3`,children:d[n].map(e=>{let t=u[e];return t?(0,g.jsx)(C,{id:e,scale:t},e):null})})]}),(0,g.jsxs)(`section`,{className:`space-y-3`,"data-testid":`pe-checklist`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,g.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Exam checklist`}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-3`,children:[(0,g.jsxs)(`span`,{className:`text-green-600`,children:[B.normal,` normal`]}),(0,g.jsxs)(`span`,{className:`text-destructive`,children:[B.abnormal,` abnormal`]}),(0,g.jsxs)(`span`,{children:[B.notAssessed,` not assessed`]})]})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:H,className:b,"data-testid":`btn-pe-all-normal`,children:`Mark all normal`}),(0,g.jsx)(`button`,{type:`button`,onClick:V,className:b,"data-testid":`btn-pe-reset`,children:`Reset`})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 gap-3`,children:R.components.map((t,r)=>(0,g.jsx)(E,{age:e,sys:n,idx:r,comp:t,getStatus:e=>N[e]??null,setStatus:(e,t)=>P(n=>({...n,[e]:t}))},r))})]}),(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-generate`,children:[(0,g.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Generate Exam Report`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Uses the statuses above + optional patient context.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,g.jsx)(`input`,{className:x,placeholder:`Patient age (e.g. 3y)`,value:D,onChange:e=>O(e.target.value)}),(0,g.jsx)(`input`,{className:x,placeholder:`Patient gender (optional)`,value:k,onChange:e=>A(e.target.value)}),(0,g.jsxs)(`select`,{className:x,value:j,onChange:e=>M(e.target.value),children:[(0,g.jsx)(`option`,{value:`narrative`,children:`Narrative`}),(0,g.jsx)(`option`,{value:`list`,children:`List`})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`button`,{type:`button`,className:y,onClick:U,disabled:z.isPending||W===0,"data-testid":`btn-pe-generate`,children:z.isPending?`Generating…`:`Generate Exam Report`}),W===0&&(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Mark at least one step before generating.`})]}),F&&(0,g.jsx)(`div`,{className:`rounded-md border border-border bg-muted/40 p-3 whitespace-pre-wrap text-sm`,"data-testid":`pe-narrative`,children:F})]})]})}export{D as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-C9wKWOAN.js";var a=e(t(),1),o=[`newborn`,`infant`,`toddler`,`preschool`,`school`,`adolescent`],s=[`msk`,`neuro`,`resp`,`cv`],c={msk:`Musculoskeletal`,neuro:`Neuro`,resp:`Respiratory`,cv:`Cardiovascular`},l={newborn:{label:`Newborn (0–28 days)`,msk:{overview:`Exam done warm, quiet, undressed. Focus: birth injury, DDH, congenital anomaly. All steps symmetric.`,components:[{name:`Resting posture`,steps:[{label:`Observe posture`,method:`Place supine and undisturbed for 30s`,normal:`Symmetric flexion at hips, knees, elbows`},{label:`Hand position`,method:`Inspect resting hands`,normal:`Loosely fisted; opens intermittently`},{label:`Symmetry`,method:`Compare left vs right side at rest`,normal:`Mirror-image posture`}],abnormalHints:[`Frog-leg (hypotonia)`,`Asymmetric arm (brachial plexus/clavicle fx)`,`Opisthotonos (CNS)`,`Persistent fisting with thumb in palm`]},{name:`Clavicles`,steps:[{label:`Palpate right clavicle`,method:`Trace from sternoclavicular joint to acromion with index finger`,normal:`Smooth, continuous, no step-off`},{label:`Palpate left clavicle`,method:`Same technique on left side`,normal:`Smooth, continuous`},{label:`Crepitus check`,method:`Light pressure along length of clavicle while gently abducting arm`,normal:`No crepitus, no pain response`}],abnormalHints:[`Palpable step-off or callus (fracture — LGA, shoulder dystocia)`,`Asymmetric Moro on affected side`]},{name:`Hips — DDH screen`,steps:[{label:`Thigh/gluteal folds`,method:`Undress completely; compare skin-fold symmetry`,normal:`Symmetric thigh and gluteal folds`},{label:`Abduction`,method:`Flex hips 90°, abduct simultaneously`,normal:`Both hips abduct to ≥75° symmetrically`},{label:`Barlow maneuver`,method:`Thumb on medial thigh, flex hip 90°, adduct, apply gentle posterior pressure`,normal:`No clunk or movement felt (negative)`},{label:`Ortolani maneuver`,method:`From Barlow position: abduct and lift with fingers on greater trochanter`,normal:`No clunk as hip returns (negative)`},{label:`Galeazzi sign`,method:`Knees flexed together with feet on table; compare knee heights`,normal:`Knees level — no leg-length discrepancy`}],abnormalHints:[`Palpable Ortolani clunk (dislocated, reducible)`,`Barlow clunk (dislocatable)`,`Limited abduction`,`Positive Galeazzi (shortened femur)`]},{name:`Spine and back`,steps:[{label:`Position prone`,method:`Turn infant prone, support chest`,normal:`Tolerates position, lifts head briefly`},{label:`Palpate midline`,method:`Run finger from C-spine to coccyx`,normal:`Straight midline, no step-offs or gaps`},{label:`Sacral inspection`,method:`Inspect sacral dimple if present; measure depth, distance from anus`,normal:`No dimple, or dimple <5mm deep and <2.5cm from anus`},{label:`Cutaneous markers`,method:`Inspect midline skin from neck to coccyx`,normal:`No hair tuft, hemangioma, lipoma, or sinus tract`}],abnormalHints:[`Deep sacral dimple (>5mm) or >2.5cm from anus — imaging`,`Hair tuft, hemangioma, lipoma (occult dysraphism)`,`Palpable defect`]},{name:`Upper extremities`,steps:[{label:`Spontaneous movement`,method:`Observe both arms for 30s`,normal:`Symmetric antigravity movement`},{label:`Digits`,method:`Count and inspect fingers both hands`,normal:`5 digits each, no webbing or duplication`},{label:`Palmar creases`,method:`Inspect palmar creases`,normal:`Normal triradiate creases`}],abnormalHints:[`Erb/Klumpke palsy (paucity of movement)`,`Polydactyly, syndactyly`,`Single transverse (simian) palmar crease`]},{name:`Lower extremities / feet`,steps:[{label:`Hip and knee range`,method:`Gently flex, extend, internally/externally rotate each`,normal:`Full symmetric range, no contracture`},{label:`Foot alignment`,method:`Inspect resting foot position`,normal:`Midline or mildly adducted forefoot`},{label:`Passive correction`,method:`Gently attempt to bring foot to neutral`,normal:`Fully correctable to neutral`},{label:`Stroke test`,method:`Stroke lateral border of foot`,normal:`Foot dorsiflexes and everts reflexively`}],abnormalHints:[`Rigid clubfoot (non-correctable talipes equinovarus)`,`Fixed metatarsus adductus`,`Rocker-bottom foot (trisomy 18)`,`Calcaneovalgus`]}]},neuro:{overview:`Primitive reflexes present and symmetric. Tone assessed passively and actively. Full exam 3–5 min on a quiet, fed infant.`,components:[{name:`Alertness and behavior`,steps:[{label:`State cycling`,method:`Observe over 1–2 min for alert periods`,normal:`Alert periods with spontaneous eye opening`},{label:`Response to voice`,method:`Speak softly near ear`,normal:`Quiets to voice or turns toward sound`},{label:`Consolability`,method:`If crying, attempt to soothe with swaddling or voice`,normal:`Consolable within 1–2 min`}],abnormalHints:[`Lethargy`,`Jitteriness not stopped by passive flexion`,`Irritability unrelieved by feeding`]},{name:`Cranial nerves`,steps:[{label:`CN II — pupil response`,method:`Shine light in each eye`,normal:`Pupils equal, reactive to light, direct and consensual`},{label:`CN II — blink to light`,method:`Bright light in the line of sight`,normal:`Reflex blink`},{label:`CN VII — facial symmetry at rest`,method:`Observe resting face`,normal:`Symmetric nasolabial folds`},{label:`CN VII — facial symmetry with cry`,method:`Note face during a cry`,normal:`Symmetric grimace`},{label:`CN IX, X, XII — suck and swallow`,method:`Offer clean gloved finger, pacifier, or during feed`,normal:`Strong coordinated suck-swallow, no choking`}],abnormalHints:[`Asymmetric face (CN VII injury — usually forceps)`,`Poor suck or uncoordinated swallow`,`Fixed or unequal pupil`]},{name:`Tone — passive`,steps:[{label:`Pull-to-sit`,method:`Grasp hands/wrists, pull smoothly to sit`,normal:`Brief head lag at term; not dramatic`},{label:`Ventral suspension`,method:`Suspend prone over hand at chest`,normal:`Head briefly lifts to horizontal; extremities flexed`},{label:`Arm recoil`,method:`Extend both arms fully at elbows, release`,normal:`Rapid return to flexion`},{label:`Popliteal angle`,method:`Hip flexed 90°, extend knee maximally`,normal:`≤110°`}],abnormalHints:[`Marked head lag (hypotonia)`,`Slip-through on vertical suspension`,`Hypertonia / scissoring`,`Floppy limbs with no recoil`]},{name:`Spontaneous movement`,steps:[{label:`Observe limbs`,method:`Undisturbed over 1 min, note movement`,normal:`Symmetric antigravity movement of all 4 limbs`},{label:`Quality of movement`,method:`Note smoothness vs jitteriness`,normal:`Smooth, mildly variable movements`}],abnormalHints:[`Paucity of movement in one limb`,`Coarse jitteriness`,`Clonic jerks`,`Tonic posturing`]},{name:`Primitive reflexes`,steps:[{label:`Moro`,method:`Support head; allow 30° head drop or loud clap`,normal:`Symmetric arm abduction then flexion, often cry`},{label:`Rooting`,method:`Stroke cheek at corner of mouth`,normal:`Turns head toward stroke and opens mouth`},{label:`Palmar grasp`,method:`Press into palm with finger`,normal:`Strong, symmetric finger flexion`},{label:`Plantar grasp`,method:`Press ball of foot below toes`,normal:`Toes flex around finger symmetrically`},{label:`Stepping`,method:`Hold upright with feet touching surface`,normal:`Alternating stepping movements`},{label:`Tonic neck (fencing)`,method:`Turn head to one side with infant supine`,normal:`Same-side arm extends, opposite flexes (not obligate)`},{label:`Galant`,method:`Stroke paravertebrally from shoulder to buttock, one side`,normal:`Trunk curves toward stroked side`}],abnormalHints:[`Absent or asymmetric Moro — CNS injury, brachial plexus, clavicle fx`,`Absent grasps — CNS depression`,`Obligate tonic neck is abnormal`]},{name:`Babinski (plantar response)`,steps:[{label:`Stroke lateral sole`,method:`Firm stroke from heel toward toes along lateral plantar border`,normal:`Up-going great toe with fanning (normal in newborn)`},{label:`Symmetry check`,method:`Repeat opposite foot`,normal:`Symmetric response`}],abnormalHints:[`Asymmetric response is always abnormal`]}]},resp:{overview:`Newborn respiratory transition — RDS, TTN, pneumonia, meconium aspiration dominate the differential. Normal RR ≤ 60. Grunting is an alarm sign.`,components:[{name:`Inspection`,significance:`Detects distress and localises cause. Silverman score quantifies retraction severity.`,pearl:`Grunting is physiologic PEEP against a partially closed glottis — always a sign of significant lung pathology in a newborn. Never dismiss it as fussy breathing.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s, quiet and undisturbed.`,normal:`40–60 /min; tachypnea > 60`},{label:`Work of breathing (Silverman)`,method:`Inspect for upper-chest retraction, lower-chest retraction, xiphoid retraction, nasal flaring, grunting. Score 0–2 for each.`,normal:`Total Silverman 0 — no distress`},{label:`Audible sounds`,method:`Listen without stethoscope — stridor? grunting? wheeze across the room?`,normal:`Quiet respirations`},{label:`Colour`,method:`Inspect trunk and mucous membranes for central cyanosis; acrocyanosis (blue hands/feet) is normal in the first days.`,normal:`Pink trunk and mucous membranes`},{label:`Chest shape`,method:`Inspect AP:transverse diameter and symmetry.`,normal:`Slightly barrel-shaped is normal; symmetric`}],abnormalHints:[`Grunting — RDS, pneumonia, sepsis, CHD`,`Retractions + tachypnea — RDS, TTN, pneumothorax`,`Central cyanosis — cyanotic CHD, severe lung disease, persistent pulmonary HTN`,`Asymmetric chest movement — pneumothorax, diaphragmatic hernia`]},{name:`Auscultation`,significance:`Short stethoscope time in neonates because they fuss easily — get the most important zones first.`,pearl:`Listen at the axilla, not just the anterior chest — pneumothorax can sound normal anteriorly. Auscultate both axillae systematically.`,steps:[{label:`Air entry — anterior`,method:`Listen bilaterally at the upper and lower anterior chest.`,normal:`Symmetric bilateral air entry`},{label:`Air entry — axillary`,method:`Listen bilaterally at each axilla — this is the most sensitive area for detecting a small pneumothorax.`,normal:`Clear and symmetric`},{label:`Adventitious sounds`,method:`Listen for transmitted upper-airway sounds, crackles (RDS, pneumonia), grunting sounds.`,normal:`No crackles, no wheeze, clear sounds`},{label:`Inspiration:expiration ratio`,method:`Observe breath-sound timing.`,normal:`Inspiration > expiration in length`}],abnormalHints:[`Asymmetric air entry — pneumothorax, diaphragmatic hernia, endobronchial intubation`,`Fine crackles — RDS, TTN, pneumonia`,`Absent breath sounds unilaterally — pneumothorax or selective intubation`]}]},cv:{overview:`Neonatal CV exam screens for CHD — the window of presentation is short and some lesions (duct-dependent) decompensate within hours of birth. Pre/postductal saturations + femoral pulses are the two fastest screens.`,components:[{name:`Inspection and pre/postductal saturations`,significance:`Pre/postductal SpO₂ differential > 3% suggests a duct-dependent lesion or persistent pulmonary HTN. Universal CCHD screening uses this.`,pearl:`Pulse ox on the right hand = preductal (proximal to PDA insertion). Foot = postductal. Both arms and both legs should match; a differential is a red flag for critical CHD.`,steps:[{label:`Central cyanosis`,method:`Inspect tongue, lips, oral mucosa.`,normal:`Pink mucous membranes`},{label:`Pre/postductal SpO₂`,method:`Measure SpO₂ in right hand (preductal) AND either foot (postductal). Baby must be ≥24 hr old for CCHD screening.`,normal:`Both ≥ 95% AND difference < 3%`},{label:`Peripheral perfusion`,method:`Capillary refill on sternum; note mottling or distal cyanosis.`,normal:`Capillary refill < 2 s, warm pink extremities`},{label:`Precordial activity`,method:`Inspect anterior chest for hyperactive precordium.`,normal:`Not visible or minimally visible`}],abnormalHints:[`Central cyanosis with SpO₂ < 95% → cyanotic CHD workup (4-extremity BP, ECG, hyperoxia test, echo)`,`Differential > 3% (pre > post) → duct-dependent systemic flow (HLHS, coarctation, interrupted arch)`,`Preductal < postductal — persistent pulmonary HTN with reversed shunt`]},{name:`Palpation and auscultation`,significance:`Absent femoral pulses + arm-leg BP gradient = coarctation. Many CHD lesions manifest murmurs only after ductus closes (48–72 h).`,pearl:`Always palpate femoral pulses before discharging any newborn. Absent femorals in a well-appearing baby can be the only finding in a ductal-dependent coarctation — catastrophic if missed.`,steps:[{label:`Apex beat`,method:`Palpate at the 4th ICS left of sternum (apex is higher in newborns).`,normal:`Palpable at 4th ICS, mid-clavicular or just lateral`},{label:`Femoral pulses`,method:`Palpate both femoral pulses at the mid-inguinal point while simultaneously feeling the right brachial pulse — detects delay.`,normal:`Present, symmetric, equal timing with brachial`},{label:`Auscultate each cardiac area`,method:`Use pediatric diaphragm at each classic point; baby quiet if possible.`,normal:`S1 S2 crisp; physiologic flow murmur sometimes present in the first 24–48 h`},{label:`Continuous murmur`,method:`Listen below the left clavicle for a continuous ("machinery") murmur of PDA.`,normal:`No continuous murmur after the first day of life in a term baby`},{label:`Four-limb BP (if any concern)`,method:`Right arm, left arm, both legs.`,normal:`Within 10 mmHg across limbs`}],abnormalHints:[`Absent femoral pulses — coarctation of the aorta (surgical emergency if duct-dependent)`,`Harsh holosystolic at LLSB — VSD`,`Continuous machinery murmur — PDA (expected in preterm; in term > 48 h is abnormal)`,`Gallop S3/S4 — heart failure`,`Single S2 — transposition, truncus, severe AS/PS`]}]}},infant:{label:`Infant (1–12 months)`,msk:{overview:`Continued DDH screen through 6 months. Watch motor progression and symmetry of tone/movement.`,components:[{name:`Hips — continued DDH screen`,steps:[{label:`Thigh-fold symmetry`,method:`Inspect with infant supine, thighs flexed`,normal:`Symmetric folds`},{label:`Barlow/Ortolani (through 3mo)`,method:`As in newborn — thumb medial, flex 90°, adduct+push then abduct+lift`,normal:`Negative bilaterally`},{label:`Abduction (any age)`,method:`Flex 90°, abduct simultaneously`,normal:`≥70° symmetric abduction`},{label:`Galeazzi`,method:`Knees flexed feet flat on exam table`,normal:`Knees equal height`}],abnormalHints:[`Clunk on Barlow/Ortolani (<3mo)`,`Limited abduction`,`Asymmetric folds`,`Positive Galeazzi`]},{name:`Gross-motor milestones (age-appropriate)`,steps:[{label:`Head control`,method:`Prone, pull-to-sit, held upright`,normal:`Age-appropriate: 2mo lifts head 45°; 4mo no head lag`},{label:`Rolling`,method:`Observe on flat surface`,normal:`Rolls back-to-front by 5–6mo`},{label:`Sitting`,method:`Place in sitting position`,normal:`Tripod sit by 6mo; sits without support by 7–8mo`},{label:`Standing`,method:`Support under arms`,normal:`Bears weight by 6mo; pulls to stand by 9mo`}],abnormalHints:[`Milestone delay by ≥2mo`,`Loss of previously attained milestone`,`Asymmetric use of limbs`]},{name:`Spine`,steps:[{label:`Palpate seated`,method:`Run finger along spine with infant sitting or held upright`,normal:`Midline, no step-offs`},{label:`Back curvature`,method:`Inspect sitting and lying`,normal:`Physiologic gentle kyphosis in early infancy; lumbar lordosis as sitting develops`}],abnormalHints:[`Fixed kyphoscoliosis`,`Sacral dimple with cutaneous marker`,`Step-off`]},{name:`Extremities`,steps:[{label:`Passive range`,method:`Through each major joint`,normal:`Full symmetric range`},{label:`Joint inspection`,method:`Inspect for swelling, warmth, effusion`,normal:`No swelling, warmth, or effusion`},{label:`Feet alignment`,method:`Observe standing if pulling up, else passive positioning`,normal:`Correctable or aligned feet; flexible`}],abnormalHints:[`Joint swelling/warmth (septic vs reactive arthritis)`,`Rigid clubfoot`,`Persistent asymmetric tone`]}]},neuro:{overview:`Primitive reflexes fading on schedule; protective reflexes emerging; gross motor and tone interlinked.`,components:[{name:`Alertness and social engagement`,steps:[{label:`Social smile`,method:`Face-to-face interaction`,normal:`Social smile by 6–8 weeks`},{label:`Tracking`,method:`Move object across visual field`,normal:`180° horizontal tracking by 3mo`},{label:`Engagement`,method:`Face-to-face, voice, toys`,normal:`Age-appropriate reciprocal interaction`}],abnormalHints:[`No social smile by 3mo`,`Absent tracking past 3mo`,`Poor engagement (developmental concern)`]},{name:`Cranial nerves`,steps:[{label:`Pupils`,method:`Light response each eye`,normal:`Equal reactive`},{label:`Eye alignment`,method:`Inspect with gaze forward and in all directions`,normal:`No strabismus past 4mo`},{label:`Facial symmetry`,method:`Observe smile and cry`,normal:`Symmetric`},{label:`Suck and swallow`,method:`Observe feeding`,normal:`Coordinated, no choking`}],abnormalHints:[`Persistent nystagmus`,`Strabismus past 4mo`,`Asymmetric face`]},{name:`Tone`,steps:[{label:`Pull-to-sit`,method:`Gently pull wrists/hands`,normal:`No head lag by 4mo`},{label:`Ventral suspension`,method:`Support prone, observe`,normal:`Head above horizontal, extremities actively flexed (age-dependent)`},{label:`Vertical suspension`,method:`Support under arms, lift`,normal:`Does not slip through hands`}],abnormalHints:[`Persistent head lag past 4mo (hypotonia)`,`Hypertonia / scissoring (UMN)`,`Slip-through on vertical suspension`]},{name:`Primitive reflex integration`,steps:[{label:`Moro`,method:`Head drop or clap`,normal:`Absent by 6mo`},{label:`Palmar grasp`,method:`Press into palm`,normal:`Integrated by 5–6mo; replaced by voluntary grasp`},{label:`Tonic neck`,method:`Turn head to side`,normal:`Absent by 6mo`},{label:`Rooting`,method:`Stroke cheek`,normal:`Absent by 3–4mo`}],abnormalHints:[`Persistence of any primitive reflex past 6mo warrants eval (CP, CNS injury)`]},{name:`Protective and postural reflexes`,steps:[{label:`Parachute`,method:`Held prone, tilt head downward suddenly`,normal:`Symmetric arm extension protectively by 9mo (emerges 6–9mo)`},{label:`Lateral propping`,method:`Seated infant, gentle tilt to one side`,normal:`Arm extends to catch by 6–7mo`},{label:`Landau`,method:`Suspend prone`,normal:`Extends head, spine, legs by 6mo`}],abnormalHints:[`Absent parachute after 12mo (concerning)`,`Asymmetric lateral propping`,`Absent Landau`]}]},resp:{overview:`Infant respiratory disease centers on bronchiolitis, reactive airways, and pneumonia. Normal RR ≤ 50 (< 2 mo: ≤ 60). Infants are obligate nose-breathers — nasal congestion alone can cause significant WOB.`,components:[{name:`Inspection`,significance:`Infant distress signs escalate fast. Nasal flaring, tracheal tug, head bobbing = significant WOB. Apnea in an infant < 2 mo is an emergency.`,pearl:`A quiet infant with retractions is more worrying than a crying one — exhausted infants stop crying and become hypoxic silently.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s while quiet.`,normal:`< 2 mo: ≤ 60; 2–12 mo: ≤ 50`},{label:`Work of breathing`,method:`Inspect nasal flaring, subcostal/intercostal/suprasternal retractions, tracheal tug, head-bobbing, accessory muscle use.`,normal:`No retractions, effortless breathing`},{label:`Audible sounds`,method:`Stridor? Wheeze across the room? Grunting? Prolonged expiration?`,normal:`Quiet respirations`},{label:`Colour and feeding history`,method:`Central cyanosis? Poor feeding (feeding is an effort marker in infants)?`,normal:`Pink, feeds well`},{label:`Apnea observation`,method:`Watch for ≥ 20-s pauses or pauses < 20 s with bradycardia/cyanosis.`,normal:`No apneas`}],abnormalHints:[`Grunting / persistent retractions — pneumonia, bronchiolitis, CHF`,`Wheeze — bronchiolitis (RSV), asthma, foreign body`,`Stridor — croup (6 mo–6 y), laryngomalacia (infant), foreign body`,`Apnea — bronchiolitis, sepsis, pertussis, seizure`]},{name:`Auscultation`,significance:`Infants have a thin chest wall — sounds transmit widely. Symmetry, wheeze, and crackles are the main findings.`,pearl:`In bronchiolitis, the classical finding is widespread end-inspiratory fine crackles PLUS expiratory wheeze. Tachypnea + retractions in an RSV-season infant confirms.`,steps:[{label:`Air entry — bilateral`,method:`Warm stethoscope; listen at anterior chest and both axillae, both sides.`,normal:`Symmetric air entry`},{label:`Wheeze`,method:`Listen in expiration. Diffuse wheeze = lower airway; focal wheeze = foreign body or local obstruction.`,normal:`No wheeze`},{label:`Crackles`,method:`Listen in late inspiration. Focal = pneumonia; diffuse fine = bronchiolitis.`,normal:`No crackles`},{label:`Prolonged expiration`,method:`Note expiration:inspiration length ratio.`,normal:`Inspiration ≥ expiration`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse wheeze + fine crackles in an RSV-season infant — bronchiolitis`,`Silent chest with extreme WOB — impending respiratory failure`]}]},cv:{overview:`Most CHD manifests in the first year as pulmonary blood-flow changes and the ductus closes. Infant CV exam = growth review + inspection + femoral pulses + auscultation. A harsh pan-systolic LLSB murmur in a 6-week-old = VSD until proven otherwise.`,components:[{name:`Inspection and functional assessment`,significance:`Heart failure in infants presents as poor feeding, sweating during feeds (diaphoresis), tachypnea, and poor weight gain. These historical features predict bad exam findings.`,pearl:`Ask "Does the baby sweat while feeding?" — infant CHF presents with diaphoresis on the forehead during feeds, well before peripheral edema appears.`,steps:[{label:`Growth trajectory`,method:`Plot weight-for-age on WHO chart. Failure to thrive raises CHD concern.`,normal:`Tracking ≥ 10th percentile or stable on personal curve`},{label:`Feeding history`,method:`Ask about feed duration, sweating with feeds, tachypnea with feeds, tiring easily.`,normal:`Feeds < 20 min, no diaphoresis, no tachypnea`},{label:`Central cyanosis`,method:`Inspect tongue and oral mucosa.`,normal:`Pink`},{label:`Clubbing`,method:`Inspect finger nail beds (subtle in infants).`,normal:`No clubbing`},{label:`Peripheral perfusion`,method:`Cap refill, warmth of extremities.`,normal:`Cap refill < 2 s, warm extremities`}],abnormalHints:[`Poor weight gain — consider CHF from L-to-R shunt (VSD, PDA, AVSD)`,`Diaphoresis with feeds — infant CHF`,`Tiring with feeds — significant CHD`,`Central cyanosis — cyanotic CHD (ToF, TGA, TA, etc.)`]},{name:`Palpation and auscultation`,significance:`Femoral pulses + 4-limb BP screen coarctation. A harsh holosystolic murmur at LLSB is almost always a VSD in this age.`,pearl:`Listen over each of the 5 classic points as in the adult exam — the locations shift slightly with infant chest size but relative positions are the same. Also listen at the back: coarctation murmurs radiate there.`,steps:[{label:`Apex beat`,method:`Palpate at 4th ICS mid-clavicular line.`,normal:`Palpable at 4th ICS in infants`},{label:`Femoral pulses`,method:`Palpate bilaterally, simultaneously with right brachial.`,normal:`Present, equal, no delay vs brachial`},{label:`Listen at each classic area (APTM)`,method:`See APTM diagram. Use pediatric stethoscope with both diaphragm and bell.`,normal:`S1 and S2 crisp, no murmur or physiologic only`},{label:`Listen over the back (interscapular)`,method:`Check for radiation of coarctation murmurs.`,normal:`No radiating murmur`}],abnormalHints:[`Harsh holosystolic LLSB murmur — VSD`,`Continuous "machinery" murmur below left clavicle — PDA`,`Systolic ejection at ULSB + fixed split S2 — ASD`,`Ejection murmur at ULSB + cyanosis — tetralogy of Fallot`,`Absent femorals + radio-femoral delay — coarctation`,`Gallop + tachycardia — heart failure`]}]}},toddler:{label:`Toddler (1–3 years)`,msk:{overview:`Gait, physiologic alignment changes, in-toeing, joint range. Cooperation unpredictable — use play.`,components:[{name:`Gait`,steps:[{label:`Base of support`,method:`Have child walk ~10 feet`,normal:`Wide-based initially, narrowing by 2y`},{label:`Heel-strike`,method:`Observe foot contact pattern`,normal:`Heel-strike developing by 18mo, consistent by 2y`},{label:`Arm swing`,method:`Observe reciprocal arm swing`,normal:`Reciprocal arm swing by 18mo`},{label:`Symmetry`,method:`Watch both sides in stance and swing`,normal:`Symmetric stride length and cadence`}],abnormalHints:[`Toe-walking past 2y (idiopathic vs CP vs DMD)`,`Limp (Legg-Calvé-Perthes, transient synovitis, trauma)`,`Wide-based ataxia`]},{name:`Knee alignment`,steps:[{label:`Stand feet together`,method:`Feet/medial malleoli touching; inspect knees`,normal:`Genu varum resolving by 18–24mo; mild genu valgum common by 2–3y`},{label:`Intercondylar or intermalleolar distance`,method:`Measure if alignment appears abnormal`,normal:`<5cm intercondylar (varum) or <8cm intermalleolar (valgum)`},{label:`Symmetry`,method:`Compare sides`,normal:`Symmetric`}],abnormalHints:[`Persistent varum past 2y`,`Severe valgum >8cm`,`Unilateral (Blount disease, rickets)`]},{name:`Feet alignment`,steps:[{label:`In-toeing / out-toeing`,method:`Observe foot angle during gait`,normal:`Mild in-toeing common (tibial torsion, femoral anteversion)`},{label:`Arch during stance`,method:`Stand flat, then on tiptoes`,normal:`Flexible flat foot that forms arch on tiptoe`},{label:`Heel alignment`,method:`View from behind standing`,normal:`Neutral or mildly valgus heel`}],abnormalHints:[`Rigid flat foot (tarsal coalition)`,`Fixed metatarsus adductus`,`Severe in-toeing >15°`]},{name:`Joint range`,steps:[{label:`Hips`,method:`Flex, abduct, rotate each hip`,normal:`Full symmetric range, no pain`},{label:`Knees`,method:`Flex, extend; palpate for effusion`,normal:`Full range, no effusion, stable`},{label:`Ankles`,method:`Dorsiflex, plantarflex, invert, evert`,normal:`Full range`},{label:`Shoulders, elbows, wrists`,method:`Through full range each`,normal:`Full symmetric range`}],abnormalHints:[`Joint effusion (septic vs reactive)`,`Guarded or painful motion`,`Asymmetric limitation`]},{name:`Spine`,steps:[{label:`Inspect standing`,method:`View spine from behind`,normal:`Midline, no prominent curve`},{label:`Palpate midline`,method:`Run finger along spinous processes`,normal:`Midline, no step-off, no tenderness`},{label:`Shoulder/hip symmetry`,method:`Compare shoulder and hip heights`,normal:`Symmetric`}],abnormalHints:[`Fixed scoliosis`,`Abnormal kyphosis`,`Asymmetric shoulder/hip`,`Midline tenderness`]}]},neuro:{overview:`Shifting to adult-pattern exam. Primitive reflexes should be absent. Use play-based techniques.`,components:[{name:`Mental status and language`,steps:[{label:`Engagement`,method:`Interaction with examiner/parent`,normal:`Alert, interactive, age-appropriate`},{label:`Language — expressive`,method:`Note spontaneous utterances`,normal:`1y: 1–3 words; 2y: 2-word phrases; 3y: short sentences`},{label:`Language — receptive`,method:`Ask to point to body parts or follow simple commands`,normal:`Follows age-appropriate commands`}],abnormalHints:[`Language regression (autism, epileptic encephalopathy)`,`Poor engagement`,`No 2-word phrases by 2y`]},{name:`Cranial nerves`,steps:[{label:`CN II — pupil response`,method:`Shine light each eye`,normal:`Pupils equal reactive`},{label:`CN III, IV, VI — EOM`,method:`Follow toy in H pattern`,normal:`Full smooth tracking, no strabismus`},{label:`CN V — facial sensation`,method:`Light touch on forehead, cheek, jaw`,normal:`Responds to touch, symmetric`},{label:`CN VII — face`,method:`Elicit smile, watch eye closure during cry`,normal:`Symmetric face`},{label:`CN IX, X, XII — mouth`,method:`Say "ahh"; stick out tongue`,normal:`Palate rises symmetrically; tongue midline`}],abnormalHints:[`Strabismus`,`Facial asymmetry`,`Tongue deviation`,`Absent palate elevation`]},{name:`Motor — tone and bulk`,steps:[{label:`Passive tone`,method:`Move each limb through full range`,normal:`Normal resistance throughout`},{label:`Bulk inspection`,method:`Inspect muscle bulk of thighs, calves, glutes`,normal:`Symmetric, age-appropriate bulk`},{label:`Contracture check`,method:`Test for heel-cord tightness, hamstring tightness`,normal:`No contractures`}],abnormalHints:[`Spasticity (especially catch in ankles)`,`Hypotonia`,`Calf pseudo-hypertrophy (DMD)`]},{name:`Motor — functional strength`,steps:[{label:`Rising from floor`,method:`Place flat on back; ask to stand up`,normal:`Rises without using hands to push off thighs (no Gowers)`},{label:`Climbing stairs`,method:`Observe or history`,normal:`Climbs holding rail`},{label:`Squatting/getting up`,method:`Encourage via play`,normal:`Squats and rises without help`}],abnormalHints:[`Gowers sign (proximal weakness — DMD)`,`Unable to climb stairs at age expected`,`Calf pain on walking (myositis)`]},{name:`Deep tendon reflexes`,steps:[{label:`Patellar`,method:`Sitting or supine with distraction (toy)`,normal:`2+ symmetric`},{label:`Biceps`,method:`Arm at rest, strike thumb on tendon`,normal:`2+ symmetric`},{label:`Achilles`,method:`With distraction`,normal:`2+ symmetric`}],abnormalHints:[`Hyperreflexia or clonus (UMN, CP)`,`Absent reflexes (LMN, neuropathy)`,`Asymmetry`]},{name:`Coordination and gait`,steps:[{label:`Run`,method:`Watch run ~10 feet`,normal:`Runs with reciprocal arm swing by 2y`},{label:`Stairs`,method:`Observe`,normal:`Climbs with rail`},{label:`Kick ball`,method:`Place ball; observe kick`,normal:`Kicks by 2y`},{label:`Ataxia check`,method:`Watch for fluency of movement`,normal:`Smooth, no tremor`}],abnormalHints:[`Ataxic gait`,`Intention tremor`,`Clumsiness beyond age`]},{name:`Plantar response`,steps:[{label:`Stroke lateral sole`,method:`Firm stroke from heel to toes`,normal:`Down-going great toe (plantar flexion) by age 2`}],abnormalHints:[`Up-going toe after age 2 = UMN sign (Babinski positive)`]}]},resp:{overview:`Toddler respiratory disease: viral URIs, reactive airways, croup (6 mo–6 y classical age), foreign-body aspiration (age 1–3 is peak). Normal RR ≤ 40.`,components:[{name:`Inspection`,pearl:`Sudden onset of unilateral wheeze + choking history in a toddler = foreign body until proven otherwise. CXR in expiration (or decubitus) helps show the trapped air.`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s if possible.`,normal:`≤ 40 /min`},{label:`Work of breathing`,method:`Retractions, nasal flaring, tracheal tug.`,normal:`No retractions`},{label:`Audible sounds`,method:`Stridor (croup), wheeze, barking cough.`,normal:`Quiet respirations`},{label:`Drooling / posture`,method:`Tripod positioning, drooling (epiglottitis in unvaccinated child).`,normal:`No drooling, normal posture`}],abnormalHints:[`Barking cough + stridor — croup`,`Drooling + tripod + toxic — epiglottitis (emergency)`,`Sudden unilateral wheeze — foreign body aspiration`]},{name:`Auscultation`,steps:[{label:`Air entry`,method:`Cooperation variable — listen quickly and systematically.`,normal:`Symmetric`},{label:`Adventitious sounds`,method:`Wheeze, crackles, stridor at the neck.`,normal:`Clear lung fields`},{label:`Unilateral findings`,method:`Focal wheeze, decreased air entry, or asymmetry — think foreign body or pneumonia.`,normal:`Symmetric bilateral`}],abnormalHints:[`Unilateral decreased breath sounds + wheeze — foreign body`,`Focal crackles — pneumonia`,`Diffuse wheeze — asthma/RAD`]}]},cv:{overview:`Most hemodynamically significant CHD has been detected by this age. Innocent murmurs peak here (Still's murmur, venous hum). The exam is adult-pattern but with smaller chest and less cooperation.`,components:[{name:`Inspection and palpation`,pearl:`Innocent murmurs are a normal finding in well toddlers — soft, systolic, at the LLSB, musical, and they change with position. Anything that doesn't fit that pattern deserves referral.`,steps:[{label:`General appearance + growth`,method:`Happy, active, tracking growth.`,normal:`Normal growth and activity`},{label:`Colour and clubbing`,method:`Inspect tongue, nail beds.`,normal:`Pink, no clubbing`},{label:`Apex beat`,method:`Palpate at 5th ICS mid-clavicular line.`,normal:`Located at 5th ICS MCL, tapping quality`},{label:`Peripheral pulses`,method:`Brachial + femoral, symmetric and simultaneous.`,normal:`Symmetric, no delay`}],abnormalHints:[`Tiring with play, poor growth — missed CHD`,`Cyanosis + clubbing — cyanotic CHD`,`Absent femorals — coarctation`]},{name:`Auscultation`,steps:[{label:`All 5 classic points`,method:`See APTM diagram above — Aortic, Pulmonic, Erb's, Tricuspid, Mitral.`,normal:`Crisp S1, S2 with physiologic split at pulmonic area`},{label:`Evaluate any murmur`,method:`Timing, location, radiation, grade. Apply the "7 S" innocent-murmur criteria.`,normal:`No murmur, or soft (≤ grade 2) innocent murmur`},{label:`Change with position`,method:`Have toddler sit, stand, lie down — does the murmur change? Innocent murmurs typically disappear or soften with standing.`,normal:`Murmur (if any) changes with position`}],abnormalHints:[`Harsh, loud (≥3/6), radiating, or diastolic murmur — not innocent, refer`,`Cyanosis + murmur — CHD workup`,`Fixed split S2 — ASD`]}]}},preschool:{label:`Preschool (3–5 years)`,msk:{overview:`Functional gait maneuvers, scoliosis screen, resolving physiologic alignment.`,components:[{name:`Gait — multiple patterns`,steps:[{label:`Normal gait`,method:`Walk ~15 feet barefoot`,normal:`Symmetric, smooth, reciprocal arm swing`},{label:`Heel walking`,method:`Walk on heels only`,normal:`Able by 4y`},{label:`Toe walking`,method:`Walk on toes only`,normal:`Able by 4y`},{label:`Tandem walking`,method:`Heel-to-toe along a line for 5 steps`,normal:`Able by 4y with minimal deviation`},{label:`Hopping`,method:`Hop on one foot`,normal:`3–5 hops on preferred foot by 4y`}],abnormalHints:[`Persistent toe-walking`,`Asymmetric stance/stride`,`Difficulty with any pattern`]},{name:`Alignment`,steps:[{label:`Knee alignment`,method:`Stand feet together`,normal:`Mild residual valgus resolving; neutral by 6–7y`},{label:`Foot arch`,method:`Standing, then tiptoe`,normal:`Arch forms on tiptoe (flexible flat foot)`},{label:`Heel position`,method:`View from behind standing`,normal:`Neutral or mild valgus`}],abnormalHints:[`Persistent unilateral varum`,`Rigid flat foot (no arch on tiptoe)`,`Pes cavus`]},{name:`Scoliosis screen (Adam forward-bend)`,steps:[{label:`Position`,method:`Feet together, bend forward at waist, arms hanging, palms together`,normal:`Arms and head relaxed`},{label:`View from behind`,method:`Examiner at same height; look along back`,normal:`Symmetric paraspinal contour`},{label:`View from side`,method:`Side view for kyphosis`,normal:`Smooth thoracic curve`}],abnormalHints:[`Rib hump (thoracic scoliosis)`,`Lumbar prominence`,`Asymmetric scapular height`]},{name:`Joint range and stability`,steps:[{label:`Active range`,method:`Ask to perform full range at hips, knees, ankles, shoulders, elbows, wrists`,normal:`Full symmetric range, no pain`},{label:`Knee stability`,method:`Palpate for effusion; assess stability if complaint`,normal:`Stable, no effusion`},{label:`Carrying angle (elbows)`,method:`Arms at sides, palms forward`,normal:`Normal valgus carrying angle`}],abnormalHints:[`Joint hypermobility (Beighton score)`,`Effusion`,`Pain with motion`,`Valgus >15°`]},{name:`Feet`,steps:[{label:`Standing inspection`,method:`View from front and behind`,normal:`Symmetric feet, neutral heel, flexible flat feet common`},{label:`Tiptoe`,method:`Stand on tiptoes`,normal:`Arch forms, symmetric`},{label:`Pes planus vs cavus`,method:`Note arch height`,normal:`Flexible flat foot or mild arch`}],abnormalHints:[`Rigid flat foot`,`Pes cavus (Charcot-Marie-Tooth)`,`Pain`]}]},neuro:{overview:`Formal pediatric neuro exam now feasible — most 4- and 5-year-olds cooperate with structured testing.`,components:[{name:`Mental status and language`,steps:[{label:`Orientation (age-appropriate)`,method:`Ask name, age, where you are`,normal:`Knows name and age by 3y; location by 4–5y`},{label:`Speech intelligibility`,method:`Listen to spontaneous speech`,normal:`Strangers understand by 4y`},{label:`Receptive language`,method:`2- and 3-step commands`,normal:`Follows 3-step commands by 4–5y`}],abnormalHints:[`Dysarthria`,`Expressive or receptive language delay`,`Inattention`]},{name:`Cranial nerves (II–XII)`,steps:[{label:`CN II — visual acuity`,method:`HOTV chart or pictures at 10ft, each eye`,normal:`20/30 or better by 4y; 20/25 by 5y`},{label:`CN II — visual fields`,method:`Confrontation with toys from periphery`,normal:`Full fields`},{label:`CN II — pupils`,method:`Light response each eye`,normal:`PERRL`},{label:`CN III, IV, VI — EOM`,method:`Follow toy in H pattern; include convergence`,normal:`Full EOM, convergence present`},{label:`CN V — sensation`,method:`Light touch forehead, cheek, jaw each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench teeth, palpate masseter`,normal:`Symmetric strong bulk`},{label:`CN VII — face`,method:`Smile, wrinkle forehead, close eyes, puff cheeks`,normal:`Symmetric movement of all regions`},{label:`CN VIII — hearing`,method:`Finger rub each ear or whispered words`,normal:`Intact bilaterally`},{label:`CN IX, X — palate`,method:`Open mouth, say "ahh"`,normal:`Palate rises symmetrically, uvula midline`},{label:`CN XI — SCM/trapezius`,method:`Shrug shoulders, turn head against resistance`,normal:`Symmetric strength`},{label:`CN XII — tongue`,method:`Stick tongue out, move side to side`,normal:`Midline, no atrophy, full movement`}],abnormalHints:[`Strabismus (amblyopia risk)`,`Facial weakness`,`Tongue deviation/fasciculations`,`Uvula off-midline`]},{name:`Motor — tone, bulk, strength`,steps:[{label:`Tone inspection`,method:`Passive range all four limbs`,normal:`Normal tone throughout`},{label:`Bulk inspection`,method:`Observe muscle bulk symmetry`,normal:`Symmetric, age-appropriate`},{label:`Strength — shoulder abduction`,method:`Arms out, push down against resistance`,normal:`5/5 bilaterally`},{label:`Strength — elbow flexion`,method:`Flex elbow against resistance`,normal:`5/5 bilaterally`},{label:`Strength — grip`,method:`Squeeze examiner's fingers`,normal:`5/5 symmetric`},{label:`Strength — hip flexion`,method:`Lift leg off table against resistance`,normal:`5/5 bilaterally`},{label:`Strength — knee extension`,method:`Straighten knee against resistance`,normal:`5/5 bilaterally`},{label:`Strength — dorsiflexion`,method:`Pull toes up against resistance`,normal:`5/5 bilaterally`}],abnormalHints:[`Focal weakness`,`Gowers sign`,`Pseudohypertrophy (DMD)`,`Atrophy`]},{name:`Deep tendon reflexes`,steps:[{label:`Biceps`,method:`Thumb on biceps tendon, strike`,normal:`2+ symmetric`},{label:`Patellar`,method:`Knees hanging, strike patellar tendon`,normal:`2+ symmetric`},{label:`Achilles`,method:`Slight dorsiflexion, strike Achilles tendon`,normal:`2+ symmetric`},{label:`Plantar response`,method:`Stroke lateral sole heel-to-toes`,normal:`Down-going great toe`}],abnormalHints:[`Hyperreflexia or clonus (UMN)`,`Hyporeflexia (LMN)`,`Up-going plantar (Babinski — abnormal past 2y)`,`Asymmetry`]},{name:`Coordination`,steps:[{label:`Finger-to-nose`,method:`Touch examiner's finger then own nose, repeat`,normal:`Smooth, no dysmetria`},{label:`Heel-to-shin`,method:`Run heel down opposite shin`,normal:`Smooth bilaterally`},{label:`Rapid alternating movements`,method:`Tap palm with opposite hand alternating palm/back`,normal:`Rhythmic, symmetric`},{label:`Tandem walk`,method:`Heel-to-toe for 5 steps`,normal:`Minimal deviation`}],abnormalHints:[`Dysmetria`,`Dysdiadochokinesia`,`Intention tremor`,`Ataxic tandem`]},{name:`Sensory`,steps:[{label:`Light touch — hands`,method:`Cotton wisp on palm/dorsum, eyes closed`,normal:`Feels each touch`},{label:`Light touch — feet`,method:`Same on dorsum of foot bilaterally`,normal:`Feels each touch`}],abnormalHints:[`Focal sensory loss`,`Stocking-glove loss`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk ~20 feet`,normal:`Smooth, symmetric`},{label:`Heel walk`,method:`Walk on heels`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe`,normal:`Intact`},{label:`Romberg (5y+)`,method:`Feet together, eyes closed, stand 10s`,normal:`Stable without sway`}],abnormalHints:[`Ataxic gait (cerebellar)`,`Romberg positive (dorsal column)`,`Circumduction (UMN)`]}]},resp:{overview:`Adult-pattern but shorter. Cooperation better than toddler. RR ≤ 30. Common: asthma/RAD, pneumonia, URIs.`,components:[{name:`Inspection`,steps:[{label:`Respiratory rate`,method:`Count over full 60 s quietly.`,normal:`≤ 30 /min`},{label:`Work of breathing`,method:`Retractions, nasal flaring, accessory muscle use.`,normal:`Effortless breathing`},{label:`Audible sounds`,method:`Wheeze, stridor, cough quality (barking = croup).`,normal:`Quiet`},{label:`Chest shape`,method:`AP:transverse, hyperinflation signs.`,normal:`Not barrel-chested`}],abnormalHints:[`Barrel chest — chronic asthma, cystic fibrosis`,`Retractions + wheeze — asthma exacerbation`]},{name:`Auscultation`,steps:[{label:`Systematic zones`,method:`Upper, mid, lower fields anteriorly and posteriorly; axillae bilaterally. Cooperative deep breaths through mouth.`,normal:`Symmetric vesicular sounds`},{label:`Wheeze`,method:`Expiratory, diffuse (asthma) or focal (foreign body, rare at this age).`,normal:`No wheeze`},{label:`Crackles`,method:`Focal = pneumonia; diffuse fine = interstitial disease (rare in kids).`,normal:`No crackles`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse wheeze — asthma`,`Prolonged expiration with wheeze — lower airway obstruction`]}]},cv:{overview:`Most CHD is detected by this age. Innocent murmurs peak in this range. Sports participation exams require thorough CV screening.`,components:[{name:`Inspection and palpation`,steps:[{label:`General and growth`,method:`Track on growth curve; activity tolerance.`,normal:`Normal growth, active`},{label:`Apex beat`,method:`5th ICS mid-clavicular line.`,normal:`Normal position and character`},{label:`Peripheral pulses`,method:`Brachial + femoral simultaneously. BP in arm and leg if HTN.`,normal:`Symmetric, no delay`}],abnormalHints:[`Absent femorals or arm-leg BP gradient — coarctation (always check in HTN screening)`,`Displaced apex — cardiomegaly`]},{name:`Auscultation`,pearl:`The 7 "S" criteria and the 5 classic innocent murmurs (see panel above) handle most murmurs you'll find in this age group. Still's murmur is the single most common.`,steps:[{label:`All 5 classic points`,method:`Walk through A → P → E → T → M with diaphragm then bell.`,normal:`S1 S2 clear, physiologic S2 split at pulmonic, no added sounds`},{label:`Any murmur`,method:`Characterise: timing, location, radiation, grade, character. Apply 7 S criteria + compare to innocent-murmur panel.`,normal:`No murmur, or innocent flow murmur meeting all 7 S criteria`},{label:`Position change`,method:`Standing vs supine. Innocent murmurs typically soften or disappear on standing.`,normal:`Murmur (if any) changes with position`},{label:`Sports screening extras (if applicable)`,method:`Screen for HOCM — murmur intensifies with Valsalva and standing (opposite of most).`,normal:`No murmur worsening on Valsalva`}],abnormalHints:[`Murmur breaking any of the 7 S criteria — refer`,`Harsh systolic at LUSB + fixed split S2 — ASD`,`Murmur louder with Valsalva — HOCM (sports participation risk)`,`Diastolic murmur — always pathologic`]}]}},school:{label:`School-age (6–11 years)`,msk:{overview:`Scoliosis screening peri-puberty, sports overuse injuries, resolving alignment.`,components:[{name:`Scoliosis screen (forward-bend + scoliometer)`,steps:[{label:`Standing inspection`,method:`Shoulders and iliac crest heights`,normal:`Symmetric shoulder and pelvic heights`},{label:`Forward bend (Adam test)`,method:`Feet together, bend forward at waist, arms hanging palms together`,normal:`Symmetric paraspinal contour`},{label:`Rib hump`,method:`View tangentially from behind at level of curve`,normal:`No rib hump`},{label:`Lumbar prominence`,method:`Same view at lumbar level`,normal:`No prominence`},{label:`Scoliometer (if available)`,method:`Place scoliometer across rib hump, read angle of trunk rotation`,normal:`ATR < 5°; ≥7° → refer`}],abnormalHints:[`Rib hump`,`ATR ≥7°`,`Asymmetric shoulders or pelvis`,`Decompensation (plumb line offset)`]},{name:`Back and spine`,steps:[{label:`Posture inspection`,method:`Standing, view front/back/side`,normal:`Normal spinal curves; plumb line centered`},{label:`Palpate spinous processes`,method:`From C2 to S1`,normal:`No tenderness, no step-off`},{label:`Range of motion`,method:`Flex, extend, lateral bend, rotate`,normal:`Full painless range`}],abnormalHints:[`Midline tenderness`,`Step-off (spondylolisthesis)`,`Limited motion with pain`]},{name:`Alignment`,steps:[{label:`Knees`,method:`Feet together, inspect`,normal:`Neutral alignment by 6–7y`},{label:`Feet`,method:`Stand, then tiptoes`,normal:`Medial arch present, symmetric`},{label:`Leg lengths`,method:`Supine, measure ASIS to medial malleolus if asymmetric`,normal:`Equal within 1cm`}],abnormalHints:[`Residual valgum`,`Pes cavus`,`Leg-length discrepancy >1cm`]},{name:`Joint stability and sports exam (if active)`,steps:[{label:`Active range all joints`,method:`Through full range`,normal:`Full symmetric range, no pain or crepitus`},{label:`Knee — Lachman (if sports-active)`,method:`Knee 20° flexion, stabilize femur, pull tibia forward`,normal:`Firm endpoint, no laxity`},{label:`Knee — McMurray`,method:`Flexed knee, rotate tibia while extending`,normal:`No pain or click`},{label:`Shoulder — impingement (Neer/Hawkins)`,method:`Passive shoulder flexion with arm in internal rotation`,normal:`No pain`},{label:`Ankle stability`,method:`Anterior drawer and talar tilt`,normal:`No laxity`}],abnormalHints:[`ACL laxity (positive Lachman)`,`Meniscal click`,`Shoulder impingement`,`Ankle instability`]},{name:`Gait and functional movement`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Smooth, symmetric`},{label:`Single-leg stance`,method:`Stand on one foot 10s each side`,normal:`Stable without Trendelenburg drop`},{label:`Squat`,method:`Full squat and rise`,normal:`Full squat without pain or asymmetry`},{label:`Hop on one foot`,method:`5 hops each side`,normal:`Able and symmetric`}],abnormalHints:[`Trendelenburg sign (hip abductor weakness)`,`Antalgic gait`,`Asymmetric squat`,`Pain with hop`]}]},neuro:{overview:`Adult-pattern six-component exam: mental status, CN, motor, reflexes, sensory, coordination/gait.`,components:[{name:`Mental status`,steps:[{label:`Orientation`,method:`Name, age, school, city, day of week`,normal:`Oriented x 4`},{label:`Attention`,method:`Count backward from 20; days of week backward`,normal:`Intact`},{label:`3-item recall`,method:`Ball-flag-tree; ask at 3 and 5 min`,normal:`3/3 recall at 5 min`},{label:`Language`,method:`Name common objects; repeat a sentence`,normal:`Fluent, no paraphasia`}],abnormalHints:[`Inattention (ADHD features)`,`Memory deficits`,`Word-finding difficulty`,`Perseveration`]},{name:`Cranial nerves (II–XII)`,steps:[{label:`CN II — acuity`,method:`Snellen at 20ft each eye with corrective lenses if worn`,normal:`20/20 or baseline`},{label:`CN II — fields`,method:`Confrontation, 4 quadrants each eye`,normal:`Full fields`},{label:`CN II — fundoscopy (if indicated)`,method:`Direct ophthalmoscopy — disc, vessels, macula`,normal:`Sharp disc, normal cup-disc ratio, no papilledema`},{label:`CN II, III — pupils`,method:`Direct and consensual light, accommodation`,normal:`PERRLA`},{label:`CN III, IV, VI — EOM`,method:`Follow finger in H pattern; convergence`,normal:`Full EOM, no nystagmus, convergence intact`},{label:`CN V — sensation`,method:`Light touch V1 (forehead), V2 (cheek), V3 (jaw) each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench teeth, palpate masseter/temporalis; jaw opening`,normal:`Symmetric strength`},{label:`CN VII`,method:`Raise eyebrows, close eyes tight, smile/show teeth, puff cheeks`,normal:`Symmetric movement, all regions`},{label:`CN VIII`,method:`Finger rub each ear; Weber/Rinne if deficit`,normal:`Hears bilaterally`},{label:`CN IX, X`,method:`Palate elevation with "ahh"; uvula midline; voice quality`,normal:`Symmetric elevation, uvula midline, normal voice`},{label:`CN XI`,method:`Shrug shoulders against resistance; head turn against resistance`,normal:`5/5 SCM and trapezius`},{label:`CN XII`,method:`Stick tongue out; side-to-side`,normal:`Midline, no atrophy or fasciculations`}],abnormalHints:[`Papilledema (increased ICP)`,`Focal cranial nerve deficit — any warrants workup`,`Tongue fasciculations (LMN/MND)`]},{name:`Motor — bulk, tone, strength`,steps:[{label:`Bulk inspection`,method:`Shoulders, thighs, calves, intrinsic hand muscles`,normal:`Symmetric, no atrophy`},{label:`Tone`,method:`Passive range at elbows, wrists, knees, ankles`,normal:`Normal resistance throughout`},{label:`Strength — deltoids`,method:`Shoulder abduction against resistance`,normal:`5/5 bilaterally`},{label:`Strength — biceps`,method:`Elbow flexion against resistance`,normal:`5/5`},{label:`Strength — triceps`,method:`Elbow extension against resistance`,normal:`5/5`},{label:`Strength — grip`,method:`Squeeze 2 fingers`,normal:`5/5 symmetric`},{label:`Strength — finger abduction`,method:`Spread fingers against resistance`,normal:`5/5`},{label:`Strength — hip flexion`,method:`Lift leg supine against resistance`,normal:`5/5`},{label:`Strength — knee extension`,method:`Straighten knee against resistance`,normal:`5/5`},{label:`Strength — dorsiflexion`,method:`Pull toes up against resistance`,normal:`5/5`},{label:`Strength — plantarflexion`,method:`Push foot down against resistance`,normal:`5/5`}],abnormalHints:[`Focal weakness (localize)`,`Spasticity (UMN)`,`Atrophy`,`Fasciculations`]},{name:`Deep tendon reflexes`,steps:[{label:`Biceps (C5-C6)`,method:`Thumb on tendon, strike`,normal:`2+ symmetric`},{label:`Triceps (C7-C8)`,method:`Strike triceps tendon`,normal:`2+ symmetric`},{label:`Brachioradialis (C5-C6)`,method:`Strike distal radius`,normal:`2+ symmetric`},{label:`Patellar (L3-L4)`,method:`Knees hanging, strike tendon`,normal:`2+ symmetric`},{label:`Achilles (S1)`,method:`Slight dorsiflexion, strike tendon`,normal:`2+ symmetric`},{label:`Plantar response`,method:`Stroke lateral sole heel-to-toes`,normal:`Down-going bilaterally`},{label:`Clonus`,method:`Rapid dorsiflexion at ankle`,normal:`No sustained clonus`}],abnormalHints:[`Hyperreflexia with clonus (UMN: stroke, MS, cord lesion)`,`Hyporeflexia (LMN, neuropathy, myopathy)`,`Asymmetry`,`Up-going Babinski`,`Sustained clonus`]},{name:`Sensory`,steps:[{label:`Light touch — upper`,method:`Cotton wisp dorsum of hands, eyes closed`,normal:`Intact, symmetric`},{label:`Light touch — lower`,method:`Same on dorsum of feet`,normal:`Intact, symmetric`},{label:`Pain — upper`,method:`Broken Q-tip or pin on hands`,normal:`Intact, symmetric`},{label:`Pain — lower`,method:`Same on feet`,normal:`Intact, symmetric`},{label:`Vibration`,method:`128 Hz tuning fork at distal IP joint of great toes`,normal:`Feels vibration; counts down seconds`},{label:`Proprioception`,method:`Move great toe up/down with eyes closed`,normal:`Identifies direction correctly`}],abnormalHints:[`Dermatomal loss (nerve root)`,`Stocking-glove (neuropathy)`,`Loss of vibration/proprioception (dorsal column — B12, tabes, MS)`]},{name:`Coordination`,steps:[{label:`Finger-nose-finger`,method:`Touch examiner finger then own nose, examiner moves target`,normal:`Smooth, accurate, no dysmetria`},{label:`Heel-to-shin`,method:`Supine: heel down opposite shin`,normal:`Smooth, on-target`},{label:`Rapid alternating movements`,method:`Supinate/pronate hand on knee rapidly`,normal:`Rhythmic, symmetric`},{label:`Fine motor`,method:`Finger tapping (thumb to each finger in sequence)`,normal:`Rhythmic, accurate`}],abnormalHints:[`Dysmetria (past-pointing, overshoot)`,`Intention tremor`,`Dysdiadochokinesia`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Narrow-based, smooth, reciprocal arm swing`},{label:`Heel walk`,method:`Walk on heels`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe along a line`,normal:`Minimal deviation, 10+ steps`},{label:`Romberg`,method:`Feet together, eyes closed, 30s`,normal:`Stable without fall or significant sway`}],abnormalHints:[`Wide-based (cerebellar)`,`Steppage (peripheral neuropathy)`,`Scissoring (UMN)`,`Romberg positive (dorsal column)`,`Circumduction`]}]},resp:{overview:`Nearly adult-pattern. Exam the same as adolescent with slightly more flexibility in cooperation. RR ≤ 30 in younger school-age, ≤ 20 in older. Sports history relevant (exercise-induced asthma).`,components:[{name:`Inspection`,steps:[{label:`Respiratory rate`,method:`Count over 60 s.`,normal:`≤ 30 (6–11 y)`},{label:`Work of breathing`,method:`Retractions, accessory muscles.`,normal:`Effortless`},{label:`Audible sounds`,method:`Listen for wheeze, stridor.`,normal:`Quiet`},{label:`Chest shape`,method:`Barrel chest, pectus deformities.`,normal:`Normal shape`},{label:`Clubbing`,method:`Schamroth window test.`,normal:`No clubbing`}],abnormalHints:[`Clubbing — CF, chronic hypoxemia, bronchiectasis`,`Barrel chest — chronic asthma, CF`]},{name:`Palpation and percussion`,steps:[{label:`Tracheal position`,method:`Middle finger in suprasternal notch.`,normal:`Midline`},{label:`Chest expansion`,method:`Hands laterally, thumbs meeting at spine. Deep breath.`,normal:`Symmetric 3–5 cm`},{label:`Tactile fremitus`,method:`Ulnar side of hand; "ninety-nine". Compare sides.`,normal:`Symmetric`},{label:`Percussion`,method:`Pleximeter + plexor technique. Compare sides.`,normal:`Resonant throughout`}],abnormalHints:[`Deviated trachea — pneumothorax, effusion, collapse`,`Dull percussion — consolidation, effusion`,`Hyper-resonant — pneumothorax, hyperinflation`]},{name:`Auscultation`,steps:[{label:`Systematic zones`,method:`Six anterior + four lateral + six posterior zones, compare side-to-side.`,normal:`Symmetric vesicular sounds`},{label:`Adventitious sounds`,method:`Wheeze, crackles, rhonchi, rub, stridor at neck. Use sounds library for reference.`,normal:`No added sounds`},{label:`Cough re-listen`,method:`Secretions (rhonchi, coarse crackles) should clear; fibrosis crackles do not.`,normal:`Secretion-based sounds clear with cough`}],abnormalHints:[`Focal crackles + fever — pneumonia`,`Diffuse fine crackles — early interstitial disease`,`Expiratory wheeze — asthma / RAD`]}]},cv:{overview:`Nearly adult-pattern. Sports participation screening is a key indication in this age. HOCM screening (family history of sudden cardiac death, exertional syncope, murmur louder with Valsalva) is specifically relevant.`,components:[{name:`Inspection and palpation`,pearl:`For sports participation exams, always ask about exertional symptoms (syncope, chest pain, unexpected fatigue) AND family history of sudden cardiac death before age 50. Screening exam alone catches only ~3% of HOCM.`,steps:[{label:`General and growth`,method:`Track on growth curve; review activity tolerance.`,normal:`Normal growth, age-appropriate activity`},{label:`Colour and clubbing`,method:`Inspect mucous membranes and nail beds.`,normal:`Pink, no clubbing`},{label:`Apex beat`,method:`Palpate at 5th ICS mid-clavicular line.`,normal:`Normal position, tapping character`},{label:`Peripheral pulses`,method:`Simultaneous brachial + femoral.`,normal:`Symmetric, no delay`},{label:`Blood pressure`,method:`Measure BP with appropriately sized cuff. If elevated, check both arms and one leg.`,normal:`Age-appropriate (< 120/80 roughly by 10+ years)`}],abnormalHints:[`Exertional syncope — HOCM, arrhythmia, LQTS`,`BP differential — coarctation`,`Displaced apex — cardiomegaly`]},{name:`Auscultation`,steps:[{label:`All 5 classic points`,method:`See APTM diagram. A → P → E → T → M with diaphragm and bell.`,normal:`S1, S2 clear with physiologic split at P, no added sounds`},{label:`Grade any murmur`,method:`Levine 1–6 (see scales above); characterise timing, location, radiation.`,normal:`No murmur, or innocent flow murmur meeting all 7 S criteria`},{label:`Innocent vs pathologic`,method:`Apply 7 S criteria; compare to innocent-murmur panel.`,normal:`Innocent murmur (if present) clearly fits all 7 S features`},{label:`Dynamic maneuvers`,method:`Standing: HOCM louder; most others soften. Valsalva: HOCM louder.`,normal:`Murmur (if any) softens on standing and Valsalva`}],abnormalHints:[`Murmur louder with Valsalva / standing — HOCM (sports disqualification considerations)`,`Any diastolic murmur`,`Murmur ≥ grade 3, radiating, or with thrill`]}]}},adolescent:{label:`Adolescent (12–21 years)`,msk:{overview:`Sports-related injuries, adolescent scoliosis, apophyseal overuse, hypermobility screening.`,components:[{name:`Scoliosis screen`,steps:[{label:`Standing inspection`,method:`Patient undressed to waist (keep privacy); compare shoulders, iliac crests, scapular heights`,normal:`Symmetric shoulders and pelvis`},{label:`Forward bend (Adam)`,method:`Feet together, bend forward, arms hanging palms together`,normal:`Symmetric paraspinal contour`},{label:`Scoliometer`,method:`Place across thoracic and lumbar regions at maximum prominence`,normal:`ATR <5°; 5–6° monitor; ≥7° refer`},{label:`Plumb line check`,method:`Drop plumb from C7; note where it falls`,normal:`Passes through gluteal cleft (compensated)`},{label:`Leg lengths`,method:`Supine; ASIS to medial malleolus each side`,normal:`Within 1cm`}],abnormalHints:[`Rib/lumbar hump`,`ATR ≥7°`,`Decompensation (plumb off gluteal cleft)`,`Leg-length discrepancy driving apparent curve`]},{name:`Back pain evaluation (if complaint)`,steps:[{label:`Inspect and palpate`,method:`Spinous processes, paraspinal muscles, SI joints`,normal:`Non-tender`},{label:`Range of motion`,method:`Flex, extend, lateral bend, rotate`,normal:`Full painless range`},{label:`Single-leg hyperextension (stork)`,method:`Stand on one foot, extend back — each side`,normal:`No pain (negative for spondylolysis)`},{label:`Straight-leg raise`,method:`Supine, lift straight leg to 70°+`,normal:`No radicular pain to 70°`},{label:`SI joint tests`,method:`FABER, SI compression`,normal:`No pain`}],abnormalHints:[`Spondylolysis (positive stork test)`,`Radicular pain (disc herniation)`,`SI joint pathology`,`Inflammatory back pain pattern`]},{name:`Joint stability — sports-specific`,steps:[{label:`Knee — Lachman`,method:`Knee 20° flexion, stabilize femur, pull tibia anteriorly`,normal:`Firm endpoint, no laxity (ACL intact)`},{label:`Knee — anterior drawer`,method:`Knee 90°, pull tibia forward`,normal:`No excess anterior translation`},{label:`Knee — varus/valgus stress`,method:`Stress at 0 and 30° flexion`,normal:`No gap opening (LCL/MCL intact)`},{label:`Knee — McMurray`,method:`Flex, rotate tibia while extending`,normal:`No pain or click`},{label:`Shoulder — apprehension`,method:`Abduct and externally rotate`,normal:`No apprehension`},{label:`Shoulder — Neer/Hawkins`,method:`Passive flexion with internal rotation`,normal:`No pain`},{label:`Ankle — anterior drawer`,method:`Pull heel forward with tibia stabilized`,normal:`No laxity`},{label:`Ankle — talar tilt`,method:`Invert heel with tibia stabilized`,normal:`No excess tilt`}],abnormalHints:[`ACL/PCL tear`,`MCL/LCL laxity`,`Meniscal injury`,`Shoulder instability/impingement`,`Ankle ligament laxity`]},{name:`Apophysitis and overuse screen`,steps:[{label:`Tibial tubercle`,method:`Palpate with knee flexed`,normal:`Non-tender`},{label:`Calcaneal apophysis`,method:`Palpate posterior calcaneus`,normal:`Non-tender`},{label:`Iliac apophyses`,method:`Palpate ASIS, AIIS, iliac crest`,normal:`Non-tender`},{label:`Rotator cuff`,method:`Empty-can (Jobe) test`,normal:`No pain or weakness`}],abnormalHints:[`Osgood-Schlatter (tibial tubercle tender)`,`Sever (calcaneal tender)`,`Iliac apophysitis`,`Rotator cuff tendinopathy`]},{name:`Hypermobility screen (Beighton)`,steps:[{label:`Fifth finger extension`,method:`Passive extension of fifth MCP to >90°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Thumb to forearm`,method:`Passive flexion of thumb to touch forearm`,normal:`Does not reach (1 pt each side if positive)`},{label:`Elbow hyperextension`,method:`Hyperextension >10°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Knee hyperextension`,method:`Hyperextension >10°`,normal:`No hyperextension (1 pt each side if positive)`},{label:`Palms to floor`,method:`Feet together, bend forward, palms flat on floor with knees straight`,normal:`Cannot reach (1 pt if positive)`}],abnormalHints:[`Beighton ≥5/9 suggests hypermobility spectrum (hEDS workup if with other features)`]},{name:`Alignment and gait`,steps:[{label:`Standing alignment`,method:`View knees, feet`,normal:`Neutral alignment, medial arch`},{label:`Normal gait`,method:`Walk 20 feet`,normal:`Symmetric, smooth`},{label:`Functional movements`,method:`Squat, single-leg stance, hop`,normal:`Full symmetric function`}],abnormalHints:[`Antalgic gait`,`Trendelenburg`,`Asymmetric squat`]}]},neuro:{overview:`Full adult-pattern neuro exam across six pillars: mental status, cranial nerves, motor, reflexes, sensory, coordination/gait. In adolescents, screen concussion sequelae if sports-active; frontal release signs must be absent.`,components:[{name:`Mental status`,significance:`Detects cognitive change (concussion, substance use, mood disorder, rare neurodegenerative disease).`,pearl:`Attention precedes memory. A patient who can't attend (serial 7s, months backward) will fail memory even with intact hippocampus — distinguish before calling it a memory problem.`,steps:[{label:`Orientation`,method:`Name, age, date, location, situation`,normal:`Oriented x 4`},{label:`Attention`,method:`Count backward from 100 by 7s (serial 7s) or months of year backward`,normal:`Intact`},{label:`Short-term memory`,method:`3-item registration and recall at 5 min`,normal:`3/3 recall`},{label:`Language`,method:`Object naming; sentence repetition; reading; writing`,normal:`Fluent, no paraphasia, comprehends written and spoken`},{label:`Executive function`,method:`Similarities (apple/orange); interpret proverb`,normal:`Abstract, age-appropriate`}],abnormalHints:[`Post-concussion cognitive changes`,`Mood or personality changes`,`Subtle executive dysfunction`,`Word-finding difficulty`]},{name:`Cranial nerves (II–XII, full formal exam)`,significance:`Localises brainstem, base-of-skull, and specific nerve pathology. Subtle deficits (RAPD, mild facial weakness, Horner) are easily missed — exam discipline matters.`,pearl:`The fastest screen for a CN deficit is asking the patient to speak, smile, look around, and swallow water. What's preserved in everyday function tells you what's likely intact — then examine formally to confirm and to catch the subtle.`,steps:[{label:`CN I (if indicated)`,method:`Coffee or cinnamon each nostril separately`,normal:`Identifies both`},{label:`CN II — acuity`,method:`Snellen at 20ft each eye; corrective lenses if worn`,normal:`20/20 or baseline`},{label:`CN II — fields`,method:`Confrontation, 4 quadrants each eye`,normal:`Full fields`},{label:`CN II — fundoscopy`,method:`Direct ophthalmoscopy — disc, vessels, macula`,normal:`Sharp disc, normal cup/disc, no papilledema`},{label:`CN II, III — pupils`,method:`Direct, consensual, swinging flashlight, accommodation`,normal:`PERRLA, no RAPD`},{label:`CN III, IV, VI — EOM`,method:`H pattern, convergence, note nystagmus or ptosis`,normal:`Full conjugate movement, no nystagmus, convergence intact`},{label:`CN V — sensation`,method:`Light touch V1, V2, V3 each side`,normal:`Intact, symmetric`},{label:`CN V — motor`,method:`Clench jaw, palpate masseter/temporalis; lateral jaw movement`,normal:`Symmetric strength and bulk`},{label:`CN V — corneal reflex (if indicated)`,method:`Cotton wisp to cornea`,normal:`Blinks bilaterally`},{label:`CN VII`,method:`Wrinkle forehead, close eyes against resistance, smile/bare teeth, puff cheeks`,normal:`Symmetric all four movements`},{label:`CN VIII — hearing`,method:`Finger rub each ear; Weber (midline) + Rinne (air > bone) if deficit`,normal:`Equal bilaterally`},{label:`CN IX, X`,method:`Palate elevation with "ahh"; uvula midline; voice; gag (if indicated)`,normal:`Symmetric palate, uvula midline, normal voice`},{label:`CN XI`,method:`Shoulder shrug and head turn against resistance`,normal:`5/5 SCM and trapezius bilaterally`},{label:`CN XII`,method:`Tongue protrusion, side to side; inspect for fasciculations/atrophy`,normal:`Midline, no atrophy or fasciculations, full movement`}],abnormalHints:[`Any focal cranial nerve deficit`,`Papilledema`,`RAPD`,`Nystagmus`,`Facial asymmetry`,`Tongue deviation`]},{name:`Motor — bulk, tone, strength`,significance:`Localises lesion to UMN vs LMN vs muscle vs junction. Pattern of weakness (proximal vs distal, symmetric vs focal) narrows differential.`,pearl:`Pronator drift is the most sensitive screen for subtle UMN weakness — a normal-feeling arm that drifts down with eyes closed still has corticospinal tract dysfunction. Always do it even when formal strength is 5/5.`,steps:[{label:`Bulk inspection`,method:`Inspect shoulders, biceps, thighs, calves, dorsal interossei (between metacarpals) of hands.`,normal:`Symmetric bulk; no atrophy, no pseudohypertrophy`},{label:`Tone — upper`,method:`Passive flex-extend elbow and pronate-supinate wrist at slow then quick speeds. Then pronator drift: arms outstretched, palms up, eyes closed for 10 s.`,normal:`Smooth passive range; no drift, no pronation of the outstretched hand`},{label:`Tone — lower`,method:`Passive knee flexion-extension; quick ankle dorsiflexion to check for catch. Heel-slap test: roll thigh and watch for ankle swing.`,normal:`Normal resistance, no catch, symmetric`},{label:`Strength — deltoid (C5)`,method:`Patient abducts both arms to 90°. Examiner pushes down on each arm just above the elbow while patient resists. Compare sides.`,normal:`Holds against full resistance — MRC 5/5 bilaterally`},{label:`Strength — biceps (C5–C6)`,method:`Elbow flexed 90°, supinated. Examiner grasps wrist and pulls to extend while patient resists.`,normal:`Holds against full resistance — 5/5`},{label:`Strength — triceps (C7)`,method:`Elbow flexed 90°. Examiner pushes wrist toward shoulder while patient extends against resistance.`,normal:`Extends against full resistance — 5/5`},{label:`Strength — wrist extension (C6–C7)`,method:`Patient makes fist, extends wrist. Examiner pushes down on knuckles while patient holds wrist up.`,normal:`Holds against full resistance — 5/5`},{label:`Strength — finger flexion / grip (C8)`,method:`Patient grips two of examiner's crossed fingers as hard as possible. Compare sides.`,normal:`Strong symmetric grip — 5/5`},{label:`Strength — finger abduction (T1)`,method:`Patient spreads fingers wide. Examiner squeezes index and little fingers together while patient resists.`,normal:`Holds fingers apart — 5/5`},{label:`Strength — hip flexion (L2–L3)`,method:`Supine. Patient lifts straight leg 30° off table. Examiner pushes down on thigh just above knee while patient resists.`,normal:`Holds thigh up against full resistance — 5/5`},{label:`Strength — knee extension (L3–L4)`,method:`Sitting, knee 90°. Patient straightens knee while examiner pushes distal shin down.`,normal:`Extends against full resistance — 5/5`},{label:`Strength — ankle dorsiflexion (L4–L5)`,method:`Patient pulls toes and foot up toward shin. Examiner pushes foot down at the dorsum.`,normal:`Holds dorsiflexion against full resistance — 5/5; preserved heel-walk`},{label:`Strength — great toe extension (L5)`,method:`Patient extends great toe up while examiner pushes it down with thumb.`,normal:`Holds against full resistance — 5/5 (classic L5 test)`},{label:`Strength — ankle plantarflexion (S1)`,method:`Patient pushes foot down against examiner's hand at the ball. OR ask patient to toe-walk 10 steps (more sensitive — unilateral plantarflexion weakness shows immediately).`,normal:`Full power; toe-walks symmetrically — 5/5`}],abnormalHints:[`Focal weakness → localise by myotome`,`Pronator drift (subtle UMN, always check even with 5/5)`,`Spasticity / catch (UMN)`,`Atrophy (LMN, disuse)`,`Fasciculations (MND, ALS)`,`Pseudohypertrophy of calves (DMD in a young male)`]},{name:`Deep tendon reflexes`,significance:`Reflex pattern (increased, decreased, asymmetric) localises UMN vs LMN vs root vs peripheral nerve. Inexpensive and fast, but asymmetry is the most informative finding.`,pearl:`A reinforced reflex is still a reflex. If you can't elicit it initially, use Jendrassik (teeth clench or pull interlocked fingers apart) to boost — absent reflexes without reinforcement aren't truly absent.`,steps:[{label:`Biceps (C5–C6)`,method:`Patient's arm relaxed across lap. Examiner places thumb firmly on biceps tendon at the cubital fossa, strikes thumb with reflex hammer. Compare both sides sequentially.`,normal:`2+ symmetric — visible contraction of biceps, slight elbow flexion`},{label:`Brachioradialis (C5–C6)`,method:`Arm relaxed. Strike the distal radius about 3 cm proximal to the wrist, on its radial (thumb) side.`,normal:`2+ symmetric — elbow flexion and slight forearm supination`},{label:`Triceps (C7)`,method:`Support the patient's arm at the wrist with elbow at 90°. Strike the triceps tendon just above the olecranon.`,normal:`2+ symmetric — triceps contraction, slight elbow extension`},{label:`Finger flexors — Hoffmann sign`,method:`Grasp the middle finger's distal phalanx, flick it downward quickly and release. Watch the thumb and index finger.`,normal:`Negative — no thumb flexion, no index flexion (positive = corticospinal tract dysfunction)`},{label:`Patellar (L3–L4)`,method:`Patient sits with knees hanging freely off the table. Strike the patellar tendon just below the patella.`,normal:`2+ symmetric — quadriceps contraction with knee extension`},{label:`Achilles (S1)`,method:`Patient's knee slightly flexed and leg externally rotated, or kneeling on a chair. Slightly dorsiflex the foot and strike the Achilles tendon.`,normal:`2+ symmetric — plantar flexion of the foot`},{label:`Plantar response (Babinski)`,method:`Stroke the lateral aspect of the sole firmly from the heel toward the little toe, then curve across the ball of the foot.`,normal:`Toes flex downward (plantar flexion, "down-going") bilaterally in anyone ≥ 2 years`},{label:`Ankle clonus`,method:`Knee slightly bent. Support the shin with one hand, quickly and sharply dorsiflex the foot with the other, hold in dorsiflexion.`,normal:`≤ 3 non-sustained beats is acceptable; sustained rhythmic oscillation = pathological clonus (UMN)`}],abnormalHints:[`Hyperreflexia + sustained clonus = UMN (MS, myelopathy, cord lesion, stroke)`,`Symmetric hyporeflexia = peripheral polyneuropathy, GBS, myopathy, hypothyroid, B12 deficiency`,`Asymmetric hyporeflexia = radiculopathy at that segment`,`Hoffmann positive = corticospinal tract dysfunction at cervical cord or above`,`Up-going Babinski after age 2 = UMN (always abnormal)`]},{name:`Sensory`,steps:[{label:`Light touch — upper`,method:`Cotton wisp, dorsum of hands, eyes closed`,normal:`Intact, symmetric`},{label:`Light touch — lower`,method:`Dorsum of feet`,normal:`Intact, symmetric`},{label:`Pain — upper`,method:`Broken Q-tip sharp end, hands`,normal:`Intact, symmetric`},{label:`Pain — lower`,method:`Same on feet`,normal:`Intact, symmetric`},{label:`Temperature (if indicated)`,method:`Cold tuning fork each area`,normal:`Intact`},{label:`Vibration`,method:`128 Hz tuning fork at distal IP of great toes; count seconds to fade`,normal:`Feels vibration; appropriate duration`},{label:`Proprioception`,method:`Move great toe up/down with eyes closed`,normal:`Identifies direction correctly`},{label:`Two-point discrimination (if indicated)`,method:`Blunt calipers on fingertip`,normal:`<5mm on fingertip`},{label:`Stereognosis (if indicated)`,method:`Identify coin/key in hand with eyes closed`,normal:`Correct identification`}],abnormalHints:[`Dermatomal loss (nerve root)`,`Stocking-glove loss (length-dependent neuropathy)`,`Dorsal column loss (B12, tabes, MS — positive Romberg, vibration loss)`,`Cortical deficit (astereognosis, impaired 2-pt)`]},{name:`Coordination`,steps:[{label:`Finger-nose-finger`,method:`Alternate examiner's finger and own nose; examiner moves target`,normal:`Smooth, accurate bilaterally`},{label:`Heel-to-shin`,method:`Supine: heel down opposite shin and back`,normal:`Smooth, accurate`},{label:`Rapid alternating (Dysdiadochokinesis)`,method:`Supinate/pronate hand rapidly on thigh`,normal:`Rhythmic, symmetric`},{label:`Finger tapping`,method:`Thumb to each finger in sequence rapidly`,normal:`Rhythmic, smooth, symmetric`}],abnormalHints:[`Dysmetria (cerebellar)`,`Intention tremor`,`Dysdiadochokinesia`,`Decomposed movement`]},{name:`Gait and Romberg`,steps:[{label:`Normal gait`,method:`Walk 20 feet`,normal:`Narrow-based, smooth, reciprocal arm swing`},{label:`Heel walk`,method:`Walk on heels only`,normal:`Able without difficulty`},{label:`Toe walk`,method:`Walk on toes only`,normal:`Able without difficulty`},{label:`Tandem`,method:`Heel-to-toe along a line, 10+ steps`,normal:`Minimal deviation`},{label:`Romberg`,method:`Feet together, eyes open then closed, 30s`,normal:`Stable — no significant sway or fall with eyes closed`},{label:`Single-leg stance`,method:`10s each side, eyes open`,normal:`Stable without drift`}],abnormalHints:[`Ataxic (wide-based — cerebellar)`,`Steppage (peripheral neuropathy / foot drop)`,`Circumduction (UMN hemiparesis)`,`Scissoring`,`Romberg positive (dorsal column)`]},{name:`Frontal release / primitive reflexes`,steps:[{label:`Grasp reflex`,method:`Stroke palm`,normal:`Absent`},{label:`Snout reflex`,method:`Tap upper lip`,normal:`No lip pucker`},{label:`Glabellar tap`,method:`Tap between eyebrows — should habituate after 3–4 taps`,normal:`Habituates (no sustained blink)`},{label:`Palmomental`,method:`Stroke thenar eminence`,normal:`No ipsilateral chin twitch`}],abnormalHints:[`Presence suggests frontal lobe pathology, neurodegenerative disease, or severe TBI — rare in adolescence but relevant in post-concussion workup`]}]},resp:{overview:`Systematic respiratory exam: inspection → palpation → percussion → auscultation → special maneuvers. Always start from observation — rate, pattern, work of breathing, and audible sounds (stridor, grunting) can be diagnostic before the stethoscope touches the chest.`,components:[{name:`Inspection — observation before touching`,significance:`Detects respiratory distress and localises the level of airway compromise before any equipment is used. High yield: RR, WOB, audible sounds, chest shape, colour.`,pearl:`Audible stridor at rest from across the room = upper-airway obstruction, often urgent. Grunting in an infant = significant distress — never dismiss as fussiness.`,steps:[{label:`Respiratory rate`,method:`Count over a full 60 seconds (not 15×4) — children normally breathe irregularly. Count while the patient is calm, before any interaction.`,normal:`Within age-appropriate range (see scales card above)`},{label:`Respiratory pattern`,method:`Observe depth, regularity, and inspiration:expiration ratio. Watch for prolonged expiration, paradoxical chest-abdominal movement, or apneas.`,normal:`Regular, I:E ratio ~1:2, no pauses > 10 s in an infant`},{label:`Work of breathing`,method:`Inspect for nasal flaring, suprasternal/intercostal/subcostal retractions, accessory muscle use (SCM, abdominals), tripod positioning, head-bobbing in infants.`,normal:`No retractions; breathing effortless`},{label:`Audible sounds (no stethoscope)`,method:`Listen at the bedside without the stethoscope. Grunting? Stridor? Wheezing audible across the room? Hoarse voice?`,normal:`No audible stridor, grunting, or wheeze`},{label:`Chest shape and symmetry`,method:`Inspect from front and lateral. Note AP-to-transverse diameter, pectus excavatum/carinatum, chest wall asymmetry.`,normal:`AP:transverse ~1:2 (not barrel-chested); symmetric`},{label:`Colour and perfusion`,method:`Inspect lips, tongue, nail beds for central cyanosis. Check peripheral perfusion (capillary refill, mottling).`,normal:`Pink, cap refill < 2 s, no cyanosis`},{label:`Clubbing`,method:`Inspect fingernails: Schamroth sign (reverse a finger against its mirror — normal forms a diamond-shaped window, clubbed does not).`,normal:`Normal nail angle, Schamroth window present`}],abnormalHints:[`Audible stridor — upper airway (croup, epiglottitis, foreign body, laryngomalacia)`,`Grunting in infant — significant distress`,`Tripod positioning, accessory muscle use — severe distress`,`Barrel chest — chronic air-trapping (asthma, CF)`,`Central cyanosis — significant hypoxemia`,`Clubbing in a child — cystic fibrosis, chronic hypoxemia, bronchiectasis, cyanotic CHD`]},{name:`Palpation`,significance:`Localises pathology: consolidation increases tactile fremitus; pneumothorax/effusion decreases it. Trachea deviates AWAY from expanding lesions and TOWARD collapsing ones.`,pearl:`Tracheal deviation is one of the fastest bedside clues to mediastinal shift — tension pneumothorax pushes it away, lobar collapse pulls it toward. Palpate with the middle finger in the suprasternal notch.`,steps:[{label:`Tracheal position`,method:`Patient sitting upright, neck slightly extended. Place middle finger in the suprasternal notch, check equal distance to each SCM.`,normal:`Midline`},{label:`Chest expansion — symmetry`,method:`Hands on lateral chest wall with thumbs meeting at the spine (posterior) or xiphoid (anterior). Patient takes a deep breath. Watch thumbs separate symmetrically.`,normal:`Symmetric 3–5 cm separation`},{label:`Tactile fremitus`,method:`Ulnar surface of hand on chest wall. Ask patient to say "ninety-nine" repeatedly. Move hand systematically across each zone, comparing sides.`,normal:`Equal mild vibration bilaterally over lung fields`},{label:`Chest wall tenderness`,method:`Palpate ribs, costochondral junctions, sternum, and intercostal spaces.`,normal:`No tenderness`},{label:`Subcutaneous emphysema`,method:`Gentle palpation along clavicles, neck, chest wall.`,normal:`No crepitus under skin`}],abnormalHints:[`Tracheal deviation — tension pneumothorax, large pleural effusion (away); upper lobe collapse (toward)`,`Asymmetric expansion — pneumothorax, large effusion, lobar collapse, phrenic palsy`,`Increased fremitus — consolidation (pneumonia), lobar pneumonia`,`Decreased/absent fremitus — pleural effusion, pneumothorax, obstruction`,`Costochondral tenderness — costochondritis, trauma`,`Subcutaneous emphysema — pneumothorax, tracheobronchial injury`]},{name:`Percussion`,significance:`Differentiates air (hyper-resonant), fluid (dull), and consolidated lung (dull) without imaging. Well-performed percussion detects a pleural effusion > 300 mL or a pneumothorax with ~90% sensitivity.`,pearl:`Pleximeter fingertip must be flat against the chest wall — lift other fingers off. The "feel" of a percussion note is as informative as the sound: dullness has a dense, reflected quality; hyper-resonance feels hollow and springy.`,steps:[{label:`Technique`,method:`Place middle finger of non-dominant hand (pleximeter) flat on chest wall; strike distal IP joint with tip of dominant middle finger (plexor) using a quick wrist flick.`,normal:`N/A — technique step`},{label:`Systematic zones`,method:`Percuss from apex to base, comparing side-to-side at each level. Include anterior, lateral (mid-axillary), and posterior fields.`,normal:`Resonant throughout lung fields`},{label:`Cardiac dullness`,method:`Percuss from resonant lung toward the heart border. Left sternal border dullness starts at the 3rd–5th ICS.`,normal:`Dullness beginning at the expected cardiac border`},{label:`Hepatic dullness`,method:`Right 5th–6th ICS mid-clavicular line transitions from resonant to dull.`,normal:`Liver edge dullness at expected level`},{label:`Diaphragmatic excursion`,method:`Patient inhales fully then exhales fully; mark level of dullness at each end. Difference is diaphragm excursion.`,normal:`3–5 cm excursion bilaterally`}],abnormalHints:[`Hyper-resonant — pneumothorax, emphysematous bulla, severe asthma attack`,`Dull — consolidation, pleural effusion (stony dull), atelectasis, pleural thickening, large mass`,`Raised diaphragm (loss of excursion) — effusion, paralysis, subdiaphragmatic pathology`]},{name:`Auscultation — normal breath sounds`,significance:`Breath sound quality varies by location. Bronchial sounds heard peripherally = consolidation; absent breath sounds = pneumothorax, effusion, obstruction.`,pearl:`Always compare corresponding points side-to-side sequentially — your ear calibrates to "normal" one side and immediately hears asymmetry. Listen through a full respiratory cycle at each zone.`,steps:[{label:`Technique`,method:`Diaphragm of stethoscope directly on skin (not over clothing). Patient breathes slowly and deeply through an open mouth.`,normal:`N/A — technique`},{label:`Vesicular sounds (peripheral)`,method:`Listen over lung fields away from the sternum. Play the "Normal vesicular" sample above for reference.`,normal:`Soft, low-pitched, inspiration > expiration in length and loudness`},{label:`Bronchovesicular (over main bronchi)`,method:`Listen at the 1st–2nd ICS anteriorly and between scapulae posteriorly.`,normal:`Intermediate pitch, inspiration = expiration`},{label:`Bronchial (over trachea)`,method:`Listen directly over the manubrium or trachea.`,normal:`Harsh, high-pitched, expiration > inspiration`},{label:`Systematic comparison`,method:`Six zones anteriorly (upper/mid/lower × L/R), four lateral, six posterior. Compare side-to-side at each zone.`,normal:`Symmetric breath sounds at every paired zone`}],abnormalHints:[`Bronchial sounds heard peripherally — consolidation (pneumonia)`,`Absent/diminished breath sounds — pneumothorax, effusion, severe obstruction, obesity / muscular chest`,`Prolonged expiration — lower airway obstruction (asthma, bronchiolitis)`]},{name:`Auscultation — adventitious sounds`,significance:`Adventitious (added) sounds are the key diagnostic finding. Timing (inspiratory vs expiratory vs biphasic), character (continuous vs discontinuous), and location are all informative.`,pearl:`Ask the patient to cough and re-listen. Secretions (rhonchi, some coarse crackles) clear or change; fine crackles of fibrosis or early pneumonia do not. The cough test separates two differential groups in one maneuver.`,steps:[{label:`Listen for wheeze`,method:`Continuous musical sounds, typically expiratory. Use the "Wheeze" sample for reference.`,normal:`No wheeze`},{label:`Listen for crackles — fine`,method:`Short, high-pitched, discontinuous "Velcro" sounds. Typically end-inspiratory, bibasilar. Use the "Fine crackles" sample.`,normal:`No crackles`},{label:`Listen for crackles — coarse`,method:`Longer, lower-pitched, louder than fine. Use the "Coarse crackles" sample.`,normal:`No crackles`},{label:`Listen for rhonchi`,method:`Low-pitched, continuous, snore-like. Often change with cough. Use the "Rhonchi" sample.`,normal:`No rhonchi`},{label:`Listen for pleural rub`,method:`Grating, creaky, biphasic, does NOT clear with cough. Use the "Pleural rub" sample.`,normal:`No pleural rub`},{label:`Listen at the neck (for stridor)`,method:`Place stethoscope over the anterior neck. Stridor is loudest here and differentiates from wheeze (loudest over chest). Use the "Stridor" sample.`,normal:`No stridor`},{label:`Listen for expiratory grunting (infants)`,method:`Often audible without a stethoscope at the bedside — short, low-pitched sound at the end of each expiration (glottal closure against exhaled air).`,normal:`No grunting`},{label:`Cough re-listen`,method:`Have patient cough forcefully; re-listen to any abnormal area. Note if the sound clears or changes.`,normal:`Any secretion-based sound should clear or change with cough`}],abnormalHints:[`Wheeze — asthma, bronchiolitis, foreign body (localised), anaphylaxis`,`Fine crackles — pulmonary edema, interstitial lung disease, early pneumonia`,`Coarse crackles — bronchitis, pneumonia, bronchiectasis, aspiration`,`Rhonchi — large-airway secretions`,`Pleural rub — pleurisy, PE, pneumonia with pleural involvement`,`Stridor — upper airway obstruction (croup, epiglottitis, FB)`]},{name:`Special maneuvers — transmitted voice sounds`,significance:`Vocal resonance tests detect consolidation (increased transmission) and effusion/pneumothorax (decreased). Useful when auscultation suggests asymmetry.`,pearl:`Whispered pectoriloquy is the most sensitive of the three — whispered words transmitted clearly through consolidated lung. If "one, two, three" whispered becomes clearly audible over one lung zone, there is consolidation underneath.`,steps:[{label:`Bronchophony`,method:`Patient says "ninety-nine" in normal voice. Listen at each lung zone with the stethoscope.`,normal:`Muffled, indistinct sound`},{label:`Egophony`,method:`Patient says "ee" continuously. Listen over any suspicious area.`,normal:`"Ee" sounds like "ee" (no change)`},{label:`Whispered pectoriloquy`,method:`Patient whispers "one, two, three" or "ninety-nine". Listen over each zone.`,normal:`Whisper is faint and indistinct`}],abnormalHints:[`Bronchophony increased — consolidation`,`Egophony positive ("ee" → "A" / "ay") — consolidation, sometimes top of an effusion`,`Whispered pectoriloquy positive (whisper clearly audible) — consolidation`]}]},cv:{overview:`Systematic cardiovascular exam: inspection → palpation → auscultation at the five classic points → peripheral vascular exam. Always palpate the apex BEFORE auscultating — knowing where the apex lies tells you where to put the stethoscope and flags cardiomegaly immediately.`,components:[{name:`Inspection`,significance:`Detects obvious precordial activity, chest-wall signs of congenital heart disease, and systemic markers (cyanosis, clubbing, dysmorphic features).`,pearl:`Clubbing + central cyanosis in a well-appearing adolescent = cyanotic congenital heart disease until proven otherwise. Inspect the fingernails before reaching for the stethoscope.`,steps:[{label:`General appearance`,method:`Observe body habitus, features suggesting syndromic CHD (Turner, Down, Marfan, Williams).`,normal:`No dysmorphic features, appropriate growth`},{label:`Central cyanosis`,method:`Inspect lips, tongue, and oral mucosa for bluish discoloration.`,normal:`Pink oral mucosa, no cyanosis`},{label:`Peripheral cyanosis / clubbing`,method:`Inspect nail beds; do Schamroth's window (oppose nails of 4th fingers — normally forms a diamond-shaped window).`,normal:`Pink nail beds, Schamroth window present`},{label:`Precordial bulge`,method:`Inspect anterior chest wall tangentially for asymmetric prominence over the heart.`,normal:`Symmetric chest, no bulge`},{label:`Visible apex beat`,method:`Inspect for a visible cardiac impulse at the 5th ICS mid-clavicular line.`,normal:`Apex may be visible in thin patients; should not be displaced`},{label:`Neck veins (JVP)`,method:`Patient reclined 45°, head turned slightly left. Observe the right internal jugular pulsation; measure vertical height above the sternal angle.`,normal:`≤ 4 cm above sternal angle (≤ 9 cm H₂O from right atrium)`}],abnormalHints:[`Central cyanosis — right-to-left shunt, severe hypoxemia`,`Clubbing — cyanotic CHD, chronic hypoxemia`,`Precordial bulge — long-standing cardiomegaly (grew during skeletal growth)`,`Visible apex displaced lateral/inferior — cardiomegaly`,`Elevated JVP — right-heart failure, fluid overload, cardiac tamponade`]},{name:`Palpation`,significance:`Localises the apex (confirms cardiac size), detects thrills (loud murmurs), and identifies a parasternal heave (RV hypertrophy).`,pearl:`If you feel a thrill, the murmur is at least grade 4/6 — grade your murmur as ≥4 even if it sounds less impressive. Thrill = loud, palpable turbulence.`,steps:[{label:`Apex beat — localise`,method:`Feel with the tips of the fingers at the 5th ICS mid-clavicular line. If not found, roll the patient to the left lateral decubitus position.`,normal:`Located at 5th ICS, mid-clavicular line, less than 2 cm in diameter`},{label:`Apex character`,method:`Describe: tapping (normal), heaving (pressure overload, e.g. AS/HTN), thrusting (volume overload, e.g. AR/MR), dyskinetic (MI/aneurysm).`,normal:`Brief tapping quality`},{label:`Parasternal heave`,method:`Place the heel of the hand along the left sternal border. Sustained outward movement with each systole = heave.`,normal:`No heave`},{label:`Thrills`,method:`Use the palmar aspect of the hand at each of the 5 auscultation areas (A, P, E, T, M). A thrill = palpable turbulence.`,normal:`No thrills`},{label:`Peripheral pulses — upper`,method:`Palpate radial pulses bilaterally, then brachial. Note rate, rhythm, volume, and symmetry.`,normal:`Symmetric 2+ pulses, regular rhythm, age-appropriate rate`},{label:`Peripheral pulses — lower`,method:`Palpate femoral pulses. Compare to brachial — radio-femoral or brachio-femoral delay suggests coarctation of the aorta.`,normal:`Femoral pulses 2+ symmetric, no delay relative to radial`}],abnormalHints:[`Apex displaced laterally/inferiorly — cardiomegaly`,`Heaving apex — pressure overload (AS, HTN)`,`Thrusting apex — volume overload (AR, MR)`,`Thrill over precordium — always pathological; at least grade 4/6 murmur`,`Parasternal heave — RV hypertrophy (pulmonary HTN, pulmonary stenosis, VSD with Eisenmenger)`,`Radio-femoral delay — coarctation of the aorta (always check in a hypertensive adolescent)`]},{name:`Auscultation — approach`,significance:`Systematic technique ensures every relevant finding is detected. Listen at all 5 points, with both diaphragm and bell, in supine/sitting/left-lateral positions as needed.`,pearl:`Time every murmur by simultaneously palpating the carotid pulse with the fingers of your free hand. Pulse = systole. Murmur heard during the pulse = systolic; in between pulses = diastolic.`,steps:[{label:`Positioning`,method:`Patient supine, head of bed at 30°. Exam room quiet, patient relaxed. Warm the stethoscope first.`,normal:`N/A — technique`},{label:`Diaphragm technique`,method:`Firm contact with skin. Detects HIGH-pitched sounds: S1, S2, systolic ejection murmurs, AR, MR.`,normal:`N/A — technique`},{label:`Bell technique`,method:`Very light contact — enough to make a seal but not stretch the skin. Detects LOW-pitched sounds: S3, S4, mitral stenosis rumble.`,normal:`N/A — technique`},{label:`Listen at each of the 5 points`,method:`A → P → E → T → M in order, each with diaphragm then bell. Spend a full cycle at each zone.`,normal:`S1 crisp, S2 clear (splits physiologically on inspiration at P), no added sounds, no murmur`},{label:`Left lateral decubitus position`,method:`If apex murmur suspected. Roll patient to left side. Listen at the apex with the BELL for mitral stenosis rumble or S3/S4.`,normal:`No added sounds, no diastolic rumble`},{label:`Sitting forward, held expiration`,method:`Patient leans forward, exhales fully, holds. Listen at left lower sternal border and Erb's point with the DIAPHRAGM for aortic regurgitation (soft early diastolic decrescendo).`,normal:`No early-diastolic murmur`}],abnormalHints:[`Fixed split S2 (no change with respiration) — ASD`,`Loud S2 at pulmonic area — pulmonary HTN`,`S3 — volume overload, CHF (can be normal in young athletes)`,`S4 — stiff ventricle (HTN, HCM, ischemia)`,`Audible opening snap — mitral stenosis (rare in children)`]},{name:`Auscultation — heart sounds and murmurs`,significance:`Characterising a murmur by timing, location, radiation, pitch, quality, and dynamic maneuvers narrows the differential.`,pearl:`Innocent murmurs in children share 7 "S" features: Soft (≤ grade 2), Systolic, Short, Single (no added S3/S4), Small (localised, non-radiating), Sweet (musical), Sensitive to position/respiration (louder supine, softer standing). Anything breaking this pattern deserves workup.`,steps:[{label:`S1`,method:`Listen at the apex (mitral). Coincides with the carotid pulse upstroke. Mitral + tricuspid closure.`,normal:`Single, crisp, single-component sound`},{label:`S2`,method:`Listen at the pulmonic area in HELD INSPIRATION and HELD EXPIRATION. Note whether S2 splits physiologically (wider in inspiration, narrower/absent in expiration).`,normal:`Physiologic split (widens on inspiration, narrows on expiration)`},{label:`S3 / S4 gallops`,method:`Bell at the apex in left lateral decubitus. S3 = early diastole (after S2), low-pitched. S4 = late diastole (just before S1).`,normal:`Absent in adults; S3 can be normal in young athletes under age 30`},{label:`Identify murmur — timing`,method:`Time vs carotid pulse. Systolic (during pulse) vs diastolic (between pulses) vs continuous.`,normal:`No murmur, or only soft innocent flow murmur`},{label:`Identify murmur — location + radiation`,method:`Where loudest? Does it radiate? AS → carotids. MR → axilla. Coarctation → back.`,normal:`N/A — characterise only if murmur present`},{label:`Identify murmur — character`,method:`Crescendo-decrescendo (ejection) vs holosystolic (plateau) vs decrescendo early-diastolic (AR, PR) vs mid-diastolic rumble (MS, TS).`,normal:`N/A — characterise only if murmur present`},{label:`Grade intensity`,method:`Levine 1–6 scale (see scales card above).`,normal:`No murmur, or grade ≤ 2 soft innocent flow murmur`},{label:`Dynamic maneuvers`,method:`Standing: ↑HOCM, ↑MVP click (earlier). Squatting: opposite. Valsalva: ↑HOCM, most others decrease.`,normal:`No significant change with posture`}],abnormalHints:[`Holosystolic murmur at apex → axilla — mitral regurgitation`,`Holosystolic at lower left sternal border (LLSB) — VSD, tricuspid regurgitation`,`Systolic ejection at upper right sternal border → carotids — aortic stenosis`,`Systolic ejection at upper left sternal border — pulmonary stenosis`,`Continuous "machinery" below left clavicle — PDA`,`Early diastolic at Erb's point, leaning forward — aortic regurgitation`,`Diastolic rumble at apex, bell in left-lateral — mitral stenosis`,`Fixed split S2 + systolic flow murmur — ASD`]},{name:`Peripheral vascular exam`,significance:`Coarctation of the aorta hides until BP and pulses are checked in all four extremities. Differential diagnosis of a hypertensive adolescent should include this in the first 60 seconds.`,pearl:`Four-limb BP measurement is mandatory in any adolescent with hypertension or a murmur. Upper-extremity BP > lower-extremity BP (or brachio-femoral delay) = coarctation until excluded.`,steps:[{label:`Four-limb blood pressure`,method:`Measure BP in right arm, left arm, and at least one leg. Use appropriately sized cuff (bladder width 40% of limb circumference, length 80–100%).`,normal:`Arm BPs within 10 mmHg of each other; leg systolic within 20 mmHg of arm systolic (may be higher)`},{label:`Radial pulses`,method:`Palpate both radials simultaneously — note any delay or asymmetry.`,normal:`Simultaneous, symmetric, 2+`},{label:`Radio-femoral delay`,method:`Palpate radial and femoral simultaneously. Feel the femoral as clearly "after" the radial = delay.`,normal:`No delay`},{label:`Femoral pulses`,method:`Palpate both femoral pulses at the mid-inguinal point. Compare amplitude to radials.`,normal:`Symmetric 2+ pulses, equal amplitude to radial`},{label:`Dorsalis pedis + posterior tibialis`,method:`Palpate in both feet.`,normal:`2+ pulses bilaterally`},{label:`Capillary refill`,method:`Press and release the nail bed; time to normal colour.`,normal:`< 2 sec`}],abnormalHints:[`Asymmetric upper-extremity BP (> 10 mmHg) — subclavian stenosis or coarctation at the origin`,`Upper >> lower-extremity BP — coarctation of the aorta`,`Diminished or absent femoral pulses with brachio-femoral delay — coarctation`,`Bounding pulses with wide pulse pressure — AR, PDA, arteriovenous fistula, thyrotoxicosis, anemia`,`Weak thready pulses — low output state (heart failure, shock, hypovolemia)`,`Prolonged capillary refill — dehydration, shock, cold stress`]}]}}},u={mrc:{title:`MRC strength grade (0–5)`,icon:`fa-hand-fist`,rows:[[`5`,`Normal power — holds against full resistance`],[`4`,`Reduced — moves against gravity + some resistance`],[`3`,`Moves against gravity only (no added resistance)`],[`2`,`Full range with gravity eliminated (horizontal plane)`],[`1`,`Flicker / trace contraction, no joint movement`],[`0`,`No contraction`]]},dtr:{title:`Deep-tendon reflex grade (0–4+)`,icon:`fa-circle-dot`,rows:[[`0`,`Absent`],[`1+`,`Hypoactive — trace, only with reinforcement`],[`2+`,`Normal`],[`3+`,`Brisk — may still be normal in anxious patients`],[`4+`,`Hyperactive with sustained clonus — always abnormal`]]},plantar:{title:`Plantar response (Babinski)`,icon:`fa-shoe-prints`,rows:[[`Down-going`,`Normal in anyone ≥ 2 years`],[`Up-going`,`Normal < 2 years; abnormal after — UMN lesion`],[`Asymmetric`,`Always abnormal at any age`]]},beighton:{title:`Beighton hypermobility score (0–9)`,icon:`fa-hands`,rows:[[`≤ 3`,`Normal flexibility`],[`4`,`Borderline — consider in context`],[`≥ 5`,`Hypermobility spectrum; screen for hEDS if other features present`]]},atr:{title:`Scoliometer — angle of trunk rotation`,icon:`fa-ruler`,rows:[[`< 5°`,`Normal, no follow-up`],[`5–6°`,`Borderline — re-check at each visit`],[`≥ 7°`,`Refer for PA/lateral spine x-ray + orthopedic evaluation`]]},rr:{title:`Respiratory rate — upper limit by age (awake)`,icon:`fa-lungs`,rows:[[`Newborn`,`≤ 60 /min`],[`< 2 months`,`≤ 60 /min (WHO tachypnea cutoff)`],[`2–12 months`,`≤ 50 /min (WHO tachypnea cutoff)`],[`1–5 years`,`≤ 40 /min (WHO tachypnea cutoff)`],[`6–11 years`,`≤ 30 /min`],[`≥ 12 years`,`≤ 20 /min (adult pattern)`]]},spo2:{title:`Pulse oximetry (SpO₂) — at room air`,icon:`fa-heart-pulse`,rows:[[`≥ 95%`,`Normal`],[`92–94%`,`Mild hypoxemia — investigate cause`],[`< 92%`,`Moderate hypoxemia — supplemental O₂`],[`< 88%`,`Severe — urgent intervention; target ≥ 90% acutely`]]},silverman:{title:`Silverman–Andersen retraction score (neonatal, 0–10)`,icon:`fa-baby`,rows:[[`0`,`No respiratory distress`],[`1–3`,`Mild — close observation`],[`4–6`,`Moderate distress — consider CPAP / support`],[`7–10`,`Severe — imminent respiratory failure, intubate`]]},westley:{title:`Westley croup severity score`,icon:`fa-stethoscope`,rows:[[`≤ 2`,`Mild — home management, cool mist, oral dexamethasone`],[`3–5`,`Moderate — nebulised epinephrine + dexamethasone`],[`6–11`,`Severe — admit, continuous monitoring`],[`≥ 12`,`Impending respiratory failure — ICU / airway management`]]},murmurGrade:{title:`Heart-murmur grading (Levine 1–6)`,icon:`fa-wave-square`,rows:[[`1/6`,`Very faint — heard only with concentration`],[`2/6`,`Soft but readily heard`],[`3/6`,`Moderately loud, no thrill`],[`4/6`,`Loud WITH a palpable thrill`],[`5/6`,`Very loud; audible with stethoscope just off the chest`],[`6/6`,`Audible without the stethoscope touching the chest`]]},pulseAmp:{title:`Pulse amplitude grade (0–4)`,icon:`fa-heart-pulse`,rows:[[`0`,`Absent`],[`1+`,`Diminished, thready`],[`2+`,`Normal`],[`3+`,`Bounding`],[`4+`,`Bounding with visible pulsation (e.g., aortic regurgitation)`]]},capRefill:{title:`Capillary refill time`,icon:`fa-hand`,rows:[[`< 2 sec`,`Normal`],[`2–3 sec`,`Borderline — consider hydration / perfusion`],[`≥ 3 sec`,`Delayed — dehydration, shock, low cardiac output`]]}},d={msk:[`atr`,`beighton`],neuro:[`mrc`,`dtr`,`plantar`],resp:[`rr`,`spo2`,`silverman`,`westley`],cv:[`murmurGrade`,`pulseAmp`,`capRefill`]},f=[{letter:`A`,color:`#dc2626`,title:`Aortic area`,location:`2nd ICS, right sternal border`,listen:`S2 (aortic component), aortic stenosis, aortic regurgitation`},{letter:`P`,color:`#2563eb`,title:`Pulmonic area`,location:`2nd ICS, left sternal border`,listen:`S2 (pulmonic component), pulmonic stenosis, PDA, physiologic split of S2`,innocent:`Pulmonary flow murmur (children, adolescents) — upper left sternal border`},{letter:`E`,color:`#059669`,title:`Erb's point`,location:`3rd ICS, left sternal border`,listen:`Aortic regurgitation (best here), transitional zone murmurs`,innocent:`Still's murmur classically radiates to Erb's / LLSB`},{letter:`T`,color:`#d97706`,title:`Tricuspid area`,location:`4th–5th ICS, lower left sternal border`,listen:`Tricuspid regurgitation, VSD, S3/S4, holosystolic murmurs`,innocent:`Still's murmur — vibratory, musical, age 3–7 y (loudest between LLSB and apex)`},{letter:`M`,color:`#7c3aed`,title:`Mitral area (apex)`,location:`5th ICS, mid-clavicular line`,listen:`S1, mitral regurgitation, mitral stenosis (with bell, left-lateral decubitus)`}],p=[{name:`Still's (vibratory) murmur`,age:`3–7 y (most common in children)`,location:`LLSB, radiating to apex`,character:`Low-frequency vibratory / musical systolic, grade 2–3/6, mid-systolic, "twanging-string" quality`,confirm:`Louder supine, softer or disappears on standing or Valsalva. No radiation to neck/back. Normal S2.`},{name:`Pulmonary flow murmur`,age:`School-age and adolescents, thin chest`,location:`Upper left sternal border (2nd–3rd ICS)`,character:`Soft blowing early systolic ejection, grade 1–2/6, higher-pitched`,confirm:`No ejection click. Physiologic split of S2. Louder supine, softer on standing. No radiation.`},{name:`Venous hum`,age:`Ages 3–8, disappears by adolescence`,location:`Supraclavicular or infraclavicular area, usually right`,character:`Soft continuous hum, louder in diastole. Only innocent continuous murmur.`,confirm:`Disappears when supine OR when jugular vein is gently compressed (key maneuver). Turning head to opposite side also alters it.`},{name:`Carotid bruit / supraclavicular bruit`,age:`Children and adolescents`,location:`Supraclavicular fossa, right > left; may radiate to carotid`,character:`Brief early systolic, grade 2–3/6, higher-pitched than Still's`,confirm:`Softer or disappears with hyperextension of the shoulders. Normal cardiac exam otherwise. No radiation below the clavicles.`},{name:`Peripheral pulmonary stenosis (PPS, neonatal)`,age:`Newborns and infants < 6–12 months`,location:`Upper LSB, radiates to BOTH axillae and the back`,character:`Soft systolic ejection murmur, grade 1–2/6`,confirm:`Typical age + radiation to back/axillae. Resolves by age 1 as branch pulmonary arteries grow. Persistence or louder grade warrants echo.`}],m=[{key:`normal`,src:`/audio/respiratory/normal-vesicular.ogg`,title:`Normal vesicular breath sounds`,where:`Peripheral lung fields`,features:`Soft, rustling. Inspiration louder and longer than expiration.`,clinical:`Baseline — deviation elsewhere is what you listen for.`},{key:`wheeze`,src:`/audio/respiratory/wheeze.ogg`,title:`Wheeze`,where:`Diffuse in asthma; localised in foreign body`,features:`Continuous, high-pitched, musical. Usually expiratory; biphasic if severe.`,clinical:`Lower-airway narrowing — asthma, bronchiolitis, foreign body, bronchomalacia. Silent chest in severe asthma is an ominous sign.`},{key:`stridor`,src:`/audio/respiratory/stridor.ogg`,title:`Stridor`,where:`Louder over neck than chest — upper airway`,features:`Continuous, high-pitched, harsh. Classically inspiratory (extrathoracic obstruction); biphasic if fixed.`,clinical:`Croup, epiglottitis, foreign body, laryngomalacia (infant). Distinguish from wheeze by auscultating the neck — stridor is loudest there.`},{key:`finecrackles`,src:`/audio/respiratory/crackles-fine.ogg`,title:`Fine (end-inspiratory) crackles`,where:`Bibasilar in pulmonary edema/fibrosis; focal in pneumonia`,features:`Discontinuous, brief, high-pitched. "Velcro" quality. Late inspiratory, do NOT clear with cough.`,clinical:`Alveolar opening — pulmonary fibrosis, pulmonary edema, early pneumonia, atelectasis.`},{key:`coarsecrackles`,src:`/audio/respiratory/crackles-coarse.ogg`,title:`Coarse crackles`,where:`Lower lobes; either side`,features:`Discontinuous, longer and louder than fine crackles. Lower-pitched. Can be early or late inspiratory; often clear partly with cough.`,clinical:`Secretions in larger airways — bronchitis, later pneumonia, bronchiectasis, aspiration.`},{key:`rhonchi`,src:`/audio/respiratory/rhonchi.ogg`,title:`Rhonchi`,where:`Central or anywhere with airway secretions`,features:`Continuous, low-pitched, snore-like. Typically expiratory. Clear or change with cough.`,clinical:`Large-airway secretions — bronchitis, pneumonia with large-airway involvement, cystic fibrosis, bronchiectasis.`},{key:`pleuralrub`,src:`/audio/respiratory/pleural-rub.ogg`,title:`Pleural friction rub`,where:`Focal, often lateral or posterior lower chest`,features:`Grating, creaky — "leather on leather". Biphasic (heard in inspiration and expiration). Does NOT clear with cough.`,clinical:`Pleural inflammation — pleuritis, pulmonary embolism, pneumonia with pleural involvement, viral pleurisy.`}],h=[{key:`normal`,src:`/audio/cardiac/normal.ogg`,title:`Normal heart sounds (S1, S2)`,where:`All four classic auscultation points`,rate:`~61 bpm reference`,features:`"lub-dub": S1 (closure of mitral + tricuspid) louder at apex; S2 (closure of aortic + pulmonic) louder at base. Physiologic S2 split on inspiration.`,clinical:`Reference for rhythm, rate, and the normal S1–S2 interval. Listen for what's changed — not just what's added.`},{key:`infant-normal`,src:`/audio/cardiac/infant-normal.ogg`,title:`Infant normal heart sounds`,where:`Infant chest — rate will be higher than adult`,rate:`Pediatric reference (120–160 bpm range)`,features:`Same S1–S2 pattern, faster rate. Short diastole makes murmurs easier to miss — careful auscultation needed.`,clinical:`Reference for neonatal/infant rhythm. Any murmur in the first 72 h should prompt pre/postductal sat screening.`},{key:`vsd`,src:`/audio/cardiac/vsd.wav`,title:`Ventricular septal defect (VSD)`,where:`Lower left sternal border (4th ICS)`,features:`Harsh, blowing, holosystolic (pansystolic) murmur — plateau shape through all of systole. Often accompanied by a thrill if large.`,clinical:`Most common congenital heart defect. Small VSD: loud murmur, usually asymptomatic, may close spontaneously. Large VSD: softer murmur (less pressure gradient) but signs of heart failure, pulmonary hypertension.`},{key:`mvp`,src:`/audio/cardiac/mitral-prolapse.wav`,title:`Mitral valve prolapse (MVP) — click + late systolic murmur`,where:`Apex (5th ICS, mid-clavicular line)`,features:`Mid-systolic click followed by a late-systolic crescendo murmur. Timing of click changes with maneuvers: earlier with standing or Valsalva, later with squatting.`,clinical:`Often benign, especially in thin young women. Features suggesting need for echo: thickened/redundant leaflets, associated MR, symptoms (palpitations, chest pain), arrhythmias.`},{key:`stills`,src:`/audio/cardiac/stills-murmur.ogg`,title:`Still's murmur (innocent)`,where:`LLSB, radiating to apex`,rate:`Classic age 3–7 y (this recording is a toddler)`,features:`Low-frequency vibratory / musical systolic, grade 2–3/6, mid-systolic, "twanging-string" quality.`,clinical:`The most common innocent murmur of childhood. Louder supine, softer or disappears on standing or Valsalva. Normal S2. No radiation to neck or back. No workup needed when classic.`},{key:`functional`,src:`/audio/cardiac/functional-murmur.wav`,title:`Functional (innocent) murmur — adult female`,where:`Left sternal border, soft systolic`,features:`Soft systolic murmur in a structurally normal heart — often from increased cardiac output, thin chest wall, anemia, hyperthyroidism, or pregnancy.`,clinical:`Benign if it meets the 7 S criteria. Investigate if loud (≥3/6), holosystolic, diastolic, radiating, or with thrill / symptoms.`}],g=n(),_=`rounded-lg border border-border bg-card p-5 space-y-3`,v=`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors cursor-pointer`,y=`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,b=`rounded-md border border-border bg-background px-3 py-2 text-sm font-medium hover:bg-muted disabled:opacity-50`,x=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring`;function S(e,t,n,r){return`${e}/${t}/${n}/${r}`}function C({id:e,scale:t}){return(0,g.jsxs)(`section`,{className:`rounded-md border border-border bg-background p-3`,"data-testid":`scale-`+e,children:[(0,g.jsx)(`h4`,{className:`text-sm font-semibold mb-2`,children:t.title}),(0,g.jsx)(`table`,{className:`w-full text-xs`,children:(0,g.jsx)(`tbody`,{children:t.rows.map(([e,t],n)=>(0,g.jsxs)(`tr`,{className:`border-b border-border last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-1 pr-3 font-mono font-semibold whitespace-nowrap`,children:e}),(0,g.jsx)(`td`,{className:`py-1 text-muted-foreground`,children:t})]},n))})})]})}function w({entry:e}){return(0,g.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3 space-y-2`,"data-testid":`sound-`+e.key,children:[(0,g.jsx)(`div`,{className:`text-sm font-semibold`,children:e.title}),(0,g.jsx)(`audio`,{controls:!0,preload:`none`,className:`w-full`,children:(0,g.jsx)(`source`,{src:e.src})}),(0,g.jsxs)(`div`,{className:`text-xs space-y-0.5 text-muted-foreground`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Where:`}),` `,e.where]}),e.rate&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Rate:`}),` `,e.rate]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Features:`}),` `,e.features]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`span`,{className:`font-semibold`,children:`Clinical:`}),` `,e.clinical]})]})]})}function T({step:e,status:t,onStatus:n}){let r=`text-xs font-medium px-2 py-1 rounded border`;return(0,g.jsxs)(`div`,{className:`flex items-start gap-2 py-2 border-b border-border last:border-0`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Method:`}),` `,e.method]}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Normal:`}),` `,e.normal]})]}),(0,g.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-1 flex-shrink-0`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>n(t===`normal`?null:`normal`),className:r+` `+(t===`normal`?`bg-green-600 text-white border-green-600`:`border-green-600 text-green-700 hover:bg-green-50 dark:hover:bg-green-950/30`),children:`Normal`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>n(t===`abnormal`?null:`abnormal`),className:r+` `+(t===`abnormal`?`bg-destructive text-white border-destructive`:`border-destructive text-destructive hover:bg-red-50 dark:hover:bg-red-950/30`),children:`Abnormal`})]})]})}function E({age:e,sys:t,idx:n,comp:r,getStatus:i,setStatus:a}){return(0,g.jsxs)(`div`,{className:_,"data-testid":`pe-component-${e}-${t}-${n}`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:r.name}),(0,g.jsx)(`div`,{children:r.steps.map((r,o)=>{let s=S(e,t,n,o);return(0,g.jsx)(T,{step:r,status:i(s),onStatus:e=>a(s,e)},o)})}),r.abnormalHints.length>0&&(0,g.jsxs)(`div`,{className:`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-destructive mb-1`,children:`Watch for`}),(0,g.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-red-900 dark:text-red-200 space-y-0.5`,children:r.abnormalHints.map((e,t)=>(0,g.jsx)(`li`,{children:e},t))})]}),r.pearl&&(0,g.jsxs)(`div`,{className:`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-300 dark:border-amber-800 p-3 text-xs text-amber-900 dark:text-amber-100`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Pearl:`}),` `,r.pearl]}),r.significance&&(0,g.jsxs)(`div`,{className:`rounded-md bg-sky-50 dark:bg-sky-950/30 border border-sky-200 dark:border-sky-900 p-3 text-xs text-sky-900 dark:text-sky-100`,children:[(0,g.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:`Significance:`}),` `,r.significance]})]})}function D(){let[e,t]=(0,a.useState)(`toddler`),[n,T]=(0,a.useState)(`msk`),[D,O]=(0,a.useState)(``),[k,A]=(0,a.useState)(``),[j,M]=(0,a.useState)(`narrative`),[N,P]=(0,a.useState)({}),[F,I]=(0,a.useState)(null),L=l[e],R=L[n],z=r({mutationFn:e=>i.post(`/api/generate-pe-narrative`,e),onSuccess:e=>I(e.narrative),onError:e=>I(`Generation failed: `+e.message)}),B=(0,a.useMemo)(()=>{let t=0,r=0,i=0;return R.components.forEach((a,o)=>a.steps.forEach((a,s)=>{let c=N[S(e,n,o,s)]??null;c===`normal`?t++:c===`abnormal`?r++:i++})),{normal:t,abnormal:r,notAssessed:i}},[e,n,R,N]);function V(){P(t=>{let r={...t};return R.components.forEach((t,i)=>t.steps.forEach((t,a)=>{delete r[S(e,n,i,a)]})),r}),I(null)}function H(){P(t=>{let r={...t};return R.components.forEach((t,i)=>t.steps.forEach((t,a)=>{r[S(e,n,i,a)]=`normal`})),r})}function U(){I(null);let t=[];R.components.forEach((r,i)=>r.steps.forEach((a,o)=>{t.push({component:r.name,label:a.label,method:a.method,normal:a.normal,status:N[S(e,n,i,o)]??null})})),z.mutate({steps:t,ageGroup:e,system:n,patientAge:D||void 0,patientGender:k||void 0,format:j})}let W=B.normal+B.abnormal;return(0,g.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-5`,children:[(0,g.jsxs)(`header`,{children:[(0,g.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Physical Exam Guide`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Age-group and system-specific exam checklist with abnormal-finding hints. Toggle normal / abnormal on each step, then generate a narrative for your note.`})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Age group`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`pe-age-group-pills`,children:o.map(n=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:v+(e===n?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80 border-border`),"data-testid":`pe-age-`+n,children:l[n].label},n))})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`System`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`pe-system-pills`,children:s.map(e=>(0,g.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:v+(n===e?` bg-primary text-primary-foreground border-primary`:` bg-muted hover:bg-muted/80 border-border`),"data-testid":`pe-system-`+e,children:c[e]},e))})]}),(0,g.jsxs)(`section`,{className:_+` border-l-4 border-l-primary`,"data-testid":`pe-overview`,children:[(0,g.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[L.label,` — `,c[n]]}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:R.overview})]}),n===`cv`&&(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-cv-aptm`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:`Auscultation landmarks (APTM + Erb's)`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:f.map(e=>(0,g.jsxs)(`div`,{className:`flex gap-3 items-start rounded-md border border-border p-3`,children:[(0,g.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center font-bold text-white flex-shrink-0`,style:{background:e.color},children:e.letter}),(0,g.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,g.jsx)(`div`,{className:`font-semibold`,children:e.title}),(0,g.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.location}),(0,g.jsxs)(`div`,{className:`text-xs mt-1`,children:[(0,g.jsx)(`strong`,{children:`Listen for:`}),` `,e.listen]}),e.innocent&&(0,g.jsxs)(`div`,{className:`text-xs text-green-700 dark:text-green-300 mt-1`,children:[(0,g.jsx)(`em`,{children:`Innocent:`}),` `,e.innocent]})]})]},e.letter))}),(0,g.jsx)(`h3`,{className:`text-base font-semibold mt-3`,children:`Cardiac sounds library`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:h.map(e=>(0,g.jsx)(w,{entry:e},e.key))}),(0,g.jsx)(`h3`,{className:`text-base font-semibold mt-3`,children:`Classic innocent murmurs`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:p.map(e=>(0,g.jsxs)(`div`,{className:`rounded-md border border-green-200 dark:border-green-900 bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1`,children:[(0,g.jsx)(`div`,{className:`font-semibold`,children:e.name}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Age: `,e.age,` · Location: `,e.location]}),(0,g.jsxs)(`div`,{className:`text-xs`,children:[(0,g.jsx)(`strong`,{children:`Sound:`}),` `,e.character]}),(0,g.jsxs)(`div`,{className:`text-xs`,children:[(0,g.jsx)(`strong`,{children:`Confirm innocent:`}),` `,e.confirm]})]},e.name))})]}),n===`resp`&&(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-resp-sounds`,children:[(0,g.jsx)(`h3`,{className:`text-base font-semibold`,children:`Respiratory sounds library`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:m.map(e=>(0,g.jsx)(w,{entry:e},e.key))})]}),d[n]&&d[n].length>0&&(0,g.jsxs)(`details`,{className:_,"data-testid":`pe-scales`,children:[(0,g.jsx)(`summary`,{className:`cursor-pointer font-semibold text-sm`,children:`Grading scales & reference`}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mt-3`,children:d[n].map(e=>{let t=u[e];return t?(0,g.jsx)(C,{id:e,scale:t},e):null})})]}),(0,g.jsxs)(`section`,{className:`space-y-3`,"data-testid":`pe-checklist`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,g.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Exam checklist`}),(0,g.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-3`,children:[(0,g.jsxs)(`span`,{className:`text-green-600`,children:[B.normal,` normal`]}),(0,g.jsxs)(`span`,{className:`text-destructive`,children:[B.abnormal,` abnormal`]}),(0,g.jsxs)(`span`,{children:[B.notAssessed,` not assessed`]})]})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:H,className:b,"data-testid":`btn-pe-all-normal`,children:`Mark all normal`}),(0,g.jsx)(`button`,{type:`button`,onClick:V,className:b,"data-testid":`btn-pe-reset`,children:`Reset`})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 gap-3`,children:R.components.map((t,r)=>(0,g.jsx)(E,{age:e,sys:n,idx:r,comp:t,getStatus:e=>N[e]??null,setStatus:(e,t)=>P(n=>({...n,[e]:t}))},r))})]}),(0,g.jsxs)(`section`,{className:_,"data-testid":`pe-generate`,children:[(0,g.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Generate Exam Report`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Uses the statuses above + optional patient context.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,g.jsx)(`input`,{className:x,placeholder:`Patient age (e.g. 3y)`,value:D,onChange:e=>O(e.target.value)}),(0,g.jsx)(`input`,{className:x,placeholder:`Patient gender (optional)`,value:k,onChange:e=>A(e.target.value)}),(0,g.jsxs)(`select`,{className:x,value:j,onChange:e=>M(e.target.value),children:[(0,g.jsx)(`option`,{value:`narrative`,children:`Narrative`}),(0,g.jsx)(`option`,{value:`list`,children:`List`})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`button`,{type:`button`,className:y,onClick:U,disabled:z.isPending||W===0,"data-testid":`btn-pe-generate`,children:z.isPending?`Generating…`:`Generate Exam Report`}),W===0&&(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Mark at least one step before generating.`})]}),F&&(0,g.jsx)(`div`,{className:`rounded-md border border-border bg-muted/40 p-3 whitespace-pre-wrap text-sm`,"data-testid":`pe-narrative`,children:F})]})]})}export{D as default}; \ No newline at end of file diff --git a/public/app/assets/Recorder-DdXTjnSC.js b/public/app/assets/Recorder-DdXTjnSC.js new file mode 100644 index 0000000..8937d7f --- /dev/null +++ b/public/app/assets/Recorder-DdXTjnSC.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";var r=e(t(),1),i=class{mediaRecorder=null;chunks=[];stream=null;start(){return this.chunks=[],navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:16e3,echoCancellation:!0,noiseSuppression:!0}}).then(e=>{this.stream=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`;this.mediaRecorder=new MediaRecorder(e,{mimeType:t,audioBitsPerSecond:32e3}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.start(1e3)})}stop(){return new Promise(e=>{if(!this.mediaRecorder||this.mediaRecorder.state===`inactive`){e(null);return}this.mediaRecorder.onstop=()=>{let t=new Blob(this.chunks,{type:this.mediaRecorder.mimeType});this.stream&&this.stream.getTracks().forEach(e=>e.stop()),e(t)},this.mediaRecorder.stop()})}pause(){if(this.mediaRecorder&&typeof this.mediaRecorder.pause==`function`&&this.mediaRecorder.state===`recording`)try{this.mediaRecorder.pause()}catch{}}resume(){if(this.mediaRecorder)try{if(typeof this.mediaRecorder.resume==`function`&&this.mediaRecorder.state===`paused`)this.mediaRecorder.resume();else if(this.mediaRecorder.state===`inactive`&&this.stream&&this.stream.active){let e=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`;this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:e,audioBitsPerSecond:32e3}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.start(1e3)}}catch{}}},a=null;async function o(){try{let e=await(await fetch(`/api/transcribe/status`,{credentials:`include`})).json();a=!!e.available,e.provider}catch{a=!1}}function s(){return a}async function c(e,t=`encounter`){if(a===null&&await o(),a===!1)return{success:!1,noProvider:!0,error:`No transcription API configured — using live transcript`};let n=new FormData;n.append(`audio`,e,`audio.webm`);try{let r=await(await fetch(`/api/transcribe`,{method:`POST`,credentials:`include`,body:n})).json();return!r.success&&e.size>0&&l(e,t+`-failed-transcription`).catch(()=>{}),r}catch(n){return l(e,t+`-failed-transcription`).catch(()=>{}),{success:!1,error:n.message}}}async function l(e,t){try{let n=new FormData;n.append(`audio`,e,`audio.webm`),n.append(`module`,t);let r=await(await fetch(`/api/audio-backups`,{method:`POST`,credentials:`include`,body:n})).json();if(r.success&&r.id)return r.id}catch{}return m(e,t)}var u=`PedScribeAudioBackup`,d=`recordings`,f=null;function p(){return f?Promise.resolve(f):new Promise((e,t)=>{let n=indexedDB.open(u,1);n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains(d)||t.createObjectStore(d,{keyPath:`id`,autoIncrement:!0}).createIndex(`timestamp`,`timestamp`,{unique:!1})},n.onsuccess=()=>{f=n.result,e(f)},n.onerror=()=>t(Error(`IndexedDB open failed`))})}function m(e,t){return p().then(n=>new Promise((r,i)=>{let a=n.transaction(d,`readwrite`).objectStore(d).add({blob:e,module:t,timestamp:Date.now(),size:e.size,mimeType:e.type});a.onsuccess=()=>r(a.result),a.onerror=()=>i(Error(`Failed to save audio backup`))})).catch(()=>null)}var h=`ped_web_speech_enabled`;function g(){if(typeof window>`u`)return null;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition||null}function _(){try{return localStorage.getItem(h)===`1`||localStorage.getItem(h)===`true`}catch{return!1}}function v(e){let t=g();if(!t)return null;let n=null,r=!1;function i(){let n=new t;return n.continuous=!0,n.interimResults=!0,n.lang=`en-US`,n.maxAlternatives=1,n.onresult=t=>{let n=``;for(let r=t.resultIndex;r{t.error===`no-speech`||t.error===`aborted`||e.onError?.(t.error)},n.onend=()=>{if(r)try{n.start()}catch{}},n}return{start:()=>{r=!0,n=i();try{n.start()}catch{}},stop:()=>{if(r=!1,n)try{n.stop()}catch{}}}}function y(e,t){if(!e||!t)return e;let n=e.trim();if(!n||t.trimEnd().endsWith(n))return``;let r=n.split(/\s+/);if(r.length>=3){if(t.trimEnd().split(/\s+/).slice(-r.length).join(` `)===n)return``;let e=Math.ceil(r.length/2),i=r.slice(0,e).join(` `);if(t.trimEnd().endsWith(i))return r.slice(e).join(` `)+` `}return e}var b=n(),x=`inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-semibold border transition-colors`;function S({module:e,onTranscript:t,onInterim:n,onError:a,disabled:l}){let u=(0,r.useRef)(null),d=(0,r.useRef)(null),f=(0,r.useRef)(``),p=(0,r.useRef)(null),m=(0,r.useRef)(0),h=(0,r.useRef)(0),g=(0,r.useRef)(0),[S,C]=(0,r.useState)(`idle`),[w,T]=(0,r.useState)(0);(0,r.useEffect)(()=>{s()===null&&o()},[]),(0,r.useEffect)(()=>()=>{p.current&&window.clearInterval(p.current),d.current&&d.current.stop(),u.current&&u.current.stop().catch(()=>{})},[]);function E(){p.current&&window.clearInterval(p.current),p.current=window.setInterval(()=>{T(Math.floor((Date.now()-m.current-h.current)/1e3))},1e3)}function D(){p.current&&=(window.clearInterval(p.current),null)}async function O(){if(S===`idle`){f.current=``,h.current=0,T(0);try{let e=new i;if(await e.start(),u.current=e,m.current=Date.now(),E(),C(`recording`),_()){let e=v({onFinal:e=>{let t=y(e,f.current);f.current+=t,n?.(f.current)},onInterim:e=>n?.(f.current+e),onError:()=>{}});d.current=e,e?.start()}}catch{a?.(`Microphone permission denied`),C(`idle`)}}}function k(){S===`recording`&&(u.current?.pause(),d.current?.stop(),g.current=Date.now(),D(),C(`paused`))}function A(){S===`paused`&&(u.current?.resume(),h.current+=Date.now()-g.current,E(),_()&&!d.current&&(d.current=v({onFinal:e=>{let t=y(e,f.current);f.current+=t,n?.(f.current)},onInterim:e=>n?.(f.current+e)})),d.current?.start(),C(`recording`))}async function j(){if(S!==`recording`&&S!==`paused`)return;let n=f.current.trim();d.current?.stop(),d.current=null,D();let r=w;C(`transcribing`);try{let i=await u.current.stop();if(u.current=null,!i||i.size===0){n&&t(n,{durationSec:r,appended:!0}),C(`idle`);return}if(i.size>24*1024*1024){a?.(`Recording too large for AI transcription — using live transcript`),n&&t(n,{durationSec:r,appended:!0}),C(`idle`);return}let o=await c(i,e);o.success&&o.text?t(o.text,{provider:o.provider,durationSec:r,appended:!1}):o.noProvider?n?t(n,{durationSec:r,appended:!0}):a?.(`No transcription API configured`):n?t(n,{durationSec:r,appended:!0}):a?.(o.error||`Transcription failed`)}catch(e){a?.(e.message)}finally{C(`idle`)}}let M=String(Math.floor(w/60)).padStart(2,`0`),N=String(w%60).padStart(2,`0`);return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`recorder-`+e,children:[S===`idle`&&(0,b.jsx)(`button`,{type:`button`,onClick:O,disabled:l,className:x+` bg-destructive text-white border-destructive hover:bg-red-700`,"data-testid":`recorder-start`,children:`🎙 Start recording`}),(S===`recording`||S===`paused`)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{type:`button`,onClick:S===`recording`?k:A,className:x+` bg-amber-500 text-white border-amber-500 hover:bg-amber-600`,"data-testid":`recorder-pause`,children:S===`recording`?`⏸ Pause`:`▶ Resume`}),(0,b.jsx)(`button`,{type:`button`,onClick:j,className:x+` bg-slate-800 text-white border-slate-800 hover:bg-slate-900`,"data-testid":`recorder-stop`,children:`⏹ Stop`}),(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-sm text-destructive font-mono`,"data-testid":`recorder-timer`,children:[(0,b.jsx)(`span`,{className:S===`recording`?`animate-pulse`:`opacity-50`,children:`●`}),S===`paused`?`paused `:``,M,`:`,N]})]}),S===`transcribing`&&(0,b.jsx)(`span`,{className:`text-sm text-muted-foreground`,"data-testid":`recorder-transcribing`,children:`⌛ Transcribing…`})]})}export{S as t}; \ No newline at end of file diff --git a/public/app/assets/ResetPassword-pLQAcaAT.js b/public/app/assets/ResetPassword-CVgOn7wd.js similarity index 97% rename from public/app/assets/ResetPassword-pLQAcaAT.js rename to public/app/assets/ResetPassword-CVgOn7wd.js index f18ef8a..3e7f010 100644 --- a/public/app/assets/ResetPassword-pLQAcaAT.js +++ b/public/app/assets/ResetPassword-CVgOn7wd.js @@ -1 +1 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{i as r,o as i,s as a}from"./index-BuU36CvS.js";var o=e(t(),1),s=n(),c=`rounded-2xl border border-border bg-card p-6 shadow-lg space-y-4 w-full max-w-md`,l=`w-full rounded-md bg-primary text-primary-foreground px-4 py-3 text-sm font-semibold disabled:opacity-60`,u=`w-full rounded-md border border-input bg-background px-3 py-2.5 text-sm outline-none focus:ring-2 focus:ring-ring`,d=`block text-xs font-semibold text-muted-foreground mb-1`,f=`rounded-md bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-900 p-3 text-sm text-green-800 dark:text-green-100`,p=`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3 text-sm text-red-800 dark:text-red-100`,m=`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 p-3 text-sm text-amber-900 dark:text-amber-100`;function h(){let[e]=a(),t=i(),n=e.get(`token`)||``,[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);async function D(e){if(e.preventDefault(),b(``),S(``),w(``),!n){b(`Missing reset token. Open the reset link from your email.`);return}if(h.length<8){b(`Password must be 8+ characters`);return}if(h!==_){b(`Passwords do not match`);return}E(!0);try{let e=await r.post(`/api/auth/reset-password`,{token:n,newPassword:h});S(`Password reset. You can now sign in.`),e.passwordWarning&&w(e.passwordWarning),setTimeout(()=>t(`/auth`,{replace:!0}),2500)}catch(e){b(e.message||`Reset failed. The link may have expired.`)}finally{E(!1)}}return(0,s.jsx)(`div`,{className:`min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 dark:from-slate-900 dark:via-slate-950 dark:to-slate-900 flex items-center justify-center p-4`,children:(0,s.jsxs)(`div`,{className:c,children:[(0,s.jsxs)(`header`,{className:`text-center space-y-1`,children:[(0,s.jsx)(`div`,{className:`text-4xl`,children:`🔑`}),(0,s.jsx)(`h1`,{className:`text-xl font-bold`,children:`Set a new password`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose a password at least 8 characters long.`})]}),y&&(0,s.jsx)(`div`,{className:p,children:y}),x&&(0,s.jsx)(`div`,{className:f,children:x}),C&&(0,s.jsx)(`div`,{className:m,children:C}),(0,s.jsxs)(`form`,{onSubmit:D,className:`space-y-3`,"data-testid":`reset-password-form`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{className:d,children:`New password`}),(0,s.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:u,value:h,onChange:e=>g(e.target.value),autoFocus:!0,"data-testid":`reset-new`})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{className:d,children:`Confirm new password`}),(0,s.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:u,value:_,onChange:e=>v(e.target.value),"data-testid":`reset-confirm`})]}),(0,s.jsx)(`button`,{type:`submit`,className:l,disabled:T||!n,"data-testid":`reset-submit`,children:T?`Resetting…`:`Reset password`})]})]})})}export{h as default}; \ No newline at end of file +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{i as r,o as i,s as a}from"./index-C9wKWOAN.js";var o=e(t(),1),s=n(),c=`rounded-2xl border border-border bg-card p-6 shadow-lg space-y-4 w-full max-w-md`,l=`w-full rounded-md bg-primary text-primary-foreground px-4 py-3 text-sm font-semibold disabled:opacity-60`,u=`w-full rounded-md border border-input bg-background px-3 py-2.5 text-sm outline-none focus:ring-2 focus:ring-ring`,d=`block text-xs font-semibold text-muted-foreground mb-1`,f=`rounded-md bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-900 p-3 text-sm text-green-800 dark:text-green-100`,p=`rounded-md bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-900 p-3 text-sm text-red-800 dark:text-red-100`,m=`rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900 p-3 text-sm text-amber-900 dark:text-amber-100`;function h(){let[e]=a(),t=i(),n=e.get(`token`)||``,[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``),[T,E]=(0,o.useState)(!1);async function D(e){if(e.preventDefault(),b(``),S(``),w(``),!n){b(`Missing reset token. Open the reset link from your email.`);return}if(h.length<8){b(`Password must be 8+ characters`);return}if(h!==_){b(`Passwords do not match`);return}E(!0);try{let e=await r.post(`/api/auth/reset-password`,{token:n,newPassword:h});S(`Password reset. You can now sign in.`),e.passwordWarning&&w(e.passwordWarning),setTimeout(()=>t(`/auth`,{replace:!0}),2500)}catch(e){b(e.message||`Reset failed. The link may have expired.`)}finally{E(!1)}}return(0,s.jsx)(`div`,{className:`min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 dark:from-slate-900 dark:via-slate-950 dark:to-slate-900 flex items-center justify-center p-4`,children:(0,s.jsxs)(`div`,{className:c,children:[(0,s.jsxs)(`header`,{className:`text-center space-y-1`,children:[(0,s.jsx)(`div`,{className:`text-4xl`,children:`🔑`}),(0,s.jsx)(`h1`,{className:`text-xl font-bold`,children:`Set a new password`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose a password at least 8 characters long.`})]}),y&&(0,s.jsx)(`div`,{className:p,children:y}),x&&(0,s.jsx)(`div`,{className:f,children:x}),C&&(0,s.jsx)(`div`,{className:m,children:C}),(0,s.jsxs)(`form`,{onSubmit:D,className:`space-y-3`,"data-testid":`reset-password-form`,children:[(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{className:d,children:`New password`}),(0,s.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:u,value:h,onChange:e=>g(e.target.value),autoFocus:!0,"data-testid":`reset-new`})]}),(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`label`,{className:d,children:`Confirm new password`}),(0,s.jsx)(`input`,{type:`password`,required:!0,minLength:8,className:u,value:_,onChange:e=>v(e.target.value),"data-testid":`reset-confirm`})]}),(0,s.jsx)(`button`,{type:`submit`,className:l,disabled:T||!n,"data-testid":`reset-submit`,children:T?`Resetting…`:`Reset password`})]})]})})}export{h as default}; \ No newline at end of file diff --git a/public/app/assets/Settings-CnDpQmnm.js b/public/app/assets/Settings-B_mY7MfB.js similarity index 99% rename from public/app/assets/Settings-CnDpQmnm.js rename to public/app/assets/Settings-B_mY7MfB.js index bf2deac..68425af 100644 --- a/public/app/assets/Settings-CnDpQmnm.js +++ b/public/app/assets/Settings-B_mY7MfB.js @@ -1,4 +1,4 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-BuU36CvS.js";import{t as s}from"./ConfirmModal-zYA0ebt6.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,f=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,p=`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`,m=`rounded-md bg-destructive text-white px-3 py-2 text-sm font-medium disabled:opacity-50`;function h({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function g(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);return t<60?`just now`:t<3600?Math.floor(t/60)+`m ago`:t<86400?Math.floor(t/3600)+`h ago`:Math.floor(t/86400)+`d ago`}function _(){let e=o(),[t,n]=(0,c.useState)(``),[a,s]=(0,c.useState)(``),[p,m]=(0,c.useState)(``),[g,_]=(0,c.useState)(null),v=r({mutationFn:e=>i.post(`/api/auth/change-password`,e),onSuccess:t=>{_({text:t.message||`Password changed`,kind:`ok`}),n(``),s(``),m(``),e.invalidateQueries({queryKey:[`sessions`]}),t.passwordWarning&&setTimeout(()=>_({text:t.passwordWarning,kind:`info`}),2e3)},onError:e=>_({text:e.message,kind:`err`})});function y(e){if(e.preventDefault(),_(null),!t||!a)return _({text:`Fill in all fields`,kind:`err`});if(a.length<8)return _({text:`New password must be 8+ characters`,kind:`err`});if(a!==p)return _({text:`Passwords do not match`,kind:`err`});v.mutate({currentPassword:t,newPassword:a})}return(0,l.jsxs)(`section`,{className:u,"data-testid":`change-password-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Change Password`}),(0,l.jsxs)(`form`,{onSubmit:y,className:`space-y-2 max-w-sm`,children:[(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`Current password`,value:t,onChange:e=>n(e.target.value),"data-testid":`pw-current`}),(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`New password (8+ characters)`,minLength:8,value:a,onChange:e=>s(e.target.value),"data-testid":`pw-new`}),(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`Confirm new password`,minLength:8,value:p,onChange:e=>m(e.target.value),"data-testid":`pw-confirm`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`button`,{type:`submit`,disabled:v.isPending,className:f,"data-testid":`btn-change-password`,children:v.isPending?`Changing…`:`Change Password`}),(0,l.jsx)(h,{msg:g})]})]})]})}function v({codes:e,onClose:t}){return(0,l.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,children:(0,l.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-border bg-background p-5 shadow-lg space-y-3`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Save your backup codes`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each code can be used once if you lose access to your authenticator. They will not be shown again.`}),(0,l.jsx)(`pre`,{className:`bg-muted p-3 rounded text-sm font-mono whitespace-pre-wrap break-all`,children:e.join(` +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,l as a,u as o}from"./index-C9wKWOAN.js";import{t as s}from"./ConfirmModal-CIfDDoVq.js";var c=e(t(),1),l=n(),u=`rounded-lg border border-border bg-card p-5 space-y-3`,d=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,f=`rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-medium disabled:opacity-50`,p=`rounded-md border border-border px-3 py-2 text-sm disabled:opacity-50`,m=`rounded-md bg-destructive text-white px-3 py-2 text-sm font-medium disabled:opacity-50`;function h({msg:e}){return e?(0,l.jsx)(`div`,{className:`text-sm `+(e.kind===`ok`?`text-green-600`:e.kind===`err`?`text-destructive`:`text-muted-foreground`),children:e.text}):null}function g(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);return t<60?`just now`:t<3600?Math.floor(t/60)+`m ago`:t<86400?Math.floor(t/3600)+`h ago`:Math.floor(t/86400)+`d ago`}function _(){let e=o(),[t,n]=(0,c.useState)(``),[a,s]=(0,c.useState)(``),[p,m]=(0,c.useState)(``),[g,_]=(0,c.useState)(null),v=r({mutationFn:e=>i.post(`/api/auth/change-password`,e),onSuccess:t=>{_({text:t.message||`Password changed`,kind:`ok`}),n(``),s(``),m(``),e.invalidateQueries({queryKey:[`sessions`]}),t.passwordWarning&&setTimeout(()=>_({text:t.passwordWarning,kind:`info`}),2e3)},onError:e=>_({text:e.message,kind:`err`})});function y(e){if(e.preventDefault(),_(null),!t||!a)return _({text:`Fill in all fields`,kind:`err`});if(a.length<8)return _({text:`New password must be 8+ characters`,kind:`err`});if(a!==p)return _({text:`Passwords do not match`,kind:`err`});v.mutate({currentPassword:t,newPassword:a})}return(0,l.jsxs)(`section`,{className:u,"data-testid":`change-password-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Change Password`}),(0,l.jsxs)(`form`,{onSubmit:y,className:`space-y-2 max-w-sm`,children:[(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`Current password`,value:t,onChange:e=>n(e.target.value),"data-testid":`pw-current`}),(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`New password (8+ characters)`,minLength:8,value:a,onChange:e=>s(e.target.value),"data-testid":`pw-new`}),(0,l.jsx)(`input`,{type:`password`,className:d,placeholder:`Confirm new password`,minLength:8,value:p,onChange:e=>m(e.target.value),"data-testid":`pw-confirm`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`button`,{type:`submit`,disabled:v.isPending,className:f,"data-testid":`btn-change-password`,children:v.isPending?`Changing…`:`Change Password`}),(0,l.jsx)(h,{msg:g})]})]})]})}function v({codes:e,onClose:t}){return(0,l.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,children:(0,l.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-border bg-background p-5 shadow-lg space-y-3`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Save your backup codes`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each code can be used once if you lose access to your authenticator. They will not be shown again.`}),(0,l.jsx)(`pre`,{className:`bg-muted p-3 rounded text-sm font-mono whitespace-pre-wrap break-all`,children:e.join(` `)}),(0,l.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,onClick:()=>navigator.clipboard?.writeText(e.join(` `)),className:p,children:`Copy`}),(0,l.jsx)(`button`,{type:`button`,onClick:t,className:f,children:`I've saved them`})]})]})})}function y({user:e}){let t=o(),n=e.totp_enabled===!0,[g,_]=(0,c.useState)(`idle`),[y,b]=(0,c.useState)(null),[x,S]=(0,c.useState)(``),[C,w]=(0,c.useState)(``),[T,E]=(0,c.useState)(null),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(null),{data:j}=a({queryKey:[`2fa-backup-count`],queryFn:()=>i.get(`/api/auth/2fa/backup-codes/count`),enabled:n}),M=r({mutationFn:()=>i.post(`/api/auth/setup-2fa`,{}),onSuccess:e=>{b(e),_(`setup`),A(null)},onError:e=>A({text:e.message,kind:`err`})}),N=r({mutationFn:e=>i.post(`/api/auth/verify-2fa`,{code:e}),onSuccess:e=>{_(`idle`),S(``),b(null),e.backupCodes&&e.backupCodes.length&&E(e.backupCodes),t.invalidateQueries({queryKey:[`auth-me`]}),t.invalidateQueries({queryKey:[`2fa-backup-count`]}),A({text:`2FA enabled`,kind:`ok`})},onError:e=>A({text:e.message||`Invalid code`,kind:`err`})}),P=r({mutationFn:e=>i.post(`/api/auth/disable-2fa`,{password:e}),onSuccess:()=>{_(`idle`),w(``),t.invalidateQueries({queryKey:[`auth-me`]}),t.invalidateQueries({queryKey:[`2fa-backup-count`]}),A({text:`2FA disabled`,kind:`info`})},onError:e=>A({text:e.message||`Failed`,kind:`err`})}),F=r({mutationFn:e=>i.post(`/api/auth/2fa/backup-codes`,{password:e}),onSuccess:e=>{O(!1),e.codes&&e.codes.length&&E(e.codes),t.invalidateQueries({queryKey:[`2fa-backup-count`]})},onError:e=>{O(!1),A({text:e.message||`Failed to regenerate codes`,kind:`err`})}});return(0,l.jsxs)(`section`,{className:u,"data-testid":`2fa-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Two-Factor Authentication`}),(0,l.jsxs)(`p`,{className:`text-sm`,"data-testid":`2fa-status`,children:[`Status:`,` `,(0,l.jsx)(`span`,{className:n?`text-green-600 font-medium`:`text-destructive font-medium`,children:n?`✅ Enabled`:`❌ Not enabled`})]}),!n&&g===`idle`&&(0,l.jsx)(`button`,{type:`button`,className:f,onClick:()=>M.mutate(),disabled:M.isPending,"data-testid":`btn-setup-2fa`,children:M.isPending?`Setting up…`:`Enable 2FA`}),n&&g===`idle`&&(0,l.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive`,onClick:()=>_(`disabling`),"data-testid":`btn-disable-2fa`,children:`Disable 2FA`}),j&&(0,l.jsxs)(`span`,{className:`text-sm `+(j.remaining<=2?`text-orange-500`:`text-muted-foreground`),children:[j.remaining,` backup codes remaining.`]}),j&&(0,l.jsx)(`button`,{type:`button`,className:p,onClick:()=>O(!0),"data-testid":`btn-regen-backup-codes`,children:`Regenerate`})]}),g===`setup`&&y&&(0,l.jsxs)(`div`,{className:`space-y-3 p-3 bg-muted/40 rounded-md`,children:[(0,l.jsx)(`p`,{className:`text-sm`,children:`Scan this QR code with your authenticator app:`}),(0,l.jsx)(`img`,{src:y.qrCode,alt:`2FA QR code`,className:`bg-white p-2 rounded max-w-[240px]`}),(0,l.jsxs)(`p`,{className:`text-sm`,children:[`Or enter manually: `,(0,l.jsx)(`code`,{className:`bg-muted px-2 py-0.5 rounded text-xs`,children:y.secret})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,l.jsx)(`input`,{type:`text`,maxLength:6,className:d+` max-w-[140px] font-mono tracking-widest`,placeholder:`123456`,value:x,onChange:e=>S(e.target.value.replace(/\D/g,``)),"data-testid":`2fa-verify-code`}),(0,l.jsx)(`button`,{type:`button`,className:f,disabled:x.length!==6||N.isPending,onClick:()=>N.mutate(x),"data-testid":`btn-verify-2fa`,children:N.isPending?`Verifying…`:`Verify & Enable`}),(0,l.jsx)(`button`,{type:`button`,className:p,onClick:()=>{_(`idle`),b(null),S(``)},children:`Cancel`})]})]}),g===`disabling`&&(0,l.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted/40 rounded-md max-w-sm`,children:[(0,l.jsx)(`label`,{className:`block text-sm font-medium`,children:`Enter your password to confirm:`}),(0,l.jsx)(`input`,{type:`password`,className:d,value:C,onChange:e=>w(e.target.value),placeholder:`Password`,"data-testid":`2fa-disable-password`}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,className:m,disabled:!C||P.isPending,onClick:()=>P.mutate(C),"data-testid":`btn-disable-2fa-confirm`,children:P.isPending?`Disabling…`:`Confirm Disable`}),(0,l.jsx)(`button`,{type:`button`,className:p,onClick:()=>{_(`idle`),w(``)},"data-testid":`btn-disable-2fa-cancel`,children:`Cancel`})]})]}),(0,l.jsx)(h,{msg:k}),(0,l.jsx)(s,{open:D,title:`Regenerate backup codes?`,body:`This invalidates your existing codes. Enter your current password to confirm.`,confirmText:`Regenerate`,danger:!0,requirePassword:!0,passwordPlaceholder:`Current password`,busy:F.isPending,onConfirm:e=>e&&F.mutate(e),onCancel:()=>O(!1)}),T&&(0,l.jsx)(v,{codes:T,onClose:()=>E(null)})]})}function b({s:e,isCurrent:t,onRevoke:n}){return(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border-2 px-3 py-2 `+(t?`border-primary bg-primary/5`:`border-border bg-muted/40`),"data-testid":`session-row-`+e.id,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsxs)(`div`,{className:`text-sm font-medium truncate`,children:[e.device_label||`Unknown device`,t&&(0,l.jsx)(`span`,{className:`ml-2 text-xs text-primary font-medium`,children:`(this device)`})]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e.ip_address||`—`,` · Created `,new Date(e.created_at).toLocaleDateString(),` · Active `,g(e.last_activity)]})]}),!t&&(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:n,"data-testid":`btn-revoke-session-`+e.id,children:`Revoke`})]})}function x(){let e=o(),[t,n]=(0,c.useState)(null),[d,f]=(0,c.useState)(null),{data:m,isLoading:g,error:_}=a({queryKey:[`sessions`],queryFn:()=>i.get(`/api/sessions`)}),v=r({mutationFn:e=>i.delete(`/api/sessions/`+e),onSuccess:()=>{f({text:`Session revoked`,kind:`info`}),e.invalidateQueries({queryKey:[`sessions`]})},onError:e=>f({text:e.message,kind:`err`})}),y=r({mutationFn:()=>i.delete(`/api/sessions`),onSuccess:t=>{f({text:`All other sessions revoked (`+(t.revoked||0)+` removed)`,kind:`info`}),e.invalidateQueries({queryKey:[`sessions`]})},onError:e=>f({text:e.message,kind:`err`})}),x=v.isPending||y.isPending;return(0,l.jsxs)(`section`,{className:u,"data-testid":`sessions-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Active Sessions`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Devices where you are currently logged in. Revoke any session to immediately log that device out.`}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:()=>n({kind:`all`}),"data-testid":`btn-revoke-all-sessions`,children:`Revoke All Other Sessions`}),g&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading sessions…`}),_&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:`Could not load sessions.`}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[m?.sessions.map(e=>(0,l.jsx)(b,{s:e,isCurrent:e.id===m.currentSessionId,onRevoke:()=>n({kind:`one`,id:e.id})},e.id)),m&&m.sessions.length===0&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No active sessions found.`})]}),(0,l.jsx)(h,{msg:d}),(0,l.jsx)(s,{open:t?.kind===`one`,title:`Revoke this session?`,body:`That device will be logged out.`,confirmText:`Revoke`,danger:!0,busy:x,onConfirm:()=>{t?.kind===`one`&&v.mutate(t.id),n(null)},onCancel:()=>n(null)}),(0,l.jsx)(s,{open:t?.kind===`all`,title:`Revoke all other sessions?`,body:`All other devices will be logged out.`,confirmText:`Revoke All`,danger:!0,busy:x,onConfirm:()=>{y.mutate(),n(null)},onCancel:()=>n(null)})]})}function S({user:e}){let t=o(),n=!!e.nextcloud_url,[a,m]=(0,c.useState)(e.nextcloud_url||``),[g,_]=(0,c.useState)(e.nextcloud_user||``),[v,y]=(0,c.useState)(``),[b,x]=(0,c.useState)(e.webdav_learning_path||``),[S,C]=(0,c.useState)(!1),[w,T]=(0,c.useState)(null),E=r({mutationFn:e=>i.post(`/api/nextcloud/connect`,e),onSuccess:e=>{T({text:e.message||`Connected`,kind:`ok`}),y(``),t.invalidateQueries({queryKey:[`auth-me`]})},onError:e=>T({text:e.message||`Connection failed`,kind:`err`})}),D=r({mutationFn:()=>i.post(`/api/nextcloud/disconnect`,{}),onSuccess:()=>{T({text:`Disconnected`,kind:`info`}),y(``),t.invalidateQueries({queryKey:[`auth-me`]})},onError:e=>T({text:e.message,kind:`err`})}),O=r({mutationFn:e=>i.post(`/api/user/webdav-path`,{path:e}),onSuccess:()=>{T({text:`Path saved`,kind:`ok`}),t.invalidateQueries({queryKey:[`auth-me`]})},onError:e=>T({text:e.message||`Failed to save`,kind:`err`})});function k(e){e.preventDefault(),T(null);let t=a.trim().replace(/\/+$/,``),n=g.trim(),r=v.trim();if(!t||!n||!r)return T({text:`Fill all Nextcloud fields`,kind:`err`});E.mutate({nextcloudUrl:t,username:n,appPassword:r})}return(0,l.jsxs)(`section`,{className:u,"data-testid":`nextcloud-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Nextcloud Integration`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Export generated documents to your Nextcloud.`}),(0,l.jsx)(`div`,{className:`text-sm`,"data-testid":`nc-status`,children:n?(0,l.jsxs)(l.Fragment,{children:[`✅ Connected to `,(0,l.jsx)(`strong`,{children:e.nextcloud_url}),` as `,e.nextcloud_user]}):(0,l.jsx)(l.Fragment,{children:`Not connected`})}),(0,l.jsxs)(`form`,{onSubmit:k,className:`space-y-2 max-w-md`,children:[(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`Nextcloud URL`}),(0,l.jsx)(`input`,{type:`url`,className:d,value:a,onChange:e=>m(e.target.value),placeholder:`https://cloud.example.com`,"data-testid":`nc-url`})]}),(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`Username`}),(0,l.jsx)(`input`,{type:`text`,className:d,value:g,onChange:e=>_(e.target.value),placeholder:`your-username`,"data-testid":`nc-user`})]}),(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`App Password`}),(0,l.jsx)(`input`,{type:`password`,className:d,value:v,onChange:e=>y(e.target.value),placeholder:`Generate in Nextcloud → Settings → Security`,"data-testid":`nc-pass`}),(0,l.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-1`,children:`Go to Nextcloud → Settings → Security → Create new app password`})]}),(0,l.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,l.jsx)(`button`,{type:`submit`,className:f,disabled:E.isPending,"data-testid":`btn-nc-connect`,children:E.isPending?`Connecting…`:n?`Reconnect`:`Connect`}),n&&(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive`,onClick:()=>C(!0),"data-testid":`btn-nc-disconnect`,children:`Disconnect`})]})]}),n&&(0,l.jsx)(`div`,{className:`border-t border-border pt-3 space-y-2 max-w-md`,children:(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`Learning Hub — Default Browse Path`}),(0,l.jsxs)(`span`,{className:`block text-xs text-muted-foreground mb-2`,children:[`Folder opened first when picking files for AI content generation (e.g. `,(0,l.jsx)(`code`,{children:`/Medical-Resources`}),`)`]}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`text`,className:d,value:b,onChange:e=>x(e.target.value),placeholder:`/Medical-Resources`,"data-testid":`nc-webdav-path`}),(0,l.jsx)(`button`,{type:`button`,className:f,disabled:O.isPending,onClick:()=>O.mutate(b.trim()),"data-testid":`btn-nc-save-path`,children:O.isPending?`Saving…`:`Save Path`})]})]})}),(0,l.jsx)(h,{msg:w}),(0,l.jsx)(s,{open:S,title:`Disconnect Nextcloud?`,body:`Future exports will fail until you reconnect. Your stored credentials will be cleared.`,confirmText:`Disconnect`,danger:!0,busy:D.isPending,onConfirm:()=>{D.mutate(),C(!1)},onCancel:()=>C(!1)})]})}function C(e){return e<1024?e+` B`:e<1048576?Math.round(e/1024)+` KB`:(e/1048576).toFixed(1)+` MB`}function w({doc:e,onDownload:t,onDelete:n,downloading:r}){return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md bg-muted/40 border border-border`,"data-testid":`doc-row-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.filename}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[C(e.size_bytes),` · `,new Date(e.created_at).toLocaleDateString(),e.description?` · `+e.description:``]})]}),(0,l.jsx)(`button`,{type:`button`,className:f+` text-xs`,disabled:r,onClick:t,"data-testid":`btn-doc-download-`+e.id,children:r?`…`:`Download`}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:n,"data-testid":`btn-doc-delete-`+e.id,children:`Delete`})]})}function T(){let e=o(),[t,n]=(0,c.useState)(null),[p,m]=(0,c.useState)(``),[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(null),{data:b,isLoading:x,error:S}=a({queryKey:[`documents`],queryFn:()=>i.get(`/api/documents`)}),C=r({mutationFn:async e=>{let t=new FormData;t.append(`file`,e.file),t.append(`description`,e.description);let n=await fetch(`/api/documents/upload`,{method:`POST`,credentials:`include`,body:t}),r=(n.headers.get(`content-type`)||``).includes(`application/json`)?await n.json():null;if(!n.ok||r&&r.success===!1)throw Error(r&&r.error||n.statusText);return r},onSuccess:t=>{_({text:`Document uploaded: `+t.filename,kind:`ok`}),n(null),m(``),e.invalidateQueries({queryKey:[`documents`]})},onError:e=>_({text:`Upload failed: `+e.message,kind:`err`})}),T=r({mutationFn:e=>i.delete(`/api/documents/`+e),onSuccess:()=>{_({text:`Document deleted`,kind:`info`}),e.invalidateQueries({queryKey:[`documents`]})},onError:e=>_({text:e.message||`Delete failed`,kind:`err`})}),E=r({mutationFn:e=>i.get(`/api/documents/`+e+`/download`),onSuccess:e=>{e.url?window.open(e.url,`_blank`,`noopener,noreferrer`):_({text:`Download failed`,kind:`err`})},onError:e=>_({text:e.message||`Download failed`,kind:`err`})});function D(e){if(e.preventDefault(),_(null),!t)return _({text:`Select a file first`,kind:`err`});C.mutate({file:t,description:p})}return(0,l.jsxs)(`section`,{className:u,"data-testid":`documents-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Documents`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Upload and manage documents via S3 storage (PDF, images, Word docs, text files). Max 10 MB per file.`}),x&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),S&&(0,l.jsx)(`div`,{className:`text-sm text-destructive`,children:`Failed to load documents.`}),b&&!b.s3_configured&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground italic`,children:`S3 storage not configured. Set S3_BUCKET in server environment.`}),b&&b.s3_configured&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`form`,{onSubmit:D,className:`flex flex-wrap gap-2 items-center`,"data-testid":`doc-upload-area`,children:[(0,l.jsx)(`input`,{type:`file`,className:`text-sm`,accept:`.pdf,.jpg,.jpeg,.png,.gif,.doc,.docx,.txt,.csv`,onChange:e=>n(e.target.files?.[0]??null),"data-testid":`doc-file-input`}),(0,l.jsx)(`input`,{type:`text`,className:d+` max-w-xs`,placeholder:`Description (optional)`,value:p,onChange:e=>m(e.target.value),"data-testid":`doc-description`}),(0,l.jsx)(`button`,{type:`submit`,className:f,disabled:!t||C.isPending,"data-testid":`btn-doc-upload`,children:C.isPending?`Uploading…`:`Upload`})]}),(0,l.jsx)(`div`,{className:`space-y-2`,children:b.documents.length===0?(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No documents uploaded yet.`}):b.documents.map(e=>(0,l.jsx)(w,{doc:e,onDownload:()=>E.mutate(e.id),onDelete:()=>y(e),downloading:E.isPending&&E.variables===e.id},e.id))})]}),(0,l.jsx)(h,{msg:g}),(0,l.jsx)(s,{open:!!v,title:`Delete this document permanently?`,body:v?.filename,confirmText:`Delete`,danger:!0,busy:T.isPending,onConfirm:()=>{v&&T.mutate(v.id),y(null)},onCancel:()=>y(null)})]})}function E(){let e=o(),[t,n]=(0,c.useState)(null),[s,m]=(0,c.useState)(``),[g,_]=(0,c.useState)(``),[v,y]=(0,c.useState)(!1),[b,x]=(0,c.useState)(!1),{data:S}=a({queryKey:[`voice-options`],queryFn:()=>i.get(`/api/user/preferences/options`)}),{data:C}=a({queryKey:[`voice-prefs`],queryFn:()=>i.get(`/api/user/preferences`)});!b&&C&&(m(C.stt_model||``),_(C.tts_voice||``),x(!0));let w=r({mutationFn:e=>i.post(`/api/user/preferences`,e),onSuccess:()=>{n({text:`Voice preferences saved`,kind:`ok`}),e.invalidateQueries({queryKey:[`voice-prefs`]})},onError:e=>n({text:e.message||`Save failed`,kind:`err`})});async function T(){n(null),y(!0);try{await i.post(`/api/user/preferences`,{tts_voice:g||null}),e.invalidateQueries({queryKey:[`voice-prefs`]});let t=`Hello, this is a preview of the `+(g||`server default`)+` voice. This is how your read-aloud feature will sound.`,n=await fetch(`/api/text-to-speech`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(!n.ok)throw Error(`Preview failed`);let r=await n.blob(),a=URL.createObjectURL(r),o=new Audio(a);o.onended=()=>URL.revokeObjectURL(a),await o.play()}catch(e){n({text:`Preview failed: `+e.message,kind:`err`})}finally{y(!1)}}return(0,l.jsxs)(`section`,{className:u,"data-testid":`voice-preferences-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Voice Preferences`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Customize your speech-to-text model and text-to-speech voice. These settings apply to all recording and read-aloud features.`}),(0,l.jsxs)(`div`,{className:`space-y-2 max-w-md`,children:[(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`Speech-to-Text Model (Transcription)`}),(0,l.jsxs)(`select`,{className:d,value:s,onChange:e=>m(e.target.value),"data-testid":`stt-model-select`,children:[(0,l.jsxs)(`option`,{value:``,children:[`Server default`,S?` (`+S.sttProvider+`)`:``]}),S?.sttModels.map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,l.jsxs)(`label`,{className:`block text-sm`,children:[(0,l.jsx)(`span`,{className:`block text-xs font-semibold text-muted-foreground mb-1`,children:`Text-to-Speech Voice (Read Aloud)`}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsxs)(`select`,{className:d,value:g,onChange:e=>_(e.target.value),"data-testid":`tts-voice-select`,children:[(0,l.jsxs)(`option`,{value:``,children:[`Server default`,S?` (`+S.ttsProvider+`)`:``]}),S?.ttsVoices.map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,l.jsx)(`button`,{type:`button`,className:p,disabled:v,onClick:T,"data-testid":`btn-preview-voice`,children:v?`Loading…`:`Preview`})]})]}),(0,l.jsx)(`button`,{type:`button`,className:f,disabled:w.isPending,onClick:()=>w.mutate({stt_model:s||null,tts_voice:g||null}),"data-testid":`btn-save-voice-prefs`,children:w.isPending?`Saving…`:`Save Voice Preferences`})]}),(0,l.jsx)(h,{msg:t})]})}var D=`ped_browser_whisper_enabled`,O=`ped_browser_whisper_model`,k=[{value:`Xenova/whisper-tiny.en`,label:`Tiny (~39MB) — fastest, ~2-3s`},{value:`Xenova/whisper-base.en`,label:`Base (~74MB) — balanced, ~3-5s`},{value:`Xenova/whisper-small.en`,label:`Small (~244MB) — best quality, ~6-10s`}];function A(e,t=``){try{return window.localStorage.getItem(e)??t}catch{return t}}function j(e,t){try{window.localStorage.setItem(e,t)}catch{}}function M(){let[e,t]=(0,c.useState)(A(D)===`true`),[n,r]=(0,c.useState)(A(O)||k[0].value);function i(e){t(e),j(D,String(e))}function a(e){r(e),j(O,e)}return(0,l.jsxs)(`section`,{className:u,"data-testid":`browser-whisper-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Browser Transcription (Local Whisper)`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Transcribes audio entirely in your browser — no audio sent to any server. Powered by OpenAI Whisper running in WebAssembly. Model is downloaded once and cached locally.`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:`Enable browser transcription:`}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-primary size-4`,checked:e,onChange:e=>i(e.target.checked),"data-testid":`browser-whisper-enabled`}),(0,l.jsx)(`span`,{className:`text-sm`,"data-testid":`browser-whisper-status`,children:e?`On — audio stays on device`:`Off`})]})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:`Model:`}),(0,l.jsx)(`select`,{className:d+` max-w-md`,value:n,onChange:e=>a(e.target.value),"data-testid":`browser-whisper-model`,children:k.map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`When enabled, overrides server transcription. Falls back to server if browser transcription fails. The actual WASM download runs from the recording components — pre-download will light up when those port to React.`})]})}var N=`ped_web_speech_enabled`;function P(){let[e,t]=(0,c.useState)(A(N)===`true`),[n,r]=(0,c.useState)(!1),i=typeof window<`u`&&(`webkitSpeechRecognition`in window||`SpeechRecognition`in window);function a(){j(D,`false`),t(!0),j(N,`true`)}function o(){t(!1),j(N,`false`)}return(0,l.jsxs)(`section`,{className:u+` border-l-4 border-l-orange-500`,"data-testid":`web-speech-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Real-Time Streaming Transcription`}),(0,l.jsxs)(`div`,{className:`bg-orange-50 dark:bg-orange-950/30 p-3 rounded-md text-sm text-orange-900 dark:text-orange-100`,children:[(0,l.jsx)(`strong`,{children:`Privacy Warning:`}),` Uses your browser's built-in speech recognition, which `,(0,l.jsx)(`strong`,{children:`may send audio to cloud servers`}),` (Chrome/Edge send to Google). Only enable if you accept this trade-off for real-time transcription.`]}),(0,l.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`See words appear as you speak (streaming). Overrides browser and server transcription when enabled. `,(0,l.jsx)(`strong`,{children:`Not HIPAA-compliant`}),` in most browsers.`]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:`Enable real-time streaming:`}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,l.jsx)(`input`,{type:`checkbox`,className:`accent-orange-500 size-4`,checked:e,disabled:!i,onChange:e=>{e.target.checked?r(!0):o()},"data-testid":`web-speech-enabled`}),(0,l.jsx)(`span`,{className:`text-sm`,"data-testid":`web-speech-status`,children:i?e?`On — real-time streaming`:`Off`:`Not supported in this browser`})]})]}),i&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Streaming integration lights up when the recording components port to React.`}),(0,l.jsx)(s,{open:n,title:`Enable real-time streaming transcription?`,body:`Your browser's speech recognition may send audio to cloud servers (e.g. Google). This is NOT HIPAA-compliant. Only enable if you understand and accept this privacy trade-off.`,confirmText:`Enable`,danger:!0,onConfirm:()=>{a(),r(!1)},onCancel:()=>r(!1)})]})}var F=[{value:`physical_exam`,label:`Physical Exam Template`},{value:`ros`,label:`Review of Systems Template`},{value:`encounter_format`,label:`Encounter Note Format`},{value:`family_history`,label:`Family History Format`},{value:`assessment_plan`,label:`Assessment & Plan Format`},{value:`template_soap`,label:`SOAP Note Template`},{value:`template_hpi`,label:`HPI Template`},{value:`template_wellvisit`,label:`Well Visit Template`},{value:`template_sickvisit`,label:`Sick Visit Template`},{value:`custom`,label:`Custom`}],I=Object.fromEntries(F.map(e=>[e.value,e.label.replace(/ Template$| Format$/,``)]));function L(){let e=o(),[t,n]=(0,c.useState)(null),[m,g]=(0,c.useState)(null),[_,v]=(0,c.useState)(F[0].value),[y,b]=(0,c.useState)(``),[x,S]=(0,c.useState)(``),[C,w]=(0,c.useState)(null),{data:T}=a({queryKey:[`memories`],queryFn:()=>i.get(`/api/memories`)}),E=(T?.memories||[]).filter(e=>!e.category.startsWith(`correction_`)),D=r({mutationFn:e=>{let{id:t,...n}=e;return t?i.put(`/api/memories/`+t,n):i.post(`/api/memories`,n)},onSuccess:()=>{n({text:m?`Template updated`:`Template saved`,kind:`ok`}),g(null),b(``),S(``),e.invalidateQueries({queryKey:[`memories`]})},onError:e=>n({text:e.message||`Save failed`,kind:`err`})}),O=r({mutationFn:e=>i.delete(`/api/memories/`+e),onSuccess:()=>{n({text:`Template deleted`,kind:`info`}),e.invalidateQueries({queryKey:[`memories`]})},onError:e=>n({text:e.message||`Delete failed`,kind:`err`})});function k(e){g(e.id),v(e.category),b(e.name),S(e.content)}function A(){g(null),b(``),S(``)}function j(e){if(e.preventDefault(),n(null),!y.trim())return n({text:`Enter a template name`,kind:`err`});if(!x.trim())return n({text:`Enter template content`,kind:`err`});D.mutate({id:m??void 0,category:_,name:y.trim(),content:x.trim()})}return(0,l.jsxs)(`section`,{className:u,"data-testid":`templates-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`My Templates`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Save reusable templates for physical exam, ROS, encounter format, etc. The AI will use these when generating notes.`}),(0,l.jsxs)(`form`,{onSubmit:j,className:`space-y-2`,children:[(0,l.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,l.jsx)(`select`,{className:d+` max-w-xs`,value:_,onChange:e=>v(e.target.value),"data-testid":`mem-category`,children:F.map(e=>(0,l.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,l.jsx)(`input`,{type:`text`,className:d+` flex-1 min-w-[150px]`,placeholder:`Template name (e.g. Normal PE)`,value:y,onChange:e=>b(e.target.value),"data-testid":`mem-name`})]}),(0,l.jsx)(`textarea`,{rows:5,className:d+` resize-y`,placeholder:`Paste your template here. Example: HEENT: Normocephalic, atraumatic. Eyes: PERRL…`,value:x,onChange:e=>S(e.target.value),"data-testid":`mem-content`}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(`button`,{type:`submit`,className:f,disabled:D.isPending,"data-testid":`btn-mem-save`,children:D.isPending?`Saving…`:m?`Update Template`:`Add Template`}),m!==null&&(0,l.jsx)(`button`,{type:`button`,className:p,onClick:A,children:`Cancel`})]})]}),(0,l.jsx)(`div`,{className:`space-y-2`,children:E.length===0?(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No templates saved yet. Add one above.`}):E.map(e=>(0,l.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md bg-muted/40 border border-border`,"data-testid":`mem-row-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,l.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:I[e.category]||e.category})]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[(e.content||``).slice(0,100).replace(/\n/g,` `),e.content&&e.content.length>100?`…`:``]})]}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-xs`,onClick:()=>k(e),"data-testid":`btn-mem-edit-`+e.id,children:`Edit`}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:()=>w(e),"data-testid":`btn-mem-delete-`+e.id,children:`Delete`})]},e.id))}),(0,l.jsx)(h,{msg:t}),(0,l.jsx)(s,{open:!!C,title:`Delete template "`+(C?.name||``)+`"?`,body:`This cannot be undone.`,confirmText:`Delete`,danger:!0,busy:O.isPending,onConfirm:()=>{C&&O.mutate(C.id),w(null)},onCancel:()=>w(null)})]})}var R={correction_soap:`SOAP Correction`,correction_hpi:`HPI Correction`,correction_encounter:`Encounter Correction`,correction_wellvisit:`Well Visit Correction`,correction_sickvisit:`Sick Visit Correction`};function z(e){let t=e.indexOf(` CORRECTED TO: `);return t===-1?{original:e.trim(),corrected:``}:{original:e.substring(0,t).replace(/^ORIGINAL:\s*/i,``).trim(),corrected:e.substring(t+15).trim()}}function B(){let e=o(),[t,n]=(0,c.useState)({}),[d,f]=(0,c.useState)(null),[p,m]=(0,c.useState)(null),{data:g}=a({queryKey:[`memories`],queryFn:()=>i.get(`/api/memories`)}),_=(g?.memories||[]).filter(e=>e.category.startsWith(`correction_`)),v=r({mutationFn:e=>i.delete(`/api/memories/`+e),onSuccess:()=>{f({text:`Correction deleted`,kind:`info`}),e.invalidateQueries({queryKey:[`memories`]})},onError:e=>f({text:e.message||`Delete failed`,kind:`err`})});return(0,l.jsxs)(`section`,{className:u,"data-testid":`corrections-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`AI Learning (Corrections)`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The AI automatically learns from your edits. When you modify AI-generated text and save, corrections are stored here and applied to future notes. Latest 20 per section.`}),(0,l.jsx)(`div`,{className:`space-y-2`,children:_.length===0?(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No corrections yet. Edit AI-generated notes and save to start learning.`}):_.map(e=>{let r=t[e.id],i=z(e.content||``),a=e.created_at?new Date(e.created_at).toLocaleDateString():``;return(0,l.jsxs)(`div`,{className:`rounded-md bg-muted/40 border border-border overflow-hidden`,"data-testid":`corr-row-`+e.id,children:[(0,l.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left`,onClick:()=>n({...t,[e.id]:!r}),children:[(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r?`▾`:`▸`}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:R[e.category]||e.category}),(0,l.jsx)(`span`,{className:`flex-1 text-sm truncate`,children:e.name}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a}),(0,l.jsx)(`span`,{role:`button`,className:`text-destructive text-xs px-2`,onClick:t=>{t.stopPropagation(),m(e)},"data-testid":`btn-corr-delete-`+e.id,children:`Delete`})]}),r&&(0,l.jsxs)(`div`,{className:`px-3 py-2 text-sm space-y-2 border-t border-border`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`text-xs font-semibold uppercase text-destructive mb-1`,children:`Original (AI generated):`}),(0,l.jsx)(`div`,{className:`whitespace-pre-wrap text-muted-foreground`,children:i.original})]}),i.corrected&&(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`text-xs font-semibold uppercase text-green-600 mb-1`,children:`Corrected to:`}),(0,l.jsx)(`div`,{className:`whitespace-pre-wrap`,children:i.corrected})]})]})]},e.id)})}),(0,l.jsx)(h,{msg:d}),(0,l.jsx)(s,{open:!!p,title:`Delete this correction?`,body:`The AI will no longer apply this edit in future notes.`,confirmText:`Delete`,danger:!0,busy:v.isPending,onConfirm:()=>{p&&v.mutate(p.id),m(null)},onCancel:()=>m(null)})]})}function V(){let e=o(),[t,n]=(0,c.useState)(null),[d,m]=(0,c.useState)(null),{data:_,isLoading:v}=a({queryKey:[`audio-backups`],queryFn:()=>i.get(`/api/audio-backups`)}),y=r({mutationFn:e=>i.delete(`/api/audio-backups/`+e),onSuccess:()=>{n({text:`Backup deleted`,kind:`info`}),e.invalidateQueries({queryKey:[`audio-backups`]})},onError:e=>n({text:e.message,kind:`err`})});function b(e){window.open(`/api/audio-backups/`+e+`/audio`,`_blank`,`noopener,noreferrer`)}return(0,l.jsxs)(`section`,{className:u,"data-testid":`audio-backups-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Audio Backups`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recordings are automatically backed up on the server and kept for 24 hours. Retry flow ports with the recording components.`}),v&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[_&&_.backups.length===0&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No audio backups.`}),_?.backups.map(e=>{let t=Math.round(e.size_bytes/1024),n=e.compressed_bytes?` (`+Math.round(e.compressed_bytes/1024)+` KB compressed)`:``;return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md bg-muted/40 border border-border`,"data-testid":`audio-backup-row-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.module,` recording`]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[new Date(e.created_at).toLocaleString(),` · `,t,` KB`,n,` · `,g(e.created_at)]})]}),(0,l.jsx)(`button`,{type:`button`,className:f+` text-xs`,onClick:()=>b(e.id),children:`Play`}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:()=>m(e),"data-testid":`btn-audio-delete-`+e.id,children:`Delete`})]},e.id)})]}),(0,l.jsx)(h,{msg:t}),(0,l.jsx)(s,{open:!!d,title:`Delete this audio backup?`,body:`This cannot be undone.`,confirmText:`Delete`,danger:!0,busy:y.isPending,onConfirm:()=>{d&&y.mutate(d.id),m(null)},onCancel:()=>m(null)})]})}function H(){let e=o(),[t,n]=(0,c.useState)(null),[d,f]=(0,c.useState)(null),{data:m,isLoading:g}=a({queryKey:[`saved-encounters`],queryFn:()=>i.get(`/api/encounters/saved`)}),_=r({mutationFn:e=>i.delete(`/api/encounters/saved/`+e),onSuccess:()=>{n({text:`Deleted`,kind:`info`}),e.invalidateQueries({queryKey:[`saved-encounters`]})},onError:e=>n({text:e.message,kind:`err`})});return(0,l.jsxs)(`section`,{className:u,"data-testid":`saved-encounters-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Saved Encounters`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Encounters are automatically deleted after 7 days per site policy. Resume action ports with the encounter components.`}),g&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),(0,l.jsxs)(`div`,{className:`space-y-2`,children:[m&&m.encounters.length===0&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No saved encounters.`}),m?.encounters.map(e=>{let t=new Date(e.updated_at).toLocaleDateString(),n=new Date(e.expires_at).toLocaleDateString(),r=(e.transcript_preview||``).slice(0,80);return(0,l.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md bg-muted/40 border border-border`,"data-testid":`enc-row-`+e.id,children:[(0,l.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,l.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,l.jsx)(`span`,{className:`font-medium truncate`,children:e.label||`Untitled`}),(0,l.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase tracking-wide`,children:e.enc_type})]}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[t,` · expires `,n,r?` · `+r+`…`:``]})]}),(0,l.jsx)(`button`,{type:`button`,className:p+` text-destructive text-xs`,onClick:()=>f(e),"data-testid":`btn-enc-delete-`+e.id,children:`Delete`})]},e.id)})]}),(0,l.jsx)(h,{msg:t}),(0,l.jsx)(s,{open:!!d,title:`Delete this saved encounter?`,body:d?.label||void 0,confirmText:`Delete`,danger:!0,busy:_.isPending,onConfirm:()=>{d&&_.mutate(d.id),f(null)},onCancel:()=>f(null)})]})}function U(){return(0,l.jsxs)(`section`,{className:u,"data-testid":`compliance-section`,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Compliance & Usage`}),(0,l.jsxs)(`div`,{className:`text-sm space-y-2`,children:[(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:`AWS Bedrock`}),` is available with a Business Associate Agreement (BAA) for HIPAA-eligible workloads.`]}),(0,l.jsxs)(`ul`,{className:`list-disc pl-5 space-y-1 text-muted-foreground`,children:[(0,l.jsx)(`li`,{children:`All connections use HTTPS/TLS encryption`}),(0,l.jsx)(`li`,{children:`Authentication with optional 2FA`}),(0,l.jsx)(`li`,{children:`No patient data stored on server beyond session`}),(0,l.jsx)(`li`,{children:`AWS Bedrock supports BAA for HIPAA compliance`}),(0,l.jsx)(`li`,{children:`Azure OpenAI supports BAA for HIPAA compliance`})]}),(0,l.jsxs)(`p`,{children:[(0,l.jsx)(`strong`,{children:`Important:`}),` Check with your institution's guidelines and policies before use. This tool is not intended for production clinical use without proper organizational authorization and provider BAAs in place. Use with caution.`]})]})]})}function W(){let{data:e,isLoading:t,error:n}=a({queryKey:[`auth-me`],queryFn:()=>i.get(`/api/auth/me`)}),r=e?.user.canLocalAuth!==!1;return(0,l.jsxs)(`div`,{className:`max-w-3xl mx-auto p-6 space-y-4`,children:[(0,l.jsxs)(`header`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Settings`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Account security, integrations, and personal templates. More sub-sections port over in follow-up commits.`})]}),t&&(0,l.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),n&&(0,l.jsxs)(`div`,{className:`text-sm text-destructive`,children:[`Could not load your account: `,n.message]}),e&&r&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(_,{}),(0,l.jsx)(y,{user:e.user}),(0,l.jsx)(x,{})]}),e&&!r&&(0,l.jsxs)(`section`,{className:u,children:[(0,l.jsx)(`h3`,{className:`text-base font-semibold`,children:`Account managed by single sign-on`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your password and two-factor authentication are managed by your identity provider.`})]}),e&&(0,l.jsx)(S,{user:e.user}),e&&(0,l.jsx)(T,{}),e&&(0,l.jsx)(E,{}),e&&(0,l.jsx)(M,{}),e&&(0,l.jsx)(P,{}),e&&(0,l.jsx)(L,{}),e&&(0,l.jsx)(B,{}),e&&(0,l.jsx)(V,{}),e&&(0,l.jsx)(H,{}),(0,l.jsx)(U,{})]})}export{W as default}; \ No newline at end of file diff --git a/public/app/assets/Shadess-DU9cvMlg.js b/public/app/assets/Shadess-DU9cvMlg.js new file mode 100644 index 0000000..2dec1c5 --- /dev/null +++ b/public/app/assets/Shadess-DU9cvMlg.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-C9wKWOAN.js";import{t as a}from"./OutputActions-6XZlmtIw.js";import{t as o}from"./Recorder-DdXTjnSC.js";var s=e(t(),1),c=n(),l=[{key:`strengths`,label:`Strengths`,icon:`⭐`,color:`#f59e0b`,intro:`Starting with what you do well helps us get to know you better.`,questions:[{id:`str1`,text:`Has something they are proud of or enjoy`,type:`yn`},{id:`str2`,text:`Describes self positively when asked`,type:`yn`},{id:`str3`,text:`Has at least one trusted adult they can talk to`,type:`yn`}]},{key:`school`,label:`School`,icon:`🎓`,color:`#3b82f6`,intro:`Ask about school performance, attendance, and future plans.`,questions:[{id:`sch1`,text:`Grades are satisfactory / doing their best`,type:`yn`},{id:`sch2`,text:`Likes school or finds something enjoyable about it`,type:`yn`},{id:`sch3`,text:`Regular attendance (no truancy concerns)`,type:`yn`},{id:`sch4`,text:`Has plans or goals for the future`,type:`yn`}]},{key:`home`,label:`Home`,icon:`🏠`,color:`#10b981`,intro:`Ask about living situation and family relationships.`,questions:[{id:`hom1`,text:`Stable living situation`,type:`yn`},{id:`hom2`,text:`Gets along with people at home`,type:`yn`},{id:`hom3`,text:`Would talk to family member if stressed`,type:`yn`},{id:`hom4`,text:`Has experienced household violence or instability (concern if YES)`,type:`yn`,concern_if:!0}]},{key:`activities`,label:`Activities`,icon:`👥`,color:`#8b5cf6`,intro:`Ask about friends, hobbies, and peer relationships.`,questions:[{id:`act1`,text:`Has friends and spends time with them`,type:`yn`},{id:`act2`,text:`Involved in sports, clubs, or hobbies`,type:`yn`},{id:`act3`,text:`Social media/screen use within healthy limits`,type:`yn`},{id:`act4`,text:`Has experienced bullying (concern if YES)`,type:`yn`,concern_if:!0}]},{key:`drugs`,label:`Drugs / Substances`,icon:`💊`,color:`#ef4444`,intro:`This is confidential. Ask in private.`,questions:[{id:`drg1`,text:`Has tried cigarettes / vaping / tobacco`,type:`yn`,concern_if:!0},{id:`drg2`,text:`Has tried alcohol`,type:`yn`,concern_if:!0},{id:`drg3`,text:`Has tried marijuana or other drugs`,type:`yn`,concern_if:!0},{id:`drg4`,text:`Friends use substances`,type:`yn`},{id:`drg5`,text:`CRAFFT screen result (if done)`,type:`text`,placeholder:`e.g., Score 0 — low risk`}]},{key:`emotions`,label:`Emotions / Eating`,icon:`❤️`,color:`#ec4899`,intro:`Screen for depression, anxiety, and disordered eating.`,questions:[{id:`emo1`,text:`Feeling down, sad, or hopeless recently`,type:`yn`,concern_if:!0},{id:`emo2`,text:`Feeling unusually stressed or anxious`,type:`yn`,concern_if:!0},{id:`emo3`,text:`Trouble sleeping`,type:`yn`},{id:`emo4`,text:`PHQ-A / depression screen result (if done)`,type:`text`,placeholder:`e.g., PHQ-A score 3 — minimal`},{id:`emo5`,text:`Happy with eating habits and body image`,type:`yn`},{id:`emo6`,text:`Restricting food / purging / using diet pills (concern if YES)`,type:`yn`,concern_if:!0}]},{key:`sexuality`,label:`Sexuality`,icon:`🛡️`,color:`#f97316`,intro:`Ask in private. Normalize the questions.`,questions:[{id:`sex1`,text:`Comfortable discussing attraction/identity`,type:`yn`},{id:`sex2`,text:`Sexually active`,type:`yn`},{id:`sex3`,text:`Uses protection consistently if sexually active`,type:`yn`},{id:`sex4`,text:`History of unwanted sexual contact (concern if YES)`,type:`yn`,concern_if:!0},{id:`sex5`,text:`STI screening indicated/done`,type:`yn`}]},{key:`safety`,label:`Safety`,icon:`🛡`,color:`#6366f1`,intro:`Ask about violence, weapons, and suicidal ideation.`,questions:[{id:`saf1`,text:`Feels safe at school and home`,type:`yn`},{id:`saf2`,text:`Carries a weapon (concern if YES)`,type:`yn`,concern_if:!0},{id:`saf3`,text:`Has been in physical fights recently`,type:`yn`,concern_if:!0},{id:`saf4`,text:`Wears seatbelt; safe driving practices`,type:`yn`},{id:`saf5`,text:`Thoughts of hurting self or suicide (concern if YES — STAT eval)`,type:`yn`,concern_if:!0},{id:`saf6`,text:`Columbia/ASQ suicide screen result (if done)`,type:`text`,placeholder:`e.g., ASQ: negative`}]}],u=`rounded-md border border-input bg-background px-3 py-2 text-sm`,d=`inline-flex items-center gap-1 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium hover:bg-muted disabled:opacity-50`,f=`inline-flex items-center gap-1 rounded-md bg-primary text-primary-foreground px-3 py-2 text-sm font-semibold disabled:opacity-50`;function p(){let e={};return l.forEach(t=>{e[t.key]={questions:{},comment:``,concern:!1,skipped:!1}}),e}function m(){let[e,t]=(0,s.useState)(``),[n,m]=(0,s.useState)(``),[h,g]=(0,s.useState)(p),[_,v]=(0,s.useState)(``),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)(null),[C,w]=(0,s.useState)(null),T=r({mutationFn:async()=>{let t={};if(l.forEach(e=>{let n=h[e.key],r=e.questions.map(e=>({id:e.id,text:e.text,answer:n.questions[e.id]||``})).filter(e=>e.answer!==``);t[e.key]={skipped:n.skipped,comment:n.comment,concern:n.concern,questions:r}}),!Object.values(t).some(e=>!e.skipped&&(e.questions.length>0||e.comment))&&!_.trim())throw Error(`Fill in at least one domain or dictate something`);return i.post(`/api/well-visit/shadess`,{patientAge:e,patientGender:n,domains:t,dictationText:_.trim()||null})},onSuccess:e=>{S(e.assessment),w({kind:`ok`,text:`Generated`});try{sessionStorage.setItem(`wv-shadess-assessment`,e.assessment)}catch{}},onError:e=>w({kind:`err`,text:e.message||`Generation failed`})});function E(e,t,n,r){g(i=>{let a=i[e],o={...a.questions,[t]:n},s=a.concern;return r!==void 0&&n===`yes`===r&&(s=!0),{...i,[e]:{...a,questions:o,concern:s}}})}function D(e,t){g(n=>({...n,[e]:{...n[e],comment:t}}))}function O(e){g(t=>({...t,[e]:{...t[e],skipped:!t[e].skipped}}))}function k(e){g(t=>({...t,[e]:{...t[e],concern:!t[e].concern}}))}function A(){g(p()),v(``),S(null),w(null)}return(0,c.jsxs)(`div`,{className:`space-y-4`,children:[(0,c.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 space-y-3`,children:[(0,c.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Patient age`}),(0,c.jsx)(`input`,{className:u+` w-32`,value:e,onChange:e=>t(e.target.value),placeholder:`e.g. 14 years`})]}),(0,c.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Gender`}),(0,c.jsxs)(`select`,{className:u+` w-40`,value:n,onChange:e=>m(e.target.value),children:[(0,c.jsx)(`option`,{value:``,children:`Select`}),(0,c.jsx)(`option`,{children:`Male`}),(0,c.jsx)(`option`,{children:`Female`}),(0,c.jsx)(`option`,{children:`Non-binary/Other`})]})]}),(0,c.jsx)(`div`,{className:`ml-auto text-xs text-muted-foreground`,children:`Recommended age 12 and older. Ask in private.`})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Listen in (optional dictation)`}),(0,c.jsx)(o,{module:`shadess`,onTranscript:(e,t)=>{v(n=>t.appended&&n?n+` `+e:e),b(null)},onError:e=>b(e)}),y&&(0,c.jsx)(`div`,{className:`text-sm text-destructive`,children:y}),(0,c.jsx)(`textarea`,{className:u+` w-full mt-1 min-h-[60px] font-mono text-xs`,placeholder:`Or type the dictation directly. Used as supplementary input alongside the structured answers below.`,value:_,onChange:e=>v(e.target.value)})]})]}),l.map(e=>{let t=h[e.key];return(0,c.jsxs)(`div`,{className:`rounded-lg border border-border bg-card overflow-hidden`,style:{borderLeftWidth:3,borderLeftColor:e.color},"data-testid":`shadess-domain-`+e.key,children:[(0,c.jsxs)(`div`,{className:`px-4 py-2 flex items-center gap-2 bg-muted/30`,children:[(0,c.jsx)(`span`,{style:{color:e.color},children:e.icon}),(0,c.jsx)(`strong`,{className:`text-sm`,children:e.label}),(0,c.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1 ml-2`,children:e.intro}),t.concern&&(0,c.jsx)(`span`,{className:`text-xs text-amber-700 bg-amber-100 px-2 py-0.5 rounded`,children:`⚠ Concern`}),(0,c.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:`text-xs text-muted-foreground hover:text-foreground`,title:`Toggle concern flag`,children:`🚩`}),(0,c.jsxs)(`label`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:t.skipped,onChange:()=>O(e.key)}),` Skip`]})]}),(0,c.jsxs)(`div`,{className:`px-4 py-2 space-y-2 `+(t.skipped?`opacity-30`:``),children:[e.questions.map(n=>n.type===`yn`?(0,c.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,c.jsxs)(`span`,{className:`flex-1`,children:[n.text,n.concern_if!==void 0&&(0,c.jsxs)(`span`,{className:`text-[10px] text-muted-foreground ml-1`,children:[`(flag if `,n.concern_if?`Yes`:`No`,`)`]})]}),(0,c.jsxs)(`select`,{className:u+` text-xs py-1 w-24`,value:t.questions[n.id]||``,onChange:t=>E(e.key,n.id,t.target.value,n.concern_if),disabled:t.skipped,"data-testid":`shadess-q-`+n.id,children:[(0,c.jsx)(`option`,{value:``,children:`—`}),(0,c.jsx)(`option`,{value:`yes`,children:`Yes`}),(0,c.jsx)(`option`,{value:`no`,children:`No`})]})]},n.id):(0,c.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,c.jsx)(`span`,{className:`flex-1`,children:n.text}),(0,c.jsx)(`input`,{type:`text`,className:u+` text-xs py-1 flex-1 max-w-[260px]`,placeholder:n.placeholder,value:t.questions[n.id]||``,onChange:t=>E(e.key,n.id,t.target.value),disabled:t.skipped,"data-testid":`shadess-q-`+n.id})]},n.id)),(0,c.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,c.jsx)(`span`,{className:`flex-1 pt-1`,children:`Additional notes:`}),(0,c.jsx)(`textarea`,{rows:2,className:u+` text-xs flex-1 min-w-[200px] resize-y`,placeholder:`Free text comments for this domain…`,value:t.comment,onChange:t=>D(e.key,t.target.value),disabled:t.skipped})]})]})]},e.key)}),(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,c.jsx)(`button`,{type:`button`,onClick:()=>T.mutate(),disabled:T.isPending,className:f,"data-testid":`shadess-generate`,children:T.isPending?`Generating…`:`✨ Generate SSHADESS Assessment`}),(0,c.jsx)(`button`,{type:`button`,onClick:A,className:d,children:`↺ New patient`})]}),C&&(0,c.jsx)(`div`,{className:`text-sm `+(C.kind===`ok`?`text-green-600`:`text-destructive`),children:C.text}),x&&(0,c.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,c.jsx)(`header`,{className:`px-4 py-2 border-b border-border bg-muted/40`,children:(0,c.jsx)(`h3`,{className:`text-sm font-semibold`,children:`SSHADESS Assessment`})}),(0,c.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:x}),(0,c.jsx)(`div`,{className:`px-4 pb-4`,children:(0,c.jsx)(a,{text:x,onUpdate:S,sourceContext:_,exportLabel:`sshadess`,exportType:`sshadess`})}),(0,c.jsx)(`div`,{className:`px-4 pb-3 text-xs text-muted-foreground`,children:`ℹ︎ Auto-saved to session for the Visit Note tab — switch tabs to incorporate.`})]})]})}export{m as default}; \ No newline at end of file diff --git a/public/app/assets/SickVisit-BHH5UBrw.js b/public/app/assets/SickVisit-BHH5UBrw.js new file mode 100644 index 0000000..a902713 --- /dev/null +++ b/public/app/assets/SickVisit-BHH5UBrw.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,n as a}from"./index-C9wKWOAN.js";import{n as o,t as s}from"./EditableResult-DaHQp1Pv.js";import{t as c}from"./Recorder-DdXTjnSC.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./DxPicker-CCeyfxop.js";var _=e(t(),1),v=n(),y=`sickvisit`;function b(){let[e,t]=(0,_.useState)(``),[n,b]=(0,_.useState)(``),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)({}),[j,M]=(0,_.useState)({}),[N,P]=(0,_.useState)([]),[F,I]=(0,_.useState)(``),[L,R]=(0,_.useState)(null),[z,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(null),U=r({mutationFn:e=>i.post(`/api/sick-visit/note`,e),onSuccess:e=>R(e.note)});function W(e){e.preventDefault(),B(null);let t=l(m,k,`Review of Systems`),r=l(f,j,`Physical Examination`),i=d(N,F),o={patientAge:n,patientGender:x,chiefComplaint:C,transcript:(D||T).trim(),ros:t||void 0,physicalExam:r||void 0,diagnoses:i||void 0},s=a.safeParse(o);if(!s.success){B(s.error.issues.map(e=>e.message).join(`, `));return}R(null),U.mutate(s.data)}let G=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,K=D||T;return(0,v.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,v.jsxs)(`header`,{children:[(0,v.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Sick Visit`}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Chief complaint + transcript → structured sick-visit note.`})]}),(0,v.jsx)(o,{type:y,label:e,setLabel:t,transcript:T,generatedNote:L||``,partialData:{age:n,gender:x,chiefComplaint:C,rosData:k,peData:j,diagnoses:N,dxFreetext:F},onLoad:e=>{E(e.transcript||``),O(``),R(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&b(t.age),t?.gender&&S(t.gender),t?.chiefComplaint&&w(t.chiefComplaint),t?.rosData&&A(t.rosData),t?.peData&&M(t.peData),t?.diagnoses&&P(t.diagnoses),t?.dxFreetext&&I(t.dxFreetext)}catch{}t(e.label||``)},onClear:()=>{E(``),O(``),R(null),B(null),b(``),S(``),w(``),A({}),M({}),P([]),I(``)}}),(0,v.jsxs)(`form`,{onSubmit:W,className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,v.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,v.jsx)(`input`,{className:G,placeholder:`e.g. 4 years`,value:n,onChange:e=>b(e.target.value)})]}),(0,v.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,v.jsxs)(`select`,{className:G,value:x,onChange:e=>S(e.target.value),children:[(0,v.jsx)(`option`,{value:``,children:`Select`}),(0,v.jsx)(`option`,{children:`Male`}),(0,v.jsx)(`option`,{children:`Female`})]})]}),(0,v.jsxs)(`label`,{className:`flex flex-col gap-1 col-span-3 md:col-span-1`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Chief complaint`}),(0,v.jsx)(`input`,{className:G,placeholder:`e.g. Fever x 2 days`,value:C,onChange:e=>w(e.target.value)})]})]}),(0,v.jsx)(c,{module:`sickvisit`,onTranscript:(e,t)=>{E(n=>t.appended&&n?n+` `+e:e),O(``),H(null)},onInterim:e=>O(e?T?T+` `+e:e:``),onError:e=>H(e)}),V&&(0,v.jsx)(`div`,{className:`text-sm text-destructive`,children:V}),(0,v.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,v.jsx)(`textarea`,{className:G+` min-h-[200px] font-mono text-sm`,placeholder:`Click Start recording, or type / paste encounter narrative.`,value:K,onChange:e=>{E(e.target.value),O(``)}})]}),(0,v.jsxs)(`div`,{className:`rounded-lg border border-border bg-card`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between bg-muted/40 border-b border-border`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Review of Systems`}),(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>A(h(m,k)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`✓ All WNL`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>A(u(k,m)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`Clear`})]})]}),(0,v.jsx)(p,{systems:m,data:k,onChange:A,btnLabels:{wnl:`WNL`,abnormal:`Abnormal`,notrev:`Not reviewed`},testIdPrefix:`sv-ros`})]}),(0,v.jsxs)(`div`,{className:`rounded-lg border border-border bg-card`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between bg-muted/40 border-b border-border`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Physical Examination`}),(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>M(h(f,j)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`✓ All Normal`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>M(u(j,f)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`Clear`})]})]}),(0,v.jsx)(p,{systems:f,data:j,onChange:M,btnLabels:{wnl:`Normal`,abnormal:`Abnormal`,notrev:`Not examined`},testIdPrefix:`sv-pe`})]}),(0,v.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Diagnoses (ICD-10)`}),(0,v.jsx)(g,{value:N,onChange:P,testIdPrefix:`sv-dx`}),(0,v.jsxs)(`label`,{className:`block`,children:[(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Additional free-text diagnosis / note (optional)`}),(0,v.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),className:G+` text-sm`,placeholder:`e.g. Follow up in 48 hours if not improving`})]})]}),z&&(0,v.jsx)(`div`,{className:`text-sm text-destructive`,children:z}),U.error&&(0,v.jsx)(`div`,{className:`text-sm text-destructive`,children:U.error.message}),(0,v.jsx)(`button`,{type:`submit`,disabled:U.isPending||!C.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:U.isPending?`Generating…`:`Generate Note`})]}),L!==null&&(0,v.jsx)(s,{text:L,onChange:R,section:`sickvisit`,title:`Sick Visit Note`,exportLabel:`sick-visit-note`,exportType:`sick-visit`,sourceContext:K})]})}export{b as default}; \ No newline at end of file diff --git a/public/app/assets/SickVisit-vgkhrwdD.js b/public/app/assets/SickVisit-vgkhrwdD.js deleted file mode 100644 index a7024ba..0000000 --- a/public/app/assets/SickVisit-vgkhrwdD.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,n as a}from"./index-BuU36CvS.js";var o=e(t(),1),s=n();function c(){let[e,t]=(0,o.useState)(``),[n,c]=(0,o.useState)(``),[l,u]=(0,o.useState)(``),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(null),[h,g]=(0,o.useState)(null),_=r({mutationFn:e=>i.post(`/api/sick-visit/note`,e),onSuccess:e=>m(e.note)});function v(t){t.preventDefault(),g(null);let r={patientAge:e,patientGender:n,chiefComplaint:l,transcript:d},i=a.safeParse(r);if(!i.success){g(i.error.issues.map(e=>e.message).join(`, `));return}m(null),_.mutate(i.data)}let y=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,s.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,s.jsxs)(`header`,{children:[(0,s.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Sick Visit`}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Chief complaint + transcript → structured sick-visit note.`})]}),(0,s.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,s.jsx)(`input`,{className:y,placeholder:`e.g. 4 years`,value:e,onChange:e=>t(e.target.value)})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,s.jsxs)(`select`,{className:y,value:n,onChange:e=>c(e.target.value),children:[(0,s.jsx)(`option`,{value:``,children:`Select`}),(0,s.jsx)(`option`,{children:`Male`}),(0,s.jsx)(`option`,{children:`Female`})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1 col-span-3 md:col-span-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Chief complaint`}),(0,s.jsx)(`input`,{className:y,placeholder:`e.g. Fever x 2 days`,value:l,onChange:e=>u(e.target.value)})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,s.jsx)(`textarea`,{className:y+` min-h-[200px] font-mono text-sm`,placeholder:`Encounter narrative — transcribed or dictated.`,value:d,onChange:e=>f(e.target.value)})]}),h&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:h}),_.error&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:_.error.message}),(0,s.jsx)(`button`,{type:`submit`,disabled:_.isPending||!l.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:_.isPending?`Generating…`:`Generate Note`})]}),p&&(0,s.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,s.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,s.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Sick Visit Note`}),(0,s.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(p),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,s.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:p})]})]})}export{c as default}; \ No newline at end of file diff --git a/public/app/assets/Soap-DyFxx9HE.js b/public/app/assets/Soap-DyFxx9HE.js new file mode 100644 index 0000000..28b3b83 --- /dev/null +++ b/public/app/assets/Soap-DyFxx9HE.js @@ -0,0 +1 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,r as a}from"./index-C9wKWOAN.js";import{n as o,t as s}from"./EditableResult-DaHQp1Pv.js";import{t as c}from"./Recorder-DdXTjnSC.js";var l=e(t(),1),u=n(),d=`soap`;function f(){let[e,t]=(0,l.useState)(``),[n,f]=(0,l.useState)(``),[p,m]=(0,l.useState)(``),[h,g]=(0,l.useState)(`full`),[_,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(``),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(null),[T,E]=(0,l.useState)(null),[D,O]=(0,l.useState)(null),k=r({mutationFn:e=>i.post(`/api/generate-soap`,e),onSuccess:e=>w(e.soap)});function A(e){e.preventDefault(),E(null);let t={transcript:(y||_).trim(),patientAge:n,patientGender:p,type:h,additionalInstructions:x},r=a.safeParse(t);if(!r.success){E(r.error.issues.map(e=>e.message).join(`, `));return}w(null),k.mutate(r.data)}let j=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,M=y||_;return(0,u.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,u.jsxs)(`header`,{children:[(0,u.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`SOAP Note`}),(0,u.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Encounter transcript → full SOAP or subjective-only narrative.`})]}),(0,u.jsx)(o,{type:d,label:e,setLabel:t,transcript:_,generatedNote:C||``,partialData:{age:n,gender:p,type:h,additionalInstructions:x},onLoad:e=>{v(e.transcript||``),b(``),w(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&f(t.age),t?.gender&&m(t.gender),t?.type&&g(t.type),t?.additionalInstructions&&S(t.additionalInstructions)}catch{}t(e.label||``)},onClear:()=>{v(``),b(``),w(null),E(null),f(``),m(``),g(`full`),S(``)}}),(0,u.jsxs)(`form`,{onSubmit:A,className:`space-y-4`,children:[(0,u.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,u.jsx)(`input`,{className:j,placeholder:`e.g. 3 years`,value:n,onChange:e=>f(e.target.value)})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,u.jsxs)(`select`,{className:j,value:p,onChange:e=>m(e.target.value),children:[(0,u.jsx)(`option`,{value:``,children:`Select`}),(0,u.jsx)(`option`,{children:`Male`}),(0,u.jsx)(`option`,{children:`Female`})]})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Output type`}),(0,u.jsxs)(`select`,{className:j,value:h,onChange:e=>g(e.target.value),children:[(0,u.jsx)(`option`,{value:`full`,children:`Full SOAP`}),(0,u.jsx)(`option`,{value:`subjective`,children:`Subjective only`})]})]})]}),(0,u.jsx)(c,{module:`soap`,onTranscript:(e,t)=>{v(n=>t.appended&&n?n+` `+e:e),b(``),O(null)},onInterim:e=>b(e?_?_+` `+e:e:``),onError:e=>O(e)}),D&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:D}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript`}),(0,u.jsx)(`textarea`,{className:j+` min-h-[200px] font-mono text-sm`,placeholder:`Click Start recording, or type / paste the encounter transcript.`,value:M,onChange:e=>{v(e.target.value),b(``)}})]}),(0,u.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,u.jsxs)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[`Additional instructions `,(0,u.jsx)(`span`,{className:`text-muted-foreground normal-case font-normal`,children:`(optional)`})]}),(0,u.jsx)(`textarea`,{className:j+` min-h-[60px] text-sm`,placeholder:`e.g., 'Include return precautions', 'Add differential for otitis media'`,value:x,onChange:e=>S(e.target.value)})]}),T&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:T}),k.error&&(0,u.jsx)(`div`,{className:`text-sm text-destructive`,children:k.error.message}),(0,u.jsx)(`button`,{type:`submit`,disabled:k.isPending||!M.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:k.isPending?`Generating…`:`Generate SOAP`})]}),C!==null&&(0,u.jsx)(s,{text:C,onChange:w,section:`soap`,title:`Generated SOAP`,exportLabel:`soap-note`,exportType:`soap`,sourceContext:M})]})}export{f as default}; \ No newline at end of file diff --git a/public/app/assets/Soap-VyU-WHem.js b/public/app/assets/Soap-VyU-WHem.js deleted file mode 100644 index 7777da2..0000000 --- a/public/app/assets/Soap-VyU-WHem.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i,r as a}from"./index-BuU36CvS.js";var o=e(t(),1),s=n();function c(){let[e,t]=(0,o.useState)(``),[n,c]=(0,o.useState)(``),[l,u]=(0,o.useState)(`full`),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(null),[_,v]=(0,o.useState)(null),y=r({mutationFn:e=>i.post(`/api/generate-soap`,e),onSuccess:e=>g(e.soap)});function b(t){t.preventDefault(),v(null);let r={transcript:d,patientAge:e,patientGender:n,type:l,additionalInstructions:p},i=a.safeParse(r);if(!i.success){v(i.error.issues.map(e=>e.message).join(`, `));return}g(null),y.mutate(i.data)}let x=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,s.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,s.jsxs)(`header`,{children:[(0,s.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`SOAP Note`}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Encounter transcript → full SOAP or subjective-only narrative.`})]}),(0,s.jsxs)(`form`,{onSubmit:b,className:`space-y-4`,children:[(0,s.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,s.jsx)(`input`,{className:x,placeholder:`e.g. 3 years`,value:e,onChange:e=>t(e.target.value)})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,s.jsxs)(`select`,{className:x,value:n,onChange:e=>c(e.target.value),children:[(0,s.jsx)(`option`,{value:``,children:`Select`}),(0,s.jsx)(`option`,{children:`Male`}),(0,s.jsx)(`option`,{children:`Female`})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Output type`}),(0,s.jsxs)(`select`,{className:x,value:l,onChange:e=>u(e.target.value),children:[(0,s.jsx)(`option`,{value:`full`,children:`Full SOAP`}),(0,s.jsx)(`option`,{value:`subjective`,children:`Subjective only`})]})]})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript`}),(0,s.jsx)(`textarea`,{className:x+` min-h-[200px] font-mono text-sm`,placeholder:`Type or paste the encounter transcript.`,value:d,onChange:e=>f(e.target.value)})]}),(0,s.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,s.jsxs)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:[`Additional instructions `,(0,s.jsx)(`span`,{className:`text-muted-foreground normal-case font-normal`,children:`(optional)`})]}),(0,s.jsx)(`textarea`,{className:x+` min-h-[60px] text-sm`,placeholder:`e.g., 'Include return precautions', 'Add differential for otitis media'`,value:p,onChange:e=>m(e.target.value)})]}),_&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:_}),y.error&&(0,s.jsx)(`div`,{className:`text-sm text-destructive`,children:y.error.message}),(0,s.jsx)(`button`,{type:`submit`,disabled:y.isPending||!d.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:y.isPending?`Generating…`:`Generate SOAP`})]}),h&&(0,s.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,s.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,s.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Generated SOAP`}),(0,s.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(h),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,s.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:h})]})]})}export{c as default}; \ No newline at end of file diff --git a/public/app/assets/VaxSchedule-WVnLWGX9.js b/public/app/assets/VaxSchedule-DSxl1k27.js similarity index 97% rename from public/app/assets/VaxSchedule-WVnLWGX9.js rename to public/app/assets/VaxSchedule-DSxl1k27.js index e81ab38..7a91d69 100644 --- a/public/app/assets/VaxSchedule-WVnLWGX9.js +++ b/public/app/assets/VaxSchedule-DSxl1k27.js @@ -1 +1 @@ -import{t as e}from"./jsx-runtime-ByY1xr43.js";import{i as t,l as n}from"./index-BuU36CvS.js";var r=e();function i(){let{data:e,isLoading:i,error:a}=n({queryKey:[`schedule-data`],queryFn:()=>t.get(`/api/schedule-data`)});if(i)return(0,r.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading schedule…`});if(a)return(0,r.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:a.message});if(!e)return null;let o=e.visitAges.filter(t=>e.periodicity[t.id]?.vaccines?.length),s=[],c=new Set;return o.forEach(t=>{e.periodicity[t.id].vaccines.forEach(e=>{c.has(e.vaccine)||(c.add(e.vaccine),s.push(e.vaccine))})}),(0,r.jsxs)(`div`,{className:`max-w-full mx-auto p-6 space-y-4`,children:[(0,r.jsxs)(`header`,{children:[(0,r.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Vaccine Schedule`}),(0,r.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`AAP/ACIP 2025 complete immunization schedule (0–18 years).`})]}),(0,r.jsx)(`div`,{className:`rounded-lg border border-border overflow-auto bg-card`,children:(0,r.jsxs)(`table`,{className:`text-xs`,children:[(0,r.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,r.jsxs)(`tr`,{children:[(0,r.jsx)(`th`,{className:`text-left font-semibold px-3 py-2 border-b border-border min-w-[180px] sticky left-0 bg-muted`,children:`Vaccine`}),o.map(e=>(0,r.jsx)(`th`,{className:`px-2 py-2 border-b border-border text-center whitespace-nowrap`,children:e.label},e.id))]})}),(0,r.jsx)(`tbody`,{children:s.map(t=>(0,r.jsxs)(`tr`,{className:`even:bg-muted/20`,children:[(0,r.jsx)(`td`,{className:`px-3 py-2 border-b border-border font-medium sticky left-0 bg-card`,children:e.vaccineFullNames[t]||t}),o.map(n=>{let i=(e.periodicity[n.id].vaccines||[]).find(e=>e.vaccine===t);if(!i)return(0,r.jsx)(`td`,{className:`border-b border-border`},n.id);let a=typeof i.dose==`number`?`#`+i.dose:i.dose||`•`;return(0,r.jsx)(`td`,{className:`border-b border-border text-center bg-primary/10 font-mono text-[11px]`,title:i.notes||`${t} dose ${i.dose}`,children:a},n.id)})]},t))})]})}),(0,r.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Hover any filled cell for notes. Sources: AAP/Bright Futures (Feb 2025), CDC Child & Adolescent Immunization Schedule (2025).`})]})}export{i as default}; \ No newline at end of file +import{t as e}from"./jsx-runtime-ByY1xr43.js";import{i as t,l as n}from"./index-C9wKWOAN.js";var r=e();function i(){let{data:e,isLoading:i,error:a}=n({queryKey:[`schedule-data`],queryFn:()=>t.get(`/api/schedule-data`)});if(i)return(0,r.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading schedule…`});if(a)return(0,r.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:a.message});if(!e)return null;let o=e.visitAges.filter(t=>e.periodicity[t.id]?.vaccines?.length),s=[],c=new Set;return o.forEach(t=>{e.periodicity[t.id].vaccines.forEach(e=>{c.has(e.vaccine)||(c.add(e.vaccine),s.push(e.vaccine))})}),(0,r.jsxs)(`div`,{className:`max-w-full mx-auto p-6 space-y-4`,children:[(0,r.jsxs)(`header`,{children:[(0,r.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Vaccine Schedule`}),(0,r.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`AAP/ACIP 2025 complete immunization schedule (0–18 years).`})]}),(0,r.jsx)(`div`,{className:`rounded-lg border border-border overflow-auto bg-card`,children:(0,r.jsxs)(`table`,{className:`text-xs`,children:[(0,r.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,r.jsxs)(`tr`,{children:[(0,r.jsx)(`th`,{className:`text-left font-semibold px-3 py-2 border-b border-border min-w-[180px] sticky left-0 bg-muted`,children:`Vaccine`}),o.map(e=>(0,r.jsx)(`th`,{className:`px-2 py-2 border-b border-border text-center whitespace-nowrap`,children:e.label},e.id))]})}),(0,r.jsx)(`tbody`,{children:s.map(t=>(0,r.jsxs)(`tr`,{className:`even:bg-muted/20`,children:[(0,r.jsx)(`td`,{className:`px-3 py-2 border-b border-border font-medium sticky left-0 bg-card`,children:e.vaccineFullNames[t]||t}),o.map(n=>{let i=(e.periodicity[n.id].vaccines||[]).find(e=>e.vaccine===t);if(!i)return(0,r.jsx)(`td`,{className:`border-b border-border`},n.id);let a=typeof i.dose==`number`?`#`+i.dose:i.dose||`•`;return(0,r.jsx)(`td`,{className:`border-b border-border text-center bg-primary/10 font-mono text-[11px]`,title:i.notes||`${t} dose ${i.dose}`,children:a},n.id)})]},t))})]})}),(0,r.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Hover any filled cell for notes. Sources: AAP/Bright Futures (Feb 2025), CDC Child & Adolescent Immunization Schedule (2025).`})]})}export{i as default}; \ No newline at end of file diff --git a/public/app/assets/VisitNote-B6TwVraG.js b/public/app/assets/VisitNote-B6TwVraG.js new file mode 100644 index 0000000..59208da --- /dev/null +++ b/public/app/assets/VisitNote-B6TwVraG.js @@ -0,0 +1,5 @@ +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-C9wKWOAN.js";import{n as ee,t as te}from"./EditableResult-DaHQp1Pv.js";import{t as ne}from"./Recorder-DdXTjnSC.js";import{a,c as o,i as re,n as s,o as c,r as l,s as u,t as ie}from"./DxPicker-CCeyfxop.js";var d=e(t(),1),f=n(),ae=`wellvisit`,p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;function m(){let[e,t]=(0,d.useState)(``),[n,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(``),[y,b]=(0,d.useState)(``),[x,S]=(0,d.useState)(``),[C,w]=(0,d.useState)(``),[T,E]=(0,d.useState)(``),[D,O]=(0,d.useState)(``),[k,A]=(0,d.useState)(null),[j,M]=(0,d.useState)(``),[N,P]=(0,d.useState)(``),[F,I]=(0,d.useState)(``),[L,R]=(0,d.useState)(``),[z,B]=(0,d.useState)(``),[V,H]=(0,d.useState)({}),[U,W]=(0,d.useState)({}),[G,K]=(0,d.useState)([]),[q,J]=(0,d.useState)(``),[Y,X]=(0,d.useState)(`full`),[Z,Q]=(0,d.useState)(null);(0,d.useEffect)(()=>{try{let e=sessionStorage.getItem(`wv-shadess-assessment`);e&&M(e);let t=sessionStorage.getItem(`wv-milestones-narrative`);t&&P(t);let n=sessionStorage.getItem(`wv-byvisit-statuses`);n&&B(n);let r=sessionStorage.getItem(`ped_visit_age`);r&&v(e=>e||r)}catch{}},[]);let $=r({mutationFn:e=>i.post(`/api/well-visit/note`,e),onSuccess:e=>Q(e.note)});function oe(e){e.preventDefault(),Q(null);let t=a(l,V,`ROS`),r=a(s,U,`PHYSICAL EXAM`),i=re(G,q);$.mutate({patientAge:n,patientGender:h,visitAge:_,vitals:y,measurements:x,parentConcerns:C,transcript:(D||T).trim(),shadessAssessment:j||void 0,screenings:[F,z].filter(Boolean).join(` + +`),vaccines:L,ros:t||void 0,physicalExam:r||void 0,diagnoses:i||void 0,physicianMemories:N?`[DEVELOPMENTAL ASSESSMENT] +`+N:void 0,noteStyle:Y})}let se=D||T;return(0,f.jsxs)(`div`,{className:`space-y-4`,children:[(0,f.jsx)(ee,{type:ae,label:e,setLabel:t,transcript:T,generatedNote:Z||``,partialData:{age:n,gender:h,visitAge:_,vitals:y,measurements:x,parentConcerns:C,shadess:j,milestones:N,byvisit:z,screenings:F,vaccines:L,rosData:V,peData:U,diagnoses:G,dxFreetext:q,noteStyle:Y},onLoad:e=>{E(e.transcript||``),O(``),Q(e.generated_note||null);try{let t=e.partial_data?JSON.parse(e.partial_data):null;t?.age&&m(t.age),t?.gender&&g(t.gender),t?.visitAge&&v(t.visitAge),t?.vitals&&b(t.vitals),t?.measurements&&S(t.measurements),t?.parentConcerns&&w(t.parentConcerns),t?.shadess&&M(t.shadess),t?.milestones&&P(t.milestones),t?.byvisit&&B(t.byvisit),t?.screenings&&I(t.screenings),t?.vaccines&&R(t.vaccines),t?.rosData&&H(t.rosData),t?.peData&&W(t.peData),t?.diagnoses&&K(t.diagnoses),t?.dxFreetext&&J(t.dxFreetext),t?.noteStyle&&X(t.noteStyle)}catch{}t(e.label||``)},onClear:()=>{E(``),O(``),Q(null),m(``),g(``),v(``),b(``),S(``),w(``),M(``),P(``),B(``),I(``),R(``),H({}),W({}),K([]),J(``),X(`full`)}}),(0,f.jsxs)(`form`,{onSubmit:oe,className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,f.jsx)(`input`,{className:p,value:n,onChange:e=>m(e.target.value)})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,f.jsxs)(`select`,{className:p,value:h,onChange:e=>g(e.target.value),children:[(0,f.jsx)(`option`,{value:``,children:`Select`}),(0,f.jsx)(`option`,{children:`Male`}),(0,f.jsx)(`option`,{children:`Female`})]})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Visit age`}),(0,f.jsx)(`input`,{className:p,placeholder:`e.g. 6 months`,value:_,onChange:e=>v(e.target.value)})]})]}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Vital signs`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[60px] font-mono text-xs`,value:y,onChange:e=>b(e.target.value)})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Measurements / growth`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[60px] font-mono text-xs`,value:x,onChange:e=>S(e.target.value)})]})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Parent / patient concerns`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[60px] text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,f.jsx)(ne,{module:`wellvisit`,onTranscript:(e,t)=>{E(n=>t.appended&&n?n+` `+e:e),O(``),A(null)},onInterim:e=>O(e?T?T+` `+e:e:``),onError:e=>A(e)}),k&&(0,f.jsx)(`div`,{className:`text-sm text-destructive`,children:k}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[160px] font-mono text-sm`,value:se,onChange:e=>{E(e.target.value),O(``)},placeholder:`Click Start recording, or type / paste.`})]}),(j||N||z)&&(0,f.jsxs)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 dark:bg-amber-950/30 p-3 space-y-2`,children:[(0,f.jsx)(`div`,{className:`text-xs font-semibold text-amber-800 dark:text-amber-200`,children:`Carry-overs from other tabs (used in note generation)`}),N&&(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`Developmental assessment (`,N.length,` chars)`]}),(0,f.jsx)(`textarea`,{className:p+` mt-1 min-h-[80px] font-mono text-xs`,value:N,onChange:e=>P(e.target.value)})]}),j&&(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`SSHADESS assessment (`,j.length,` chars)`]}),(0,f.jsx)(`textarea`,{className:p+` mt-1 min-h-[80px] font-mono text-xs`,value:j,onChange:e=>M(e.target.value)})]}),z&&(0,f.jsxs)(`details`,{className:`text-xs`,children:[(0,f.jsxs)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:[`By-visit-age statuses (`,z.split(` +`).length,` lines)`]}),(0,f.jsx)(`textarea`,{className:p+` mt-1 min-h-[80px] font-mono text-xs`,value:z,onChange:e=>B(e.target.value)})]})]}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Screenings completed`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[60px] text-xs`,value:F,onChange:e=>I(e.target.value)})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Immunizations today`}),(0,f.jsx)(`textarea`,{className:p+` min-h-[60px] text-xs`,value:L,onChange:e=>R(e.target.value)})]})]}),(0,f.jsxs)(`div`,{className:`rounded-lg border border-border bg-card`,children:[(0,f.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between bg-muted/40 border-b border-border`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Review of Systems`}),(0,f.jsxs)(`div`,{className:`flex gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>H(u(l,V)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`✓ All WNL`}),(0,f.jsx)(`button`,{type:`button`,onClick:()=>H(o(V,l)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`Clear`})]})]}),(0,f.jsx)(c,{systems:l,data:V,onChange:H,btnLabels:{wnl:`WNL`,abnormal:`Abnormal`,notrev:`Not reviewed`},testIdPrefix:`wv-ros`})]}),(0,f.jsxs)(`div`,{className:`rounded-lg border border-border bg-card`,children:[(0,f.jsxs)(`div`,{className:`px-3 py-2 flex items-center justify-between bg-muted/40 border-b border-border`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Physical Examination`}),(0,f.jsxs)(`div`,{className:`flex gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>W(u(s,U)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`✓ All Normal`}),(0,f.jsx)(`button`,{type:`button`,onClick:()=>W(o(U,s)),className:`text-xs rounded border border-border px-2 py-1 hover:bg-muted`,children:`Clear`})]})]}),(0,f.jsx)(c,{systems:s,data:U,onChange:W,btnLabels:{wnl:`Normal`,abnormal:`Abnormal`,notrev:`Not examined`},testIdPrefix:`wv-pe`})]}),(0,f.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 space-y-2`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,children:`Diagnoses (ICD-10)`}),(0,f.jsx)(ie,{value:G,onChange:K,testIdPrefix:`wv-dx`}),(0,f.jsxs)(`label`,{className:`block`,children:[(0,f.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Additional free-text diagnosis / note (optional)`}),(0,f.jsx)(`input`,{type:`text`,value:q,onChange:e=>J(e.target.value),className:p+` text-sm`,placeholder:`e.g. Rule out iron-deficiency anaemia pending labs`})]})]}),(0,f.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,f.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Note style`}),(0,f.jsxs)(`select`,{className:p,value:Y,onChange:e=>X(e.target.value),children:[(0,f.jsx)(`option`,{value:`full`,children:`Full encounter note`}),(0,f.jsx)(`option`,{value:`short`,children:`Brief SOAP`})]})]}),$.error&&(0,f.jsx)(`div`,{className:`text-sm text-destructive`,children:$.error.message}),(0,f.jsx)(`button`,{type:`submit`,disabled:$.isPending||!n.trim()&&!_.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:$.isPending?`Generating…`:`Generate Well Visit Note`})]}),Z!==null&&(0,f.jsx)(te,{text:Z,onChange:Q,section:`wellvisit`,title:`Well Visit Note`,exportLabel:`well-visit-note`,exportType:`well-visit`,sourceContext:se})]})}export{m as default}; \ No newline at end of file diff --git a/public/app/assets/WellVisit-CQEpKEWj.js b/public/app/assets/WellVisit-CQEpKEWj.js deleted file mode 100644 index 45d0e04..0000000 --- a/public/app/assets/WellVisit-CQEpKEWj.js +++ /dev/null @@ -1 +0,0 @@ -import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{c as r,i}from"./index-BuU36CvS.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(``),[n,s]=(0,a.useState)(``),[c,l]=(0,a.useState)(``),[u,d]=(0,a.useState)(``),[f,p]=(0,a.useState)(``),[m,h]=(0,a.useState)(``),[g,_]=(0,a.useState)(``),[v,y]=(0,a.useState)(``),[b,x]=(0,a.useState)(``),[S,C]=(0,a.useState)(`full`),[w,T]=(0,a.useState)(null),E=r({mutationFn:e=>i.post(`/api/well-visit/note`,e),onSuccess:e=>T(e.note)});function D(t){t.preventDefault(),T(null),E.mutate({patientAge:e,patientGender:n,visitAge:c,vitals:u,measurements:f,parentConcerns:m,transcript:g,screenings:v,vaccines:b,noteStyle:S})}let O=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`;return(0,o.jsxs)(`div`,{className:`max-w-4xl mx-auto p-6 space-y-4`,children:[(0,o.jsxs)(`header`,{children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Well Visit`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preventive-care note generation. Milestones and SSHADESS sub-tabs land in a follow-up; this first port covers the Visit Note pane.`})]}),(0,o.jsxs)(`form`,{onSubmit:D,className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Age`}),(0,o.jsx)(`input`,{className:O,value:e,onChange:e=>t(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Gender`}),(0,o.jsxs)(`select`,{className:O,value:n,onChange:e=>s(e.target.value),children:[(0,o.jsx)(`option`,{value:``,children:`Select`}),(0,o.jsx)(`option`,{children:`Male`}),(0,o.jsx)(`option`,{children:`Female`})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Visit age`}),(0,o.jsx)(`input`,{className:O,placeholder:`e.g. 6 months`,value:c,onChange:e=>l(e.target.value)})]})]}),(0,o.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Vital signs`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[60px] font-mono text-xs`,value:u,onChange:e=>d(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Measurements / growth`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[60px] font-mono text-xs`,value:f,onChange:e=>p(e.target.value)})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Parent / patient concerns`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[60px] text-sm`,value:m,onChange:e=>h(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transcript / dictation`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[160px] font-mono text-sm`,value:g,onChange:e=>_(e.target.value)})]}),(0,o.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Screenings completed`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[60px] text-xs`,value:v,onChange:e=>y(e.target.value)})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Immunizations today`}),(0,o.jsx)(`textarea`,{className:O+` min-h-[60px] text-xs`,value:b,onChange:e=>x(e.target.value)})]})]}),(0,o.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,o.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Note style`}),(0,o.jsxs)(`select`,{className:O,value:S,onChange:e=>C(e.target.value),children:[(0,o.jsx)(`option`,{value:`full`,children:`Full encounter note`}),(0,o.jsx)(`option`,{value:`short`,children:`Brief SOAP`})]})]}),E.error&&(0,o.jsx)(`div`,{className:`text-sm text-destructive`,children:E.error.message}),(0,o.jsx)(`button`,{type:`submit`,disabled:E.isPending||!e.trim()&&!c.trim(),className:`rounded-md bg-primary text-primary-foreground px-4 py-2 text-sm font-medium disabled:opacity-50`,children:E.isPending?`Generating…`:`Generate Well Visit Note`})]}),w&&(0,o.jsxs)(`section`,{className:`rounded-lg border border-border bg-card`,children:[(0,o.jsxs)(`header`,{className:`px-4 py-2 border-b border-border flex items-center justify-between bg-muted/40`,children:[(0,o.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Well Visit Note`}),(0,o.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(w),className:`text-xs text-muted-foreground underline`,children:`Copy`})]}),(0,o.jsx)(`div`,{className:`p-4 whitespace-pre-wrap text-sm`,children:w})]})]})}export{s as default}; \ No newline at end of file diff --git a/public/app/assets/WellVisit-Dv-oLhFb.js b/public/app/assets/WellVisit-Dv-oLhFb.js new file mode 100644 index 0000000..667a6a1 --- /dev/null +++ b/public/app/assets/WellVisit-Dv-oLhFb.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ByVisitAge-jMcNy23H.js","assets/jsx-runtime-ByY1xr43.js","assets/index-C9wKWOAN.js","assets/preload-helper-BmrihbwG.js","assets/index-D2yFXEFs.css","assets/Milestones-BIwzyW98.js","assets/OutputActions-6XZlmtIw.js","assets/Shadess-DU9cvMlg.js","assets/Recorder-DdXTjnSC.js","assets/VisitNote-B6TwVraG.js","assets/DxPicker-CCeyfxop.js","assets/EditableResult-DaHQp1Pv.js"])))=>i.map(i=>d[i]); +import{i as e,n as t,t as n}from"./jsx-runtime-ByY1xr43.js";import{t as r}from"./preload-helper-BmrihbwG.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./ByVisitAge-jMcNy23H.js`),__vite__mapDeps([0,1,2,3,4]))),s=(0,i.lazy)(()=>r(()=>import(`./Milestones-BIwzyW98.js`),__vite__mapDeps([5,1,2,3,4,6]))),c=(0,i.lazy)(()=>r(()=>import(`./Shadess-DU9cvMlg.js`),__vite__mapDeps([7,1,2,3,4,6,8]))),l=(0,i.lazy)(()=>r(()=>import(`./VisitNote-B6TwVraG.js`),__vite__mapDeps([9,1,2,3,4,10,11,6,8]))),u=[{id:`byvisit`,icon:`👶`,label:`By Visit Age`},{id:`milestones`,icon:`🍼`,label:`Milestones`},{id:`shadess`,icon:`🧠`,label:`SSHADESS (12+)`},{id:`note`,icon:`📄`,label:`Visit Note`}],d=`ped_wellvisit_subtab`;function f(){try{let e=localStorage.getItem(d);if(e===`byvisit`||e===`milestones`||e===`shadess`||e===`note`)return e}catch{}return`byvisit`}function p(){let[e,t]=(0,i.useState)(f);function n(e){t(e);try{localStorage.setItem(d,e)}catch{}}return(0,a.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6 space-y-4`,children:[(0,a.jsxs)(`header`,{children:[(0,a.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Well Visit / Preventive Care`}),(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`AAP 2025 Bright Futures periodicity — vaccines, screenings, billing codes, milestones, SSHADESS, and the encounter note.`})]}),(0,a.jsx)(`div`,{className:`flex flex-wrap gap-2`,"data-testid":`wellvisit-subnav`,children:u.map(t=>(0,a.jsxs)(`button`,{type:`button`,onClick:()=>n(t.id),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors `+(e===t.id?`bg-primary text-primary-foreground border-primary`:`bg-muted hover:bg-muted/80 border-border`),"data-testid":`wellvisit-pill-`+t.id,children:[(0,a.jsx)(`span`,{className:`mr-1`,"aria-hidden":!0,children:t.icon}),t.label]},t.id))}),(0,a.jsxs)(i.Suspense,{fallback:(0,a.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`}),children:[e===`byvisit`&&(0,a.jsx)(o,{}),e===`milestones`&&(0,a.jsx)(s,{}),e===`shadess`&&(0,a.jsx)(c,{}),e===`note`&&(0,a.jsx)(l,{})]})]})}export{p as default}; \ No newline at end of file diff --git a/public/app/assets/fenton-Dvwmge1q.js b/public/app/assets/fenton-BaYL-F22.js similarity index 100% rename from public/app/assets/fenton-Dvwmge1q.js rename to public/app/assets/fenton-BaYL-F22.js diff --git a/public/app/assets/index-BEGt1l85.css b/public/app/assets/index-BEGt1l85.css deleted file mode 100644 index 0f990ac..0000000 --- a/public/app/assets/index-BEGt1l85.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-50:oklch(98% .016 73.684);--color-orange-100:oklch(95.4% .038 75.164);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-700:oklch(55.3% .195 38.402);--color-orange-900:oklch(40.8% .123 38.172);--color-orange-950:oklch(26.6% .079 36.259);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-amber-950:oklch(27.9% .077 45.635);--color-green-50:oklch(98.2% .018 155.826);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-green-950:oklch(26.6% .065 152.934);--color-sky-50:oklch(97.7% .013 236.62);--color-sky-100:oklch(95.1% .026 236.824);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-900:oklch(39.1% .09 240.876);--color-sky-950:oklch(29.3% .066 243.157);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-blue-950:oklch(28.2% .091 267.935);--color-indigo-50:oklch(96.2% .018 272.314);--color-violet-50:oklch(96.9% .016 293.756);--color-violet-200:oklch(89.4% .057 293.283);--color-violet-500:oklch(60.6% .25 292.717);--color-violet-800:oklch(43.2% .232 292.759);--color-violet-950:oklch(28.3% .141 291.089);--color-purple-50:oklch(97.7% .014 308.299);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-900:oklch(38.1% .176 304.987);--color-purple-950:oklch(29.1% .149 302.717);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-xl:36rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5 / 2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--radius:.5rem;--color-background:#fff;--color-foreground:#0f172a;--color-muted:#f1f5f9;--color-muted-foreground:#64748b;--color-card:#fff;--color-primary:#0f172a;--color-primary-foreground:#f8fafc;--color-destructive:#ef4343;--color-border:#e2e8f0;--color-input:#e2e8f0;--color-ring:#94a3b8}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.left-0{left:calc(var(--spacing) * 0)}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.my-2{margin-block:calc(var(--spacing) * 2)}.my-4{margin-block:calc(var(--spacing) * 4)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mr-1{margin-right:calc(var(--spacing) * 1)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:calc(var(--spacing) * 1)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-8{height:calc(var(--spacing) * 8)}.h-screen{height:100vh}.max-h-\[70vh\]{max-height:70vh}.min-h-\[60px\]{min-height:60px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[160px\]{min-height:160px}.min-h-\[200px\]{min-height:200px}.min-h-\[220px\]{min-height:220px}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing) * .5)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-8{width:calc(var(--spacing) * 8)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-36{width:calc(var(--spacing) * 36)}.w-64{width:calc(var(--spacing) * 64)}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-\[140px\]{max-width:140px}.max-w-\[240px\]{max-width:240px}.max-w-full{max-width:100%}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-\[150px\]{min-width:150px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize-y{resize:vertical}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 0) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 0) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:var(--radius)}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-500{border-color:var(--color-amber-500)}.border-blue-500{border-color:var(--color-blue-500)}.border-border{border-color:var(--color-border)}.border-destructive{border-color:var(--color-destructive)}.border-green-200{border-color:var(--color-green-200)}.border-green-500{border-color:var(--color-green-500)}.border-green-600{border-color:var(--color-green-600)}.border-input{border-color:var(--color-input)}.border-primary{border-color:var(--color-primary)}.border-purple-500{border-color:var(--color-purple-500)}.border-red-200{border-color:var(--color-red-200)}.border-red-500{border-color:var(--color-red-500)}.border-sky-200{border-color:var(--color-sky-200)}.border-violet-500{border-color:var(--color-violet-500)}.border-l-orange-500{border-left-color:var(--color-orange-500)}.border-l-primary{border-left-color:var(--color-primary)}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-background{background-color:var(--color-background)}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.bg-black\/40{background-color:color-mix(in oklab, var(--color-black) 40%, transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-500{background-color:var(--color-blue-500)}.bg-border{background-color:var(--color-border)}.bg-card{background-color:var(--color-card)}.bg-destructive{background-color:var(--color-destructive)}.bg-green-50{background-color:var(--color-green-50)}.bg-green-600{background-color:var(--color-green-600)}.bg-muted{background-color:var(--color-muted)}.bg-muted\/20{background-color:#f1f5f933}@supports (color:color-mix(in lab, red, red)){.bg-muted\/20{background-color:color-mix(in oklab, var(--color-muted) 20%, transparent)}}.bg-muted\/30{background-color:#f1f5f94d}@supports (color:color-mix(in lab, red, red)){.bg-muted\/30{background-color:color-mix(in oklab, var(--color-muted) 30%, transparent)}}.bg-muted\/40{background-color:#f1f5f966}@supports (color:color-mix(in lab, red, red)){.bg-muted\/40{background-color:color-mix(in oklab, var(--color-muted) 40%, transparent)}}.bg-orange-50{background-color:var(--color-orange-50)}.bg-primary{background-color:var(--color-primary)}.bg-primary\/5{background-color:#0f172a0d}@supports (color:color-mix(in lab, red, red)){.bg-primary\/5{background-color:color-mix(in oklab, var(--color-primary) 5%, transparent)}}.bg-primary\/10{background-color:#0f172a1a}@supports (color:color-mix(in lab, red, red)){.bg-primary\/10{background-color:color-mix(in oklab, var(--color-primary) 10%, transparent)}}.bg-purple-50{background-color:var(--color-purple-50)}.bg-purple-500{background-color:var(--color-purple-500)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-500{background-color:var(--color-red-500)}.bg-sky-50{background-color:var(--color-sky-50)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-violet-50{background-color:var(--color-violet-50)}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-blue-50{--tw-gradient-from:var(--color-blue-50);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-white{--tw-gradient-via:var(--color-white);--tw-gradient-via-stops:var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-indigo-50{--tw-gradient-to:var(--color-indigo-50);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-8{padding-block:calc(var(--spacing) * 8)}.pt-1{padding-top:calc(var(--spacing) * 1)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-6{padding-left:calc(var(--spacing) * 6)}.pl-8{padding-left:calc(var(--spacing) * 8)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-blue-800{color:var(--color-blue-800)}.text-blue-900{color:var(--color-blue-900)}.text-destructive{color:var(--color-destructive)}.text-foreground{color:var(--color-foreground)}.text-green-600{color:var(--color-green-600)}.text-green-700{color:var(--color-green-700)}.text-green-800{color:var(--color-green-800)}.text-green-900{color:var(--color-green-900)}.text-muted-foreground{color:var(--color-muted-foreground)}.text-orange-500{color:var(--color-orange-500)}.text-orange-700{color:var(--color-orange-700)}.text-orange-900{color:var(--color-orange-900)}.text-primary{color:var(--color-primary)}.text-primary-foreground{color:var(--color-primary-foreground)}.text-purple-900{color:var(--color-purple-900)}.text-red-600{color:var(--color-red-600)}.text-red-700{color:var(--color-red-700)}.text-red-800{color:var(--color-red-800)}.text-red-900{color:var(--color-red-900)}.text-sky-900{color:var(--color-sky-900)}.text-violet-800{color:var(--color-violet-800)}.text-white{color:var(--color-white)}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.no-underline{text-decoration-line:none}.underline{text-decoration-line:underline}.accent-orange-500{accent-color:var(--color-orange-500)}.accent-primary{accent-color:var(--color-primary)}.opacity-60{opacity:.6}.opacity-80{opacity:.8}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.even\:bg-muted\/20:nth-child(2n){background-color:#f1f5f933}@supports (color:color-mix(in lab, red, red)){.even\:bg-muted\/20:nth-child(2n){background-color:color-mix(in oklab, var(--color-muted) 20%, transparent)}}@media (hover:hover){.hover\:bg-green-50:hover{background-color:var(--color-green-50)}.hover\:bg-muted:hover{background-color:var(--color-muted)}.hover\:bg-muted\/40:hover{background-color:#f1f5f966}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/40:hover{background-color:color-mix(in oklab, var(--color-muted) 40%, transparent)}}.hover\:bg-muted\/50:hover{background-color:#f1f5f980}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab, var(--color-muted) 50%, transparent)}}.hover\:bg-muted\/60:hover{background-color:#f1f5f999}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/60:hover{background-color:color-mix(in oklab, var(--color-muted) 60%, transparent)}}.hover\:bg-muted\/80:hover{background-color:#f1f5f9cc}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/80:hover{background-color:color-mix(in oklab, var(--color-muted) 80%, transparent)}}.hover\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\:bg-slate-800:hover{background-color:var(--color-slate-800)}.hover\:text-foreground:hover{color:var(--color-foreground)}.hover\:underline:hover{text-decoration-line:underline}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-ring:focus{--tw-ring-color:var(--color-ring)}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}@media (width>=40rem){.sm\:col-span-1{grid-column:span 1/span 1}.sm\:col-span-2{grid-column:span 2/span 2}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}}@media (width>=48rem){.md\:col-span-1{grid-column:span 1/span 1}.md\:col-span-2{grid-column:span 2/span 2}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-\[1\.2fr_1fr_1fr_auto\]{grid-template-columns:1.2fr 1fr 1fr auto}.md\:items-end{align-items:flex-end}}@media (width>=64rem){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (prefers-color-scheme:dark){.dark\:border-amber-800{border-color:var(--color-amber-800)}.dark\:border-amber-900{border-color:var(--color-amber-900)}.dark\:border-green-900{border-color:var(--color-green-900)}.dark\:border-red-900{border-color:var(--color-red-900)}.dark\:border-sky-900{border-color:var(--color-sky-900)}.dark\:bg-amber-950\/30{background-color:#4619014d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-950\/30{background-color:color-mix(in oklab, var(--color-amber-950) 30%, transparent)}}.dark\:bg-black{background-color:var(--color-black)}.dark\:bg-blue-950\/30{background-color:#1624564d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-950\/30{background-color:color-mix(in oklab, var(--color-blue-950) 30%, transparent)}}.dark\:bg-green-950\/30{background-color:#032e154d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-green-950\/30{background-color:color-mix(in oklab, var(--color-green-950) 30%, transparent)}}.dark\:bg-orange-950\/30{background-color:#4413064d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-orange-950\/30{background-color:color-mix(in oklab, var(--color-orange-950) 30%, transparent)}}.dark\:bg-purple-950\/30{background-color:#3c03664d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-purple-950\/30{background-color:color-mix(in oklab, var(--color-purple-950) 30%, transparent)}}.dark\:bg-red-950\/30{background-color:#4608094d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-950\/30{background-color:color-mix(in oklab, var(--color-red-950) 30%, transparent)}}.dark\:bg-red-950\/40{background-color:#46080966}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-950\/40{background-color:color-mix(in oklab, var(--color-red-950) 40%, transparent)}}.dark\:bg-sky-950\/30{background-color:#052f4a4d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-sky-950\/30{background-color:color-mix(in oklab, var(--color-sky-950) 30%, transparent)}}.dark\:bg-violet-950\/30{background-color:#2f0d684d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-violet-950\/30{background-color:color-mix(in oklab, var(--color-violet-950) 30%, transparent)}}.dark\:from-slate-900{--tw-gradient-from:var(--color-slate-900);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.dark\:via-slate-950{--tw-gradient-via:var(--color-slate-950);--tw-gradient-via-stops:var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.dark\:to-slate-900{--tw-gradient-to:var(--color-slate-900);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.dark\:text-amber-100{color:var(--color-amber-100)}.dark\:text-amber-200{color:var(--color-amber-200)}.dark\:text-blue-100{color:var(--color-blue-100)}.dark\:text-blue-200{color:var(--color-blue-200)}.dark\:text-green-100{color:var(--color-green-100)}.dark\:text-green-200{color:var(--color-green-200)}.dark\:text-green-300{color:var(--color-green-300)}.dark\:text-orange-100{color:var(--color-orange-100)}.dark\:text-purple-100{color:var(--color-purple-100)}.dark\:text-red-100{color:var(--color-red-100)}.dark\:text-red-200{color:var(--color-red-200)}.dark\:text-sky-100{color:var(--color-sky-100)}.dark\:text-violet-200{color:var(--color-violet-200)}@media (hover:hover){.dark\:hover\:bg-green-950\/30:hover{background-color:#032e154d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-green-950\/30:hover{background-color:color-mix(in oklab, var(--color-green-950) 30%, transparent)}}.dark\:hover\:bg-red-950\/30:hover{background-color:#4608094d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-red-950\/30:hover{background-color:color-mix(in oklab, var(--color-red-950) 30%, transparent)}}}}}body{background:var(--color-background);color:var(--color-foreground);margin:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false} diff --git a/public/app/assets/index-BuU36CvS.js b/public/app/assets/index-BuU36CvS.js deleted file mode 100644 index b3da05c..0000000 --- a/public/app/assets/index-BuU36CvS.js +++ /dev/null @@ -1,50 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Auth-BtfAUU3w.js","assets/jsx-runtime-ByY1xr43.js","assets/ResetPassword-pLQAcaAT.js","assets/Dictation-Dk3CctmR.js","assets/Encounter-CbwLX_2x.js","assets/Soap-VyU-WHem.js","assets/SickVisit-vgkhrwdD.js","assets/HospitalCourse-BeNFIL_Z.js","assets/ChartReview-95oCueTc.js","assets/WellVisit-CQEpKEWj.js","assets/VaxSchedule-WVnLWGX9.js","assets/Catchup--869idMv.js","assets/Settings-CnDpQmnm.js","assets/ConfirmModal-zYA0ebt6.js","assets/Learning-BRd1B0-L.js","assets/PeGuide-eWPZEjQC.js","assets/Bedside-BsBuEI_m.js","assets/fenton-Dvwmge1q.js","assets/Calculators-hFcuewWL.js","assets/Admin-C0fswhTW.js"])))=>i.map(i=>d[i]); -import{i as e,n as t,r as n,t as r}from"./jsx-runtime-ByY1xr43.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var i=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,ee||(ee=!0,ae());else{var t=n(l);t!==null&&ce(x,t.startTime-e)}}var ee=!1,S=-1,te=5,ne=-1;function re(){return g?!0:!(e.unstable_now()-net&&re());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ce(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ae():ee=!1}}}var ae;if(typeof y==`function`)ae=function(){y(ie)};else if(typeof MessageChannel<`u`){var oe=new MessageChannel,se=oe.port2;oe.port1.onmessage=ie,ae=function(){se.postMessage(null)}}else ae=function(){_(ie,0)};function ce(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,ce(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,ae()))),r},e.unstable_shouldYield=re,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=n(((e,t)=>{t.exports=i()})),o=n((e=>{var n=t();function r(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=n((e=>{var n=a(),r=t(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1he||(e.current=me[he],me[he]=null,he--)}function T(e,t){he++,me[he]=e.current,e.current=t}var ve=ge(null),ye=ge(null),be=ge(null),E=ge(null);function xe(e,t){switch(T(be,t),T(ye,e),T(ve,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}_e(ve),T(ve,e)}function Se(){_e(ve),_e(ye),_e(be)}function Ce(e){e.memoizedState!==null&&T(E,e);var t=ve.current,n=Hd(t,e.type);t!==n&&(T(ye,e),T(ve,n))}function we(e){ye.current===e&&(_e(ve),_e(ye)),E.current===e&&(_e(E),Qf._currentValue=pe)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Oe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?De(n):``}function Ae(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De(`Lazy`);case 13:return e.child!==t&&t!==null?De(`Suspense Fallback`):De(`Suspense`);case 19:return De(`SuspenseList`);case 0:case 15:return ke(e.type,!1);case 11:return ke(e.type.render,!1);case 1:return ke(e.type,!0);case 31:return De(`Activity`);default:return``}}function je(e){try{var t=``,n=null;do t+=Ae(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Me=Object.prototype.hasOwnProperty,Ne=n.unstable_scheduleCallback,Pe=n.unstable_cancelCallback,Fe=n.unstable_shouldYield,Ie=n.unstable_requestPaint,Le=n.unstable_now,Re=n.unstable_getCurrentPriorityLevel,ze=n.unstable_ImmediatePriority,Be=n.unstable_UserBlockingPriority,Ve=n.unstable_NormalPriority,He=n.unstable_LowPriority,Ue=n.unstable_IdlePriority,We=n.log,Ge=n.unstable_setDisableYieldValue,Ke=null,qe=null;function D(e){if(typeof We==`function`&&Ge(e),qe&&typeof qe.setStrictMode==`function`)try{qe.setStrictMode(Ke,e)}catch{}}var Je=Math.clz32?Math.clz32:Ze,Ye=Math.log,Xe=Math.LN2;function Ze(e){return e>>>=0,e===0?32:31-(Ye(e)/Xe|0)|0}var Qe=256,$e=262144,et=4194304;function tt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function nt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=tt(n))):i=tt(o):i=tt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=tt(n))):i=tt(o)):i=tt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function rt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function it(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function at(){var e=et;return et<<=1,!(et&62914560)&&(et=4194304),e}function ot(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function st(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ct(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),bn=!1;if(yn)try{var xn={};Object.defineProperty(xn,`passive`,{get:function(){bn=!0}}),window.addEventListener(`test`,xn,xn),window.removeEventListener(`test`,xn,xn)}catch{bn=!1}var Sn=null,Cn=null,wn=null;function Tn(){if(wn)return wn;var e,t=Cn,n=t.length,r,i=`value`in Sn?Sn.value:Sn.textContent,a=i.length;for(e=0;e=rr),or=` `,sr=!1;function cr(e,t){switch(e){case`keyup`:return tr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function lr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var k=!1;function ur(e,t){switch(e){case`compositionend`:return lr(t);case`keypress`:return t.which===32?(sr=!0,or):null;case`textInput`:return e=t.data,e===or&&sr?null:e;default:return null}}function dr(e,t){if(k)return e===`compositionend`||!nr&&cr(e,t)?(e=Tn(),wn=Cn=Sn=null,k=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Nr(n)}}function Fr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Fr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ir(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Kt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kt(e.document)}return t}function Lr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Rr=yn&&`documentMode`in document&&11>=document.documentMode,zr=null,Br=null,Vr=null,Hr=!1;function Ur(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hr||zr==null||zr!==Kt(r)||(r=zr,`selectionStart`in r&&Lr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Vr&&Mr(Vr,r)||(Vr=r,r=Ed(Br,`onSelect`),0>=o,i-=o,Pi=1<<32-Je(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),P&&Ii(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),P&&Ii(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return P&&Ii(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),P&&Ii(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===y&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case _:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===y){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===ae&&ja(l)===r.type){n(e,r.sibling),c=i(r,a.props),Ra(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===y?(c=Si(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=xi(a.type,a.key,a.props,null,e.mode,c),Ra(c,a),c.return=e,e=c)}return s(e);case v:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=Ti(a,e.mode,c),c.return=e,e=c}return s(e);case ae:return a=ja(a),b(e,r,a,c)}if(fe(a))return h(e,r,a,c);if(le(a)){if(l=le(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,La(a),c);if(a.$$typeof===S)return b(e,r,aa(e,a),c);za(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Ci(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ia=0;var i=b(e,t,n,r);return Fa=null,i}catch(t){if(t===Ta||t===Da)throw t;var a=_i(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Va=Ba(!0),Ha=Ba(!1),Ua=!1;function Wa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ga(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=mi(e),pi(e,null,n),t}return ui(e,r,t,n),mi(e)}function Ja(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}function Ya(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Xa=!1;function Za(){if(Xa){var e=ga;if(e!==null)throw e}}function Qa(e,t,n,r){Xa=!1;var i=e.updateQueue;Ua=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(J&f)===f:(r&f)===f){f!==0&&f===ha&&(Xa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Ua=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Kl|=o,e.lanes=o,e.memoizedState=d}}function $a(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function eo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=C.T,s={};C.T=s,Is(e,!1,t,n);try{var c=i(),l=C.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fs(e,t,ya(c,r),pu(e)):Fs(e,t,r,pu(e))}catch(n){Fs(e,t,{then:function(){},status:`rejected`,reason:n},pu())}finally{w.p=a,o!==null&&s.types!==null&&(o.types=s.types),C.T=o}}function Ts(){}function Es(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Ds(e).queue;ws(e,i,t,pe,n===null?Ts:function(){return Os(e),n(r)})}function Ds(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:pe,baseState:pe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:pe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Os(e){var t=Ds(e);t.next===null&&(t=e.alternate.memoizedState),Fs(e,t.next.queue,{},pu())}function ks(){return I(Qf)}function As(){return Mo().memoizedState}function js(){return Mo().memoizedState}function Ms(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pu();e=Ka(n);var r=qa(t,e,n);r!==null&&(hu(r,t,n),Ja(r,t,n)),t={cache:da()},e.payload=t;return}t=t.return}}function Ns(e,t,n){var r=pu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Rs(t,n):(n=di(e,t,n,r),n!==null&&(hu(n,e,r),zs(n,t,r)))}function Ps(e,t,n){Fs(e,t,n,pu())}function Fs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Rs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,jr(s,o))return ui(e,t,i,0),K===null&&li(),!1}catch{}if(n=di(e,t,i,r),n!==null)return hu(n,e,r),zs(n,t,r),!0}return!1}function Is(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(t)throw Error(o(479))}else t=di(e,n,r,2),t!==null&&hu(t,e,2)}function Ls(e){var t=e.alternate;return e===z||t!==null&&t===z}function Rs(e,t){_o=go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ut(e,n)}}var Bs={readContext:I,use:Fo,useCallback:V,useContext:V,useEffect:V,useImperativeHandle:V,useLayoutEffect:V,useInsertionEffect:V,useMemo:V,useReducer:V,useRef:V,useState:V,useDebugValue:V,useDeferredValue:V,useTransition:V,useSyncExternalStore:V,useId:V,useHostTransitionStatus:V,useFormState:V,useActionState:V,useOptimistic:V,useMemoCache:V,useCacheRefresh:V};Bs.useEffectEvent=V;var Vs={readContext:I,use:Fo,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:I,useEffect:ds,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ls(4194308,4,_s.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ls(4194308,4,e,t)},useInsertionEffect:function(e,t){ls(4,2,e,t)},useMemo:function(e,t){var n=jo();t=t===void 0?null:t;var r=e();if(vo){D(!0);try{e()}finally{D(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=jo();if(n!==void 0){var i=n(t);if(vo){D(!0);try{n(t)}finally{D(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ns.bind(null,z,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ps.bind(null,z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ys,useDeferredValue:function(e,t){return Ss(jo(),e,t)},useTransition:function(){var e=qo(!1);return e=ws.bind(null,z,e.queue,!0,!1),jo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=z,i=jo();if(P){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),K===null)throw Error(o(349));J&127||Ho(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,ds(Wo.bind(null,r,a,e),[e]),r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,a,n,t),null),n},useId:function(){var e=jo(),t=K.identifierPrefix;if(P){var n=Fi,r=Pi;n=(r&~(1<<32-Je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=yo++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[_t]=t,a[vt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Pd(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Fc(t)}}return H(t),Ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=be.current,Ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=M,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[_t]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||Ui(t,!0)}else e=Bd(e).createTextNode(r),e[_t]=t,t.stateNode=e}return H(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ki(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[_t]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),e=!1}else n=F(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(po(t),t):(po(t),null);if(t.flags&128)throw Error(o(558))}return H(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[_t]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),i=!1}else i=F(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(po(t),t):(po(t),null)}return po(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Rc(t,t.updateQueue),H(t),null);case 4:return Se(),e===null&&Sd(t.stateNode.containerInfo),H(t),null;case 10:return $i(t.type),H(t),null;case 19:if(_e(L),r=t.memoizedState,r===null)return H(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)zc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=mo(e),a!==null){for(t.flags|=128,zc(r,!1),e=a.updateQueue,t.updateQueue=e,Rc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)bi(n,e),n=n.sibling;return T(L,L.current&1|2),P&&Ii(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Le()>nu&&(t.flags|=128,i=!0,zc(r,!1),t.lanes=4194304)}else{if(!i)if(e=mo(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Rc(t,e),zc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!P)return H(t),null}else 2*Le()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,i=!0,zc(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(H(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Le(),e.sibling=null,n=L.current,T(L,i?n&1|2:n&1),P&&Ii(t,r.treeForkCount),e);case 22:case 23:return po(t),ao(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(H(t),t.subtreeFlags&6&&(t.flags|=8192)):H(t),n=t.updateQueue,n!==null&&Rc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&_e(xa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$i(ua),H(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Vc(e,t){switch(j(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $i(ua),Se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return we(t),null;case 31:if(t.memoizedState!==null){if(po(t),t.alternate===null)throw Error(o(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(po(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _e(L),null;case 4:return Se(),null;case 10:return $i(t.type),null;case 22:case 23:return po(t),ao(),e!==null&&_e(xa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return $i(ua),null;case 25:return null;default:return null}}function Hc(e,t){switch(j(t),t.tag){case 3:$i(ua),Se();break;case 26:case 27:case 5:we(t);break;case 4:Se();break;case 31:t.memoizedState!==null&&po(t);break;case 13:po(t);break;case 19:_e(L);break;case 10:$i(t.type);break;case 22:case 23:po(t),ao(),e!==null&&_e(xa);break;case 24:$i(ua)}}function Uc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Wc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function Gc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{eo(t,n)}catch(t){Z(e,e.return,t)}}}function Kc(e,t,n){n.props=Js(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function qc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function Jc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}function Yc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Z(e,e.return,t)}}function Xc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[vt]=t}catch(t){Z(e,e.return,t)}}function Zc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Zc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function $c(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=un));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(el(e,t,n),e=e.sibling;e!==null;)el(e,t,n),e=e.sibling}function tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[_t]=e,t[vt]=n}catch(t){Z(e,e.return,t)}}var nl=!1,rl=!1,il=!1,al=typeof WeakSet==`function`?WeakSet:Set,U=null;function ol(e,t){if(e=e.containerInfo,Rd=sp,e=Ir(e),Lr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,U=t;U!==null;)if(t=U,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,U=e;else for(;U!==null;){switch(t=U,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(a,r,n),a[_t]=e,kt(a),r=a;break a;case`link`:var s=Vf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Pr(s,h),v=Pr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,C.T=null,n=lu,lu=null;var a=ou,s=su;if(au=0,X=ou=null,su=0,G&6)throw Error(o(331));var c=G;if(G|=4,Fl(a.current),Dl(a,a.current,s,n),G=c,id(0,!1),qe&&typeof qe.onPostCommitFiberRoot==`function`)try{qe.onPostCommitFiberRoot(Ke,a)}catch{}return!0}finally{w.p=i,C.T=r,Vu(e,t)}}function Wu(e,t,n){t=Di(n,t),t=ec(e.stateNode,t,2),e=qa(e,t,2),e!==null&&(st(e,2),rd(e))}function Z(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=Di(n,e),n=tc(2),r=qa(t,n,2),r!==null&&(nc(n,r,t,e),st(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ul=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,K===e&&(J&n)===n&&(Gl===4||Gl===3&&(J&62914560)===J&&300>Le()-eu?!(G&2)&&Su(e,0):Jl|=n,Xl===J&&(Xl=0)),rd(e)}function qu(e,t){t===0&&(t=at()),e=fi(e,t),e!==null&&(st(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),qu(e,n)}function Xu(e,t){return Ne(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=J,a=nt(r,r===K?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||rt(r,a)||(n=!0,ld(r,a));r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&Gd()&&(e=nd);for(var t=Le(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}au!==0&&au!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Jt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),kt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Jt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Jt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Jt(n.imageSizes)+`"]`)):i+=`[href="`+Jt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),kt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Jt(r)+`"][href="`+Jt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),kt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Ot(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);kt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),kt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Ot(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),kt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=be.current)?gf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Ot(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var a=Ot(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(jf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),a||Nf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Ot(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Af(e){return`href="`+Jt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),kt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Jt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Jt(n.href)+`"]`);if(r)return t.instance=r,kt(r),r;var i=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),kt(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,kt(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),kt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,kt(i),i):(r=n,(i=mf.get(a))&&(r=h({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),kt(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,kt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),kt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=e(t(),1),d=l(),f=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},p=new class extends f{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},m={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},h=new class{#e=m;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function g(e){setTimeout(e,0)}var _=typeof window>`u`||`Deno`in globalThis;function v(){}function y(e,t){return typeof e==`function`?e(t):e}function b(e){return typeof e==`number`&&e>=0&&e!==1/0}function x(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ee(e,t){return typeof e==`function`?e(t):e}function S(e,t){return typeof e==`function`?e(t):e}function te(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==re(o,t.options))return!1}else if(!ae(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function ne(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ie(t.options.mutationKey)!==ie(a))return!1}else if(!ae(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function re(e,t){return(t?.queryKeyHashFn||ie)(e)}function ie(e){return JSON.stringify(e,(e,t)=>ue(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ae(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ae(e[n],t[n])):!1}var oe=Object.prototype.hasOwnProperty;function se(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=le(e)&&le(t);if(!r&&!(ue(e)&&ue(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l{h.setTimeout(t,e)})}function C(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:se(e,t)}function w(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function pe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var me=Symbol();function he(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===me?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ge(e,t){return typeof e==`function`?e(...t):!!e}function _e(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var T=(()=>{let e=()=>_;return{isServer(){return e()},setIsServer(t){e=t}}})();function ve(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ye=g;function be(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ye,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var E=be(),xe=new class extends f{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Se(e){return Math.min(1e3*2**e,3e4)}function Ce(e){return(e??`online`)===`online`?xe.isOnline():!0}var we=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Te(e){let t=!1,n=0,r,i=ve(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new we(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>p.isFocused()&&(e.networkMode===`always`||xe.isOnline())&&e.canRun(),u=()=>Ce(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},m=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),h=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(T.isServer()?0:3),o=e.retryDelay??Se,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&nl()?void 0:m()).then(()=>{t?f(r):h()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?h():m().then(h),i)}}var Ee=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),b(this.gcTime)&&(this.#e=h.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(T.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(h.clearTimeout(this.#e),this.#e=void 0)}},De=class extends Ee{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ae(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ae(this.options);e.data!==void 0&&(this.setState(ke(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=C(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>S(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===me||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ee(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!x(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=he(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Te({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof we&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof we){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Oe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...ke(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),E.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Oe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ce(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function ke(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ae(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var je=class extends f{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ve(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Ne(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Pe(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Pe(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof S(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!ce(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Fe(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||S(this.options.enabled,this.#t)!==S(t.enabled,this.#t)||ee(this.options.staleTime,this.#t)!==ee(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||S(this.options.enabled,this.#t)!==S(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Le(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(v)),t}#g(){this.#b();let e=ee(this.options.staleTime,this.#t);if(T.isServer()||this.#r.isStale||!b(e))return;let t=x(this.#r.dataUpdatedAt,e)+1;this.#d=h.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(T.isServer()||S(this.options.enabled,this.#t)===!1||!b(this.#p)||this.#p===0)&&(this.#f=h.setInterval(()=>{(this.options.refetchIntervalInBackground||p.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(h.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(h.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ne(e,t),o=i&&Fe(e,n,t,r);(a||o)&&(l={...l,...Oe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=C(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=C(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Ie(e,t),refetch:this.refetch,promise:this.#o,isEnabled:S(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=ve())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!ce(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){E.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function Me(e,t){return S(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&S(t.retryOnMount,e)===!1)}function Ne(e,t){return Me(e,t)||e.state.data!==void 0&&Pe(e,t,t.refetchOnMount)}function Pe(e,t,n){if(S(t.enabled,e)!==!1&&ee(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ie(e,t)}return!1}function Fe(e,t,n,r){return(e!==t||S(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ie(e,n)}function Ie(e,t){return S(t.enabled,e)!==!1&&e.isStaleByTime(ee(t.staleTime,e))}function Le(e,t){return!ce(e.getCurrentResult(),t)}function Re(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{_e(e,()=>t.signal,()=>n=!0)},u=he(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?pe:w;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Be:ze,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:ze(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function ze(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Be(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ve=class extends Ee{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||He(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Te({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),E.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function He(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Ue=class extends f{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Ve({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=We(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=We(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=We(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=We(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){E.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ne(t,e))}findAll(e={}){return this.getAll().filter(t=>ne(e,t))}notify(e){E.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return E.batch(()=>Promise.all(e.map(e=>e.continue().catch(v))))}};function We(e){return e.options.scope?.id}var Ge=class extends f{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),ce(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ie(t.mutationKey)!==ie(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??He();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){E.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ke=class extends f{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??re(r,t),a=this.get(i);return a||(a=new De({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){E.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>te(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>te(e,t)):t}notify(e){E.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){E.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){E.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},qe=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Ke,this.#t=e.mutationCache||new Ue,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=p.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=xe.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ee(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=y(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return E.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;E.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return E.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=E.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(v).catch(v)}invalidateQueries(e,t={}){return E.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=E.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(v)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(v)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ee(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(v).catch(v)}fetchInfiniteQuery(e){return e.behavior=Re(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(v).catch(v)}ensureInfiniteQueryData(e){return e.behavior=Re(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return xe.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ie(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ae(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ie(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ae(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=re(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===me&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},D=r(),Je=u.createContext(void 0),Ye=e=>{let t=u.useContext(Je);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Xe=({client:e,children:t})=>(u.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,D.jsx)(Je.Provider,{value:e,children:t})),Ze=u.createContext(!1),Qe=()=>u.useContext(Ze);Ze.Provider;function $e(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var et=u.createContext($e()),tt=()=>u.useContext(et),nt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ge(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},rt=e=>{u.useEffect(()=>{e.clearReset()},[e])},it=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ge(n,[e.error,r])),at=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},ot=(e,t)=>e.isLoading&&e.isFetching&&!t,st=(e,t)=>e?.suspense&&t.isPending,ct=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function lt(e,t,n){let r=Qe(),i=tt(),a=Ye(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,at(o),nt(o,i,s),rt(i);let c=!a.getQueryCache().get(o.queryHash),[l]=u.useState(()=>new t(a,o)),d=l.getOptimisticResult(o),f=!r&&e.subscribed!==!1;if(u.useSyncExternalStore(u.useCallback(e=>{let t=f?l.subscribe(E.batchCalls(e)):v;return l.updateResult(),t},[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),u.useEffect(()=>{l.setOptions(o)},[o,l]),st(o,d))throw ct(o,l,i);if(it({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!T.isServer()&&ot(d,r)&&(c?ct(o,l,i):s?.promise)?.catch(v).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?d:l.trackResult(d)}function ut(e,t){return lt(e,je,t)}function dt(e,t){let n=Ye(t),[r]=u.useState(()=>new Ge(n,e));u.useEffect(()=>{r.setOptions(e)},[r,e]);let i=u.useSyncExternalStore(u.useCallback(e=>r.subscribe(E.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=u.useCallback((e,t)=>{r.mutate(e,t).catch(v)},[r]);if(i.error&&ge(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var ft=`modulepreload`,pt=function(e){return`/app/`+e},mt={},ht=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=pt(t,n),t in mt)return;mt[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:ft,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},gt=`popstate`;function _t(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function vt(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return St(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Ct(t)}return Tt(t,n,null,e)}function O(e,t){if(e===!1||e==null)throw Error(t)}function yt(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function bt(){return Math.random().toString(36).substring(2,10)}function xt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function St(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?wt(t):t,state:n,key:t&&t.key||r||bt(),unstable_mask:i}}function Ct({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function wt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Tt(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=_t(e)?e:St(h.location,e,t);n&&n(r,e),l=u()+1;let d=xt(r,l),f=h.createHref(r.unstable_mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=_t(e)?e:St(h.location,e,t);n&&n(r,e),l=u();let i=xt(r,l),d=h.createHref(r.unstable_mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Et(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(gt,d),c=e,()=>{i.removeEventListener(gt,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Et(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),O(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:Ct(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function Dt(e,t,n=`/`){return Ot(e,t,n,!1)}function Ot(e,t,n,r){let i=Kt((typeof t==`string`?wt(t):t).pathname||`/`,n);if(i==null)return null;let a=At(e);Mt(a);let o=null;for(let e=0;o==null&&e{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;O(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=tn([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(O(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),At(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Bt(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of jt(e.path))a(e,t,!0,n)}),t}function jt(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=jt(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Mt(e){e.sort((e,t)=>e.score===t.score?Vt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Nt=/^:[\w-]+$/,Pt=3,Ft=2,It=1,Lt=10,Rt=-2,zt=e=>e===`*`;function Bt(e,t){let n=e.split(`/`),r=n.length;return n.some(zt)&&(r+=Rt),t&&(r+=Ft),n.filter(e=>!zt(e)).reduce((e,t)=>e+(Nt.test(t)?Pt:t===``?It:Lt),r)}function Vt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function Ht(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Wt(e,t=!1,n=!0){yt(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Gt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return yt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Kt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var qt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Jt(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?wt(e):e,a;return n?(n=en(n),a=n.startsWith(`/`)?Yt(n.substring(1),`/`):Yt(n,t)):a=t,{pathname:a,search:an(r),hash:on(i)}}function Yt(e,t){let n=nn(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Xt(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Zt(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Qt(e){let t=Zt(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function $t(e,t,n,r=!1){let i;typeof e==`string`?i=wt(e):(i={...e},O(!i.pathname||!i.pathname.includes(`?`),Xt(`?`,`pathname`,`search`,i)),O(!i.pathname||!i.pathname.includes(`#`),Xt(`#`,`pathname`,`hash`,i)),O(!i.search||!i.search.includes(`#`),Xt(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Jt(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var en=e=>e.replace(/\/\/+/g,`/`),tn=e=>en(e.join(`/`)),nn=e=>e.replace(/\/+$/,``),rn=e=>nn(e).replace(/^\/*/,`/`),an=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,on=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,sn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function cn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ln(e){return tn(e.map(e=>e.route.path).filter(Boolean))||`/`}var un=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function dn(e,t){let n=e;if(typeof n!=`string`||!qt.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(un)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Kt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{yt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var fn=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(fn);var pn=[`GET`,...fn];new Set(pn);var mn=u.createContext(null);mn.displayName=`DataRouter`;var hn=u.createContext(null);hn.displayName=`DataRouterState`;var gn=u.createContext(!1);function _n(){return u.useContext(gn)}var vn=u.createContext({isTransitioning:!1});vn.displayName=`ViewTransition`;var yn=u.createContext(new Map);yn.displayName=`Fetchers`;var bn=u.createContext(null);bn.displayName=`Await`;var xn=u.createContext(null);xn.displayName=`Navigation`;var Sn=u.createContext(null);Sn.displayName=`Location`;var Cn=u.createContext({outlet:null,matches:[],isDataRoute:!1});Cn.displayName=`Route`;var wn=u.createContext(null);wn.displayName=`RouteError`;var Tn=`REACT_ROUTER_ERROR`,En=`REDIRECT`,Dn=`ROUTE_ERROR_RESPONSE`;function On(e){if(e.startsWith(`${Tn}:${En}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function kn(e){if(e.startsWith(`${Tn}:${Dn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new sn(t.status,t.statusText,t.data)}catch{}}function An(e,{relative:t}={}){O(jn(),`useHref() may be used only in the context of a component.`);let{basename:n,navigator:r}=u.useContext(xn),{hash:i,pathname:a,search:o}=zn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:tn([n,a])),r.createHref({pathname:s,search:o,hash:i})}function jn(){return u.useContext(Sn)!=null}function Mn(){return O(jn(),`useLocation() may be used only in the context of a component.`),u.useContext(Sn).location}var Nn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Pn(e){u.useContext(xn).static||u.useLayoutEffect(e)}function Fn(){let{isDataRoute:e}=u.useContext(Cn);return e?ir():In()}function In(){O(jn(),`useNavigate() may be used only in the context of a component.`);let e=u.useContext(mn),{basename:t,navigator:n}=u.useContext(xn),{matches:r}=u.useContext(Cn),{pathname:i}=Mn(),a=JSON.stringify(Qt(r)),o=u.useRef(!1);return Pn(()=>{o.current=!0}),u.useCallback((r,s={})=>{if(yt(o.current,Nn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=$t(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:tn([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var Ln=u.createContext(null);function Rn(e){let t=u.useContext(Cn).outlet;return u.useMemo(()=>t&&u.createElement(Ln.Provider,{value:e},t),[t,e])}function zn(e,{relative:t}={}){let{matches:n}=u.useContext(Cn),{pathname:r}=Mn(),i=JSON.stringify(Qt(n));return u.useMemo(()=>$t(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function Bn(e,t){return Vn(e,t)}function Vn(e,t,n){O(jn(),`useRoutes() may be used only in the context of a component.`);let{navigator:r}=u.useContext(xn),{matches:i}=u.useContext(Cn),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;or(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant (or called \`useRoutes()\`) at "${s}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let d=Mn(),f;if(t){let e=typeof t==`string`?wt(t):t;O(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),f=e}else f=d;let p=f.pathname||`/`,m=p;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);m=`/`+p.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let h=Dt(e,{pathname:m});yt(l||h!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),yt(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let g=Jn(h&&h.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:tn([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:tn([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&g?u.createElement(Sn.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...f},navigationType:`POP`}},g):g}function Hn(){let e=rr(),t=cn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=u.createElement(u.Fragment,null,u.createElement(`p`,null,`💿 Hey developer 👋`),u.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,u.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,u.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),u.createElement(u.Fragment,null,u.createElement(`h2`,null,`Unexpected Application Error!`),u.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?u.createElement(`pre`,{style:i},n):null,o)}var Un=u.createElement(Hn,null),Wn=class extends u.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=kn(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:u.createElement(Cn.Provider,{value:this.props.routeContext},u.createElement(wn.Provider,{value:e,children:this.props.component}));return this.context?u.createElement(Kn,{error:e},t):t}};Wn.contextType=gn;var Gn=new WeakMap;function Kn({children:e,error:t}){let{basename:n}=u.useContext(xn);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=On(t.digest);if(e){let r=Gn.get(t);if(r)throw r;let i=dn(e.location,n);if(un&&!Gn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw Gn.set(t,n),n}return u.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function qn({routeContext:e,match:t,children:n}){let r=u.useContext(mn);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),u.createElement(Cn.Provider,{value:e},n)}function Jn(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);O(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:ln(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let d,f=!1,p=null,m=null;r&&(d=a&&n.route.id?a[n.route.id]:void 0,p=n.route.errorElement||Un,o&&(s<0&&c===0?(or(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):s===c&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(i.slice(0,c+1)),g=()=>{let t;return t=d?p:f?m:n.route.Component?u.createElement(n.route.Component,null):n.route.element?n.route.element:e,u.createElement(qn,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?u.createElement(Wn,{location:r.location,revalidation:r.revalidation,component:p,error:d,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:l}):g()},null)}function Yn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Xn(e){let t=u.useContext(mn);return O(t,Yn(e)),t}function Zn(e){let t=u.useContext(hn);return O(t,Yn(e)),t}function Qn(e){let t=u.useContext(Cn);return O(t,Yn(e)),t}function $n(e){let t=Qn(e),n=t.matches[t.matches.length-1];return O(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function er(){return $n(`useRouteId`)}function tr(){return Zn(`useNavigation`).navigation}function nr(){let{matches:e,loaderData:t}=Zn(`useMatches`);return u.useMemo(()=>e.map(e=>kt(e,t)),[e,t])}function rr(){let e=u.useContext(wn),t=Zn(`useRouteError`),n=$n(`useRouteError`);return e===void 0?t.errors?.[n]:e}function ir(){let{router:e}=Xn(`useNavigate`),t=$n(`useNavigate`),n=u.useRef(!1);return Pn(()=>{n.current=!0}),u.useCallback(async(r,i={})=>{yt(n.current,Nn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var ar={};function or(e,t,n){!t&&!ar[e]&&(ar[e]=!0,yt(!1,n))}u.memo(sr);function sr({routes:e,future:t,state:n,isStatic:r,onError:i}){return Vn(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function cr({to:e,replace:t,state:n,relative:r}){O(jn(),` may be used only in the context of a component.`);let{static:i}=u.useContext(xn);yt(!i,` must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.`);let{matches:a}=u.useContext(Cn),{pathname:o}=Mn(),s=Fn(),c=$t(e,Qt(a),o,r===`path`),l=JSON.stringify(c);return u.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function lr(e){return Rn(e.context)}function k(e){O(!1,`A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .`)}function ur({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,unstable_useTransitions:o}){O(!jn(),`You cannot render a inside another . You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=u.useMemo(()=>({basename:s,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=wt(n));let{pathname:l=`/`,search:d=``,hash:f=``,state:p=null,key:m=`default`,unstable_mask:h}=n,g=u.useMemo(()=>{let e=Kt(l,s);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:m,unstable_mask:h},navigationType:r}},[s,l,d,f,p,m,r,h]);return yt(g!=null,` is not able to match the URL "${l}${d}${f}" because it does not start with the basename, so the won't render anything.`),g==null?null:u.createElement(xn.Provider,{value:c},u.createElement(Sn.Provider,{children:t,value:g}))}function dr({children:e,location:t}){return Bn(fr(e),t)}u.Component;function fr(e,t=[]){let n=[];return u.Children.forEach(e,(e,r)=>{if(!u.isValidElement(e))return;let i=[...t,r];if(e.type===u.Fragment){n.push.apply(n,fr(e.props.children,i));return}O(e.type===k,`[${typeof e.type==`string`?e.type:e.type.name}] is not a component. All component children of must be a or `),O(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=fr(e.props.children,i)),n.push(a)}),n}var pr=`get`,mr=`application/x-www-form-urlencoded`;function hr(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function gr(e){return hr(e)&&e.tagName.toLowerCase()===`button`}function _r(e){return hr(e)&&e.tagName.toLowerCase()===`form`}function vr(e){return hr(e)&&e.tagName.toLowerCase()===`input`}function yr(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function br(e,t){return e.button===0&&(!t||t===`_self`)&&!yr(e)}function xr(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Sr(e,t){let n=xr(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Cr=null;function wr(){if(Cr===null)try{new FormData(document.createElement(`form`),0),Cr=!1}catch{Cr=!0}return Cr}var Tr=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Er(e){return e!=null&&!Tr.has(e)?(yt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${mr}"`),null):e}function Dr(e,t){let n,r,i,a,o;if(_r(e)){let o=e.getAttribute(`action`);r=o?Kt(o,t):null,n=e.getAttribute(`method`)||pr,i=Er(e.getAttribute(`enctype`))||mr,a=new FormData(e)}else if(gr(e)||vr(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a