@medplum/react 3.2.10 → 3.2.11

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.
@@ -217,6 +217,11 @@ export declare interface AsyncAutocompleteProps<T> extends Omit<ComboboxProps, '
217
217
  readonly toOption: (item: T) => AsyncAutocompleteOption<T>;
218
218
  readonly loadOptions: (input: string, signal: AbortSignal) => Promise<T[]>;
219
219
  readonly itemComponent?: (props: AsyncAutocompleteOption<T>) => JSX.Element | ReactNode;
220
+ readonly pillComponent?: (props: {
221
+ item: AsyncAutocompleteOption<T>;
222
+ disabled?: boolean;
223
+ onRemove: () => void;
224
+ }) => JSX.Element;
220
225
  readonly emptyComponent?: (props: {
221
226
  search: string;
222
227
  }) => JSX.Element | ReactNode;
@@ -217,6 +217,11 @@ export declare interface AsyncAutocompleteProps<T> extends Omit<ComboboxProps, '
217
217
  readonly toOption: (item: T) => AsyncAutocompleteOption<T>;
218
218
  readonly loadOptions: (input: string, signal: AbortSignal) => Promise<T[]>;
219
219
  readonly itemComponent?: (props: AsyncAutocompleteOption<T>) => JSX.Element | ReactNode;
220
+ readonly pillComponent?: (props: {
221
+ item: AsyncAutocompleteOption<T>;
222
+ disabled?: boolean;
223
+ onRemove: () => void;
224
+ }) => JSX.Element;
220
225
  readonly emptyComponent?: (props: {
221
226
  search: string;
222
227
  }) => JSX.Element | ReactNode;
