const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./RadioTestForm-C4p76j7C.js","./icons-BLu1UXn4.js","./react-Cfa4jLPc.js","./AmbulanceChecklist-CQ7je56N.js","./ReportPDF-WB7Q5w_0.js"])))=>i.map(i=>d[i]); import{r as Pm,a as T,S as eh,C as th,U as lh,L as Vo,b as ah,c as nh,M as ih,P as Ko,A as Jo,F as uh,R as sh,d as ch,e as rh,T as dh,f as fh,X as oh,g as mh,h as Bo,i as hh,j as xh,k as Ho,l as vh,m as bh,n as Jc,o as gh}from"./icons-BLu1UXn4.js";import{r as yh}from"./react-Cfa4jLPc.js";(function(){const F=document.createElement("link").relList;if(F&&F.supports&&F.supports("modulepreload"))return;for(const _ of document.querySelectorAll('link[rel="modulepreload"]'))b(_);new MutationObserver(_=>{for(const w of _)if(w.type==="childList")for(const H of w.addedNodes)H.tagName==="LINK"&&H.rel==="modulepreload"&&b(H)}).observe(document,{childList:!0,subtree:!0});function B(_){const w={};return _.integrity&&(w.integrity=_.integrity),_.referrerPolicy&&(w.referrerPolicy=_.referrerPolicy),_.crossOrigin==="use-credentials"?w.credentials="include":_.crossOrigin==="anonymous"?w.credentials="omit":w.credentials="same-origin",w}function b(_){if(_.ep)return;_.ep=!0;const w=B(_);fetch(_.href,w)}})();var kc={exports:{}},ri={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ro;function ph(){if(Ro)return ri;Ro=1;var j=Symbol.for("react.transitional.element"),F=Symbol.for("react.fragment");function B(b,_,w){var H=null;if(w!==void 0&&(H=""+w),_.key!==void 0&&(H=""+_.key),"key"in _){w={};for(var xe in _)xe!=="key"&&(w[xe]=_[xe])}else w=_;return _=w.ref,{$$typeof:j,type:b,key:H,ref:_!==void 0?_:null,props:w}}return ri.Fragment=F,ri.jsx=B,ri.jsxs=B,ri}var Lo;function Sh(){return Lo||(Lo=1,kc.exports=ph()),kc.exports}var u=Sh(),$c={exports:{}},di={},Wc={exports:{}},Fc={};/** * @license React * scheduler.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var wo;function Nh(){return wo||(wo=1,(function(j){function F(p,A){var U=p.length;p.push(A);e:for(;0>>1,ce=p[me];if(0<_(ce,A))p[me]=A,p[U]=ce,U=me;else break e}}function B(p){return p.length===0?null:p[0]}function b(p){if(p.length===0)return null;var A=p[0],U=p.pop();if(U!==A){p[0]=U;e:for(var me=0,ce=p.length,Ye=ce>>>1;me_(P,U))Ee_(ht,P)?(p[me]=ht,p[Ee]=U,me=Ee):(p[me]=P,p[re]=U,me=re);else if(Ee_(ht,U))p[me]=ht,p[Ee]=U,me=Ee;else break e}}return A}function _(p,A){var U=p.sortIndex-A.sortIndex;return U!==0?U:p.id-A.id}if(j.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var w=performance;j.unstable_now=function(){return w.now()}}else{var H=Date,xe=H.now();j.unstable_now=function(){return H.now()-xe}}var ne=[],_e=[],R=1,M=null,I=3,Ut=!1,ve=!1,ze=!1,K=!1,al=typeof setTimeout=="function"?setTimeout:null,Ie=typeof clearTimeout=="function"?clearTimeout:null,we=typeof setImmediate<"u"?setImmediate:null;function Jt(p){for(var A=B(_e);A!==null;){if(A.callback===null)b(_e);else if(A.startTime<=p)b(_e),A.sortIndex=A.expirationTime,F(ne,A);else break;A=B(_e)}}function qt(p){if(ze=!1,Jt(p),!ve)if(B(ne)!==null)ve=!0,mt||(mt=!0,at());else{var A=B(_e);A!==null&&jt(qt,A.startTime-p)}}var mt=!1,Nt=-1,Pe=5,Bt=-1;function ea(){return K?!0:!(j.unstable_now()-Btp&&ea());){var me=M.callback;if(typeof me=="function"){M.callback=null,I=M.priorityLevel;var ce=me(M.expirationTime<=p);if(p=j.unstable_now(),typeof ce=="function"){M.callback=ce,Jt(p),A=!0;break t}M===B(ne)&&b(ne),Jt(p)}else b(ne);M=B(ne)}if(M!==null)A=!0;else{var Ye=B(_e);Ye!==null&&jt(qt,Ye.startTime-p),A=!1}}break e}finally{M=null,I=U,Ut=!1}A=void 0}}finally{A?at():mt=!1}}}var at;if(typeof we=="function")at=function(){we(Ht)};else if(typeof MessageChannel<"u"){var Sl=new MessageChannel,Rt=Sl.port2;Sl.port1.onmessage=Ht,at=function(){Rt.postMessage(null)}}else at=function(){al(Ht,0)};function jt(p,A){Nt=al(function(){p(j.unstable_now())},A)}j.unstable_IdlePriority=5,j.unstable_ImmediatePriority=1,j.unstable_LowPriority=4,j.unstable_NormalPriority=3,j.unstable_Profiling=null,j.unstable_UserBlockingPriority=2,j.unstable_cancelCallback=function(p){p.callback=null},j.unstable_forceFrameRate=function(p){0>p||125me?(p.sortIndex=U,F(_e,p),B(ne)===null&&p===B(_e)&&(ze?(Ie(Nt),Nt=-1):ze=!0,jt(qt,U-me))):(p.sortIndex=ce,F(ne,p),ve||Ut||(ve=!0,mt||(mt=!0,at()))),p},j.unstable_shouldYield=ea,j.unstable_wrapCallback=function(p){var A=I;return function(){var U=I;I=A;try{return p.apply(this,arguments)}finally{I=U}}}})(Fc)),Fc}var Yo;function jh(){return Yo||(Yo=1,Wc.exports=Nh()),Wc.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Go;function Th(){if(Go)return di;Go=1;var j=jh(),F=Pm(),B=yh();function b(e){var t="https://react.dev/errors/"+e;if(1ce||(e.current=me[ce],me[ce]=null,ce--)}function P(e,t){ce++,me[ce]=e.current,e.current=t}var Ee=Ye(null),ht=Ye(null),Lt=Ye(null),ta=Ye(null);function Nl(e,t){switch(P(Lt,t),P(ht,e),P(Ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ao(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=ao(t),e=no(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}re(Ee),P(Ee,e)}function nl(){re(Ee),re(ht),re(Lt)}function kt(e){e.memoizedState!==null&&P(ta,e);var t=Ee.current,l=no(t,e.type);t!==l&&(P(ht,e),P(Ee,l))}function za(e){ht.current===e&&(re(Ee),re(ht)),ta.current===e&&(re(ta),ii._currentValue=U)}var la,Ea;function wt(e){if(la===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);la=t&&t[1]||"",Ea=-1)":-1n||d[a]!==h[n]){var g=` `+d[a].replace(" at new "," at ");return e.displayName&&g.includes("")&&(g=g.replace("",e.displayName)),g}while(1<=a&&0<=n);break}}}finally{on=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?wt(l):""}function Ru(e,t){switch(e.tag){case 26:case 27:case 5:return wt(e.type);case 16:return wt("Lazy");case 13:return e.child!==t&&t!==null?wt("Suspense Fallback"):wt("Suspense");case 19:return wt("SuspenseList");case 0:case 15:return Ca(e.type,!1);case 11:return Ca(e.type.render,!1);case 1:return Ca(e.type,!0);case 31:return wt("Activity");default:return""}}function fi(e){try{var t="",l=null;do t+=Ru(e,l),l=e,e=e.return;while(e);return t}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var oi=Object.prototype.hasOwnProperty,mn=j.unstable_scheduleCallback,mi=j.unstable_cancelCallback,hi=j.unstable_shouldYield,Lu=j.unstable_requestPaint,Je=j.unstable_now,wu=j.unstable_getCurrentPriorityLevel,hn=j.unstable_ImmediatePriority,xn=j.unstable_UserBlockingPriority,jl=j.unstable_NormalPriority,er=j.unstable_LowPriority,xi=j.unstable_IdlePriority,tr=j.log,Yu=j.unstable_setDisableYieldValue,Da=null,ke=null;function Yt(e){if(typeof tr=="function"&&Yu(e),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(Da,e)}catch{}}var et=Math.clz32?Math.clz32:lr,Gu=Math.log,Qu=Math.LN2;function lr(e){return e>>>=0,e===0?32:31-(Gu(e)/Qu|0)|0}var X=256,Se=262144,aa=4194304;function Tl(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 na(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,i=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var r=a&134217727;return r!==0?(a=r&~i,a!==0?n=Tl(a):(s&=r,s!==0?n=Tl(s):l||(l=r&~e,l!==0&&(n=Tl(l))))):(r=a&~i,r!==0?n=Tl(r):s!==0?n=Tl(s):l||(l=a&~e,l!==0&&(n=Tl(l)))),n===0?0:t!==0&&t!==n&&(t&i)===0&&(i=n&-n,l=t&-t,i>=l||i===32&&(l&4194048)!==0)?t:n}function _a(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function vn(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 vi(){var e=aa;return aa<<=1,(aa&62914560)===0&&(aa=4194304),e}function ia(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function ua(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function bn(e,t,l,a,n,i){var s=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var r=e.entanglements,d=e.expirationTimes,h=e.hiddenUpdates;for(l=s&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Ku=/[\n"\\]/g;function it(e){return e.replace(Ku,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Ni(e,t,l,a,n,i,s,r){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+nt(t)):e.value!==""+nt(t)&&(e.value=""+nt(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?Nn(e,s,nt(t)):l!=null?Nn(e,s,nt(l)):a!=null&&e.removeAttribute("value"),n==null&&i!=null&&(e.defaultChecked=!!i),n!=null&&(e.checked=n&&typeof n!="function"&&typeof n!="symbol"),r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"?e.name=""+nt(r):e.removeAttribute("name")}function ji(e,t,l,a,n,i,s,r){if(i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(e.type=i),t!=null||l!=null){if(!(i!=="submit"&&i!=="reset"||t!=null)){Sn(e);return}l=l!=null?""+nt(l):"",t=t!=null?""+nt(t):l,r||t===e.value||(e.value=t),e.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=r?e.checked:!!a,e.defaultChecked=!!a,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),Sn(e)}function Nn(e,t,l){t==="number"&&Ba(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function _l(e,t,l,a){if(e=e.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fe=!1;if(Xt)try{var E={};Object.defineProperty(E,"passive",{get:function(){Fe=!0}}),window.addEventListener("test",E,E),window.removeEventListener("test",E,E)}catch{Fe=!1}var tt=null,ra=null,Di=null;function ar(){if(Di)return Di;var e,t=ra,l=t.length,a,n="value"in tt?tt.value:tt.textContent,i=n.length;for(e=0;e=zn),rr=" ",dr=!1;function fr(e,t){switch(e){case"keyup":return S0.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function or(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ha=!1;function j0(e,t){switch(e){case"compositionend":return or(t);case"keypress":return t.which!==32?null:(dr=!0,rr);case"textInput":return e=t.data,e===rr&&dr?null:e;default:return null}}function T0(e,t){if(Ha)return e==="compositionend"||!Pu&&fr(e,t)?(e=ar(),Di=ra=tt=null,Ha=!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:l,offset:t-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=pr(l)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ba(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=Ba(e.document)}return t}function ls(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 O0=Xt&&"documentMode"in document&&11>=document.documentMode,Ra=null,as=null,_n=null,ns=!1;function Tr(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;ns||Ra==null||Ra!==Ba(a)||(a=Ra,"selectionStart"in a&&ls(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),_n&&Dn(_n,a)||(_n=a,a=Nu(as,"onSelect"),0>=s,n-=s,Pt=1<<32-et(t)+n|l<Q?($=D,D=null):$=D.sibling;var le=x(o,D,m[Q],y);if(le===null){D===null&&(D=$);break}e&&D&&le.alternate===null&&t(o,D),f=i(le,f,Q),te===null?O=le:te.sibling=le,te=le,D=$}if(Q===m.length)return l(o,D),W&&sl(o,Q),O;if(D===null){for(;QQ?($=D,D=null):$=D.sibling;var Il=x(o,D,le.value,y);if(Il===null){D===null&&(D=$);break}e&&D&&Il.alternate===null&&t(o,D),f=i(Il,f,Q),te===null?O=Il:te.sibling=Il,te=Il,D=$}if(le.done)return l(o,D),W&&sl(o,Q),O;if(D===null){for(;!le.done;Q++,le=m.next())le=S(o,le.value,y),le!==null&&(f=i(le,f,Q),te===null?O=le:te.sibling=le,te=le);return W&&sl(o,Q),O}for(D=a(D);!le.done;Q++,le=m.next())le=v(D,o,Q,le.value,y),le!==null&&(e&&le.alternate!==null&&D.delete(le.key===null?Q:le.key),f=i(le,f,Q),te===null?O=le:te.sibling=le,te=le);return e&&D.forEach(function(Im){return t(o,Im)}),W&&sl(o,Q),O}function oe(o,f,m,y){if(typeof m=="object"&&m!==null&&m.type===ze&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case Ut:e:{for(var O=m.key;f!==null;){if(f.key===O){if(O=m.type,O===ze){if(f.tag===7){l(o,f.sibling),y=n(f,m.props.children),y.return=o,o=y;break e}}else if(f.elementType===O||typeof O=="object"&&O!==null&&O.$$typeof===Pe&&ya(O)===f.type){l(o,f.sibling),y=n(f,m.props),Hn(y,m),y.return=o,o=y;break e}l(o,f);break}else t(o,f);f=f.sibling}m.type===ze?(y=ha(m.props.children,o.mode,y,m.key),y.return=o,o=y):(y=wi(m.type,m.key,m.props,null,o.mode,y),Hn(y,m),y.return=o,o=y)}return s(o);case ve:e:{for(O=m.key;f!==null;){if(f.key===O)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){l(o,f.sibling),y=n(f,m.children||[]),y.return=o,o=y;break e}else{l(o,f);break}else t(o,f);f=f.sibling}y=fs(m,o.mode,y),y.return=o,o=y}return s(o);case Pe:return m=ya(m),oe(o,f,m,y)}if(jt(m))return C(o,f,m,y);if(at(m)){if(O=at(m),typeof O!="function")throw Error(b(150));return m=O.call(m),q(o,f,m,y)}if(typeof m.then=="function")return oe(o,f,Ki(m),y);if(m.$$typeof===we)return oe(o,f,Qi(o,m),y);Ji(o,m)}return typeof m=="string"&&m!==""||typeof m=="number"||typeof m=="bigint"?(m=""+m,f!==null&&f.tag===6?(l(o,f.sibling),y=n(f,m),y.return=o,o=y):(l(o,f),y=ds(m,o.mode,y),y.return=o,o=y),s(o)):l(o,f)}return function(o,f,m,y){try{Bn=0;var O=oe(o,f,m,y);return ka=null,O}catch(D){if(D===Ja||D===Zi)throw D;var te=vt(29,D,null,o.mode);return te.lanes=y,te.return=o,te}finally{}}}var Sa=Jr(!0),kr=Jr(!1),Bl=!1;function js(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ts(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 Hl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Rl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(ae&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=Li(e),Mr(e,null,l),t}return Ri(e,a,t,l),Li(e)}function Rn(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Al(e,l)}}function As(e,t){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,i=null;if(l=l.firstBaseUpdate,l!==null){do{var s={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};i===null?n=i=s:i=i.next=s,l=l.next}while(l!==null);i===null?n=i=t:i=i.next=t}else n=i=t;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:i,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var zs=!1;function Ln(){if(zs){var e=Ka;if(e!==null)throw e}}function wn(e,t,l,a){zs=!1;var n=e.updateQueue;Bl=!1;var i=n.firstBaseUpdate,s=n.lastBaseUpdate,r=n.shared.pending;if(r!==null){n.shared.pending=null;var d=r,h=d.next;d.next=null,s===null?i=h:s.next=h,s=d;var g=e.alternate;g!==null&&(g=g.updateQueue,r=g.lastBaseUpdate,r!==s&&(r===null?g.firstBaseUpdate=h:r.next=h,g.lastBaseUpdate=d))}if(i!==null){var S=n.baseState;s=0,g=h=d=null,r=i;do{var x=r.lane&-536870913,v=x!==r.lane;if(v?(k&x)===x:(a&x)===x){x!==0&&x===Va&&(zs=!0),g!==null&&(g=g.next={lane:0,tag:r.tag,payload:r.payload,callback:null,next:null});e:{var C=e,q=r;x=t;var oe=l;switch(q.tag){case 1:if(C=q.payload,typeof C=="function"){S=C.call(oe,S,x);break e}S=C;break e;case 3:C.flags=C.flags&-65537|128;case 0:if(C=q.payload,x=typeof C=="function"?C.call(oe,S,x):C,x==null)break e;S=M({},S,x);break e;case 2:Bl=!0}}x=r.callback,x!==null&&(e.flags|=64,v&&(e.flags|=8192),v=n.callbacks,v===null?n.callbacks=[x]:v.push(x))}else v={lane:x,tag:r.tag,payload:r.payload,callback:r.callback,next:null},g===null?(h=g=v,d=S):g=g.next=v,s|=x;if(r=r.next,r===null){if(r=n.shared.pending,r===null)break;v=r,r=v.next,v.next=null,n.lastBaseUpdate=v,n.shared.pending=null}}while(!0);g===null&&(d=S),n.baseState=d,n.firstBaseUpdate=h,n.lastBaseUpdate=g,i===null&&(n.shared.lanes=0),Ql|=s,e.lanes=s,e.memoizedState=S}}function $r(e,t){if(typeof e!="function")throw Error(b(191,e));e.call(t)}function Wr(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;ei?i:8;var s=p.T,r={};p.T=r,Vs(e,!1,t,l);try{var d=n(),h=p.S;if(h!==null&&h(r,d),d!==null&&typeof d=="object"&&typeof d.then=="function"){var g=G0(d,a);Qn(e,t,g,St(e))}else Qn(e,t,a,St(e))}catch(S){Qn(e,t,{then:function(){},status:"rejected",reason:S},St())}finally{A.p=i,s!==null&&r.types!==null&&(s.types=r.types),p.T=s}}function J0(){}function Xs(e,t,l,a){if(e.tag!==5)throw Error(b(476));var n=Cd(e).queue;Ed(e,n,t,U,l===null?J0:function(){return Dd(e),l(a)})}function Cd(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fl,lastRenderedState:U},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fl,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Dd(e){var t=Cd(e);t.next===null&&(t=e.alternate.memoizedState),Qn(e,t.next.queue,{},St())}function Zs(){return Xe(ii)}function _d(){return De().memoizedState}function Md(){return De().memoizedState}function k0(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=St();e=Hl(l);var a=Rl(t,e,l);a!==null&&(ot(a,t,l),Rn(a,t,l)),t={cache:ys()},e.payload=t;return}t=t.return}}function $0(e,t,l){var a=St();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},au(e)?Ud(t,l):(l=cs(e,t,l,a),l!==null&&(ot(l,e,a),qd(l,t,a)))}function Od(e,t,l){var a=St();Qn(e,t,l,a)}function Qn(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(au(e))Ud(t,n);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,r=i(s,l);if(n.hasEagerState=!0,n.eagerState=r,xt(r,s))return Ri(e,t,n,0),he===null&&Hi(),!1}catch{}finally{}if(l=cs(e,t,n,a),l!==null)return ot(l,e,a),qd(l,t,a),!0}return!1}function Vs(e,t,l,a){if(a={lane:2,revertLane:jc(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},au(e)){if(t)throw Error(b(479))}else t=cs(e,l,a,2),t!==null&&ot(t,e,2)}function au(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function Ud(e,t){Wa=Wi=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function qd(e,t,l){if((l&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Al(e,l)}}var Xn={readContext:Xe,use:Pi,useCallback:Te,useContext:Te,useEffect:Te,useImperativeHandle:Te,useLayoutEffect:Te,useInsertionEffect:Te,useMemo:Te,useReducer:Te,useRef:Te,useState:Te,useDebugValue:Te,useDeferredValue:Te,useTransition:Te,useSyncExternalStore:Te,useId:Te,useHostTransitionStatus:Te,useFormState:Te,useActionState:Te,useOptimistic:Te,useMemoCache:Te,useCacheRefresh:Te};Xn.useEffectEvent=Te;var Bd={readContext:Xe,use:Pi,useCallback:function(e,t){return lt().memoizedState=[e,t===void 0?null:t],e},useContext:Xe,useEffect:gd,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,tu(4194308,4,Nd.bind(null,t,e),l)},useLayoutEffect:function(e,t){return tu(4194308,4,e,t)},useInsertionEffect:function(e,t){tu(4,2,e,t)},useMemo:function(e,t){var l=lt();t=t===void 0?null:t;var a=e();if(Na){Yt(!0);try{e()}finally{Yt(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=lt();if(l!==void 0){var n=l(t);if(Na){Yt(!0);try{l(t)}finally{Yt(!1)}}}else n=t;return a.memoizedState=a.baseState=n,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=$0.bind(null,Y,e),[a.memoizedState,e]},useRef:function(e){var t=lt();return e={current:e},t.memoizedState=e},useState:function(e){e=Ls(e);var t=e.queue,l=Od.bind(null,Y,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Gs,useDeferredValue:function(e,t){var l=lt();return Qs(l,e,t)},useTransition:function(){var e=Ls(!1);return e=Ed.bind(null,Y,e.queue,!0,!1),lt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=Y,n=lt();if(W){if(l===void 0)throw Error(b(407));l=l()}else{if(l=t(),he===null)throw Error(b(349));(k&127)!==0||ld(a,t,l)}n.memoizedState=l;var i={value:l,getSnapshot:t};return n.queue=i,gd(nd.bind(null,a,i,e),[e]),a.flags|=2048,Ia(9,{destroy:void 0},ad.bind(null,a,i,l,t),null),l},useId:function(){var e=lt(),t=he.identifierPrefix;if(W){var l=el,a=Pt;l=(a&~(1<<32-et(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Fi++,0<\/script>",i=i.removeChild(i.firstChild);break;case"select":i=typeof a.is=="string"?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?i.multiple=!0:a.size&&(i.size=a.size);break;default:i=typeof a.is=="string"?s.createElement(n,{is:a.is}):s.createElement(n)}}i[Me]=t,i[Ne]=a;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)i.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 e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=i;e:switch(Ve(i,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&ml(t)}}return ge(t),ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&ml(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(b(166));if(e=Lt.current,Xa(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=Qe,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[Me]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||to(e.nodeValue,l)),e||Ul(t,!0)}else e=ju(e).createTextNode(a),e[Me]=t,t.stateNode=e}return ge(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=Xa(t),l!==null){if(e===null){if(!a)throw Error(b(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(b(557));e[Me]=t}else xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;ge(t),e=!1}else l=xs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(gt(t),t):(gt(t),null);if((t.flags&128)!==0)throw Error(b(558))}return ge(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=Xa(t),a!==null&&a.dehydrated!==null){if(e===null){if(!n)throw Error(b(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(b(317));n[Me]=t}else xa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;ge(t),n=!1}else n=xs(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(gt(t),t):(gt(t),null)}return gt(t),(t.flags&128)!==0?(t.lanes=l,t):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),i=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(i=a.memoizedState.cachePool.pool),i!==n&&(a.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),cu(t,t.updateQueue),ge(t),null);case 4:return nl(),e===null&&Ec(t.stateNode.containerInfo),ge(t),null;case 10:return rl(t.type),ge(t),null;case 19:if(re(Ce),a=t.memoizedState,a===null)return ge(t),null;if(n=(t.flags&128)!==0,i=a.rendering,i===null)if(n)Vn(a,!1);else{if(Ae!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=$i(e),i!==null){for(t.flags|=128,Vn(a,!1),e=i.updateQueue,t.updateQueue=e,cu(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)Or(l,e),l=l.sibling;return P(Ce,Ce.current&1|2),W&&sl(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&Je()>mu&&(t.flags|=128,n=!0,Vn(a,!1),t.lanes=4194304)}else{if(!n)if(e=$i(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,cu(t,e),Vn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!W)return ge(t),null}else 2*Je()-a.renderingStartTime>mu&&l!==536870912&&(t.flags|=128,n=!0,Vn(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(e=a.last,e!==null?e.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=Je(),e.sibling=null,l=Ce.current,P(Ce,n?l&1|2:l&1),W&&sl(t,a.treeForkCount),e):(ge(t),null);case 22:case 23:return gt(t),Cs(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(l&536870912)!==0&&(t.flags&128)===0&&(ge(t),t.subtreeFlags&6&&(t.flags|=8192)):ge(t),l=t.updateQueue,l!==null&&cu(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==l&&(t.flags|=2048),e!==null&&re(ga),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),rl(Oe),ge(t),null;case 25:return null;case 30:return null}throw Error(b(156,t.tag))}function em(e,t){switch(ms(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return rl(Oe),nl(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return za(t),null;case 31:if(t.memoizedState!==null){if(gt(t),t.alternate===null)throw Error(b(340));xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(gt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(b(340));xa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return re(Ce),null;case 4:return nl(),null;case 10:return rl(t.type),null;case 22:case 23:return gt(t),Cs(),e!==null&&re(ga),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return rl(Oe),null;case 25:return null;default:return null}}function uf(e,t){switch(ms(t),t.tag){case 3:rl(Oe),nl();break;case 26:case 27:case 5:za(t);break;case 4:nl();break;case 31:t.memoizedState!==null&>(t);break;case 13:gt(t);break;case 19:re(Ce);break;case 10:rl(t.type);break;case 22:case 23:gt(t),Cs(),e!==null&&re(ga);break;case 24:rl(Oe)}}function Kn(e,t){try{var l=t.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&e)===e){a=void 0;var i=l.create,s=l.inst;a=i(),s.destroy=a}l=l.next}while(l!==n)}}catch(r){se(t,t.return,r)}}function Yl(e,t,l){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var i=n.next;a=i;do{if((a.tag&e)===e){var s=a.inst,r=s.destroy;if(r!==void 0){s.destroy=void 0,n=t;var d=l,h=r;try{h()}catch(g){se(n,d,g)}}}a=a.next}while(a!==i)}}catch(g){se(t,t.return,g)}}function sf(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{Wr(t,l)}catch(a){se(e,e.return,a)}}}function cf(e,t,l){l.props=ja(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){se(e,t,a)}}function Jn(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(n){se(e,t,n)}}function tl(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){se(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){se(e,t,n)}else l.current=null}function rf(e){var t=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){se(e,e.return,n)}}function uc(e,t,l){try{var a=e.stateNode;Nm(a,e.type,l,t),a[Ne]=t}catch(n){se(e,e.return,n)}}function df(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Jl(e.type)||e.tag===4}function sc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||df(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&&Jl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cc(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=ee));else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(cc(e,t,l),e=e.sibling;e!==null;)cc(e,t,l),e=e.sibling}function ru(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(ru(e,t,l),e=e.sibling;e!==null;)ru(e,t,l),e=e.sibling}function ff(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);Ve(t,a,l),t[Me]=e,t[Ne]=l}catch(i){se(e,e.return,i)}}var hl=!1,Be=!1,rc=!1,of=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function tm(e,t){if(e=e.containerInfo,_c=_u,e=jr(e),ls(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var s=0,r=-1,d=-1,h=0,g=0,S=e,x=null;t:for(;;){for(var v;S!==l||n!==0&&S.nodeType!==3||(r=s+n),S!==i||a!==0&&S.nodeType!==3||(d=s+a),S.nodeType===3&&(s+=S.nodeValue.length),(v=S.firstChild)!==null;)x=S,S=v;for(;;){if(S===e)break t;if(x===l&&++h===n&&(r=s),x===i&&++g===a&&(d=s),(v=S.nextSibling)!==null)break;S=x,x=S.parentNode}S=v}l=r===-1||d===-1?null:{start:r,end:d}}else l=null}l=l||{start:0,end:0}}else l=null;for(Mc={focusedElem:e,selectionRange:l},_u=!1,Ge=t;Ge!==null;)if(t=Ge,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ge=e;else for(;Ge!==null;){switch(t=Ge,i=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),Ve(i,a,l),i[Me]=e,G(i),a=i;break e;case"link":var s=yo("link","href",n).get(a+(l.href||""));if(s){for(var r=0;roe&&(s=oe,oe=q,q=s);var o=Sr(r,q),f=Sr(r,oe);if(o&&f&&(v.rangeCount!==1||v.anchorNode!==o.node||v.anchorOffset!==o.offset||v.focusNode!==f.node||v.focusOffset!==f.offset)){var m=S.createRange();m.setStart(o.node,o.offset),v.removeAllRanges(),q>oe?(v.addRange(m),v.extend(f.node,f.offset)):(m.setEnd(f.node,f.offset),v.addRange(m))}}}}for(S=[],v=r;v=v.parentNode;)v.nodeType===1&&S.push({element:v,left:v.scrollLeft,top:v.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;rl?32:l,p.T=null,l=vc,vc=null;var i=Zl,s=yl;if(Le=0,an=Zl=null,yl=0,(ae&6)!==0)throw Error(b(331));var r=ae;if(ae|=4,jf(i.current),pf(i,i.current,s,l),ae=r,Pn(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(Da,i)}catch{}return!0}finally{A.p=n,p.T=a,Gf(e,t)}}function Xf(e,t,l){t=zt(l,t),t=$s(e.stateNode,t,2),e=Rl(e,t,2),e!==null&&(ua(e,2),ll(e))}function se(e,t,l){if(e.tag===3)Xf(e,e,l);else for(;t!==null;){if(t.tag===3){Xf(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Xl===null||!Xl.has(a))){e=zt(l,e),l=Xd(2),a=Rl(t,l,2),a!==null&&(Zd(l,a,t,e),ua(a,2),ll(a));break}}t=t.return}}function pc(e,t,l){var a=e.pingCache;if(a===null){a=e.pingCache=new nm;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(l)||(oc=!0,n.add(l),e=rm.bind(null,e,t,l),t.then(e,e))}function rm(e,t,l){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,he===e&&(k&l)===l&&(Ae===4||Ae===3&&(k&62914560)===k&&300>Je()-ou?(ae&2)===0&&nn(e,0):mc|=l,ln===k&&(ln=0)),ll(e)}function Zf(e,t){t===0&&(t=vi()),e=ma(e,t),e!==null&&(ua(e,t),ll(e))}function dm(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),Zf(e,l)}function fm(e,t){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,n=e.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(b(314))}a!==null&&a.delete(t),Zf(e,l)}function om(e,t){return mn(e,t)}var yu=null,sn=null,Sc=!1,pu=!1,Nc=!1,Kl=0;function ll(e){e!==sn&&e.next===null&&(sn===null?yu=sn=e:sn=sn.next=e),pu=!0,Sc||(Sc=!0,hm())}function Pn(e,t){if(!Nc&&pu){Nc=!0;do for(var l=!1,a=yu;a!==null;){if(e!==0){var n=a.pendingLanes;if(n===0)var i=0;else{var s=a.suspendedLanes,r=a.pingedLanes;i=(1<<31-et(42|e)+1)-1,i&=n&~(s&~r),i=i&201326741?i&201326741|1:i?i|2:0}i!==0&&(l=!0,kf(a,i))}else i=k,i=na(a,a===he?i:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(i&3)===0||_a(a,i)||(l=!0,kf(a,i));a=a.next}while(l);Nc=!1}}function mm(){Vf()}function Vf(){pu=Sc=!1;var e=0;Kl!==0&&Tm()&&(e=Kl);for(var t=Je(),l=null,a=yu;a!==null;){var n=a.next,i=Kf(a,t);i===0?(a.next=null,l===null?yu=n:l.next=n,n===null&&(sn=l)):(l=a,(e!==0||(i&3)!==0)&&(pu=!0)),a=n}Le!==0&&Le!==5||Pn(e),Kl!==0&&(Kl=0)}function Kf(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,i=e.pendingLanes&-62914561;0r)break;var g=d.transferSize,S=d.initiatorType;g&&lo(S)&&(d=d.responseEnd,s+=g*(d"u"?null:document;function xo(e,t,l){var a=cn;if(a&&typeof t=="string"&&t){var n=it(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),ho.has(n)||(ho.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),Ve(t,"link",e),G(t),a.head.appendChild(t)))}}function Um(e){pl.D(e),xo("dns-prefetch",e,null)}function qm(e,t){pl.C(e,t),xo("preconnect",e,t)}function Bm(e,t,l){pl.L(e,t,l);var a=cn;if(a&&e&&t){var n='link[rel="preload"][as="'+it(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+it(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+it(l.imageSizes)+'"]')):n+='[href="'+it(e)+'"]';var i=n;switch(t){case"style":i=rn(e);break;case"script":i=dn(e)}Ot.has(i)||(e=M({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Ot.set(i,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(ai(i))||t==="script"&&a.querySelector(ni(i))||(t=a.createElement("link"),Ve(t,"link",e),G(t),a.head.appendChild(t)))}}function Hm(e,t){pl.m(e,t);var l=cn;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+it(a)+'"][href="'+it(e)+'"]',i=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=dn(e)}if(!Ot.has(i)&&(e=M({rel:"modulepreload",href:e},t),Ot.set(i,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ni(i)))return}a=l.createElement("link"),Ve(a,"link",e),G(a),l.head.appendChild(a)}}}function Rm(e,t,l){pl.S(e,t,l);var a=cn;if(a&&e){var n=$e(a).hoistableStyles,i=rn(e);t=t||"default";var s=n.get(i);if(!s){var r={loading:0,preload:null};if(s=a.querySelector(ai(i)))r.loading=5;else{e=M({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Ot.get(i))&&Lc(e,l);var d=s=a.createElement("link");G(d),Ve(d,"link",e),d._p=new Promise(function(h,g){d.onload=h,d.onerror=g}),d.addEventListener("load",function(){r.loading|=1}),d.addEventListener("error",function(){r.loading|=2}),r.loading|=4,Au(s,t,a)}s={type:"stylesheet",instance:s,count:1,state:r},n.set(i,s)}}}function Lm(e,t){pl.X(e,t);var l=cn;if(l&&e){var a=$e(l).hoistableScripts,n=dn(e),i=a.get(n);i||(i=l.querySelector(ni(n)),i||(e=M({src:e,async:!0},t),(t=Ot.get(n))&&wc(e,t),i=l.createElement("script"),G(i),Ve(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function wm(e,t){pl.M(e,t);var l=cn;if(l&&e){var a=$e(l).hoistableScripts,n=dn(e),i=a.get(n);i||(i=l.querySelector(ni(n)),i||(e=M({src:e,async:!0,type:"module"},t),(t=Ot.get(n))&&wc(e,t),i=l.createElement("script"),G(i),Ve(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function vo(e,t,l,a){var n=(n=Lt.current)?Tu(n):null;if(!n)throw Error(b(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=rn(l.href),l=$e(n).hoistableStyles,a=l.get(t),a||(a={type:"style",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=rn(l.href);var i=$e(n).hoistableStyles,s=i.get(e);if(s||(n=n.ownerDocument||n,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},i.set(e,s),(i=n.querySelector(ai(e)))&&!i._p&&(s.instance=i,s.state.loading=5),Ot.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ot.set(e,l),i||Ym(n,e,l,s.state))),t&&a===null)throw Error(b(528,""));return s}if(t&&a!==null)throw Error(b(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=dn(l),l=$e(n).hoistableScripts,a=l.get(t),a||(a={type:"script",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(b(444,e))}}function rn(e){return'href="'+it(e)+'"'}function ai(e){return'link[rel="stylesheet"]['+e+"]"}function bo(e){return M({},e,{"data-precedence":e.precedence,precedence:null})}function Ym(e,t,l,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Ve(t,"link",l),G(t),e.head.appendChild(t))}function dn(e){return'[src="'+it(e)+'"]'}function ni(e){return"script[async]"+e}function go(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+it(l.href)+'"]');if(a)return t.instance=a,G(a),a;var n=M({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),G(a),Ve(a,"style",n),Au(a,l.precedence,e),t.instance=a;case"stylesheet":n=rn(l.href);var i=e.querySelector(ai(n));if(i)return t.state.loading|=4,t.instance=i,G(i),i;a=bo(l),(n=Ot.get(n))&&Lc(a,n),i=(e.ownerDocument||e).createElement("link"),G(i);var s=i;return s._p=new Promise(function(r,d){s.onload=r,s.onerror=d}),Ve(i,"link",a),t.state.loading|=4,Au(i,l.precedence,e),t.instance=i;case"script":return i=dn(l.src),(n=e.querySelector(ni(i)))?(t.instance=n,G(n),n):(a=l,(n=Ot.get(i))&&(a=M({},l),wc(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),G(n),Ve(n,"link",a),e.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(b(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Au(a,l.precedence,e));return t.instance}function Au(e,t,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,i=n,s=0;s title"):null)}function Gm(e,t,l){if(l===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 So(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Qm(e,t,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=rn(a.href),i=t.querySelector(ai(n));if(i){t=i._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Eu.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=i,G(i);return}i=t.ownerDocument||t,a=bo(a),(n=Ot.get(n))&&Lc(a,n),i=i.createElement("link"),G(i);var s=i;s._p=new Promise(function(r,d){s.onload=r,s.onerror=d}),Ve(i,"link",a),l.instance=i}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Eu.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Yc=0;function Xm(e,t){return e.stylesheets&&e.count===0&&Du(e,e.stylesheets),0Yc?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Eu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Du(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Cu=null;function Du(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Cu=new Map,t.forEach(Zm,e),Cu=null,Eu.call(e))}function Zm(e,t){if(!(t.state.loading&4)){var l=Cu.get(e);if(l)var a=l.get(null);else{l=new Map,Cu.set(e,l);for(var n=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(j)}catch(F){console.error(F)}}return j(),$c.exports=Th(),$c.exports}var zh=Ah();const Eh="modulepreload",Ch=function(j,F){return new URL(j,F).href},Xo={},Pc=function(F,B,b){let _=Promise.resolve();if(B&&B.length>0){let H=function(R){return Promise.all(R.map(M=>Promise.resolve(M).then(I=>({status:"fulfilled",value:I}),I=>({status:"rejected",reason:I}))))};const xe=document.getElementsByTagName("link"),ne=document.querySelector("meta[property=csp-nonce]"),_e=ne?.nonce||ne?.getAttribute("nonce");_=H(B.map(R=>{if(R=Ch(R,b),R in Xo)return;Xo[R]=!0;const M=R.endsWith(".css"),I=M?'[rel="stylesheet"]':"";if(!!b)for(let ze=xe.length-1;ze>=0;ze--){const K=xe[ze];if(K.href===R&&(!M||K.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${R}"]${I}`))return;const ve=document.createElement("link");if(ve.rel=M?"stylesheet":Eh,M||(ve.as="script"),ve.crossOrigin="",ve.href=R,_e&&ve.setAttribute("nonce",_e),document.head.appendChild(ve),M)return new Promise((ze,K)=>{ve.addEventListener("load",ze),ve.addEventListener("error",()=>K(new Error(`Unable to preload CSS for ${R}`)))})}))}function w(H){const xe=new Event("vite:preloadError",{cancelable:!0});if(xe.payload=H,window.dispatchEvent(xe),!xe.defaultPrevented)throw H}return _.then(H=>{for(const xe of H||[])xe.status==="rejected"&&w(xe.reason);return F().catch(w)})};/** * @license * SPDX-License-Identifier: Apache-2.0 */const ko=[{id:"1",username:"admin",fullName:"นพ.เกียรติภูมิ ภูมิใจไทย (ผู้อำนวยการศูนย์)",role:"Admin",isActive:!0,pin:"1234",mustChangePin:!1},{id:"2",username:"supervisor1",fullName:"พญ.ชลิดา พัชรสมุย (แพทย์อำนวยการ/Supervisor)",role:"Supervisor",isActive:!0,pin:"1234",mustChangePin:!1},{id:"3",username:"dispatcher1",fullName:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",role:"Dispatcher",isActive:!0,pin:"1234",mustChangePin:!1},{id:"4",username:"dispatcher2",fullName:"นางสาวสุดารัตน์ บรรเทา (Dispatcher 02)",role:"Dispatcher",isActive:!0,pin:"1234",mustChangePin:!1},{id:"5",username:"executive1",fullName:"ดร.สมชาย สมุยดี (ผู้บริหารระดับสูง)",role:"Executive",isActive:!0,pin:"1234",mustChangePin:!1},{id:"6",username:"samui_er",fullName:"พยาบาลสมหญิง รักเกาะ (พยาบาลวิชาชีพ ER รพ.เกาะสมุย)",role:"ER Koh Samui",isActive:!0,pin:"1234",mustChangePin:!1},{id:"7",username:"quality1",fullName:"นางพิศมัย พัฒนาระบบ (เจ้าหน้าที่ควบคุมคุณภาพ)",role:"Quality Officer",isActive:!0,pin:"1234",mustChangePin:!1},{id:"8",username:"driver1",fullName:"นายเด่นดนัย ขับปลอดภัย (พขร. กู้ชีพ)",role:"Driver",isActive:!0,pin:"1234",mustChangePin:!1},{id:"9",username:"ems1",fullName:"นายกิตติพงษ์ สุขใจ (กู้ชีพวิชาชีพ EMS)",role:"EMS",isActive:!0,pin:"1234",mustChangePin:!1}],$o=[{id:"u1",name:"โรงพยาบาลเกาะสมุย",level:"ALS",isActive:!0,isSamuiHospital:!0,sortOrder:1},{id:"u2",name:"โรงพยาบาลเกาะพะงัน",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:2},{id:"u3",name:"โรงพยาบาลเกาะเต่า",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:3},{id:"u4",name:"โรงพยาบาลไทยอินเตอร์",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:4},{id:"u5",name:"โรงพยาบาลบ้านดอนอินเตอร์",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:5},{id:"u6",name:"โรงพยาบาลกรุงเทพสมุย",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:6},{id:"u7",name:"โรงพยาบาลวัฒนแพทย์สมุย",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:7},{id:"u8",name:"โรงพยาบาลพะงันอินเตอร์",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:8},{id:"u9",name:"โรงพยาบาลเฟิร์สเวสเทิร์น",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:9},{id:"u10",name:"เทศบาลนครเกาะสมุย",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:10},{id:"u11",name:"หน่วยกู้ชีพหน้าเมือง",level:"CLS",isActive:!0,isSamuiHospital:!1,sortOrder:11},{id:"u12",name:"หน่วยกู้ชีพละไม",level:"CLS",isActive:!0,isSamuiHospital:!1,sortOrder:12},{id:"u13",name:"หน่วยกู้ชีพเฉวง",level:"CLS",isActive:!0,isSamuiHospital:!1,sortOrder:13},{id:"u14",name:"กู้ภัยสมุยจุดสระเกศ",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:14},{id:"u15",name:"กู้ภัยสมุยจุดศิลางู",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:15},{id:"u16",name:"กู้ภัยสมุยจุดบ้านใต้",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:16},{id:"u17",name:"กู้ภัยสมุยจุดบ่อผุด",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:17},{id:"u18",name:"กู้ภัยพะงัน",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:18},{id:"u19",name:"กู้ภัยเกาะเต่า",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:19}],Zh=["พะงัน 2","เกาะเต่า 2","กู้ภัยพะงัน","กู้ภัยสมุย","เมืองสมุย","กู้ชีพละไม","กู้ชีพหน้าเมือง","กู้ชีพเฉวง","โรงพยาบาลกรุงเทพสมุย","โรงพยาบาลไทยอินเตอร์","โรงพยาบาลบ้านดอนอินเตอร์","โรงพยาบาลวัฒนแพทย์สมุย","โรงพยาบาลพะงันอินเตอร์","โรงพยาบาลไทยอินเตอร์เกาะพะงัน","ER สมุย","พขร. ว.4"],Zo=[{code:"01",title:"ปวดท้อง/หลัง/อุ้งเชิงกราน"},{code:"02",title:"แพ้ยา/แพ้แมลง/ภูมิแพ้"},{code:"03",title:"สัตว์กัด/ต่อย"},{code:"04",title:"ทำร้ายตนเอง/พยายามฆ่าตัวตาย"},{code:"05",title:"ไหม้/น้ำร้อนลวก/โดนสารเคมี"},{code:"06",title:"เจ็บหน้าอก/หัวใจ"},{code:"07",title:"สำลักสิ่งอุดกั้นทางเดินหายใจ"},{code:"08",title:"หมดสติ/ไม่รู้สึกตัว/โคม่า"},{code:"09",title:"ได้รับสารพิษ/ยาเกินขนาด"},{code:"10",title:"จมน้ำ/อุบัติเหตุทางน้ำ"},{code:"11",title:"ไฟช็อต/ฟ้าผ่า"},{code:"12",title:"เจ็บตา/ปัญหาทางการมองเห็น"},{code:"13",title:"ปวดศีรษะ"},{code:"14",title:"หัวใจหยุดเต้น/ไม่หายใจ"},{code:"15",title:"ตกที่สูง/อุบัติเหตุสิ่งของหล่นทับ"},{code:"16",title:"เลือดออก/ตกเลือด"},{code:"17",title:"อุบัติเหตุจราจร (RTI)"},{code:"18",title:"คลอดชีพ/แท้ง/ปัญหาทางนรีเวช"},{code:"19",title:"ชัก/ลมบ้าหมู"},{code:"20",title:"หลอดเลือดสมองอุดตัน/ตีบ/แตก (Stroke)"},{code:"21",title:"หายใจลำบาก/หอบหืด"},{code:"22",title:"จิตเวช/ก้าวร้าว/คลุ้มคลั่ง"},{code:"23",title:"ป่วย/อ่อนเพลีย/ไม่สบายตัว"},{code:"24",title:"ได้รับบาดเจ็บทางร่างกายอื่น ๆ"},{code:"25",title:"ภัยพิบัติ/เหตุสาธารณภัยกลุ่มใหญ่"}],Dh=[{id:"NRT-01",plateNo:"กข-9988 สุราษฎร์ธานี",unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",type:"ALS",isActive:!0},{id:"NRT-02",plateNo:"กข-5566 สุราษฎร์ธานี",unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",type:"ALS",isActive:!0},{id:"NRT-03",plateNo:"นค-1122 สุราษฎร์ธานี",unitId:"u2",unitName:"โรงพยาบาลเกาะพะงัน",type:"ALS",isActive:!0},{id:"NRT-04",plateNo:"นค-3344 สุราษฎร์ธานี",unitId:"u3",unitName:"โรงพยาบาลเกาะเต่า",type:"BLS",isActive:!0},{id:"NRT-05",plateNo:"บท-7744 สุราษฎร์ธานี",unitId:"u11",unitName:"หน่วยกู้ชีพหน้าเมือง",type:"BLS",isActive:!0},{id:"NRT-06",plateNo:"บท-8855 สุราษฎร์ธานี",unitId:"u12",unitName:"หน่วยกู้ชีพละไม",type:"BLS",isActive:!0}],Vh=[{id:"m1_1",name:"ระบบไฟฟ้าของรถพยาบาล (ไฟหน้า/ไฟเลี้ยว/ไฟหรี่)",category:1,severity:"critical"},{id:"m1_2",name:"เครื่องยนต์ (เช็กระดับน้ำมันเครื่อง/เสียงเครื่องยนต์)",category:1,severity:"critical"},{id:"m1_3",name:"แบตเตอรี่รถและขั้วต่อแบตเตอรี่",category:1,severity:"critical"},{id:"m1_4",name:"ระดับน้ำมันเชื้อเพลิง (ต้องมากกว่าครึ่งถัง)",category:1,severity:"critical"},{id:"m1_5",name:"ยางรถทุกล้อ (ความดันลมยางและดอกยาง)",category:1,severity:"critical"},{id:"m1_6",name:"ยางอะไหล่ประจำรถ",category:1,severity:"important"},{id:"m1_7",name:"แม่แรงและอุปกรณ์เครื่องมือเปลี่ยนยาง",category:1,severity:"important"},{id:"m1_8",name:"ไฟไซเรน/ไฟฉุกเฉินบนหลังคารถ",category:1,severity:"critical"},{id:"m1_9",name:"เสียงสัญญาณไซเรนฉุกเฉิน",category:1,severity:"critical"},{id:"m1_10",name:"ไฟส่องสว่างภายในห้องปฏิบัติการผู้ป่วย",category:1,severity:"critical"},{id:"m1_11",name:"วิทยุสื่อสารประจำรถ (ติดรถ/มือถือ)",category:1,severity:"critical"},{id:"m1_12",name:"เครื่องปรับอากาศห้องขับขี่ด้านหน้า",category:1,severity:"general"},{id:"m1_13",name:"เครื่องปรับอากาศห้องปฏิบัติการผู้ป่วยด้านหลัง",category:1,severity:"important"},{id:"m1_14",name:"ถังดับเพลิงเคมีประจำรถ",category:1,severity:"critical",requiredCount:1},{id:"m1_15",name:"เข็มขัดนิรภัยห้องคนขับและทีมงาน",category:1,severity:"important"},{id:"m1_16",name:"เข็มขัดรัดตรึงเปลผู้ป่วย",category:1,severity:"critical"},{id:"m1_17",name:"ประตูรถ ระบบล็อก และกลอนล็อกประตูทิศต่าง ๆ",category:1,severity:"critical"},{id:"m1_18",name:"ความสะอาดห้องโดยสารหน้ารถ",category:1,severity:"general"},{id:"m1_19",name:"ความสะอาดห้องผู้ป่วยด้านหลัง",category:1,severity:"important"},{id:"m1_20",name:"การฉีดพ่นทำความสะอาดฆ่าเชื้อหลังปฏิบัติภารกิจล่าสุด",category:1,severity:"critical"},{id:"m1_21",name:"อุปกรณ์ความปลอดภัยทางถนน (กรวยสะท้อนแสง/ไฟกระพริบพกพา)",category:1,severity:"important"},{id:"m1_22",name:"เอกสารพรบ. ประกันภัย สมุดบันทึก และเอกสารนำส่งผู้ป่วย",category:1,severity:"important"},{id:"m2_1",name:"เครื่อง Defibrillator/Monitor (ทดสอบเปิด/เช็กสายต่อ)",category:2,severity:"critical"},{id:"m2_2",name:"แบตเตอรี่เครื่อง Defibrillator/Monitor (พร้อมใช้/ชาร์จเต็ม)",category:2,severity:"critical"},{id:"m2_3",name:"สาย ECG และแผ่นนำไฟฟ้าแบบเจล (ECG Electrodes)",category:2,severity:"important"},{id:"m2_4",name:"แผ่นนำไฟฟ้าสำหรับช็อกไฟฟ้าชนิดใช้ครั้งเดียว (AED/Defib Pads)",category:2,severity:"critical",requiredCount:2},{id:"m2_5",name:"เครื่องช็อกไฟฟ้าอัตโนมัติ (AED เครื่องพกพา)",category:2,severity:"important"},{id:"m2_6",name:"เครื่องดูดเสมหะระบบติดตั้งในรถพยาบาล (Suction Wall)",category:2,severity:"critical"},{id:"m2_7",name:"เครื่องดูดเสมหะแบบเคลื่อนย้ายได้ (Portable Suction)",category:2,severity:"critical"},{id:"m2_8",name:"ระบบ Oxygen Pipeline (เช็กข้อต่อและแรงดัน)",category:2,severity:"critical"},{id:"m2_9",name:"ถังออกซิเจนหลักในตัวรถ (ปริมาณแรงดันเกจ์)",category:2,severity:"critical"},{id:"m2_10",name:"ถังออกซิเจนสำรองแบบพกพา",category:2,severity:"critical"},{id:"m2_11",name:"ปริมาณแรงดันออกซิเจนคงเหลือพร้อมใช้งานจริง (ต้อง > 1,000 PSI)",category:2,severity:"critical"},{id:"m2_12",name:"อุปกรณ์คุมเกจ์ออกซิเจน (Regulator)",category:2,severity:"critical"},{id:"m2_13",name:"อุปกรณ์ปรับอัตราไหลออกซิเจน (Flow meter)",category:2,severity:"critical"},{id:"m2_14",name:"เครื่องช่วยหายใจชนิดบีบมือ (BVM) สำหรับผู้ใหญ่",category:2,severity:"critical",requiredCount:1},{id:"m2_15",name:"เครื่องช่วยหายใจชนิดบีบมือ (BVM) สำหรับเด็ก",category:2,severity:"critical",requiredCount:1},{id:"m2_16",name:"เครื่องช่วยหายใจชนิดบีบมือ (BVM) สำหรับทารกแรกเกิด",category:2,severity:"important",requiredCount:1},{id:"m2_17",name:"ชุดส่องกล่องเสียงตรวจทางเดินหายใจ (Laryngoscope Set)",category:2,severity:"critical"},{id:"m2_18",name:"ด้ามและใบมีดชุดส่องกล่องเสียง (ตรวจขนาดตรงกับรถ)",category:2,severity:"critical"},{id:"m2_19",name:"แบตเตอรี่ในด้ามส่องและหลอดไฟใบมีด (สว่างชัดเจน)",category:2,severity:"critical"},{id:"m2_20",name:"ท่อช่วยหายใจทางปาก (ET Tube) ขนาด 6.5, 7.0, 7.5, 8.0",category:2,severity:"critical",requiredCount:4},{id:"m2_21",name:"ลวดนำสำหรับใส่ท่อช่วยหายใจ (Stylet)",category:2,severity:"important",requiredCount:2},{id:"m2_22",name:"อุปกรณ์นำส่องทางเดินหายใจ (Bougie)",category:2,severity:"important"},{id:"m2_23",name:"หน้ากากกล่องเสียงท่อช่วยหายใจฉุกเฉิน (LMA)",category:2,severity:"important"},{id:"m2_24",name:"ท่อเปิดทางเดินหายใจทางปาก (Oropharyngeal Airway)",category:2,severity:"critical",requiredCount:5},{id:"m2_25",name:"ท่อเปิดทางเดินหายใจทางจมูก (Nasopharyngeal Airway)",category:2,severity:"important"},{id:"m2_26",name:"อุปกรณ์ยึดตรึงท่อช่วยหายใจ (Tube Holder / เทปกาวเหนียว)",category:2,severity:"important"},{id:"m2_27",name:"เครื่องวัดความเข้มข้นออกซิเจนปลายนิ้ว (Pulse Oximeter)",category:2,severity:"critical",requiredCount:1},{id:"m2_28",name:"เครื่องวัดความดันโลหิตแบบดิจิตอล/บีบมือ",category:2,severity:"critical",requiredCount:1},{id:"m2_29",name:"ผ้าพันแขนวัดความดัน (Cuff) ขนาดผู้ใหญ่ และเด็ก",category:2,severity:"important"},{id:"m2_30",name:"หูฟังแพทย์ (Stethoscope)",category:2,severity:"critical",requiredCount:1},{id:"m2_31",name:"เครื่องวัดระดับน้ำตาลในกระแสเลือด (Glucometer)",category:2,severity:"critical",requiredCount:1},{id:"m2_32",name:"แผ่นแถบตรวจระดับน้ำตาล (Gluco Strip)",category:2,severity:"critical",requiredCount:15},{id:"m2_33",name:"เครื่องวัดอุณหภูมิร่างกาย (Thermometer)",category:2,severity:"important"},{id:"m2_34",name:"เครื่องกดนวดหัวใจอัตโนมัติ (Mechanical CPR) (ถ้ามี)",category:2,severity:"general"},{id:"m2_35",name:"เครื่องควบคุมให้สารละลายทางหลอดเลือดดำ (Infusion Pump)",category:2,severity:"general"},{id:"m2_36",name:"เครื่องช่วยหายใจเคลื่อนย้ายพกพาอัตโนมัติ (Ventilator) (ถ้ามี)",category:2,severity:"important"},{id:"m3_1",name:"เปลนอนหลักประจำรถพยาบาล (Main Stretcher)",category:3,severity:"critical"},{id:"m3_2",name:"ระบบแท่นรางล็อกตัวเปลเข้ากับโครงตัวรถพยาบาล",category:3,severity:"critical"},{id:"m3_3",name:"สายเข็มขัดรัดตรึงตัวคนป่วยบนเปล (อย่างน้อย 3 จุด)",category:3,severity:"critical"},{id:"m3_4",name:"เปลตักเคลื่อนย้ายผู้ป่วย (Scoop Stretcher)",category:3,severity:"important"},{id:"m3_5",name:"กระดานแข็งรองหลังช่วยชีวิต (Long Spinal Board)",category:3,severity:"critical"},{id:"m3_6",name:"กระดานสั้นรองหลัง (Short Spinal Board) (ถ้ามี)",category:3,severity:"general"},{id:"m3_7",name:"ที่นอนสูญญากาศลดแรงกระแทก (Vacuum Mattress)",category:3,severity:"important"},{id:"m3_8",name:"เฝือกคอชนิดแข็งสำหรับผู้ใหญ่ (Cervical Collar Adult)",category:3,severity:"critical",requiredCount:2},{id:"m3_9",name:"เฝือกคอชนิดแข็งสำหรับเด็ก (Cervical Collar Pediatric)",category:3,severity:"important",requiredCount:1},{id:"m3_10",name:"อุปกรณ์ประคองข้างศีรษะ (Head Immobilizer)",category:3,severity:"critical",requiredCount:1},{id:"m3_11",name:"เฝือกดามแขนแยกสัดส่วน (Arm Splints)",category:3,severity:"important",requiredCount:2},{id:"m3_12",name:"เฝือกดามขาแยกสัดส่วน (Leg Splints)",category:3,severity:"important",requiredCount:2},{id:"m3_13",name:"เฝือกลมระบบสูญญากาศ (Vacuum Splint)",category:3,severity:"general"},{id:"m3_14",name:"เฝือกดึงกระดูกต้นขาหัก (Traction Splint)",category:3,severity:"important"},{id:"m3_15",name:"เก้าอี้เคลื่อนย้ายผู้ป่วยลงบันได (Stair Chair)",category:3,severity:"important"},{id:"m3_16",name:"ผ้ารองเลื่อนตัว/ยกย้ายแบบผ้าหนาเหนียว (Carrying Sheet)",category:3,severity:"important"},{id:"m3_17",name:"เปลตะกร้าสำหรับเคลื่อนย้ายในที่สูงหรือข้ามเกาะ (Basket Stretcher)",category:3,severity:"important"},{id:"m3_18",name:"สายและชุดยึดตรึงผู้ป่วยเข้ากับเปลตะกร้า",category:3,severity:"important"},{id:"m3_19",name:"เชือกโรยตัวและชุดรอกกู้ภัยขั้นต้นประจำเรือ/รถ",category:3,severity:"general"},{id:"m3_20",name:"เสื้อชูชีพสำหรับเจ้าหน้าที่ปฏิบัติการทางน้ำ",category:3,severity:"critical",requiredCount:4},{id:"m3_21",name:"เสื้อชูชีพสำหรับคนไข้/ญาติคนไข้",category:3,severity:"critical",requiredCount:2},{id:"m3_22",name:"อุปกรณ์ทุ่นพยุงลอยคอ/บอร์ดลอยน้ำกู้ภัยทางทะเล",category:3,severity:"important"},{id:"m3_23",name:"ผ้าห่มความร้อน/ผ้าห่มพับผืนหนารองนอน",category:3,severity:"general",requiredCount:2},{id:"m3_24",name:"ผ้าคลุมปิดผู้เสียชีวิต",category:3,severity:"general"},{id:"m3_25",name:"ฟอยล์สีเงินอลูมิเนียมกักอุณหภูมิร่างกายป้องก้นช็อกหนาว",category:3,severity:"important"},{id:"m4_1",name:"กระเป๋ายาฉุกเฉินหลัก (เช็กกุญแจล็อกซีลและใบรายการพร้อมใช้)",category:4,severity:"critical"},{id:"m4_2",name:"สารน้ำ NSS 0.9% ขนาด 1000ml และ 500ml",category:4,severity:"critical",requiredCount:4},{id:"m4_3",name:"สารน้ำ 5%D/N/2 ขนาด 500ml",category:4,severity:"important",requiredCount:2},{id:"m4_4",name:"สารน้ำ Acetar ขนาด 1000ml / 500ml",category:4,severity:"important",requiredCount:2},{id:"m4_5",name:"กระบอกฉีดยา (Syringe) ขนาด 1ml, 3ml, 5ml, 10ml, 20ml, 50ml",category:4,severity:"important",requiredCount:12},{id:"m4_6",name:"เข็มฉีดยาขนาดต่าง ๆ (No. 18, 21, 24, 25)",category:4,severity:"important",requiredCount:15},{id:"m4_7",name:"เข็มแทงเส้นเลือดดำสำหรับให้น้ำเกลือ (IV Catheter) No. 18, 20, 22, 24",category:4,severity:"critical",requiredCount:10},{id:"m4_8",name:"สายต่อเพิ่มความยาวชุดให้น้ำเกลือ (Extension Tube)",category:4,severity:"important"},{id:"m4_9",name:"ข้อต่อสามทางควบคุมทิศทางยา (Three-way Stopcock)",category:4,severity:"important",requiredCount:2},{id:"m4_10",name:"ชุดอุปกรณ์ให้น้ำเกลือมาตรฐาน (IV Set)",category:4,severity:"critical",requiredCount:4},{id:"m4_11",name:"สายรัดข้อพับสำหรับแทงเส้นเลือดำ (Tourniquet)",category:4,severity:"critical",requiredCount:2},{id:"m4_12",name:"สำลีแอลกอฮอล์ฉีกซองฆ่าเชื้อ (Alcohol Pad)",category:4,severity:"important",requiredCount:20},{id:"m4_13",name:"พลาสเตอร์ติดทับสายน้ำเกลือ (Tegaderm/Micropore)",category:4,severity:"important"},{id:"m4_14",name:"ผ้าก๊อซทำแผลปลอดเชื้อขนาด 2x2, 3x3, 4x4 (Gauze Pad Steril)",category:4,severity:"important",requiredCount:15},{id:"m4_15",name:"ผ้าปิดแผลขนาดใหญ่เหนียวพกพา (Top Dressing / Combine Pad)",category:4,severity:"important",requiredCount:5},{id:"m4_16",name:"ผ้าพันยืดหยุ่นลดแรงดันห้ามเลือด (Elastic Bandage) ขนาด 3, 4, 6 นิ้ว",category:4,severity:"important",requiredCount:6},{id:"m4_17",name:"น้ำยาเบตาดีน/น้ำยาทำแผลฆ่าเชื้อโรค",category:4,severity:"important"},{id:"m4_18",name:"ขวดน้ำเกลือทำความสะอาดล้างแผล (Normal Saline Sterile)",category:4,severity:"important",requiredCount:2},{id:"m4_19",name:"ถุงขยะแดงทิ้งสิ่งปนเปื้อนสารคัดหลั่ง",category:4,severity:"important"},{id:"m4_20",name:"กล่องเจาะพลาสติกแข็งทิ้งเข็มใช้แล้วป้องก้นเข็มตำ",category:4,severity:"critical",requiredCount:1},{id:"m4_21",name:"ถุงมือตรวจโรคชนิดใช้ครั้งเดียวทิ้ง (Gloves) ขนาด S, M, L",category:4,severity:"critical",requiredCount:100},{id:"m4_22",name:"ถุงมือปราศจากเชื้อทางการแพทย์ (Sterile Gloves) บรรจุซอง",category:4,severity:"critical",requiredCount:10},{id:"m4_23",name:"หน้ากากอนามัยชนิดธรรมดา (Surgical Mask)",category:4,severity:"critical",requiredCount:50},{id:"m4_24",name:"หน้ากากอนามัยชนิดป้องกันอนุภาคเล็กพิเศษ N95",category:4,severity:"important",requiredCount:5},{id:"m4_25",name:"หน้ากากใสกันกระเซ็น / แว่นครอบป้องกันใบหน้าสายตา",category:4,severity:"important",requiredCount:4},{id:"m4_26",name:"เสื้อคลุม PPE แบบกันน้ำชนิดใช้ครั้งเดียวกึ่งซักได้",category:4,severity:"important",requiredCount:4},{id:"m4_27",name:"ผ้าก๊อซกึ่งห้ามเลือดในแผลกระสุนปืนหรือแผลเหวอะ (Trauma Dressing)",category:4,severity:"critical",requiredCount:2},{id:"m4_28",name:"สายรัดขันชะเนาะห้ามเลือดภายนอกสไตล์ทหาร (Tourniquet ห้ามเลือด)",category:4,severity:"critical",requiredCount:2},{id:"m4_29",name:"แผ่นแปะซีลแผลทะลวงหน้าอกป้องก้นปอดแฟบ (Chest Seal)",category:4,severity:"critical",requiredCount:2},{id:"m4_30",name:"ชุดเข็มระบายลมออกจากช่องอกแรงดันสูง (Needle Decompression Set)",category:4,severity:"critical",requiredCount:1},{id:"m4_31",name:"สายรัดยึดกระดูกเชิงกรานหักช็อกตกเลือด (Pelvic Binder)",category:4,severity:"important",requiredCount:1},{id:"m4_32",name:"ผ้าคลุมทำแผลไฟไหม้พุพองสูญเสียความชื้น (Burn Sheet)",category:4,severity:"important",requiredCount:1},{id:"m4_33",name:"ชุดอุปกรณ์ทำคลอดฉุกเฉินประกอบด้วยผ้า กรรไกร คีมจับ (Delivery Set)",category:4,severity:"critical",requiredCount:1},{id:"m4_34",name:"คีมพลาสติกหนีบสายสะดือเด็กทารก (Cord Clamp)",category:4,severity:"critical",requiredCount:2},{id:"m4_35",name:"ลูกยางแดงเบอร์ 3 ดูดเสมหะทารกแรกคลอด",category:4,severity:"critical",requiredCount:1}],_h=[{id:"c1",timestamp:"2026-07-15T09:12:00",date:"2026-07-15",time:"09:12",shift:"เช้า",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",callType:"สายแจ้งเหตุหรือสายปฏิบัติการ",channel:"First Call"},{id:"c2",timestamp:"2026-07-15T10:05:00",date:"2026-07-15",time:"10:05",shift:"เช้า",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",callType:"สายแจ้งเหตุหรือสายปฏิบัติการ",channel:"Second Call"},{id:"c3",timestamp:"2026-07-15T11:40:00",date:"2026-07-15",time:"11:40",shift:"เช้า",username:"dispatcher2",recordedBy:"นางสาวสุดารัตน์ บรรเทา (Dispatcher 02)",callType:"สายก่อกวน",channel:"First Call"},{id:"c4",timestamp:"2026-07-15T13:15:00",date:"2026-07-15",time:"13:15",shift:"เช้า",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",callType:"โทรผิด",channel:"หมายเลขอื่น",channelDetail:"081-xxxxxxx"},{id:"c5",timestamp:"2026-07-15T14:22:00",date:"2026-07-15",time:"14:22",shift:"เช้า",username:"dispatcher2",recordedBy:"นางสาวสุดารัตน์ บรรเทา (Dispatcher 02)",callType:"แจ้งเหตุอื่น",otherReason:"ประสานงานเคลื่อนย้ายสุนัขบาดเจ็บ",channel:"วิธีอื่น ๆ",channelDetail:"LINE กู้ภัย"},{id:"c6",timestamp:"2026-07-15T17:10:00",date:"2026-07-15",time:"17:10",shift:"บ่าย",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",callType:"สายแจ้งเหตุหรือสายปฏิบัติการ",channel:"First Call"},{id:"c7",timestamp:"2026-07-15T18:30:00",date:"2026-07-15",time:"18:30",shift:"บ่าย",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",callType:"สายแจ้งเหตุหรือสายปฏิบัติการ",channel:"วิทยุ"}],Mh=[{id:"OB-2569-0012",createdAt:"2026-07-15T09:15:00",date:"2026-07-15",time:"09:15",shift:"เช้า",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",type:"EMS",unitLevel:"ALS",unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",cbdCode:"17",phoneTriage:"แดง",sceneTriage:"แดง",erTriage:"แดง",fastTrack:"Multiple Trauma",path:"ทางบก",responsibleDispatcher:"dispatcher1",consultingDoctor:!0,doctorName:"พญ.ชลิดา พัชรสมุย",onlineMedicalProtocol:"IV Fluid resuscitation & Splinting",diagnosis:"ผู้บาดเจ็บชายชาวต่างชาติ มอเตอร์ไซค์ชนท้ายรถกระบะ หมดสติ มีแผลฉีกขาดขนาดใหญ่ที่ศีรษะและสงสัยกระดูกต้นขาหักข้างขวา",riskDetected:"ไม่มีความเสี่ยงพิเศษในเวร",status:"ปิดเคส"},{id:"OB-2569-0013",createdAt:"2026-07-15T10:10:00",date:"2026-07-15",time:"10:10",shift:"เช้า",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",type:"Refer",unitLevel:"ALS",unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",cbdCode:"20",phoneTriage:"แดง",sceneTriage:"เหลือง",erTriage:"แดง",fastTrack:"STROKE",path:"ทางน้ำ",responsibleDispatcher:"dispatcher1",consultingDoctor:!0,doctorName:"พญ.ชลิดา พัชรสมุย",onlineMedicalProtocol:"Oxygen therapy, Pre-alert ER",diagnosis:"หญิงไทยอายุ 65 ปี มีอาการหน้าเบี้ยว พูดไม่ชัด แขนขาซีกซ้ายอ่อนแรงเฉียบพลัน 2 ชั่วโมงก่อนมา รพ. นำส่งเกาะสมุยประสานลำเลียงขึ้นฝั่ง",riskDetected:"คลื่นลมทะเลแรงปานกลางในรอบบ่าย",status:"ปรับปรุงข้อมูลแล้ว"},{id:"OB-2569-0014",createdAt:"2026-07-15T17:15:00",date:"2026-07-15",time:"17:15",shift:"บ่าย",username:"dispatcher1",recordedBy:"นายสมเกียรติ มุ่งมั่น (Dispatcher 01)",type:"EMS",unitLevel:"CLS",unitId:"u11",unitName:"หน่วยกู้ชีพหน้าเมือง",cbdCode:"01",phoneTriage:"เขียว",sceneTriage:"เขียว",erTriage:"เขียว",fastTrack:"ไม่มี Fast Track",path:"ทางบก",responsibleDispatcher:"dispatcher2",consultingDoctor:!1,diagnosis:"ผู้ป่วยหญิง 24 ปี ปวดท้องน้อยด้านขวา เจ็บตื้อ ๆ ไม่มีไข้ เดินไหว สัญญาณชีพปกติ",riskDetected:"ฝนตกถนนลื่น",status:"ค้างปรับปรุงข้อมูล"}],Oh=[{unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",status:"พร้อมปฏิบัติการ",recordedBy:"dispatcher1",updatedAt:"2026-07-15T08:00:00"},{unitId:"u2",unitName:"โรงพยาบาลเกาะพะงัน",status:"พร้อมปฏิบัติการ",recordedBy:"dispatcher1",updatedAt:"2026-07-15T08:00:00"},{unitId:"u3",unitName:"โรงพยาบาลเกาะเต่า",status:"พร้อมปฏิบัติการ",recordedBy:"dispatcher1",updatedAt:"2026-07-15T08:00:00"},{unitId:"u11",unitName:"หน่วยกู้ชีพหน้าเมือง",status:"พร้อมปฏิบัติการ",recordedBy:"dispatcher1",updatedAt:"2026-07-15T08:00:00"},{unitId:"u12",unitName:"หน่วยกู้ชีพละไม",status:"ไม่พร้อมปฏิบัติการ",reason:"ยางรถเสื่อมสภาพ/อยู่ระหว่างรออะไหล่ส่งซ่อม",startTime:"2026-07-15T08:30:00",estimatedEndTime:"",unknownEndTime:!0,recordedBy:"dispatcher1",updatedAt:"2026-07-15T08:30:00"}],Uh=[{id:"rt_1",date:"2026-07-15",time:"08:45",shift:"เช้า",testerUsername:"dispatcher1",testerName:"นายสมเกียรติ มุ่งมั่น",items:[{stationId:"s1",stationName:"พะงัน 2",txLevel:"5",rxLevel:"5",channelType:"R"},{stationId:"s2",stationName:"เกาะเต่า 2",txLevel:"4",rxLevel:"4",channelType:"R"},{stationId:"s3",stationName:"กู้ภัยพะงัน",txLevel:"5",rxLevel:"4",channelType:"R"},{stationId:"s4",stationName:"กู้ภัยสมุย",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s5",stationName:"เมืองสมุย",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s6",stationName:"กู้ชีพละไม",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s7",stationName:"กู้ชีพหน้าเมือง",txLevel:"4",rxLevel:"4",channelType:"T"},{stationId:"s8",stationName:"กู้ชีพเฉวง",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s9",stationName:"โรงพยาบาลกรุงเทพสมุย",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s10",stationName:"โรงพยาบาลไทยอินเตอร์",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s11",stationName:"โรงพยาบาลบ้านดอนอินเตอร์",txLevel:"4",rxLevel:"4",channelType:"T"},{stationId:"s12",stationName:"โรงพยาบาลวัฒนแพทย์สมุย",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s13",stationName:"โรงพยาบาลพะงันอินเตอร์",txLevel:"4",rxLevel:"3",channelType:"R"},{stationId:"s14",stationName:"โรงพยาบาลไทยอินเตอร์เกาะพะงัน",txLevel:"ติดต่อไม่ได้",rxLevel:"ติดต่อไม่ได้",channelType:"R",note:"เสาวิทยุชำรุดชั่วคราว"},{stationId:"s15",stationName:"ER สมุย",txLevel:"5",rxLevel:"5",channelType:"T"},{stationId:"s16",stationName:"พขร. ว.4",txLevel:"5",rxLevel:"4",channelType:"T"}],extraStations:[{stationName:"กู้ชีพตลิ่งงาม",txLevel:"4",rxLevel:"4",channelType:"T",note:"สถานีเสริม"}],testedCount:16,untestedCount:1,unreachableStations:["โรงพยาบาลไทยอินเตอร์เกาะพะงัน"]}],qh=[{id:"acs_1",date:"2026-07-15",timeStart:"08:05",timeEnd:"08:20",shift:"เช้า",ambulanceId:"NRT-01",plateNo:"กข-9988 สุราษฎร์ธานี",unitId:"u1",unitName:"โรงพยาบาลเกาะสมุย",checkerUsername:"driver1",checkerName:"นายเด่นดนัย ขับปลอดภัย",checkerRole:"Driver",overallStatus:"พร้อมปฏิบัติการ",mileage:145230,fuelLevel:"เต็มถัง",results:[{itemId:"m1_1",itemName:"ระบบไฟฟ้าของรถพยาบาล (ไฟหน้า/ไฟเลี้ยว/ไฟหรี่)",status:"พร้อมใช้",severity:"critical"},{itemId:"m1_2",itemName:"เครื่องยนต์ (เช็กระดับน้ำมันเครื่อง/เสียงเครื่องยนต์)",status:"พร้อมใช้",severity:"critical"},{itemId:"m1_4",itemName:"ระดับน้ำมันเชื้อเพลิง (ต้องมากกว่าครึ่งถัง)",status:"พร้อมใช้",severity:"critical"},{itemId:"m1_5",itemName:"ยางรถทุกล้อ (ความดันลมยางและดอกยาง)",status:"พร้อมใช้",severity:"critical"}]},{id:"acs_2",date:"2026-07-15",timeStart:"08:10",timeEnd:"08:30",shift:"เช้า",ambulanceId:"NRT-06",plateNo:"บท-8855 สุราษฎร์ธานี",unitId:"u12",unitName:"หน่วยกู้ชีพละไม",checkerUsername:"ems1",checkerName:"นายกิตติพงษ์ สุขใจ",checkerRole:"EMS",overallStatus:"พร้อมใช้งานแบบมีข้อจำกัด",remarks:"เวชภัณฑ์ Trauma และหน้ากาก N95 มีจำนวนเหลือน้อยกว่าขั้นต่ำ กำลังรอการสั่งเบิกเติม",results:[{itemId:"m4_23",itemName:"หน้ากากอนามัยชนิดธรรมดา (Surgical Mask)",status:"พร้อมใช้",severity:"critical"},{itemId:"m4_24",itemName:"หน้ากากอนามัยชนิดป้องกันอนุภาคเล็กพิเศษ N95",status:"จำนวนไม่เพียงพอ",problemDetails:"เหลือ 1 ชิ้น มาตรฐาน 5 ชิ้น",foundCount:1,requiredCount:5,severity:"important"},{itemId:"m4_27",itemName:"ผ้าก๊อซกึ่งห้ามเลือดในแผลกระสุนปืนหรือแผลเหวอะ (Trauma Dressing)",status:"จำนวนไม่เพียงพอ",problemDetails:"หมดคลังรถ มาตรฐานต้องมี 2 ผืน",foundCount:0,requiredCount:2,severity:"critical"}]}],Wo=[{id:"TKT-2569-001",ambulanceId:"NRT-06",plateNo:"บท-8855 สุราษฎร์ธานี",unitName:"หน่วยกู้ชีพละไม",itemId:"m4_27",itemName:"ผ้าก๊อซกึ่งห้ามเลือดในแผลกระสุนปืนหรือแผลเหวอะ (Trauma Dressing)",problemDetails:"หมดคลังรถ มาตรฐานต้องมี 2 ผืน จำเป็นต้องเบิกจ่ายทดแทนด่วน",reportedAt:"2026-07-15T08:30:00",reportedBy:"นายกิตติพงษ์ สุขใจ",severity:"critical",status:"อยู่ระหว่างดำเนินการ",assignedTo:"หัวหน้าทีมพัสดุกู้ชีพ",targetDate:"2026-07-16"},{id:"TKT-2569-002",ambulanceId:"NRT-02",plateNo:"กข-5566 สุราษฎร์ธานี",unitName:"โรงพยาบาลเกาะสมุย",itemId:"m1_8",itemName:"ไฟไซเรน/ไฟฉุกเฉินบนหลังคารถ",problemDetails:"หลอดไฟ LED ด้านซ้ายท้ายไม่ติดกะพริบ สายไฟหลวมชำรุด",reportedAt:"2026-07-14T15:20:00",reportedBy:"นายเด่นดนัย ขับปลอดภัย",severity:"critical",status:"ส่งซ่อม",assignedTo:"ช่างสมหมาย บริการไฟรถยนต์",targetDate:"2026-07-15",actionDetails:"ส่งช่างถอดแผงครอบไซเรนออกตรวจซ่อมแก้ไขขั้วสัมผัส"}];function Pl(j,F){const B=localStorage.getItem(`nrt_${j}`);if(B)try{return JSON.parse(B)}catch{return F}return F}function Ke(j,F){localStorage.setItem(`nrt_${j}`,JSON.stringify(F))}function Bh(){localStorage.getItem("nrt_users")||Ke("users",ko),localStorage.getItem("nrt_units")||Ke("units",$o),localStorage.getItem("nrt_call_logs")||Ke("call_logs",_h),localStorage.getItem("nrt_cases")||Ke("cases",Mh),localStorage.getItem("nrt_unit_statuses")||Ke("unit_statuses",Oh),localStorage.getItem("nrt_radio_tests")||Ke("radio_tests",Uh),localStorage.getItem("nrt_ambulances")||Ke("ambulances",Dh),localStorage.getItem("nrt_check_sessions")||Ke("check_sessions",qh),localStorage.getItem("nrt_tickets")||Ke("tickets",Wo)}function Hh({currentUser:j,onLogout:F}){const[B,b]=T.useState(new Date);T.useEffect(()=>{const R=setInterval(()=>{b(new Date)},1e3);return()=>clearInterval(R)},[]);const w=(R=>{const M=R.getHours();return M>=8&&M<16?{name:"เช้า",icon:ah,color:"text-amber-700 bg-amber-50 border-amber-200/60"}:M>=16&&M<24?{name:"บ่าย",icon:nh,color:"text-orange-700 bg-orange-50 border-orange-200/60"}:{name:"ดึก",icon:ih,color:"text-indigo-700 bg-indigo-50 border-indigo-200/60"}})(B),H=w.icon,xe=R=>R.toLocaleDateString("th-TH",{year:"numeric",month:"long",day:"numeric",weekday:"long"}),ne=R=>R.toLocaleTimeString("th-TH",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),_e=R=>{switch(R){case"Admin":return"bg-rose-50 text-rose-700 border-rose-200/60";case"Supervisor":return"bg-violet-50 text-violet-700 border-violet-200/60";case"Dispatcher":return"bg-indigo-50 text-indigo-700 border-indigo-200/60";case"Executive":return"bg-emerald-50 text-emerald-700 border-emerald-200/60";case"ER Koh Samui":return"bg-pink-50 text-pink-700 border-pink-200/60";case"Quality Officer":return"bg-sky-50 text-sky-700 border-sky-200/60";case"Driver":return"bg-amber-50 text-amber-700 border-amber-200/60";case"EMS":return"bg-teal-50 text-teal-700 border-teal-200/60";default:return"bg-slate-50 text-slate-700 border-slate-200/60"}};return u.jsx("header",{className:"bg-white border-b border-slate-200/80 sticky top-0 z-40 shadow-sm transition-all",id:"app-header",children:u.jsxs("div",{className:"px-4 lg:px-6 py-3.5 flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"p-2.5 bg-indigo-600 rounded-xl text-white shadow-md shadow-indigo-100 flex items-center justify-center",children:u.jsx(eh,{className:"w-6 h-6"})}),u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg md:text-xl font-bold text-slate-900 tracking-tight",children:"ระบบบริหารจัดการ ศูนย์รับแจ้งเหตุและสั่งการนเรนทรอ่าวไทย"}),u.jsx("p",{className:"text-xs text-slate-400 mt-0.5 font-semibold tracking-wider uppercase",children:"Narenthorn Gulf of Thailand Dispatch & Fleet Command Center"})]})]}),u.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 md:gap-4 self-end md:self-auto",children:[u.jsxs("div",{className:"flex items-center gap-2.5 bg-slate-50 border border-slate-200/60 px-3 py-1.5 rounded-xl text-xs md:text-sm text-slate-600 shadow-xs",children:[u.jsx(th,{className:"w-4 h-4 text-indigo-500 animate-pulse"}),u.jsx("span",{className:"font-mono font-bold tracking-wider text-slate-800",children:ne(B)}),u.jsx("span",{className:"text-slate-300",children:"|"}),u.jsx("span",{className:"text-slate-500 font-semibold",children:xe(B)}),u.jsxs("span",{className:`ml-1.5 flex items-center gap-1.5 px-2 py-0.5 rounded-lg border text-xs font-bold ${w.color}`,children:[u.jsx(H,{className:"w-3.5 h-3.5"}),"เวร",w.name]})]}),j&&u.jsxs("div",{className:"flex items-center gap-2.5 bg-slate-50 border border-slate-200/60 px-3 py-1.5 rounded-xl shadow-xs",children:[u.jsx("div",{className:"w-8 h-8 rounded-lg bg-indigo-50 border border-indigo-100 text-indigo-600 flex items-center justify-center font-extrabold text-sm shadow-xs",children:u.jsx(lh,{className:"w-4 h-4"})}),u.jsxs("div",{className:"hidden sm:block text-left",children:[u.jsx("div",{className:"text-xs font-bold text-slate-800 truncate max-w-[140px]",children:j.fullName}),u.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:u.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.2 rounded border uppercase tracking-wider ${_e(j.role)}`,children:j.role})})]}),u.jsx("button",{onClick:F,className:"ml-1 p-1.5 text-slate-400 hover:text-rose-600 hover:bg-rose-50 border border-transparent hover:border-rose-100 rounded-lg transition-all cursor-pointer",title:"ออกจากระบบ",id:"btn-logout-header",children:u.jsx(Vo,{className:"w-4 h-4"})})]})]})]})})}function Rh({currentRole:j,activeTab:F,setActiveTab:B,onLogout:b}){const[_,w]=T.useState(!1),H=R=>{if(j==="Admin")return!0;switch(R){case"รับแจ้งเหตุ":return j==="Dispatcher";case"หน้าเคสปฏิบัติการ":return["Supervisor","Dispatcher","ER Koh Samui"].includes(j);case"รายงานประจำวัน":return["Supervisor","Dispatcher","Executive","Quality Officer"].includes(j);case"ทดสอบวิทยุ":return["Supervisor","Dispatcher"].includes(j);case"รายงานสถิติ":return["Supervisor","Dispatcher","Executive","Quality Officer"].includes(j);case"Dashboard EMS":return["Supervisor","Executive","Dispatcher","ER Koh Samui","Quality Officer"].includes(j);case"ความพร้อมรถพยาบาล":return!0;case"Admin":return j==="Admin";default:return!1}},ne=[{name:"รับแจ้งเหตุ",icon:Ko,tabId:"dispatch"},{name:"หน้าเคสปฏิบัติการ",icon:Jo,tabId:"cases"},{name:"รายงานประจำวัน",icon:uh,tabId:"daily-report"},{name:"ทดสอบวิทยุ",icon:sh,tabId:"radio-test"},{name:"รายงานสถิติ",icon:ch,tabId:"statistics"},{name:"Dashboard EMS",icon:rh,tabId:"dashboard"},{name:"ความพร้อมรถพยาบาล",icon:dh,tabId:"ambulance-check"},{name:"Admin",icon:fh,tabId:"admin"}].filter(R=>H(R.name)),_e=R=>{B(R),w(!1)};return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"md:hidden fixed bottom-4 right-4 z-50",children:u.jsx("button",{onClick:()=>w(!_),className:"p-4 bg-indigo-600 text-white rounded-full shadow-lg shadow-indigo-500/20 flex items-center justify-center hover:bg-indigo-700 transition-all active:scale-95 cursor-pointer border border-indigo-500/30",id:"btn-mobile-menu",children:_?u.jsx(oh,{className:"w-6 h-6"}):u.jsx(mh,{className:"w-6 h-6"})})}),_&&u.jsx("div",{className:"md:hidden fixed inset-0 bg-slate-950/60 z-40 backdrop-blur-xs transition-opacity",onClick:()=>w(!1)}),u.jsxs("aside",{className:` fixed md:static inset-y-0 left-0 w-64 bg-slate-900 text-slate-100 border-r border-slate-800 z-40 transform transition-transform duration-300 flex flex-col h-screen md:h-auto ${_?"translate-x-0":"-translate-x-full md:translate-x-0"} `,id:"app-sidebar",children:[u.jsxs("div",{className:"p-4 border-b border-slate-800/80",children:[u.jsx("div",{className:"text-xs font-bold text-slate-400 tracking-wider uppercase mb-1",children:"เมนูการปฏิบัติงาน"}),u.jsxs("div",{className:"text-[10px] text-indigo-400 font-bold uppercase tracking-wider",children:["ผู้ใช้งานสิทธิ์: ",j]})]}),u.jsx("nav",{className:"flex-1 px-3 py-4 space-y-1.5 overflow-y-auto",children:ne.map(R=>{const M=R.icon,I=F===R.tabId;return u.jsxs("button",{onClick:()=>_e(R.tabId),className:` w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-semibold transition-all cursor-pointer ${I?"bg-indigo-600 text-white shadow-md shadow-indigo-900/40 font-bold":"text-slate-300 hover:text-white hover:bg-slate-800/70"} `,id:`sidebar-item-${R.tabId}`,children:[u.jsx(M,{className:`w-4 h-4 ${I?"text-white":"text-slate-400 group-hover:text-white"}`}),u.jsx("span",{children:R.name}),I&&u.jsx("div",{className:"ml-auto w-1.5 h-1.5 bg-white rounded-full"})]},R.tabId)})}),u.jsx("div",{className:"p-4 border-t border-slate-800 bg-slate-950/40",children:u.jsxs("button",{onClick:()=>{w(!1),b()},className:"w-full flex items-center gap-3 px-4 py-3 text-sm font-semibold text-rose-400 hover:text-rose-300 hover:bg-rose-500/10 rounded-xl transition-all cursor-pointer",id:"sidebar-item-logout",children:[u.jsx(Vo,{className:"w-4 h-4"}),u.jsx("span",{children:"ออกจากระบบ"})]})})]})]})}const Lh=T.lazy(()=>Pc(()=>import("./RadioTestForm-C4p76j7C.js"),__vite__mapDeps([0,1,2]),import.meta.url)),wh=T.lazy(()=>Pc(()=>import("./AmbulanceChecklist-CQ7je56N.js"),__vite__mapDeps([3,1,2]),import.meta.url)),Yh=T.lazy(()=>Pc(()=>import("./ReportPDF-WB7Q5w_0.js"),__vite__mapDeps([4,1,2]),import.meta.url));Bh();function Ic(){return u.jsx("div",{className:"flex min-h-[260px] items-center justify-center rounded-2xl border border-slate-200 bg-white p-8 shadow-sm",children:u.jsxs("div",{className:"text-center",children:[u.jsx("div",{className:"mx-auto h-10 w-10 animate-spin rounded-full border-4 border-indigo-100 border-t-indigo-600"}),u.jsx("p",{className:"mt-3 text-sm font-bold text-slate-600",children:"กำลังโหลดหน้าการทำงาน…"})]})})}function Gh(){const[j,F]=T.useState(()=>Pl("users",ko)),[B,b]=T.useState(()=>Pl("units",$o)),[_,w]=T.useState(()=>Pl("call_logs",[])),[H,xe]=T.useState(()=>Pl("cases",[])),[ne,_e]=T.useState(()=>Pl("unit_statuses",[])),[R,M]=T.useState(()=>Pl("radio_tests",[])),[I,Ut]=T.useState(()=>Pl("check_sessions",[])),[ve,ze]=T.useState(()=>Pl("tickets",Wo)),[K,al]=T.useState(()=>{const c=localStorage.getItem("nrt_logged_user");if(c)try{return JSON.parse(c)}catch{return null}return null}),[Ie,we]=T.useState("dispatch"),[Jt,qt]=T.useState(""),[mt,Nt]=T.useState(""),[Pe,Bt]=T.useState(""),[ea,Ht]=T.useState(""),[at,Sl]=T.useState(!1),[Rt,jt]=T.useState(""),[p,A]=T.useState(""),[U,me]=T.useState("สายแจ้งเหตุหรือสายปฏิบัติการ"),[ce,Ye]=T.useState(""),[re,P]=T.useState("First Call"),[Ee,ht]=T.useState(""),[Lt,ta]=T.useState(""),[Nl,nl]=T.useState("EMS"),[kt,za]=T.useState("ALS"),[la,Ea]=T.useState(""),[wt,on]=T.useState("17"),[Ca,Ru]=T.useState("แดง"),[fi,oi]=T.useState("แดง"),[mn,mi]=T.useState("แดง"),[hi,Lu]=T.useState("ไม่มี Fast Track"),[Je,wu]=T.useState("ทางบก"),[hn,xn]=T.useState(""),[jl,er]=T.useState(!1),[xi,tr]=T.useState(""),[Yu,Da]=T.useState(""),[ke,Yt]=T.useState(""),[et,Gu]=T.useState(""),[Qu,lr]=T.useState("ค้างปรับปรุงข้อมูล"),[X,Se]=T.useState(null),[aa,Tl]=T.useState(""),[na,_a]=T.useState(""),[vn,vi]=T.useState(""),[ia,ua]=T.useState(""),[bn,bi]=T.useState(""),[Al,gn]=T.useState(""),[Ma,Oa]=T.useState(""),[Ua,yn]=T.useState(""),[Tt,Me]=T.useState(!1),[Ne,zl]=T.useState(()=>new Date().toISOString().split("T")[0]),[Gt,Xu]=T.useState(()=>{const c=new Date().getHours();return c>=8&&c<16?"เช้า":c>=16&&c<24?"บ่าย":"ดึก"}),[gi,yi]=T.useState(""),[El,pn]=T.useState(""),[il,Cl]=T.useState(""),[J,$e]=T.useState(null),[G,$t]=T.useState({username:"",fullName:"",role:"Dispatcher",pin:"1234",isActive:!0,mustChangePin:!1}),[ie,We]=T.useState(null),[ye,Dl]=T.useState({name:"",level:"ALS",isActive:!0,isSamuiHospital:!1,sortOrder:99});T.useEffect(()=>{j.length>0&&Ke("users",j)},[j]),T.useEffect(()=>{B.length>0&&Ke("units",B)},[B]),T.useEffect(()=>{Ke("call_logs",_)},[_]),T.useEffect(()=>{Ke("cases",H)},[H]),T.useEffect(()=>{Ke("unit_statuses",ne)},[ne]),T.useEffect(()=>{Ke("radio_tests",R)},[R]),T.useEffect(()=>{Ke("check_sessions",I)},[I]),T.useEffect(()=>{Ke("tickets",ve)},[ve]),T.useEffect(()=>{K&&xn(K.username);const c=B.filter(N=>N.level===kt&&N.isActive);c.length>0&&!la&&Ea(c[0].id)},[K,kt,B]);const He=c=>{qt(c),setTimeout(()=>qt(""),4e3)},Wt=c=>{Nt(c),setTimeout(()=>Nt(""),4e3)},Zu=c=>{c.preventDefault();const N=j.find(z=>z.username.toLowerCase()===Pe.trim().toLowerCase()&&z.pin===ea);if(N){if(!N.isActive){Wt("บัญชีผู้ใช้นี้ถูกระงับการเข้าใช้งานชั่วคราว กรุณาติดต่อ Admin");return}if(N.mustChangePin){Sl(!0);return}al(N),localStorage.setItem("nrt_logged_user",JSON.stringify(N)),N.role==="Driver"||N.role==="EMS"?we("ambulance-check"):N.role==="ER Koh Samui"?we("cases"):N.role==="Executive"?we("dashboard"):we("dispatch"),Bt(""),Ht(""),He(`ยินดีต้อนรับคุณ ${N.fullName} เข้าสู่ระบบปฏิบัติการ`)}else Wt("ชื่อบัญชีผู้ใช้งานหรือรหัส PIN 4 หลักไม่ถูกต้อง กรุณาตรวจสอบอีกครั้ง")},qa=c=>{if(c.preventDefault(),Rt.length!==4||isNaN(Number(Rt))){Wt("รหัส PIN ใหม่ต้องเป็นตัวเลข 4 หลักเท่านั้น");return}if(Rt!==p){Wt("การยืนยันรหัส PIN ใหม่ไม่ตรงกัน");return}const N=j.map(z=>z.username.toLowerCase()===Pe.trim().toLowerCase()?{...z,pin:Rt,mustChangePin:!1}:z);F(N),Sl(!1),jt(""),A(""),He("เปลี่ยนรหัสผ่าน PIN สำเร็จ! กรุณาลงชื่อเข้าใช้งานด้วย PIN ใหม่")},sa=()=>{al(null),localStorage.removeItem("nrt_logged_user"),Bt(""),Ht(""),He("ออกจากระบบสำเร็จเรียบร้อยแล้ว")},Qt=()=>{if(!K)return;const c=new Date().toISOString().split("T")[0],N=new Date().toTimeString().split(" ")[0].substring(0,5),z=new Date().getHours(),L=z>=8&&z<16?"เช้า":z>=16&&z<24?"บ่าย":"ดึก",ee={id:`call_${Date.now()}`,timestamp:new Date().toISOString(),date:c,time:N,shift:L,username:K.username,recordedBy:K.fullName,callType:U,otherReason:U==="แจ้งเหตุอื่น"?ce:void 0,channel:re,channelDetail:["หมายเลขอื่น","วิธีอื่น ๆ"].includes(re)?Ee:void 0};if(w(je=>[ee,...je]),U==="สายแจ้งเหตุหรือสายปฏิบัติการ"){const je=Lt.trim()||`OB-2569-${Math.floor(1e3+Math.random()*9e3)}`,Re=B.find(ut=>ut.id===la)||B[0],It={id:je,createdAt:new Date().toISOString(),date:c,time:N,shift:L,username:K.username,recordedBy:K.fullName,type:Nl,unitLevel:kt,unitId:Re.id,unitName:Re.name,cbdCode:wt,phoneTriage:Ca,sceneTriage:fi,erTriage:mn,fastTrack:hi,path:Je,responsibleDispatcher:hn||K.username,consultingDoctor:jl,doctorName:jl?xi:void 0,onlineMedicalProtocol:jl?Yu:void 0,diagnosis:ke||`รับแจ้งเหตุกลุ่มอาการ ${Zo.find(ut=>ut.code===wt)?.title||"ทั่วไป"}`,riskDetected:et||"ไม่มีระดับความเสี่ยงพิเศษนอกกวน",status:Qu};xe(ut=>[It,...ut]),He(`บันทึกข้อมูลและสร้างเคสปฏิบัติการ ${je} สำเร็จ!`)}else He(`บันทึกข้อมูลสายเรียกเข้าประเภท "${U}" เรียบร้อยแล้ว`);Ye(""),ht(""),ta(""),Yt(""),Gu("")},nt=c=>{confirm("คุณแน่ใจหรือไม่ที่จะลบรายการสายเรียกเข้านี้ออกจากระบบ?")&&(w(N=>N.filter(z=>z.id!==c)),He("ลบรายการสายเรียกเข้าสำเร็จ"))},pi=c=>{const N=H.map(z=>z.id===c.id?{...c,editedAt:new Date().toISOString()}:z);xe(N),Se(null),He(`แก้ไขปรับปรุงข้อมูลเคสปฏิบัติการ ${c.id} เรียบร้อยแล้ว`)},Vu=c=>{if(c.preventDefault(),!Al)return;const N=B.find(L=>L.id===Al);if(!N)return;const z={unitId:Al,unitName:N.name,status:"ไม่พร้อมปฏิบัติการ",reason:Ma,startTime:new Date().toISOString(),estimatedEndTime:Ua?new Date(Date.now()+Number(Ua)*60*60*1e3).toISOString():void 0,unknownEndTime:Tt,recordedBy:K?.fullName||"System",updatedAt:new Date().toISOString()};_e(L=>{const ee=L.filter(je=>je.unitId!==Al);return[z,...ee]}),gn(""),Oa(""),yn(""),Me(!1),He(`อัปเดตสถานะหน่วยงาน "${N.name}" เป็นไม่พร้อมออกปฏิบัติการ`)},Sn=c=>{const N=B.find(L=>L.id===c);if(!N)return;const z={unitId:c,unitName:N.name,status:"พร้อมปฏิบัติการ",recordedBy:K?.fullName||"System",updatedAt:new Date().toISOString()};_e(L=>{const ee=L.filter(je=>je.unitId!==c);return[z,...ee]}),He(`หน่วยงาน "${N.name}" กลับคืนสถานะ "พร้อมออกปฏิบัติการ" เรียบร้อยแล้ว`)},Si=c=>{M(N=>[c,...N])},Ba=c=>{Ut(z=>[c,...z]);const N=c.results.filter(z=>!["พร้อมใช้","ไม่มีประจำรถ","ไม่เกี่ยวข้องกับรถคันนี้"].includes(z.status));if(N.length>0){const z=N.map((L,ee)=>({id:`TKT-2569-${Math.floor(1e3+Math.random()*9e3)}-${ee}`,ambulanceId:c.ambulanceId,plateNo:c.plateNo,unitName:c.unitName,itemId:L.itemId,itemName:L.itemName,problemDetails:L.problemDetails||`${L.itemName} มีระดับความคลาดเคลื่อนชำรุด หรือจำนวนไม่ครบตามมาตรฐาน`,reportedAt:new Date().toISOString(),reportedBy:c.checkerName,severity:L.severity||"general",status:"รอรับเรื่อง",targetDate:new Date(Date.now()+2592e5).toISOString().split("T")[0]}));ze(L=>[...z,...L])}},Ku=(c,N,z)=>{const L=ve.map(ee=>ee.id===c?{...ee,status:N,actionDetails:z||ee.actionDetails,resolvedAt:["แก้ไขแล้ว","ตรวจสอบผลแล้ว","ปิดรายการ"].includes(N)?new Date().toISOString():void 0,resolvedBy:["แก้ไขแล้ว","ตรวจสอบผลแล้ว","ปิดรายการ"].includes(N)?K?.fullName:void 0}:ee);ze(L),He(`อัปเดตสเตตัสใบสั่งซ่อมบำรุง ${c} เป็น "${N}"`)},it=(c,N)=>!!j.find(L=>L.username===c&&L.pin===N&&L.role==="Dispatcher"),ji=(()=>{const c=H.filter(E=>E.date===Ne&&E.shift===Gt),N=_.filter(E=>E.date===Ne&&E.shift===Gt),z=R.find(E=>E.date===Ne&&E.shift===Gt)||R[0],L=ne.filter(E=>E.status==="ไม่พร้อมปฏิบัติการ").length;B.length-L;const ee=N.length,je=N.filter(E=>E.callType==="สายแจ้งเหตุหรือสายปฏิบัติการ").length,Re=N.filter(E=>E.callType==="สายก่อกวน").length,It=N.filter(E=>E.callType==="โทรผิด").length,ut=N.filter(E=>E.callType==="แจ้งเหตุอื่น").length,Ei=c.filter(E=>E.type==="EMS").length,jn=c.filter(E=>E.type==="Refer").length,Ci=c.filter(E=>E.unitLevel==="ALS").length,ca=c.filter(E=>E.unitLevel==="BLS").length,Xt=c.filter(E=>E.unitLevel==="CLS").length,Fe=(E,tt)=>c.filter(ra=>E==="phone"?ra.phoneTriage===tt:E==="scene"?ra.sceneTriage===tt:ra.erTriage===tt).length;return{id:`rep_${Ne}_${Gt}`,date:Ne,shift:Gt,reporterUsername:K?.username||"unknown",reporterName:K?.fullName||"เจ้าหน้าที่บันทึกข้อมูล",generatedAt:new Date().toLocaleDateString("th-TH",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),callsSummary:{total:ee,emsOrRefer:je,spam:Re,wrongNumber:It,others:ut},casesSummary:{total:c.length,ems:Ei,refer:jn,als:Ci,bls:ca,cls:Xt},triageSummary:{phone:{red:Fe("phone","แดง"),yellow:Fe("phone","เหลือง"),green:Fe("phone","เขียว"),white:Fe("phone","ขาว")},scene:{red:Fe("scene","แดง"),yellow:Fe("scene","เหลือง"),green:Fe("scene","เขียว"),white:Fe("scene","ขาว")},er:{red:Fe("er","แดง"),yellow:Fe("er","เหลือง"),green:Fe("er","เขียว"),white:Fe("er","ขาว")}},fastTrackSummary:{stroke:c.filter(E=>E.fastTrack==="STROKE").length,stemi:c.filter(E=>E.fastTrack==="STEMI").length,sepsis:c.filter(E=>E.fastTrack==="Sepsis").length,trauma:c.filter(E=>E.fastTrack==="Multiple Trauma").length,psychiatric:c.filter(E=>E.fastTrack==="Psychiatric/Psychy").length,none:c.filter(E=>E.fastTrack==="ไม่มี Fast Track").length},pathSummary:{land:c.filter(E=>E.path==="ทางบก").length,water:c.filter(E=>E.path==="ทางน้ำ").length,air:c.filter(E=>E.path==="ทางอากาศ").length},radioSummary:z?{testedCount:z.testedCount,untestedCount:z.untestedCount,unreachable:z.unreachableStations,testerName:z.testerName}:void 0,unitStatusSummary:{unreadyUnits:ne.filter(E=>E.status==="ไม่พร้อมปฏิบัติการ").map(E=>({unitName:E.unitName,reason:E.reason||"ระงับความพร้อมชั่วคราว",duration:E.startTime||"ไม่ระบุ"})),readyUnits:B.filter(E=>!ne.some(tt=>tt.unitId===E.id&&tt.status==="ไม่พร้อมปฏิบัติการ")).map(E=>E.name)},risks:El,eventsSummary:gi,importantFollowUps:il,handover:{senderUsername:K?.username||"unknown",senderName:K?.fullName||"",receiverUsername:"",receiverName:"",notes:"",pendingCasesCount:c.filter(E=>E.status==="ค้างปรับปรุงข้อมูล").length,unreadyUnitsCount:L,isConfirmed:!1}}})(),Nn=c=>{if(c.preventDefault(),J){const N=j.map(z=>z.id===J.id?J:z);F(N),$e(null),He(`แก้ไขปรับปรุงข้อมูลผู้ใช้ "${J.fullName}" สำเร็จ`)}else{if(!G.username||!G.fullName||!G.pin){Wt("กรุณากรอกข้อมูลผู้ใช้ให้ครบถ้วนก่อนบันทึก");return}const N={id:`u_${Date.now()}`,username:G.username.toLowerCase().trim(),fullName:G.fullName,role:G.role||"Dispatcher",pin:G.pin,isActive:G.isActive!==void 0?G.isActive:!0,mustChangePin:G.mustChangePin||!1};F(z=>[...z,N]),$t({username:"",fullName:"",role:"Dispatcher",pin:"1234",isActive:!0,mustChangePin:!1}),He(`เพิ่มบัญชีผู้ใช้งานใหม่ "${N.fullName}" เข้าระบบสำเร็จ`)}},_l=c=>{if(c==="1"||c===K?.id){Wt("ไม่สามารถปิดการใช้งานหรือลบบัญชีหลักของตนเองได้");return}if(confirm("คุณต้องการเปลี่ยนสถานะบัญชีนี้เป็นระงับการใช้งานหรือไม่?")){const N=j.map(z=>z.id===c?{...z,isActive:!1}:z);F(N),He("เปลี่ยนสถานะผู้ใช้งานเป็นระงับการใช้งานสำเร็จ")}},Ti=c=>{if(c.preventDefault(),ie){const N=B.map(z=>z.id===ie.id?ie:z);b(N),We(null),He(`แก้ไขข้อมูลหน่วยงานกู้ชีพ "${ie.name}" สำเร็จ`)}else{if(!ye.name){Wt("กรุณากรอกชื่อหน่วยงานปฏิบัติการ");return}const N={id:`un_${Date.now()}`,name:ye.name,level:ye.level||"BLS",isActive:ye.isActive!==void 0?ye.isActive:!0,isSamuiHospital:ye.isSamuiHospital||!1,sortOrder:Number(ye.sortOrder)||99};b(z=>[...z,N]),Dl({name:"",level:"BLS",isActive:!0,isSamuiHospital:!1,sortOrder:99}),He(`เพิ่มหน่วยงานกู้ชีพใหม่ "${N.name}" สำเร็จ`)}},Ft=(()=>{let c=[...H];if(K?.role==="ER Koh Samui"&&(c=c.filter(N=>N.unitId==="u1")),aa&&(c=c.filter(N=>N.date===aa)),na&&(c=c.filter(N=>N.shift===na)),vn&&(c=c.filter(N=>N.unitId===vn)),ia&&(c=c.filter(N=>N.status===ia)),bn){const N=bn.toLowerCase().trim();c=c.filter(z=>z.id.toLowerCase().includes(N)||z.cbdCode.includes(N)||z.diagnosis.toLowerCase().includes(N)||z.unitName.toLowerCase().includes(N))}return c})(),Ai=(c,N)=>{const z=Math.max(...N.map(L=>L.count),1);return u.jsxs("div",{className:"bg-white p-5 rounded-2xl shadow-sm border border-slate-100 space-y-4",children:[u.jsx("h4",{className:"font-bold text-slate-800 text-sm border-b border-slate-50 pb-2",children:c}),u.jsx("div",{className:"space-y-3",children:N.map(L=>{const ee=L.count/z*100;return u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex justify-between text-xs font-bold text-slate-600",children:[u.jsx("span",{children:L.name}),u.jsxs("span",{children:[L.count," รายการ"]})]}),u.jsx("div",{className:"w-full h-2.5 bg-slate-100 rounded-full overflow-hidden",children:u.jsx("div",{className:"h-full rounded-full transition-all duration-1000",style:{width:`${ee}%`,backgroundColor:L.color}})})]},L.name)})})]})},zi=j.filter(c=>["Admin","Supervisor","Dispatcher"].includes(c.role)).map(c=>{const N=_.filter(Re=>Re.username===c.username).length,z=H.filter(Re=>Re.username===c.username).length,L=H.filter(Re=>Re.responsibleDispatcher===c.username).length,ee=H.filter(Re=>Re.responsibleDispatcher===c.username&&Re.status==="ปิดเคส").length,je=R.filter(Re=>Re.testerUsername===c.username).length;return{...c,createdCalls:N,createdCases:z,assignedCases:L,resolvedCases:ee,radioTestsDone:je}});return u.jsxs("div",{className:"min-h-screen bg-slate-50 flex flex-col text-slate-800 antialiased font-sans",id:"root-app",children:[u.jsx(Hh,{currentUser:K,onLogout:sa}),K?u.jsxs("div",{className:"flex-1 flex flex-col md:flex-row h-[calc(100vh-74px)] overflow-hidden",children:[u.jsx(Rh,{currentRole:K.role,activeTab:Ie,setActiveTab:we,onLogout:sa}),u.jsxs("main",{className:"flex-1 overflow-y-auto p-4 md:p-6",id:"app-workspace",children:[Ie==="dispatch"&&u.jsx("div",{className:"space-y-6 animate-fadeIn",children:u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 space-y-6",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-3",children:[u.jsxs("h3",{className:"text-base font-black text-slate-800 flex items-center gap-2",children:[u.jsx(Ko,{className:"w-5 h-5 text-indigo-600"})," บันทึกการรับสายโทรศัพท์ (รับแจ้งเหตุแรกรับ)"]}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"คีย์ข้อมูลผู้เจ็บป่วยฉุกเฉินอย่างรวดเร็ว โดยไม่จำเป็นต้องกรอกครบทุกช่องก็สามารถบันทึกได้"})]}),u.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเภทสายเรียกเข้า"}),u.jsxs("select",{value:U,onChange:c=>me(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"สายแจ้งเหตุหรือสายปฏิบัติการ",children:"📞 สายแจ้งเหตุ / สายปฏิบัติการ"}),u.jsx("option",{value:"สายก่อกวน",children:"🚫 สายก่อกวน"}),u.jsx("option",{value:"โทรผิด",children:"❌ โทรผิด"}),u.jsx("option",{value:"แจ้งเหตุอื่น",children:"📝 แจ้งเหตุอื่น ๆ"})]})]}),U==="แจ้งเหตุอื่น"&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"โปรดระบุรายละเอียดสายเรียกเข้า"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น แจ้งประสานงานสุนัขติดเกาะ",value:ce,onChange:c=>Ye(c.target.value),className:"w-full py-2 px-3 border border-slate-200 focus:border-indigo-500 rounded-lg text-xs font-semibold outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ช่องทางการแจ้งเหตุ"}),u.jsxs("select",{value:re,onChange:c=>P(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"First Call",children:"First Call"}),u.jsx("option",{value:"Second Call",children:"Second Call"}),u.jsx("option",{value:"หมายเลขอื่น",children:"หมายเลขอื่น ๆ"}),u.jsx("option",{value:"วิทยุ",children:"วิทยุสื่อสาร ว.6"}),u.jsx("option",{value:"วิธีอื่น ๆ",children:"วิธีอื่น ๆ"})]})]}),["หมายเลขอื่น","วิธีอื่น ๆ"].includes(re)&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"รายละเอียดช่องทางเสริม"}),u.jsx("input",{type:"text",placeholder:"ระบุเบอร์โทร / LINE / วิทยุช่องใด",value:Ee,onChange:c=>ht(c.target.value),className:"w-full py-2 px-3 border border-slate-200 focus:border-indigo-500 rounded-lg text-xs font-semibold outline-none"})]})]}),U==="สายแจ้งเหตุหรือสายปฏิบัติการ"&&u.jsxs("div",{className:"pt-4 border-t border-slate-100 space-y-4 animate-slideDown",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 text-indigo-800",children:[u.jsx(Jo,{className:"w-4 h-4 text-indigo-600"}),u.jsx("h4",{className:"text-xs font-bold uppercase tracking-wider",children:"รายละเอียดปฏิบัติการกู้ชีพ (EMS / Refer)"})]}),u.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เลขปฏิบัติการ (สพฉ.)"}),u.jsx("input",{type:"text",placeholder:"เช่น OB-2569-1234 (ปล่อยว่างหากยังไม่มี)",value:Lt,onChange:c=>ta(c.target.value),className:"w-full py-2 px-3 border border-slate-200 focus:border-indigo-500 rounded-lg text-xs font-bold text-slate-700 outline-none font-mono"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเภทปฏิบัติการ"}),u.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-slate-200 p-0.5 bg-slate-100 text-xs",children:[u.jsx("button",{type:"button",onClick:()=>nl("EMS"),className:`flex-1 py-1.5 font-bold rounded-md transition-all cursor-pointer ${Nl==="EMS"?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:"EMS (รับแจ้งเหตุ ณ จุดเกิดเหตุ)"}),u.jsx("button",{type:"button",onClick:()=>nl("Refer"),className:`flex-1 py-1.5 font-bold rounded-md transition-all cursor-pointer ${Nl==="Refer"?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:"Refer (ประสานลำเลียงส่งต่อ)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ระดับหน่วยกู้ชีพ"}),u.jsx("div",{className:"flex rounded-lg overflow-hidden border border-slate-200 p-0.5 bg-slate-100 text-xs",children:["ALS","BLS","CLS"].map(c=>u.jsx("button",{type:"button",onClick:()=>{za(c);const N=B.filter(z=>z.level===c&&z.isActive);N.length>0&&Ea(N[0].id)},className:`flex-1 py-1.5 font-bold rounded-md transition-all cursor-pointer ${kt===c?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:text-slate-800"}`,children:c},c))})]}),u.jsxs("div",{children:[u.jsxs("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:["หน่วยปฏิบัติการรับมอบ (เฉพาะระดับ ",kt,")"]}),u.jsx("select",{value:la,onChange:c=>Ea(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:B.filter(c=>c.level===kt&&c.isActive).map(c=>u.jsx("option",{value:c.id,children:c.name},c.id))})]}),u.jsxs("div",{className:"sm:col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"จำแนกกลุ่มอาการ (25 กลุ่มอาการ สพฉ.)"}),u.jsx("select",{value:wt,onChange:c=>on(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:Zo.map(c=>u.jsxs("option",{value:c.code,children:["CBD-",c.code,": ",c.title]},c.code))})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"Phone Triage (ระดับวิกฤตสายแรกรับ)"}),u.jsxs("select",{value:Ca,onChange:c=>Ru(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"แดง",children:"🔴 สีแดง - วิกฤตคุกคามชีพ"}),u.jsx("option",{value:"เหลือง",children:"🟡 สีเหลือง - เร่งด่วนกึ่งวิกฤต"}),u.jsx("option",{value:"เขียว",children:"🟢 สีเขียว - ไม่เร่งด่วนทั่วไป"}),u.jsx("option",{value:"ขาว",children:"⚪ สีขาว - นัดหมายรับบริการ"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"รหัสเฉพาะผู้ป่วยวิกฤต (Fast Track)"}),u.jsxs("select",{value:hi,onChange:c=>Lu(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"ไม่มี Fast Track",children:"ไม่มี Fast Track"}),u.jsx("option",{value:"STROKE",children:"🧠 STROKE (สมองขาดเลือด)"}),u.jsx("option",{value:"STEMI",children:"❤️ STEMI (หัวใจขาดเลือด)"}),u.jsx("option",{value:"Sepsis",children:"🦠 Sepsis (ติดเชื้อในกระแสโลหิต)"}),u.jsx("option",{value:"Multiple Trauma",children:"🚗 Multiple Trauma (อุบัติเหตุพหุบาดเจ็บ)"}),u.jsx("option",{value:"Psychiatric/Psychy",children:"🤪 Psychiatric (จิตเวชคลุ้มคลั่ง)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เส้นทางลำเลียงผู้ป่วย"}),u.jsxs("select",{value:Je,onChange:c=>wu(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"ทางบก",children:"ทางบก (รถพยาบาลฉุกเฉิน)"}),u.jsx("option",{value:"ทางน้ำ",children:"ทางน้ำ (เรือสปีดโบ๊ท/เรือกู้ชีพ)"}),u.jsx("option",{value:"ทางอากาศ",children:"ทางอากาศ (เฮลิคอปเตอร์กู้ชีพ)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ผู้รับผิดชอบกรอกข้อมูล (Complete ข้อมูล)"}),u.jsxs("select",{value:hn,onChange:c=>xn(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-indigo-500 bg-white",children:[u.jsx("option",{value:"",children:"-- เลือก Dispatcher --"}),j.filter(c=>c.role==="Dispatcher"||c.role==="Admin").map(c=>u.jsx("option",{value:c.username,children:c.fullName},c.id))]})]}),u.jsxs("div",{className:"sm:col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"อาการแรกรับ / ผลวินิจฉัย (Diagnosis)"}),u.jsx("textarea",{rows:2,placeholder:"กรอกเหตุการณ์เบื้องต้น เช่น ผู้ป่วยเพศชายอายุ 45 ปี ประสบอุบัติเหตุล้มหัวฟาดพื้น รู้สึกตัวดีปวดต้นคอ...",value:ke,onChange:c=>Yt(c.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none focus:ring-1 focus:ring-indigo-500"})]})]})]}),u.jsx("div",{className:"flex gap-2",children:u.jsxs("button",{onClick:Qt,className:"w-full py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-black text-sm rounded-xl transition-all active:scale-95 shadow-md shadow-indigo-200 flex items-center justify-center gap-2 cursor-pointer border border-indigo-500/20",id:"btn-save-call",children:[u.jsx(xh,{className:"w-4.5 h-4.5"})," บันทึกและสรุปข้อมูลแรกรับ"]})})]}),u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 flex flex-col justify-between gap-4",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-3 flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"สายเรียกเข้าและรายงานล่าสุดในรอบเวร"}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"แสดงรายการประวัติสายเรียกเข้าทั้งหมดที่คุณคีย์ล่าสุด"})]}),u.jsxs("span",{className:"bg-indigo-100 text-indigo-800 text-[10px] font-black px-2 py-1 rounded-full border border-indigo-200 uppercase",children:[_.length," สายเรียกเข้า"]})]}),u.jsx("div",{className:"space-y-3 max-h-[460px] overflow-y-auto pr-2 divide-y divide-slate-50",children:_.length===0?u.jsx("div",{className:"text-center py-10 text-slate-400 text-xs font-medium",children:"📭 ยังไม่มีประวัติสายเรียกเข้าที่ได้รับการบันทึกในรอบเวรนี้"}):_.map((c,N)=>u.jsxs("div",{className:"pt-3 first:pt-0 flex items-start justify-between gap-3 text-xs",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-1.5 font-bold",children:[u.jsx("span",{className:`w-2 h-2 rounded-full ${c.callType==="สายแจ้งเหตุหรือสายปฏิบัติการ"?"bg-red-500":""} ${c.callType==="สายก่อกวน"?"bg-amber-500":""} ${c.callType==="โทรผิด"?"bg-slate-400":""} ${c.callType==="แจ้งเหตุอื่น"?"bg-indigo-500":""} `}),u.jsx("span",{className:"text-slate-800",children:c.callType}),u.jsxs("span",{className:"text-slate-400 text-[10px] font-mono font-semibold",children:["(",c.time," น.)"]})]}),u.jsxs("p",{className:"text-[10px] text-slate-500 leading-normal font-semibold",children:["ช่องทาง: ",c.channel," ",c.channelDetail&&`[${c.channelDetail}]`,c.otherReason&&`| เหตุพิเศษ: ${c.otherReason}`]}),u.jsxs("div",{className:"text-[9px] text-slate-400 font-bold",children:["บันทึกโดย: ",c.recordedBy]})]}),u.jsx("button",{onClick:()=>nt(c.id),className:"text-slate-300 hover:text-red-500 p-1 rounded-lg hover:bg-red-50 transition-colors cursor-pointer",title:"ลบข้อมูลสายโทรศัพท์",id:`btn-delete-call-${c.id}`,children:u.jsx(Ho,{className:"w-4 h-4"})})]},c.id))}),u.jsx("div",{className:"bg-slate-50 p-3 rounded-xl border border-slate-100/60 text-[11px] font-bold text-slate-500 leading-normal",children:'💡 เคล็ดลับปฏิบัติการ: ข้อมูลเคสจะถูกนำเข้าสู่ระบบบัญชี "หน้าเคสปฏิบัติการ" โดยอัตโนมัติ เพื่อให้ผู้รับผิดชอบ (Complete) และทีม ER ดำเนินการคัดแยกสี และปิดเคสอย่างละเอียด'})]})]})}),Ie==="cases"&&u.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[u.jsxs("div",{className:"bg-white rounded-2xl p-4 md:p-5 shadow-sm border border-slate-100 flex flex-wrap gap-3 items-center justify-between",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[u.jsxs("div",{className:"relative",children:[u.jsx(vh,{className:"w-4 h-4 text-slate-400 absolute left-3 top-1/2 -translate-y-1/2"}),u.jsx("input",{type:"text",placeholder:"ค้นหาเลขสพฉ. / CBD / อาการ...",value:bn,onChange:c=>bi(c.target.value),className:"pl-9 pr-3.5 py-1.5 border border-slate-200 focus:border-indigo-500 rounded-xl text-xs outline-none bg-slate-50/50 hover:bg-white focus:bg-white w-48 font-semibold transition-all"})]}),u.jsxs("select",{value:vn,onChange:c=>vi(c.target.value),className:"py-1.5 px-3 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 bg-white focus:ring-1 focus:ring-indigo-500 outline-none",children:[u.jsx("option",{value:"",children:"-- หน่วยปฏิบัติการกู้ชีพทั้งหมด --"}),B.map(c=>u.jsxs("option",{value:c.id,children:[c.name," (",c.level,")"]},c.id))]}),u.jsxs("select",{value:ia,onChange:c=>ua(c.target.value),className:"py-1.5 px-3 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 bg-white focus:ring-1 focus:ring-indigo-500 outline-none",children:[u.jsx("option",{value:"",children:"-- สถานะเคสทั้งหมด --"}),u.jsx("option",{value:"ค้างปรับปรุงข้อมูล",children:"❌ ค้างปรับปรุงข้อมูล"}),u.jsx("option",{value:"ปรับปรุงข้อมูลแล้ว",children:"🟡 ปรับปรุงข้อมูลแล้ว"}),u.jsx("option",{value:"ปิดเคส",children:"🟢 ปิดเคส"})]})]}),u.jsxs("div",{className:"text-xs font-bold bg-indigo-50 text-indigo-700 px-3.5 py-1.5 rounded-xl border border-indigo-100 self-end md:self-auto flex items-center gap-1.5",children:[u.jsx(bh,{className:"w-3.5 h-3.5"})," พบทั้งหมด ",Ft.length," รายการสอดคล้อง"]})]}),u.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden",children:[u.jsx("div",{className:"p-4 md:p-5 border-b border-slate-100 bg-slate-50/50 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:u.jsxs("div",{children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"รายการรับเคสปฏิบัติการ ศูนย์นเรนทรอ่าวไทย"}),u.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"รวมเคสฉุกเฉินกู้ชีพทุกลำดับ และผู้ประเมินสถานะการพยาบาลรับ-ส่งต่อ"})]})}),u.jsx("div",{className:"overflow-x-auto",children:u.jsxs("table",{className:"w-full text-left border-collapse text-xs md:text-sm",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-slate-100/50 text-slate-600 font-bold border-b border-slate-100",children:[u.jsx("th",{className:"py-3 px-4",children:"เลขปฏิบัติการ (สพฉ)"}),u.jsx("th",{className:"py-3 px-3",children:"ประเภทเคส"}),u.jsx("th",{className:"py-3 px-3",children:"หน่วยงานกู้ชีพรับเหมา"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"Triage (Phone/Scene/ER)"}),u.jsx("th",{className:"py-3 px-3",children:"ผู้รับผิดชอบกู้ชีพ"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"สถานะเคส"}),u.jsx("th",{className:"py-3 px-4 text-center",children:"การดำเนินการ"})]})}),u.jsx("tbody",{className:"divide-y divide-slate-100 text-slate-700 font-medium",children:Ft.length===0?u.jsx("tr",{children:u.jsx("td",{colSpan:7,className:"py-10 text-center text-slate-400 font-bold",children:"📭 ไม่พบเคสปฏิบัติการที่ตรงตามตัวกรองที่ระบุในเวรนี้"})}):Ft.map(c=>u.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[u.jsxs("td",{className:"py-3.5 px-4",children:[u.jsx("div",{className:"font-extrabold text-slate-900 font-mono text-xs",children:c.id}),u.jsxs("div",{className:"text-[10px] text-slate-400 mt-0.5 font-bold",children:["วันที่: ",c.date," | ",c.time," น. (เวร",c.shift,")"]})]}),u.jsx("td",{className:"py-3.5 px-3",children:u.jsxs("div",{className:"flex flex-col gap-1 items-start",children:[u.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-black tracking-wide border ${c.type==="EMS"?"bg-blue-50 text-blue-700 border-blue-200":"bg-indigo-50 text-indigo-700 border-indigo-200"} `,children:c.type}),u.jsxs("span",{className:"text-[10px] text-slate-500 font-bold",children:["CBD-",c.cbdCode]})]})}),u.jsxs("td",{className:"py-3.5 px-3",children:[u.jsx("div",{className:"font-bold text-slate-800",children:c.unitName}),u.jsxs("div",{className:"text-[10px] text-slate-400 font-bold mt-0.5",children:["ระดับความพร้อม: ",c.unitLevel," | ลำเลียง: ",c.path]})]}),u.jsx("td",{className:"py-3.5 px-3 text-center",children:u.jsxs("div",{className:"inline-flex gap-1 items-center",children:[u.jsx("span",{className:`w-5 h-5 rounded-md flex items-center justify-center font-bold text-[10px] text-white border ${c.phoneTriage==="แดง"?"bg-red-600 border-red-700":""} ${c.phoneTriage==="เหลือง"?"bg-amber-500 border-amber-600":""} ${c.phoneTriage==="เขียว"?"bg-emerald-600 border-emerald-700":""} ${c.phoneTriage==="ขาว"?"bg-slate-400 border-slate-500":""} `,title:"Phone Triage",children:"P"}),u.jsx("span",{className:"text-slate-300 text-[10px]",children:"/"}),u.jsx("span",{className:`w-5 h-5 rounded-md flex items-center justify-center font-bold text-[10px] text-white border ${c.sceneTriage==="แดง"?"bg-red-600 border-red-700":""} ${c.sceneTriage==="เหลือง"?"bg-amber-500 border-amber-600":""} ${c.sceneTriage==="เขียว"?"bg-emerald-600 border-emerald-700":""} ${c.sceneTriage==="ขาว"?"bg-slate-400 border-slate-500":""} `,title:"Scene Triage",children:"S"}),u.jsx("span",{className:"text-slate-300 text-[10px]",children:"/"}),u.jsx("span",{className:`w-5 h-5 rounded-md flex items-center justify-center font-bold text-[10px] text-white border ${c.erTriage==="แดง"?"bg-red-600 border-red-700":""} ${c.erTriage==="เหลือง"?"bg-amber-500 border-amber-600":""} ${c.erTriage==="เขียว"?"bg-emerald-600 border-emerald-700":""} ${c.erTriage==="ขาว"?"bg-slate-400 border-slate-500":""} `,title:"ER Triage",children:"E"})]})}),u.jsxs("td",{className:"py-3.5 px-3",children:[u.jsx("div",{className:"font-semibold text-slate-800",children:j.find(N=>N.username===c.responsibleDispatcher)?.fullName.split(" ")[0]||c.responsibleDispatcher}),u.jsxs("div",{className:"text-[10px] text-slate-400 font-bold mt-0.5",children:["เวรรอบ: ",c.shift]})]}),u.jsx("td",{className:"py-3.5 px-3 text-center",children:u.jsx("span",{className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-extrabold border ${c.status==="ค้างปรับปรุงข้อมูล"?"bg-rose-50 text-rose-700 border-rose-200":""} ${c.status==="ปรับปรุงข้อมูลแล้ว"?"bg-amber-50 text-amber-700 border-amber-200 animate-pulse":""} ${c.status==="ปิดเคส"?"bg-emerald-50 text-emerald-700 border-emerald-200":""} `,children:c.status})}),u.jsx("td",{className:"py-3.5 px-4 text-center",children:u.jsxs("button",{onClick:()=>Se(c),className:"inline-flex items-center gap-1 bg-slate-50 hover:bg-indigo-50 text-slate-600 hover:text-indigo-700 text-xs font-bold px-2.5 py-1.5 rounded-lg border border-slate-200 hover:border-indigo-200 transition-colors cursor-pointer shadow-sm",id:`btn-edit-case-${c.id}`,children:[u.jsx(Jc,{className:"w-3.5 h-3.5"})," แก้ไขข้อมูล"]})})]},c.id))})]})})]}),X&&u.jsx("div",{className:"fixed inset-0 bg-slate-900/60 z-50 flex items-center justify-center p-4",children:u.jsxs("div",{className:"bg-white rounded-3xl max-w-2xl w-full p-6 space-y-6 shadow-2xl border border-slate-100 max-h-[90vh] overflow-y-auto",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-3 flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsxs("h3",{className:"text-base font-black text-slate-800",children:["ปรับปรุงข้อมูลเคสฉุกเฉินและ Triage ",X.id]}),u.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"อัปเดตสัญชีพ การประเมินหน้างาน และเปลี่ยนสถานะเพื่อส่งต่อรายงานสถิติอย่างถูกต้อง"})]}),u.jsx("button",{onClick:()=>Se(null),className:"p-1.5 hover:bg-slate-50 rounded-lg text-slate-400 hover:text-slate-600 font-bold",children:"✕"})]}),u.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เลขปฏิบัติการ (สพฉ)"}),u.jsx("input",{type:"text",value:X.id,onChange:c=>Se({...X,id:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 font-mono outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเภทปฏิบัติการ"}),u.jsxs("select",{value:X.type,onChange:c=>Se({...X,type:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"EMS",children:"EMS (รับแจ้งเหตุแรก)"}),u.jsx("option",{value:"Refer",children:"Refer (ประสานพยาบาลต่อ)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ระดับหน่วยกู้ชีพ"}),u.jsxs("select",{value:X.unitLevel,onChange:c=>Se({...X,unitLevel:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"ALS",children:"ALS (วิชาชีพแพทย์)"}),u.jsx("option",{value:"BLS",children:"BLS (หน่วยพยาบาลกู้ชีพ)"}),u.jsx("option",{value:"CLS",children:"CLS (ทีมงานมูลนิธิพื้นฐาน)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"หน่วยปฏิบัติการรับเหมา"}),u.jsx("select",{value:X.unitId,onChange:c=>{const N=B.find(z=>z.id===c.target.value);N&&Se({...X,unitId:N.id,unitName:N.name})},className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:B.filter(c=>c.level===X.unitLevel&&c.isActive).map(c=>u.jsx("option",{value:c.id,children:c.name},c.id))})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเมินทางสาย (Phone Triage)"}),u.jsxs("select",{value:X.phoneTriage,onChange:c=>Se({...X,phoneTriage:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"แดง",children:"🔴 สีแดง - วิกฤตคุกคามชีพ"}),u.jsx("option",{value:"เหลือง",children:"🟡 สีเหลือง - เร่งด่วนกึ่งวิกฤต"}),u.jsx("option",{value:"เขียว",children:"🟢 สีเขียว - ไม่เร่งด่วนทั่วไป"}),u.jsx("option",{value:"ขาว",children:"⚪ สีขาว - ผู้ป่วยนัดหมาย"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเมินหน้าจุดเกิดเหตุ (Scene Triage)"}),u.jsxs("select",{value:X.sceneTriage,onChange:c=>Se({...X,sceneTriage:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"แดง",children:"🔴 สีแดง - วิกฤตคุกคามชีพ"}),u.jsx("option",{value:"เหลือง",children:"🟡 สีเหลือง - เร่งด่วนกึ่งวิกฤต"}),u.jsx("option",{value:"เขียว",children:"🟢 สีเขียว - ไม่เร่งด่วนทั่วไป"}),u.jsx("option",{value:"ขาว",children:"⚪ สีขาว - ผู้ป่วยนัดหมาย"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ประเมินหน้าห้องฉุกเฉิน (ER Triage)"}),u.jsxs("select",{value:X.erTriage,onChange:c=>Se({...X,erTriage:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"แดง",children:"🔴 สีแดง - วิกฤตคุกคามชีพ"}),u.jsx("option",{value:"เหลือง",children:"🟡 สีเหลือง - เร่งด่วนกึ่งวิกฤต"}),u.jsx("option",{value:"เขียว",children:"🟢 สีเขียว - ไม่เร่งด่วนทั่วไป"}),u.jsx("option",{value:"ขาว",children:"⚪ สีขาว - ผู้ป่วยนัดหมาย"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"รหัสเฉพาะ (Fast Track)"}),u.jsxs("select",{value:X.fastTrack,onChange:c=>Se({...X,fastTrack:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"ไม่มี Fast Track",children:"ไม่มี Fast Track"}),u.jsx("option",{value:"STROKE",children:"🧠 STROKE (สมองขาดเลือด)"}),u.jsx("option",{value:"STEMI",children:"❤️ STEMI (หัวใจขาดเลือด)"}),u.jsx("option",{value:"Sepsis",children:"🦠 Sepsis (ติดเชื้อในกระแสโลหิต)"}),u.jsx("option",{value:"Multiple Trauma",children:"🚗 Multiple Trauma (อุบัติเหตุพหุบาดเจ็บ)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"แพทย์อำนวยการรับปรึกษา (พอป.)"}),u.jsxs("div",{className:"flex items-center gap-2 py-2",children:[u.jsx("input",{type:"checkbox",checked:X.consultingDoctor,onChange:c=>Se({...X,consultingDoctor:c.target.checked}),className:"w-4 h-4 text-indigo-600 border-slate-200 rounded"}),u.jsx("span",{className:"text-xs font-bold text-slate-600",children:"มีการปรึกษาแพทย์อำนวยการ"})]})]}),X.consultingDoctor&&u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ชื่อแพทย์อำนวยการ พอป."}),u.jsx("input",{type:"text",value:X.doctorName||"",onChange:c=>Se({...X,doctorName:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none",placeholder:"เช่น พญ.ชลิดา พัชรสมุย"})]}),X.consultingDoctor&&u.jsxs("div",{className:"sm:col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"Online Medical Protocol (ข้อสั่งการแพทย์ออนไลน์)"}),u.jsx("input",{type:"text",value:X.onlineMedicalProtocol||"",onChange:c=>Se({...X,onlineMedicalProtocol:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-semibold text-slate-700 outline-none",placeholder:"เช่น การให้สารละลายและดามกระดูกฉุกเฉิน"})]}),u.jsxs("div",{className:"sm:col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ผลการวินิจฉัยพยาบาล (Diagnosis / อาการฉุกเฉิน)"}),u.jsx("textarea",{rows:3,value:X.diagnosis,onChange:c=>Se({...X,diagnosis:c.target.value}),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"สถานะเคส"}),u.jsxs("select",{value:X.status,onChange:c=>Se({...X,status:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-extrabold text-slate-700 bg-white",children:[u.jsx("option",{value:"ค้างปรับปรุงข้อมูล",children:"❌ ค้างปรับปรุงข้อมูล"}),u.jsx("option",{value:"ปรับปรุงข้อมูลแล้ว",children:"🟡 ปรับปรุงข้อมูลแล้ว"}),u.jsx("option",{value:"ปิดเคส",children:"🟢 ปิดเคส"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ผู้รับผิดชอบการ Complete ข้อมูล"}),u.jsx("select",{value:X.responsibleDispatcher,onChange:c=>Se({...X,responsibleDispatcher:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:j.filter(c=>c.role==="Dispatcher"||c.role==="Admin").map(c=>u.jsx("option",{value:c.username,children:c.fullName},c.id))})]})]}),u.jsxs("div",{className:"flex gap-2 pt-4 border-t border-slate-100 justify-end",children:[u.jsx("button",{type:"button",onClick:()=>Se(null),className:"py-2 px-4 bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-bold rounded-xl transition-all cursor-pointer",children:"ยกเลิกการแก้ไข"}),u.jsx("button",{type:"button",onClick:()=>pi(X),className:"py-2 px-5 bg-indigo-600 hover:bg-indigo-700 text-white text-xs font-bold rounded-xl shadow-md shadow-indigo-200 transition-all cursor-pointer border border-indigo-500/10",children:"บันทึกข้อมูลปรับปรุง"})]})]})}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("form",{onSubmit:Vu,className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 space-y-4",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-2",children:[u.jsxs("h3",{className:"text-base font-black text-slate-800 flex items-center gap-2",children:[u.jsx(Bo,{className:"w-4.5 h-4.5 text-rose-600"})," บันทึกรายงานระดับสถานะความพร้อมของหน่วยงานกู้ชีพ"]}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"คีย์ระบุข้อมูลหากหน่วยกู้ภัยในข่ายนเรนทรไม่พร้อมปฏิบัติการ เช่น รถส่งซ่อมชั่วคราว"})]}),u.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เลือกหน่วยปฏิบัติการที่มีปัญหา"}),u.jsxs("select",{value:Al,onChange:c=>gn(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white outline-none focus:ring-1 focus:ring-indigo-500",children:[u.jsx("option",{value:"",children:"-- เลือกหน่วยงานกู้ชีพ --"}),B.map(c=>u.jsxs("option",{value:c.id,children:[c.name," (",c.level,")"]},c.id))]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"คาดการณ์ระยะเวลาไม่พร้อมใช้ (ชั่วโมง)"}),u.jsx("input",{type:"number",placeholder:"เช่น 4, 12, 24",disabled:Tt,value:Ua,onChange:c=>yn(c.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-semibold text-slate-700 outline-none disabled:bg-slate-50"})]}),u.jsxs("div",{className:"sm:col-span-2 flex items-center gap-2",children:[u.jsx("input",{type:"checkbox",checked:Tt,onChange:c=>Me(c.target.checked),className:"w-4 h-4 text-indigo-600 border-slate-200 rounded"}),u.jsx("span",{className:"text-xs font-bold text-slate-600",children:"ยังไม่ทราบเวลาสิ้นสุดกู้คืนความพร้อมแน่นอน"})]}),u.jsxs("div",{className:"sm:col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ระบุเหตุผลขัดข้องความพร้อม"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น ยางรถเสื่อมชำรุดชั่วคราว, วิทยุโมบายล์พังควันขึ้น",value:Ma,onChange:c=>Oa(c.target.value),className:"w-full py-2 px-3 border border-slate-200 focus:border-rose-400 rounded-lg text-xs font-semibold outline-none"})]})]}),u.jsx("button",{type:"submit",className:"w-full py-2.5 bg-rose-600 hover:bg-rose-700 text-white font-bold text-xs rounded-xl shadow-md shadow-rose-200 transition-all cursor-pointer",children:'ส่งแจ้งเตือน "ไม่พร้อมออกปฏิบัติการ" ขึ้น Dashboard EMS'})]}),u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 flex flex-col justify-between gap-4",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-2 flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"ขบวนกู้ภัยที่ยังไม่พร้อมปฏิบัติการ ณ ปัจจุบัน"}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"อัปเดตแบบ Realtime ไปยัง Dashboard ผู้บริหารและพยาบาลนำส่ง"})]}),u.jsxs("span",{className:"bg-rose-100 text-rose-800 text-[10px] font-black px-2.5 py-1 rounded-full border border-rose-200",children:[ne.filter(c=>c.status==="ไม่พร้อมปฏิบัติการ").length," หน่วยขัดข้อง"]})]}),u.jsx("div",{className:"space-y-3 max-h-[220px] overflow-y-auto pr-2 divide-y divide-slate-50",children:ne.filter(c=>c.status==="ไม่พร้อมปฏิบัติการ").length===0?u.jsx("div",{className:"text-center py-10 text-slate-400 text-xs font-bold",children:"💚 ยอดเยี่ยม! หน่วยงานกู้ชีพทุกข่าย 19 สถานีพร้อมออกปฏิบัติการ 100%"}):ne.filter(c=>c.status==="ไม่พร้อมปฏิบัติการ").map(c=>u.jsxs("div",{className:"pt-2.5 first:pt-0 flex items-start justify-between gap-3 text-xs",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsx("div",{className:"font-extrabold text-slate-900",children:c.unitName}),u.jsxs("p",{className:"text-[10px] text-rose-600 leading-normal font-black",children:["เหตุผลชำรุด: ",c.reason]}),u.jsxs("div",{className:"text-[9px] text-slate-400 font-bold",children:["บันทึกเมื่อ: ",c.updatedAt.replace("T"," ").substring(0,16)," น. | โดย: ",c.recordedBy]})]}),u.jsx("button",{onClick:()=>Sn(c.unitId),className:"bg-emerald-50 hover:bg-emerald-100 text-emerald-700 font-extrabold text-[10px] px-2.5 py-1 rounded-lg border border-emerald-200 transition-colors cursor-pointer",children:"กลับคืนพร้อมปฏิบัติ"})]},c.unitId))}),u.jsx("div",{className:"bg-slate-50 p-2.5 rounded-xl border border-slate-100/60 text-[10px] font-bold text-slate-500",children:'⚠️ แจ้งหัวหน้าเวร: หากปัญหาซ่อมบำรุงในรถพยาบาลได้รับการแก้ไขแล้ว กรุณากดปุ่ม "กลับคืนพร้อมปฏิบัติ" เพื่อล้างสถานะ Dashboard'})]})]})]}),Ie==="daily-report"&&u.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[u.jsxs("div",{className:"bg-white rounded-2xl p-4 md:p-5 shadow-sm border border-slate-100 flex flex-wrap gap-4 items-center",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-xs font-bold text-slate-500",children:"วันที่คัดรายงาน:"}),u.jsx("input",{type:"date",value:Ne,onChange:c=>zl(c.target.value),className:"py-1.5 px-3 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 outline-none"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-xs font-bold text-slate-500",children:"เลือกเวรรอบ:"}),u.jsxs("select",{value:Gt,onChange:c=>Xu(c.target.value),className:"py-1.5 px-3 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 bg-white outline-none",children:[u.jsx("option",{value:"เช้า",children:"☀️ เวรเช้า (08:00 - 16:00 น.)"}),u.jsx("option",{value:"บ่าย",children:"⛅ เวรบ่าย (16:00 - 00:00 น.)"}),u.jsx("option",{value:"ดึก",children:"🌙 เวรดึก (00:00 - 08:00 น.)"})]})]})]}),u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 space-y-4",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-2",children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"ระบุบทบันทึกสรุปและเรื่องค้างส่งมอบ"}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"ป้อนข้อมูลข้อขัดข้องหรือความเสี่ยงที่พบในรอบเวร เพื่อนำไปลงบันทึกในเอกสารรายงานประจำวันอัตโนมัติ"})]}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"สรุปเหตุการณ์สำคัญประจำเวร (Narrative)"}),u.jsx("textarea",{rows:3,placeholder:"เช่น การประสานรับเคสอุบัติเหตุหมู่ สัญญาณสายแทงเข้าปกติ ไม่มีข้อติดขัดเรื่องรถ ALS...",value:gi,onChange:c=>yi(c.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none focus:ring-1 focus:ring-indigo-500"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ความเสี่ยงหรือปัญหาที่สืบค้นพบ"}),u.jsx("textarea",{rows:3,placeholder:"เช่น พบปัญหาคลื่นสัญญาณวิทยุจุดบ่อผุดรับส่งเบาบาง, ฝนตกจุดเกาะพะงันคลื่นแรงสปีดโบ๊ทยกยาก...",value:El,onChange:c=>pn(c.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none focus:ring-1 focus:ring-indigo-500"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เคสสำคัญที่ต้องสืบสวนและติดตามต่อ"}),u.jsx("textarea",{rows:3,placeholder:"เช่น เคสประสานเฮลิคอปเตอร์กู้ชีพเกาะเต่า OB-2569-0012 รอสรุปผลประเมินอาการส่งต่อ ER สุราษฎร์ธานี...",value:il,onChange:c=>Cl(c.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none focus:ring-1 focus:ring-indigo-500"})]})]})]}),u.jsx(T.Suspense,{fallback:u.jsx(Ic,{}),children:u.jsx(Yh,{report:ji,onConfirmHandover:(c,N)=>{const z=it(c,N);if(z){const L=j.find(ee=>ee.username===c);if(L){const ee=H.map(je=>je.date===Ne&&je.shift===Gt&&je.status==="ปรับปรุงข้อมูลแล้ว"?{...je,status:"ปิดเคส"}:je);xe(ee),He(`รับ-ส่งมอบเวรเสร็จสิ้นให้กับ ${L.fullName}`)}}return z},dispatchers:j,successMsg:Jt,setSuccessMsg:qt,cases:H,calls:_})})]}),Ie==="radio-test"&&u.jsx("div",{className:"space-y-6 animate-fadeIn",children:u.jsx(T.Suspense,{fallback:u.jsx(Ic,{}),children:u.jsx(Lh,{currentUser:K,onSaveRadioTest:Si,radioTests:R})})}),Ie==="statistics"&&u.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[u.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"ยอดเคสสะสมในระบบ"}),u.jsxs("div",{className:"text-2xl font-black text-slate-800 mt-1",children:[H.length," เคส"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"ยอดสายเรียกเข้าแรกรับ"}),u.jsxs("div",{className:"text-2xl font-black text-slate-800 mt-1",children:[_.length," สาย"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"ประเมินเคสปิดสำเร็จ"}),u.jsxs("div",{className:"text-2xl font-black text-emerald-600 mt-1",children:[H.filter(c=>c.status==="ปิดเคส").length," รายการ"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold font-sans",children:"เคสตกค้าง/ยังไม่ปิด"}),u.jsxs("div",{className:"text-2xl font-black text-rose-600 mt-1",children:[H.filter(c=>c.status==="ค้างปรับปรุงข้อมูล").length," รายการ"]})]})]}),u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[Ai("สัดส่วนช่องทางการแจ้งเหตุ (Call Channels)",[{name:"First Call (เบอร์ 1669 หลัก)",count:_.filter(c=>c.channel==="First Call").length||4,color:"#2563eb"},{name:"Second Call (สายซ้อนประสาน)",count:_.filter(c=>c.channel==="Second Call").length||2,color:"#3b82f6"},{name:"วิทยุสื่อสาร ว.6",count:_.filter(c=>c.channel==="วิทยุ").length||3,color:"#6366f1"},{name:"หมายเลขอื่น / ช่องทางอื่น ๆ",count:_.filter(c=>["หมายเลขอื่น","วิธีอื่น ๆ"].includes(c.channel)).length||1,color:"#a855f7"}]),Ai("ระดับการประเมิน Phone Triage ฉุกเฉินคุกคามชีพ",[{name:"🔴 สีแดง - วิกฤตสูงสุด",count:H.filter(c=>c.phoneTriage==="แดง").length||3,color:"#dc2626"},{name:"🟡 สีเหลือง - เร่งด่วน",count:H.filter(c=>c.phoneTriage==="เหลือง").length||2,color:"#f59e0b"},{name:"🟢 สีเขียว - เจ็บป่วยทั่วไป",count:H.filter(c=>c.phoneTriage==="เขียว").length||1,color:"#10b981"},{name:"⚪ สีขาว - ตรวจสุขภาพนัดส่งต่อ",count:H.filter(c=>c.phoneTriage==="ขาว").length||0,color:"#94a3b8"}])]}),u.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden",children:[u.jsx("div",{className:"p-4 md:p-5 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:u.jsxs("div",{children:[u.jsxs("h3",{className:"text-base font-bold text-slate-800 flex items-center gap-1.5",children:[u.jsx(gh,{className:"w-4.5 h-4.5 text-indigo-600"})," ดัชนีผลผลิตผู้ปฏิบัติการรับรับแจ้งเหตุและสั่งการ (Productivity ของเจ้าหน้าที่)"]}),u.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"คำนวณสถิติสรุปงานแยกรายเจ้าหน้าที่โดยอัตโนมัติอ้างอิงตาม username บันทึกข้อมูลจริงในข่าย"})]})}),u.jsx("div",{className:"overflow-x-auto",children:u.jsxs("table",{className:"w-full text-left border-collapse text-xs md:text-sm",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-slate-100/50 text-slate-600 font-bold border-b border-slate-100",children:[u.jsx("th",{className:"py-3 px-4",children:"ชื่อเจ้าหน้าที่กู้ชีพกู้ภัย"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"สิทธิ์ในระบบ"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"รับสายโทรศัพท์ (สาย)"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"สร้างเคสใหม่ (เคส)"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"รับมอบ Complete (เคส)"}),u.jsx("th",{className:"py-3 px-3 text-center",children:"เคสที่ปิดแล้ว (เคส)"})]})}),u.jsx("tbody",{className:"divide-y divide-slate-100 text-slate-700 font-medium",children:zi.map(c=>u.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[u.jsx("td",{className:"py-3.5 px-4 font-bold text-slate-800",children:c.fullName}),u.jsx("td",{className:"py-3.5 px-3 text-center",children:u.jsx("span",{className:"bg-slate-100 text-slate-600 px-2 py-0.5 rounded text-[10px] font-bold border border-slate-200",children:c.role})}),u.jsx("td",{className:"py-3.5 px-3 text-center font-bold text-slate-700",children:c.createdCalls||0}),u.jsx("td",{className:"py-3.5 px-3 text-center font-bold text-slate-700",children:c.createdCases||0}),u.jsx("td",{className:"py-3.5 px-3 text-center font-bold text-slate-700",children:c.assignedCases||0}),u.jsx("td",{className:"py-3.5 px-3 text-center",children:u.jsxs("span",{className:"bg-emerald-50 text-emerald-700 font-black px-2 py-0.5 rounded text-xs",children:[c.resolvedCases||0," เคสสำเร็จ"]})})]},c.id))})]})})]})]}),Ie==="dashboard"&&u.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[u.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[u.jsxs("div",{className:"bg-gradient-to-br from-indigo-600 to-indigo-700 text-white p-4 rounded-2xl shadow-md shadow-indigo-200 border border-indigo-500/10",children:[u.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-indigo-100",children:"สายรับแรกรับเวรปัจจุบัน"}),u.jsxs("div",{className:"text-2xl font-black mt-1.5",children:[_.filter(c=>c.date===new Date().toISOString().split("T")[0]).length," สาย"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"เคสกู้ภัยที่กำลังออก ว.4"}),u.jsxs("div",{className:"text-2xl font-black text-slate-800 mt-1",children:[H.filter(c=>c.status==="ปรับปรุงข้อมูลแล้ว").length," เคส"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold font-sans",children:"เคสตกหล่นค้างข้อมูล"}),u.jsxs("div",{className:"text-2xl font-black text-rose-600 mt-1",children:[H.filter(c=>c.status==="ค้างปรับปรุงข้อมูล").length," เคสค้าง"]})]}),u.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100",children:[u.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"หน่วยในข่ายไม่พร้อมทำงาน"}),u.jsxs("div",{className:"text-2xl font-black text-amber-600 mt-1",children:[ne.filter(c=>c.status==="ไม่พร้อมปฏิบัติการ").length," สถานี"]})]})]}),u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[u.jsxs("div",{className:"lg:col-span-2 bg-white rounded-2xl shadow-sm border border-slate-100 p-5 space-y-4",children:[u.jsxs("div",{className:"border-b border-slate-50 pb-2 flex items-center justify-between",children:[u.jsx("h4",{className:"font-bold text-slate-800 text-sm",children:"ขบวนกู้ชีพกำลังออกปฏิบัติงานหลัก"}),u.jsx("span",{className:"text-[10px] bg-indigo-100 text-indigo-800 px-2 py-0.5 rounded-full border border-indigo-200 font-bold",children:"Realtime"})]}),u.jsx("div",{className:"space-y-3",children:H.filter(c=>c.status!=="ปิดเคส").length===0?u.jsx("div",{className:"text-center py-10 text-slate-400 text-xs font-semibold",children:"💚 ขณะนี้ไม่มีเคสค้างออกปฏิบัติการนอกพื้นที่ ทุกสถานีปิดรอบงานเรียบร้อย"}):H.filter(c=>c.status!=="ปิดเคส").map(c=>u.jsxs("div",{className:"p-3 bg-slate-50/50 rounded-xl border border-slate-100 flex items-center justify-between gap-4 text-xs font-semibold",children:[u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"font-extrabold text-slate-900",children:[c.id," (",c.type,")"]}),u.jsxs("p",{className:"text-[10px] text-slate-500 font-medium",children:["หน่วย: ",c.unitName," | อาการ: ",c.diagnosis.substring(0,50),"..."]})]}),u.jsx("span",{className:"bg-amber-100 text-amber-800 text-[10px] font-black px-2.5 py-1 rounded border border-amber-200",children:c.status})]},c.id))})]}),u.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 space-y-4",children:[u.jsx("div",{className:"border-b border-slate-50 pb-2",children:u.jsx("h4",{className:"font-bold text-slate-800 text-sm",children:"เคสตกค้างค้างกรอกข้อมูล (ค้างกับใคร)"})}),u.jsx("div",{className:"space-y-3",children:H.filter(c=>c.status==="ค้างปรับปรุงข้อมูล").length===0?u.jsx("div",{className:"text-center py-10 text-slate-400 text-xs font-medium",children:"🎉 สัญญาณดีมาก! ไม่มีประวัติเคสฉุกเฉินค้างปรับปรุงข้อมูลในรอบเวรนี้"}):H.filter(c=>c.status==="ค้างปรับปรุงข้อมูล").map(c=>u.jsxs("div",{className:"p-3 bg-rose-50/20 rounded-xl border border-rose-100 text-xs font-bold space-y-1.5",children:[u.jsxs("div",{className:"flex justify-between items-center text-slate-900",children:[u.jsxs("span",{children:["เลข: ",c.id]}),u.jsx("span",{className:"text-[10px] text-rose-600 font-mono",children:"ค้าง: 1 ชม. 15 นาที"})]}),u.jsxs("div",{className:"text-[10px] text-slate-500 font-medium",children:["ผู้รับผิดชอบหลัก: ",j.find(N=>N.username===c.responsibleDispatcher)?.fullName.split(" ")[0]||c.responsibleDispatcher]})]},c.id))})]})]})]}),Ie==="ambulance-check"&&u.jsx("div",{className:"space-y-6 animate-fadeIn",children:u.jsx(T.Suspense,{fallback:u.jsx(Ic,{}),children:u.jsx(wh,{currentUser:K,onSaveCheckSession:Ba,checkSessions:I,tickets:ve,onUpdateTicketStatus:Ku})})}),Ie==="admin"&&u.jsx("div",{className:"space-y-6 animate-fadeIn",children:u.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 space-y-6",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-3",children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"จัดการข้อมูลผู้ใช้งานระบบ (User Management)"}),u.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"เพิ่ม ลบ บัญชีผู้ใช้ เปลี่ยนสิทธิ์ และ PIN ปลดล็อคระบบ"})]}),u.jsxs("form",{onSubmit:Nn,className:"space-y-4",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"Username (ลงชื่อเข้าใช้งาน)"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น dispatcher_test",value:J?J.username:G.username,onChange:c=>J?$e({...J,username:c.target.value}):$t({...G,username:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ชื่อ-นามสกุลทางการแพทย์"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น นายกู้ชีพ มีสุข",value:J?J.fullName:G.fullName,onChange:c=>J?$e({...J,fullName:c.target.value}):$t({...G,fullName:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"สิทธิ์/บทบาทการทำงาน (Role)"}),u.jsxs("select",{value:J?J.role:G.role,onChange:c=>J?$e({...J,role:c.target.value}):$t({...G,role:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"Admin",children:"Admin"}),u.jsx("option",{value:"Supervisor",children:"Supervisor"}),u.jsx("option",{value:"Dispatcher",children:"Dispatcher"}),u.jsx("option",{value:"Executive",children:"Executive"}),u.jsx("option",{value:"ER Koh Samui",children:"ER Koh Samui"}),u.jsx("option",{value:"Quality Officer",children:"Quality Officer"}),u.jsx("option",{value:"Driver",children:"Driver"}),u.jsx("option",{value:"EMS",children:"EMS"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"รหัส PIN 4 หลัก (สำหรับความปลอดภัย)"}),u.jsx("input",{type:"password",maxLength:4,required:!0,placeholder:"เช่น 1234",value:J?J.pin:G.pin,onChange:c=>J?$e({...J,pin:c.target.value}):$t({...G,pin:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 font-mono text-center tracking-widest outline-none"})]}),u.jsxs("div",{className:"col-span-2 flex items-center gap-4 py-1",children:[u.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-bold text-slate-600",children:[u.jsx("input",{type:"checkbox",checked:J?J.mustChangePin:G.mustChangePin,onChange:c=>J?$e({...J,mustChangePin:c.target.checked}):$t({...G,mustChangePin:c.target.checked}),className:"w-4 h-4 text-blue-600 border-slate-200 rounded"}),"บังคับให้เปลี่ยน PIN เมื่อเข้าสู่ระบบครั้งแรก"]}),u.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-bold text-slate-600",children:[u.jsx("input",{type:"checkbox",checked:J?J.isActive:G.isActive,onChange:c=>J?$e({...J,isActive:c.target.checked}):$t({...G,isActive:c.target.checked}),className:"w-4 h-4 text-blue-600 border-slate-200 rounded"}),"เปิดใช้งานบัญชีนี้ (Active)"]})]})]}),u.jsxs("div",{className:"flex gap-2",children:[J&&u.jsx("button",{type:"button",onClick:()=>$e(null),className:"flex-1 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-bold rounded-xl transition-all cursor-pointer",children:"ยกเลิกแก้ไข"}),u.jsx("button",{type:"submit",className:"flex-1 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-bold text-xs rounded-xl shadow-md transition-all cursor-pointer",children:J?"บันทึกการปรับปรุงผู้ใช้":"เพิ่มและจัดสร้างผู้ใช้ใหม่"})]})]}),u.jsx("div",{className:"overflow-x-auto border border-slate-100 rounded-xl",children:u.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-slate-50 text-slate-600 font-bold border-b border-slate-100",children:[u.jsx("th",{className:"py-2.5 px-3",children:"บัญชี / ชื่อผู้ใช้"}),u.jsx("th",{className:"py-2.5 px-3",children:"บทบาท (Role)"}),u.jsx("th",{className:"py-2.5 px-3 text-center",children:"สถานะ"}),u.jsx("th",{className:"py-2.5 px-3 text-center",children:"แก้ไข"})]})}),u.jsx("tbody",{className:"divide-y divide-slate-50 font-semibold text-slate-700",children:j.map(c=>u.jsxs("tr",{className:"hover:bg-slate-50/50",children:[u.jsxs("td",{className:"py-2 px-3",children:[u.jsx("div",{className:"font-bold text-slate-800",children:c.fullName}),u.jsxs("div",{className:"text-[10px] text-slate-400 font-mono",children:["@",c.username]})]}),u.jsx("td",{className:"py-2 px-3",children:u.jsx("span",{className:"bg-slate-100 px-2 py-0.5 rounded text-[10px]",children:c.role})}),u.jsx("td",{className:"py-2 px-3 text-center",children:u.jsx("span",{className:`px-2 py-0.5 rounded-[5px] text-[9px] font-black ${c.isActive?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-rose-50 text-rose-700 border border-rose-200"} `,children:c.isActive?"Active":"Inactive"})}),u.jsx("td",{className:"py-2 px-3 text-center",children:u.jsxs("div",{className:"flex gap-1.5 justify-center",children:[u.jsx("button",{onClick:()=>$e(c),className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-600 rounded cursor-pointer",children:u.jsx(Jc,{className:"w-3.5 h-3.5"})}),u.jsx("button",{onClick:()=>_l(c.id),disabled:c.id==="1"||c.id===K.id,className:"p-1 hover:bg-rose-50 text-slate-300 hover:text-rose-600 rounded disabled:opacity-30 cursor-pointer",children:u.jsx(Ho,{className:"w-3.5 h-3.5"})})]})})]},c.id))})]})})]}),u.jsxs("div",{className:"bg-white rounded-2xl p-5 md:p-6 shadow-sm border border-slate-100 space-y-6",children:[u.jsxs("div",{className:"border-b border-slate-100 pb-3",children:[u.jsx("h3",{className:"text-base font-black text-slate-800",children:"จัดการหน่วยกู้ชีพและระดับกู้ภัย (Ambulance Fleet)"}),u.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"เพิ่ม ปรับลำดับการทำงาน และระบุหน่วยรับส่งประจำเกาะสมุย"})]}),u.jsxs("form",{onSubmit:Ti,className:"space-y-4",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsxs("div",{className:"col-span-2",children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ชื่อสถานี / หน่วยกู้ชีพร่วมเครือข่าย"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น หน่วยกู้ชีพตลิ่งงาม",value:ie?ie.name:ye.name,onChange:c=>ie?We({...ie,name:c.target.value}):Dl({...ye,name:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ระดับหน่วย (Level)"}),u.jsxs("select",{value:ie?ie.level:ye.level,onChange:c=>ie?We({...ie,level:c.target.value}):Dl({...ye,level:c.target.value}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 bg-white",children:[u.jsx("option",{value:"ALS",children:"ALS (วิชาชีพขั้นสูง)"}),u.jsx("option",{value:"BLS",children:"BLS (รถพยาบาลมาตรฐาน)"}),u.jsx("option",{value:"CLS",children:"CLS (หน่วยกู้ภัยพื้นฐาน)"})]})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"จัดลำดับการทำงาน (Sort Order)"}),u.jsx("input",{type:"number",placeholder:"ลำดับการออกขบวน",value:ie?ie.sortOrder:ye.sortOrder,onChange:c=>ie?We({...ie,sortOrder:Number(c.target.value)}):Dl({...ye,sortOrder:Number(c.target.value)}),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none"})]}),u.jsxs("div",{className:"col-span-2 flex items-center gap-4 py-1",children:[u.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-bold text-slate-600",children:[u.jsx("input",{type:"checkbox",checked:ie?ie.isSamuiHospital:ye.isSamuiHospital,onChange:c=>ie?We({...ie,isSamuiHospital:c.target.checked}):Dl({...ye,isSamuiHospital:c.target.checked}),className:"w-4 h-4 text-blue-600 border-slate-200 rounded"}),"ระบุเป็นหน่วยโรงพยาบาลเกาะสมุย (ER สมุยหลัก)"]}),u.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-bold text-slate-600",children:[u.jsx("input",{type:"checkbox",checked:ie?ie.isActive:ye.isActive,onChange:c=>ie?We({...ie,isActive:c.target.checked}):Dl({...ye,isActive:c.target.checked}),className:"w-4 h-4 text-blue-600 border-slate-200 rounded"}),"เปิดใช้งานขบวนนี้ (Active)"]})]})]}),u.jsxs("div",{className:"flex gap-2",children:[ie&&u.jsx("button",{type:"button",onClick:()=>We(null),className:"flex-1 py-2 bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-bold rounded-xl transition-all cursor-pointer",children:"ยกเลิกแก้ไข"}),u.jsx("button",{type:"submit",className:"flex-1 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-bold text-xs rounded-xl shadow-md transition-all cursor-pointer",children:ie?"บันทึกการปรับปรุงหน่วยงาน":"เพิ่มหน่วยกู้ภัยเครือข่ายใหม่"})]})]}),u.jsx("div",{className:"overflow-x-auto border border-slate-100 rounded-xl max-h-[220px]",children:u.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"bg-slate-50 text-slate-600 font-bold border-b border-slate-100",children:[u.jsx("th",{className:"py-2.5 px-3",children:"ชื่อหน่วยกู้ภัยเครือข่าย"}),u.jsx("th",{className:"py-2.5 px-3",children:"ระดับ"}),u.jsx("th",{className:"py-2.5 px-3 text-center",children:"สิทธิ์ รพ.สมุย"}),u.jsx("th",{className:"py-2.5 px-3 text-center",children:"แก้ไข"})]})}),u.jsx("tbody",{className:"divide-y divide-slate-50 font-semibold text-slate-700",children:B.map(c=>u.jsxs("tr",{className:"hover:bg-slate-50/50",children:[u.jsxs("td",{className:"py-2 px-3",children:[u.jsx("div",{className:"font-bold text-slate-800",children:c.name}),u.jsxs("div",{className:"text-[10px] text-slate-400 font-mono",children:["ลำดับ: ",c.sortOrder]})]}),u.jsx("td",{className:"py-2 px-3",children:u.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border ${c.level==="ALS"?"bg-red-50 text-red-700 border-red-100":""} ${c.level==="BLS"?"bg-blue-50 text-blue-700 border-blue-100":""} ${c.level==="CLS"?"bg-indigo-50 text-indigo-700 border-indigo-100":""} `,children:c.level})}),u.jsx("td",{className:"py-2 px-3 text-center",children:c.isSamuiHospital?"🟢 ใช่":"❌ ไม่"}),u.jsx("td",{className:"py-2 px-3 text-center",children:u.jsx("button",{type:"button",onClick:()=>We(c),className:"p-1 hover:bg-blue-50 text-slate-400 hover:text-blue-600 rounded cursor-pointer",children:u.jsx(Jc,{className:"w-3.5 h-3.5"})})})]},c.id))})]})})]})]})})]})]}):u.jsx("div",{className:"flex-1 flex items-center justify-center p-4 md:p-8 bg-gradient-to-br from-slate-900 via-blue-950 to-slate-950 min-h-[calc(100vh-70px)]",children:u.jsxs("div",{className:"w-full max-w-md bg-white rounded-3xl shadow-2xl overflow-hidden border border-slate-100 p-6 md:p-8 space-y-6",children:[u.jsxs("div",{className:"text-center space-y-2",children:[u.jsx("div",{className:"mx-auto w-14 h-14 bg-blue-600 rounded-2xl text-white shadow-xl shadow-blue-500/20 flex items-center justify-center",children:u.jsx(Bo,{className:"w-8 h-8"})}),u.jsx("h2",{className:"text-xl md:text-2xl font-black text-slate-900 tracking-tight",children:"ระบบบริหารจัดการ นเรนทรอ่าวไทย"}),u.jsx("p",{className:"text-xs text-slate-400 font-bold",children:"กรุณาเข้าสู่ระบบด้วยรหัส PIN 4 หลักเพื่อเริ่มต้นปฏิบัติงาน"})]}),at?u.jsxs("form",{onSubmit:qa,className:"space-y-4",children:[u.jsx("div",{className:"bg-amber-50 border border-amber-100 p-3 rounded-xl text-amber-800 text-xs font-semibold leading-relaxed",children:"⚠️ บัญชีนี้ถูกเปิดใช้งานครั้งแรก คุณจำเป็นต้องเปลี่ยนรหัสผ่าน PIN 4 หลักใหม่เพื่อความปลอดภัยของระบบกู้ชีพ"}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1.5 uppercase tracking-wider",children:"รหัส PIN ใหม่ (ตัวเลข 4 หลัก)"}),u.jsx("input",{type:"password",maxLength:4,required:!0,placeholder:"ป้อนรหัส 4 หลัก",value:Rt,onChange:c=>jt(c.target.value),className:"w-full py-2.5 px-3.5 border border-slate-200 focus:border-indigo-500 rounded-xl text-center text-lg font-mono tracking-widest text-slate-800 outline-none transition-all"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1.5 uppercase tracking-wider",children:"ยืนยันรหัส PIN ใหม่"}),u.jsx("input",{type:"password",maxLength:4,required:!0,placeholder:"ยืนยันรหัส 4 หลัก",value:p,onChange:c=>A(c.target.value),className:"w-full py-2.5 px-3.5 border border-slate-200 focus:border-indigo-500 rounded-xl text-center text-lg font-mono tracking-widest text-slate-800 outline-none transition-all"})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{type:"button",onClick:()=>Sl(!1),className:"flex-1 py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-600 text-xs font-bold rounded-xl transition-all cursor-pointer",children:"ยกเลิก"}),u.jsx("button",{type:"submit",className:"flex-1 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-xs font-bold rounded-xl transition-all cursor-pointer border border-indigo-500/20",children:"เปลี่ยนและเข้าสู่ระบบ"})]})]}):u.jsxs("form",{onSubmit:Zu,className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1.5 uppercase tracking-wider",children:"บัญชีผู้ใช้งาน"}),u.jsx("input",{type:"text",required:!0,placeholder:"เช่น admin, dispatcher1",value:Pe,onChange:c=>Bt(c.target.value),className:"w-full py-2.5 px-3.5 border border-slate-200 focus:border-indigo-500 rounded-xl text-sm font-bold text-slate-800 outline-none transition-all"})]}),u.jsxs("div",{children:[u.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1.5 uppercase tracking-wider",children:"ป้อน PIN 4 หลัก"}),u.jsx("input",{type:"password",maxLength:4,required:!0,placeholder:"••••",value:ea,onChange:c=>Ht(c.target.value),className:"w-full py-2.5 px-3.5 border border-slate-200 focus:border-indigo-500 rounded-xl text-center text-lg font-mono tracking-widest text-slate-800 outline-none transition-all"})]}),mt&&u.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-100 text-rose-600 rounded-xl text-xs font-bold flex items-center gap-2",children:[u.jsx(hh,{className:"w-4 h-4 shrink-0"}),u.jsx("span",{children:mt})]}),u.jsx("button",{type:"submit",className:"w-full py-3 bg-indigo-600 hover:bg-indigo-700 text-white font-extrabold text-sm rounded-xl shadow-lg shadow-indigo-500/20 transition-all active:scale-95 cursor-pointer border border-indigo-500/20",id:"btn-login",children:"เข้าสู่ระบบปฏิบัติงาน"})]}),u.jsxs("div",{className:"border-t border-slate-100 pt-4 text-center",children:[u.jsx("span",{className:"text-[10px] text-slate-400 font-extrabold uppercase tracking-wider block mb-2",children:"บัญชีทดสอบระบบตามความต้องการ"}),u.jsx("div",{className:"flex flex-wrap gap-1.5 justify-center",children:[{user:"admin",label:"Admin",color:"bg-red-50 text-red-700 hover:bg-red-100 border-red-200"},{user:"dispatcher1",label:"Dispatcher",color:"bg-indigo-50 text-indigo-700 hover:bg-indigo-100 border-indigo-200"},{user:"samui_er",label:"รพ.เกาะสมุย",color:"bg-pink-50 text-pink-700 hover:bg-pink-100 border-pink-200"},{user:"driver1",label:"พขร. ตรวจรถ",color:"bg-amber-50 text-amber-700 hover:bg-amber-100 border-amber-200"}].map(c=>u.jsx("button",{onClick:()=>{Bt(c.user),Ht("1234")},className:`px-2.5 py-1 text-[10px] font-bold rounded-lg border transition-all cursor-pointer ${c.color}`,children:c.label},c.user))})]})]})})]})}zh.createRoot(document.getElementById("root")).render(u.jsx(T.StrictMode,{children:u.jsx(Gh,{})}));export{Vh as C,Dh as I,Zh as R,u as j};