1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{44949:function(e,t,n){Promise.resolve().then(n.bind(n,49517))},49517:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return e3}});var r,a,s=n(57437),l=n(9442),o=n(29665);let i=[{element:"#your-notes-text-area",popover:{description:"Try editing the scratch notes we've provided. You can also dictate or transcribe a consult in real time!",position:"left",allowClose:!0,overlayClickAction:"close"}},{element:"#patient-details-container",popover:{description:"Add patient information (Optional) <br/><br/> <strong> This information never leaves your browser.</strong>",side:"top",align:"center"},allowClose:!0,overlayClickAction:"close"},{element:"#generate-button-action",popover:{description:"...Click <strong>Generate</strong> to watch MedNotes work it's magic.",side:"top",align:"center"},allowClose:!0,overlayClickAction:"close"},{element:"#document-appear-here",popover:{description:"Watch this space to see your documentation emerge ready for you to review and edit!",showButtons:[]},allowClose:!0,overlayClickAction:"close"}],d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=0,r=()=>{if(i.every(e=>!e.element||document.querySelector(e.element))){var a;let e=null===(a=document.querySelector("#generate-button-action"))||void 0===a?void 0:a.closest("button"),t=()=>{e&&(e.dataset.generated="true")};e&&e.addEventListener("click",t,{once:!0});let n=(0,o.v)({steps:i,allowClose:!0,stagePadding:15,stageRadius:8,onNextClick:(e,t)=>{if(l.nT.track(l.j7.NEXT_CLICKED,{step:t.element}),"#generate-button-action"===t.element&&e){let t=e.closest("button");!t||t.dataset.generated||t.disabled||(t.dataset.generated="true",t.click())}n.moveNext(),localStorage.setItem("tourShownAt",new Date().toISOString())},onPrevClick:(e,t)=>{l.nT.track(l.j7.PREVIOUS_CLICKED,{step:t.element}),n.movePrevious()},onCloseClick:()=>{l.nT.track(l.j7.CLOSE_CLICKED),localStorage.setItem("tourShownAt",new Date().toISOString()),n.destroy()},onDestroyStarted:()=>{localStorage.setItem("tourShownAt",new Date().toISOString()),e&&delete e.dataset.generated,null==e||e.removeEventListener("click",t),n.destroy()}});n.drive()}else n<e?(n++,setTimeout(r,t)):console.warn("Some tour elements were not found after retries.")};r()};var c=n(24693),u=n(89802),p=n(80338),m=n(36976),g=n(99185),h=n(93448),f=n(16219),x=n(64806),v=n(26358),b=n(61994),w=n(2265),y=n(29501),j=n(20653);let S=e=>{let{placeholder:t,options:n,selectedValues:r,setSelectedValues:a,className:l,disabled:o=!1,id:i}=e,[d,c]=(0,w.useState)(!1),u=(0,w.useRef)(null),p=e=>{a(r.includes(e)?r.filter(t=>t!==e):[...r,e])},m=n.filter(e=>r.includes(e.value)).map(e=>e.name);return(0,w.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,s.jsxs)("div",{className:(0,b.Z)("relative w-full",l),ref:u,children:[(0,s.jsx)("div",{id:i,className:(0,b.Z)("inline-flex w-full items-center rounded px-[5px] text-[13px] leading-none min-h-[30px] gap-[5px] outline-none border cursor-pointer",o&&"opacity-50 cursor-not-allowed"),onClick:()=>!o&&c(!d),children:(0,s.jsxs)("div",{className:"w-full h-full flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-ellipsis overflow-hidden py-1",children:r.length>0?m.join(", "):t}),(0,s.jsx)("span",{className:"px-1",children:d?(0,s.jsx)(j.g8U,{}):(0,s.jsx)(j.v4q,{})})]})}),d&&(0,s.jsx)("div",{className:"absolute -top-52 left-0 w-full mt-1 z-50 bg-white rounded-md shadow-lg max-h-60 overflow-auto",children:n.map(e=>(0,s.jsxs)("div",{className:(0,b.Z)("relative flex items-center h-8 px-2 text-sm leading-none rounded-md select-none cursor-pointer hover:bg-gray-100",r.includes(e.value)&&"bg-gray-100",x.ar.CorrespondenceTemplateListItem),"data-test-id":"multi-select-option",onClick:()=>p(e.value),children:[(0,s.jsx)("div",{className:"absolute left-2 flex items-center",children:r.includes(e.value)&&(0,s.jsx)(j.nQG,{})}),(0,s.jsx)("span",{className:"pl-5",children:e.name})]},e.value))})]})};var N=n(29827),E=n(21770),C=n(7326),k=n(39878),T=n(10534);let D=e=>{let t=(0,N.NL)();return(0,E.D)({mutationFn:async()=>{var t;if(!e)return;let{data:n,error:r}=await (0,C.Z)().from("user_workspaces").select("generate_count").eq("id",e).single();if(r)throw r;let a=null!==(t=null==n?void 0:n.generate_count)&&void 0!==t?t:0,{data:s,error:l}=await (0,C.Z)().from("user_workspaces").update({generate_count:a+1}).eq("id",e).select();if(l)throw l;return s},onSuccess:()=>{e&&t.invalidateQueries({queryKey:["currentUserWorkspace",e]})}})};var I=e=>{var t;let{isOutputBeingGenerated:n,notes:r,currentTemplateIds:a,onChangeTemplateId:l,stopRecording:o,isLimitReached:i}=e,d=(0,f.s)(e=>e.setCurrentTemplateIds),{data:j}=(0,u.xb)(),{openModal:N}=(0,k.d)(),{data:E}=(0,m.pg)(),{data:C}=(0,g.xu)(),{data:I}=(0,p.i3)({workspaceId:null!==(t=null==j?void 0:j.current_user_workspace_id)&&void 0!==t?t:""}),{data:L}=(0,p.SL)(),A=(null==C?void 0:C.is_archived)===!0,{formState:O}=(0,y.Gc)(),R=E&&(null==I?void 0:I.length)&&!A?I:L,_=!(null==R?void 0:R.length),P=D(null==C?void 0:C.id);(0,w.useEffect)(()=>
1{if(!E&&R&&R.length>0&&(!a||0===a.length)){let e=R.find(e=>"Progress notes"===e.name);e&&(l([e.id]),d([e.id]))}},[R,a,l,d]),(0,w.useEffect)(()=>{if(R&&R.length>0&&a&&a.length>0){let e=a.filter(e=>R.some(t=>t.id===e));e.length!==a.length&&(l(e),d(e))}},[R]);let F=r.replace(/\s/g,"").length<50;return(0,s.jsxs)("div",{className:"flex flex-row p-4 justify-start gap-x-5 gap-y-3 min-w-min border-b border-l border-r border-custom-pink items-stretch rounded-b",children:[(0,s.jsx)("div",{className:"flex items-center flex-grow w-full h-full relative ",onFocusCapture:()=>{o()},tabIndex:-1,children:(0,s.jsx)(c.Z,{className:"flex items-center flex-grow w-full h-full relative",isLoading:!R,children:(0,s.jsx)(S,{id:x.UE.CorrespondenceSubmitTemplateSelect,selectedValues:a||[],disabled:!R,className:(0,b.Z)(x.ar.CorrespondenceSubmitTemplateSelect,"text-[0.9rem] font-medium w-full absolute inset-0",_&&"bg-gray-100 animate-pulse"),placeholder:"Select Document(s)",options:(null!=R?R:[]).map(e=>({name:e.name,value:e.id})),setSelectedValues:e=>{l(e),d(e)}})})}),(0,s.jsx)(c.Z,{isLoading:_,className:"",children:(0,s.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[!i&&(0,s.jsx)("button",{id:x.UE.GenerateButton,className:(0,h.cn)(x.ar.GenerateButton,"btn bg-[#2C9967] hover:bg-[#176541] text-white disabled:bg-button-disabled disabled:text-button-disabled-text py-1 px-3 rounded text-sm whitespace-nowrap"),disabled:n||_||!(null==a?void 0:a.length)||F||!!O.errors.file,onClick:()=>{o(),(null==C?void 0:C.id)&&P.mutate()},children:(0,s.jsx)("div",{id:"generate-button-action",children:n?(0,s.jsxs)("div",{className:"flex items-center justify-center",children:[(0,s.jsx)(v.$,{size:"sm",className:"mr-2"}),"Loading"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"block sm:hidden",children:"Go! â¤"}),(0,s.jsx)("span",{className:"hidden sm:block",children:"Generate! â¤"})]})})}),i&&(0,s.jsxs)("p",{className:"text-xs text-red-500",children:["Monthly limit reached."," ",(0,s.jsx)("button",{type:"button",className:"underline cursor-pointer font-medium",onClick:()=>N(T.u_.Billing,{isSubscriber:!1}),children:"Subscribe"})," ","for unlimited generates."]})]})})]})},L=n(31855);let A=w.forwardRef((e,t)=>{let{className:n,children:r,...a}=e;return(0,s.jsxs)(L.fC,{ref:t,className:(0,h.cn)("relative overflow-hidden",n),...a,children:[(0,s.jsx)(L.l_,{className:"h-full w-full rounded-[inherit]",children:r}),(0,s.jsx)(O,{}),(0,s.jsx)(L.Ns,{})]})});A.displayName=L.fC.displayName;let O=w.forwardRef((e,t)=>{let{className:n,orientation:r="vertical",...a}=e;return(0,s.jsx)(L.gb,{ref:t,orientation:r,className:(0,h.cn)("flex touch-none select-none transition-colors","vertical"===r&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...a,children:(0,s.jsx)(L.q4,{className:"relative flex-1 rounded-full bg-border"})})});O.displayName=L.gb.displayName;var R=n(17168),_=n(88108),P=n.n(_),F=n(50884),M=n.n(F),Z=n(63658);let B={darkMode:["class"],content:["./src/pages/**/*.{js,ts,jsx,tsx,mdx}","./src/components/**/*.{js,ts,jsx,tsx,mdx}","./src/app/**/*.{js,ts,jsx,tsx,mdx}","./src/templates/**/*.{js,ts,jsx,tsx,mdx}","./src/providers/**/*.{js,ts,jsx,tsx,mdx}","./pages/**/*.{ts,tsx}","./components/**/*.{ts,tsx}","./app/**/*.{ts,tsx}","./src/**/*.{ts,tsx}"],theme:{container:{center:!0,padding:"2rem",screens:{"2xl":"1400px"}},extend:{backgroundImage:{gradient:"radial-gradient(circle at 22% 11%,rgba(62, 180, 137,.20),hsla(0,0%,100%,0) 19%),radial-gradient(circle at 82% 25%,rgba(33,150,243,.18),hsla(0,0%,100%,0) 35%),radial-gradient(circle at 25% 61%,rgba(250, 128, 114, .28),hsla(0,0%,100%,0) 55%)"},colors:{"custom-red":"#FE8888","accent-text":"#1A1060","border-focus":"#a3a3a8",accent:"#F5EFFE","button-disabled":"#F0EEF1","button-disabled-text":"#AEAFBC",border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"},...n.n(Z)()},boxShadow:{custom:"0px 0px 0px 1px rgba(84, 82, 95, 0.14)","dropdown-menu":"0px 10px 38px -10px rgba(22, 23, 24, 0.35), 0px 10px 20px -15px rgba(22, 23, 24, 0.2)","non-auth-container":"0px 30px 70px 0px #1414141A","tab-bar":"0 1px 0 rgba(0, 0, 0, 0.3)"},borderWidth:{border:"2px","border-inner":"1px","border-inner-bold":"1.5px"},borderColor:{"custom-pink":"#FE8888"},borderStyle:{solid:"solid"},screens:{sm:"30em",md:"48em",lg:"62em",xl:"80em","2xl":"96em","h-md":{raw:"(min-height: 700px)"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}},plugins:[M()]},U=Object.entries((null===(r=P()(B).theme)||void 0===r?void 0:r.screens)||{}).reduce((e,t)=>
1{let[n,r]=t;return e[n]="(min-width: ".concat(r,")"),e},{}),z=()=>W(U.md),G=()=>W(U.lg),q=()=>{let[e,t]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{let e=window.matchMedia("(min-width: 0px)"),n=()=>t(!0);return e.addEventListener("change",n),e.matches&&t(!0),()=>e.removeEventListener("change",n)},[]),e},W=e=>{let[t,n]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{let r=window.matchMedia(e);r.matches!==t&&n(r.matches);let a=e=>n(e.matches);return r.addEventListener("change",a),()=>r.removeEventListener("change",a)},[t,e]),t};var V=n(69067),H=n(35067),K=n(40656);let Y=()=>{let e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")};var $=n(33145);n(6179),n(12320);var J=n(71931);let X=null===(a=n(25566).env.NEXT_PUBLIC_BASE_URL)||void 0===a?void 0:a.replace(/(^\w+:|^)\/\//,"");var Q=()=>{let{connection:e,connectToDeepgram:t,connectionState:n,disconnectFromDeepgram:r}=(0,V.YD)(),{microphone:a,startMicrophone:l,stopMicrophone:o,setupMicrophone:i,setupMixedMicrophone:d,resetMicrophone:c,microphoneState:u}=(0,H.pf)(),p=(0,f.s)(e=>e.notes),g=(0,f.s)(e=>e.setNotes),[h,x]=(0,w.useState)({notes:p||"",speaker:null}),[v]=(0,J.Nr)(h,300),b=(0,w.useRef)(),y=(0,w.useRef)(),[j,S]=(0,w.useState)(null),[N,E]=(0,w.useState)(!1),{data:C}=(0,m.pg)(),{showToast:D,showPopup:I}=(0,K.l)(),{openModal:L}=(0,k.d)(),[A,O]=(0,w.useState)(T.RecordingType.Scribe),[R,_]=(0,w.useState)("en"),[P,F]=(0,w.useState)(!1),M=!!e&&!!a,Z=(0,w.useRef)(null),B=async()=>{try{Z.current=await navigator.wakeLock.request("screen")}catch(e){console.error("Screen Wake Lock failed:",e)}},U=()=>{var e;null===(e=Z.current)||void 0===e||e.release(),Z.current=null},z=async e=>{B();try{E(!0);let n=R.startsWith("en");if(t({model:n?"nova-2-medical":"nova-2",language:R,smart_format:!0,...(e===T.RecordingType.Scribe||e===T.RecordingType.Telehealth)&&{diarize:!0}}),e!==T.RecordingType.Telehealth){let e=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!1,echoCancellation:!1}});S(e)}}catch(e){if(console.error("Error while accessing the microphone",e),e instanceof Error&&("NotAllowedError"===e.name||"PermissionDeniedError"===e.name))return I({isWide:Y(),title:"Microphone access denied",messages:Y()?['Please open "Safari" > "Settings" > "Websites" > "Microphone" and allow "'.concat(null!=X?X:"Mednotes",' to continue".'),(0,s.jsx)($.default,{src:"/assets/safari-mic-permissions.png",alt:"Safari microphone permissions",width:1186,height:703})]:["Please click the microphone icon in the toolbar to allow microphone access.",(0,s.jsx)($.default,{src:"/assets/mic-permissions.png",alt:"Chrome and Firefox microphone permissions",width:285,height:47})]});D({message:"Error while accessing the microphone",type:"error"})}},G=()=>{U(),a&&(a.stop(),r(),null==j||j.getTracks().forEach(e=>{e.stop()}),S(null),o())},q=async()=>{if(!C)return L(T.u_.Auth,{heading:"Sign In to access this feature"});if(!a){if(A===T.RecordingType.Telehealth)try{await d(),F(!0)}catch(e){console.error("Error setting up telehealth audio:",e instanceof Error?e.name:"unknown",e instanceof Error?e.message:String(e)),D({message:e instanceof Error&&"NoTabAudioError"===e.name?"The shared tab has no audio. Please share a tab with audio enabled.":"Tab sharing was cancelled or denied. Recording not started.",type:"error"})}else try{await i(),F(!0)}catch(e){console.error("Error setting up microphone",e)}return}if(e&&a)return G();z(A)},W=e=>{var t,n,r,a,s;let{is_final:l,speech_final:o}=e,i=null==e?void 0:null===(n=e.channel)||void 0===n?void 0:null===(t=n.alternatives[0])||void 0===t?void 0:t.transcript,d=null==e?void 0:null===(s=e.channel)||void 0===s?void 0:null===(a=s.alternatives[0])||void 0===a?void 0:null===(r=a.words[0])||void 0===r?void 0:r.speaker;i&&l&&x(e=>{let t=e.notes,n=e.speaker;return!t||t.endsWith(" ")||t.endsWith("\n")||(t+=" "),null!=d&&n!==d?(null!=n&&(t+="\n"),t+="[Speaker ".concat(d+1,"]: ")):null==d&&t&&!t.endsWith(" ")&&(t+=" "),{notes:t+=i,speaker:null!=d?d:null}})};return(0,w.useEffect)(()=>{v&&g(v.notes)},[v]),(0,w.useEffect)(()=>{P&&u===H.tn.Ready&&(q(),F(!1))},[P,u,t]),(0,w.useEffect)(()=>{M&&N&&E(!1)},[M,N]),(0,w.useEffect)(()=>
1{if(!a||!e)return;let t=t=>{t.data.size>0&&(null==e||e.send(t.data))};return n===V.xe.OPEN&&(e.addListener(V.lA.Transcript,W),a.addEventListener(H.ZM.DataAvailable,t),l()),()=>{e.removeListener(V.lA.Transcript,W),a.removeEventListener(H.ZM.DataAvailable,t),clearTimeout(b.current)}},[n]),(0,w.useEffect)(()=>{if(e)return u!==H.tn.Open&&n===V.xe.OPEN?(e.keepAlive(),y.current=setInterval(()=>{e.keepAlive()},1e4)):clearInterval(y.current),()=>{clearInterval(y.current)}},[u,n]),{notesData:h,isRecording:M,onClickRecord:q,onChangeNotes:e=>{x(t=>({...t,notes:e}))},onToggleRecordingType:e=>{G(),c(),O(e)},recordingType:A,isConnecting:N,microphoneIsLoading:P,onChangeSpeaker:e=>x(t=>({...t,speaker:e})),stopRecording:G,language:R,setLanguage:_}},ee=n(95108),et=n(63642),en=n(36132);n(14071);var er=n(99376),ea=n(42444),es=n(74291);let el=e=>(0,s.jsxs)("svg",{width:"24px",height:"24px","stroke-width":"1.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",color:"#C69214",...e,children:[(0,s.jsx)("path",{d:"M11.5 7L9 12H12H15L12.5 17",stroke:"#C69214","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),(0,s.jsx)("path",{d:"M5 18L3.13036 4.91253C3.05646 4.39524 3.39389 3.91247 3.90398 3.79912L11.5661 2.09641C11.8519 2.03291 12.1481 2.03291 12.4339 2.09641L20.096 3.79912C20.6061 3.91247 20.9435 4.39524 20.8696 4.91252L19 18C18.9293 18.495 18.5 21.5 12 21.5C5.5 21.5 5.07071 18.495 5 18Z",stroke:"#C69214","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})]}),eo=e=>{var t;let{isEnabled:n,report:r}=e;return console.log("Enabled:",n),(0,s.jsxs)(es.Vq,{children:[(0,s.jsx)(es.hg,{className:"w-full h-full",children:(0,s.jsx)("button",{type:"button",className:"text-[#C69214] bg-[#FFF5D1] p-1 rounded text-[13px] disabled:bg-button-disabled disabled:text-button-disabled-text hover:outline-hover-delete whitespace-nowrap disabled:cursor-not-allowed",disabled:!n,children:(0,s.jsx)(el,{height:20,width:20})})}),(0,s.jsx)(es.cZ,{children:(0,s.jsxs)(es.fK,{children:[(0,s.jsxs)(es.$N,{className:"mb-4 flex items-center",children:["Medicolegal Risk Review:","High Risk"===r.risk_level&&(0,s.jsx)("span",{className:"ml-2 text-red-600 font-bold text-sm",children:r.risk_level})]}),(0,s.jsx)("p",{className:"text-base whitespace-pre-wrap mt-4",children:null!==(t=r.document)&&void 0!==t?t:"No audit feedback available."})]})})]})},ei=[{element:"#output-container",popover:{description:"You can edit the text, copy it, email it securely, or push to a FHIR compatible EMR. <br/> <br/> Sign In to setup clinic workspaces, custom documents/upload examples so the output matches what you need.",position:"left"}},{element:"#sign-in-mobile",popover:{description:'\n Do you like what you saw?<br/><br/>\n Rate your experience:<br/>\n <div id="tour-rating-stars" style="font-size: 24px; display: flex; justify-content: center;">
1\n <span class="star" data-rating="1" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(1)">â</span>\n <span class="star" data-rating="2" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(2)">â</span>\n <span class="star" data-rating="3" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(3)">â</span>\n <span class="star" data-rating="4" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(4)">â</span>\n <span class="star" data-rating="5" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(5)">â</span>\n </div>\n <div id="rating-message" style="text-align: center; margin-top: 5px; height: 20px;"></div>\n <br/>\n Sign in to start using MedNotes, whenever you want,<strong> for FREE</strong>\n ',position:"center"}}],ed=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=0,r=null;window.handleStarClick=function(e){try{let t=document.getElementById("tour-rating-stars"),n=document.getElementById("rating-message");if(!t){console.error("Stars container not found");return}t.querySelectorAll(".star").forEach((t,n)=>{n<e?(t.innerHTML="â
",t.style.color="gold"):(t.innerHTML="â",t.style.color=""),t.removeAttribute("onclick"),t.style.cursor="default"}),n?n.textContent="Thanks for your feedback!":console.error("Rating message element not found"),l.nT.track(l.j7.RATING_GIVEN,{rating:e}),setTimeout(()=>{r?r.moveNext():console.error("Tour instance not available")},800)}catch(e){console.error("Error in handleStarClick:",e)}};let a=()=>{if(ei.every(e=>!e.element||document.querySelector(e.element))){let e=(0,o.v)({steps:ei,allowClose:!0,onNextClick:(t,n)=>{l.nT.track(l.j7.NEXT_CLICKED,{step:n.element}),ei.findIndex(e=>e.element===n.element)===ei.length-1&&localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.moveNext()},onPrevClick:(t,n)=>{l.nT.track(l.j7.PREVIOUS_CLICKED,{step:n.element}),e.movePrevious()},onCloseClick:()=>{l.nT.track(l.j7.CLOSE_CLICKED),localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.destroy()},onDestroyStarted:()=>{localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.destroy()}});r=e,e.drive()}else n<e?(n++,setTimeout(a,t)):console.warn("Some tour elements were not found after retries.")};a()},ec=null,eu=()=>{ec&&(ec.destroy(),ec=null)},ep=[{element:"#output-container",popover:{description:"You can edit the text, copy it, email it securely, or push to a FHIR compatible EMR. <br/> <br/> Sign In to setup clinic workspaces, custom documents/upload examples so the output matches what you need.",position:"left"}},{element:"#sign-in-desktop",popover:{description:'\n Do you like what you saw?<br/><br/>\n Rate your experience:<br/>\n <div id="tour-rating-stars" style="font-size: 24px; display: flex; justify-content: center;">
1\n <span class="star" data-rating="1" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(1)">â</span>\n <span class="star" data-rating="2" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(2)">â</span>\n <span class="star" data-rating="3" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(3)">â</span>\n <span class="star" data-rating="4" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(4)">â</span>\n <span class="star" data-rating="5" style="cursor: pointer; padding: 0 5px; user-select: none;" onclick="window.handleStarClick(5)">â</span>\n </div>\n <div id="rating-message" style="text-align: center; margin-top: 5px; height: 20px;"></div>\n <br/>\n Sign in to start using MedNotes, whenever you want,<strong> for FREE</strong>\n ',position:"center"}}],em=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,n=0;window.handleStarClick=function(e){try{let t=document.getElementById("tour-rating-stars"),n=document.getElementById("rating-message");if(!t){console.error("Stars container not found");return}t.querySelectorAll(".star").forEach((t,n)=>{n<e?(t.innerHTML="â
",t.style.color="gold"):(t.innerHTML="â",t.style.color=""),t.removeAttribute("onclick"),t.style.cursor="default"}),n?n.textContent="Thanks for your feedback!":console.error("Rating message element not found"),l.nT.track(l.j7.RATING_GIVEN,{rating:e}),setTimeout(()=>{ec?ec.moveNext():console.error("Tour instance not available")},800)}catch(e){console.error("Error in handleStarClick:",e)}};let r=()=>{if(ep.every(e=>!e.element||document.querySelector(e.element))){let e=(0,o.v)({steps:ep,allowClose:!0,onNextClick:(t,n)=>{l.nT.track(l.j7.NEXT_CLICKED,{step:n.element}),ep.findIndex(e=>e.element===n.element)===ep.length-1&&localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.moveNext()},onPrevClick:(t,n)=>{l.nT.track(l.j7.PREVIOUS_CLICKED,{step:n.element}),e.movePrevious()},onCloseClick:()=>{l.nT.track(l.j7.CLOSE_CLICKED),localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.destroy()},onDestroyStarted:()=>{localStorage.setItem("generatedTourShownAt",new Date().toISOString()),e.destroy()}});ec=e,e.drive()}else n<e?(n++,setTimeout(r,t)):console.warn("Some tour elements were not found after retries.")};r()};n(83079);var eg=n(12119),eh=(0,eg.$)("33abeb95aa7df8d0526c14ec8cc45bcebb2bbb29"),ef=n(16593),ex=n(27648);let ev=e=>{var t;let{isOutputBeingGenerated:n,output:r,setOutput:a,onCopyToClipBoard:l,progressNote:o}=e,{showPopup:i}=(0,K.l)(),{openModal:d}=(0,k.d)(),{data:p}=(0,m.pg)(),{data:f,isPending:v}=(0,g.xu)(),b=0===r.length,{watch:j}=(0,y.Gc)(),S=j("letter.type"),{data:N,isLoading:E}=(0,u.xb)(),C=!N&&E&&!S||v,[D,I]=(0,w.useState)(!1),[L,A]=(0,w.useState)(0);(0,w.useEffect)(()=>{if(n){A(0);let e=setInterval(()=>{A(t=>{let n=t+.5;return n>=98?(clearInterval(e),98):n})},100);return()=>clearInterval(e)}},[n]);let O=(0,s.jsx)("button",{type:"button",onClick:()=>{if(eu(),!p)return d(T.u_.Auth,{heading:"Sign In to access this feature"})},className:"text-[#00824F] bg-[#E7E8DD] py-1 px-3 rounded text-[13px] hover:outline-hover-send cursor-pointer whitespace-nowrap disabled:bg-button-disabled disabled:text-button-disabled-text",disabled:b,children:"Send via email"}),{notesData:R}=Q(),[_,P]=(0,w.useState)(r),{data:F,isLoading:M,isError:Z}=function(e){let{response:t,enabled:n}=e;return(0,ef.a)({queryKey:["auditReport",t],queryFn:()=>eh({response:t}),enabled:n})}({response:_,enabled:"Progress notes"===o&&!n&&!!_});(0,w.useEffect)(()=>{let e=setTimeout(()=>{P(r)},3e3);return()=>clearTimeout(e)},[r]),(0,w.useEffect)(()=>{M||Z||_!==r||I(!1)},[M,Z,_,r]);let B=(0,h.C)();return(0,w.useEffect)(()=>{if(null===B)return;let e=localStorage.getItem("generatedTourShownAt"),t=new Date;e&&(e=>{let n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()})(e)||!(r.length>0)||n||(B?em():ed())},[B,r,n]),(0,s.jsxs)("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden",id:x.UE.OutputContainer,children:[(0,s.jsx)("div",{className:"w-full min-w-min flex-1 min-h-0 flex flex-col",children:(0,s.jsxs)(c.Z,{isLoading:C,className:"relative w-full flex flex-col flex-1 min-h-0 rounded-md ".concat(n?"bg-white":""),children:[n&&0===r.length&&(0,s.jsx)("div",{className:"absolute inset-0 bg-white flex items-center justify-center z-10",children:(0,s.jsx)(eb,{progress:L})}),(0,s.jsx)("textarea",{id:x.UE.CorrespondenceOutputTextArea,onChange:e=>{a(e.target.value),I(!0)},value:r,disabled:0===r.length||n,className:(0,h.cn)(x.ar.CorrespondenceOutputTextArea,"w-full p-3 text-[14px] border-border-inner rounded-md resize-none flex-1 min-h-0 ".concat(n?"bg-white":"disabled:bg-[#F1F1F4]"))})]})}),(0,s.jsx)("div",{className:"flex justify-end w-full gap-x-2 gap-y-2 p-3 px-0 items-end",children:(0,s.jsxs)("div",{className:"flex gap-x-2 gap-y-2 flex-wrap justify-end",children:[(0,s.jsx)(c.Z,{isLoading:C,children:(null==f?void 0:null===(t=f.workspace)||void 0===t?void 0:t.enable_wingman)&&(0,s.jsx)(eo,{report:F||{document:"",risk_level:null},isEnabled:!!F&&!M&&!Z&&!D})}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("button",{type:"button",onClick:()=>
1{if(eu(),!p)return d(T.u_.Auth,{heading:"Sign In to access this feature"});l()},className:" text-[#0073DD] bg-[#E7E7F0] py-1 px-3 rounded text-[13px] disabled:bg-button-disabled disabled:text-button-disabled-text hover:outline-hover-copy whitespace-nowrap",disabled:b,children:"Copy"})}),b&&(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("button",{type:"button",className:" text-[#00824F] bg-[#E7E8DD] py-1 px-3 rounded text-[13px] disabled:bg-button-disabled disabled:text-button-disabled-text hover:outline-hover-send whitespace-nowrap",disabled:!0,children:"Send via email"})}),!b&&p&&(0,s.jsx)(ea.B,{output:r,letterType:S,children:O}),!b&&!p&&(0,s.jsx)(c.Z,{isLoading:C,children:O}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("button",{type:"button",disabled:b,onClick:()=>{if(eu(),!p){d(T.u_.Auth,{heading:"Sign In to access this feature"});return}i({messages:["EMR Integration is available for an Enterprise Plan.",(0,s.jsxs)(s.Fragment,{children:["To upgrade please contact",(0,s.jsx)(ex.default,{className:"font-bold",href:"mailto:[email protected]",children:"mailto:[email protected]"})]})]})},className:" text-[#915ABD] bg-[#F8E0EF] py-1 px-3 rounded text-[13px] disabled:bg-button-disabled disabled:text-button-disabled-text hover:outline-hover-upload whitespace-nowrap",children:"Upload to EMR"})})]})})]})},eb=e=>{let{progress:t}=e,[n,r]=(0,w.useState)("0%");return(0,w.useEffect)(()=>{requestAnimationFrame(()=>{r("".concat(t,"%"))})},[t]),(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center w-full h-full",children:[(0,s.jsx)("p",{className:"mb-4 text-gray-500 text-sm",children:"Document(s) will be generated here...."}),(0,s.jsx)("div",{className:"relative w-1/2 max-w-md",children:(0,s.jsx)("div",{className:"w-full bg-gray-200 h-2 rounded-md overflow-hidden",children:(0,s.jsx)("div",{className:"progress-bar transition-all ease-in-out rounded-md bg-blue-500",style:{width:n}})})})]})};var ew=n(56563),ey=n(18857);let ej=()=>"mednotes",eS=e=>window.localStorage.getItem(e),eN=(e,t)=>{window.localStorage.setItem(e,t)},eE=e=>{let t=ej();t&&eN(t,JSON.stringify(e))},eC=()=>{let e=ej();if(!e)return null;let t=eS(e);if(null==t?void 0:t.startsWith("{"))return JSON.parse(t);let n={id:(0,ey.Mc)(),generationCredits:3,createdAt:new Date().toISOString()};return eE(n),n},ek=()=>{let e=eC();e&&eE({...e,generationCredits:e.generationCredits-1})};var eT=()=>{let[e]=(0,w.useState)(()=>eC());return e},eD=n(70040),eI=n(85969);let eL=eD.uz[0],eA=e=>{var t;let{stopRecording:n}=e,r=(0,w.useRef)(null),[a,l]=(0,w.useState)(()=>window.innerWidth>=640),o=(0,ew.Z)(),{register:i,setValue:d,watch:u}=(0,y.Gc)(),p=eT(),{data:g}=(0,m.pg)(),[f,v]=(0,w.useState)(!1),j=u("patientDetails.DOB"),S=u("patientDetails.name"),N=u("patientDetails.surname"),E=u("patientDetails.gender"),C=!g&&!f,k=(0,w.useRef)(null);(0,w.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>{n()};return e.addEventListener("focusin",t),()=>{e.removeEventListener("focusin",t)}},[n]),(0,w.useEffect)(()=>{void 0===u("consultationType")&&d("consultationType",eD.FO[0].note)},[u("consultationType")]),(0,w.useEffect)(()=>{if(g)return v(!0);!f&&o&&(j||d("patientDetails.DOB",12),S||d("patientDetails.name","John"),N||d("patientDetails.surname","Singh"),E||d("patientDetails.gender",eL),v(!0))},[i,d,j,S,N,E,g,p,f,o]);let T=(null===(t=r.current)||void 0===t?void 0:t.offsetHeight)||0,D=u("consultationType"),I=eD.FO.find(e=>e.note===D);return(0,s.jsx)("div",{style:{maxHeight:!a&&T?T:"100%"},className:(0,b.Z)("flex flex-col items-start bg-[url(/assets/patientDetails-bg.png)] bg-cover bg-center px-4 py-1 border-l border-r border-b border-custom-pink rounded-none",!a&&"overflow-hidden"),onClick:()=>{a||l(!0)},children:(0,s.jsxs)("div",{className:"flex items-center gap-2 gap-y-3 pt-1 pb-4 mt-3",ref:k,id:x.UE.PatientDetailsContainer,children:[(0,s.jsx)("div",{className:"flex items-center space-x-2",children:(0,s.jsx)("button",{type:"button",id:x.UE.ConsultationModeButton,onClick:()=>{let e=(eD.FO.findIndex(e=>e.note===D)+1)%eD.FO.length;d("consultationType",eD.FO[e].note)},className:(0,h.cn)(x.UE.ConsultationModeButton,"flex items-center space-x-1 px-2 py-1 rounded text-sm"),title:"Toggle consultation mode (".concat(null==I?void 0:I.mode,")"),children:(0,s.jsx)("span",{children:null==I?void 0:I.icon})})}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("input",{id:x.UE.PatientDetailsFirstNameInput,value:S,type:"text",placeholder:"First Name",className:(0,b.Z)(x.ar.PatientDetailsFirstNameInput,"border-border-inner w-full max-w-28 p-1 rounded text-[13px]"),onChange:e=>d("patientDetails.name",e.target.value),disabled:C})}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("input",{id:x.UE.PatientDetailsLastNameInput,name:"lastName",value:N,type:"text",placeholder:"Last Name",className:(0,b.Z)(x.ar.PatientDetailsLastNameInput,"border-border-inner w-full max-w-28 p-1 rounded text-[13px]"),disabled:C,onChange:e=>d("patientDetails.surname",e.target.value)})}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)("input",{id:x.UE.PatientDetailsDOBPicker,type:"number",min:0,placeholder:"Age",className:(0,b.Z)("border-border-inner w-full max-w-20 p-1 rounded text-[13px]"),disabled:C,value:null!=j?j:"",onCh
1ange:e=>{let t=e.target.value;if(""===t){d("patientDetails.DOB",null);return}let n=parseInt(t);isNaN(n)||(n>99&&(n=99),d("patientDetails.DOB",n))}})}),(0,s.jsx)(c.Z,{isLoading:C,children:(0,s.jsx)(eI.Ph,{id:x.UE.PatientDetailsGenderSelect,value:E,disabled:C,className:(0,b.Z)(x.ar.PatientDetailsGenderSelect,"h-[30px] bg-white"),placeholder:"Gender",setValue:e=>{d("patientDetails.gender",e)},children:eD.uz.map(e=>(0,s.jsx)(eI.Ql,{value:e,className:x.ar.PatientDetailsOptionSelect,children:e},e))})})]})})},eO=async e=>{if(!e)throw Error("No file provided.");let t=new FormData;t.append("file",e);try{let e=await fetch("".concat("https://background-api.mednotes.ai","/v1/extract-text"),{method:"POST",body:t});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return(await e.json()).text}catch(e){throw console.error("Error in extracting text:",e),e}},eR=()=>({onSubmit:async e=>{try{return await eO(e)}catch(e){throw console.error("Error calling API for extracting text",e),e}}}),{Dictate:e_,Scribe:eP,Telehealth:eF}=T.RecordingType,eM=[{code:"en",label:"English"},{code:"ar",label:"Arabic"},{code:"zh-CN",label:"Chinese"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"el",label:"Greek"},{code:"hi",label:"Hindi"},{code:"it",label:"Italian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"pt",label:"Portuguese"},{code:"ru",label:"Russian"},{code:"es",label:"Spanish"}],eZ=[{type:eP,label:"Scribe",icon:(0,s.jsx)(j.Tk0,{}),tooltip:"Transcribe an in-person consultation"},{type:eF,label:"Scribe",icon:(0,s.jsx)(j.Odl,{}),tooltip:"Transcribe a browser tab consultation"},{type:e_,label:"Dictate",icon:null,tooltip:"Dictate consultation notes"}],eB=e=>{let{reset:t,onClickRecord:n,isConnecting:r,isRecording:a,notes:o,onChangeNotes:i,onToggleRecordingType:d,recordingType:u,stopRecording:p,language:g,onChangeLanguage:f}=e,S=(0,w.useRef)(null),N=(0,ew.Z)(),{data:E,isPending:C}=(0,m.pg)(),[D,I]=(0,w.useState)(!1),L=(0,w.useRef)(null),[A,O]=(0,w.useState)(!1),[R,_]=(0,w.useState)(!1),P=(0,w.useRef)(null),[F,M]=(0,w.useState)(!1),Z=!E&&!D,[B,U]=(0,w.useState)(!1),{openModal:z}=(0,k.d)(),{onSubmit:G}=eR(),{setValue:q,watch:W,formState:V}=(0,y.Gc)();(0,w.useEffect)(()=>{if(null===L.current)return;let e=L.current;e.scrollTop=e.scrollHeight},[o]),(0,w.useEffect)(()=>{if(!C){if(E)return I(!0);!D&&N&&(o||i(eD.dD),I(!0))}},[i,E,D,N]),(0,w.useEffect)(()=>{D&&L.current&&(L.current.scrollTop=0)},[D]),(0,w.useEffect)(()=>{let e=e=>{e.target instanceof HTMLElement&&!function(e,t){let n=e;for(;n;){if(n.id===t)return!0;n=n.parentElement}return!1}(e.target,x.UE.RecordButton)&&(A&&O(!1),R&&_(!1))};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[A,R]),(0,w.useEffect)(()=>{let e=P.current;if(!e)return;let t=new ResizeObserver(()=>{let t=e.children,n=0;for(let e=0;e<t.length;e++)n+=t[e].offsetWidth;M(n>e.clientWidth)});return t.observe(e),()=>{t.disconnect()}},[P]);let H=async e=>{var t;let n=(null===(t=e.target.files)||void 0===t?void 0:t[0])||null;if(n&&n instanceof File){if(n.type.startsWith("video/")){e.target.value="",q("file",null,{shouldValidate:!0}),q("fileName",""),q("document_text",""),alert("You cannot upload video files.");return}e.target.value="",q("file",n,{shouldValidate:!0}),q("fileName",n.name);try{U(!0);let e=await G(n);q("document_text",e),l.nT.track(l.w$.UPLOAD_SUCCESS),U(!1)}catch(e){console.error("Error extracting text:",e)}}};return(0,s.jsxs)("div",{ref:S,id:x.UE.YourNotesContainer,className:"flex flex-col p-3 gap-3 md:flex-grow bg-white rounded rounded-b-none border border-custom-pink flex-grow",children:[(0,s.jsxs)("div",{ref:P,className:"flex items-start justify-end gap-2 flex-wrap py-1",children:[(0,s.jsx)(c.Z,{isLoading:Z,className:"flex justify-start items-start flex-grow",children:(0,s.jsxs)("div",{id:x.UE.RecordButton,className:(0,b.Z)(" flex items-stretch"),children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>O(e=>!e),className:(0,b.Z)("px-3 pr-2 py-1 bg-gray-500 hover:bg-gray-600 text-white text-sm flex items-center relative gap-2 border-r disabled:bg-gray-400 disabled:cursor-not-allowed",A?"rounded-tl":"rounded-l"),children:[r?(0,s.jsx)("div",{className:"flex items-center justify-center",children:"Loading"}):(()=>{let e=eZ.find(e=>e.type===u);return(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[null==e?void 0:e.label,null==e?void 0:e.icon]})})(),(0,s.jsx)(j.v4q,{className:(0,b.Z)("transition-transform",A&&"rotate-180")}
1)]}),(0,s.jsx)("div",{className:(0,b.Z)("absolute top-full right-0 z-10 rounded-b bg-gray-500 text-white text-sm flex flex-col min-w-full",!A&&"hidden"),children:eZ.map(e=>(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsxs)("button",{type:"button",className:(0,b.Z)("flex items-center gap-1.5 px-3 py-1.5 whitespace-nowrap hover:bg-gray-600 text-left w-full",e.type===u&&"bg-gray-600"),onClick:()=>{O(!1),d(e.type)},children:[e.label,e.icon]}),(0,s.jsx)("span",{className:"pointer-events-none absolute left-full top-1/2 -translate-y-1/2 ml-2 px-2 py-1 rounded bg-gray-800 text-white text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-150 delay-700 z-20",children:e.tooltip})]},e.type))})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{type:"button",disabled:r||a,onClick:()=>_(e=>!e),className:"px-2 py-1 bg-gray-500 hover:bg-gray-600 text-white text-sm border-l border-gray-400 disabled:bg-gray-400 disabled:cursor-not-allowed uppercase tracking-wide",title:"Recording language",children:g.split("-")[0]}),(0,s.jsx)("div",{className:(0,b.Z)("absolute top-full right-0 z-10 rounded-b bg-gray-500 text-white text-sm flex flex-col min-w-full",!R&&"hidden"),children:eM.map(e=>(0,s.jsx)("button",{type:"button",className:(0,b.Z)("px-3 py-1.5 whitespace-nowrap hover:bg-gray-600 text-left",e.code===g&&"bg-gray-600"),onClick:()=>{f(e.code),_(!1)},children:e.label},e.code))})]}),(0,s.jsx)("button",{type:"button",onClick:n,disabled:r,className:(0,b.Z)("pl-3 pr-3 bg-[#2C9967] hover:bg-[#176541] text-white text-sm flex items-center justify-center relative disabled:bg-gray-400 disabled:cursor-not-allowed",a&&"bg-[#DC3E43] hover:bg-[#a32e32]",A?"rounded-tr":"rounded-r"),children:r?(0,s.jsx)("div",{className:"flex items-center justify-center px-1.5",children:(0,s.jsx)(v.$,{size:"sm"})}):a?"Stop":"Start"})]})}),(0,s.jsxs)("div",{className:(0,h.cn)("justify-between items-center flex gap-3",!F&&"flex-grow"),children:[Z?(0,s.jsx)(v.$,{className:"text-gray-300 mr-1"}):(0,s.jsx)(c.Z,{isLoading:Z,children:(0,s.jsx)(eU,{text:o})}),(0,s.jsx)(c.Z,{isLoading:Z,className:"",children:(0,s.jsx)("button",{type:"button",onClick:t,className:"text-white bg-[#DC3E43] py-1 px-3 rounded text-sm hover:bg-[#a32e32] disabled:bg-button-disabled disabled:text-button-disabled-text",children:"Reset"})})]})]}),(0,s.jsx)(c.Z,{isLoading:Z,className:"flex-grow main-text-area",children:(0,s.jsx)("textarea",{id:x.UE.YourNotesTextArea,disabled:Z,ref:L,value:o,className:(0,b.Z)(x.ar.YourNotesTextArea,"w-full border-border-inner rounded-md p-3 resize-none text-[14px] h-full",Z&&"bg-gray-100 animate-pulse"),placeholder:"Scribe, dictate, type or paste in notes",onChange:e=>{i(e.target.value)}})}),(0,s.jsx)(c.Z,{isLoading:Z,children:(0,s.jsxs)("div",{className:"flex flex-col items-start gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,s.jsx)("label",{htmlFor:"fileInput",className:"bg-gray-100 text-black py-2 px-4 rounded cursor-pointer",onClick:e=>{p(),l.nT.track(l.w$.CLICKED_UPLOAD),E||(e.preventDefault(),z(T.u_.Auth,{heading:"Sign In to access this feature"}))},children:B?(0,s.jsx)(v.$,{className:"text-gray-600",size:"sm"}):(0,s.jsx)(j.rG2,{})}),(0,s.jsx)("input",{id:"fileInput",type:"file",accept:".pdf,image/png,image/jpeg",className:"hidden",onChange:H,disabled:B,"data-test-id":"file-upload"}),(0,s.jsx)("span",{className:"text-gray-800 text-xs font-medium",children:W("fileName")||"Upload supporting images or PDFs"}),W("fileName")&&(0,s.jsx)("div",{className:"bg-gray-100 text-black py-1 px-1 rounded-full cursor-pointer",children:(0,s.jsx)(j.Pxu,{className:"cursor-pointer",onClick:()=>{q("file",null,{shouldValidate:!0}),q("fileName",""),q("document_text","")},"data-test-id":"remove-file"})})]}),V.errors.file&&(0,s.jsx)("p",{className:"text-red-500 text-xs",children:V.errors.file.message})]})})]})},eU=e=>{let{text:t}=e,n=t.replace(/\s/g,"");return(0,s.jsx)("div",{className:(0,b.Z)("items-center whitespace-nowrap",t.length>0?"flex":"hidden"),children:(0,s.jsx)(()=>{let e=n.length<250?[{color:"bg-red-400"},{color:"bg-gray-300"},{color:"bg-gray-300"},{color:"bg-gray-300"}
1]:n.length<500?[{color:"bg-amber-400"},{color:"bg-amber-400"},{color:"bg-gray-300"},{color:"bg-gray-300"}]:n.length<1e3?[{color:"bg-green-500"},{color:"bg-green-500"},{color:"bg-green-500"},{color:"bg-gray-300"}]:[{color:"bg-green-500"},{color:"bg-green-500"},{color:"bg-green-500"},{color:"bg-green-500"}];return(0,s.jsx)("span",{className:"flex items-center gap-1 px-1",children:e.map((e,t)=>(0,s.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(e.color)},t))})},{})})};var ez=n(19639),eG=n(84004);let eq=async e=>{let{templateId:t,consultNotes:n,patientAgeYears:r,patientGender:a,patientFirstName:s,patientLastName:l,patientHonorific:o,document_text:i,onProgress:d}=e;try{let e=await fetch("".concat(eG.O.NEXT_PUBLIC_SERVICE_API_BASE_URL_STREAM,"/v1/generate"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({template_id:t,note:n,age:r,gender:a,document_text:i})});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));if(!e.body)throw Error("Response body is null");let c=e.body.getReader(),u=new TextDecoder,p="";for(;;){let{done:e,value:t}=await c.read();if(e)break;let n=u.decode(t);p+=n,d&&d(function(e,t,n,r,a){let s=[(({Mrs:"Ms",Miss:"Ms",Mister:"Mr","":""})[r]||r).replace(/\.$/,""),t,n].filter(Boolean).join(" ").trim();return e.replace(/\[name\]/gi,s)}(p.replace("[[ ## document ## ]]","").replace("[[ ## completed ## ]]None",""),s,l,o,0))}}catch(e){throw console.error("Error in pollApi:",e),Error("Failed to process request: ".concat(e))}},eW=e=>{let{value:t,localStorageKey:n}=e;(0,w.useEffect)(()=>{sessionStorage&&sessionStorage.setItem(n,JSON.stringify(t))},[t,n,"undefined"!=typeof sessionStorage])};var eV=n(47379),eH=n(31229),eK=(0,eg.$)("cbab176aba40b52c64df686a5efb473b3637e7ec");let eY="consultForm",e$={patientDetails:{patientPrefix:"",name:"",surname:"",DOB:null,gender:""},notes:"",letter:{type:"",style:""},consultationType:""},eJ=eH.z.object({patientDetails:eH.z.object({patientPrefix:eH.z.string().optional(),name:eH.z.string().optional(),surname:eH.z.string().optional(),DOB:eH.z.number().nullable().optional(),gender:eH.z.string().optional()}),notes:eH.z.string().optional(),letter:eH.z.object({type:eH.z.string().optional(),style:eH.z.string().optional()}),templateId:eH.z.string().optional(),document_text:eH.z.string().optional(),consultationType:eH.z.string().optional(),file:eH.z.union([eH.z.instanceof(File),eH.z.string()]).nullable().refine(e=>!e||"string"==typeof e||["image/jpeg","image/png","application/pdf"].includes(e.type),{message:"Only JPG, PNG, or PDF files are allowed."}).optional()}),eX=()=>{var e,t,n;let{data:r}=(0,m.pg)(),{data:a}=(0,u.xb)(),s=eT(),{openModal:o}=(0,k.d)(),i=(0,N.NL)(),d=(0,f.s)(e=>e.currentTemplateIds),[c,p,g]=function(e,t){let[n,r]=(0,w.useState)(()=>{try{let n=window.sessionStorage.getItem(e);return n?JSON.parse(n):t}catch(e){return t}}),a=(0,w.useRef)(null),s=(0,w.useRef)(n),l=(0,w.useCallback)(()=>{null!==a.current&&(clearTimeout(a.current),a.current=null);try{window.sessionStorage.setItem(e,JSON.stringify(s.current))}catch(e){console.error("Could not save to sessionStorage:",e)}},[e]),o=(0,w.useCallback)(function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t instanceof Function?r(e=>{let n=t(e);return s.current=n,n}):(s.current=t,r(t)),n||(null!==a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{try{window.sessionStorage.setItem(e,JSON.stringify(s.current))}catch(e){console.error("Could not save to sessionStorage:",e)}a.current=null},300))},[e]);return(0,w.useEffect)(()=>()=>{null!==a.current&&(clearTimeout(a.current),a.current=null),l()},[l]),[n,o,l]}("output",[]),[h,x]=(0,w.useState)([]),[v,b]=(0,w.useState)(!1),j=(0,w.useRef)(!1),S=null!==(e=null==a?void 0:a.is_subscriber)&&void 0!==e&&e,E=null!==(t=null==a?void 0:a.monthly_generate_limit)&&void 0!==t?t:25,C=null!==(n=null==a?void 0:a.monthly_generates_used)&&void 0!==n?n:0,D=(null==a?void 0:a.monthly_reset_at)?new Date(a.monthly_reset_at):null,I=new Date,L=!D||I.getTime()-D.getTime()>2592e6?0:C,A=!!r&&!S&&L>=E;(0,w.useEffect)(()=>{let e=()=>{O.reset(e$)};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[]),(0,w.useEffect)(()=>{j.current&&!v&&g(),j.current=v},[v,g]);let O=(0,y.cI)({resolver:(0,eV.F)(eJ),defaultValues:(()=>
1{if("undefined"==typeof sessionStorage)return e$;let e=sessionStorage.getItem(eY);if(!e)return e$;try{return JSON.parse(e)||e$}catch(e){return console.error(e),e$}})(),mode:"onBlur"});eW({value:O.getValues(),localStorageKey:eY});let{showToast:R}=(0,K.l)(),_=async(e,t,n)=>{try{let a=null==s?void 0:s.generationCredits;if(!r&&null!=a&&a<=0){o(T.u_.Auth,{heading:"Sign In to access this feature"});return}if(r||ek(),A){o(T.u_.Billing,{isSubscriber:!1});return}let c=null!=t?t:d;null==n||n(c),l.nT.track(l.w$.CLICKED_GENERATE),b(!0),x([]);let u=[],m=c.map(async t=>{try{let n={consultNotes:"".concat(e.consultationType||""," ").concat(e.notes),patientAgeYears:e.patientDetails.DOB,patientGender:e.patientDetails.gender,patientFirstName:(0,ez.f)(e.patientDetails.name),patientHonorific:e.patientDetails.patientPrefix,patientLastName:(0,ez.f)(e.patientDetails.surname),templateId:t,document_text:e.document_text};return await eq({...n,onProgress:e=>{let n=e.trim();p(e=>{let r=[...e],a=r.findIndex(e=>e.templateId===t);return -1!==a?r[a]={templateId:t,response:n}:r.push({templateId:t,response:n}),r},!0)}}),{templateId:t,success:!0}}catch(e){return console.error("Error calling API for templateId ".concat(t,":"),e),u.push(t),{templateId:t,success:!1}}}),g=await Promise.allSettled(m);b(!1),x(u),g.some(e=>{var t;return"fulfilled"===e.status&&(null===(t=e.value)||void 0===t?void 0:t.success)})&&r&&!S&&(await eK(),i.invalidateQueries({queryKey:["userProfile"]}))}catch(e){console.error("Unexpected error in onSubmit:",e),b(!1)}};return{...O,onSubmit:_,isOutputBeingGenerated:v,output:c,reset:()=>{O.reset(e$),p([])},copyToClipboard:e=>{let t=null==c?void 0:c.find(t=>t.templateId===e);if(!t){R({message:"No content available to copy",type:"error"});return}navigator.clipboard.writeText(t.response),R({message:"Copied to Clipboard",type:"success"}),l.nT.track(l.w$.COPY)},setOutput:p,failedRequests:h,isLimitReached:A,isSubscriber:S,monthlyLimit:E,effectiveUsed:L}},eQ=[{element:"#your-notes-text-area",popover:{description:"Try editing the scratch notes we've provided. You can also dictate or transcribe a consult in real time!",position:"left"}},{element:"#patient-details-container",popover:{description:"Add patient information (Optional) <br/><br/> <strong> This information never leaves your browser.</strong>"}},{element:"#generate-button-action",popover:{description:"...Click <strong>Go</strong> to watch MedNotes work it's magic."},overlayClickAction:"close",buttons:[]},{element:"#document-appear-here",popover:{description:"Watch this space to see your documentation emerge ready for you to review and edit!",showButtons:[]},allowClose:!0,overlayClickAction:"close"}],e0=()=>{var e;let t=null===(e=document.querySelector("#generate-button-action"))||void 0===e?void 0:e.closest("button"),n=()=>{t&&(t.dataset.generated="true")};t&&t.addEventListener("click",n,{once:!0});let r=(0,o.v)({steps:eQ,allowClose:!0,stagePadding:15,stageRadius:8,onNextClick:(e,t)=>{if(l.nT.track(l.j7.NEXT_CLICKED,{step:t.element}),"#generate-button-action"===t.element&&e){let t=e.closest("button");!t||t.dataset.generated||t.disabled||(t.dataset.generated="true",t.click())}r.moveNext(),localStorage.setItem("tourShownAt",new Date().toISOString())},onPrevClick:(e,t)=>{l.nT.track(l.j7.PREVIOUS_CLICKED,{step:t.element}),r.movePrevious()},onCloseClick:()=>{l.nT.track(l.j7.CLOSE_CLICKED),localStorage.setItem("tourShownAt",new Date().toISOString()),r.destroy()},onDestroyStarted:()=>{localStorage.setItem("tourShownAt",new Date().toISOString()),t&&delete t.dataset.generated,null==t||t.removeEventListener("click",n),r.destroy()}});r.drive()};var e1=n(97821);let e2=(e,t)=>{let[n,r]=(0,w.useState)(null),[a,s]=(0,w.useState)(460),l=(0,w.useRef)(0),o=(0,w.useRef)(t);o.current=t;let i=t=>{let n=window.innerWidth-(e?a:0);r(Math.max(Math.min(n-t.clientX+-15,.75*n),Math.max(.25*n,350)))},d=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",d)},c=e=>{var t,n;let i=window.innerWidth,d=i-e.clientX-8;if(o.current){s(Math.max(Math.min(d,i-360-10),350));return}let c=l.current||a+(null!==(n=null===(t=document.getElementById(x.UE.DocumentAppearHere))||void 0===t?void 0:t.getBoundingClientRect().width)&&void 0!==n?n:0),u=Math.max(Math.min(d,Math.max(c-360,350)),350);s(u),r(Math.max(c-u,360))},u=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};
1return{correspondenceWidthPx:n,setCorrespondenceWidthPx:r,settingsWidthPx:a,setSettingsWidthPx:s,onMouseDownVertical:()=>{document.addEventListener("mousemove",i),document.addEventListener("mouseup",d)},onMouseDownSettings:()=>{if(!o.current){var e,t,r;let s=null!==(r=null!==(t=null===(e=document.getElementById(x.UE.DocumentAppearHere))||void 0===e?void 0:e.getBoundingClientRect().width)&&void 0!==t?t:n)&&void 0!==r?r:0;l.current=a+s}document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)}}};function e3(){var e;let t=(0,ee.Z)(),{data:n}=(0,m.pg)(),r=(0,er.useSearchParams)(),{showToast:a}=(0,K.l)(),l=(0,N.NL)(),{data:o}=(0,p.SL)(),{data:i}=(0,p.i3)(),{currentTemplateIds:c,setCurrentTemplateIds:u}=(0,f.s)(),[g,v]=(0,w.useState)(c||[]),{openModal:b}=(0,k.d)();eT();let[j,S]=(0,w.useState)([]),[E,C]=(0,w.useState)(""),T=n&&(null==i?void 0:i.length)?i:o,D=null==T?void 0:T.map(e=>({name:e.name,value:e.id})),L=(0,w.useRef)(en.j.value),[_,P]=(0,w.useState)(!!r.get("clearForm")),F=z(),M=G(),Z=q(),[B,U]=(0,w.useState)(!1),W=eX(),[V,H]=(0,w.useState)("notes"),[Y,$]=(0,w.useState)((null!==(e=r.get("settings"))&&void 0!==e?e:"")==="1"),J=(0,h.C)(),{correspondenceWi
1dthPx:X,setCorrespondenceWidthPx:ea,settingsWidthPx:es,setSettingsWidthPx:el,onMouseDownVertical:eo,onMouseDownSettings:ei}=e2(Y,B),ed=(0,et.Z)(),{notesData:ec,isRecording:eu,onClickRecord:ep,onChangeNotes:em,onToggleRecordingType:eg,recordingType:eh,isConnecting:ef,microphoneIsLoading:ex,onChangeSpeaker:eb,stopRecording:ew,language:ey,setLanguage:ej}=Q(),eS=W.handleSubmit(e=>{W.onSubmit({...e,notes:ec.notes},g,e=>{S(e),C(e[0]||""),W.setOutput(e.map(e=>({templateId:e,response:""}))),H("ai-draft")})}),eN=(0,w.useCallback)(()=>{ew(),W.reset(),em(""),eb(null),u([]),v([]),C(""),W.setOutput([]),S([]),H("notes")},[W,o,em,eb,ew]);(0,w.useEffect)(()=>{_&&(eN(),ed({clearForm:null}),P(!1))},[_,ed,eN]),(0,w.useEffect)(()=>{let e=r.get("checkout");"success"===e?(a({message:"Subscription activated! You now have unlimited generates.",type:"success",timeout:7e3}),l.invalidateQueries({queryKey:["userProfile"]}),ed({checkout:null})):"cancelled"===e&&ed({checkout:null})},[r]);let eE=(0,w.useRef)(Y);eE.current=Y;let eC=(0,w.useRef)(es);(0,w.useEffect)(()=>{eC.current=es},[es]);let ek=(0,w.useRef)(B);(0,w.useEffect)(()=>{ek.current=B},[B]),(0,w.useEffect)(()=>{var e;let t=(null!==(e=r.get("settings"))&&void 0!==e?e:"")==="1";if(t&&!n){ed({settings:null});return}let a=window.innerWidth>=768&&window.innerWidth<992;if(t&&!eE.current){if(a){let e=document.getElementById(x.UE.DocumentAppearHere),t=null==e?void 0:e.getBoundingClientRect().width;el(t&&t>0?t:.6*window.innerWidth),U(!0)}else{let e=window.innerWidth/3;el(e),ea(e)}}else!t&&eE.current&&(ek.current?ea(eC.current):ea(null),U(!1));$(t),t&&!J&&H("settings")},[r,J,n]),(0,w.useEffect)(()=>{if(Y&&Z&&!(F&&!M)&&B){U(!1);let e=window.innerWidth/3;el(e),ea(e)}},[F,M,Y,Z,B]),(0,w.useEffect)(()=>{let{data:{subscription:e}}=t.auth.onAuthStateChange(async e=>{"SIGNED_OUT"===e&&eN()});return()=>{null==e||e.unsubscribe()}},[eN]);let eD=Array.isArray(W.output)?W.output:[],eI=j.map(e=>(null!=D?D:[]).find(t=>t.value===e)).filter(e=>!!e);(0,w.useEffect)(()=>{!(eI.length>0)||E&&eI.find(e=>e.value===E)||C(eI[0].value)},[eI,E]);let[eL,eO]=(0,w.useState)(0);(0,w.useEffect)(()=>{if(W.isOutputBeingGenerated){eO(0);let e=setInterval(()=>{eO(t=>{let n=t+.9;return n>=90?(clearInterval(e),98):n})},100);return()=>clearInterval(e)}W.output.length},[W.isOutputBeingGenerated]);let eR=(0,s.jsx)("div",{style:Z?B?{display:"none"}:{minWidth:350,maxWidth:F?"75%":void 0,width:F?null!=X?X:"60%":void 0}:{},className:"flex p-3 pb-0 md:pb-0 border-custom-pink flex-col border md:h-full bg-white rounded md:w-[60%] h-full overflow-hidden",id:x.UE.DocumentAppearHere,children:(null==eI?void 0:eI.length)===0?(0,s.jsxs)("div",{className:"w-full flex-1 flex flex-col gap-2 items-center justify-center",children:[(0,s.jsx)("div",{className:"w-full flex items-center justify-center",children:(0,s.jsx)("p",{className:"font-medium select-none text-[0.9rem]",children:W.isOutputBeingGenerated?(0,s.jsx)(s.Fragment,{children:(0,s.jsx)("p",{children:"Generating Documents..."})}):"Generated Documents will appear here..."})}),(0,s.jsx)("div",{className:"w-9/12",children:W.isOutputBeingGenerated&&(0,s.jsx)("div",{className:"w-full",children:(0,s.jsx)(e5,{progress:eL})})})]}):(0,s.jsxs)(R.mQ,{value:E,onValueChange:C,className:"w-full h-full flex flex-col overflow-hidden",children:[(0,s.jsxs)(A,{className:"w-full whitespace-nowrap shrink-0",children:[(0,s.jsx)(R.dr,{className:"overflow-x-auto scrollbar-hide",children:null==eI?void 0:eI.map(e=>(0,s.jsx)(R.SP,{value:e.value,className:"whitespace-nowrap",children:e.name},e.value))}),(0,s.jsx)(O,{orientation:"horizontal"})]}),null==eI?void 0:eI.map(e=>{var t;let n=eD.find(t=>t.templateId===e.value),r=W.failedRequests.includes(e.value);return(0,s.jsx)(R.nU,{value:e.value,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:n&&"Failed to process request."!==n.response?(0,s.jsx)(ev,{onCopyToClipBoard:()=>W.copyToClipboard(e.value),setOutput:t=>W.setOutput([{templateId:e.value,response:t}]),output:n.response,isOutputBeingGenerated:W.isOutputBeingGenerated,progressNote:e.name}):r?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-red-500",children:"Failed to generate document."}),(0,s.jsx)("button",{onClick:()=>W.onSubmit({...W.getValues(),templateId:e.value,notes:ec.notes}),className:"btn bg-red-500 text-white px-4 py-1 rounded",children:"Retry"})]}):W.isOutputBeingGenerated&&(!n||""===n.response)?(0,s.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center",children:[(0,s.jsx)("p",{className:"font-medium select-none text-[0.9rem] mb-2",children:"Generating Documents..."}),(0,s.jsx)("div",{className:"w-9/12",children:(0,s.jsx)(e5,{progress:eL})})]}):(0,s.jsx)(ev,{onCopyToClipBoard:()=>W.copyToClipboard(e.value),setOutput:t=>{let n=(Array.isArray(W.output)?W.output:[]).filter(t=>t.templateId!==e.value);W.setOutput([...n,{templateId:e.value,response:t}])},output:null!==(t=null==n?void 0:n.response)&&void 0!==t?t:"",isOutputBeingGenerated:W.
1isOutputBeingGenerated})},e.value)})]})}),e_=(0,w.useMemo)(()=>(0,s.jsx)(e1.v,{}),[]),eP=(0,s.jsx)("div",{style:Z?{width:F?es:void 0,minWidth:F?es:void 0}:{},className:"hidden md:flex p-3 pb-0 md:pb-0 border-gray-300 flex-col border md:h-full bg-white rounded",children:e_}),eF=(0,s.jsx)("div",{className:" flex-grow relative h-full md:min-w-[350px]",children:(0,s.jsxs)("div",{className:"md:absolute md:inset-0 flex flex-col h-full",children:[(0,s.jsx)(eB,{recordingType:eh,onToggleRecordingType:eg,onChangeNotes:em,notes:ec.notes,reset:eN,onClickRecord:ep,isConnecting:ef||ex,isRecording:eu,stopRecording:ew,language:ey,onChangeLanguage:ej}),(0,s.jsx)(eA,{stopRecording:ew}),(0,s.jsx)(I,{onChangeTemplateId:e=>{v(e),u(e)},currentTemplateIds:g,notes:ec.notes,isOutputBeingGenerated:W.isOutputBeingGenerated,stopRecording:ew,isLimitReached:W.isLimitReached})]})});return(0,w.useEffect)(()=>{let e;let t=()=>{clearTimeout(e),e=setTimeout(()=>{let e=localStorage.getItem("tourShownAt"),t=new Date,r=(!e||!(e=>{let n=new Date(e);return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()})(e))&&!n&&""!==ec.notes,a=()=>{f.q.getState().landingDialogOpen?setTimeout(a,500):J?d():e0()};r&&a()},L.current)},r=["keydown","click","keypress","scroll","touchstart"];return r.forEach(e=>{window.addEventListener(e,t)}),t(),()=>{clearTimeout(e),r.forEach(e=>{window.removeEventListener(e,t)})}},[n,ec.notes,J]),(0,s.jsx)(y.RV,{...W,children:(0,s.jsxs)("form",{onSubmit:eS,className:"h-full w-full relative flex flex-col justify-between",children:[J&&(0,s.jsxs)("div",{className:"hidden w-full md:flex flex-col md:flex-row gap-2 md:gap-0 md:flex-1 md:min-h-0 relative md:justify-center",children:[eF,!B&&(0,s.jsx)("button",{type:"button",className:"h-full w-2.5 flex-shrink-0 md:flex items-center justify-center cursor-ew-resize hidden group",onMouseDown:eo,children:(0,s.jsx)("div",{className:"w-0.5 h-16 rounded-lg bg-gray-300 group-hover:bg-gray-400"})}),eR,Y&&(0,s.jsx)("button",{type:"button",className:"h-full w-2.5 flex-shrink-0 md:flex items-center justify-center cursor-ew-resize hidden group",onMouseDown:ei,children:(0,s.jsx)("div",{className:"w-0.5 h-16 rounded-lg bg-gray-300 group-hover:bg-gray-400"})}),Y&&eP]}),!J&&(0,s.jsxs)(R.mQ,{value:V,onValueChange:e=>H(e),className:"w-full h-full flex flex-col justify-between md:hidden",children:[(0,s.jsxs)("div",{className:"flex-grow w-full relative overflow-scroll",children:[(0,s.jsx)(R.nU,{value:"notes",className:" absolute inset-0",children:eF}),(0,s.jsx)(R.nU,{className:"absolute inset-0",value:"ai-draft",children:eR}),(0,s.jsx)(R.nU,{className:"absolute inset-0",value:"settings",children:(0,s.jsx)("div",{className:"h-full w-full p-2",children:(0,s.jsx)(e1.v,{})})})]}),(0,s.jsx)("div",{className:"w-full flex items-center justify-center mt-3 mb-1.5 px-0.5",children:(0,s.jsxs)(R.dr,{className:"w-full h-12",children:[(0,s.jsx)(R.SP,{className:"w-full h-full text-lg",value:"notes",children:"Notes"}),(0,s.jsx)(R.SP,{className:"w-full text-lg",value:"ai-draft",children:"AI Draft"}),(0,s.jsx)(R.SP,{className:"w-full text-lg ",value:"settings",disabled:!n,children:"Settings"})]})})]})]})})}let e5=e=>{let{progress:t}=e,[n,r]=(0,w.useState)("0%");return(0,w.useEffect)(()=>{r("".concat(t,"%"))},[t]),(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("div",{className:"w-full bg-gray-200 h-1 absolute rounded-md overflow-hidden",children:(0,s.jsx)("div",{className:"progress-bar transition-all duration-0 ease-in-out rounded-md",style:{width:n}})})})}},42444:function(e,t,n){"use strict";n.d(t,{B:function(){return y}});var r=n(57437),a=n(36976),s=n(26358),l=n(97928),o=n(61994),i=n(2265),d=n(80338),c=n(16219),u=n(95713),p=n(29501),m=n(34422);let g=m.Ry({to:m.Z_().required("Email address is required").matches(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/,"Please enter a valid email address"),subject:m.Z_().required("Subject is required"),email:m.Z_().required("Email content is required")}).required(),h=(e,t)=>{var n;let r=(0,c.s)(e=>e.currentTemplateIds),{data:a}=(0,d.i3)(),s=null==a?void 0:a.find(e=>r.includes(e.id)),l=(0,p.cI)({resolver:(0,u.X)(g),defaultValues:{to:"",subject:"".concat(null!==(n=null==s?void 0:s.name)&&void 0!==n?n:""," - Confidential"),email:"".concat(f,"\n\n").concat(e)},mode:"onBlur"}),{reset:o}=l;return(0,i.useEffect)(()=>{s&&o(e=>({...e,subject:"".concat(s.name," - Confidential")}))},[s,o]),l},f="Hi,\n\nAttached below, please find a letter regarding a recent patient session. Your attention to this document and any necessary follow-up would be greatly appreciated.\n\n--";var x=n(40656),v=n(39878),b=n(10534),w=n(9442);let y=e=>{let{children:t,output:n,letterType:d}=e,{openModal:c}=(0,v.d)(),[u,p]=(0,i.useState)(!1),{register:m,handleSubmit:g,formState:{errors:f,isValid:y},watch:j}=h(n,d),{showToast:S}=(0,x.l)(),{data:N}=(0,a.pg)(),[E,C]=(0,i.useState)(!1),k=async e=>{C(!0);let{to:t,subject:n,email:r}=e;w.nT.track(w.w$.EMAIL_SENT),(await fetch("/api/send-email",{method:"POST",body:JSON.stringify({to:t,
1subject:n,text:r}),headers:{"Content-Type":"application/json"}})).ok||C(!1),S({message:"Email Sent",type:"success"}),C(!1)};return j("email"),(0,r.jsxs)(l.fC,{open:u,onOpenChange:p,children:[(0,r.jsx)(l.xz,{onClick:()=>{if(!N)return c(b.u_.Auth,{heading:"Sign In to access this feature"});w.nT.track(w.w$.OPENED_EMAIL_DIALOG)},asChild:!0,children:t}),(0,r.jsxs)(l.h_,{children:[(0,r.jsx)(l.aV,{className:"fixed inset-0 bg-black bg-opacity-50 z-10"}),(0,r.jsx)(l.VY,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white rounded-lg shadow-lg p-6 w-[50vw] min-w-[400px] z-50",children:(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e.stopPropagation(),g(k)(e).then(()=>{p(!1)})},children:[(0,r.jsx)(l.Dx,{className:" m-0 text-[19px] font-bold mb-5",children:"Encrypt and Send"}),(0,r.jsxs)("div",{className:"flex flex-col",children:[(0,r.jsx)("h6",{className:"font-bold text-sm",children:"To"}),(0,r.jsx)("input",{placeholder:"[email protected]",className:(0,o.Z)("border my-2 p-1 px-2 rounded-md w-full text-sm",f.to&&"border-[#FF0000]"),...m("to")}),f.to&&(0,r.jsx)("div",{className:"relative",children:(0,r.jsx)("span",{className:"text-red-500 text-sm absolute -bottom-[10px]",children:f.to.message})}),(0,r.jsx)("h6",{className:"font-bold text-sm mt-3",children:"Subject"}),(0,r.jsx)("input",{disabled:!0,readOnly:!0,className:"border my-2 p-1 px-2 rounded-md w-full text-sm disabled:bg-button-disabled disabled:text-button-disabled-text",...m("subject")}),(0,r.jsx)("h6",{className:"font-bold text-sm mt-3",children:"Email"}),(0,r.jsx)("textarea",{className:(0,o.Z)("border my-2 p-1 px-2 rounded-md w-full h-[240px] text-sm"),...m("email")})]}),(0,r.jsxs)("div",{className:"flex justify-end ",children:[(0,r.jsx)(l.x8,{asChild:!0,children:(0,r.jsx)("button",{type:"button",className:"bg-[#F0F0F3] text-[#5A5E67] mr-2 hover:bg-green5 focus:shadow-green7 inline-flex h-[30px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none focus:shadow-[0_0_0_2px] focus:outline-none text-sm",children:"Cancel"})}),(0,r.jsx)("button",{disabled:!y,className:"bg-[#31A46C] text-white hover:bg-green5 focus:shadow-green7 inline-flex h-[30px] items-center justify-center rounded-[4px] px-[15px] font-medium leading-none focus:shadow-[0_0_0_2px] focus:outline-none text-sm disabled:bg-button-disabled disabled:text-button-disabled-text hover:bg-[#176541]",children:E?(0,r.jsx)(s.$,{size:"md"}):"Send"})]})]})})]})]})}},56563:function(e,t,n){"use strict";var r=n(2265);t.Z=()=>{let[e,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>t(!0),[]),e}},19639:function(e,t,n){"use strict";function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:3;if(!e)return"";if(e.length<=n+r)return e;let a=e.slice(0,n),s=e.slice(-r);return a+t.repeat(e.length-n-r)+s}function a(e){return e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():""}n.d(t,{R:function(){return r},f:function(){return a}})},69067:function(e,t,n){"use strict";n.d(t,{DeepgramContextProvider:function(){return c},YD:function(){return u},lA:function(){return l.l},xe:function(){return a.x}});var r=n(57437),a=n(93249),s=n(80790),l=n(77047),o=n(2265);let i=(0,o.createContext)(void 0),d=async()=>{let e=await fetch("/api/authenticate-dictate",{cache:"no-store"});return(await e.json()).key},c=e=>{let{children:t}=e,[n,c]=(0,o.useState)(null),[u,p]=(0,o.useState)(a.x.CLOSED),m=async(e,t)=>{let n=await d(),r=(0,s.eI)(n).listen.live(e,t);r.addListener(l.l.Open,()=>{p(a.x.OPEN)}),r.addListener(l.l.Close,()=>{p(a.x.CLOSED)}),c(r)},g=async()=>{n&&(n.finish(),c(null))};return(0,r.jsx)(i.Provider,{value:{connection:n,connectToDeepgram:m,disconnectFromDeepgram:g,connectionState:u},children:t})};function u(){let e=(0,o.useContext)(i);if(void 0===e)throw Error("useDeepgram must be used within a DeepgramContextProvider");return e}},35067:function(e,t,n){"use strict";n.d(t,{MicrophoneContextProvider:function(){return c},ZM:function(){return s},pf:function(){return u},tn:function(){return l}});var r,a,s,l,o=n(57437),i=n(2265);(r=s||(s={})).DataAvailable="dataavailable",r.Error="error",r.Pause="pause",r.Resume="resume",r.Start="start",r.Stop="stop",(a=l||(l={}))[a.NotSetup=-1]="NotSetup",a[a.SettingUp=0]="SettingUp",a[a.Ready=1]="Ready",a[a.Opening=2]="Opening",a[a.Open=3]="Open",a[a.Error=4]="Error",a[a.Pausing=5]="Pausing",a[a.Paused=6]="Paused";let d=(0,i.createContext)(void 0),c=e=>{let{children:t}=e,[n,r]=(0,i.useState)(-1),[a,s]=(0,i.useState)(null),l=(0,i.useRef)([]),c=(0,i.useRef)([]),u=(0,i.useRef)(null),p=()=>
1{l.current.forEach(e=>e.stop()),l.current=[],c.current.forEach(e=>e.stop()),c.current=[],u.current&&(u.current.close().catch(()=>{}),u.current=null)},m=async()=>{r(0);try{let e=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0}}),t=new MediaRecorder(e);r(1),s(t)}catch(e){throw console.error(e),e}},g=async()=>{r(0);let e=null,t=null;try{(e=await navigator.mediaDevices.getDisplayMedia({audio:!0,video:!0})).getVideoTracks().forEach(e=>e.stop()),t=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0}});let n=e.getAudioTracks();if(0===n.length)throw e.getTracks().forEach(e=>e.stop()),t.getTracks().forEach(e=>e.stop()),r(-1),Object.assign(Error("No audio from shared tab"),{name:"NoTabAudioError"});let a=new AudioContext,o=a.createMediaStreamDestination();a.createMediaStreamSource(t).connect(o),a.createMediaStreamSource(e).connect(o),l.current=t.getTracks(),c.current=e.getTracks(),u.current=a;let i=new MediaRecorder(o.stream);r(1),s(i)}catch(n){throw null==e||e.getTracks().forEach(e=>e.stop()),null==t||t.getTracks().forEach(e=>e.stop()),r(-1),n}},h=(0,i.useCallback)(()=>{((null==a?void 0:a.state)==="recording"||(null==a?void 0:a.state)==="paused")&&a.stop(),p(),s(null),r(-1)},[a]),f=(0,i.useCallback)(()=>{r(5),(null==a?void 0:a.state)==="recording"&&(a.pause(),r(6)),p()},[a]),x=(0,i.useCallback)(()=>{r(2),(null==a?void 0:a.state)==="paused"?a.resume():(null==a?void 0:a.state)!=="recording"&&(null==a||a.start(250)),r(3)},[a]);return(0,o.jsx)(d.Provider,{value:{microphone:a,startMicrophone:x,stopMicrophone:f,setupMicrophone:m,setupMixedMicrophone:g,resetMicrophone:h,microphoneState:n},children:t})};function u(){let e=(0,i.useContext)(d);if(void 0===e)throw Error("useMicrophone must be used within a MicrophoneContextProvider");return e}}},function(e){e.O(0,[661,339,890,603,760,310,33,563,366,880,725,786,156,314,145,709,708,601,311,402,821,971,117,744],function(){return e(e.s=44949)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.