@@ -1,4 +1,4 @@
1
- var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var require_pointer=__commonJS({"../../node_modules/rfc6902/pointer.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.Pointer=void 0;function unescape(token){return token.replace(/~1/g,"/").replace(/~0/g,"~")}function escape(token){return token.replace(/~/g,"~0").replace(/\//g,"~1")}var Pointer=function(){function Pointer2(tokens){tokens===void 0&&(tokens=[""]),this.tokens=tokens}return Pointer2.fromJSON=function(path){var tokens=path.split("/").map(unescape);if(tokens[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(path));return new Pointer2(tokens)},Pointer2.prototype.toString=function(){return this.tokens.map(escape).join("/")},Pointer2.prototype.evaluate=function(object){for(var parent=null,key="",value=object,i=1,l=this.tokens.length;i<l;i++)parent=value,key=this.tokens[i],!(key=="__proto__"||key=="constructor"||key=="prototype")&&(value=(parent||{})[key]);return{parent,key,value}},Pointer2.prototype.get=function(object){return this.evaluate(object).value},Pointer2.prototype.set=function(object,value){var endpoint=this.evaluate(object);endpoint.parent&&(endpoint.parent[endpoint.key]=value)},Pointer2.prototype.push=function(token){this.tokens.push(token)},Pointer2.prototype.add=function(token){var tokens=this.tokens.concat(String(token));return new Pointer2(tokens)},Pointer2}();exports.Pointer=Pointer}});var require_util=__commonJS({"../../node_modules/rfc6902/util.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.clone=exports.objectType=exports.hasOwnProperty=void 0;exports.hasOwnProperty=Object.prototype.hasOwnProperty;function objectType(object){return object===void 0?"undefined":object===null?"null":Array.isArray(object)?"array":typeof object}exports.objectType=objectType;function isNonPrimitive(value){return value!=null&&typeof value=="object"}function clone(source){if(!isNonPrimitive(source))return source;if(source.constructor==Array){for(var length_1=source.length,arrayTarget=new Array(length_1),i=0;i<length_1;i++)arrayTarget[i]=clone(source[i]);return arrayTarget}if(source.constructor==Date){var dateTarget=new Date(+source);return dateTarget}var objectTarget={};for(var key in source)exports.hasOwnProperty.call(source,key)&&(objectTarget[key]=clone(source[key]));return objectTarget}exports.clone=clone}});var require_diff=__commonJS({"../../node_modules/rfc6902/diff.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var util_1=require_util();function isDestructive(_a){var op=_a.op;return op==="remove"||op==="replace"||op==="copy"||op==="move"}exports.isDestructive=isDestructive;function subtract(minuend,subtrahend){var obj={};for(var add_key in minuend)util_1.hasOwnProperty.call(minuend,add_key)&&minuend[add_key]!==void 0&&(obj[add_key]=1);for(var del_key in subtrahend)util_1.hasOwnProperty.call(subtrahend,del_key)&&subtrahend[del_key]!==void 0&&delete obj[del_key];return Object.keys(obj)}exports.subtract=subtract;function intersection(objects){for(var length=objects.length,counter={},i=0;i<length;i++){var object=objects[i];for(var key in object)util_1.hasOwnProperty.call(object,key)&&object[key]!==void 0&&(counter[key]=(counter[key]||0)+1)}for(var key in counter)counter[key]<length&&delete counter[key];return Object.keys(counter)}exports.intersection=intersection;function isArrayAdd(array_operation){return array_operation.op==="add"}function isArrayRemove(array_operation){return array_operation.op==="remove"}function appendArrayOperation(base,operation){return{operations:base.operations.concat(operation),cost:base.cost+1}}function diffArrays(input,output,ptr,diff2){diff2===void 0&&(diff2=diffAny);var memo2={"0,0":{operations:[],cost:0}};function dist(i,j2){var memo_key="".concat(i,",").concat(j2),memoized=memo2[memo_key];if(memoized===void 0){if(i>0&&j2>0&&!diff2(input[i-1],output[j2-1],ptr.add(String(i-1))).length)memoized=dist(i-1,j2-1);else{var alternatives=[];if(i>0){var remove_base=dist(i-1,j2),remove_operation={op:"remove",index:i-1};alternatives.push(appendArrayOperation(remove_base,remove_operation))}if(j2>0){var add_base=dist(i,j2-1),add_operation={op:"add",index:i-1,value:output[j2-1]};alternatives.push(appendArrayOperation(add_base,add_operation))}if(i>0&&j2>0){var replace_base=dist(i-1,j2-1),replace_operation={op:"replace",index:i-1,original:input[i-1],value:output[j2-1]};alternatives.push(appendArrayOperation(replace_base,replace_operation))}var best=alternatives.sort(function(a,b2){return a.cost-b2.cost})[0];memoized=best}memo2[memo_key]=memoized}return memoized}var input_length=isNaN(input.length)||input.length<=0?0:input.length,output_length=isNaN(output.length)||output.length<=0?0:output.length,array_operations=dist(input_length,output_length).operations,padded_operations=array_operations.reduce(function(_a,array_operation){var operations=_a[0],padding=_a[1];if(isArrayAdd(array_operation)){var padded_index=array_operation.index+1+padding,index_token=padded_index<input_length+padding?String(padded_index):"-",operation={op:array_operation.op,path:ptr.add(index_token).toString(),value:array_operation.value};return[operations.concat(operation),padding+1]}else if(isArrayRemove(array_operation)){var operation={op:array_operation.op,path:ptr.add(String(array_operation.index+padding)).toString()};return[operations.concat(operation),padding-1]}else{var replace_ptr=ptr.add(String(array_operation.index+padding)),replace_operations=diff2(array_operation.original,array_operation.value,replace_ptr);return[operations.concat.apply(operations,replace_operations),padding]}},[[],0])[0];return padded_operations}exports.diffArrays=diffArrays;function diffObjects(input,output,ptr,diff2){diff2===void 0&&(diff2=diffAny);var operations=[];return subtract(input,output).forEach(function(key){operations.push({op:"remove",path:ptr.add(key).toString()})}),subtract(output,input).forEach(function(key){operations.push({op:"add",path:ptr.add(key).toString(),value:output[key]})}),intersection([input,output]).forEach(function(key){operations.push.apply(operations,diff2(input[key],output[key],ptr.add(key)))}),operations}exports.diffObjects=diffObjects;function diffAny(input,output,ptr,diff2){if(diff2===void 0&&(diff2=diffAny),input===output)return[];var input_type=(0,util_1.objectType)(input),output_type=(0,util_1.objectType)(output);return input_type=="array"&&output_type=="array"?diffArrays(input,output,ptr,diff2):input_type=="object"&&output_type=="object"?diffObjects(input,output,ptr,diff2):[{op:"replace",path:ptr.toString(),value:output}]}exports.diffAny=diffAny}});var require_patch=__commonJS({"../../node_modules/rfc6902/patch.js"(exports){"use strict";var __extends=exports&&exports.__extends||function(){var extendStatics=function(d,b2){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d2,b3){d2.__proto__=b3}||function(d2,b3){for(var p2 in b3)Object.prototype.hasOwnProperty.call(b3,p2)&&(d2[p2]=b3[p2])},extendStatics(d,b2)};return function(d,b2){if(typeof b2!="function"&&b2!==null)throw new TypeError("Class extends value "+String(b2)+" is not a constructor or null");extendStatics(d,b2);function __(){this.constructor=d}d.prototype=b2===null?Object.create(b2):(__.prototype=b2.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var pointer_1=require_pointer(),util_1=require_util(),diff_1=require_diff(),MissingError=function(_super){__extends(MissingError2,_super);function MissingError2(path){var _this=_super.call(this,"Value required at path: ".concat(path))||this;return _this.path=path,_this.name="MissingError",_this}return MissingError2}(Error);exports.MissingError=MissingError;var TestError=function(_super){__extends(TestError2,_super);function TestError2(actual,expected){var _this=_super.call(this,"Test failed: ".concat(actual," != ").concat(expected))||this;return _this.actual=actual,_this.expected=expected,_this.name="TestError",_this}return TestError2}(Error);exports.TestError=TestError;function _add(object,key,value){if(Array.isArray(object))if(key=="-")object.push(value);else{var index=parseInt(key,10);object.splice(index,0,value)}else object[key]=value}function _remove(object,key){if(Array.isArray(object)){var index=parseInt(key,10);object.splice(index,1)}else delete object[key]}function add(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_add(endpoint.parent,endpoint.key,(0,util_1.clone)(operation.value)),null)}exports.add=add;function remove(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.value===void 0?new MissingError(operation.path):(_remove(endpoint.parent,endpoint.key),null)}exports.remove=remove;function replace(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);if(endpoint.parent===null)return new MissingError(operation.path);if(Array.isArray(endpoint.parent)){if(parseInt(endpoint.key,10)>=endpoint.parent.length)return new MissingError(operation.path)}else if(endpoint.value===void 0)return new MissingError(operation.path);return endpoint.parent[endpoint.key]=(0,util_1.clone)(operation.value),null}exports.replace=replace;function move(object,operation){var from_endpoint=pointer_1.Pointer.fromJSON(operation.from).evaluate(object);if(from_endpoint.value===void 0)return new MissingError(operation.from);var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_remove(from_endpoint.parent,from_endpoint.key),_add(endpoint.parent,endpoint.key,from_endpoint.value),null)}exports.move=move;function copy(object,operation){var from_endpoint=pointer_1.Pointer.fromJSON(operation.from).evaluate(object);if(from_endpoint.value===void 0)return new MissingError(operation.from);var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_add(endpoint.parent,endpoint.key,(0,util_1.clone)(from_endpoint.value)),null)}exports.copy=copy;function test(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return(0,diff_1.diffAny)(endpoint.value,operation.value,new pointer_1.Pointer).length?new TestError(endpoint.value,operation.value):null}exports.test=test;var InvalidOperationError=function(_super){__extends(InvalidOperationError2,_super);function InvalidOperationError2(operation){var _this=_super.call(this,"Invalid operation: ".concat(operation.op))||this;return _this.operation=operation,_this.name="InvalidOperationError",_this}return InvalidOperationError2}(Error);exports.InvalidOperationError=InvalidOperationError;function apply(object,operation){switch(operation.op){case"add":return add(object,operation);case"remove":return remove(object,operation);case"replace":return replace(object,operation);case"move":return move(object,operation);case"copy":return copy(object,operation);case"test":return test(object,operation)}return new InvalidOperationError(operation)}exports.apply=apply}});var require_rfc6902=__commonJS({"../../node_modules/rfc6902/index.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.createTests=exports.createPatch=exports.applyPatch=exports.Pointer=void 0;var pointer_1=require_pointer();Object.defineProperty(exports,"Pointer",{enumerable:!0,get:function(){return pointer_1.Pointer}});var patch_1=require_patch(),diff_1=require_diff();function applyPatch(object,patch){return patch.map(function(operation){return(0,patch_1.apply)(object,operation)})}exports.applyPatch=applyPatch;function wrapVoidableDiff(diff2){function wrappedDiff(input,output,ptr){var custom_patch=diff2(input,output,ptr);return Array.isArray(custom_patch)?custom_patch:(0,diff_1.diffAny)(input,output,ptr,wrappedDiff)}return wrappedDiff}function createPatch2(input,output,diff2){var ptr=new pointer_1.Pointer;return(diff2?wrapVoidableDiff(diff2):diff_1.diffAny)(input,output,ptr)}exports.createPatch=createPatch2;function createTest(input,path){var endpoint=pointer_1.Pointer.fromJSON(path).evaluate(input);if(endpoint!==void 0)return{op:"test",path,value:endpoint.value}}function createTests(input,patch){var tests=new Array;return patch.filter(diff_1.isDestructive).forEach(function(operation){var pathTest=createTest(input,operation.path);if(pathTest&&tests.push(pathTest),"from"in operation){var fromTest=createTest(input,operation.from);fromTest&&tests.push(fromTest)}}),tests}exports.createTests=createTests}});import{useEffect as _,useMemo as Q,useState as A}from"react";import{createContext as D,useContext as z}from"react";import{jsx as J}from"react/jsx-runtime";import{useMemo as X}from"react";import{useEffect as q,useRef as G}from"react";import{deepEquals as H,isReference as w,isResource as Y,normalizeOperationOutcome as Z}from"@medplum/core";import{useCallback as $,useEffect as j,useState as ee}from"react";import{allOk as te,normalizeOperationOutcome as ne}from"@medplum/core";import{useEffect as re,useState as v}from"react";import{deepEquals as F}from"@medplum/core";import{useCallback as R,useEffect as y,useRef as p,useState as B}from"react";var O=D(void 0);function T(){return z(O)}function b(){return T().medplum}function se(){return T().navigate}function ue(){return T().profile}var N=["change","storageInitialized","storageInitFailed","profileRefreshing","profileRefreshed"];function me(e){let t=e.medplum,n=e.navigate??V,[i,r2]=A({profile:t.getProfile(),loading:t.isLoading()});_(()=>{function o(){r2(u=>({...u,profile:t.getProfile(),loading:t.isLoading()}))}for(let u of N)t.addEventListener(u,o);return()=>{for(let u of N)t.removeEventListener(u,o)}},[t]);let s=Q(()=>({...i,medplum:t,navigate:n}),[i,t,n]);return J(O.Provider,{value:s,children:e.children})}function V(e){window.location.assign(e)}var U=new Map,Se=e=>X(()=>{if(!e)return;let t=e.split("?")[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has("Key-Pair-Id")||!n.has("Signature"))return e;let i=n.get("Expires");if(!i||i.length>13)return e;let r2=U.get(t);if(r2){let o=new URLSearchParams(new URL(r2).search).get("Expires");if(o&&parseInt(o,10)*1e3-5e3>Date.now())return r2}return U.set(t,e),e},[e]);function xe(e){let t=G();return q(()=>{t.current=e}),t.current}function Te(e,t){let n=b(),[i,r2]=ee(()=>W(n,e)),s=$(o=>{H(o,i)||r2(o)},[i]);return j(()=>{let o=!0,u=W(n,e);return!u&&w(e)?n.readReference(e).then(a=>{o&&s(a)}).catch(a=>{o&&(s(void 0),t&&t(Z(a)))}):s(u),()=>o=!1},[n,e,s,t]),i}function W(e,t){if(t){if(Y(t))return t;if(w(t))return e.getCachedReference(t)}}function Ne(e,t){return P("search",e,t)}function Ue(e,t){return P("searchOne",e,t)}function We(e,t){return P("searchResources",e,t)}function P(e,t,n){let i=b(),[r2,s]=v(),[o,u]=v(!0),[a,d]=v(),[f,m]=v();return re(()=>{let S=i.fhirSearchUrl(t,n).toString();S!==r2&&(s(S),i[e](t,n).then(l=>{u(!1),d(l),m(te)}).catch(l=>{u(!1),d(void 0),m(ne(l))}))},[i,e,t,n,r2]),[a,o,f]}var oe=3e3;function Qe(e,t,n){let i=b(),[r2,s]=B(),[o,u]=B(n?.subscriptionProps),a=p(!1),d=p(),f=p(),m=p(),S=p();S.current=t;let l=p();l.current=n?.onWebSocketOpen;let L=p();L.current=n?.onWebSocketClose;let K=p();K.current=n?.onSubscriptionConnect;let k=p();k.current=n?.onSubscriptionDisconnect;let I=p();I.current=n?.onError,y(()=>{F(n?.subscriptionProps,o)||u(n?.subscriptionProps)},[o,n]),y(()=>{d.current&&(clearTimeout(d.current),d.current=void 0);let c=!1;return(f.current!==e||!F(m.current,o))&&(c=!0),c&&f.current&&i.unsubscribeFromCriteria(f.current,m.current),f.current=e,m.current=o,c&&s(i.subscribeToCriteria(e,o)),()=>{d.current=setTimeout(()=>{s(void 0),i.unsubscribeFromCriteria(e,o)},oe)}},[i,e,o]);let E=R(c=>{S.current?.(c.payload)},[]),x=R(()=>{l.current?.()},[]),g=R(()=>{L.current?.()},[]),C=R(c=>{K.current?.(c.payload.subscriptionId)},[]),h=R(c=>{k.current?.(c.payload.subscriptionId)},[]),M=R(c=>{I.current?.(c.payload)},[]);y(()=>r2?(a.current||(r2.addEventListener("message",E),r2.addEventListener("open",x),r2.addEventListener("close",g),r2.addEventListener("connect",C),r2.addEventListener("disconnect",h),r2.addEventListener("error",M),a.current=!0),()=>{a.current=!1,r2.removeEventListener("message",E),r2.removeEventListener("open",x),r2.removeEventListener("close",g),r2.removeEventListener("connect",C),r2.removeEventListener("disconnect",h),r2.removeEventListener("error",M)}):()=>{},[r2,E,x,g,C,h,M])}import{formatAddress}from"@medplum/core";import{Fragment,jsx}from"react/jsx-runtime";function AddressDisplay(props){let address=props.value;return address?jsx(Fragment,{children:formatAddress(address)}):null}import{Group,NativeSelect,TextInput}from"@mantine/core";import{useContext,useMemo,useRef,useState}from"react";import{isPopulated}from"@medplum/core";import{createContext}from"react";var DEFAULT_IGNORED_PROPERTIES=["meta","implicitRules","contained","extension","modifierExtension"],DEFAULT_IGNORED_NON_NESTED_PROPERTIES=["language","text"];var ElementsContext=createContext({path:"",profileUrl:void 0,elements:Object.create(null),elementsByPath:Object.create(null),getExtendedProps:()=>({readonly:!1,hidden:!1}),accessPolicyResource:void 0,debugMode:!1,isDefaultContext:!0});ElementsContext.displayName="ElementsContext";var EXTENSION_KEYS=["extension","modifierExtension"],IGNORED_PROPERTIES=["id",...DEFAULT_IGNORED_PROPERTIES].filter(prop=>!EXTENSION_KEYS.includes(prop));function getElementsToRender(inputElements){return Object.entries(inputElements).filter(([key,element])=>!isPopulated(element.type)||element.max===0||element.path.toLowerCase().endsWith("extension.url")&&element.fixed||EXTENSION_KEYS.includes(key)&&!isPopulated(element.slicing?.slices)||IGNORED_PROPERTIES.includes(key)?!1:!(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&element.path.split(".").length===2||key.includes(".")))}import{jsx as jsx2,jsxs}from"react/jsx-runtime";function getLine(address,index){return address.line&&address.line.length>index?address.line[index]:""}function setLine(address,index,str){let line=address.line||[];for(;line.length<=index;)line.push("");return line[index]=str,{...address,line}}function AddressInput(props){let[value,setValue]=useState(props.defaultValue||{}),valueRef=useRef();valueRef.current=value;let{getExtendedProps}=useContext(ElementsContext),[useProps,typeProps,line1Props,line2Props,cityProps,stateProps,postalCodeProps]=useMemo(()=>["use","type","line1","line2","city","state","postalCode"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}function setUse(use){setValueWrapper({...valueRef.current,use})}function setType(type){setValueWrapper({...valueRef.current,type})}function setLine1(line1){setValueWrapper(setLine(valueRef.current||{},0,line1))}function setLine2(line2){setValueWrapper(setLine(valueRef.current||{},1,line2))}function setCity(city){setValueWrapper({...valueRef.current,city})}function setState(state){setValueWrapper({...valueRef.current,state})}function setPostalCode(postalCode){setValueWrapper({...valueRef.current,postalCode})}return jsxs(Group,{gap:"xs",wrap:"nowrap",grow:!0,children:[jsx2(NativeSelect,{disabled:props.disabled||useProps?.readonly,"data-testid":"address-use",defaultValue:value.use,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","billing"]}),jsx2(NativeSelect,{disabled:props.disabled||typeProps?.readonly,"data-testid":"address-type",defaultValue:value.type,onChange:e=>setType(e.currentTarget.value),data:["","postal","physical","both"]}),jsx2(TextInput,{disabled:props.disabled||line1Props?.readonly,placeholder:"Line 1",defaultValue:getLine(value,0),onChange:e=>setLine1(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||line2Props?.readonly,placeholder:"Line 2",defaultValue:getLine(value,1),onChange:e=>setLine2(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||cityProps?.readonly,placeholder:"City",defaultValue:value.city,onChange:e=>setCity(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||stateProps?.readonly,placeholder:"State",defaultValue:value.state,onChange:e=>setState(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||postalCodeProps?.readonly,placeholder:"Postal Code",defaultValue:value.postalCode,onChange:e=>setPostalCode(e.currentTarget.value)})]})}import{TextInput as TextInput2}from"@mantine/core";import{createReference}from"@medplum/core";import{useState as useState2}from"react";import{jsx as jsx3}from"react/jsx-runtime";function AnnotationInput(props){let author=ue(),[value,setValue]=useState2(props.defaultValue||{});function setText(text){let newValue=text?{text,authorReference:author&&createReference(author),time:new Date().toISOString()}:{};setValue(newValue),props.onChange&&props.onChange(newValue)}return jsx3(TextInput2,{disabled:props.disabled,name:props.name,placeholder:"Annotation text",defaultValue:value.text,onChange:e=>setText(e.currentTarget.value)})}import{AppShell as MantineAppShell3}from"@mantine/core";import{showNotification as showNotification3}from"@mantine/notifications";import{Suspense,useEffect as useEffect2,useState as useState8}from"react";import{Alert}from"@mantine/core";import{normalizeErrorString}from"@medplum/core";import{forwardRef,createElement}from"react";var defaultAttributes={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};var createReactComponent=(type,iconName,iconNamePascal,iconNode)=>{let Component2=forwardRef(({color="currentColor",size=24,stroke=2,title,className,children,...rest},ref)=>createElement("svg",{ref,...defaultAttributes[type],width:size,height:size,className:["tabler-icon",`tabler-icon-${iconName}`,className].join(" "),...type==="filled"?{fill:color}:{strokeWidth:stroke,stroke:color},...rest},[title&&createElement("title",{key:"svg-title"},title),...iconNode.map(([tag,attrs])=>createElement(tag,attrs)),...Array.isArray(children)?children:[children]]));return Component2.displayName=`${iconNamePascal}`,Component2};var IconAdjustmentsHorizontal=createReactComponent("outline","adjustments-horizontal","IconAdjustmentsHorizontal",[["path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M4 6l8 0",key:"svg-1"}],["path",{d:"M16 6l4 0",key:"svg-2"}],["path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-3"}],["path",{d:"M4 12l2 0",key:"svg-4"}],["path",{d:"M10 12l10 0",key:"svg-5"}],["path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-6"}],["path",{d:"M4 18l11 0",key:"svg-7"}],["path",{d:"M19 18l1 0",key:"svg-8"}]]);var IconAlertCircle=createReactComponent("outline","alert-circle","IconAlertCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]);var IconArrowDown=createReactComponent("outline","arrow-down","IconArrowDown",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 13l-6 6",key:"svg-1"}],["path",{d:"M6 13l6 6",key:"svg-2"}]]);var IconArrowRight=createReactComponent("outline","arrow-right","IconArrowRight",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M13 18l6 -6",key:"svg-1"}],["path",{d:"M13 6l6 6",key:"svg-2"}]]);var IconArrowUp=createReactComponent("outline","arrow-up","IconArrowUp",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 11l-6 -6",key:"svg-1"}],["path",{d:"M6 11l6 -6",key:"svg-2"}]]);var IconBleachOff=createReactComponent("outline","bleach-off","IconBleachOff",[["path",{d:"M5 19h14m1.986 -1.977a2 2 0 0 0 -.146 -.773l-7.1 -12.25a2 2 0 0 0 -3.5 0l-.815 1.405m-1.488 2.568l-4.797 8.277a2 2 0 0 0 1.75 2.75",key:"svg-0"}],["path",{d:"M3 3l18 18",key:"svg-1"}]]);var IconBleach=createReactComponent("outline","bleach","IconBleach",[["path",{d:"M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75",key:"svg-0"}]]);var IconBoxMultiple=createReactComponent("outline","box-multiple","IconBoxMultiple",[["path",{d:"M7 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2",key:"svg-1"}]]);var IconBracketsContain=createReactComponent("outline","brackets-contain","IconBracketsContain",[["path",{d:"M7 4h-4v16h4",key:"svg-0"}],["path",{d:"M17 4h4v16h-4",key:"svg-1"}],["path",{d:"M8 16h.01",key:"svg-2"}],["path",{d:"M12 16h.01",key:"svg-3"}],["path",{d:"M16 16h.01",key:"svg-4"}]]);var IconBucketOff=createReactComponent("outline","bucket-off","IconBucketOff",[["path",{d:"M5.029 5.036c-.655 .58 -1.029 1.25 -1.029 1.964c0 2.033 3.033 3.712 6.96 3.967m3.788 -.21c3.064 -.559 5.252 -2.029 5.252 -3.757c0 -2.21 -3.582 -4 -8 -4c-1.605 0 -3.1 .236 -4.352 .643",key:"svg-0"}],["path",{d:"M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.1 -.3 .252 -.812 .457 -1.535m.862 -3.146c.262 -.975 .735 -2.76 1.418 -5.354a7.45 7.45 0 0 0 .263 -1.965",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]]);var IconBucket=createReactComponent("outline","bucket","IconBucket",[["path",{d:"M12 7m-8 0a8 4 0 1 0 16 0a8 4 0 1 0 -16 0",key:"svg-0"}],["path",{d:"M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.333 -1 1.246 -4.345 2.737 -10.035a7.45 7.45 0 0 0 .263 -1.965",key:"svg-1"}]]);var IconCalendar=createReactComponent("outline","calendar","IconCalendar",[["path",{d:"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12z",key:"svg-0"}],["path",{d:"M16 3v4",key:"svg-1"}],["path",{d:"M8 3v4",key:"svg-2"}],["path",{d:"M4 11h16",key:"svg-3"}],["path",{d:"M11 15h1",key:"svg-4"}],["path",{d:"M12 15v3",key:"svg-5"}]]);var IconCheck=createReactComponent("outline","check","IconCheck",[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]]);var IconCheckbox=createReactComponent("outline","checkbox","IconCheckbox",[["path",{d:"M9 11l3 3l8 -8",key:"svg-0"}],["path",{d:"M20 12v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h9",key:"svg-1"}]]);var IconChevronDown=createReactComponent("outline","chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]);var IconChevronUp=createReactComponent("outline","chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]);var IconCircleMinus=createReactComponent("outline","circle-minus","IconCircleMinus",[["path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l6 0",key:"svg-1"}]]);var IconCirclePlus=createReactComponent("outline","circle-plus","IconCirclePlus",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 12h6",key:"svg-1"}],["path",{d:"M12 9v6",key:"svg-2"}]]);var IconCloudUpload=createReactComponent("outline","cloud-upload","IconCloudUpload",[["path",{d:"M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1",key:"svg-0"}],["path",{d:"M9 15l3 -3l3 3",key:"svg-1"}],["path",{d:"M12 12l0 9",key:"svg-2"}]]);var IconColumns=createReactComponent("outline","columns","IconColumns",[["path",{d:"M4 6l5.5 0",key:"svg-0"}],["path",{d:"M4 10l5.5 0",key:"svg-1"}],["path",{d:"M4 14l5.5 0",key:"svg-2"}],["path",{d:"M4 18l5.5 0",key:"svg-3"}],["path",{d:"M14.5 6l5.5 0",key:"svg-4"}],["path",{d:"M14.5 10l5.5 0",key:"svg-5"}],["path",{d:"M14.5 14l5.5 0",key:"svg-6"}],["path",{d:"M14.5 18l5.5 0",key:"svg-7"}]]);var IconCopy=createReactComponent("outline","copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);var IconCurrencyDollar=createReactComponent("outline","currency-dollar","IconCurrencyDollar",[["path",{d:"M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2",key:"svg-0"}],["path",{d:"M12 3v3m0 12v3",key:"svg-1"}]]);var IconDots=createReactComponent("outline","dots","IconDots",[["path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var IconEdit=createReactComponent("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);var IconEqualNot=createReactComponent("outline","equal-not","IconEqualNot",[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}],["path",{d:"M5 19l14 -14",key:"svg-2"}]]);var IconEqual=createReactComponent("outline","equal","IconEqual",[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}]]);var IconFileAlert=createReactComponent("outline","file-alert","IconFileAlert",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 17l.01 0",key:"svg-2"}],["path",{d:"M12 11l0 3",key:"svg-3"}]]);var IconFilePlus=createReactComponent("outline","file-plus","IconFilePlus",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]]);var IconFilter=createReactComponent("outline","filter","IconFilter",[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z",key:"svg-0"}]]);var IconGenderFemale=createReactComponent("outline","gender-female","IconGenderFemale",[["path",{d:"M12 9m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0",key:"svg-0"}],["path",{d:"M12 14v7",key:"svg-1"}],["path",{d:"M9 18h6",key:"svg-2"}]]);var IconGenderMale=createReactComponent("outline","gender-male","IconGenderMale",[["path",{d:"M10 14m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0",key:"svg-0"}],["path",{d:"M19 5l-5.4 5.4",key:"svg-1"}],["path",{d:"M19 5h-5",key:"svg-2"}],["path",{d:"M19 5v5",key:"svg-3"}]]);var IconLogout=createReactComponent("outline","logout","IconLogout",[["path",{d:"M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M9 12h12l-3 -3",key:"svg-1"}],["path",{d:"M18 15l3 -3",key:"svg-2"}]]);var IconMathGreater=createReactComponent("outline","math-greater","IconMathGreater",[["path",{d:"M5 18l14 -6l-14 -6",key:"svg-0"}]]);var IconMathLower=createReactComponent("outline","math-lower","IconMathLower",[["path",{d:"M19 18l-14 -6l14 -6",key:"svg-0"}]]);var IconMessage=createReactComponent("outline","message","IconMessage",[["path",{d:"M8 9h8",key:"svg-0"}],["path",{d:"M8 13h6",key:"svg-1"}],["path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12z",key:"svg-2"}]]);var IconPlus=createReactComponent("outline","plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]);var IconRefresh=createReactComponent("outline","refresh","IconRefresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]);var IconSearch=createReactComponent("outline","search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);var IconSettings=createReactComponent("outline","settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]);var IconSortAscending=createReactComponent("outline","sort-ascending","IconSortAscending",[["path",{d:"M4 6l7 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l9 0",key:"svg-2"}],["path",{d:"M15 9l3 -3l3 3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]]);var IconSortDescending=createReactComponent("outline","sort-descending","IconSortDescending",[["path",{d:"M4 6l9 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l7 0",key:"svg-2"}],["path",{d:"M15 15l3 3l3 -3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]]);var IconSquare=createReactComponent("outline","square","IconSquare",[["path",{d:"M3 3m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z",key:"svg-0"}]]);var IconStethoscope=createReactComponent("outline","stethoscope","IconStethoscope",[["path",{d:"M6 4h-1a2 2 0 0 0 -2 2v3.5h0a5.5 5.5 0 0 0 11 0v-3.5a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M8 15a6 6 0 1 0 12 0v-3",key:"svg-1"}],["path",{d:"M11 3v2",key:"svg-2"}],["path",{d:"M6 3v2",key:"svg-3"}],["path",{d:"M20 10m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-4"}]]);var IconSwitchHorizontal=createReactComponent("outline","switch-horizontal","IconSwitchHorizontal",[["path",{d:"M16 3l4 4l-4 4",key:"svg-0"}],["path",{d:"M10 7l10 0",key:"svg-1"}],["path",{d:"M8 13l-4 4l4 4",key:"svg-2"}],["path",{d:"M4 17l9 0",key:"svg-3"}]]);var IconTableExport=createReactComponent("outline","table-export","IconTableExport",[["path",{d:"M12.5 21h-7.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7.5",key:"svg-0"}],["path",{d:"M3 10h18",key:"svg-1"}],["path",{d:"M10 3v18",key:"svg-2"}],["path",{d:"M16 19h6",key:"svg-3"}],["path",{d:"M19 16l3 3l-3 3",key:"svg-4"}]]);var IconTrash=createReactComponent("outline","trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);var IconUserSquare=createReactComponent("outline","user-square","IconUserSquare",[["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M6 21v-1a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v1",key:"svg-1"}],["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z",key:"svg-2"}]]);var IconX=createReactComponent("outline","x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);import{Component}from"react";import{jsx as jsx4}from"react/jsx-runtime";var ErrorBoundary=class extends Component{constructor(props){super(props),this.state={lastLocation:window.location.toString()}}static getDerivedStateFromError(error){return{error,lastLocation:window.location.toString()}}componentDidUpdate(_prevProps,_prevState){window.location.toString()!==this.state.lastLocation&&this.setState({lastLocation:window.location.toString(),error:void 0})}shouldComponentUpdate(nextProps,nextState){return!!(this.props.children!==nextProps.children||nextState.error&&!this.state.error||this.state.lastLocation!==window.location.toString())}componentDidCatch(error,errorInfo){console.error("Uncaught error:",error,errorInfo)}render(){return this.state.error?jsx4(Alert,{icon:jsx4(IconAlertCircle,{size:16}),title:"Something went wrong",color:"red",children:normalizeErrorString(this.state.error)}):this.props.children}};import{Center,Loader}from"@mantine/core";import{jsx as jsx5}from"react/jsx-runtime";function Loading(){return jsx5(Center,{style:{width:"100%",height:"100vh"},children:jsx5(Loader,{})})}var AppShell_default={main:"AppShell_main"};import{Group as Group5,AppShell as MantineAppShell,Menu as Menu2,Text as Text3,UnstyledButton}from"@mantine/core";import{formatHumanName as formatHumanName3}from"@medplum/core";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}var clsx_default=clsx;import{useState as useState4}from"react";import{Avatar}from"@mantine/core";import{getDisplayString,getImageSrc}from"@medplum/core";import{Anchor}from"@mantine/core";import{isReference,isResource}from"@medplum/core";function killEvent(e){e.preventDefault(),e.stopPropagation()}function isCheckboxCell(el){if(isCheckboxElement(el))return!0;if(el instanceof HTMLTableCellElement){let children=el.children;if(children.length===1&&isCheckboxElement(children[0]))return!0}return!1}function isCheckboxElement(el){return el instanceof HTMLInputElement&&el.type==="checkbox"}import{jsx as jsx6}from"react/jsx-runtime";function MedplumLink(props){let navigate=se(),{to,suffix,label,onClick,children,...rest}=props,href=getHref(to);return suffix&&(href+="/"+suffix),jsx6(Anchor,{href,"aria-label":label,onClick:e=>{killEvent(e),onClick?onClick(e):to&&navigate(href)},...rest,children})}function getHref(to){if(to){if(typeof to=="string")return getStringHref(to);if(isResource(to))return getResourceHref(to);if(isReference(to))return getReferenceHref(to)}return"#"}function getStringHref(to){return to.startsWith("http://")||to.startsWith("https://")||to.startsWith("/")?to:"/"+to}function getResourceHref(to){return`/${to.resourceType}/${to.id}`}function getReferenceHref(to){return`/${to.reference}`}function getInitials(input){let words=input.split(" ").filter(Boolean);return words.length>1?words[0][0]+words[words.length-1][0]:words.length===1?words[0][0]:""}import{jsx as jsx7}from"react/jsx-runtime";function ResourceAvatar(props){let resource=Te(props.value),text=resource?getDisplayString(resource):props.alt??"",initials=getInitials(text),uncachedImageUrl=(resource&&getImageSrc(resource))??props.src,imageUrl=Se(uncachedImageUrl??void 0),radius=props.radius??"xl",avatarProps={...props,value:void 0,link:void 0};return props.link?jsx7(MedplumLink,{to:resource,children:jsx7(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}):jsx7(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}var Header_default={logoButton:"Header_logoButton",user:"Header_user",userName:"Header_userName",userActive:"Header_userActive"};import{Avatar as Avatar2,Group as Group2,Menu,SegmentedControl,Stack,Text,useMantineColorScheme}from"@mantine/core";import{getReferenceString}from"@medplum/core";import{formatHumanName}from"@medplum/core";import{Fragment as Fragment2,jsx as jsx8}from"react/jsx-runtime";function HumanNameDisplay(props){let name=props.value;return name?jsx8(Fragment2,{children:formatHumanName(name,props.options)}):null}import{Fragment as Fragment3,jsx as jsx9,jsxs as jsxs2}from"react/jsx-runtime";function HeaderDropdown(props){let context=T(),{medplum,profile,navigate}=context,logins=medplum.getLogins(),{colorScheme,setColorScheme}=useMantineColorScheme();return jsxs2(Fragment3,{children:[jsxs2(Stack,{align:"center",p:"xl",children:[jsx9(ResourceAvatar,{size:"xl",radius:100,value:context.profile}),jsx9(HumanNameDisplay,{value:context.profile?.name?.[0]}),jsx9(Text,{c:"dimmed",size:"xs",children:medplum.getActiveLogin()?.project.display})]}),logins.length>1&&jsx9(Menu.Divider,{}),logins.map(login=>login.profile.reference!==getReferenceString(context.profile)&&jsx9(Menu.Item,{onClick:()=>{medplum.setActiveLogin(login).then(()=>window.location.reload()).catch(console.log)},children:jsxs2(Group2,{children:[jsx9(Avatar2,{radius:"xl"}),jsxs2("div",{style:{flex:1},children:[jsx9(Text,{size:"sm",fw:500,children:login.profile.display}),jsx9(Text,{c:"dimmed",size:"xs",children:login.project.display})]})]})},login.profile.reference)),jsx9(Menu.Divider,{}),jsx9(Group2,{justify:"center",children:jsx9(SegmentedControl,{size:"xs",value:colorScheme,onChange:newValue=>setColorScheme(newValue),data:[{label:"Light",value:"light"},{label:"Dark",value:"dark"},{label:"Auto",value:"auto"}]})}),jsx9(Menu.Divider,{}),jsx9(Menu.Item,{leftSection:jsx9(IconSwitchHorizontal,{size:14,stroke:1.5}),onClick:()=>navigate("/signin"),children:"Add another account"}),jsx9(Menu.Item,{leftSection:jsx9(IconSettings,{size:14,stroke:1.5}),onClick:()=>navigate(`/${getReferenceString(profile)}`),children:"Account settings"}),jsx9(Menu.Item,{leftSection:jsx9(IconLogout,{size:14,stroke:1.5}),onClick:async()=>{await medplum.signOut(),navigate("/signin")},children:"Sign out"}),jsx9(Text,{size:"xs",c:"dimmed",ta:"center",children:props.version})]})}import{Group as Group4,Text as Text2}from"@mantine/core";import{formatHumanName as formatHumanName2,getDisplayString as getDisplayString2,getReferenceString as getReferenceString2,isUUID}from"@medplum/core";import{forwardRef as forwardRef2,useCallback as useCallback2}from"react";import{Combobox,Group as Group3,Loader as Loader2,Pill,PillsInput,ScrollAreaAutosize,useCombobox}from"@mantine/core";import{showNotification}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString2}from"@medplum/core";import{useCallback,useEffect,useMemo as useMemo2,useRef as useRef2,useState as useState3}from"react";var AsyncAutocompleteTestIds={selectedItems:"selected-items",options:"options"};import{jsx as jsx10,jsxs as jsxs3}from"react/jsx-runtime";function AsyncAutocomplete(props){let combobox=useCombobox({onDropdownClose:()=>combobox.resetSelectedOption(),onDropdownOpen:()=>combobox.updateSelectedOptionIndex("active")}),{name,label,description,error,defaultValue:defaultValue2,toOption:toOption4,loadOptions,itemComponent,emptyComponent,onChange,onCreate,creatable,clearable,required,placeholder,leftSection,maxValues,optionsDropdownMaxHeight=320,minInputLength=0,...rest}=props,disabled=rest.disabled,defaultItems=toDefaultItems(defaultValue2),[search,setSearch]=useState3(""),[timer,setTimer]=useState3(),[abortController,setAbortController]=useState3(),[autoSubmit,setAutoSubmit]=useState3(),[selected,setSelected]=useState3(defaultItems.map(toOption4)),[options,setOptions]=useState3([]),ItemComponent3=itemComponent??DefaultItemComponent,EmptyComponent=emptyComponent??DefaultEmptyComponent,searchRef=useRef2();searchRef.current=search;let lastLoadOptionsRef=useRef2(),lastValueRef=useRef2(),timerRef=useRef2();timerRef.current=timer;let abortControllerRef=useRef2();abortControllerRef.current=abortController;let autoSubmitRef=useRef2();autoSubmitRef.current=autoSubmit;let optionsRef=useRef2();optionsRef.current=options;let handleTimer=useCallback(()=>{if(setTimer(void 0),searchRef.current===lastValueRef.current&&loadOptions===lastLoadOptionsRef.current||(searchRef.current?.length??0)<minInputLength)return;lastValueRef.current=searchRef.current,lastLoadOptionsRef.current=loadOptions;let newAbortController=new AbortController;setAbortController(newAbortController),loadOptions(searchRef.current??"",newAbortController.signal).then(newValues=>{newAbortController.signal.aborted||(setOptions(newValues.map(toOption4)),autoSubmitRef.current?(newValues.length>0&&onChange(newValues.slice(0,1)),setAutoSubmit(!1)):newValues.length>0&&combobox.openDropdown())}).catch(err=>{newAbortController.signal.aborted||err.message.includes("aborted")||showNotification({color:"red",message:normalizeErrorString2(err)})}).finally(()=>{newAbortController.signal.aborted||setAbortController(void 0)})},[combobox,loadOptions,onChange,toOption4,minInputLength]),handleSearchChange=useCallback(e=>{(options&&options.length>0||creatable)&&combobox.openDropdown(),combobox.updateSelectedOptionIndex(),setSearch(e.currentTarget.value),abortControllerRef.current&&(abortControllerRef.current.abort(),setAbortController(void 0)),timerRef.current!==void 0&&window.clearTimeout(timerRef.current);let newTimer=window.setTimeout(()=>handleTimer(),100);setTimer(newTimer)},[combobox,options,creatable,handleTimer]),addSelected=useCallback(newValue=>{let alreadySelected=selected.some(v2=>v2.value===newValue),newSelected=alreadySelected?selected.filter(v2=>v2.value!==newValue):[...selected],option=options?.find(option2=>option2.value===newValue);if(!option&&creatable!==!1&&onCreate){let createdResource=onCreate(newValue);option=toOption4(createdResource)}if(option){if(maxValues===0){onChange([option.resource]),selected.length>0&&setSelected([]);return}alreadySelected||newSelected.push(option)}if(maxValues!==void 0)for(;newSelected.length>maxValues;)newSelected.shift();onChange(newSelected.map(v2=>v2.resource)),setSelected(newSelected)},[creatable,options,selected,maxValues,onChange,onCreate,toOption4]),handleValueSelect=useMemo2(()=>{if(!disabled)return val=>{disabled||(maxValues===1&&(setSearch(""),setOptions([]),combobox.closeDropdown()),lastValueRef.current=void 0,addSelected(val==="$create"?search:val))}},[addSelected,combobox,disabled,maxValues,search]),handleValueRemove=useCallback(item=>{let newSelected=selected.filter(v2=>v2.value!==item.value);onChange(newSelected.map(v2=>v2.resource)),setSelected(newSelected)},[selected,onChange]),handleKeyDown=useCallback(e=>{e.key==="Enter"?(timer||abortController)&&setAutoSubmit(!0):e.key==="Backspace"&&search.length===0&&(killEvent(e),handleValueRemove(selected[selected.length-1]))},[abortController,handleValueRemove,search.length,selected,timer]);useEffect(()=>()=>{abortControllerRef.current&&abortControllerRef.current.abort()},[]);let clearButton=!disabled&&clearable&&selected.length>0&&jsx10(Combobox.ClearButton,{title:"Clear all",size:16,onClear:()=>{setSearch(""),setSelected([]),onChange([]),combobox.closeDropdown()}});return jsxs3(Combobox,{store:combobox,onOptionSubmit:handleValueSelect,withinPortal:!0,shadow:"xl",...rest,children:[jsx10(Combobox.DropdownTarget,{children:jsx10(PillsInput,{label,description,error,className:props.className,leftSection,rightSection:abortController?jsx10(Loader2,{size:16}):clearButton,required,disabled,children:jsxs3(Pill.Group,{"data-testid":AsyncAutocompleteTestIds.selectedItems,children:[selected.map(item=>jsx10(Pill,{withRemoveButton:!disabled,onRemove:()=>handleValueRemove(item),children:item.label},item.value)),!disabled&&(maxValues===void 0||maxValues===0||selected.length<maxValues)&&jsx10(Combobox.EventsTarget,{children:jsx10(PillsInput.Field,{role:"searchbox",name,value:search,placeholder,onFocus:handleSearchChange,onBlur:()=>{combobox.closeDropdown(),setSearch("")},onKeyDown:handleKeyDown,onChange:handleSearchChange})})]})})}),jsx10(Combobox.Dropdown,{hidden:options.length===0,"data-testid":AsyncAutocompleteTestIds.options,children:jsx10(Combobox.Options,{children:jsxs3(ScrollAreaAutosize,{type:"scroll",mah:optionsDropdownMaxHeight,children:[options.map(item=>{let active=selected.some(v2=>v2.value===item.value);return jsx10(Combobox.Option,{value:item.value,active,children:jsx10(ItemComponent3,{...item,active})},item.value)}),creatable&&search.trim().length>0&&jsxs3(Combobox.Option,{value:"$create",children:["+ Create ",search]}),!creatable&&search.trim().length>0&&options.length===0&&jsx10(EmptyComponent,{search})]})})})]})}function toDefaultItems(defaultValue2){return defaultValue2?Array.isArray(defaultValue2)?defaultValue2:[defaultValue2]:[]}function DefaultItemComponent(props){return jsxs3(Group3,{gap:"xs",children:[props.active&&jsx10(IconCheck,{size:12}),jsx10("span",{children:props.label})]})}function DefaultEmptyComponent(){return jsx10(Combobox.Empty,{children:"Nothing found"})}var HeaderSearchInput_default={searchInput:"HeaderSearchInput_searchInput"};import{jsx as jsx11,jsxs as jsxs4}from"react/jsx-runtime";function toOption(resource){return{value:resource.id,label:getDisplayString2(resource),resource}}function HeaderSearchInput(props){let navigate=se(),medplum=b(),loadData=useCallback2(async(input,signal)=>{let query=buildGraphQLQuery(input),options={signal},response=await medplum.graphql(query,void 0,void 0,options);return getResourcesFromResponse(response,input)},[medplum]),handleSelect=useCallback2(item=>{item.length>0&&navigate(`/${getReferenceString2(item[0])}`)},[navigate]);return jsx11(AsyncAutocomplete,{size:"sm",radius:"md",className:HeaderSearchInput_default.searchInput,leftSection:jsx11(IconSearch,{size:16}),placeholder:"Search",itemComponent:ItemComponent,toOption,onChange:handleSelect,loadOptions:loadData,maxValues:0,clearable:!1},`${props.pathname}?${props.searchParams}`)}var ItemComponent=forwardRef2(({resource,active:_active,...others},ref)=>{let helpText;return resource.resourceType==="Patient"?helpText=resource.birthDate:resource.resourceType==="ServiceRequest"&&(helpText=resource.subject?.display),jsx11("div",{ref,...others,children:jsxs4(Group4,{wrap:"nowrap",children:[jsx11(ResourceAvatar,{value:resource}),jsxs4("div",{children:[jsx11(Text2,{children:getDisplayString2(resource)}),jsx11(Text2,{size:"xs",c:"dimmed",children:helpText})]})]})})});function buildGraphQLQuery(input){let escaped=JSON.stringify(input);return isUUID(input)?`{
1
+ var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var require_pointer=__commonJS({"../../node_modules/rfc6902/pointer.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.Pointer=void 0;function unescape(token){return token.replace(/~1/g,"/").replace(/~0/g,"~")}function escape(token){return token.replace(/~/g,"~0").replace(/\//g,"~1")}var Pointer=function(){function Pointer2(tokens){tokens===void 0&&(tokens=[""]),this.tokens=tokens}return Pointer2.fromJSON=function(path){var tokens=path.split("/").map(unescape);if(tokens[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(path));return new Pointer2(tokens)},Pointer2.prototype.toString=function(){return this.tokens.map(escape).join("/")},Pointer2.prototype.evaluate=function(object){for(var parent=null,key="",value=object,i=1,l=this.tokens.length;i<l;i++)parent=value,key=this.tokens[i],!(key=="__proto__"||key=="constructor"||key=="prototype")&&(value=(parent||{})[key]);return{parent,key,value}},Pointer2.prototype.get=function(object){return this.evaluate(object).value},Pointer2.prototype.set=function(object,value){var endpoint=this.evaluate(object);endpoint.parent&&(endpoint.parent[endpoint.key]=value)},Pointer2.prototype.push=function(token){this.tokens.push(token)},Pointer2.prototype.add=function(token){var tokens=this.tokens.concat(String(token));return new Pointer2(tokens)},Pointer2}();exports.Pointer=Pointer}});var require_util=__commonJS({"../../node_modules/rfc6902/util.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.clone=exports.objectType=exports.hasOwnProperty=void 0;exports.hasOwnProperty=Object.prototype.hasOwnProperty;function objectType(object){return object===void 0?"undefined":object===null?"null":Array.isArray(object)?"array":typeof object}exports.objectType=objectType;function isNonPrimitive(value){return value!=null&&typeof value=="object"}function clone(source){if(!isNonPrimitive(source))return source;if(source.constructor==Array){for(var length_1=source.length,arrayTarget=new Array(length_1),i=0;i<length_1;i++)arrayTarget[i]=clone(source[i]);return arrayTarget}if(source.constructor==Date){var dateTarget=new Date(+source);return dateTarget}var objectTarget={};for(var key in source)exports.hasOwnProperty.call(source,key)&&(objectTarget[key]=clone(source[key]));return objectTarget}exports.clone=clone}});var require_diff=__commonJS({"../../node_modules/rfc6902/diff.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.diffAny=exports.diffObjects=exports.diffArrays=exports.intersection=exports.subtract=exports.isDestructive=void 0;var util_1=require_util();function isDestructive(_a){var op=_a.op;return op==="remove"||op==="replace"||op==="copy"||op==="move"}exports.isDestructive=isDestructive;function subtract(minuend,subtrahend){var obj={};for(var add_key in minuend)util_1.hasOwnProperty.call(minuend,add_key)&&minuend[add_key]!==void 0&&(obj[add_key]=1);for(var del_key in subtrahend)util_1.hasOwnProperty.call(subtrahend,del_key)&&subtrahend[del_key]!==void 0&&delete obj[del_key];return Object.keys(obj)}exports.subtract=subtract;function intersection(objects){for(var length=objects.length,counter={},i=0;i<length;i++){var object=objects[i];for(var key in object)util_1.hasOwnProperty.call(object,key)&&object[key]!==void 0&&(counter[key]=(counter[key]||0)+1)}for(var key in counter)counter[key]<length&&delete counter[key];return Object.keys(counter)}exports.intersection=intersection;function isArrayAdd(array_operation){return array_operation.op==="add"}function isArrayRemove(array_operation){return array_operation.op==="remove"}function appendArrayOperation(base,operation){return{operations:base.operations.concat(operation),cost:base.cost+1}}function diffArrays(input,output,ptr,diff2){diff2===void 0&&(diff2=diffAny);var memo2={"0,0":{operations:[],cost:0}};function dist(i,j2){var memo_key="".concat(i,",").concat(j2),memoized=memo2[memo_key];if(memoized===void 0){if(i>0&&j2>0&&!diff2(input[i-1],output[j2-1],ptr.add(String(i-1))).length)memoized=dist(i-1,j2-1);else{var alternatives=[];if(i>0){var remove_base=dist(i-1,j2),remove_operation={op:"remove",index:i-1};alternatives.push(appendArrayOperation(remove_base,remove_operation))}if(j2>0){var add_base=dist(i,j2-1),add_operation={op:"add",index:i-1,value:output[j2-1]};alternatives.push(appendArrayOperation(add_base,add_operation))}if(i>0&&j2>0){var replace_base=dist(i-1,j2-1),replace_operation={op:"replace",index:i-1,original:input[i-1],value:output[j2-1]};alternatives.push(appendArrayOperation(replace_base,replace_operation))}var best=alternatives.sort(function(a,b2){return a.cost-b2.cost})[0];memoized=best}memo2[memo_key]=memoized}return memoized}var input_length=isNaN(input.length)||input.length<=0?0:input.length,output_length=isNaN(output.length)||output.length<=0?0:output.length,array_operations=dist(input_length,output_length).operations,padded_operations=array_operations.reduce(function(_a,array_operation){var operations=_a[0],padding=_a[1];if(isArrayAdd(array_operation)){var padded_index=array_operation.index+1+padding,index_token=padded_index<input_length+padding?String(padded_index):"-",operation={op:array_operation.op,path:ptr.add(index_token).toString(),value:array_operation.value};return[operations.concat(operation),padding+1]}else if(isArrayRemove(array_operation)){var operation={op:array_operation.op,path:ptr.add(String(array_operation.index+padding)).toString()};return[operations.concat(operation),padding-1]}else{var replace_ptr=ptr.add(String(array_operation.index+padding)),replace_operations=diff2(array_operation.original,array_operation.value,replace_ptr);return[operations.concat.apply(operations,replace_operations),padding]}},[[],0])[0];return padded_operations}exports.diffArrays=diffArrays;function diffObjects(input,output,ptr,diff2){diff2===void 0&&(diff2=diffAny);var operations=[];return subtract(input,output).forEach(function(key){operations.push({op:"remove",path:ptr.add(key).toString()})}),subtract(output,input).forEach(function(key){operations.push({op:"add",path:ptr.add(key).toString(),value:output[key]})}),intersection([input,output]).forEach(function(key){operations.push.apply(operations,diff2(input[key],output[key],ptr.add(key)))}),operations}exports.diffObjects=diffObjects;function diffAny(input,output,ptr,diff2){if(diff2===void 0&&(diff2=diffAny),input===output)return[];var input_type=(0,util_1.objectType)(input),output_type=(0,util_1.objectType)(output);return input_type=="array"&&output_type=="array"?diffArrays(input,output,ptr,diff2):input_type=="object"&&output_type=="object"?diffObjects(input,output,ptr,diff2):[{op:"replace",path:ptr.toString(),value:output}]}exports.diffAny=diffAny}});var require_patch=__commonJS({"../../node_modules/rfc6902/patch.js"(exports){"use strict";var __extends=exports&&exports.__extends||function(){var extendStatics=function(d,b2){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d2,b3){d2.__proto__=b3}||function(d2,b3){for(var p2 in b3)Object.prototype.hasOwnProperty.call(b3,p2)&&(d2[p2]=b3[p2])},extendStatics(d,b2)};return function(d,b2){if(typeof b2!="function"&&b2!==null)throw new TypeError("Class extends value "+String(b2)+" is not a constructor or null");extendStatics(d,b2);function __(){this.constructor=d}d.prototype=b2===null?Object.create(b2):(__.prototype=b2.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:!0});exports.apply=exports.InvalidOperationError=exports.test=exports.copy=exports.move=exports.replace=exports.remove=exports.add=exports.TestError=exports.MissingError=void 0;var pointer_1=require_pointer(),util_1=require_util(),diff_1=require_diff(),MissingError=function(_super){__extends(MissingError2,_super);function MissingError2(path){var _this=_super.call(this,"Value required at path: ".concat(path))||this;return _this.path=path,_this.name="MissingError",_this}return MissingError2}(Error);exports.MissingError=MissingError;var TestError=function(_super){__extends(TestError2,_super);function TestError2(actual,expected){var _this=_super.call(this,"Test failed: ".concat(actual," != ").concat(expected))||this;return _this.actual=actual,_this.expected=expected,_this.name="TestError",_this}return TestError2}(Error);exports.TestError=TestError;function _add(object,key,value){if(Array.isArray(object))if(key=="-")object.push(value);else{var index=parseInt(key,10);object.splice(index,0,value)}else object[key]=value}function _remove(object,key){if(Array.isArray(object)){var index=parseInt(key,10);object.splice(index,1)}else delete object[key]}function add(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_add(endpoint.parent,endpoint.key,(0,util_1.clone)(operation.value)),null)}exports.add=add;function remove(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.value===void 0?new MissingError(operation.path):(_remove(endpoint.parent,endpoint.key),null)}exports.remove=remove;function replace(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);if(endpoint.parent===null)return new MissingError(operation.path);if(Array.isArray(endpoint.parent)){if(parseInt(endpoint.key,10)>=endpoint.parent.length)return new MissingError(operation.path)}else if(endpoint.value===void 0)return new MissingError(operation.path);return endpoint.parent[endpoint.key]=(0,util_1.clone)(operation.value),null}exports.replace=replace;function move(object,operation){var from_endpoint=pointer_1.Pointer.fromJSON(operation.from).evaluate(object);if(from_endpoint.value===void 0)return new MissingError(operation.from);var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_remove(from_endpoint.parent,from_endpoint.key),_add(endpoint.parent,endpoint.key,from_endpoint.value),null)}exports.move=move;function copy(object,operation){var from_endpoint=pointer_1.Pointer.fromJSON(operation.from).evaluate(object);if(from_endpoint.value===void 0)return new MissingError(operation.from);var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return endpoint.parent===void 0?new MissingError(operation.path):(_add(endpoint.parent,endpoint.key,(0,util_1.clone)(from_endpoint.value)),null)}exports.copy=copy;function test(object,operation){var endpoint=pointer_1.Pointer.fromJSON(operation.path).evaluate(object);return(0,diff_1.diffAny)(endpoint.value,operation.value,new pointer_1.Pointer).length?new TestError(endpoint.value,operation.value):null}exports.test=test;var InvalidOperationError=function(_super){__extends(InvalidOperationError2,_super);function InvalidOperationError2(operation){var _this=_super.call(this,"Invalid operation: ".concat(operation.op))||this;return _this.operation=operation,_this.name="InvalidOperationError",_this}return InvalidOperationError2}(Error);exports.InvalidOperationError=InvalidOperationError;function apply(object,operation){switch(operation.op){case"add":return add(object,operation);case"remove":return remove(object,operation);case"replace":return replace(object,operation);case"move":return move(object,operation);case"copy":return copy(object,operation);case"test":return test(object,operation)}return new InvalidOperationError(operation)}exports.apply=apply}});var require_rfc6902=__commonJS({"../../node_modules/rfc6902/index.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.createTests=exports.createPatch=exports.applyPatch=exports.Pointer=void 0;var pointer_1=require_pointer();Object.defineProperty(exports,"Pointer",{enumerable:!0,get:function(){return pointer_1.Pointer}});var patch_1=require_patch(),diff_1=require_diff();function applyPatch(object,patch){return patch.map(function(operation){return(0,patch_1.apply)(object,operation)})}exports.applyPatch=applyPatch;function wrapVoidableDiff(diff2){function wrappedDiff(input,output,ptr){var custom_patch=diff2(input,output,ptr);return Array.isArray(custom_patch)?custom_patch:(0,diff_1.diffAny)(input,output,ptr,wrappedDiff)}return wrappedDiff}function createPatch2(input,output,diff2){var ptr=new pointer_1.Pointer;return(diff2?wrapVoidableDiff(diff2):diff_1.diffAny)(input,output,ptr)}exports.createPatch=createPatch2;function createTest(input,path){var endpoint=pointer_1.Pointer.fromJSON(path).evaluate(input);if(endpoint!==void 0)return{op:"test",path,value:endpoint.value}}function createTests(input,patch){var tests=new Array;return patch.filter(diff_1.isDestructive).forEach(function(operation){var pathTest=createTest(input,operation.path);if(pathTest&&tests.push(pathTest),"from"in operation){var fromTest=createTest(input,operation.from);fromTest&&tests.push(fromTest)}}),tests}exports.createTests=createTests}});import{useEffect as _,useMemo as Q,useState as A}from"react";import{createContext as D,useContext as z}from"react";import{jsx as J}from"react/jsx-runtime";import{useMemo as X}from"react";import{useEffect as q,useRef as G}from"react";import{deepEquals as H,isReference as w,isResource as Y,normalizeOperationOutcome as Z}from"@medplum/core";import{useCallback as $,useEffect as j,useState as ee}from"react";import{allOk as te,normalizeOperationOutcome as ne}from"@medplum/core";import{useEffect as re,useState as v}from"react";import{deepEquals as F}from"@medplum/core";import{useCallback as R,useEffect as y,useRef as p,useState as B}from"react";var O=D(void 0);function T(){return z(O)}function b(){return T().medplum}function se(){return T().navigate}function ue(){return T().profile}var N=["change","storageInitialized","storageInitFailed","profileRefreshing","profileRefreshed"];function me(e){let t=e.medplum,n=e.navigate??V,[i,r2]=A({profile:t.getProfile(),loading:t.isLoading()});_(()=>{function o(){r2(u=>({...u,profile:t.getProfile(),loading:t.isLoading()}))}for(let u of N)t.addEventListener(u,o);return()=>{for(let u of N)t.removeEventListener(u,o)}},[t]);let s=Q(()=>({...i,medplum:t,navigate:n}),[i,t,n]);return J(O.Provider,{value:s,children:e.children})}function V(e){window.location.assign(e)}var U=new Map,Se=e=>X(()=>{if(!e)return;let t=e.split("?")[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has("Key-Pair-Id")||!n.has("Signature"))return e;let i=n.get("Expires");if(!i||i.length>13)return e;let r2=U.get(t);if(r2){let o=new URLSearchParams(new URL(r2).search).get("Expires");if(o&&parseInt(o,10)*1e3-5e3>Date.now())return r2}return U.set(t,e),e},[e]);function xe(e){let t=G();return q(()=>{t.current=e}),t.current}function Te(e,t){let n=b(),[i,r2]=ee(()=>W(n,e)),s=$(o=>{H(o,i)||r2(o)},[i]);return j(()=>{let o=!0,u=W(n,e);return!u&&w(e)?n.readReference(e).then(a=>{o&&s(a)}).catch(a=>{o&&(s(void 0),t&&t(Z(a)))}):s(u),()=>o=!1},[n,e,s,t]),i}function W(e,t){if(t){if(Y(t))return t;if(w(t))return e.getCachedReference(t)}}function Ne(e,t){return P("search",e,t)}function Ue(e,t){return P("searchOne",e,t)}function We(e,t){return P("searchResources",e,t)}function P(e,t,n){let i=b(),[r2,s]=v(),[o,u]=v(!0),[a,d]=v(),[f,m]=v();return re(()=>{let S=i.fhirSearchUrl(t,n).toString();S!==r2&&(s(S),i[e](t,n).then(l=>{u(!1),d(l),m(te)}).catch(l=>{u(!1),d(void 0),m(ne(l))}))},[i,e,t,n,r2]),[a,o,f]}var oe=3e3;function Qe(e,t,n){let i=b(),[r2,s]=B(),[o,u]=B(n?.subscriptionProps),a=p(!1),d=p(),f=p(),m=p(),S=p();S.current=t;let l=p();l.current=n?.onWebSocketOpen;let L=p();L.current=n?.onWebSocketClose;let K=p();K.current=n?.onSubscriptionConnect;let k=p();k.current=n?.onSubscriptionDisconnect;let I=p();I.current=n?.onError,y(()=>{F(n?.subscriptionProps,o)||u(n?.subscriptionProps)},[o,n]),y(()=>{d.current&&(clearTimeout(d.current),d.current=void 0);let c=!1;return(f.current!==e||!F(m.current,o))&&(c=!0),c&&f.current&&i.unsubscribeFromCriteria(f.current,m.current),f.current=e,m.current=o,c&&s(i.subscribeToCriteria(e,o)),()=>{d.current=setTimeout(()=>{s(void 0),i.unsubscribeFromCriteria(e,o)},oe)}},[i,e,o]);let E=R(c=>{S.current?.(c.payload)},[]),x=R(()=>{l.current?.()},[]),g=R(()=>{L.current?.()},[]),C=R(c=>{K.current?.(c.payload.subscriptionId)},[]),h=R(c=>{k.current?.(c.payload.subscriptionId)},[]),M=R(c=>{I.current?.(c.payload)},[]);y(()=>r2?(a.current||(r2.addEventListener("message",E),r2.addEventListener("open",x),r2.addEventListener("close",g),r2.addEventListener("connect",C),r2.addEventListener("disconnect",h),r2.addEventListener("error",M),a.current=!0),()=>{a.current=!1,r2.removeEventListener("message",E),r2.removeEventListener("open",x),r2.removeEventListener("close",g),r2.removeEventListener("connect",C),r2.removeEventListener("disconnect",h),r2.removeEventListener("error",M)}):()=>{},[r2,E,x,g,C,h,M])}import{formatAddress}from"@medplum/core";import{Fragment,jsx}from"react/jsx-runtime";function AddressDisplay(props){let address=props.value;return address?jsx(Fragment,{children:formatAddress(address)}):null}import{Group,NativeSelect,TextInput}from"@mantine/core";import{useContext,useMemo,useRef,useState}from"react";import{isPopulated}from"@medplum/core";import{createContext}from"react";var DEFAULT_IGNORED_PROPERTIES=["meta","implicitRules","contained","extension","modifierExtension"],DEFAULT_IGNORED_NON_NESTED_PROPERTIES=["language","text"];var ElementsContext=createContext({path:"",profileUrl:void 0,elements:Object.create(null),elementsByPath:Object.create(null),getExtendedProps:()=>({readonly:!1,hidden:!1}),accessPolicyResource:void 0,debugMode:!1,isDefaultContext:!0});ElementsContext.displayName="ElementsContext";var EXTENSION_KEYS=["extension","modifierExtension"],IGNORED_PROPERTIES=["id",...DEFAULT_IGNORED_PROPERTIES].filter(prop=>!EXTENSION_KEYS.includes(prop));function getElementsToRender(inputElements){return Object.entries(inputElements).filter(([key,element])=>!isPopulated(element.type)||element.max===0||element.path.toLowerCase().endsWith("extension.url")&&element.fixed||EXTENSION_KEYS.includes(key)&&!isPopulated(element.slicing?.slices)||IGNORED_PROPERTIES.includes(key)?!1:!(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&element.path.split(".").length===2||key.includes(".")))}import{jsx as jsx2,jsxs}from"react/jsx-runtime";function getLine(address,index){return address.line&&address.line.length>index?address.line[index]:""}function setLine(address,index,str){let line=address.line||[];for(;line.length<=index;)line.push("");return line[index]=str,{...address,line}}function AddressInput(props){let[value,setValue]=useState(props.defaultValue||{}),valueRef=useRef();valueRef.current=value;let{getExtendedProps}=useContext(ElementsContext),[useProps,typeProps,line1Props,line2Props,cityProps,stateProps,postalCodeProps]=useMemo(()=>["use","type","line1","line2","city","state","postalCode"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}function setUse(use){setValueWrapper({...valueRef.current,use})}function setType(type){setValueWrapper({...valueRef.current,type})}function setLine1(line1){setValueWrapper(setLine(valueRef.current||{},0,line1))}function setLine2(line2){setValueWrapper(setLine(valueRef.current||{},1,line2))}function setCity(city){setValueWrapper({...valueRef.current,city})}function setState(state){setValueWrapper({...valueRef.current,state})}function setPostalCode(postalCode){setValueWrapper({...valueRef.current,postalCode})}return jsxs(Group,{gap:"xs",wrap:"nowrap",grow:!0,children:[jsx2(NativeSelect,{disabled:props.disabled||useProps?.readonly,"data-testid":"address-use",defaultValue:value.use,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","billing"]}),jsx2(NativeSelect,{disabled:props.disabled||typeProps?.readonly,"data-testid":"address-type",defaultValue:value.type,onChange:e=>setType(e.currentTarget.value),data:["","postal","physical","both"]}),jsx2(TextInput,{disabled:props.disabled||line1Props?.readonly,placeholder:"Line 1",defaultValue:getLine(value,0),onChange:e=>setLine1(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||line2Props?.readonly,placeholder:"Line 2",defaultValue:getLine(value,1),onChange:e=>setLine2(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||cityProps?.readonly,placeholder:"City",defaultValue:value.city,onChange:e=>setCity(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||stateProps?.readonly,placeholder:"State",defaultValue:value.state,onChange:e=>setState(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||postalCodeProps?.readonly,placeholder:"Postal Code",defaultValue:value.postalCode,onChange:e=>setPostalCode(e.currentTarget.value)})]})}import{TextInput as TextInput2}from"@mantine/core";import{createReference}from"@medplum/core";import{useState as useState2}from"react";import{jsx as jsx3}from"react/jsx-runtime";function AnnotationInput(props){let author=ue(),[value,setValue]=useState2(props.defaultValue||{});function setText(text){let newValue=text?{text,authorReference:author&&createReference(author),time:new Date().toISOString()}:{};setValue(newValue),props.onChange&&props.onChange(newValue)}return jsx3(TextInput2,{disabled:props.disabled,name:props.name,placeholder:"Annotation text",defaultValue:value.text,onChange:e=>setText(e.currentTarget.value)})}import{AppShell as MantineAppShell3}from"@mantine/core";import{showNotification as showNotification3}from"@mantine/notifications";import{Suspense,useEffect as useEffect2,useState as useState8}from"react";import{Alert}from"@mantine/core";import{normalizeErrorString}from"@medplum/core";import{forwardRef,createElement}from"react";var defaultAttributes={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};var createReactComponent=(type,iconName,iconNamePascal,iconNode)=>{let Component2=forwardRef(({color="currentColor",size=24,stroke=2,title,className,children,...rest},ref)=>createElement("svg",{ref,...defaultAttributes[type],width:size,height:size,className:["tabler-icon",`tabler-icon-${iconName}`,className].join(" "),...type==="filled"?{fill:color}:{strokeWidth:stroke,stroke:color},...rest},[title&&createElement("title",{key:"svg-title"},title),...iconNode.map(([tag,attrs])=>createElement(tag,attrs)),...Array.isArray(children)?children:[children]]));return Component2.displayName=`${iconNamePascal}`,Component2};var IconAdjustmentsHorizontal=createReactComponent("outline","adjustments-horizontal","IconAdjustmentsHorizontal",[["path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M4 6l8 0",key:"svg-1"}],["path",{d:"M16 6l4 0",key:"svg-2"}],["path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-3"}],["path",{d:"M4 12l2 0",key:"svg-4"}],["path",{d:"M10 12l10 0",key:"svg-5"}],["path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-6"}],["path",{d:"M4 18l11 0",key:"svg-7"}],["path",{d:"M19 18l1 0",key:"svg-8"}]]);var IconAlertCircle=createReactComponent("outline","alert-circle","IconAlertCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]]);var IconArrowDown=createReactComponent("outline","arrow-down","IconArrowDown",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 13l-6 6",key:"svg-1"}],["path",{d:"M6 13l6 6",key:"svg-2"}]]);var IconArrowRight=createReactComponent("outline","arrow-right","IconArrowRight",[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M13 18l6 -6",key:"svg-1"}],["path",{d:"M13 6l6 6",key:"svg-2"}]]);var IconArrowUp=createReactComponent("outline","arrow-up","IconArrowUp",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M18 11l-6 -6",key:"svg-1"}],["path",{d:"M6 11l6 -6",key:"svg-2"}]]);var IconBleachOff=createReactComponent("outline","bleach-off","IconBleachOff",[["path",{d:"M5 19h14m1.986 -1.977a2 2 0 0 0 -.146 -.773l-7.1 -12.25a2 2 0 0 0 -3.5 0l-.815 1.405m-1.488 2.568l-4.797 8.277a2 2 0 0 0 1.75 2.75",key:"svg-0"}],["path",{d:"M3 3l18 18",key:"svg-1"}]]);var IconBleach=createReactComponent("outline","bleach","IconBleach",[["path",{d:"M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75",key:"svg-0"}]]);var IconBoxMultiple=createReactComponent("outline","box-multiple","IconBoxMultiple",[["path",{d:"M7 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2",key:"svg-1"}]]);var IconBracketsContain=createReactComponent("outline","brackets-contain","IconBracketsContain",[["path",{d:"M7 4h-4v16h4",key:"svg-0"}],["path",{d:"M17 4h4v16h-4",key:"svg-1"}],["path",{d:"M8 16h.01",key:"svg-2"}],["path",{d:"M12 16h.01",key:"svg-3"}],["path",{d:"M16 16h.01",key:"svg-4"}]]);var IconBucketOff=createReactComponent("outline","bucket-off","IconBucketOff",[["path",{d:"M5.029 5.036c-.655 .58 -1.029 1.25 -1.029 1.964c0 2.033 3.033 3.712 6.96 3.967m3.788 -.21c3.064 -.559 5.252 -2.029 5.252 -3.757c0 -2.21 -3.582 -4 -8 -4c-1.605 0 -3.1 .236 -4.352 .643",key:"svg-0"}],["path",{d:"M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.1 -.3 .252 -.812 .457 -1.535m.862 -3.146c.262 -.975 .735 -2.76 1.418 -5.354a7.45 7.45 0 0 0 .263 -1.965",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]]);var IconBucket=createReactComponent("outline","bucket","IconBucket",[["path",{d:"M12 7m-8 0a8 4 0 1 0 16 0a8 4 0 1 0 -16 0",key:"svg-0"}],["path",{d:"M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.333 -1 1.246 -4.345 2.737 -10.035a7.45 7.45 0 0 0 .263 -1.965",key:"svg-1"}]]);var IconCalendar=createReactComponent("outline","calendar","IconCalendar",[["path",{d:"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12z",key:"svg-0"}],["path",{d:"M16 3v4",key:"svg-1"}],["path",{d:"M8 3v4",key:"svg-2"}],["path",{d:"M4 11h16",key:"svg-3"}],["path",{d:"M11 15h1",key:"svg-4"}],["path",{d:"M12 15v3",key:"svg-5"}]]);var IconCheck=createReactComponent("outline","check","IconCheck",[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]]);var IconCheckbox=createReactComponent("outline","checkbox","IconCheckbox",[["path",{d:"M9 11l3 3l8 -8",key:"svg-0"}],["path",{d:"M20 12v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h9",key:"svg-1"}]]);var IconChevronDown=createReactComponent("outline","chevron-down","IconChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]);var IconChevronUp=createReactComponent("outline","chevron-up","IconChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]);var IconCircleMinus=createReactComponent("outline","circle-minus","IconCircleMinus",[["path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l6 0",key:"svg-1"}]]);var IconCirclePlus=createReactComponent("outline","circle-plus","IconCirclePlus",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M9 12h6",key:"svg-1"}],["path",{d:"M12 9v6",key:"svg-2"}]]);var IconCloudUpload=createReactComponent("outline","cloud-upload","IconCloudUpload",[["path",{d:"M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1",key:"svg-0"}],["path",{d:"M9 15l3 -3l3 3",key:"svg-1"}],["path",{d:"M12 12l0 9",key:"svg-2"}]]);var IconColumns=createReactComponent("outline","columns","IconColumns",[["path",{d:"M4 6l5.5 0",key:"svg-0"}],["path",{d:"M4 10l5.5 0",key:"svg-1"}],["path",{d:"M4 14l5.5 0",key:"svg-2"}],["path",{d:"M4 18l5.5 0",key:"svg-3"}],["path",{d:"M14.5 6l5.5 0",key:"svg-4"}],["path",{d:"M14.5 10l5.5 0",key:"svg-5"}],["path",{d:"M14.5 14l5.5 0",key:"svg-6"}],["path",{d:"M14.5 18l5.5 0",key:"svg-7"}]]);var IconCopy=createReactComponent("outline","copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);var IconCurrencyDollar=createReactComponent("outline","currency-dollar","IconCurrencyDollar",[["path",{d:"M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2",key:"svg-0"}],["path",{d:"M12 3v3m0 12v3",key:"svg-1"}]]);var IconDots=createReactComponent("outline","dots","IconDots",[["path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);var IconEdit=createReactComponent("outline","edit","IconEdit",[["path",{d:"M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1",key:"svg-0"}],["path",{d:"M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z",key:"svg-1"}],["path",{d:"M16 5l3 3",key:"svg-2"}]]);var IconEqualNot=createReactComponent("outline","equal-not","IconEqualNot",[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}],["path",{d:"M5 19l14 -14",key:"svg-2"}]]);var IconEqual=createReactComponent("outline","equal","IconEqual",[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}]]);var IconFileAlert=createReactComponent("outline","file-alert","IconFileAlert",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 17l.01 0",key:"svg-2"}],["path",{d:"M12 11l0 3",key:"svg-3"}]]);var IconFilePlus=createReactComponent("outline","file-plus","IconFilePlus",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z",key:"svg-1"}],["path",{d:"M12 11l0 6",key:"svg-2"}],["path",{d:"M9 14l6 0",key:"svg-3"}]]);var IconFilter=createReactComponent("outline","filter","IconFilter",[["path",{d:"M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z",key:"svg-0"}]]);var IconGenderFemale=createReactComponent("outline","gender-female","IconGenderFemale",[["path",{d:"M12 9m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0",key:"svg-0"}],["path",{d:"M12 14v7",key:"svg-1"}],["path",{d:"M9 18h6",key:"svg-2"}]]);var IconGenderMale=createReactComponent("outline","gender-male","IconGenderMale",[["path",{d:"M10 14m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0",key:"svg-0"}],["path",{d:"M19 5l-5.4 5.4",key:"svg-1"}],["path",{d:"M19 5h-5",key:"svg-2"}],["path",{d:"M19 5v5",key:"svg-3"}]]);var IconLogout=createReactComponent("outline","logout","IconLogout",[["path",{d:"M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M9 12h12l-3 -3",key:"svg-1"}],["path",{d:"M18 15l3 -3",key:"svg-2"}]]);var IconMathGreater=createReactComponent("outline","math-greater","IconMathGreater",[["path",{d:"M5 18l14 -6l-14 -6",key:"svg-0"}]]);var IconMathLower=createReactComponent("outline","math-lower","IconMathLower",[["path",{d:"M19 18l-14 -6l14 -6",key:"svg-0"}]]);var IconMessage=createReactComponent("outline","message","IconMessage",[["path",{d:"M8 9h8",key:"svg-0"}],["path",{d:"M8 13h6",key:"svg-1"}],["path",{d:"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12z",key:"svg-2"}]]);var IconPlus=createReactComponent("outline","plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]);var IconRefresh=createReactComponent("outline","refresh","IconRefresh",[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]]);var IconSearch=createReactComponent("outline","search","IconSearch",[["path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M21 21l-6 -6",key:"svg-1"}]]);var IconSettings=createReactComponent("outline","settings","IconSettings",[["path",{d:"M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065z",key:"svg-0"}],["path",{d:"M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-1"}]]);var IconSortAscending=createReactComponent("outline","sort-ascending","IconSortAscending",[["path",{d:"M4 6l7 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l9 0",key:"svg-2"}],["path",{d:"M15 9l3 -3l3 3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]]);var IconSortDescending=createReactComponent("outline","sort-descending","IconSortDescending",[["path",{d:"M4 6l9 0",key:"svg-0"}],["path",{d:"M4 12l7 0",key:"svg-1"}],["path",{d:"M4 18l7 0",key:"svg-2"}],["path",{d:"M15 15l3 3l3 -3",key:"svg-3"}],["path",{d:"M18 6l0 12",key:"svg-4"}]]);var IconSquare=createReactComponent("outline","square","IconSquare",[["path",{d:"M3 3m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z",key:"svg-0"}]]);var IconStethoscope=createReactComponent("outline","stethoscope","IconStethoscope",[["path",{d:"M6 4h-1a2 2 0 0 0 -2 2v3.5h0a5.5 5.5 0 0 0 11 0v-3.5a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M8 15a6 6 0 1 0 12 0v-3",key:"svg-1"}],["path",{d:"M11 3v2",key:"svg-2"}],["path",{d:"M6 3v2",key:"svg-3"}],["path",{d:"M20 10m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-4"}]]);var IconSwitchHorizontal=createReactComponent("outline","switch-horizontal","IconSwitchHorizontal",[["path",{d:"M16 3l4 4l-4 4",key:"svg-0"}],["path",{d:"M10 7l10 0",key:"svg-1"}],["path",{d:"M8 13l-4 4l4 4",key:"svg-2"}],["path",{d:"M4 17l9 0",key:"svg-3"}]]);var IconTableExport=createReactComponent("outline","table-export","IconTableExport",[["path",{d:"M12.5 21h-7.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7.5",key:"svg-0"}],["path",{d:"M3 10h18",key:"svg-1"}],["path",{d:"M10 3v18",key:"svg-2"}],["path",{d:"M16 19h6",key:"svg-3"}],["path",{d:"M19 16l3 3l-3 3",key:"svg-4"}]]);var IconTrash=createReactComponent("outline","trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);var IconUserSquare=createReactComponent("outline","user-square","IconUserSquare",[["path",{d:"M9 10a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M6 21v-1a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v1",key:"svg-1"}],["path",{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z",key:"svg-2"}]]);var IconX=createReactComponent("outline","x","IconX",[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]]);import{Component}from"react";import{jsx as jsx4}from"react/jsx-runtime";var ErrorBoundary=class extends Component{constructor(props){super(props),this.state={lastLocation:window.location.toString()}}static getDerivedStateFromError(error){return{error,lastLocation:window.location.toString()}}componentDidUpdate(_prevProps,_prevState){window.location.toString()!==this.state.lastLocation&&this.setState({lastLocation:window.location.toString(),error:void 0})}shouldComponentUpdate(nextProps,nextState){return!!(this.props.children!==nextProps.children||nextState.error&&!this.state.error||this.state.lastLocation!==window.location.toString())}componentDidCatch(error,errorInfo){console.error("Uncaught error:",error,errorInfo)}render(){return this.state.error?jsx4(Alert,{icon:jsx4(IconAlertCircle,{size:16}),title:"Something went wrong",color:"red",children:normalizeErrorString(this.state.error)}):this.props.children}};import{Center,Loader}from"@mantine/core";import{jsx as jsx5}from"react/jsx-runtime";function Loading(){return jsx5(Center,{style:{width:"100%",height:"100vh"},children:jsx5(Loader,{})})}var AppShell_default={main:"AppShell_main"};import{Group as Group5,AppShell as MantineAppShell,Menu as Menu2,Text as Text3,UnstyledButton}from"@mantine/core";import{formatHumanName as formatHumanName3}from"@medplum/core";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}var clsx_default=clsx;import{useState as useState4}from"react";import{Avatar}from"@mantine/core";import{getDisplayString,getImageSrc}from"@medplum/core";import{Anchor}from"@mantine/core";import{isReference,isResource}from"@medplum/core";function killEvent(e){e.preventDefault(),e.stopPropagation()}function isCheckboxCell(el){if(isCheckboxElement(el))return!0;if(el instanceof HTMLTableCellElement){let children=el.children;if(children.length===1&&isCheckboxElement(children[0]))return!0}return!1}function isCheckboxElement(el){return el instanceof HTMLInputElement&&el.type==="checkbox"}import{jsx as jsx6}from"react/jsx-runtime";function MedplumLink(props){let navigate=se(),{to,suffix,label,onClick,children,...rest}=props,href=getHref(to);return suffix&&(href+="/"+suffix),jsx6(Anchor,{href,"aria-label":label,onClick:e=>{killEvent(e),onClick?onClick(e):to&&navigate(href)},...rest,children})}function getHref(to){if(to){if(typeof to=="string")return getStringHref(to);if(isResource(to))return getResourceHref(to);if(isReference(to))return getReferenceHref(to)}return"#"}function getStringHref(to){return to.startsWith("http://")||to.startsWith("https://")||to.startsWith("/")?to:"/"+to}function getResourceHref(to){return`/${to.resourceType}/${to.id}`}function getReferenceHref(to){return`/${to.reference}`}function getInitials(input){let words=input.split(" ").filter(Boolean);return words.length>1?words[0][0]+words[words.length-1][0]:words.length===1?words[0][0]:""}import{jsx as jsx7}from"react/jsx-runtime";function ResourceAvatar(props){let resource=Te(props.value),text=resource?getDisplayString(resource):props.alt??"",initials=getInitials(text),uncachedImageUrl=(resource&&getImageSrc(resource))??props.src,imageUrl=Se(uncachedImageUrl??void 0),radius=props.radius??"xl",avatarProps={...props,value:void 0,link:void 0};return props.link?jsx7(MedplumLink,{to:resource,children:jsx7(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}):jsx7(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}var Header_default={logoButton:"Header_logoButton",user:"Header_user",userName:"Header_userName",userActive:"Header_userActive"};import{Avatar as Avatar2,Group as Group2,Menu,SegmentedControl,Stack,Text,useMantineColorScheme}from"@mantine/core";import{getReferenceString}from"@medplum/core";import{formatHumanName}from"@medplum/core";import{Fragment as Fragment2,jsx as jsx8}from"react/jsx-runtime";function HumanNameDisplay(props){let name=props.value;return name?jsx8(Fragment2,{children:formatHumanName(name,props.options)}):null}import{Fragment as Fragment3,jsx as jsx9,jsxs as jsxs2}from"react/jsx-runtime";function HeaderDropdown(props){let context=T(),{medplum,profile,navigate}=context,logins=medplum.getLogins(),{colorScheme,setColorScheme}=useMantineColorScheme();return jsxs2(Fragment3,{children:[jsxs2(Stack,{align:"center",p:"xl",children:[jsx9(ResourceAvatar,{size:"xl",radius:100,value:context.profile}),jsx9(HumanNameDisplay,{value:context.profile?.name?.[0]}),jsx9(Text,{c:"dimmed",size:"xs",children:medplum.getActiveLogin()?.project.display})]}),logins.length>1&&jsx9(Menu.Divider,{}),logins.map(login=>login.profile.reference!==getReferenceString(context.profile)&&jsx9(Menu.Item,{onClick:()=>{medplum.setActiveLogin(login).then(()=>window.location.reload()).catch(console.log)},children:jsxs2(Group2,{children:[jsx9(Avatar2,{radius:"xl"}),jsxs2("div",{style:{flex:1},children:[jsx9(Text,{size:"sm",fw:500,children:login.profile.display}),jsx9(Text,{c:"dimmed",size:"xs",children:login.project.display})]})]})},login.profile.reference)),jsx9(Menu.Divider,{}),jsx9(Group2,{justify:"center",children:jsx9(SegmentedControl,{size:"xs",value:colorScheme,onChange:newValue=>setColorScheme(newValue),data:[{label:"Light",value:"light"},{label:"Dark",value:"dark"},{label:"Auto",value:"auto"}]})}),jsx9(Menu.Divider,{}),jsx9(Menu.Item,{leftSection:jsx9(IconSwitchHorizontal,{size:14,stroke:1.5}),onClick:()=>navigate("/signin"),children:"Add another account"}),jsx9(Menu.Item,{leftSection:jsx9(IconSettings,{size:14,stroke:1.5}),onClick:()=>navigate(`/${getReferenceString(profile)}`),children:"Account settings"}),jsx9(Menu.Item,{leftSection:jsx9(IconLogout,{size:14,stroke:1.5}),onClick:async()=>{await medplum.signOut(),navigate("/signin")},children:"Sign out"}),jsx9(Text,{size:"xs",c:"dimmed",ta:"center",children:props.version})]})}import{Group as Group4,Text as Text2}from"@mantine/core";import{formatHumanName as formatHumanName2,getDisplayString as getDisplayString2,getReferenceString as getReferenceString2,isUUID}from"@medplum/core";import{forwardRef as forwardRef2,useCallback as useCallback2}from"react";import{Combobox,Group as Group3,Loader as Loader2,Pill,PillsInput,ScrollAreaAutosize,useCombobox}from"@mantine/core";import{showNotification}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString2}from"@medplum/core";import{useCallback,useEffect,useMemo as useMemo2,useRef as useRef2,useState as useState3}from"react";var AsyncAutocompleteTestIds={selectedItems:"selected-items",options:"options"};import{jsx as jsx10,jsxs as jsxs3}from"react/jsx-runtime";function AsyncAutocomplete(props){let combobox=useCombobox({onDropdownClose:()=>combobox.resetSelectedOption(),onDropdownOpen:()=>combobox.updateSelectedOptionIndex("active")}),{name,label,description,error,defaultValue:defaultValue2,toOption:toOption4,loadOptions,itemComponent,pillComponent,emptyComponent,onChange,onCreate,creatable,clearable,required,placeholder,leftSection,maxValues,optionsDropdownMaxHeight=320,minInputLength=0,...rest}=props,disabled=rest.disabled,defaultItems=toDefaultItems(defaultValue2),[search,setSearch]=useState3(""),[timer,setTimer]=useState3(),[abortController,setAbortController]=useState3(),[autoSubmit,setAutoSubmit]=useState3(),[selected,setSelected]=useState3(defaultItems.map(toOption4)),[options,setOptions]=useState3([]),ItemComponent3=itemComponent??DefaultItemComponent,PillComponent=pillComponent??DefaultPillComponent,EmptyComponent=emptyComponent??DefaultEmptyComponent,searchRef=useRef2();searchRef.current=search;let lastLoadOptionsRef=useRef2(),lastValueRef=useRef2(),timerRef=useRef2();timerRef.current=timer;let abortControllerRef=useRef2();abortControllerRef.current=abortController;let autoSubmitRef=useRef2();autoSubmitRef.current=autoSubmit;let optionsRef=useRef2();optionsRef.current=options;let handleTimer=useCallback(()=>{if(setTimer(void 0),searchRef.current===lastValueRef.current&&loadOptions===lastLoadOptionsRef.current||(searchRef.current?.length??0)<minInputLength)return;lastValueRef.current=searchRef.current,lastLoadOptionsRef.current=loadOptions;let newAbortController=new AbortController;setAbortController(newAbortController),loadOptions(searchRef.current??"",newAbortController.signal).then(newValues=>{newAbortController.signal.aborted||(setOptions(newValues.map(toOption4)),autoSubmitRef.current?(newValues.length>0&&onChange(newValues.slice(0,1)),setAutoSubmit(!1)):newValues.length>0&&combobox.openDropdown())}).catch(err=>{newAbortController.signal.aborted||err.message.includes("aborted")||showNotification({color:"red",message:normalizeErrorString2(err)})}).finally(()=>{newAbortController.signal.aborted||setAbortController(void 0)})},[combobox,loadOptions,onChange,toOption4,minInputLength]),handleSearchChange=useCallback(e=>{(options&&options.length>0||creatable)&&combobox.openDropdown(),combobox.updateSelectedOptionIndex(),setSearch(e.currentTarget.value),abortControllerRef.current&&(abortControllerRef.current.abort(),setAbortController(void 0)),timerRef.current!==void 0&&window.clearTimeout(timerRef.current);let newTimer=window.setTimeout(()=>handleTimer(),100);setTimer(newTimer)},[combobox,options,creatable,handleTimer]),addSelected=useCallback(newValue=>{let alreadySelected=selected.some(v2=>v2.value===newValue),newSelected=alreadySelected?selected.filter(v2=>v2.value!==newValue):[...selected],option=options?.find(option2=>option2.value===newValue);if(!option&&creatable!==!1&&onCreate){let createdResource=onCreate(newValue);option=toOption4(createdResource)}if(option){if(maxValues===0){onChange([option.resource]),selected.length>0&&setSelected([]);return}alreadySelected||newSelected.push(option)}if(maxValues!==void 0)for(;newSelected.length>maxValues;)newSelected.shift();onChange(newSelected.map(v2=>v2.resource)),setSelected(newSelected)},[creatable,options,selected,maxValues,onChange,onCreate,toOption4]),handleValueSelect=useMemo2(()=>{if(!disabled)return val=>{disabled||(maxValues===1&&(setSearch(""),setOptions([]),combobox.closeDropdown()),lastValueRef.current=void 0,addSelected(val==="$create"?search:val))}},[addSelected,combobox,disabled,maxValues,search]),handleValueRemove=useCallback(item=>{let newSelected=selected.filter(v2=>v2.value!==item.value);onChange(newSelected.map(v2=>v2.resource)),setSelected(newSelected)},[selected,onChange]),handleKeyDown=useCallback(e=>{e.key==="Enter"?(timer||abortController)&&setAutoSubmit(!0):e.key==="Backspace"&&search.length===0&&(killEvent(e),handleValueRemove(selected[selected.length-1]))},[abortController,handleValueRemove,search.length,selected,timer]);useEffect(()=>()=>{abortControllerRef.current&&abortControllerRef.current.abort()},[]);let clearButton=!disabled&&clearable&&selected.length>0&&jsx10(Combobox.ClearButton,{title:"Clear all",size:16,onClear:()=>{setSearch(""),setSelected([]),onChange([]),combobox.closeDropdown()}});return jsxs3(Combobox,{store:combobox,onOptionSubmit:handleValueSelect,withinPortal:!0,shadow:"xl",...rest,children:[jsx10(Combobox.DropdownTarget,{children:jsx10(PillsInput,{label,description,error,className:props.className,leftSection,rightSection:abortController?jsx10(Loader2,{size:16}):clearButton,required,disabled,children:jsxs3(Pill.Group,{"data-testid":AsyncAutocompleteTestIds.selectedItems,children:[selected.map(item=>jsx10(PillComponent,{item,disabled,onRemove:()=>handleValueRemove(item)},item.value)),!disabled&&(maxValues===void 0||maxValues===0||selected.length<maxValues)&&jsx10(Combobox.EventsTarget,{children:jsx10(PillsInput.Field,{role:"searchbox",name,value:search,placeholder,onFocus:handleSearchChange,onBlur:()=>{combobox.closeDropdown(),setSearch("")},onKeyDown:handleKeyDown,onChange:handleSearchChange})})]})})}),jsx10(Combobox.Dropdown,{hidden:options.length===0,"data-testid":AsyncAutocompleteTestIds.options,children:jsx10(Combobox.Options,{children:jsxs3(ScrollAreaAutosize,{type:"scroll",mah:optionsDropdownMaxHeight,children:[options.map(item=>{let active=selected.some(v2=>v2.value===item.value);return jsx10(Combobox.Option,{value:item.value,active,children:jsx10(ItemComponent3,{...item,active})},item.value)}),creatable&&search.trim().length>0&&jsxs3(Combobox.Option,{value:"$create",children:["+ Create ",search]}),!creatable&&search.trim().length>0&&options.length===0&&jsx10(EmptyComponent,{search})]})})})]})}function toDefaultItems(defaultValue2){return defaultValue2?Array.isArray(defaultValue2)?defaultValue2:[defaultValue2]:[]}function DefaultItemComponent(props){return jsxs3(Group3,{gap:"xs",children:[props.active&&jsx10(IconCheck,{size:12}),jsx10("span",{children:props.label})]})}function DefaultPillComponent({item,disabled,onRemove}){return jsx10(Pill,{withRemoveButton:!disabled,onRemove,children:item.label})}function DefaultEmptyComponent(){return jsx10(Combobox.Empty,{children:"Nothing found"})}var HeaderSearchInput_default={searchInput:"HeaderSearchInput_searchInput"};import{jsx as jsx11,jsxs as jsxs4}from"react/jsx-runtime";function toOption(resource){return{value:resource.id,label:getDisplayString2(resource),resource}}function HeaderSearchInput(props){let navigate=se(),medplum=b(),loadData=useCallback2(async(input,signal)=>{let query=buildGraphQLQuery(input),options={signal},response=await medplum.graphql(query,void 0,void 0,options);return getResourcesFromResponse(response,input)},[medplum]),handleSelect=useCallback2(item=>{item.length>0&&navigate(`/${getReferenceString2(item[0])}`)},[navigate]);return jsx11(AsyncAutocomplete,{size:"sm",radius:"md",className:HeaderSearchInput_default.searchInput,leftSection:jsx11(IconSearch,{size:16}),placeholder:"Search",itemComponent:ItemComponent,toOption,onChange:handleSelect,loadOptions:loadData,maxValues:0,clearable:!1},`${props.pathname}?${props.searchParams}`)}var ItemComponent=forwardRef2(({resource,active:_active,...others},ref)=>{let helpText;return resource.resourceType==="Patient"?helpText=resource.birthDate:resource.resourceType==="ServiceRequest"&&(helpText=resource.subject?.display),jsx11("div",{ref,...others,children:jsxs4(Group4,{wrap:"nowrap",children:[jsx11(ResourceAvatar,{value:resource}),jsxs4("div",{children:[jsx11(Text2,{children:getDisplayString2(resource)}),jsx11(Text2,{size:"xs",c:"dimmed",children:helpText})]})]})})});function buildGraphQLQuery(input){let escaped=JSON.stringify(input);return isUUID(input)?`{
2
2
  Patients1: PatientList(_id: ${escaped}, _count: 1) {
3
3
  resourceType
4
4
  id