pih-appointment-widget 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -70
- package/babel.config.js +5 -5
- package/dist/App.js +10 -9
- package/dist/assets/icons/icdIcons.js +30 -0
- package/dist/components/AppointmentPage.js +87 -62
- package/dist/components/ICD10Assistant.js +144 -63
- package/dist/doctor-appointments-widget.umd.js +115 -119
- package/dist/doctor-appointments-widget.umd.min.js +1 -1
- package/dist/hooks/useClipboard.js +3 -3
- package/dist/pih-appointment-widget.umd.js +309 -208
- package/dist/pih-appointment-widget.umd.min.js +1 -1
- package/dist/services/appointmentService.js +20 -20
- package/dist/services/httpService.js +14 -18
- package/dist/services/icdService.js +21 -23
- package/package.json +67 -67
- package/public/index.html +43 -43
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/rollup.config.js +43 -43
- package/src/App.js +50 -50
- package/src/Example.js +14 -14
- package/src/assets/icons/icdIcon.png +0 -0
- package/src/assets/icons/icdIcons.js +23 -0
- package/src/components/AppointmentPage.js +2502 -2498
- package/src/components/ICD10Assistant.jsx +923 -855
- package/src/constants/apiConfig.js +29 -29
- package/src/hooks/useClipboard.js +35 -35
- package/src/index.js +6 -6
- package/src/services/appointmentService.js +92 -92
- package/src/services/httpService.js +103 -103
- package/src/services/icdService.js +76 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),r=o(n);function l(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const i="https://afiyaapiqa.powermindinc.com",d="/appointment/V1/consultant/all-appointments",s="/notification/V1/consultation/online/initiate",c="https://ittisalqa.powermindinc.com/call?token=",p=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS"),"UPCOMING"===a&&(a="UPCOMING,RESCHEDULED");const r=o.apiBaseUrl,l=o.hospitalId,i=o.doctorId,s=o.token||"",c={hospitalId:l,doctorId:i,fromDate:t,toDate:n,statuses:a,appointmentType:"ONLINE"},p="".concat(r).concat(d),u=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=new URL(e);o.search=new URLSearchParams(t).toString();const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:"".concat(n)}};return fetch(o,a).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:(null==e?void 0:e.message)||String(e)||"Network error"}))}(p,c,"PIH-Appointment-Widget",s);return u},u=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};console.log("initiateConsultation -> config",t);const n=t.apiBaseUrl.replace(/\/$/,""),o="".concat(n).concat(s),a=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach(e=>{a.searchParams.append(e,n[e])});const r={"Content-Type":"application/json"};o&&(r.Authorization=o);const l={method:"POST",headers:r,body:JSON.stringify(t)};return fetch(a.toString(),l).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:e.message||"Network error"}))}(o,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId,doctorId:String(t.doctorId),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},a)};const f="pih_appointment_idToken",m="pih_appointment_email",g="pih_appointment_appToken",x="pih_appointment_doctorId",h="pih_appointment_userName",y="pih_appointment_apiBaseUrl",b="pih_appointment_hospitalId",E=720,v="pih-appointment-widget",w="data-pih-widget";class S extends t.Component{constructor(){super(...arguments),l(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{className:v,[w]:"teleconsult-appointments",style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const F=e=>{let{config:n={}}=e;const[o,r]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch(e){return null}}),[l,d]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(b):null}catch(e){return null}}),s=n.apiBaseUrl||o||i,F=n.hospitalId||l,[C,k]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch(e){return null}}),[I,D]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch(e){return null}}),z=n.idToken||n.token||C,T=n.email||I;t.useEffect(()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(f)!==e&&(A(null),R(null),P(null),_(e=>e+1),localStorage.removeItem(g),localStorage.removeItem(x),localStorage.removeItem(h)),localStorage.setItem(f,e),k(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(m,n.email),D(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(y,n.apiBaseUrl.trim()),r(n.apiBaseUrl.trim())),null!=n.hospitalId&&String(n.hospitalId).trim()&&(localStorage.setItem(b,String(n.hospitalId).trim()),d(String(n.hospitalId).trim()))}catch(e){}},[n.idToken,n.token,n.email,n.apiBaseUrl,n.hospitalId]);const[W,A]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch(e){return null}}),[M,R]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch(e){return null}}),[N,P]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch(e){return null}}),[j,L]=t.useState(()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(g),t=localStorage.getItem(f),n=localStorage.getItem(m);return!e&&!(!t||!n)}catch(e){return!1}}),[H,B]=t.useState(null),[U,Y]=t.useState(!1),[O,_]=t.useState(0);t.useEffect(()=>{W&&j&&L(!1)},[W,j]),t.useEffect(()=>{W||(z&&T?(Y(!1),B(e=>"Sign in required. Redirecting to home..."===e?null:e)):(B("Sign in required. Redirecting to home..."),Y(!0)))},[W,z,T]),t.useEffect(()=>{if(!U)return;const e=n.homeUrl||"https://afiyaproqa.powermindinc.com/";if(!e||"undefined"==typeof window)return;const t=setTimeout(()=>{window.location.href=e},2500);return()=>clearTimeout(t)},[U,n.homeUrl]),t.useEffect(()=>{if(!j)return;const e=setTimeout(()=>{B("Request timed out. Please try again."),L(!1)},3e4);return()=>clearTimeout(e)},[j]);const q=n.joinCallUrl||c;W&&String(q||"").replace(/\/?$/,"/");const K=function(e){if(!e||"string"!=typeof e)return{};try{const t=e.split(".");if(3!==t.length)return{};const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch(e){return{}}}(z),V=N||K.name||K.sub||"User",X=()=>(new Date).toISOString().split("T")[0],G=e=>{const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(n,"-").concat(o)},[J,$]=t.useState("upcoming"),[Q,Z]=t.useState([]),[ee,te]=t.useState(null),[ne,oe]=t.useState(!1),[ae,re]=t.useState(null),[le,ie]=t.useState(window.innerWidth<768),[de,se]=t.useState("today"),[ce,pe]=t.useState("today"),[ue,fe]=t.useState(!1),[me,ge]=t.useState(!1),[xe,he]=t.useState("all"),[ye,be]=t.useState("asc"),[Ee,ve]=t.useState(""),[we,Se]=t.useState(!1),[Fe,Ce]=t.useState(!1),[ke,Ie]=t.useState(!1),[De,ze]=t.useState(null),[Te,We]=t.useState(null),[Ae,Me]=t.useState(!1),[Re,Ne]=t.useState(null),[Pe,je]=t.useState(()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-E-20:300),y:80})),[Le,He]=t.useState({width:E,height:560}),[Be,Ue]=t.useState(!1),[Ye,Oe]=t.useState({x:0,y:0}),[_e,qe]=t.useState(!1),[Ke,Ve]=t.useState(null),[Xe,Ge]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Je,$e]=t.useState(1),Qe=Q.filter(e=>{if(!Ee.trim())return!0;const t=Ee.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)}),Ze=5*(Je-1),et=Ze+5,tt=Qe.slice(Ze,et),nt=Math.ceil(Qe.length/5),ot=Qe.length,[at,rt]=t.useState(X()),[lt,it]=t.useState(X()),[dt,st]=t.useState(),[ct,pt]=t.useState(),ut=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),ft=e=>null!=e&&e.image?e.image:null,mt=e=>e?e.charAt(0).toUpperCase():"?",gt=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},xt=()=>{const e="asc"===ye?"desc":"asc";be(e);const t=[...Q].sort((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o});Z(t),$e(1),t.length>0&&te(t[0])},ht=t.useCallback(async()=>{if(console.log(W,"fetchAppointments -> appToken"),!W)return void(z&&T&&_(e=>e+1));console.log(M,"fetchAppointments -> doctorIdFromLogin");const e=M;oe(!0),re(null);try{const t={apiBaseUrl:s,hospitalId:F,doctorId:e,token:W},n=await p(J,at,lt,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(g),localStorage.removeItem(x),localStorage.removeItem(h))}catch(e){}return A(null),R(null),P(null),_(e=>e+1),void re("Session expired. Re-authenticating...")}if(n.err)return void re(String(n.err||"Failed to fetch appointments"));const o=n.data||n.appointments||n||[];Z(Array.isArray(o)?o:[]),Array.isArray(o)&&o.length>0?te(o[0]):te(null)}catch(e){console.error("Error fetching appointments:",e),re(e.message||"Failed to fetch appointments")}finally{oe(!1)}},[J,at,lt,xe,s,F,M,W,z,T]),yt=e=>{te(e),Ne(null)},bt=async()=>{if(ee&&W){Me(!0),Ne(null);try{var e;const t={apiBaseUrl:s,hospitalId:F,doctorId:M,doctorName:N||V,appToken:W};console.log(ee,"selectedAppointment"),console.log(t,"callConfig");const o=await u(ee,t);if(console.log(o.status,"response"),401===o.status||403===o.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(g),localStorage.removeItem(x),localStorage.removeItem(h))}catch(e){}return A(null),R(null),P(null),_(e=>e+1),void Ne("Session expired. Re-authenticating...")}if(o.err||null===(e=o.data)||void 0===e||!e.token)return void Ne(String(o.err||"Failed to initiate call"));const a=n.joinCallUrl||c,r=o.data.token?String(a||"").replace(/\/?$/,"")+o.data.token:"";console.log("joinCallUrl",r),ze(o.data.token),We(r||""),Se(!0),Ce(!1),Ie(!1),He({width:E,height:560}),je({x:Math.max(20,window.innerWidth-E-20),y:80})}catch(e){Ne(e.message||"Failed to initiate call")}finally{Me(!1)}}},Et=()=>{Se(!1),Ce(!1),Ie(!1),ze(null),We(null),Ne(null),ht()},vt=()=>{ke&&Ie(!1),Ce(!Fe)},wt=()=>{Fe&&Ce(!1),Ie(!ke)},St=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),Ue(!0);const t=e.currentTarget.getBoundingClientRect();Oe({x:e.clientX-t.left,y:e.clientY-t.top})},Ft=t.useCallback(e=>{if(!ke)if(Be){const t=e.clientX-Ye.x,n=e.clientY-Ye.y,o=window.innerWidth-Le.width,a=window.innerHeight-Le.height;je({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(_e){const t=e.clientX-Xe.x,n=e.clientY-Xe.y;let o=Xe.width,a=Xe.height,r=Xe.posX,l=Xe.posY;const i=300,d=250,s=window.innerWidth-40,c=window.innerHeight-100;if("bottom-right"===Ke)o=Math.min(Math.max(Xe.width+t,i),s),a=Math.min(Math.max(Xe.height+n,d),c),r+o>window.innerWidth&&(o=window.innerWidth-r),l+a>window.innerHeight&&(a=window.innerHeight-l);else if("bottom-left"===Ke){o=Math.min(Math.max(Xe.width-t,i),s),r=Math.max(0,Xe.posX+t),0===r&&(o=Xe.posX+Xe.width),a=Math.min(Math.max(Xe.height+n,d),c),l+a>window.innerHeight&&(a=window.innerHeight-l)}else if("top-right"===Ke){o=Math.min(Math.max(Xe.width+t,i),s),r+o>window.innerWidth&&(o=window.innerWidth-r);a=Math.min(Math.max(Xe.height-n,d),c),l=Math.max(0,Xe.posY+n),0===l&&(a=Xe.posY+Xe.height)}else if("top-left"===Ke){o=Math.min(Math.max(Xe.width-t,i),s),r=Math.max(0,Xe.posX+t),0===r&&(o=Xe.posX+Xe.width);a=Math.min(Math.max(Xe.height-n,d),c),l=Math.max(0,Xe.posY+n),0===l&&(a=Xe.posY+Xe.height)}He({width:o,height:a}),je({x:r,y:l})}},[Be,_e,Ye,Ke,Xe,Pe,Le,ke]),Ct=()=>{Ue(!1),qe(!1),Ve(null)},kt=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),qe(!0),Ve(e),Ge({x:t.clientX,y:t.clientY,width:Le.width,height:Le.height,posX:Pe.x,posY:Pe.y})};t.useEffect(()=>{if(!we||ke)return;const e=()=>{if(!(window.innerWidth<768)){const e=Fe?350:Le.width,t=Fe?60:Le.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),r=Math.min(t,o);a===Le.width&&r===Le.height||He({width:a,height:r});const l=window.innerWidth-a-20,i=window.innerHeight-r-20;je(e=>({x:Math.min(e.x,l),y:Math.min(e.y,i)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[we,Fe,ke,Le]),t.useEffect(()=>{if(!(z&&T&&(!W||O>0)))return;let e=!1;return L(!0),B(null),(async(e,t,n,o)=>{const a=e.replace(/\/$/,""),r="".concat(a,"/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(t)),l={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:r,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(r,l).then(e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then(e=>{var t;return console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!(null==e||null===(t=e.data)||void 0===t||!t.access_token)}),e}):e.json().then(t=>{var n;const o=(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:o,status:e.status}}).catch(()=>({err:"Something went wrong!",status:e.status})))).catch(e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"}))})(s,F,z,T).then(t=>{if(e)return;const n=function(e){var t,n,o,a,r,l;return!e||e.err?null:null!==(t=null!==(n=null!==(o=null!==(a=null===(r=e.data)||void 0===r?void 0:r.access_token)&&void 0!==a?a:null===(l=e.data)||void 0===l?void 0:l.token)&&void 0!==o?o:e.token)&&void 0!==n?n:e.accessToken)&&void 0!==t?t:null}(t);if(400===t.status)return B(t.err||"Invalid request. Redirecting to home..."),L(!1),void Y(!0);if(t.err||!n){B(String(t.err||"Failed to get token")),A(null),R(null),P(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(g),localStorage.removeItem(x),localStorage.removeItem(h))}catch(e){}}else{const e=function(e){var t,n;if(null==e||!e.data)return null;const o=null!==(t=null!==(n=e.data.doctor_id)&&void 0!==n?n:e.data.doctorId)&&void 0!==t?t:null;return console.log(o,"extractDoctorIdFromLoginResponse -> id"),null!=o?String(o):null}(t);console.log(e,"extractDoctorIdFromLoginResponse -> doctorId");const o=function(e){var t,n,o;if(null==e||!e.data)return null;const a=null!==(t=null!==(n=null!==(o=e.data.name)&&void 0!==o?o:e.data.doctor_name)&&void 0!==n?n:e.data.userName)&&void 0!==t?t:null;return null!=a?String(a):null}(t);A(n),R(e),P(o),B(null),Y(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(g,n),e&&localStorage.setItem(x,e),o&&localStorage.setItem(h,o))}catch(e){}}}).catch(t=>{e||(B((null==t?void 0:t.message)||"Authentication failed. Please try again."),A(null))}).finally(()=>{e||L(!1)}),()=>{e=!0}},[s,F,z,T,O,W]),t.useEffect(()=>{$e(1),Ne(null)},[J,de,at,lt,Ee,xe]),t.useEffect(()=>{!j&&W&&ht()},[ht,W,j]),t.useEffect(()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{ie(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}},[]),t.useEffect(()=>{const e=e=>{!ue||e.target.closest("button")||e.target.closest('input[type="date"]')||fe(!1),me&&!e.target.closest("[data-appointment-type-picker]")&&ge(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[ue,me]);let It='"Nunito", serif';const Dt=H||!W&&(!z||!T);let zt;return zt=j&&z&&T?a.default.createElement("div",{className:v,[w]:"teleconsult-appointments",style:{fontFamily:It,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:v,[w]:"teleconsult-appointments",style:{fontFamily:It,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:le?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:le?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:le?"calc(100% - 90px)":"480px",maxWidth:le?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:Ee,onChange:e=>ve(e.target.value),style:{width:"100%",padding:le?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"12px":"13px",fontFamily:It,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),Ee&&a.default.createElement("button",{onClick:()=>ve(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),!1),a.default.createElement("div",{style:{padding:le?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:le?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:le?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:le?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:le?"flex-start":"center",marginBottom:le?"10px":"14px",flexDirection:le?"column":"row",gap:le?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:le?"100%":"auto"}},a.default.createElement("button",{onClick:()=>$("upcoming"),style:{background:"upcoming"===J?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"upcoming"===J?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"upcoming"===J?"white":"#555555",fontWeight:600,fontFamily:It,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>$("completed"),style:{background:"completed"===J?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"completed"===J?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"completed"===J?"white":"#555555",fontWeight:600,fontFamily:It,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>$("cancelled"),style:{background:"cancelled"===J?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"cancelled"===J?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"cancelled"===J?"white":"#555555",fontWeight:600,fontFamily:It,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:le?"flex-start":"flex-end",flexWrap:"wrap"}},a.default.createElement("button",{onClick:()=>{ue||(st(at),pt(lt),pe(de)),fe(!ue)},style:{padding:"8px 12px",fontFamily:It,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:le?"4px":"6px",cursor:"pointer",flex:"none",minWidth:le?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:le?"12":"14",height:le?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(de){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return le?"Custom":"".concat(at," to ").concat(lt)}})()),a.default.createElement("svg",{width:le?"8":"10",height:le?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),ue&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:le?"auto":0,left:le?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:le?"280px":"240px",width:le?"calc(100vw - 24px)":"auto",maxWidth:le?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===ce?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>a.default.createElement("button",{key:e,onClick:()=>{if(pe(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=X();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=G(e);break;case"currentWeek":const a=new Date(t),r=new Date(t),l=t.getDay(),i=0===l?-6:1-l;a.setDate(t.getDate()+i),r.setDate(a.getDate()+6),n=G(a),o=G(r);break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=G(d),o=G(s);break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),o="".concat(t.getFullYear(),"-12-31")}return{from:n,to:o}})(e);se(e),rt(t.from),it(t.to),st(t.from),pt(t.to),fe(!1)}else st(""),pt("")},style:{width:"100%",padding:"10px 12px",background:ce===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:It,cursor:"pointer",textAlign:"left",fontWeight:ce===e?600:400,color:ce===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{ce!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{ce!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),ce===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===ce&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:dt,onChange:e=>st(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:It,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:ct,onChange:e=>pt(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:It,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{pe(de),st(at),pt(lt),fe(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:It,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{dt&&ct&&(se("custom"),rt(dt),it(ct),fe(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:It,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:le?"column":"row",gap:le?"12px":"14px",flex:1,minHeight:0,overflow:le?"auto":"hidden"}},a.default.createElement("div",{style:{flex:le?"none":"1 1 65%",width:le?"100%":"auto",display:"flex",flexDirection:"column",minHeight:le?"400px":0,maxHeight:le?"none":"100%",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",flex:le?"none":1,minHeight:le?"auto":0,maxHeight:le?"none":"100%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:le?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:le?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:le?"10px":"11px",fontWeight:600,padding:le?"2px 7px":"3px 8px",borderRadius:"12px"}},ot))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:le?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:le?"8px":"12px",padding:le?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:le?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!le&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:xt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ye?"▲":"▼")),!le&&a.default.createElement("div",null,"Slot"),!le&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflowY:"auto",overflowX:"hidden",flex:1,minHeight:0,maxHeight:le?"none":"430px",WebkitOverflowScrolling:"touch"}},j?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Getting token...")):ne?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):ae?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},ae),a.default.createElement("button",{onClick:ht,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:It}},"Retry")):0===tt.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},Ee?'No appointments found for "'.concat(Ee,'"'):"No appointments found"),Ee&&a.default.createElement("button",{onClick:()=>ve(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:It}},"Clear Search")):tt.map(e=>a.default.createElement("div",{key:ut(e),role:"button",tabIndex:0,onClick:()=>yt(e),onKeyDown:t=>"Enter"===t.key&&yt(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:le?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:le?"8px":"12px",padding:le?"10px 12px":"12px 18px",background:ut(ee)===ut(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:le?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"8px":"10px"}},ft(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:le?"32px":"36px",height:le?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:le?"32px":"36px",height:le?"32px":"36px",borderRadius:"50%",background:gt(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:le?"14px":"16px"}},mt(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:le?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:le?"9px":"11px",color:"#888"}},e.email))),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:le?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:le?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!ne&&!ae&&tt.length>0&&a.default.createElement("div",{style:{padding:le?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:le?"wrap":"nowrap",gap:le?"10px":"0"}},a.default.createElement("div",{style:{fontSize:le?"11px":"12px",color:"#666"}},"Showing page ",Je," of ",nt," (",ot," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>$e(e=>Math.max(1,e-1)),disabled:1===Je,style:{padding:le?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Je?"#F5F5F5":"#FFFFFF",color:1===Je?"#999":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:It,fontWeight:600,cursor:1===Je?"not-allowed":"pointer",opacity:1===Je?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,nt))].map((e,t)=>{let n;return n=nt<=5||Je<=3?t+1:Je>=nt-2?nt-4+t:Je-2+t,a.default.createElement("button",{key:n,onClick:()=>$e(n),style:{padding:le?"6px 10px":"6px 12px",border:Je===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Je===n?"#4C4DDC":"#FFFFFF",color:Je===n?"#FFFFFF":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:It,fontWeight:600,cursor:"pointer",minWidth:le?"32px":"36px"}},n)})),a.default.createElement("button",{onClick:()=>$e(e=>Math.min(nt,e+1)),disabled:Je===nt,style:{padding:le?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Je===nt?"#F5F5F5":"#FFFFFF",color:Je===nt?"#999":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:It,fontWeight:600,cursor:Je===nt?"not-allowed":"pointer",opacity:Je===nt?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:le?"none":"1 1 35%",width:le?"100%":"auto",display:ee||!le?"flex":"none",flexDirection:"column",minHeight:le?"auto":0}},a.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",flex:le?"none":1,minHeight:le?"auto":0}},ee?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:le?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:le?"14px":"16px",fontWeight:"700"}},ee.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:le?"11px":"13px"}},ee.patientId||ee.mrn||"N/A")),a.default.createElement("div",null,ft(ee)?a.default.createElement("img",{style:{width:le?"36px":"44px",height:le?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:ee.image,alt:ee.patientName}):a.default.createElement("div",{style:{width:le?"36px":"44px",height:le?"36px":"44px",borderRadius:"50%",background:gt(ee.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:le?"16px":"20px"}},mt(ee.patientName)))),a.default.createElement("div",{style:{padding:le?"12px 14px":"14px 18px",gap:le?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.specialisation)||(null==ee?void 0:ee.speciality)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.type)||(null==ee?void 0:ee.appointmentType)||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.date)||(null==ee?void 0:ee.appointmentDate)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.time)||(null==ee?void 0:ee.appointmentTime)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.doctor)||(null==ee?void 0:ee.doctorName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},(null==ee?void 0:ee.hospital)||(null==ee?void 0:ee.hospitalName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:le?"11px":"12px",lineHeight:"1.4"}},(null==ee?void 0:ee.reason)||(null==ee?void 0:ee.reasonForAppointment)||"No reason provided"))),("upcoming"===J||"completed"===J&&(e=>{const t=(null==e?void 0:e.date)||(null==e?void 0:e.appointmentDate),n=(null==e?void 0:e.time)||(null==e?void 0:e.appointmentTime);if(!t||!n)return!1;try{const e=String(n).trim().match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);let o,a;if(e){o=parseInt(e[1],10),a=parseInt(e[2],10);const t=e[3].toUpperCase();"AM"===t&&12===o&&(o=0),"PM"===t&&12!==o&&(o+=12)}else{const e=String(n).trim().split(":");o=parseInt(e[0],10),a=parseInt(e[1],10)}if(isNaN(o)||isNaN(a))return!1;const r=new Date("".concat(t," ").concat(String(o).padStart(2,"0"),":").concat(String(a).padStart(2,"0"),":00"));if(isNaN(r.getTime()))return!1;const l=new Date(r.getTime()+72e5);return new Date<=l}catch(e){return!1}})(ee))&&a.default.createElement("div",{style:{display:"flex",flexDirection:le?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:Ae?void 0:bt,disabled:Ae,style:{flex:1,background:Ae?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:le?"10px 8px":"8px 6px",fontFamily:It,fontWeight:600,fontSize:le?"11px":"12px",cursor:Ae?"not-allowed":"pointer"}},Ae?"Connecting...":"Join Call >")),("upcoming"===J||"completed"===J)&&Re&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",Re))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),we&&a.default.createElement("div",{style:{position:"fixed",left:ke?"0":le?"10px":"".concat(Pe.x,"px"),top:ke?"0":le?"70px":"".concat(Pe.y,"px"),right:ke?"0":le?"10px":"auto",bottom:ke?"0":"auto",width:ke?"100vw":le?"calc(100vw - 20px)":Fe?"350px":"".concat(Le.width,"px"),height:ke?"100vh":Fe?"auto":le?"300px":"".concat(Le.height,"px"),background:"#FFFFFF",borderRadius:ke?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e5,overflow:"hidden",display:"flex",flexDirection:"column",transition:Be||_e?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:le||ke?void 0:St,onPointerMove:le||ke?void 0:Ft,onPointerUp:le||ke?void 0:Ct,onPointerCancel:le||ke?void 0:Ct,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:le?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:le||ke?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:le?"6px":"8px",height:le?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:le?"11px":"13px",fontWeight:600,fontFamily:It,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==ee?void 0:ee.patientName)||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:le?"4px":"6px",alignItems:"center",flexShrink:0}},a.default.createElement("button",{onClick:vt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Fe?"Restore":"Minimize"},Fe?a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:wt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:ke?"Exit Fullscreen":"Fullscreen"},ke?a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:Et,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",fontWeight:"bold",fontSize:le?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative",display:Fe?"none":"flex",flexDirection:"column"}},a.default.createElement("iframe",{src:(()=>{if(!De)return"";const e=String(q||"");return"".concat(e).concat(De)})(),style:{width:"100%",height:"100%",border:"none",flex:1},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!le&&!ke&&!Fe&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>kt("top-left",e),onPointerMove:Ft,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>kt("top-right",e),onPointerMove:Ft,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>kt("bottom-left",e),onPointerMove:Ft,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>kt("bottom-right",e),onPointerMove:Ft,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",right:0,bottom:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),Dt&&a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:1e5,display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",background:"rgba(0,0,0,0.4)",boxSizing:"border-box"}},a.default.createElement("div",{style:{fontFamily:It,maxWidth:"400px",width:"100%",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",textAlign:"center"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Access Denied"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"You do not have permission to access Afiya Pro. Please contact administrator for assistance.")))),a.default.createElement(S,null,zt)},C=Object.freeze({ICD_ONLY:"ICD_ONLY",CLAUDE_ONLY:"CLAUDE_ONLY",AUTO:"AUTO"}),k="".concat(i,"/insurance/api/icd/suggest");async function I(e,t){var n;if(!e||!e.trim())throw new Error("Query cannot be empty");const o=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim(),mode:t})});if(!o.ok){var a;const e=await o.json().catch(()=>({})),t=(null==e?void 0:e.message)||(null==e||null===(a=e.error)||void 0===a?void 0:a.message)||"API error: ".concat(o.status," ").concat(o.statusText);throw new Error(t)}const r=await o.json(),l=null!==(n=null==r?void 0:r.data)&&void 0!==n?n:r;if(Array.isArray(null==l?void 0:l.matches))return{matches:l.matches,note:l.note||""};if(Array.isArray(l))return{matches:l,note:""};if(Array.isArray(null==l?void 0:l.results))return{matches:l.results.map(e=>({code:e.code,description:e.description||e.name||"",reason:e.reason||""})),note:l.note||""};throw new Error("Unexpected response format from ICD suggest API")}const D='"Nunito", sans-serif',z={primary:"#4C4DDC",primaryDark:"#3A3BBD",primaryLight:"#E8EEF4",teal:"#1CC3CE",tealLight:"#E0F8F9",success:"#16a34a",successLight:"#dcfce7",error:"#dc2626",errorLight:"#fee2e2",warn:"#d97706",warnLight:"#fef3c7",text:"#1a1a1a",muted:"#666",border:"#E5E5E5",bg:"#F5F5F7",white:"#FFFFFF"};function T(e){let{children:t,color:n=z.primary,bg:o=z.primaryLight}=e;return a.default.createElement("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 10px",borderRadius:"999px",fontSize:"12px",fontWeight:700,color:n,background:o,letterSpacing:"0.5px"}},t)}function W(){return a.default.createElement(a.default.Fragment,null,a.default.createElement("style",null,"@keyframes icd-spin{to{transform:rotate(360deg)}}"),a.default.createElement("div",{style:{width:20,height:20,border:"2.5px solid #d1d5db",borderTop:"2.5px solid ".concat(z.primary),borderRadius:"50%",animation:"icd-spin 0.8s linear infinite",flexShrink:0}}))}function A(e){let{text:t,label:n="Copy",copyKey:o,copiedKey:r,copy:l}=e;const i=r===o;return a.default.createElement("button",{onClick:()=>l(t,o),title:i?"Copied!":"Copy ".concat(n),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:11,fontWeight:600,fontFamily:D,border:"1px solid ".concat(i?z.success:z.border),borderRadius:5,background:i?z.successLight:z.white,color:i?z.success:z.muted,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"}},i?"✓ Copied":"⎘ ".concat(n))}function M(e){let{match:t,index:n,copy:o,copiedKey:r}=e;const l="card-".concat(n),i="".concat(t.code," — ").concat(t.description).concat(t.reason?"\nNote: ".concat(t.reason):"");return a.default.createElement("div",{style:{border:"1px solid ".concat(z.border),borderRadius:10,padding:"14px 16px",background:z.white,display:"flex",flexDirection:"column",gap:6,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"}},a.default.createElement("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"}},a.default.createElement(T,{color:z.primary,bg:z.primaryLight},t.code),a.default.createElement("span",{style:{fontSize:13,fontWeight:600,color:z.text,lineHeight:1.4}},t.description)),a.default.createElement(A,{text:i,label:t.code,copyKey:l,copiedKey:r,copy:o})),t.reason&&a.default.createElement("p",{style:{margin:0,fontSize:12,color:z.muted,lineHeight:1.5,paddingLeft:2}},"💡 ",t.reason))}function R(e){let{item:t,onClick:n}=e;return a.default.createElement("button",{onClick:()=>n(t.query),title:"Re-run: ".concat(t.query),style:{padding:"4px 10px",border:"1px solid ".concat(z.border),borderRadius:999,fontSize:11,fontFamily:D,color:z.muted,background:z.white,cursor:"pointer",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"border-color 0.15s"},onMouseEnter:e=>e.currentTarget.style.borderColor=z.primary,onMouseLeave:e=>e.currentTarget.style.borderColor=z.border},"🕐 ",t.query)}function N(e){let{mode:t,onChange:n}=e;const o=(e,o,r)=>a.default.createElement("button",{onClick:()=>n(e),style:{flex:1,padding:"6px 0",border:"none",borderRadius:6,fontSize:12,fontWeight:700,fontFamily:D,cursor:"pointer",transition:"all 0.15s",background:t===e?z.white:"transparent",color:t===e?z.primary:"rgba(255,255,255,0.7)",boxShadow:t===e?"0 1px 4px rgba(0,0,0,0.15)":"none",display:"flex",alignItems:"center",justifyContent:"center",gap:5}},a.default.createElement("span",null,r)," ",o);return a.default.createElement("div",{style:{display:"flex",background:"rgba(255,255,255,0.15)",borderRadius:8,padding:3,gap:2,marginTop:10}},o("nlm","Quick Lookup","🔎"),o("ai","AI Suggest","🤖"))}function P(e){let{panelRef:n,onClose:o,mode:r,onModeChange:l}=e;const[i,d]=t.useState(""),[s,c]=t.useState([]),[p,u]=t.useState(""),[f,m]=t.useState(""),g=t.useRef(null),x=t.useRef(null);t.useEffect(()=>{setTimeout(()=>{var e;return null===(e=x.current)||void 0===e?void 0:e.focus()},80)},[]);const h=t.useCallback(async e=>{if(e.length<2)return c([]),void u("");u("Searching…");try{const t=((await I(e,C.ICD_ONLY)).matches||[]).map(e=>[e.code,e.description]);c(t),u(0===t.length?"No matching codes found.":"Showing ".concat(t.length," result").concat(1!==t.length?"s":""))}catch(e){u(e.message||"Could not fetch results. Check your connection."),c([])}},[]);return a.default.createElement("div",{ref:n,style:{position:"fixed",bottom:28,right:28,zIndex:99999,width:"min(480px, calc(100vw - 32px))",maxHeight:"calc(100vh - 56px)",display:"flex",flexDirection:"column",background:z.white,borderRadius:16,boxShadow:"0 12px 48px rgba(0,0,0,0.18)",fontFamily:D,overflow:"hidden",animation:"icd-slide-in 0.2s ease"}},a.default.createElement("style",null,"@keyframes icd-slide-in{from{opacity:0;transform:translateY(20px) scale(0.97)}to{opacity:1;transform:translateY(0) scale(1)}}"),a.default.createElement("div",{style:{background:"linear-gradient(135deg, ".concat(z.primary," 0%, ").concat(z.teal," 100%)"),padding:"14px 18px",flexShrink:0}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},a.default.createElement("span",{style:{fontSize:22}},"🩺"),a.default.createElement("div",null,a.default.createElement("div",{style:{color:z.white,fontWeight:700,fontSize:15,lineHeight:1.2}},"ICD-10 Coding Assistant"),a.default.createElement("div",{style:{color:"rgba(255,255,255,0.75)",fontSize:11}},"Quick ICD-10 lookup"))),a.default.createElement("button",{onClick:o,style:{background:"rgba(255,255,255,0.2)",border:"1px solid rgba(255,255,255,0.3)",borderRadius:8,color:z.white,cursor:"pointer",fontSize:18,fontWeight:"bold",width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center"}},"×")),a.default.createElement(N,{mode:r,onChange:l})),a.default.createElement("div",{style:{flex:1,overflowY:"auto",padding:"16px 18px",display:"flex",flexDirection:"column",gap:10}},a.default.createElement("input",{ref:x,type:"text",value:i,onChange:e=>{const t=e.target.value;d(t),clearTimeout(g.current),g.current=setTimeout(()=>h(t.trim()),300)},placeholder:"Type a diagnosis, e.g. diabetes, hypertension…",style:{width:"100%",padding:"10px 14px",fontSize:14,fontFamily:D,border:"1.5px solid ".concat(z.border),borderRadius:8,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"},onFocus:e=>e.target.style.borderColor=z.primary,onBlur:e=>e.target.style.borderColor=z.border}),p&&a.default.createElement("p",{style:{margin:0,fontSize:12,color:z.muted}},p),a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},s.map(e=>{let[t,n]=e;return a.default.createElement("div",{key:t,onClick:()=>(e=>{navigator.clipboard.writeText(e).then(()=>{m(e),setTimeout(()=>m(""),2e3)})})(t),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 14px",border:"1px solid ".concat(z.border),borderRadius:8,cursor:"pointer",background:z.white,transition:"background 0.1s"},onMouseEnter:e=>e.currentTarget.style.background=z.bg,onMouseLeave:e=>e.currentTarget.style.background=z.white},a.default.createElement("span",{style:{fontFamily:"monospace",fontSize:12,background:z.primaryLight,color:z.primary,padding:"3px 8px",borderRadius:6,whiteSpace:"nowrap",fontWeight:700}},t),a.default.createElement("span",{style:{fontSize:13,flex:1,color:z.text}},n),a.default.createElement("span",{style:{fontSize:11,color:f===t?z.success:z.muted,fontWeight:f===t?700:400}},f===t?"✓ copied":"copy"))}))),a.default.createElement("div",{style:{flexShrink:0,padding:"10px 18px",borderTop:"1px solid ".concat(z.border),background:z.bg,fontSize:11,color:"#aaa",textAlign:"center"}},"⚕️ For reference only. Always verify codes with a certified medical coder."))}function j(e){let{onOpen:t}=e;return a.default.createElement("button",{onClick:t,title:"ICD-10 Coding Assistant",style:{position:"fixed",bottom:28,right:28,zIndex:99998,display:"flex",alignItems:"center",gap:8,padding:"10px 18px",borderRadius:999,border:"none",background:"linear-gradient(135deg, ".concat(z.primary," 0%, ").concat(z.teal," 100%)"),color:z.white,fontFamily:D,fontWeight:700,fontSize:13,cursor:"pointer",boxShadow:"0 4px 16px rgba(76,77,220,0.35)",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.transform="translateY(-2px)",e.currentTarget.style.boxShadow="0 8px 24px rgba(76,77,220,0.4)"},onMouseLeave:e=>{e.currentTarget.style.transform="translateY(0)",e.currentTarget.style.boxShadow="0 4px 16px rgba(76,77,220,0.35)"}},a.default.createElement("span",{style:{fontSize:18}},"🩺"),"ICD-10 Assistant")}function L(e){var t;let{panelRef:n,textareaRef:o,query:r,loading:l,result:i,error:d,history:s,copy:c,copiedKey:p,onQueryChange:u,onKeyDown:f,onSubmit:m,onClear:g,onClose:x,onHistoryClick:h,mode:y,onModeChange:b}=e;const E=(null==i||null===(t=i.matches)||void 0===t?void 0:t.map(e=>"".concat(e.code," — ").concat(e.description)).join("\n"))||"";return a.default.createElement("div",{style:{position:"fixed",bottom:28,right:28,zIndex:99999,width:"min(480px, calc(100vw - 32px))",maxHeight:"calc(100vh - 56px)",display:"flex",flexDirection:"column",background:z.white,borderRadius:16,boxShadow:"0 12px 48px rgba(0,0,0,0.18)",fontFamily:D,overflow:"hidden",animation:"icd-slide-in 0.2s ease"},ref:n},a.default.createElement("style",null,"\n @keyframes icd-slide-in {\n from { opacity: 0; transform: translateY(20px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n "),a.default.createElement("div",{style:{background:"linear-gradient(135deg, ".concat(z.primary," 0%, ").concat(z.teal," 100%)"),padding:"14px 18px",flexShrink:0}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},a.default.createElement("span",{style:{fontSize:22}},"🩺"),a.default.createElement("div",null,a.default.createElement("div",{style:{color:z.white,fontWeight:700,fontSize:15,lineHeight:1.2}},"ICD-10 Coding Assistant"),a.default.createElement("div",{style:{color:"rgba(255,255,255,0.75)",fontSize:11}},"AI-powered · Medical coding helper"))),a.default.createElement("button",{onClick:x,style:{background:"rgba(255,255,255,0.2)",border:"1px solid rgba(255,255,255,0.3)",borderRadius:8,color:z.white,cursor:"pointer",fontSize:18,fontWeight:"bold",width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},"×")),a.default.createElement(N,{mode:y,onChange:b})),a.default.createElement("div",{style:{overflowY:"auto",flex:1,padding:"18px 18px 0",display:"flex",flexDirection:"column",gap:14}},a.default.createElement("p",{style:{margin:0,fontSize:13,color:z.muted,lineHeight:1.6}},"Describe a diagnosis, condition, or procedure in plain language and get relevant ICD-10 code suggestions for insurance and billing."),a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},a.default.createElement("label",{style:{fontSize:12,fontWeight:600,color:z.text},htmlFor:"icd10-query"},"Diagnosis / Condition / Procedure"),a.default.createElement("textarea",{id:"icd10-query",ref:o,value:r,onChange:u,onKeyDown:f,placeholder:"e.g. Type 2 diabetes with hypertension, chest pain on exertion, rotator cuff repair…",rows:3,style:{width:"100%",padding:"10px 12px",border:"1.5px solid ".concat(z.border),borderRadius:8,fontSize:13,fontFamily:D,color:z.text,resize:"vertical",outline:"none",boxSizing:"border-box",lineHeight:1.5,transition:"border-color 0.15s"},onFocus:e=>e.target.style.borderColor=z.primary,onBlur:e=>e.target.style.borderColor=z.border}),a.default.createElement("div",{style:{fontSize:11,color:"#aaa",textAlign:"right"}},"Press ",a.default.createElement("kbd",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3,fontFamily:"monospace"}},"⌘ Enter")," to submit")),a.default.createElement("div",{style:{display:"flex",gap:8}},a.default.createElement("button",{onClick:m,disabled:!r.trim()||l,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",background:!r.trim()||l?"#d1d5db":"linear-gradient(135deg, ".concat(z.primary," 0%, ").concat(z.primaryDark," 100%)"),color:z.white,border:"none",borderRadius:8,fontSize:13,fontWeight:700,fontFamily:D,cursor:!r.trim()||l?"not-allowed":"pointer",transition:"background 0.15s"}},l?a.default.createElement(a.default.Fragment,null,a.default.createElement(W,null),"Searching codes…"):"🔍 Find ICD-10 Codes"),(r||i)&&a.default.createElement("button",{onClick:g,style:{padding:"10px 14px",background:z.bg,border:"1px solid ".concat(z.border),borderRadius:8,fontSize:13,fontWeight:600,fontFamily:D,color:z.muted,cursor:"pointer"}},"Clear")),d&&a.default.createElement("div",{style:{background:z.errorLight,border:"1px solid #fca5a5",borderRadius:8,padding:"10px 14px",fontSize:13,color:z.error,display:"flex",gap:8}},a.default.createElement("span",null,"⚠️"),a.default.createElement("span",null,d)),i&&a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:10}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},a.default.createElement("span",{style:{fontSize:13,fontWeight:700,color:z.text}},"Suggested Codes"),a.default.createElement(T,{color:z.teal,bg:z.tealLight},i.matches.length," match",1!==i.matches.length?"es":"")),i.matches.length>0&&a.default.createElement(A,{text:E,label:"All",copyKey:"copy-all",copiedKey:p,copy:c})),0===i.matches.length&&a.default.createElement("div",{style:{padding:"20px",textAlign:"center",color:z.muted,fontSize:13,background:z.bg,borderRadius:10}},"No matching ICD-10 codes found."),i.matches.map((e,t)=>a.default.createElement(M,{key:t,index:t,match:e,copy:c,copiedKey:p}))),s.length>0&&a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},a.default.createElement("span",{style:{fontSize:11,fontWeight:600,color:"#aaa",textTransform:"uppercase",letterSpacing:"0.5px"}},"Recent searches"),a.default.createElement("div",{style:{display:"flex",gap:6,flexWrap:"wrap"}},s.map((e,t)=>a.default.createElement(R,{key:t,item:e,onClick:h}))))),a.default.createElement("div",{style:{flexShrink:0,padding:"12px 18px",borderTop:"1px solid ".concat(z.border),background:z.bg,fontSize:11,color:"#aaa",lineHeight:1.5,textAlign:"center"}},"⚕️ For reference only. Always verify codes with a certified medical coder. Not a substitute for clinical judgment or official coding guidelines."))}function H(){const[e,n]=t.useState(!1),[o,r]=t.useState("nlm"),[l,i]=t.useState(""),[d,s]=t.useState(!1),[c,p]=t.useState(null),[u,f]=t.useState(null),[m,g]=t.useState([]),x=t.useRef(null),h=t.useRef(null),{copy:y,copiedKey:b}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1800;const[n,o]=t.useState(null),a=t.useCallback(function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";if(navigator.clipboard)navigator.clipboard.writeText(t).then(()=>{o(n),setTimeout(()=>o(null),e)});else{const a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),o(n),setTimeout(()=>o(null),e)}},[e]);return{copy:a,copiedKey:n}}();t.useEffect(()=>{e&&x.current&&setTimeout(()=>{var e;return null===(e=x.current)||void 0===e?void 0:e.focus()},80)},[e]),t.useEffect(()=>{if(!e)return;const t=e=>{h.current&&!h.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[e]);const E=t.useCallback(async()=>{if(l.trim()&&!d){s(!0),f(null),p(null);try{const e=await I(l.trim(),C.CLAUDE_ONLY);p(e),g(t=>{const n=t.filter(e=>e.query.toLowerCase()!==l.trim().toLowerCase());return[{query:l.trim(),matches:e.matches},...n].slice(0,3)})}catch(e){f(e.message||"Something went wrong. Please try again.")}finally{s(!1)}}},[l,d]),v=t.useCallback(e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),E())},[E]),w=t.useCallback(()=>{var e;i(""),p(null),f(null),null===(e=x.current)||void 0===e||e.focus()},[]),S=t.useCallback(e=>{var t;i(e),p(null),f(null),null===(t=x.current)||void 0===t||t.focus()},[]),F=t.useCallback(e=>i(e.target.value),[]);return a.default.createElement(a.default.Fragment,null,!e&&a.default.createElement(j,{onOpen:()=>n(!0)}),e&&"nlm"===o&&a.default.createElement(P,{panelRef:h,onClose:()=>n(!1),mode:o,onModeChange:r}),e&&"ai"===o&&a.default.createElement(L,{panelRef:h,textareaRef:x,query:l,loading:d,result:c,error:u,history:m,copy:y,copiedKey:b,onQueryChange:F,onKeyDown:v,onSubmit:E,onClear:w,onClose:()=>n(!1),onHistoryClick:S,mode:o,onModeChange:r}))}let B=null;const U={showWidget:(e,t)=>{B||(B=document.createElement("div"),document.body.appendChild(B));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(F,{config:e}),e.showIcdAssistant&&a.default.createElement(H,null));r.default.render(a.default.createElement(n,null),B)},closePopup:()=>{B&&(r.default.unmountComponentAtNode(B),B=null)}};window.BookingSDK=U,e.AppointmentPage=F,e.ICD10Assistant=H,e.PIH_APPOINTMENT_WIDGET_CLASS=v,e.default=U,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,(function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),r=o(n);const l="https://afiyaapiqa.powermindinc.com",i="/appointment/V1/consultant/all-appointments",d="/notification/V1/consultation/online/initiate",s="https://ittisalqa.powermindinc.com/call?token=",c=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS"),"UPCOMING"===a&&(a="UPCOMING,RESCHEDULED");const r=o.apiBaseUrl,l=o.hospitalId,d=o.doctorId,s=o.token||"",c={hospitalId:l,doctorId:d,fromDate:t,toDate:n,statuses:a,appointmentType:"ONLINE"},p=`${r}${i}`,u=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=new URL(e);return o.search=new URLSearchParams(t).toString(),fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`${n}`}}).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e?.message||String(e)||"Network error"})))}(p,c,"PIH-Appointment-Widget",s);return u},p=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};console.log("initiateConsultation -> config",t);const n=`${t.apiBaseUrl.replace(/\/$/,"")}${d}`,o=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach((e=>{a.searchParams.append(e,n[e])}));const r={"Content-Type":"application/json"};o&&(r.Authorization=o);const l={method:"POST",headers:r,body:JSON.stringify(t)};return fetch(a.toString(),l).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e.message||"Network error"})))}(n,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId,doctorId:String(t.doctorId),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},o)};const u="pih_appointment_idToken",f="pih_appointment_email",m="pih_appointment_appToken",g="pih_appointment_doctorId",x="pih_appointment_userName",h="pih_appointment_apiBaseUrl",y="pih_appointment_hospitalId",b=720,E="pih-appointment-widget",w="data-pih-widget";class S extends t.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{className:E,[w]:"teleconsult-appointments",style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const F=e=>{let{config:n={}}=e;const[o,r]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch{return null}})),[i,d]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch{return null}})),F=n.apiBaseUrl||o||l,v=n.hospitalId||i,[C,A]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(u):null}catch{return null}})),[k,I]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch{return null}})),D=n.idToken||n.token||C,z=n.email||k;t.useEffect((()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){if(localStorage.getItem(u)!==e){const e=!!localStorage.getItem(m);T(null),W(null),B(null),e&&K((e=>e+1)),localStorage.removeItem(m),localStorage.removeItem(g),localStorage.removeItem(x)}localStorage.setItem(u,e),A(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(f,n.email),I(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(h,n.apiBaseUrl.trim()),r(n.apiBaseUrl.trim())),null!=n.hospitalId&&String(n.hospitalId).trim()&&(localStorage.setItem(y,String(n.hospitalId).trim()),d(String(n.hospitalId).trim()))}catch(e){}}),[n.idToken,n.token,n.email,n.apiBaseUrl,n.hospitalId]);const[M,T]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch{return null}})),[R,W]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch{return null}})),[N,B]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch{return null}})),[H,P]=t.useState((()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(m),t=localStorage.getItem(u),n=localStorage.getItem(f);return!e&&!(!t||!n)}catch{return!1}})),[Q,L]=t.useState(null),[U,j]=t.useState(!1),[Y,K]=t.useState(0);t.useEffect((()=>{M&&H&&P(!1)}),[M,H]),t.useEffect((()=>{M||(D&&z?(j(!1),L((e=>"Sign in required. Redirecting to home..."===e?null:e))):(L("Sign in required. Redirecting to home..."),j(!0)))}),[M,D,z]),t.useEffect((()=>{if(!U)return;const e=n.homeUrl||"https://afiyaproqa.powermindinc.com/";if(!e||"undefined"==typeof window)return;const t=setTimeout((()=>{window.location.href=e}),2500);return()=>clearTimeout(t)}),[U,n.homeUrl]),t.useEffect((()=>{if(!H)return;const e=setTimeout((()=>{L("Request timed out. Please try again."),P(!1)}),3e4);return()=>clearTimeout(e)}),[H]);const q=n.joinCallUrl||s;M&&String(q||"").replace(/\/?$/,"/");const J=function(e){if(!e||"string"!=typeof e)return{};try{const t=e.split(".");if(3!==t.length)return{};const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch{return{}}}(D),O=N||J.name||J.sub||"User",G=()=>(new Date).toISOString().split("T")[0],X=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,[V,Z]=t.useState("upcoming"),[$,_]=t.useState([]),[ee,te]=t.useState(null),[ne,oe]=t.useState(!1),[ae,re]=t.useState(null),[le,ie]=t.useState(window.innerWidth<768),[de,se]=t.useState("today"),[ce,pe]=t.useState("today"),[ue,fe]=t.useState(!1),[me,ge]=t.useState(!1),[xe,he]=t.useState("all"),[ye,be]=t.useState("asc"),[Ee,we]=t.useState(""),[Se,Fe]=t.useState(!1),[ve,Ce]=t.useState(!1),[Ae,ke]=t.useState(!1),[Ie,De]=t.useState(null),[ze,Me]=t.useState(null),[Te,Re]=t.useState(!1),[We,Ne]=t.useState(null),[Be,He]=t.useState((()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-b-20:300),y:80}))),[Pe,Qe]=t.useState({width:b,height:560}),[Le,Ue]=t.useState(!1),[je,Ye]=t.useState({x:0,y:0}),[Ke,qe]=t.useState(!1),[Je,Oe]=t.useState(null),[Ge,Xe]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Ve,Ze]=t.useState(1),$e=$.filter((e=>{if(!Ee.trim())return!0;const t=Ee.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)})),_e=5*(Ve-1),et=_e+5,tt=$e.slice(_e,et),nt=Math.ceil($e.length/5),ot=$e.length,[at,rt]=t.useState(G()),[lt,it]=t.useState(G()),[dt,st]=t.useState(),[ct,pt]=t.useState(),ut=e=>e?.id||e?._id||e?.appointmentId||e?.patientId||JSON.stringify(e),ft=e=>e?.image?e.image:null,mt=e=>e?e.charAt(0).toUpperCase():"?",gt=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},xt=()=>{const e="asc"===ye?"desc":"asc";be(e);const t=[...$].sort(((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o}));_(t),Ze(1),t.length>0&&te(t[0])},ht=t.useCallback((async()=>{if(console.log(M,"fetchAppointments -> appToken"),!M)return void(D&&z&&K((e=>e+1)));console.log(R,"fetchAppointments -> doctorIdFromLogin");const e=R;oe(!0),re(null);try{const t={apiBaseUrl:F,hospitalId:v,doctorId:e,token:M},n=await c(V,at,lt,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(g),localStorage.removeItem(x))}catch(e){}return T(null),W(null),B(null),K((e=>e+1)),void re("Session expired. Re-authenticating...")}if(n.err)return void re(String(n.err||"Failed to fetch appointments"));const o=n.data||n.appointments||n||[];_(Array.isArray(o)?o:[]),Array.isArray(o)&&o.length>0?te(o[0]):te(null)}catch(e){console.error("Error fetching appointments:",e),re(e.message||"Failed to fetch appointments")}finally{oe(!1)}}),[V,at,lt,xe,F,v,R,M,D,z]),yt=e=>{te(e),Ne(null)},bt=async()=>{if(ee&&M){Re(!0),Ne(null);try{const e={apiBaseUrl:F,hospitalId:v,doctorId:R,doctorName:N||O,appToken:M};console.log(ee,"selectedAppointment"),console.log(e,"callConfig");const t=await p(ee,e);if(console.log(t.status,"response"),401===t.status||403===t.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(g),localStorage.removeItem(x))}catch(e){}return T(null),W(null),B(null),K((e=>e+1)),void Ne("Session expired. Re-authenticating...")}if(t.err||!t.data?.token)return void Ne(String(t.err||"Failed to initiate call"));const o=n.joinCallUrl||s,a=t.data.token?String(o||"").replace(/\/?$/,"")+t.data.token:"";console.log("joinCallUrl",a),De(t.data.token),Me(a||""),Fe(!0),Ce(!1),ke(!1),Qe({width:b,height:560}),He({x:Math.max(20,window.innerWidth-b-20),y:80})}catch(e){Ne(e.message||"Failed to initiate call")}finally{Re(!1)}}},Et=()=>{Fe(!1),Ce(!1),ke(!1),De(null),Me(null),Ne(null),ht()},wt=()=>{Ae&&ke(!1),Ce(!ve)},St=()=>{ve&&Ce(!1),ke(!Ae)},Ft=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),Ue(!0);const t=e.currentTarget.getBoundingClientRect();Ye({x:e.clientX-t.left,y:e.clientY-t.top})},vt=t.useCallback((e=>{if(!Ae)if(Le){const t=e.clientX-je.x,n=e.clientY-je.y,o=window.innerWidth-Pe.width,a=window.innerHeight-Pe.height;He({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Ke){const t=e.clientX-Ge.x,n=e.clientY-Ge.y;let o=Ge.width,a=Ge.height,r=Ge.posX,l=Ge.posY;const i=300,d=250,s=window.innerWidth-40,c=window.innerHeight-100;if("bottom-right"===Je)o=Math.min(Math.max(Ge.width+t,i),s),a=Math.min(Math.max(Ge.height+n,d),c),r+o>window.innerWidth&&(o=window.innerWidth-r),l+a>window.innerHeight&&(a=window.innerHeight-l);else if("bottom-left"===Je){o=Math.min(Math.max(Ge.width-t,i),s),r=Math.max(0,Ge.posX+t),0===r&&(o=Ge.posX+Ge.width),a=Math.min(Math.max(Ge.height+n,d),c),l+a>window.innerHeight&&(a=window.innerHeight-l)}else if("top-right"===Je){o=Math.min(Math.max(Ge.width+t,i),s),r+o>window.innerWidth&&(o=window.innerWidth-r);a=Math.min(Math.max(Ge.height-n,d),c),l=Math.max(0,Ge.posY+n),0===l&&(a=Ge.posY+Ge.height)}else if("top-left"===Je){o=Math.min(Math.max(Ge.width-t,i),s),r=Math.max(0,Ge.posX+t),0===r&&(o=Ge.posX+Ge.width);a=Math.min(Math.max(Ge.height-n,d),c),l=Math.max(0,Ge.posY+n),0===l&&(a=Ge.posY+Ge.height)}Qe({width:o,height:a}),He({x:r,y:l})}}),[Le,Ke,je,Je,Ge,Be,Pe,Ae]),Ct=()=>{Ue(!1),qe(!1),Oe(null)},At=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),qe(!0),Oe(e),Xe({x:t.clientX,y:t.clientY,width:Pe.width,height:Pe.height,posX:Be.x,posY:Be.y})};t.useEffect((()=>{if(!Se||Ae)return;const e=()=>{if(!(window.innerWidth<768)){const e=ve?350:Pe.width,t=ve?60:Pe.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),r=Math.min(t,o);a===Pe.width&&r===Pe.height||Qe({width:a,height:r});const l=window.innerWidth-a-20,i=window.innerHeight-r-20;He((e=>({x:Math.min(e.x,l),y:Math.min(e.y,i)})))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[Se,ve,Ae,Pe]),t.useEffect((()=>{if(!(D&&z&&(!M||Y>0)))return;let e=!1;return P(!0),L(null),(async(e,t,n,o)=>{const a=`${e.replace(/\/$/,"")}/um/user/V1/sso/login?hospitalId=${encodeURIComponent(t)}`,r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:a,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(a,r).then((e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then((e=>(console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!!e?.data?.access_token}),e))):e.json().then((t=>{const n=t?.resultInfo?.message||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:n,status:e.status}})).catch((()=>({err:"Something went wrong!",status:e.status})))))).catch((e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"})))})(F,v,D,z).then((t=>{if(e)return;const n=function(e){return!e||e.err?null:e.data?.access_token??e.data?.token??e.token??e.accessToken??null}(t);if(400===t.status)return L(t.err||"Invalid request. Redirecting to home..."),P(!1),void j(!0);if(t.err||!n){L(String(t.err||"Failed to get token")),T(null),W(null),B(null),K(0);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(g),localStorage.removeItem(x))}catch(e){}}else{const e=function(e){if(!e?.data)return null;const t=e.data.doctor_id??e.data.doctorId??null;return console.log(t,"extractDoctorIdFromLoginResponse -> id"),null!=t?String(t):null}(t);console.log(e,"extractDoctorIdFromLoginResponse -> doctorId");const o=function(e){if(!e?.data)return null;const t=e.data.name??e.data.doctor_name??e.data.userName??null;return null!=t?String(t):null}(t);T(n),W(e),B(o),L(null),j(!1),K(0);try{"undefined"!=typeof localStorage&&(localStorage.setItem(m,n),e&&localStorage.setItem(g,e),o&&localStorage.setItem(x,o))}catch(e){}}})).catch((t=>{e||(L(t?.message||"Authentication failed. Please try again."),T(null))})).finally((()=>{e||P(!1)})),()=>{e=!0}}),[F,v,D,z,Y,M]),t.useEffect((()=>{Ze(1),Ne(null)}),[V,de,at,lt,Ee,xe]),t.useEffect((()=>{!H&&M&&ht()}),[ht,M,H]),t.useEffect((()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{ie(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}}),[]),t.useEffect((()=>{const e=e=>{!ue||e.target.closest("button")||e.target.closest('input[type="date"]')||fe(!1),me&&!e.target.closest("[data-appointment-type-picker]")&&ge(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[ue,me]);let kt='"Nunito", serif';const It=Q||!M&&(!D||!z);let Dt;return Dt=H&&D&&z?a.default.createElement("div",{className:E,[w]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:E,[w]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:le?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:le?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:le?"calc(100% - 90px)":"480px",maxWidth:le?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:Ee,onChange:e=>we(e.target.value),style:{width:"100%",padding:le?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"12px":"13px",fontFamily:kt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),Ee&&a.default.createElement("button",{onClick:()=>we(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),!1),a.default.createElement("div",{style:{padding:le?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:le?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:le?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:le?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:le?"flex-start":"center",marginBottom:le?"10px":"14px",flexDirection:le?"column":"row",gap:le?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:le?"100%":"auto"}},a.default.createElement("button",{onClick:()=>Z("upcoming"),style:{background:"upcoming"===V?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"upcoming"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"upcoming"===V?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>Z("completed"),style:{background:"completed"===V?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"completed"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"completed"===V?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>Z("cancelled"),style:{background:"cancelled"===V?"#4C4DDC":"#FFFFFF",padding:le?"8px 10px":"9px 16px",border:"cancelled"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"10px":"13px",color:"cancelled"===V?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:le?"1 1 auto":"none",minWidth:le?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:le?"flex-start":"flex-end",flexWrap:"wrap"}},a.default.createElement("button",{onClick:()=>{ue||(st(at),pt(lt),pe(de)),fe(!ue)},style:{padding:"8px 12px",fontFamily:kt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:le?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:le?"4px":"6px",cursor:"pointer",flex:"none",minWidth:le?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:le?"12":"14",height:le?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(de){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return le?"Custom":`${at} to ${lt}`}})()),a.default.createElement("svg",{width:le?"8":"10",height:le?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),ue&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:le?"auto":0,left:le?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:le?"280px":"240px",width:le?"calc(100vw - 24px)":"auto",maxWidth:le?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===ce?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map((e=>a.default.createElement("button",{key:e,onClick:()=>{if(pe(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=G();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=X(e);break;case"currentWeek":const a=new Date(t),r=new Date(t),l=t.getDay(),i=0===l?-6:1-l;a.setDate(t.getDate()+i),r.setDate(a.getDate()+6),n=X(a),o=X(r);break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=X(d),o=X(s);break;case"currentYear":n=`${t.getFullYear()}-01-01`,o=`${t.getFullYear()}-12-31`}return{from:n,to:o}})(e);se(e),rt(t.from),it(t.to),st(t.from),pt(t.to),fe(!1)}else st(""),pt("")},style:{width:"100%",padding:"10px 12px",background:ce===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,cursor:"pointer",textAlign:"left",fontWeight:ce===e?600:400,color:ce===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{ce!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{ce!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),ce===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))))),"custom"===ce&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:dt,onChange:e=>st(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:ct,onChange:e=>pt(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{pe(de),st(at),pt(lt),fe(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{dt&&ct&&(se("custom"),rt(dt),it(ct),fe(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:le?"column":"row",gap:le?"12px":"14px",flex:1,minHeight:0,overflow:le?"auto":"hidden"}},a.default.createElement("div",{style:{flex:le?"none":"1 1 65%",width:le?"100%":"auto",display:"flex",flexDirection:"column",minHeight:le?"400px":0,maxHeight:le?"none":"100%",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",flex:le?"none":1,minHeight:le?"auto":0,maxHeight:le?"none":"100%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:le?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:le?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:le?"10px":"11px",fontWeight:600,padding:le?"2px 7px":"3px 8px",borderRadius:"12px"}},ot))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:le?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:le?"8px":"12px",padding:le?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:le?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!le&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:xt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ye?"▲":"▼")),!le&&a.default.createElement("div",null,"Slot"),!le&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflowY:"auto",overflowX:"hidden",flex:1,minHeight:0,maxHeight:le?"none":"430px",WebkitOverflowScrolling:"touch"}},H?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Getting token...")):ne?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):ae?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},ae),a.default.createElement("button",{onClick:ht,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:kt}},"Retry")):0===tt.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},Ee?`No appointments found for "${Ee}"`:"No appointments found"),Ee&&a.default.createElement("button",{onClick:()=>we(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:kt}},"Clear Search")):tt.map((e=>a.default.createElement("div",{key:ut(e),role:"button",tabIndex:0,onClick:()=>yt(e),onKeyDown:t=>"Enter"===t.key&&yt(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:le?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:le?"8px":"12px",padding:le?"10px 12px":"12px 18px",background:ut(ee)===ut(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:le?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"8px":"10px"}},ft(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:le?"32px":"36px",height:le?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:le?"32px":"36px",height:le?"32px":"36px",borderRadius:"50%",background:gt(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:le?"14px":"16px"}},mt(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:le?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:le?"9px":"11px",color:"#888"}},e.email))),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:le?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:le?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!le&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-"))))),!ne&&!ae&&tt.length>0&&a.default.createElement("div",{style:{padding:le?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:le?"wrap":"nowrap",gap:le?"10px":"0"}},a.default.createElement("div",{style:{fontSize:le?"11px":"12px",color:"#666"}},"Showing page ",Ve," of ",nt," (",ot," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Ze((e=>Math.max(1,e-1))),disabled:1===Ve,style:{padding:le?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Ve?"#F5F5F5":"#FFFFFF",color:1===Ve?"#999":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:1===Ve?"not-allowed":"pointer",opacity:1===Ve?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,nt))].map(((e,t)=>{let n;return n=nt<=5||Ve<=3?t+1:Ve>=nt-2?nt-4+t:Ve-2+t,a.default.createElement("button",{key:n,onClick:()=>Ze(n),style:{padding:le?"6px 10px":"6px 12px",border:Ve===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Ve===n?"#4C4DDC":"#FFFFFF",color:Ve===n?"#FFFFFF":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:"pointer",minWidth:le?"32px":"36px"}},n)}))),a.default.createElement("button",{onClick:()=>Ze((e=>Math.min(nt,e+1))),disabled:Ve===nt,style:{padding:le?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Ve===nt?"#F5F5F5":"#FFFFFF",color:Ve===nt?"#999":"#1a1a1a",fontSize:le?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:Ve===nt?"not-allowed":"pointer",opacity:Ve===nt?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:le?"none":"1 1 35%",width:le?"100%":"auto",display:ee||!le?"flex":"none",flexDirection:"column",minHeight:le?"auto":0}},a.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",flex:le?"none":1,minHeight:le?"auto":0}},ee?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:le?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:le?"14px":"16px",fontWeight:"700"}},ee.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:le?"11px":"13px"}},ee.patientId||ee.mrn||"N/A")),a.default.createElement("div",null,ft(ee)?a.default.createElement("img",{style:{width:le?"36px":"44px",height:le?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:ee.image,alt:ee.patientName}):a.default.createElement("div",{style:{width:le?"36px":"44px",height:le?"36px":"44px",borderRadius:"50%",background:gt(ee.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:le?"16px":"20px"}},mt(ee.patientName)))),a.default.createElement("div",{style:{padding:le?"12px 14px":"14px 18px",gap:le?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.specialisation||ee?.speciality||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.type||ee?.appointmentType||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.date||ee?.appointmentDate||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.time||ee?.appointmentTime||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.doctor||ee?.doctorName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:le?"12px":"13px"}},ee?.hospital||ee?.hospitalName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:le?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:le?"11px":"12px",lineHeight:"1.4"}},ee?.reason||ee?.reasonForAppointment||"No reason provided"))),("upcoming"===V||"completed"===V&&(e=>{const t=e?.date||e?.appointmentDate,n=e?.time||e?.appointmentTime;if(!t||!n)return!1;try{const e=String(n).trim().match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);let o,a;if(e){o=parseInt(e[1],10),a=parseInt(e[2],10);const t=e[3].toUpperCase();"AM"===t&&12===o&&(o=0),"PM"===t&&12!==o&&(o+=12)}else{const e=String(n).trim().split(":");o=parseInt(e[0],10),a=parseInt(e[1],10)}if(isNaN(o)||isNaN(a))return!1;const r=new Date(`${t} ${String(o).padStart(2,"0")}:${String(a).padStart(2,"0")}:00`);if(isNaN(r.getTime()))return!1;const l=new Date(r.getTime()+72e5);return new Date<=l}catch{return!1}})(ee))&&a.default.createElement("div",{style:{display:"flex",flexDirection:le?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:Te?void 0:bt,disabled:Te,style:{flex:1,background:Te?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:le?"10px 8px":"8px 6px",fontFamily:kt,fontWeight:600,fontSize:le?"11px":"12px",cursor:Te?"not-allowed":"pointer"}},Te?"Connecting...":"Join Call >")),("upcoming"===V||"completed"===V)&&We&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",We))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),Se&&a.default.createElement("div",{style:{position:"fixed",left:Ae?"0":le?"10px":`${Be.x}px`,top:Ae?"0":le?"70px":`${Be.y}px`,right:Ae?"0":le?"10px":"auto",bottom:Ae?"0":"auto",width:Ae?"100vw":le?"calc(100vw - 20px)":ve?"350px":`${Pe.width}px`,height:Ae?"100vh":ve?"auto":le?"300px":`${Pe.height}px`,background:"#FFFFFF",borderRadius:Ae?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e5,overflow:"hidden",display:"flex",flexDirection:"column",transition:Le||Ke?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:le||Ae?void 0:Ft,onPointerMove:le||Ae?void 0:vt,onPointerUp:le||Ae?void 0:Ct,onPointerCancel:le||Ae?void 0:Ct,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:le?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:le||Ae?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:le?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:le?"6px":"8px",height:le?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:le?"11px":"13px",fontWeight:600,fontFamily:kt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",ee?.patientName||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:le?"4px":"6px",alignItems:"center",flexShrink:0}},a.default.createElement("button",{onClick:wt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:ve?"Restore":"Minimize"},ve?a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:St,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Ae?"Exit Fullscreen":"Fullscreen"},Ae?a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:le?"14":"16",height:le?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:Et,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:le?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:le?"28px":"32px",height:le?"28px":"32px",fontWeight:"bold",fontSize:le?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative",display:ve?"none":"flex",flexDirection:"column"}},a.default.createElement("iframe",{src:(()=>{if(!Ie)return"";return`${String(q||"")}${Ie}`})(),style:{width:"100%",height:"100%",border:"none",flex:1},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!le&&!Ae&&!ve&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>At("top-left",e),onPointerMove:vt,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>At("top-right",e),onPointerMove:vt,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>At("bottom-left",e),onPointerMove:vt,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>At("bottom-right",e),onPointerMove:vt,onPointerUp:Ct,onPointerCancel:Ct,style:{position:"absolute",right:0,bottom:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),It&&a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:1e5,display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",background:"rgba(0,0,0,0.4)",boxSizing:"border-box"}},a.default.createElement("div",{style:{fontFamily:kt,maxWidth:"400px",width:"100%",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",textAlign:"center"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Access Denied"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"You do not have permission to access Afiya Pro. Please contact administrator for assistance.")))),a.default.createElement(S,null,Dt)},v=Object.freeze({ICD_ONLY:"ICD_ONLY",CLAUDE_ONLY:"CLAUDE_ONLY",AUTO:"AUTO"}),C=`${l}/insurance/api/icd/suggest`;async function A(e,t){if(!e||!e.trim())throw new Error("Query cannot be empty");const n=await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e.trim(),mode:t})});if(!n.ok){const e=await n.json().catch((()=>({}))),t=e?.message||e?.error?.message||`API error: ${n.status} ${n.statusText}`;throw new Error(t)}const o=await n.json(),a=o?.data??o;if(Array.isArray(a?.matches))return{matches:a.matches,note:a.note||""};if(Array.isArray(a))return{matches:a,note:""};if(Array.isArray(a?.results))return{matches:a.results.map((e=>({code:e.code,description:e.description||e.name||"",reason:e.reason||""}))),note:a.note||""};throw new Error("Unexpected response format from ICD suggest API")}const k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAADsQAAA7EB9YPtSQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAB67SURBVHic7X15nBXVmfbznqp7b680jbIJIsY9LuPCB4rL4BLXRGMUjMQ1Jpo4mm8SxlE0iR1j9HOJQTT5DN/kc7KZKJM4aDSMohglLhFRRhFQVEQFItI0fbe+t6rOM39U1b11t6a770onD7+ibtf6nvM+533fs5aggcC3T/w0tPpXACfA0WPgMAqtV8Lmr9Erv5Tjn7HrItfyE/aCYV8FwzgNhkyGUn1QshrAQmy05tdLrkpA6i2ADy4/IoT2Ue8DGA8ScAho7e4dDTj6DdjO2TL9hXU1leulo6+BUjfDVGEoAQwFKAUYXtYJr5F9l9xZS5kqCVVvATJob+8AMB4AQO8/AmBmfxCIP3PZEZNqJRKfO/JGOLwdZDgrR0A2AKDsXyt5qoGGIYDs98wnAF4GEFR6dq8BkGNgq5/XQh4umXoUNG/MVXxAJv8A8V+1kKdaaBgCAABE/q1oRpNZEmjM4JNTZlRfGP0dkJIlorflyIYtcEYuqr4s1UNDEIDsUlx7wmlI22eAZG6JA3KVAEDrK6oqzx8PnQzylIL35lslmybU1rlcd/Lu1ZSnmqg7Afj2aROxdtnL0OpxkGfC0ZLrAojCv/EFPn7Y6KoJpeUyEKrEu5GJARynExpdcPgO13zm2qrJU0XUnQBg+CcQOTyTubaTFwSiGAnCsPUFVRHnoZkGwEtKKj9jhRy3lkIAmiEIbuWa06dUQ6Zqoq4EiG+yT6OMOD0nk21mM7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CQ5bYLdEn1p0+vD/yUEn8D1aIYwK+QEZVAAAAAElFTkSuQmCC",I="💡",D="🕐",z="⚕️",M='"Nunito", sans-serif',T={primary:"#4C4DDC",primaryDark:"#3A3BBD",primaryLight:"#E8EEF4",teal:"#1CC3CE",tealLight:"#E0F8F9",success:"#16a34a",successLight:"#dcfce7",error:"#dc2626",errorLight:"#fee2e2",warn:"#d97706",warnLight:"#fef3c7",text:"#1a1a1a",muted:"#666",border:"#E5E5E5",bg:"#F5F5F7",white:"#FFFFFF"};function R(e){let{children:t,color:n=T.primary,bg:o=T.primaryLight}=e;return a.default.createElement("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 10px",borderRadius:"999px",fontSize:"12px",fontWeight:700,color:n,background:o,letterSpacing:"0.5px"}},t)}function W(){return a.default.createElement(a.default.Fragment,null,a.default.createElement("style",null,"@keyframes icd-spin{to{transform:rotate(360deg)}}"),a.default.createElement("div",{style:{width:20,height:20,border:"2.5px solid #d1d5db",borderTop:`2.5px solid ${T.primary}`,borderRadius:"50%",animation:"icd-spin 0.8s linear infinite",flexShrink:0}}))}function N(e){let{text:t,label:n="Copy",copyKey:o,copiedKey:r,copy:l}=e;const i=r===o;return a.default.createElement("button",{onClick:()=>l(t,o),title:i?"Copied!":`Copy ${n}`,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:11,fontWeight:600,fontFamily:M,border:`1px solid ${i?T.success:T.border}`,borderRadius:5,background:i?T.successLight:T.white,color:i?T.success:T.muted,cursor:"pointer",transition:"all 0.15s ease",whiteSpace:"nowrap"}},i?"✓ Copied":`⎘ ${n}`)}function B(e){let{match:t,index:n,copy:o,copiedKey:r}=e;const l=`card-${n}`,i=`${t.code} — ${t.description}${t.reason?`\nNote: ${t.reason}`:""}`;return a.default.createElement("div",{style:{border:`1px solid ${T.border}`,borderRadius:10,padding:"14px 16px",background:T.white,display:"flex",flexDirection:"column",gap:6,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"}},a.default.createElement("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"}},a.default.createElement(R,{color:T.primary,bg:T.primaryLight},t.code),a.default.createElement("span",{style:{fontSize:13,fontWeight:600,color:T.text,lineHeight:1.4}},t.description)),a.default.createElement(N,{text:i,label:t.code,copyKey:l,copiedKey:r,copy:o})),t.reason&&a.default.createElement("p",{style:{margin:0,fontSize:12,color:T.muted,lineHeight:1.5,paddingLeft:2}},I," ",t.reason))}function H(e){let{item:t,onClick:n}=e;return a.default.createElement("button",{onClick:()=>n(t.query),title:`Re-run: ${t.query}`,style:{padding:"4px 10px",border:`1px solid ${T.border}`,borderRadius:999,fontSize:11,fontFamily:M,color:T.muted,background:T.white,cursor:"pointer",maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"border-color 0.15s"},onMouseEnter:e=>e.currentTarget.style.borderColor=T.primary,onMouseLeave:e=>e.currentTarget.style.borderColor=T.border},D," ",t.query)}function P(e){let{mode:t,onChange:n}=e;const o=(e,o,r)=>a.default.createElement("button",{onClick:()=>n(e),style:{flex:1,padding:"6px 0",border:"none",borderRadius:6,fontSize:12,fontWeight:700,fontFamily:M,cursor:"pointer",transition:"all 0.15s",background:t===e?T.white:"transparent",color:t===e?T.primary:"rgba(255,255,255,0.7)",boxShadow:t===e?"0 1px 4px rgba(0,0,0,0.15)":"none",display:"flex",alignItems:"center",justifyContent:"center",gap:5}},a.default.createElement("span",null,r)," ",o);return a.default.createElement("div",{style:{display:"flex",background:"rgba(255,255,255,0.15)",borderRadius:8,padding:3,gap:2,marginTop:10}},o("nlm","Quick Lookup",""),o("ai","AI Suggest",""))}function Q(e){let{panelRef:n,onClose:o,mode:r,onModeChange:l}=e;const[i,d]=t.useState(""),[s,c]=t.useState([]),[p,u]=t.useState(""),[f,m]=t.useState(""),g=t.useRef(null),x=t.useRef(null);t.useEffect((()=>{setTimeout((()=>x.current?.focus()),80)}),[]);const h=t.useCallback((async e=>{if(e.length<2)return c([]),void u("");u("Searching…");try{const t=((await A(e,v.ICD_ONLY)).matches||[]).map((e=>[e.code,e.description]));c(t),u(0===t.length?"No matching codes found.":`Showing ${t.length} result${1!==t.length?"s":""}`)}catch(e){u(e.message||"Could not fetch results. Check your connection."),c([])}}),[]);return a.default.createElement("div",{ref:n,style:{position:"fixed",bottom:28,right:28,zIndex:99999,width:"min(480px, calc(100vw - 32px))",maxHeight:"calc(100vh - 56px)",display:"flex",flexDirection:"column",background:T.white,borderRadius:16,boxShadow:"0 12px 48px rgba(0,0,0,0.18)",fontFamily:M,overflow:"hidden",animation:"icd-slide-in 0.2s ease"}},a.default.createElement("style",null,"@keyframes icd-slide-in{from{opacity:0;transform:translateY(20px) scale(0.97)}to{opacity:1;transform:translateY(0) scale(1)}}"),a.default.createElement("div",{style:{background:`linear-gradient(135deg, ${T.primary} 0%, ${T.teal} 100%)`,padding:"14px 18px",flexShrink:0}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},a.default.createElement("img",{src:k,alt:"ICD-10",style:{width:32,height:32,objectFit:"contain"}}),a.default.createElement("div",null,a.default.createElement("div",{style:{color:T.white,fontWeight:700,fontSize:15,lineHeight:1.2}},"ICD-10 Coding Assistant"),a.default.createElement("div",{style:{color:"rgba(255,255,255,0.75)",fontSize:11}},"Quick ICD-10 lookup"))),a.default.createElement("button",{onClick:o,style:{background:"rgba(255,255,255,0.2)",border:"1px solid rgba(255,255,255,0.3)",borderRadius:8,color:T.white,cursor:"pointer",fontSize:18,fontWeight:"bold",width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center"}},"×")),a.default.createElement(P,{mode:r,onChange:l})),a.default.createElement("div",{style:{flex:1,overflowY:"auto",padding:"16px 18px",display:"flex",flexDirection:"column",gap:10}},a.default.createElement("input",{ref:x,type:"text",value:i,onChange:e=>{const t=e.target.value;d(t),clearTimeout(g.current),g.current=setTimeout((()=>h(t.trim())),300)},placeholder:"Type a diagnosis, e.g. diabetes, hypertension…",style:{width:"100%",padding:"10px 14px",fontSize:14,fontFamily:M,border:`1.5px solid ${T.border}`,borderRadius:8,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"},onFocus:e=>e.target.style.borderColor=T.primary,onBlur:e=>e.target.style.borderColor=T.border}),a.default.createElement("p",{style:{margin:0,fontSize:11,color:"#aaa",lineHeight:1.6,borderLeft:`3px solid ${T.border}`,paddingLeft:8}},a.default.createElement("strong",null,"Note:")," Use short, specific keywords for better results, or try"," ",a.default.createElement("button",{onClick:()=>l("ai"),style:{background:"none",border:"none",padding:0,color:T.primary,fontWeight:700,fontSize:11,cursor:"pointer",textDecoration:"underline",fontFamily:M}},"AI Suggest")," ","for broader symptom-based recommendations."),p&&s.length>0&&a.default.createElement("p",{style:{margin:0,fontSize:12,color:T.muted}},p),"No matching codes found."===p&&0===s.length&&a.default.createElement("div",{style:{background:T.warnLight,border:"1px solid #fcd34d",borderRadius:10,padding:"14px 16px",display:"flex",gap:10,alignItems:"flex-start"}},a.default.createElement("span",{style:{fontSize:18,flexShrink:0}},"🔍"),a.default.createElement("div",null,a.default.createElement("p",{style:{margin:"0 0 4px",fontSize:13,fontWeight:700,color:T.warn}},"No results found"),a.default.createElement("p",{style:{margin:0,fontSize:12,color:T.warn,lineHeight:1.6}},"We couldn't find a match. Try using more accurate keywords or switch to"," ",a.default.createElement("button",{onClick:()=>l("ai"),style:{background:"none",border:"none",padding:0,color:T.primary,fontWeight:700,fontSize:12,cursor:"pointer",textDecoration:"underline",fontFamily:M}},"AI Suggest")," ","for better results."))),a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},s.map((e=>{let[t,n]=e;return a.default.createElement("div",{key:t,onClick:()=>(e=>{navigator.clipboard.writeText(e).then((()=>{m(e),setTimeout((()=>m("")),2e3)}))})(t),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 14px",border:`1px solid ${T.border}`,borderRadius:8,cursor:"pointer",background:T.white,transition:"background 0.1s"},onMouseEnter:e=>e.currentTarget.style.background=T.bg,onMouseLeave:e=>e.currentTarget.style.background=T.white},a.default.createElement("span",{style:{fontFamily:"monospace",fontSize:12,background:T.primaryLight,color:T.primary,padding:"3px 8px",borderRadius:6,whiteSpace:"nowrap",fontWeight:700}},t),a.default.createElement("span",{style:{fontSize:13,flex:1,color:T.text}},n),a.default.createElement("span",{style:{fontSize:11,color:f===t?T.success:T.muted,fontWeight:f===t?700:400}},f===t?"✓ copied":"copy"))})))),a.default.createElement("div",{style:{flexShrink:0,padding:"10px 18px",borderTop:`1px solid ${T.border}`,background:T.bg,fontSize:11,color:"#aaa",textAlign:"center"}},z," For reference only. Always verify codes with a certified medical coder."))}function L(e){let{onOpen:t}=e;return a.default.createElement("button",{onClick:t,title:"ICD-10 Coding Assistant",style:{position:"fixed",bottom:28,right:28,zIndex:99998,display:"flex",alignItems:"center",gap:8,padding:"10px 18px",borderRadius:999,border:"none",background:`linear-gradient(135deg, ${T.primary} 0%, ${T.teal} 100%)`,color:T.white,fontFamily:M,fontWeight:700,fontSize:13,cursor:"pointer",boxShadow:"0 4px 16px rgba(76,77,220,0.35)",transition:"transform 0.15s ease, box-shadow 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.transform="translateY(-2px)",e.currentTarget.style.boxShadow="0 8px 24px rgba(76,77,220,0.4)"},onMouseLeave:e=>{e.currentTarget.style.transform="translateY(0)",e.currentTarget.style.boxShadow="0 4px 16px rgba(76,77,220,0.35)"}},a.default.createElement("img",{src:k,alt:"ICD-10",style:{width:22,height:22,objectFit:"contain"}}),"ICD-10 Assistant")}function U(e){let{panelRef:t,textareaRef:n,query:o,loading:r,result:l,error:i,history:d,copy:s,copiedKey:c,onQueryChange:p,onKeyDown:u,onSubmit:f,onClear:m,onClose:g,onHistoryClick:x,mode:h,onModeChange:y}=e;const b=l?.matches?.map((e=>`${e.code} — ${e.description}`)).join("\n")||"";return a.default.createElement("div",{style:{position:"fixed",bottom:28,right:28,zIndex:99999,width:"min(480px, calc(100vw - 32px))",maxHeight:"calc(100vh - 56px)",display:"flex",flexDirection:"column",background:T.white,borderRadius:16,boxShadow:"0 12px 48px rgba(0,0,0,0.18)",fontFamily:M,overflow:"hidden",animation:"icd-slide-in 0.2s ease"},ref:t},a.default.createElement("style",null,"\n @keyframes icd-slide-in {\n from { opacity: 0; transform: translateY(20px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n }\n "),a.default.createElement("div",{style:{background:`linear-gradient(135deg, ${T.primary} 0%, ${T.teal} 100%)`,padding:"14px 18px",flexShrink:0}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:10}},a.default.createElement("img",{src:k,alt:"ICD-10",style:{width:32,height:32,objectFit:"contain"}}),a.default.createElement("div",null,a.default.createElement("div",{style:{color:T.white,fontWeight:700,fontSize:15,lineHeight:1.2}},"ICD-10 Coding Assistant"),a.default.createElement("div",{style:{color:"rgba(255,255,255,0.75)",fontSize:11}},"AI-powered · Medical coding helper"))),a.default.createElement("button",{onClick:g,style:{background:"rgba(255,255,255,0.2)",border:"1px solid rgba(255,255,255,0.3)",borderRadius:8,color:T.white,cursor:"pointer",fontSize:18,fontWeight:"bold",width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},"×")),a.default.createElement(P,{mode:h,onChange:y})),a.default.createElement("div",{style:{overflowY:"auto",flex:1,padding:"18px 18px 0",display:"flex",flexDirection:"column",gap:14}},a.default.createElement("p",{style:{margin:0,fontSize:13,color:T.muted,lineHeight:1.6}},"Describe a diagnosis, condition, or procedure in plain language and get relevant ICD-10 code suggestions for insurance and billing."),a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},a.default.createElement("label",{style:{fontSize:12,fontWeight:600,color:T.text},htmlFor:"icd10-query"},"Diagnosis / Condition / Procedure"),a.default.createElement("textarea",{id:"icd10-query",ref:n,value:o,onChange:p,onKeyDown:u,placeholder:"e.g. Type 2 diabetes with hypertension, chest pain on exertion, rotator cuff repair…",rows:3,style:{width:"100%",padding:"10px 12px",border:`1.5px solid ${T.border}`,borderRadius:8,fontSize:13,fontFamily:M,color:T.text,resize:"vertical",outline:"none",boxSizing:"border-box",lineHeight:1.5,transition:"border-color 0.15s"},onFocus:e=>e.target.style.borderColor=T.primary,onBlur:e=>e.target.style.borderColor=T.border}),a.default.createElement("div",{style:{fontSize:11,color:"#aaa",textAlign:"right"}},"Press ",a.default.createElement("kbd",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3,fontFamily:"monospace"}},"Enter")," to submit · ",a.default.createElement("kbd",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3,fontFamily:"monospace"}},"Shift+Enter")," for new line")),a.default.createElement("div",{style:{display:"flex",gap:8}},a.default.createElement("button",{onClick:f,disabled:!o.trim()||r,style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"10px 16px",background:!o.trim()||r?"#d1d5db":`linear-gradient(135deg, ${T.primary} 0%, ${T.primaryDark} 100%)`,color:T.white,border:"none",borderRadius:8,fontSize:13,fontWeight:700,fontFamily:M,cursor:!o.trim()||r?"not-allowed":"pointer",transition:"background 0.15s"}},r?a.default.createElement(a.default.Fragment,null,a.default.createElement(W,null),"Searching codes…"):"Find ICD-10 Codes"),(o||l)&&a.default.createElement("button",{onClick:m,style:{padding:"10px 14px",background:T.bg,border:`1px solid ${T.border}`,borderRadius:8,fontSize:13,fontWeight:600,fontFamily:M,color:T.muted,cursor:"pointer"}},"Clear")),i&&a.default.createElement("div",{style:{background:T.errorLight,border:"1px solid #fca5a5",borderRadius:8,padding:"10px 14px",fontSize:13,color:T.error,display:"flex",gap:8}},a.default.createElement("span",null,"⚠️"),a.default.createElement("span",null,i)),l&&a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:10}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:8}},a.default.createElement("span",{style:{fontSize:13,fontWeight:700,color:T.text}},"Suggested Codes"),a.default.createElement(R,{color:T.teal,bg:T.tealLight},l.matches.length," match",1!==l.matches.length?"es":"")),l.matches.length>0&&a.default.createElement(N,{text:b,label:"All",copyKey:"copy-all",copiedKey:c,copy:s})),0===l.matches.length&&a.default.createElement("div",{style:{padding:"20px",textAlign:"center",color:T.muted,fontSize:13,background:T.bg,borderRadius:10}},"No matching ICD-10 codes found."),l.matches.map(((e,t)=>a.default.createElement(B,{key:t,index:t,match:e,copy:s,copiedKey:c})))),d.length>0&&a.default.createElement("div",{style:{display:"flex",flexDirection:"column",gap:6}},a.default.createElement("span",{style:{fontSize:11,fontWeight:600,color:"#aaa",textTransform:"uppercase",letterSpacing:"0.5px"}},"Recent searches"),a.default.createElement("div",{style:{display:"flex",gap:6,flexWrap:"wrap"}},d.map(((e,t)=>a.default.createElement(H,{key:t,item:e,onClick:x})))))),a.default.createElement("div",{style:{flexShrink:0,padding:"12px 18px",borderTop:`1px solid ${T.border}`,background:T.bg,fontSize:11,color:"#aaa",lineHeight:1.5,textAlign:"center"}},z," For reference only. Always verify codes with a certified medical coder. Not a substitute for clinical judgment or official coding guidelines."))}function j(){const[e,n]=t.useState(!1),[o,r]=t.useState("nlm"),[l,i]=t.useState(""),[d,s]=t.useState(!1),[c,p]=t.useState(null),[u,f]=t.useState(null),[m,g]=t.useState([]),x=t.useRef(null),h=t.useRef(null),{copy:y,copiedKey:b}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1800;const[n,o]=t.useState(null),a=t.useCallback((function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";if(navigator.clipboard)navigator.clipboard.writeText(t).then((()=>{o(n),setTimeout((()=>o(null)),e)}));else{const a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),o(n),setTimeout((()=>o(null)),e)}}),[e]);return{copy:a,copiedKey:n}}();t.useEffect((()=>{e&&x.current&&setTimeout((()=>x.current?.focus()),80)}),[e]),t.useEffect((()=>{if(!e)return;const t=e=>{h.current&&!h.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)}),[e]);const E=t.useCallback((async()=>{if(l.trim()&&!d){s(!0),f(null),p(null);try{const e=await A(l.trim(),v.CLAUDE_ONLY);p(e),g((t=>{const n=t.filter((e=>e.query.toLowerCase()!==l.trim().toLowerCase()));return[{query:l.trim(),matches:e.matches},...n].slice(0,3)}))}catch(e){f(e.message||"Something went wrong. Please try again.")}finally{s(!1)}}}),[l,d]),w=t.useCallback((e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),E())}),[E]),S=t.useCallback((()=>{i(""),p(null),f(null),x.current?.focus()}),[]),F=t.useCallback((e=>{i(e),p(null),f(null),x.current?.focus()}),[]),C=t.useCallback((e=>i(e.target.value)),[]);return a.default.createElement(a.default.Fragment,null,!e&&a.default.createElement(L,{onOpen:()=>n(!0)}),e&&"nlm"===o&&a.default.createElement(Q,{panelRef:h,onClose:()=>n(!1),mode:o,onModeChange:r}),e&&"ai"===o&&a.default.createElement(U,{panelRef:h,textareaRef:x,query:l,loading:d,result:c,error:u,history:m,copy:y,copiedKey:b,onQueryChange:C,onKeyDown:w,onSubmit:E,onClear:S,onClose:()=>n(!1),onHistoryClick:F,mode:o,onModeChange:r}))}let Y=null;const K={showWidget:(e,t)=>{Y||(Y=document.createElement("div"),document.body.appendChild(Y));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(F,{config:e}),e.showIcdAssistant&&a.default.createElement(j,null));r.default.render(a.default.createElement(n,null),Y)},closePopup:()=>{Y&&(r.default.unmountComponentAtNode(Y),Y=null)}};window.BookingSDK=K,e.AppointmentPage=F,e.ICD10Assistant=j,e.PIH_APPOINTMENT_WIDGET_CLASS=E,e.default=K,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.initiateConsultation = exports.getAppointmentsByStatus = exports.getAppointmentDetails = void 0;
|
|
7
7
|
var _httpService = require("./httpService");
|
|
8
8
|
var _apiConfig = require("../constants/apiConfig");
|
|
9
|
-
/**
|
|
10
|
-
* Fetch appointments by status
|
|
11
|
-
* @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
|
|
12
|
-
* @param {string} fromDate - Start date in YYYY-MM-DD format
|
|
13
|
-
* @param {string} toDate - End date in YYYY-MM-DD format
|
|
14
|
-
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
15
|
-
* @returns {Promise} Appointments data
|
|
9
|
+
/**
|
|
10
|
+
* Fetch appointments by status
|
|
11
|
+
* @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
|
|
12
|
+
* @param {string} fromDate - Start date in YYYY-MM-DD format
|
|
13
|
+
* @param {string} toDate - End date in YYYY-MM-DD format
|
|
14
|
+
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
15
|
+
* @returns {Promise} Appointments data
|
|
16
16
|
*/
|
|
17
17
|
const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
18
18
|
let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
@@ -39,25 +39,25 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
|
39
39
|
// params.appointmentType = String(type).toUpperCase();
|
|
40
40
|
// }
|
|
41
41
|
params.appointmentType = 'ONLINE';
|
|
42
|
-
const url =
|
|
42
|
+
const url = `${baseURL}${_apiConfig.API_PATHS.APPOINTMENTS}`;
|
|
43
43
|
|
|
44
44
|
// Return raw response (including status) so caller can detect 401 and re-login
|
|
45
45
|
const response = await (0, _httpService.getApi)(url, params, "PIH-Appointment-Widget", token);
|
|
46
46
|
return response;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* Fetch appointment details by ID
|
|
51
|
-
* @param {string|number} appointmentId - The appointment ID
|
|
52
|
-
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
53
|
-
* @returns {Promise} Appointment details
|
|
49
|
+
/**
|
|
50
|
+
* Fetch appointment details by ID
|
|
51
|
+
* @param {string|number} appointmentId - The appointment ID
|
|
52
|
+
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
53
|
+
* @returns {Promise} Appointment details
|
|
54
54
|
*/
|
|
55
55
|
exports.getAppointmentsByStatus = getAppointmentsByStatus;
|
|
56
56
|
const getAppointmentDetails = async function (appointmentId) {
|
|
57
57
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
58
58
|
try {
|
|
59
59
|
const baseURL = config.apiBaseUrl;
|
|
60
|
-
const url =
|
|
60
|
+
const url = `${baseURL}${_apiConfig.API_PATHS.APPOINTMENT_DETAILS}/${appointmentId}`;
|
|
61
61
|
const response = await (0, _httpService.getApi)(url, {}, "PIH-Appointment-Widget");
|
|
62
62
|
if (response.err) {
|
|
63
63
|
throw new Error(response.err);
|
|
@@ -69,18 +69,18 @@ const getAppointmentDetails = async function (appointmentId) {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
/**
|
|
73
|
-
* Initiate an online consultation — returns LiveKit room token + wss URL.
|
|
74
|
-
* @param {object} appointment - Selected appointment object
|
|
75
|
-
* @param {object} config - { apiBaseUrl, hospitalId, doctorId, doctorName, appToken }
|
|
76
|
-
* @returns {Promise<{ data: { token, url, roomName, participantName }, err?, status? }>}
|
|
72
|
+
/**
|
|
73
|
+
* Initiate an online consultation — returns LiveKit room token + wss URL.
|
|
74
|
+
* @param {object} appointment - Selected appointment object
|
|
75
|
+
* @param {object} config - { apiBaseUrl, hospitalId, doctorId, doctorName, appToken }
|
|
76
|
+
* @returns {Promise<{ data: { token, url, roomName, participantName }, err?, status? }>}
|
|
77
77
|
*/
|
|
78
78
|
exports.getAppointmentDetails = getAppointmentDetails;
|
|
79
79
|
const initiateConsultation = async function (appointment) {
|
|
80
80
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
81
81
|
console.log("initiateConsultation -> config", config);
|
|
82
82
|
const baseURL = config.apiBaseUrl.replace(/\/$/, "");
|
|
83
|
-
const url =
|
|
83
|
+
const url = `${baseURL}${_apiConfig.API_PATHS.INITIATE_CALL}`;
|
|
84
84
|
const appToken = config.appToken || "";
|
|
85
85
|
const body = {
|
|
86
86
|
patientId: String(appointment.patientId || ""),
|
|
@@ -14,16 +14,15 @@ const getApi = async function (url) {
|
|
|
14
14
|
method: "GET",
|
|
15
15
|
headers: {
|
|
16
16
|
"Content-Type": "application/json",
|
|
17
|
-
"Authorization":
|
|
17
|
+
"Authorization": `${token}`
|
|
18
18
|
// "X-CLIENT-APP": header,
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
return fetch(urlWithParams, options).then(async response => {
|
|
22
22
|
const data = await response.json().catch(() => ({}));
|
|
23
23
|
if (!response.ok) {
|
|
24
|
-
var _data$resultInfo;
|
|
25
24
|
return {
|
|
26
|
-
err:
|
|
25
|
+
err: data?.resultInfo?.message || "Something went wrong!",
|
|
27
26
|
status: response.status
|
|
28
27
|
};
|
|
29
28
|
}
|
|
@@ -31,7 +30,7 @@ const getApi = async function (url) {
|
|
|
31
30
|
}).catch(error => {
|
|
32
31
|
console.error("Fetch error:", error);
|
|
33
32
|
return {
|
|
34
|
-
err:
|
|
33
|
+
err: error?.message || String(error) || "Network error"
|
|
35
34
|
};
|
|
36
35
|
});
|
|
37
36
|
};
|
|
@@ -57,9 +56,8 @@ const postApi = async function (url) {
|
|
|
57
56
|
return fetch(urlWithParams.toString(), options).then(async response => {
|
|
58
57
|
const data = await response.json().catch(() => ({}));
|
|
59
58
|
if (!response.ok) {
|
|
60
|
-
var _data$resultInfo2;
|
|
61
59
|
return {
|
|
62
|
-
err:
|
|
60
|
+
err: data?.resultInfo?.message || "Something went wrong!",
|
|
63
61
|
status: response.status
|
|
64
62
|
};
|
|
65
63
|
}
|
|
@@ -72,18 +70,18 @@ const postApi = async function (url) {
|
|
|
72
70
|
});
|
|
73
71
|
};
|
|
74
72
|
|
|
75
|
-
/**
|
|
76
|
-
* SSO login: exchange idToken + email for app token.
|
|
77
|
-
* @param {string} apiBaseUrl - e.g. https://afiyaapiqa.powermindinc.com
|
|
78
|
-
* @param {string} hospitalId - e.g. dMtEGhak
|
|
79
|
-
* @param {string} idToken - JWT id token from auth provider
|
|
80
|
-
* @param {string} email - User email
|
|
81
|
-
* @returns {Promise<{ token?: string, err?: string, ... }>} - Response with token on success, or { err } on failure
|
|
73
|
+
/**
|
|
74
|
+
* SSO login: exchange idToken + email for app token.
|
|
75
|
+
* @param {string} apiBaseUrl - e.g. https://afiyaapiqa.powermindinc.com
|
|
76
|
+
* @param {string} hospitalId - e.g. dMtEGhak
|
|
77
|
+
* @param {string} idToken - JWT id token from auth provider
|
|
78
|
+
* @param {string} email - User email
|
|
79
|
+
* @returns {Promise<{ token?: string, err?: string, ... }>} - Response with token on success, or { err } on failure
|
|
82
80
|
*/
|
|
83
81
|
exports.postApi = postApi;
|
|
84
82
|
const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
|
|
85
83
|
const base = apiBaseUrl.replace(/\/$/, "");
|
|
86
|
-
const url =
|
|
84
|
+
const url = `${base}/um/user/V1/sso/login?hospitalId=${encodeURIComponent(hospitalId)}`;
|
|
87
85
|
const options = {
|
|
88
86
|
method: "POST",
|
|
89
87
|
headers: {
|
|
@@ -105,8 +103,7 @@ const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
|
|
|
105
103
|
console.log("[getTokenFromSso] response status", response.status, response.statusText);
|
|
106
104
|
if (!response.ok) {
|
|
107
105
|
return response.json().then(errorData => {
|
|
108
|
-
|
|
109
|
-
const errorMessage = (errorData === null || errorData === void 0 || (_errorData$resultInfo = errorData.resultInfo) === null || _errorData$resultInfo === void 0 ? void 0 : _errorData$resultInfo.message) || "SSO login failed";
|
|
106
|
+
const errorMessage = errorData?.resultInfo?.message || "SSO login failed";
|
|
110
107
|
console.log("[getTokenFromSso] error body", errorData);
|
|
111
108
|
return {
|
|
112
109
|
err: errorMessage,
|
|
@@ -118,11 +115,10 @@ const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
|
|
|
118
115
|
}));
|
|
119
116
|
}
|
|
120
117
|
return response.json().then(data => {
|
|
121
|
-
var _data$data;
|
|
122
118
|
console.log("[getTokenFromSso] success", {
|
|
123
119
|
hasData: !!data,
|
|
124
120
|
dataKeys: data ? Object.keys(data) : [],
|
|
125
|
-
hasAccessToken: !!
|
|
121
|
+
hasAccessToken: !!data?.data?.access_token
|
|
126
122
|
});
|
|
127
123
|
return data;
|
|
128
124
|
});
|