@medplum/app 4.1.7 → 4.1.8

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.
@@ -73,7 +73,7 @@ function n3(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
73
73
  Prefix can't start with '-' when allowNegative is true.
74
74
  prefix: `+a+`
75
75
  allowNegative: `+o+`
76
- `),o=!1),Object.assign(Object.assign({},e),{allowNegative:o})}function kL(e){e=_L(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,a=e.onKeyDown;a===void 0&&(a=Lo);var o=e.onBlur;o===void 0&&(o=Lo);var c=e.thousandSeparator,u=e.decimalScale,f=e.fixedDecimalScale,p=e.prefix;p===void 0&&(p="");var m=e.defaultValue,g=e.value,v=e.valueIsNumericString,b=e.onValueChange,S=mD(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),j=Np(e),C=j.decimalSeparator,R=j.allowedDecimalSeparators,D=function(P){return VC(P,e)},E=function(P,I){return DL(P,I,e)},T=ac(g)?m:g,A=v??RL(T,p,t);ac(g)?ac(m)||(A=A||typeof m=="number"):A=A||typeof g=="number";var k=function(P){return gD(P)?P:(typeof P=="number"&&(P=xD(P)),A&&typeof u=="number"?UC(P,u,!!f):P)},M=SD(k(g),k(m),!!A,D,E,b),L=M[0],$=L.numAsString,V=L.formattedValue,Y=M[1],Q=function(P){var I=P.target,z=P.key,H=I.selectionStart,O=I.selectionEnd,U=I.value;if(U===void 0&&(U=""),(z==="Backspace"||z==="Delete")&&O<p.length){P.preventDefault();return}if(H!==O){a(P);return}z==="Backspace"&&U[0]==="-"&&H===p.length+1&&n&&Cs(I,1),u&&f&&(z==="Backspace"&&U[H-1]===C?(Cs(I,H-1),P.preventDefault()):z==="Delete"&&U[H]===C&&P.preventDefault()),R!=null&&R.includes(z)&&U[H]===C&&Cs(I,H+1);var K=c===!0?",":c;z==="Backspace"&&U[H-1]===K&&Cs(I,H-1),z==="Delete"&&U[H]===K&&Cs(I,H+1),a(P)},J=function(P){var I=$;if(I.match(/\d/g)||(I=""),r||(I=pL(I)),f&&u&&(I=UC(I,u,f)),I!==$){var z=VC(I,e);Y({formattedValue:z,value:I,floatValue:parseFloat(I)},{event:P,source:ed.event})}o(P)},G=function(P){return P===C?!0:td(P)},Z=function(P){var I=P.currentValue,z=P.lastValue,H=P.formattedValue,O=P.currentValueIndex,U=P.formattedValueIndex,K=I[O],ee=H[U],be=bD(z,I),xe=be.to,ye=function(qe){return E(qe).indexOf(".")+p.length};return g===0&&f&&u&&I[xe.start]===C&&ye(I)<O&&ye(H)>U?!1:O>=xe.start&&O<xe.end&&R&&R.includes(K)&&ee===C?!0:K===ee};return Object.assign(Object.assign({},S),{value:V,valueIsNumericString:!1,isValidInputCharacter:G,isCharacterSame:Z,onValueChange:Y,format:D,removeFormatting:E,getCaretBoundary:function(P){return AL(P,e)},onKeyDown:Q,onBlur:J})}function PL(e){var t=kL(e);return Cn.createElement(CL,Object.assign({},t))}function FC({direction:e,style:t,...n}){return s.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:e==="up"?"rotate(180deg)":void 0,...t},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:s.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}var Ty={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};const NL=/^(0\.0*|-0(\.0*)?)$/,OL=/^-?0\d+(\.\d+)?\.?$/;function Ry(e){return typeof e=="string"&&e!==""&&!Number.isNaN(Number(e))}function Lv(e){return typeof e=="number"?e<Number.MAX_SAFE_INTEGER:e===""||Ry(e)&&Number(e)<Number.MAX_SAFE_INTEGER}function ML(e){return e.toString().replace(".","").length}function IL(e,t){return(typeof e=="number"?e<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&ML(t)<14&&t!==""}function HC(e,t,n){if(e===void 0)return!0;const r=t===void 0||e>=t,a=n===void 0||e<=n;return r&&a}const LL={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0},zL=(e,{size:t})=>({controls:{"--ni-chevron-size":rt(t,"ni-chevron-size")}});function $L(e,t,n){const r=e.toString().replace(/^0+/,""),a=parseFloat(r);return Number.isNaN(a)?r:a>Number.MAX_SAFE_INTEGER?t!==void 0?String(t):r:ph(a,n,t)}const Op=ve((e,t)=>{const n=se("NumberInput",LL,e),{className:r,classNames:a,styles:o,unstyled:c,vars:u,onChange:f,onValueChange:p,value:m,defaultValue:g,max:v,min:b,step:S,hideControls:j,rightSection:C,isAllowed:R,clampBehavior:D,onBlur:E,allowDecimal:T,decimalScale:A,onKeyDown:k,onKeyDownCapture:M,handlersRef:L,startValue:$,disabled:V,rightSectionPointerEvents:Y,allowNegative:Q,readOnly:J,size:G,rightSectionWidth:Z,stepHoldInterval:P,stepHoldDelay:I,allowLeadingZeros:z,withKeyboardEvents:H,trimLeadingZeroesOnBlur:O,...U}=n,K=Ie({name:"NumberInput",classes:Ty,props:n,classNames:a,styles:o,unstyled:c,vars:u,varsResolver:zL}),{resolvedClassNames:ee,resolvedStyles:be}=Qs({classNames:a,styles:o,props:n}),[xe,ye]=Yn({value:m,defaultValue:g,finalValue:"",onChange:f}),qe=I!==void 0&&P!==void 0,Ne=y.useRef(null),tt=y.useRef(null),Ae=y.useRef(0),gt=(Se,$e)=>{$e.source==="event"&&ye(IL(Se.floatValue,Se.value)&&!NL.test(Se.value)&&!(z&&OL.test(Se.value))?Se.floatValue:Se.value),p==null||p(Se,$e)},Mt=Se=>{const $e=String(Se).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return $e?Math.max(0,($e[1]?$e[1].length:0)-($e[2]?+$e[2]:0)):0},It=Se=>{Ne.current&&typeof Se<"u"&&Ne.current.setSelectionRange(Se,Se)},mt=y.useRef(Eh);mt.current=()=>{if(!Lv(xe))return;let Se;const $e=Mt(xe),vt=Mt(S),ft=Math.max($e,vt),Gt=10**ft;if(!Ry(xe)&&(typeof xe!="number"||Number.isNaN(xe)))Se=ph($,b,v);else if(v!==void 0){const un=(Math.round(Number(xe)*Gt)+Math.round(S*Gt))/Gt;Se=un<=v?un:v}else Se=(Math.round(Number(xe)*Gt)+Math.round(S*Gt))/Gt;const _t=Se.toFixed(ft);ye(parseFloat(_t)),p==null||p({floatValue:parseFloat(_t),formattedValue:_t,value:_t},{source:"increment"}),setTimeout(()=>{var un;return It((un=Ne.current)==null?void 0:un.value.length)},0)};const Dt=y.useRef(Eh);Dt.current=()=>{if(!Lv(xe))return;let Se;const $e=b!==void 0?b:Q?Number.MIN_SAFE_INTEGER:0,vt=Mt(xe),ft=Mt(S),Gt=Math.max(vt,ft),_t=10**Gt;if(!Ry(xe)&&typeof xe!="number"||Number.isNaN(xe))Se=ph($,$e,v);else{const wt=(Math.round(Number(xe)*_t)-Math.round(S*_t))/_t;Se=$e!==void 0&&wt<$e?$e:wt}const un=Se.toFixed(Gt);ye(parseFloat(un)),p==null||p({floatValue:parseFloat(un),formattedValue:un,value:un},{source:"decrement"}),setTimeout(()=>{var wt;return It((wt=Ne.current)==null?void 0:wt.value.length)},0)};const nn=Se=>{k==null||k(Se),!(J||!H)&&(Se.key==="ArrowUp"&&(Se.preventDefault(),mt.current()),Se.key==="ArrowDown"&&(Se.preventDefault(),Dt.current()))},Ce=Se=>{if(M==null||M(Se),Se.key==="Backspace"){const $e=Ne.current;$e.selectionStart===0&&$e.selectionStart===$e.selectionEnd&&(Se.preventDefault(),window.setTimeout(()=>It(0),0))}},Re=Se=>{let $e=xe;D==="blur"&&typeof $e=="number"&&($e=ph($e,b,v)),O&&typeof $e=="string"&&Mt($e)<15&&($e=$L($e,v,b)),xe!==$e&&ye($e),E==null||E(Se)};Ku(L,{increment:mt.current,decrement:Dt.current});const Ge=Se=>{Se?mt.current():Dt.current(),Ae.current+=1},Te=Se=>{if(Ge(Se),qe){const $e=typeof P=="number"?P:P(Ae.current);tt.current=window.setTimeout(()=>Te(Se),$e)}},me=(Se,$e)=>{var vt;Se.preventDefault(),(vt=Ne.current)==null||vt.focus(),Ge($e),qe&&(tt.current=window.setTimeout(()=>Te($e),I))},ge=()=>{tt.current&&window.clearTimeout(tt.current),tt.current=null,Ae.current=0},ke=s.jsxs("div",{...K("controls"),children:[s.jsx(tr,{...K("control"),tabIndex:-1,"aria-hidden":!0,disabled:V||typeof xe=="number"&&v!==void 0&&xe>=v,mod:{direction:"up"},onMouseDown:Se=>Se.preventDefault(),onPointerDown:Se=>{me(Se,!0)},onPointerUp:ge,onPointerLeave:ge,children:s.jsx(FC,{direction:"up"})}),s.jsx(tr,{...K("control"),tabIndex:-1,"aria-hidden":!0,disabled:V||typeof xe=="number"&&b!==void 0&&xe<=b,mod:{direction:"down"},onMouseDown:Se=>Se.preventDefault(),onPointerDown:Se=>{me(Se,!1)},onPointerUp:ge,onPointerLeave:ge,children:s.jsx(FC,{direction:"down"})})]});return s.jsx(Pr,{component:PL,allowNegative:Q,className:Ut(Ty.root,r),size:G,...U,readOnly:J,disabled:V,value:xe,getInputRef:zn(t,Ne),onValueChange:gt,rightSection:j||J||!Lv(xe)?C:C||ke,classNames:ee,styles:be,unstyled:c,__staticSelector:"NumberInput",decimalScale:T?A:0,onKeyDown:nn,onKeyDownCapture:Ce,rightSectionPointerEvents:Y??(V?"none":void 0),rightSectionWidth:Z??`var(--ni-right-section-width-${G||"sm"})`,allowLeadingZeros:z,onBlur:Re,isAllowed:Se=>D==="strict"?R?R(Se)&&HC(Se.floatValue,b,v):HC(Se.floatValue,b,v):R?R(Se):!0})});Op.classes={...Pr.classes,...Ty};Op.displayName="@mantine/core/NumberInput";const[UL,Mp]=vr("Pagination.Root component was not found in tree");var yd={root:"m_4addd315",control:"m_326d024a",dots:"m_4ad7767d"};const BL={withPadding:!0},xd=ve((e,t)=>{const n=se("PaginationControl",BL,e),{classNames:r,className:a,style:o,styles:c,vars:u,active:f,disabled:p,withPadding:m,mod:g,...v}=n,b=Mp(),S=p||b.disabled;return s.jsx(tr,{ref:t,disabled:S,mod:[{active:f,disabled:S,"with-padding":m},g],...b.getStyles("control",{className:a,style:o,classNames:r,styles:c,active:!S}),...v})});xd.classes=yd;xd.displayName="@mantine/core/PaginationControl";function bd({style:e,children:t,path:n,...r}){return s.jsx("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)",...e},...r,children:s.jsx("path",{d:n,fill:"currentColor"})})}const VL=e=>s.jsx(bd,{...e,path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"}),FL=e=>s.jsx(bd,{...e,path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"}),HL=e=>s.jsx(bd,{...e,path:"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z"}),qL=e=>s.jsx(bd,{...e,path:"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z"}),GL=e=>s.jsx(bd,{...e,path:"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z"}),QL={icon:GL},Ip=ve((e,t)=>{const n=se("PaginationDots",QL,e),{classNames:r,className:a,style:o,styles:c,vars:u,icon:f,...p}=n,m=Mp(),g=f;return s.jsx(ce,{ref:t,...m.getStyles("dots",{className:a,style:o,styles:c,classNames:r}),...p,children:s.jsx(g,{style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});Ip.classes=yd;Ip.displayName="@mantine/core/PaginationDots";function Lp({icon:e,name:t,action:n,type:r}){const a={icon:e},o=y.forwardRef((c,u)=>{const{icon:f,...p}=se(t,a,c),m=f,g=Mp(),v=r==="next"?g.active===g.total:g.active===1;return s.jsx(xd,{disabled:g.disabled||v,ref:u,onClick:g[n],withPadding:!1,...p,children:s.jsx(m,{className:"mantine-rotate-rtl",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});return o.displayName=`@mantine/core/${t}`,o}const wD=Lp({icon:VL,name:"PaginationNext",action:"onNext",type:"next"}),jD=Lp({icon:FL,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),CD=Lp({icon:HL,name:"PaginationFirst",action:"onFirst",type:"previous"}),ED=Lp({icon:qL,name:"PaginationLast",action:"onLast",type:"next"});function R0({dotsIcon:e}){const t=Mp(),n=t.range.map((r,a)=>{var o,c,u;return r==="dots"?s.jsx(Ip,{icon:e},a):s.jsx(xd,{active:r===t.active,"aria-current":r===t.active?"page":void 0,onClick:()=>t.onChange(r),disabled:t.disabled,...(o=t.getItemProps)==null?void 0:o.call(t,r),children:((u=(c=t.getItemProps)==null?void 0:c.call(t,r))==null?void 0:u.children)??r},a)});return s.jsx(s.Fragment,{children:n})}R0.displayName="@mantine/core/PaginationItems";const WL={siblings:1,boundaries:1},YL=(e,{size:t,radius:n,color:r,autoContrast:a})=>({root:{"--pagination-control-radius":n===void 0?void 0:Vt(n),"--pagination-control-size":rt(t,"pagination-control-size"),"--pagination-control-fz":On(t),"--pagination-active-bg":r?Ht(r,e):void 0,"--pagination-active-color":Ws(a,e)?Gi({color:r,theme:e,autoContrast:a}):void 0}}),zp=ve((e,t)=>{const n=se("PaginationRoot",WL,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,total:p,value:m,defaultValue:g,onChange:v,disabled:b,siblings:S,boundaries:j,color:C,radius:R,onNextPage:D,onPreviousPage:E,onFirstPage:T,onLastPage:A,getItemProps:k,autoContrast:M,...L}=n,$=Ie({name:"Pagination",classes:yd,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:YL}),{range:V,setPage:Y,next:Q,previous:J,active:G,first:Z,last:P}=pN({page:m,initialPage:g,onChange:v,total:p,siblings:S,boundaries:j}),I=Rr(D,Q),z=Rr(E,J),H=Rr(T,Z),O=Rr(A,P);return s.jsx(UL,{value:{total:p,range:V,active:G,disabled:b,getItemProps:k,onChange:Y,onNext:I,onPrevious:z,onFirst:H,onLast:O,getStyles:$},children:s.jsx(ce,{ref:t,...$("root"),...L})})});zp.classes=yd;zp.displayName="@mantine/core/PaginationRoot";const KL={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},$a=ve((e,t)=>{const n=se("Pagination",KL,e),{withEdges:r,withControls:a,getControlProps:o,nextIcon:c,previousIcon:u,lastIcon:f,firstIcon:p,dotsIcon:m,total:g,gap:v,hideWithOnePage:b,withPages:S,...j}=n;return g<=0||b&&g===1?null:s.jsx(zp,{ref:t,total:g,...j,children:s.jsxs(je,{gap:v,children:[r&&s.jsx(CD,{icon:p,...o==null?void 0:o("first")}),a&&s.jsx(jD,{icon:u,...o==null?void 0:o("previous")}),S&&s.jsx(R0,{dotsIcon:m}),a&&s.jsx(wD,{icon:c,...o==null?void 0:o("next")}),r&&s.jsx(ED,{icon:f,...o==null?void 0:o("last")})]})})});$a.classes=yd;$a.displayName="@mantine/core/Pagination";$a.Root=zp;$a.Control=xd;$a.Dots=Ip;$a.First=CD;$a.Last=ED;$a.Next=wD;$a.Previous=jD;$a.Items=R0;const XL=({reveal:e})=>s.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"var(--psi-icon-size)",height:"var(--psi-icon-size)"},children:s.jsx("path",{d:e?"M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z":"M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})});var Dy={root:"m_f61ca620",input:"m_ccf8da4c",innerInput:"m_f2d85dd2",visibilityToggle:"m_b1072d44"};const ZL={visibilityToggleIcon:XL},JL=(e,{size:t})=>({root:{"--psi-icon-size":rt(t,"psi-icon-size"),"--psi-button-size":rt(t,"psi-button-size")}}),Na=ve((e,t)=>{const n=se("PasswordInput",ZL,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,required:p,error:m,leftSection:g,disabled:v,id:b,variant:S,inputContainer:j,description:C,label:R,size:D,errorProps:E,descriptionProps:T,labelProps:A,withAsterisk:k,inputWrapperOrder:M,wrapperProps:L,radius:$,rightSection:V,rightSectionWidth:Y,rightSectionPointerEvents:Q,leftSectionWidth:J,visible:G,defaultVisible:Z,onVisibilityChange:P,visibilityToggleIcon:I,visibilityToggleButtonProps:z,rightSectionProps:H,leftSectionProps:O,leftSectionPointerEvents:U,withErrorStyles:K,mod:ee,...be}=n,xe=yr(b),[ye,qe]=Yn({value:G,defaultValue:Z,finalValue:!1,onChange:P}),Ne=()=>qe(!ye),tt=Ie({name:"PasswordInput",classes:Dy,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:JL}),{resolvedClassNames:Ae,resolvedStyles:gt}=Qs({classNames:r,styles:c,props:n}),{styleProps:Mt,rest:It}=Qi(be),mt=I,Dt=(E==null?void 0:E.id)||`${xe}-error`,nn=(T==null?void 0:T.id)||`${xe}-description`,Ge=`${!!m&&typeof m!="boolean"?Dt:""} ${!!C?nn:""}`,Te=Ge.trim().length>0?Ge.trim():void 0,me=s.jsx(_n,{...tt("visibilityToggle"),disabled:v,radius:$,"aria-hidden":!z,tabIndex:-1,...z,variant:(z==null?void 0:z.variant)??"subtle",color:"gray",unstyled:u,onTouchEnd:ge=>{var ke;ge.preventDefault(),(ke=z==null?void 0:z.onTouchEnd)==null||ke.call(z,ge),Ne()},onMouseDown:ge=>{var ke;ge.preventDefault(),(ke=z==null?void 0:z.onMouseDown)==null||ke.call(z,ge),Ne()},onKeyDown:ge=>{var ke;(ke=z==null?void 0:z.onKeyDown)==null||ke.call(z,ge),ge.key===" "&&(ge.preventDefault(),Ne())},children:s.jsx(mt,{reveal:ye})});return s.jsx(mn.Wrapper,{required:p,id:xe,label:R,error:m,description:C,size:D,classNames:Ae,styles:gt,__staticSelector:"PasswordInput",unstyled:u,withAsterisk:k,inputWrapperOrder:M,inputContainer:j,variant:S,labelProps:{...A,htmlFor:xe},descriptionProps:{...T,id:nn},errorProps:{...E,id:Dt},mod:ee,...tt("root"),...Mt,...L,children:s.jsx(mn,{component:"div",error:m,leftSection:g,size:D,classNames:{...Ae,input:Ut(Dy.input,Ae.input)},styles:gt,radius:$,disabled:v,__staticSelector:"PasswordInput",rightSectionWidth:Y,rightSection:V??me,variant:S,unstyled:u,leftSectionWidth:J,rightSectionPointerEvents:Q||"all",rightSectionProps:H,leftSectionProps:O,leftSectionPointerEvents:U,withAria:!1,withErrorStyles:K,children:s.jsx("input",{required:p,"data-invalid":!!m||void 0,"data-with-left-section":!!g||void 0,...tt("innerInput"),disabled:v,id:xe,ref:t,...It,"aria-describedby":Te,autoComplete:It.autoComplete||"off",type:ye?"text":"password"})})})});Na.classes={...Pr.classes,...Dy};Na.displayName="@mantine/core/PasswordInput";const[e6,TD]=Hi(),[t6,n6]=Hi();var RD={card:"m_9dc8ae12"};const r6={withBorder:!0},a6=(e,{radius:t})=>({card:{"--card-radius":Vt(t)}}),D0=ve((e,t)=>{const n=se("RadioCard",r6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,checked:p,mod:m,withBorder:g,value:v,onClick:b,name:S,onKeyDown:j,...C}=n,R=Ie({name:"RadioCard",classes:RD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:a6,rootSelector:"card"}),{dir:D}=Ks(),E=TD(),T=typeof p=="boolean"?p:(E==null?void 0:E.value)===v||!1,A=S||(E==null?void 0:E.name),k=M=>{if(j==null||j(M),["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(M.nativeEvent.code)){M.preventDefault();const L=Array.from(document.querySelectorAll(`[role="radio"][name="${A||"__mantine"}"]`)),$=L.findIndex(Q=>Q===M.target),V=$+1>=L.length?0:$+1,Y=$-1<0?L.length-1:$-1;M.nativeEvent.code==="ArrowDown"&&(L[V].focus(),L[V].click()),M.nativeEvent.code==="ArrowUp"&&(L[Y].focus(),L[Y].click()),M.nativeEvent.code==="ArrowLeft"&&(L[D==="ltr"?Y:V].focus(),L[D==="ltr"?Y:V].click()),M.nativeEvent.code==="ArrowRight"&&(L[D==="ltr"?V:Y].focus(),L[D==="ltr"?V:Y].click())}};return s.jsx(t6,{value:{checked:T},children:s.jsx(tr,{ref:t,mod:[{"with-border":g,checked:T},m],...R("card"),...C,role:"radio","aria-checked":T,name:A,onClick:M=>{b==null||b(M),E==null||E.onChange(v||"")},onKeyDown:k})})});D0.displayName="@mantine/core/RadioCard";D0.classes=RD;const i6={},A0=ve((e,t)=>{const{value:n,defaultValue:r,onChange:a,size:o,wrapperProps:c,children:u,name:f,readOnly:p,...m}=se("RadioGroup",i6,e),g=yr(f),[v,b]=Yn({value:n,defaultValue:r,finalValue:"",onChange:a}),S=j=>!p&&b(typeof j=="string"?j:j.currentTarget.value);return s.jsx(e6,{value:{value:v,onChange:S,size:o,name:g},children:s.jsx(mn.Wrapper,{size:o,ref:t,...c,...m,labelElement:"div",__staticSelector:"RadioGroup",children:s.jsx(t0,{role:"radiogroup",children:u})})})});A0.classes=mn.Wrapper.classes;A0.displayName="@mantine/core/RadioGroup";function DD({size:e,style:t,...n}){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:le(e),height:le(e),...t},"aria-hidden":!0,...n,children:s.jsx("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"})})}var AD={indicator:"m_717d7ff6",icon:"m_3e4da632","indicator--outline":"m_2980836c"};const o6={icon:DD},s6=(e,{radius:t,color:n,size:r,iconColor:a,variant:o,autoContrast:c})=>{const u=fa({color:n||e.primaryColor,theme:e}),f=u.isThemeColor&&u.shade===void 0?`var(--mantine-color-${u.color}-outline)`:u.color;return{indicator:{"--radio-size":rt(r,"radio-size"),"--radio-radius":t===void 0?void 0:Vt(t),"--radio-color":o==="outline"?f:Ht(n,e),"--radio-icon-size":rt(r,"radio-icon-size"),"--radio-icon-color":a?Ht(a,e):Ws(c,e)?Gi({color:n,theme:e,autoContrast:c}):void 0}}},_0=ve((e,t)=>{const n=se("RadioIndicator",o6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,icon:p,radius:m,color:g,iconColor:v,autoContrast:b,checked:S,mod:j,variant:C,disabled:R,...D}=n,E=p,T=Ie({name:"RadioIndicator",classes:AD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:s6,rootSelector:"indicator"}),A=n6(),k=typeof S=="boolean"?S:(A==null?void 0:A.checked)||!1;return s.jsx(ce,{ref:t,...T("indicator",{variant:C}),variant:C,mod:[{checked:k,disabled:R},j],...D,children:s.jsx(E,{...T("icon")})})});_0.displayName="@mantine/core/RadioIndicator";_0.classes=AD;var _D={root:"m_f3f1af94",inner:"m_89c4f5e4",icon:"m_f3ed6b2b",radio:"m_8a3dbb89","radio--outline":"m_1bfe9d39"};const l6={labelPosition:"right"},c6=(e,{size:t,radius:n,color:r,iconColor:a,variant:o,autoContrast:c})=>{const u=fa({color:r||e.primaryColor,theme:e}),f=u.isThemeColor&&u.shade===void 0?`var(--mantine-color-${u.color}-outline)`:u.color;return{root:{"--radio-size":rt(t,"radio-size"),"--radio-radius":n===void 0?void 0:Vt(n),"--radio-color":o==="outline"?f:Ht(r,e),"--radio-icon-color":a?Ht(a,e):Ws(c,e)?Gi({color:r,theme:e,autoContrast:c}):void 0,"--radio-icon-size":rt(t,"radio-icon-size")}}},zs=ve((e,t)=>{const n=se("Radio",l6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,id:p,size:m,label:g,labelPosition:v,description:b,error:S,radius:j,color:C,variant:R,disabled:D,wrapperProps:E,icon:T=DD,rootRef:A,iconColor:k,onChange:M,mod:L,...$}=n,V=Ie({name:"Radio",classes:_D,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:c6}),Y=TD(),Q=(Y==null?void 0:Y.size)??m,J=n.size?m:Q,{styleProps:G,rest:Z}=Qi($),P=yr(p),I=Y?{checked:Y.value===Z.value,name:Z.name??Y.name,onChange:z=>{Y.onChange(z),M==null||M(z)}}:{};return s.jsx(bp,{...V("root"),__staticSelector:"Radio",__stylesApiProps:n,id:P,size:J,labelPosition:v,label:g,description:b,error:S,disabled:D,classNames:r,styles:c,unstyled:u,"data-checked":I.checked||void 0,variant:R,ref:A,mod:L,...G,...E,children:s.jsxs(ce,{...V("inner"),mod:{"label-position":v},children:[s.jsx(ce,{...V("radio",{focusable:!0,variant:R}),onChange:M,...Z,...I,component:"input",mod:{error:!!S},ref:t,id:P,disabled:D,type:"radio"}),s.jsx(T,{...V("icon"),"aria-hidden":!0})]})})});zs.classes=_D;zs.displayName="@mantine/core/Radio";zs.Group=A0;zs.Card=D0;zs.Indicator=_0;const u6={duration:100,transition:"fade"};function d6(e,t){return{...u6,...t,...e}}function f6({offset:e,position:t,defaultOpened:n}){const[r,a]=y.useState(n),o=y.useRef(null),{x:c,y:u,elements:f,refs:p,update:m,placement:g}=Dx({placement:t,middleware:[Cx({crossAxis:!0,padding:5,rootBoundary:"document"})]}),v=g.includes("right")?e:t.includes("left")?e*-1:0,b=g.includes("bottom")?e:t.includes("top")?e*-1:0,S=y.useCallback(({clientX:j,clientY:C})=>{p.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:j,y:C,left:j+v,top:C+b,right:j,bottom:C}}})},[f.reference]);return y.useEffect(()=>{if(p.floating.current){const j=o.current;j.addEventListener("mousemove",S);const C=Ii(p.floating.current);return C.forEach(R=>{R.addEventListener("scroll",m)}),()=>{j.removeEventListener("mousemove",S),C.forEach(R=>{R.removeEventListener("scroll",m)})}}},[f.reference,p.floating.current,m,S,r]),{handleMouseMove:S,x:c,y:u,opened:r,setOpened:a,boundaryRef:o,floating:p.setFloating}}var $p={tooltip:"m_1b3c8819",arrow:"m_f898399f"};const h6={refProp:"ref",withinPortal:!0,offset:10,defaultOpened:!1,position:"right",zIndex:Wr("popover")},p6=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:Vt(t),"--tooltip-bg":n?Ht(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),k0=ve((e,t)=>{const n=se("TooltipFloating",h6,e),{children:r,refProp:a,withinPortal:o,style:c,className:u,classNames:f,styles:p,unstyled:m,radius:g,color:v,label:b,offset:S,position:j,multiline:C,zIndex:R,disabled:D,defaultOpened:E,variant:T,vars:A,portalProps:k,...M}=n,L=Sn(),$=Ie({name:"TooltipFloating",props:n,classes:$p,className:u,style:c,classNames:f,styles:p,unstyled:m,rootSelector:"tooltip",vars:A,varsResolver:p6}),{handleMouseMove:V,x:Y,y:Q,opened:J,boundaryRef:G,floating:Z,setOpened:P}=f6({offset:S,position:j,defaultOpened:E});if(!Fi(r))throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const I=zn(G,op(r),t),z=r.props,H=U=>{var K;(K=z.onMouseEnter)==null||K.call(z,U),V(U),P(!0)},O=U=>{var K;(K=z.onMouseLeave)==null||K.call(z,U),P(!1)};return s.jsxs(s.Fragment,{children:[s.jsx(qo,{...k,withinPortal:o,children:s.jsx(ce,{...M,...$("tooltip",{style:{...wR(c,L),zIndex:R,display:!D&&J?"block":"none",top:(Q&&Math.round(Q))??"",left:(Y&&Math.round(Y))??""}}),variant:T,ref:Z,mod:{multiline:C},children:b})}),y.cloneElement(r,{...z,[a]:I,onMouseEnter:H,onMouseLeave:O})]})});k0.classes=$p;k0.displayName="@mantine/core/TooltipFloating";const kD=y.createContext(!1),m6=kD.Provider,g6=()=>y.useContext(kD),v6={openDelay:0,closeDelay:0};function P0(e){const{openDelay:t,closeDelay:n,children:r}=se("TooltipGroup",v6,e);return s.jsx(m6,{value:!0,children:s.jsx(GM,{delay:{open:t,close:n},children:r})})}P0.displayName="@mantine/core/TooltipGroup";P0.extend=e=>e;function y6(e){if(e===void 0)return{shift:!0,flip:!0};const t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function x6(e){const t=y6(e.middlewares),n=[UR(e.offset)];return t.shift&&n.push(Cx(typeof t.shift=="boolean"?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip=="boolean"?kh():kh(t.flip)),n.push(BR({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline=="boolean"?Gu():Gu(t.inline)):e.inline&&n.push(Gu()),n}function b6(e){var k,M,L;const[t,n]=y.useState(e.defaultOpened),a=typeof e.opened=="boolean"?e.opened:t,o=g6(),c=yr(),u=y.useCallback($=>{n($),$&&D(c)},[c]),{x:f,y:p,context:m,refs:g,update:v,placement:b,middlewareData:{arrow:{x:S,y:j}={}}}=Dx({strategy:e.strategy,placement:e.position,open:a,onOpenChange:u,middleware:x6(e)}),{delay:C,currentId:R,setCurrentId:D}=QM(m,{id:c}),{getReferenceProps:E,getFloatingProps:T}=e9([HM(m,{enabled:(k=e.events)==null?void 0:k.hover,delay:o?C:{open:e.openDelay,close:e.closeDelay},mouseOnly:!((M=e.events)!=null&&M.touch)}),JM(m,{enabled:(L=e.events)==null?void 0:L.focus,visibleOnly:!0}),n9(m,{role:"tooltip"}),XM(m,{enabled:typeof e.opened>"u"})]);h2({opened:a,position:e.position,positionDependencies:e.positionDependencies,floating:{refs:g,update:v}}),zi(()=>{var $;($=e.onPositionChange)==null||$.call(e,b)},[b]);const A=a&&R&&R!==c;return{x:f,y:p,arrowX:S,arrowY:j,reference:g.setReference,floating:g.setFloating,getFloatingProps:T,getReferenceProps:E,isGroupPhase:A,opened:a,placement:b}}const qC={position:"top",refProp:"ref",withinPortal:!0,inline:!1,defaultOpened:!1,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:Wr("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},S6=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:Vt(t),"--tooltip-bg":n?Ht(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),Zs=ve((e,t)=>{const n=se("Tooltip",qC,e),{children:r,position:a,refProp:o,label:c,openDelay:u,closeDelay:f,onPositionChange:p,opened:m,defaultOpened:g,withinPortal:v,radius:b,color:S,classNames:j,styles:C,unstyled:R,style:D,className:E,withArrow:T,arrowSize:A,arrowOffset:k,arrowRadius:M,arrowPosition:L,offset:$,transitionProps:V,multiline:Y,events:Q,zIndex:J,disabled:G,positionDependencies:Z,onClick:P,onMouseEnter:I,onMouseLeave:z,inline:H,variant:O,keepMounted:U,vars:K,portalProps:ee,mod:be,floatingStrategy:xe,middlewares:ye,...qe}=se("Tooltip",qC,n),{dir:Ne}=Ks(),tt=y.useRef(null),Ae=b6({position:o2(Ne,a),closeDelay:f,openDelay:u,onPositionChange:p,opened:m,defaultOpened:g,events:Q,arrowRef:tt,arrowOffset:k,offset:typeof $=="number"?$+(T?A/2:0):$,positionDependencies:[...Z,r],inline:H,strategy:xe,middlewares:ye}),gt=Ie({name:"Tooltip",props:n,classes:$p,className:E,style:D,classNames:j,styles:C,unstyled:R,rootSelector:"tooltip",vars:K,varsResolver:S6});if(!Fi(r))throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const Mt=zn(Ae.reference,op(r),t),It=d6(V,{duration:100,transition:"fade"}),mt=r.props;return s.jsxs(s.Fragment,{children:[s.jsx(qo,{...ee,withinPortal:v,children:s.jsx(di,{...It,keepMounted:U,mounted:!G&&!!Ae.opened,duration:Ae.isGroupPhase?10:It.duration,children:Dt=>s.jsxs(ce,{...qe,"data-fixed":xe==="fixed"||void 0,variant:O,mod:[{multiline:Y},be],...Ae.getFloatingProps({ref:Ae.floating,className:gt("tooltip").className,style:{...gt("tooltip").style,...Dt,zIndex:J,top:Ae.y??0,left:Ae.x??0}}),children:[c,s.jsx(Px,{ref:tt,arrowX:Ae.arrowX,arrowY:Ae.arrowY,visible:T,position:Ae.placement,arrowSize:A,arrowOffset:k,arrowRadius:M,arrowPosition:L,...gt("arrow")})]})})}),y.cloneElement(r,Ae.getReferenceProps({onClick:P,onMouseEnter:I,onMouseLeave:z,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,className:Ut(E,mt.className),...mt,[o]:Mt}))]})});Zs.classes=$p;Zs.displayName="@mantine/core/Tooltip";Zs.Floating=k0;Zs.Group=P0;function w6({size:e,thickness:t,sum:n,value:r,root:a,offset:o}){const c=(e*.9-t*2)/2,u=Math.PI*c*2/100,f=a||r===void 0?`${(100-n)*u}, ${n*u}`:`${r*u}, ${(100-r)*u}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:c||0,transform:a?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:f,strokeDashoffset:a?0:o||0}}function PD({size:e,value:t,offset:n,sum:r,thickness:a,root:o,color:c,lineRoundCaps:u,tooltip:f,getStyles:p,display:m,...g}){const v=Sn();return s.jsx(Zs.Floating,{disabled:!f,label:f,children:s.jsx(ce,{component:"circle",...g,...p("curve"),__vars:{"--curve-color":c?Ht(c,v):void 0},fill:"none",strokeLinecap:u?"round":"butt",...w6({sum:r,size:e,thickness:a,value:t,offset:n,root:o})})})}PD.displayName="@mantine/core/Curve";function j6({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:a}){const o=n.reduce((m,g)=>m+g.value,0),c=Math.PI*((e*.9-t*2)/2)*2;let u=c;const f=[],p=[];for(let m=0;m<n.length;m+=1)f.push({sum:o,offset:u,data:n[m],root:!1}),u-=n[m].value/100*c;if(f.push({sum:o,offset:u,data:{color:a},root:!0}),p.push({...f[f.length-1],lineRoundCaps:!1}),f.length>2){p.push({...f[0],lineRoundCaps:r}),p.push({...f[f.length-2],lineRoundCaps:r});for(let m=1;m<=f.length-3;m+=1)p.push({...f[m],lineRoundCaps:!1})}else p.push({...f[0],lineRoundCaps:r});return p}var ND={root:"m_b32e4812",svg:"m_d43b5134",curve:"m_b1ca1fbf",label:"m_b23f9dc4"};function C6(e,t){return Math.min(e||12,(t||120)/4)}const E6={size:120,thickness:12},T6=(e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":le(t),"--rp-label-offset":le(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}}),Up=ve((e,t)=>{const n=se("RingProgress",E6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,label:p,sections:m,size:g,thickness:v,roundCaps:b,rootColor:S,transitionDuration:j,...C}=n,R=Ie({name:"RingProgress",classes:ND,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:T6}),D=C6(v,g),E=j6({size:g,thickness:D,sections:m,renderRoundedLineCaps:b,rootColor:S}).map(({data:T,sum:A,root:k,lineRoundCaps:M,offset:L},$)=>y.createElement(PD,{...T,key:$,size:g,thickness:D,sum:A,offset:L,color:T==null?void 0:T.color,root:k,lineRoundCaps:M,getStyles:R}));return s.jsxs(ce,{...R("root"),size:g,ref:t,...C,children:[s.jsx("svg",{...R("svg"),children:E}),p&&s.jsx("div",{...R("label"),children:p})]})});Up.classes=ND;Up.displayName="@mantine/core/RingProgress";var OD={root:"m_cf365364",indicator:"m_9e182ccd",label:"m_1738fcb2",input:"m_1714d588",control:"m_69686b9b",innerLabel:"m_78882f40"};const R6={withItemsBorders:!0},D6=(e,{radius:t,color:n,transitionDuration:r,size:a,transitionTimingFunction:o})=>({root:{"--sc-radius":t===void 0?void 0:Vt(t),"--sc-color":n?Ht(n,e):void 0,"--sc-shadow":n?void 0:"var(--mantine-shadow-xs)","--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":o,"--sc-padding":rt(a,"sc-padding"),"--sc-font-size":On(a)}}),Bp=ve((e,t)=>{var Ne,tt;const n=se("SegmentedControl",R6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,data:p,value:m,defaultValue:g,onChange:v,size:b,name:S,disabled:j,readOnly:C,fullWidth:R,orientation:D,radius:E,color:T,transitionDuration:A,transitionTimingFunction:k,variant:M,autoContrast:L,withItemsBorders:$,mod:V,...Y}=n,Q=Ie({name:"SegmentedControl",props:n,classes:OD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:D6}),J=Sn(),G=p.map(Ae=>typeof Ae=="string"?{label:Ae,value:Ae}:Ae),Z=bN(),[P,I]=y.useState(Th()),[z,H]=y.useState(null),[O,U]=y.useState({}),K=(Ae,gt)=>{O[gt]=Ae,U(O)},[ee,be]=Yn({value:m,defaultValue:g,finalValue:Array.isArray(p)?((Ne=G.find(Ae=>!Ae.disabled))==null?void 0:Ne.value)??((tt=p[0])==null?void 0:tt.value)??null:null,onChange:v}),xe=yr(S),ye=G.map(Ae=>y.createElement(ce,{...Q("control"),mod:{active:ee===Ae.value,orientation:D},key:Ae.value},y.createElement("input",{...Q("input"),disabled:j||Ae.disabled,type:"radio",name:xe,value:Ae.value,id:`${xe}-${Ae.value}`,checked:ee===Ae.value,onChange:()=>!C&&be(Ae.value),"data-focus-ring":J.focusRing,key:`${Ae.value}-input`}),y.createElement(ce,{component:"label",...Q("label"),mod:{active:ee===Ae.value&&!(j||Ae.disabled),disabled:j||Ae.disabled,"read-only":C},htmlFor:`${xe}-${Ae.value}`,ref:gt=>K(gt,Ae.value),__vars:{"--sc-label-color":T!==void 0?Gi({color:T,theme:J,autoContrast:L}):void 0},key:`${Ae.value}-label`},s.jsx("span",{...Q("innerLabel"),children:Ae.label})))),qe=zn(t,Ae=>H(Ae));return vN(()=>{I(Th())},[p.length]),p.length===0?null:s.jsxs(ce,{...Q("root"),variant:M,size:b,ref:qe,mod:[{"full-width":R,orientation:D,initialized:Z,"with-items-borders":$},V],...Y,role:"radiogroup","data-disabled":j,children:[typeof ee=="string"&&s.jsx(zx,{target:O[ee],parent:z,component:"span",transitionDuration:"var(--sc-transition-duration)",...Q("indicator")},P),ye]})});Bp.classes=OD;Bp.displayName="@mantine/core/SegmentedControl";function A6({spacing:e,verticalSpacing:t,cols:n,selector:r}){var m;const a=Sn(),o=t===void 0?e:t,c=Ho({"--sg-spacing-x":Nn(_a(e)),"--sg-spacing-y":Nn(_a(o)),"--sg-cols":(m=_a(n))==null?void 0:m.toString()}),u=sn(a.breakpoints).reduce((g,v)=>(g[v]||(g[v]={}),typeof e=="object"&&e[v]!==void 0&&(g[v]["--sg-spacing-x"]=Nn(e[v])),typeof o=="object"&&o[v]!==void 0&&(g[v]["--sg-spacing-y"]=Nn(o[v])),typeof n=="object"&&n[v]!==void 0&&(g[v]["--sg-cols"]=n[v]),g),{}),p=Yu(sn(u),a.breakpoints).filter(g=>sn(u[g.value]).length>0).map(g=>({query:`(min-width: ${a.breakpoints[g.value]})`,styles:u[g.value]}));return s.jsx(Ys,{styles:c,media:p,selector:r})}function zv(e){return typeof e=="object"&&e!==null?sn(e):[]}function _6(e){return e.sort((t,n)=>Wu(t)-Wu(n))}function k6({spacing:e,verticalSpacing:t,cols:n}){const r=Array.from(new Set([...zv(e),...zv(t),...zv(n)]));return _6(r)}function P6({spacing:e,verticalSpacing:t,cols:n,selector:r}){var p;const a=t===void 0?e:t,o=Ho({"--sg-spacing-x":Nn(_a(e)),"--sg-spacing-y":Nn(_a(a)),"--sg-cols":(p=_a(n))==null?void 0:p.toString()}),c=k6({spacing:e,verticalSpacing:t,cols:n}),u=c.reduce((m,g)=>(m[g]||(m[g]={}),typeof e=="object"&&e[g]!==void 0&&(m[g]["--sg-spacing-x"]=Nn(e[g])),typeof a=="object"&&a[g]!==void 0&&(m[g]["--sg-spacing-y"]=Nn(a[g])),typeof n=="object"&&n[g]!==void 0&&(m[g]["--sg-cols"]=n[g]),m),{}),f=c.map(m=>({query:`simple-grid (min-width: ${m})`,styles:u[m]}));return s.jsx(Ys,{styles:o,container:f,selector:r})}var MD={container:"m_925c2d2c",root:"m_2415a157"};const N6={cols:1,spacing:"md",type:"media"},N0=ve((e,t)=>{const n=se("SimpleGrid",N6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,cols:p,verticalSpacing:m,spacing:g,type:v,...b}=n,S=Ie({name:"SimpleGrid",classes:MD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f}),j=ud();return v==="container"?s.jsxs(s.Fragment,{children:[s.jsx(P6,{...n,selector:`.${j}`}),s.jsx("div",{...S("container"),children:s.jsx(ce,{ref:t,...S("root",{className:j}),...b})})]}):s.jsxs(s.Fragment,{children:[s.jsx(A6,{...n,selector:`.${j}`}),s.jsx(ce,{ref:t,...S("root",{className:j}),...b})]})});N0.classes=MD;N0.displayName="@mantine/core/SimpleGrid";const O6={},Vp=ve((e,t)=>{const{w:n,h:r,miw:a,mih:o,...c}=se("Space",O6,e);return s.jsx(ce,{ref:t,...c,w:n,miw:a??n,h:r,mih:o??r})});Vp.displayName="@mantine/core/Space";var ID={root:"m_6d731127"};const M6={gap:"md",align:"stretch",justify:"flex-start"},I6=(e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":Nn(t),"--stack-align":n,"--stack-justify":r}}),We=ve((e,t)=>{const n=se("Stack",M6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,align:p,justify:m,gap:g,variant:v,...b}=n,S=Ie({name:"Stack",props:n,classes:ID,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:I6});return s.jsx(ce,{ref:t,...S("root"),variant:v,...b})});We.classes=ID;We.displayName="@mantine/core/Stack";const[L6,z6]=vr("Stepper component was not found in tree"),Nh=()=>null;Nh.displayName="@mantine/core/StepperCompleted";var O0={root:"m_cbb4ea7e",steps:"m_aaf89d0b",separator:"m_2a371ac9",content:"m_78da155d",step:"m_cbb57068","step--horizontal":"m_f56b1e2c","step--vertical":"m_833edb7e",verticalSeparator:"m_6496b3f3",stepWrapper:"m_818e70b",stepIcon:"m_1959ad01",stepCompletedIcon:"m_a79331dc",stepBody:"m_1956aa2a",stepLabel:"m_12051f6c",stepDescription:"m_164eea74"};const ah=(e,t)=>typeof e=="function"?s.jsx(e,{step:t||0}):e,$6={withIcon:!0,allowStepClick:!0,iconPosition:"left"},M0=ve((e,t)=>{const{classNames:n,className:r,style:a,styles:o,vars:c,step:u,state:f,color:p,icon:m,completedIcon:g,progressIcon:v,label:b,description:S,withIcon:j,iconSize:C,loading:R,allowStepClick:D,allowStepSelect:E,iconPosition:T,orientation:A,mod:k,...M}=se("StepperStep",$6,e),L=z6(),$=Sn(),V={classNames:n,styles:o},Y=f==="stepCompleted"?null:f==="stepProgress"?v:m,Q={"data-progress":f==="stepProgress"||void 0,"data-completed":f==="stepCompleted"||void 0};return s.jsxs(tr,{...L.getStyles("step",{className:r,style:a,variant:L.orientation,...V}),mod:[{"icon-position":T||L.iconPosition,"allow-click":D},k],ref:t,...Q,...M,__vars:{"--step-color":p?Ht(p,$):void 0},tabIndex:D?0:-1,children:[j&&s.jsxs("span",{...L.getStyles("stepWrapper",V),children:[s.jsxs("span",{...L.getStyles("stepIcon",V),...Q,children:[s.jsx(di,{mounted:f==="stepCompleted",transition:"pop",duration:200,children:J=>s.jsx("span",{...L.getStyles("stepCompletedIcon",{style:J,...V}),children:R?s.jsx(_r,{color:"var(--mantine-color-white)",size:"calc(var(--stepper-icon-size) / 2)",...L.getStyles("stepLoader",V)}):ah(g,u)||s.jsx(Sp,{size:"60%"})})}),f!=="stepCompleted"?R?s.jsx(_r,{...L.getStyles("stepLoader",V),size:"calc(var(--stepper-icon-size) / 2)",color:p}):ah(Y||m,u):null]}),A==="vertical"&&s.jsx("span",{...L.getStyles("verticalSeparator",V),"data-active":f==="stepCompleted"||void 0})]}),(b||S)&&s.jsxs("span",{...L.getStyles("stepBody",V),"data-orientation":L.orientation,"data-icon-position":T||L.iconPosition,children:[b&&s.jsx("span",{...L.getStyles("stepLabel",V),children:ah(b,u)}),S&&s.jsx("span",{...L.getStyles("stepDescription",V),children:ah(S,u)})]})]})});M0.classes=O0;M0.displayName="@mantine/core/StepperStep";const U6={orientation:"horizontal",iconPosition:"left",allowNextStepsSelect:!0,wrap:!0},B6=(e,{color:t,iconSize:n,size:r,contentPadding:a,radius:o,autoContrast:c})=>({root:{"--stepper-color":t?Ht(t,e):void 0,"--stepper-icon-color":Ws(c,e)?Gi({color:t,theme:e,autoContrast:c}):void 0,"--stepper-icon-size":n===void 0?rt(r,"stepper-icon-size"):le(n),"--stepper-content-padding":Nn(a),"--stepper-radius":o===void 0?void 0:Vt(o),"--stepper-fz":On(r),"--stepper-spacing":Nn(r)}}),mc=ve((e,t)=>{var z,H,O;const n=se("Stepper",U6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,children:p,onStepClick:m,active:g,icon:v,completedIcon:b,progressIcon:S,color:j,iconSize:C,contentPadding:R,orientation:D,iconPosition:E,size:T,radius:A,allowNextStepsSelect:k,wrap:M,autoContrast:L,...$}=n,V=Ie({name:"Stepper",classes:O0,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:B6}),Y=y.Children.toArray(p),Q=Y.filter(U=>U.type!==Nh),J=Y.find(U=>U.type===Nh),G=Q.reduce((U,K,ee)=>{const be=g===ee?"stepProgress":g>ee?"stepCompleted":"stepInactive",ye=typeof m!="function"?!1:typeof K.props.allowStepSelect=="boolean"?K.props.allowStepSelect:be==="stepCompleted"||k;return U.push(y.cloneElement(K,{icon:K.props.icon||v||ee+1,key:ee,step:ee,state:be,onClick:()=>ye&&(m==null?void 0:m(ee)),allowStepClick:ye,completedIcon:K.props.completedIcon||b,progressIcon:K.props.progressIcon||S,color:K.props.color||j,iconSize:C,iconPosition:K.props.iconPosition||E,orientation:D})),D==="horizontal"&&ee!==Q.length-1&&U.push(y.createElement("div",{...V("separator"),"data-active":ee<g||void 0,"data-orientation":D,key:`separator-${ee}`})),U},[]),Z=(H=(z=Q[g])==null?void 0:z.props)==null?void 0:H.children,P=(O=J==null?void 0:J.props)==null?void 0:O.children,I=g>Q.length-1?P:Z;return s.jsx(L6,{value:{getStyles:V,orientation:D,iconPosition:E},children:s.jsxs(ce,{...V("root"),ref:t,size:T,...$,children:[s.jsx(ce,{...V("steps"),mod:{orientation:D,"icon-position":E,wrap:M&&D!=="vertical"},children:G}),I&&s.jsx("div",{...V("content"),children:I})]})})});mc.classes=O0;mc.displayName="@mantine/core/Stepper";mc.Completed=Nh;mc.Step=M0;const LD=y.createContext(null),V6=LD.Provider,F6=()=>y.useContext(LD),H6={},I0=ve((e,t)=>{const{value:n,defaultValue:r,onChange:a,size:o,wrapperProps:c,children:u,readOnly:f,...p}=se("SwitchGroup",H6,e),[m,g]=Yn({value:n,defaultValue:r,finalValue:[],onChange:a}),v=b=>{const S=b.currentTarget.value;!f&&g(m.includes(S)?m.filter(j=>j!==S):[...m,S])};return s.jsx(V6,{value:{value:m,onChange:v,size:o},children:s.jsx(mn.Wrapper,{size:o,ref:t,...c,...p,labelElement:"div",__staticSelector:"SwitchGroup",children:s.jsx(t0,{role:"group",children:u})})})});I0.classes=mn.Wrapper.classes;I0.displayName="@mantine/core/SwitchGroup";var zD={root:"m_5f93f3bb",input:"m_926b4011",track:"m_9307d992",thumb:"m_93039a1d",trackLabel:"m_8277e082"};const q6={labelPosition:"right"},G6=(e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:Vt(t),"--switch-height":rt(r,"switch-height"),"--switch-width":rt(r,"switch-width"),"--switch-thumb-size":rt(r,"switch-thumb-size"),"--switch-label-font-size":rt(r,"switch-label-font-size"),"--switch-track-label-padding":rt(r,"switch-track-label-padding"),"--switch-color":n?Ht(n,e):void 0}}),Sd=ve((e,t)=>{const n=se("Switch",q6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,color:p,label:m,offLabel:g,onLabel:v,id:b,size:S,radius:j,wrapperProps:C,thumbIcon:R,checked:D,defaultChecked:E,onChange:T,labelPosition:A,description:k,error:M,disabled:L,variant:$,rootRef:V,mod:Y,...Q}=n,J=F6(),G=S||(J==null?void 0:J.size),Z=Ie({name:"Switch",props:n,classes:zD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:G6}),{styleProps:P,rest:I}=Qi(Q),z=yr(b),H=J?{checked:J.value.includes(I.value),onChange:J.onChange}:{},[O,U]=Yn({value:H.checked??D,defaultValue:E,finalValue:!1});return s.jsxs(bp,{...Z("root"),__staticSelector:"Switch",__stylesApiProps:n,id:z,size:G,labelPosition:A,label:m,description:k,error:M,disabled:L,bodyElement:"label",labelElement:"span",classNames:r,styles:c,unstyled:u,"data-checked":H.checked||D||void 0,variant:$,ref:V,mod:Y,...P,...C,children:[s.jsx("input",{...I,disabled:L,checked:O,"data-checked":H.checked||D||void 0,onChange:K=>{var ee;J?(ee=H.onChange)==null||ee.call(H,K):T==null||T(K),U(K.currentTarget.checked)},id:z,ref:t,type:"checkbox",role:"switch",...Z("input")}),s.jsxs(ce,{"aria-hidden":"true",component:"span",mod:{error:M,"label-position":A,"without-labels":!v&&!g},...Z("track"),children:[s.jsx(ce,{component:"span",mod:"reduce-motion",...Z("thumb"),children:R}),s.jsx("span",{...Z("trackLabel"),children:O?v:g})]})]})});Sd.classes={...zD,...F2};Sd.displayName="@mantine/core/Switch";Sd.Group=I0;const[Q6,W6]=vr("Table component was not found in the tree");var wd={table:"m_b23fa0ef",th:"m_4e7aa4f3",tr:"m_4e7aa4fd",td:"m_4e7aa4ef",tbody:"m_b2404537",thead:"m_b242d975",caption:"m_9e5a3ac7",scrollContainer:"m_a100c15",scrollContainerInner:"m_62259741"};function Y6(e,t){if(!t)return;const n={};return t.columnBorder&&e.withColumnBorders&&(n["data-with-column-border"]=!0),t.rowBorder&&e.withRowBorders&&(n["data-with-row-border"]=!0),t.striped&&e.striped&&(n["data-striped"]=e.striped),t.highlightOnHover&&e.highlightOnHover&&(n["data-hover"]=!0),t.captionSide&&e.captionSide&&(n["data-side"]=e.captionSide),t.stickyHeader&&e.stickyHeader&&(n["data-sticky"]=!0),n}function Js(e,t){const n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=ve((a,o)=>{const c=se(n,{},a),{classNames:u,className:f,style:p,styles:m,...g}=c,v=W6();return s.jsx(ce,{component:e,ref:o,...Y6(v,t),...v.getStyles(e,{className:f,classNames:u,style:p,styles:m,props:c}),...g})});return r.displayName=`@mantine/core/${n}`,r.classes=wd,r}const Ay=Js("th",{columnBorder:!0}),$D=Js("td",{columnBorder:!0}),vh=Js("tr",{rowBorder:!0,striped:!0,highlightOnHover:!0}),UD=Js("thead",{stickyHeader:!0}),BD=Js("tbody"),VD=Js("tfoot"),FD=Js("caption",{captionSide:!0});function L0({data:e}){return s.jsxs(s.Fragment,{children:[e.caption&&s.jsx(FD,{children:e.caption}),e.head&&s.jsx(UD,{children:s.jsx(vh,{children:e.head.map((t,n)=>s.jsx(Ay,{children:t},n))})}),e.body&&s.jsx(BD,{children:e.body.map((t,n)=>s.jsx(vh,{children:t.map((r,a)=>s.jsx($D,{children:r},a))},n))}),e.foot&&s.jsx(VD,{children:s.jsx(vh,{children:e.foot.map((t,n)=>s.jsx(Ay,{children:t},n))})})]})}L0.displayName="@mantine/core/TableDataRenderer";const K6={type:"scrollarea"},X6=(e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":le(t),"--table-max-height":le(n),"--table-overflow":r==="native"?"auto":void 0}}),z0=ve((e,t)=>{const n=se("TableScrollContainer",K6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,children:p,minWidth:m,maxHeight:g,type:v,scrollAreaProps:b,...S}=n,j=Ie({name:"TableScrollContainer",classes:wd,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:X6,rootSelector:"scrollContainer"});return s.jsx(ce,{component:v==="scrollarea"?Yr:"div",...v==="scrollarea"?g?{offsetScrollbars:"xy",...b}:{offsetScrollbars:"x",...b}:{},ref:t,...j("scrollContainer"),...S,children:s.jsx("div",{...j("scrollContainerInner"),children:p})})});z0.classes=wd;z0.displayName="@mantine/core/TableScrollContainer";const Z6={withRowBorders:!0,verticalSpacing:7},J6=(e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:a,borderColor:o,stripedColor:c,highlightOnHoverColor:u,striped:f,highlightOnHover:p,stickyHeaderOffset:m,stickyHeader:g})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":Nn(r),"--table-vertical-spacing":Nn(a),"--table-border-color":o?Ht(o,e):void 0,"--table-striped-color":f&&c?Ht(c,e):void 0,"--table-highlight-on-hover-color":p&&u?Ht(u,e):void 0,"--table-sticky-header-offset":g?le(m):void 0}}),Me=ve((e,t)=>{const n=se("Table",Z6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,horizontalSpacing:p,verticalSpacing:m,captionSide:g,stripedColor:v,highlightOnHoverColor:b,striped:S,highlightOnHover:j,withColumnBorders:C,withRowBorders:R,withTableBorder:D,borderColor:E,layout:T,variant:A,data:k,children:M,stickyHeader:L,stickyHeaderOffset:$,mod:V,tabularNums:Y,...Q}=n,J=Ie({name:"Table",props:n,className:a,style:o,classes:wd,classNames:r,styles:c,unstyled:u,rootSelector:"table",vars:f,varsResolver:J6});return s.jsx(Q6,{value:{getStyles:J,stickyHeader:L,striped:S===!0?"odd":S||void 0,highlightOnHover:j,withColumnBorders:C,withRowBorders:R,captionSide:g||"bottom"},children:s.jsx(ce,{component:"table",variant:A,ref:t,mod:[{"data-with-table-border":D,"data-tabular-nums":Y},V],...J("table"),...Q,children:M||!!k&&s.jsx(L0,{data:k})})})});Me.classes=wd;Me.displayName="@mantine/core/Table";Me.Td=$D;Me.Th=Ay;Me.Tr=vh;Me.Thead=UD;Me.Tbody=BD;Me.Tfoot=VD;Me.Caption=FD;Me.ScrollContainer=z0;Me.DataRenderer=L0;const[ez,$0]=vr("Tabs component was not found in the tree");var jd={root:"m_89d60db1","list--default":"m_576c9d4",list:"m_89d33d6d",panel:"m_b0c91715",tab:"m_4ec4dce6",tabSection:"m_fc420b1f","tab--default":"m_539e827b","list--outline":"m_6772fbd5","tab--outline":"m_b59ab47c","tab--pills":"m_c3381914"};const tz={},U0=ve((e,t)=>{const n=se("TabsList",tz,e),{children:r,className:a,grow:o,justify:c,classNames:u,styles:f,style:p,mod:m,...g}=n,v=$0();return s.jsx(ce,{...g,...v.getStyles("list",{className:a,style:p,classNames:u,styles:f,props:n,variant:v.variant}),ref:t,role:"tablist",variant:v.variant,mod:[{grow:o,orientation:v.orientation,placement:v.orientation==="vertical"&&v.placement,inverted:v.inverted},m],"aria-orientation":v.orientation,__vars:{"--tabs-justify":c},children:r})});U0.classes=jd;U0.displayName="@mantine/core/TabsList";const nz={},B0=ve((e,t)=>{const n=se("TabsPanel",nz,e),{children:r,className:a,value:o,classNames:c,styles:u,style:f,mod:p,keepMounted:m,...g}=n,v=$0(),b=v.value===o,S=v.keepMounted||m||b?r:null;return s.jsx(ce,{...g,...v.getStyles("panel",{className:a,classNames:c,styles:u,style:[f,b?void 0:{display:"none"}],props:n}),ref:t,mod:[{orientation:v.orientation},p],role:"tabpanel",id:v.getPanelId(o),"aria-labelledby":v.getTabId(o),children:S})});B0.classes=jd;B0.displayName="@mantine/core/TabsPanel";const rz={},V0=ve((e,t)=>{const n=se("TabsTab",rz,e),{className:r,children:a,rightSection:o,leftSection:c,value:u,onClick:f,onKeyDown:p,disabled:m,color:g,style:v,classNames:b,styles:S,vars:j,mod:C,tabIndex:R,...D}=n,E=Sn(),{dir:T}=Ks(),A=$0(),k=u===A.value,M=$=>{A.onChange(A.allowTabDeactivation&&u===A.value?null:u),f==null||f($)},L={classNames:b,styles:S,props:n};return s.jsxs(tr,{...D,...A.getStyles("tab",{className:r,style:v,variant:A.variant,...L}),disabled:m,unstyled:A.unstyled,variant:A.variant,mod:[{active:k,disabled:m,orientation:A.orientation,inverted:A.inverted,placement:A.orientation==="vertical"&&A.placement},C],ref:t,role:"tab",id:A.getTabId(u),"aria-selected":k,tabIndex:R!==void 0?R:k||A.value===null?0:-1,"aria-controls":A.getPanelId(u),onClick:M,__vars:{"--tabs-color":g?Ht(g,E):void 0},onKeyDown:iR({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:A.activateTabWithKeyboard,loop:A.loop,orientation:A.orientation||"horizontal",dir:T,onKeyDown:p}),children:[c&&s.jsx("span",{...A.getStyles("tabSection",L),"data-position":"left",children:c}),a&&s.jsx("span",{...A.getStyles("tabLabel",L),children:a}),o&&s.jsx("span",{...A.getStyles("tabSection",L),"data-position":"right",children:o})]})});V0.classes=jd;V0.displayName="@mantine/core/TabsTab";const GC="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",az={keepMounted:!0,orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,allowTabDeactivation:!1,unstyled:!1,inverted:!1,variant:"default",placement:"left"},iz=(e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":Vt(t),"--tabs-color":Ht(n,e),"--tabs-text-color":Ws(r,e)?Gi({color:n,theme:e,autoContrast:r}):void 0}}),Lt=ve((e,t)=>{const n=se("Tabs",az,e),{defaultValue:r,value:a,onChange:o,orientation:c,children:u,loop:f,id:p,activateTabWithKeyboard:m,allowTabDeactivation:g,variant:v,color:b,radius:S,inverted:j,placement:C,keepMounted:R,classNames:D,styles:E,unstyled:T,className:A,style:k,vars:M,autoContrast:L,mod:$,...V}=n,Y=yr(p),[Q,J]=Yn({value:a,defaultValue:r,finalValue:null,onChange:o}),G=Ie({name:"Tabs",props:n,classes:jd,className:A,style:k,classNames:D,styles:E,unstyled:T,vars:M,varsResolver:iz});return s.jsx(ez,{value:{placement:C,value:Q,orientation:c,id:Y,loop:f,activateTabWithKeyboard:m,getTabId:Vj(`${Y}-tab`,GC),getPanelId:Vj(`${Y}-panel`,GC),onChange:J,allowTabDeactivation:g,variant:v,color:b,radius:S,inverted:j,keepMounted:R,unstyled:T,getStyles:G},children:s.jsx(ce,{ref:t,id:Y,variant:v,mod:[{orientation:c,inverted:c==="horizontal"&&j,placement:c==="vertical"&&C},$],...G("root"),...V,children:u})})});Lt.classes=jd;Lt.displayName="@mantine/core/Tabs";Lt.Tab=V0;Lt.Panel=B0;Lt.List=U0;const oz={},ze=ve((e,t)=>{const n=se("TextInput",oz,e);return s.jsx(Pr,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});ze.classes=Pr.classes;ze.displayName="@mantine/core/TextInput";var HD={root:"m_7341320d"};const sz={},lz=(e,{size:t,radius:n,variant:r,gradient:a,color:o,autoContrast:c})=>{const u=e.variantColorResolver({color:o||e.primaryColor,theme:e,gradient:a,variant:r||"filled",autoContrast:c});return{root:{"--ti-size":rt(t,"ti-size"),"--ti-radius":n===void 0?void 0:Vt(n),"--ti-bg":o||r?u.background:void 0,"--ti-color":o||r?u.color:void 0,"--ti-bd":o||r?u.border:void 0}}},F0=ve((e,t)=>{const n=se("ThemeIcon",sz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,autoContrast:p,...m}=n,g=Ie({name:"ThemeIcon",classes:HD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:lz});return s.jsx(ce,{ref:t,...g("root"),...m})});F0.classes=HD;F0.displayName="@mantine/core/ThemeIcon";const cz=["h1","h2","h3","h4","h5","h6"],uz=["xs","sm","md","lg","xl"];function dz(e,t){const n=t!==void 0?t:`h${e}`;return cz.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:uz.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:le(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var qD={root:"m_8a5d1357"};const fz={order:1},hz=(e,{order:t,size:n,lineClamp:r,textWrap:a})=>{const o=dz(t,n);return{root:{"--title-fw":o.fontWeight,"--title-lh":o.lineHeight,"--title-fz":o.fontSize,"--title-line-clamp":typeof r=="number"?r.toString():void 0,"--title-text-wrap":a}}},Le=ve((e,t)=>{const n=se("Title",fz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,order:f,vars:p,size:m,variant:g,lineClamp:v,textWrap:b,mod:S,...j}=n,C=Ie({name:"Title",props:n,classes:qD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:p,varsResolver:hz});return[1,2,3,4,5,6].includes(f)?s.jsx(ce,{...C("root"),component:`h${f}`,variant:g,ref:t,mod:[{order:f,"data-line-clamp":typeof v=="number"},S],size:m,...j}):null});Le.classes=qD;Le.displayName="@mantine/core/Title";function pz(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(a){t=typeof a=="function"?a(t):a},setState(a){this.updateState(a),r.forEach(o=>o(t))},initialize(a){n||(t=a,n=!0)},subscribe(a){return r.add(a),()=>r.delete(a)}}}function mz(e){return y.useSyncExternalStore(e.subscribe,()=>e.getState(),()=>e.getState())}function gz(e,t,n){const r=[],a=[],o={};for(const c of e){const u=c.position||t;o[u]=o[u]||0,o[u]+=1,o[u]<=n?a.push(c):r.push(c)}return{notifications:a,queue:r}}const vz=()=>pz({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),el=vz(),yz=(e=el)=>mz(e);function kc(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),a=gz(r,n.defaultPosition,n.limit);e.setState({notifications:a.notifications,queue:a.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Pe(e,t=el){const n=e.id||Th();return kc(t,r=>e.id&&r.some(a=>a.id===e.id)?r:[...r,{...e,id:n}]),n}function GD(e,t=el){return kc(t,n=>n.filter(r=>{var a;return r.id===e?((a=r.onClose)==null||a.call(r,r),!1):!0})),e}function Ds(e,t=el){return kc(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function xz(e=el){kc(e,()=>[])}function bz(e=el){kc(e,t=>t.slice(0,e.getState().limit))}const ua={show:Pe,hide:GD,update:Ds,clean:xz,cleanQueue:bz,updateState:kc};function _y(e,t){return _y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},_y(e,t)}function QD(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,_y(e,t)}var $v={exports:{}},Uv,QC;function Sz(){if(QC)return Uv;QC=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Uv=e,Uv}var Bv,WC;function wz(){if(WC)return Bv;WC=1;var e=Sz();function t(){}function n(){}return n.resetWarningCache=t,Bv=function(){function r(c,u,f,p,m,g){if(g!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}r.isRequired=r;function a(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:a,element:r,elementType:r,instanceOf:a,node:r,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:t};return o.PropTypes=o,o},Bv}var YC;function jz(){return YC||(YC=1,$v.exports=wz()()),$v.exports}var Cz=jz();const an=ax(Cz),KC={disabled:!1},Oh=Cn.createContext(null);var Ez=function(t){return t.scrollTop},Fu="unmounted",Ss="exited",ws="entering",Zl="entered",ky="exiting",Xi=function(e){QD(t,e);function t(r,a){var o;o=e.call(this,r,a)||this;var c=a,u=c&&!c.isMounting?r.enter:r.appear,f;return o.appearStatus=null,r.in?u?(f=Ss,o.appearStatus=ws):f=Zl:r.unmountOnExit||r.mountOnEnter?f=Fu:f=Ss,o.state={status:f},o.nextCallback=null,o}t.getDerivedStateFromProps=function(a,o){var c=a.in;return c&&o.status===Fu?{status:Ss}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(a){var o=null;if(a!==this.props){var c=this.state.status;this.props.in?c!==ws&&c!==Zl&&(o=ws):(c===ws||c===Zl)&&(o=ky)}this.updateStatus(!1,o)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var a=this.props.timeout,o,c,u;return o=c=u=a,a!=null&&typeof a!="number"&&(o=a.exit,c=a.enter,u=a.appear!==void 0?a.appear:c),{exit:o,enter:c,appear:u}},n.updateStatus=function(a,o){if(a===void 0&&(a=!1),o!==null)if(this.cancelNextCallback(),o===ws){if(this.props.unmountOnExit||this.props.mountOnEnter){var c=this.props.nodeRef?this.props.nodeRef.current:Vu.findDOMNode(this);c&&Ez(c)}this.performEnter(a)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Ss&&this.setState({status:Fu})},n.performEnter=function(a){var o=this,c=this.props.enter,u=this.context?this.context.isMounting:a,f=this.props.nodeRef?[u]:[Vu.findDOMNode(this),u],p=f[0],m=f[1],g=this.getTimeouts(),v=u?g.appear:g.enter;if(!a&&!c||KC.disabled){this.safeSetState({status:Zl},function(){o.props.onEntered(p)});return}this.props.onEnter(p,m),this.safeSetState({status:ws},function(){o.props.onEntering(p,m),o.onTransitionEnd(v,function(){o.safeSetState({status:Zl},function(){o.props.onEntered(p,m)})})})},n.performExit=function(){var a=this,o=this.props.exit,c=this.getTimeouts(),u=this.props.nodeRef?void 0:Vu.findDOMNode(this);if(!o||KC.disabled){this.safeSetState({status:Ss},function(){a.props.onExited(u)});return}this.props.onExit(u),this.safeSetState({status:ky},function(){a.props.onExiting(u),a.onTransitionEnd(c.exit,function(){a.safeSetState({status:Ss},function(){a.props.onExited(u)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(a,o){o=this.setNextCallback(o),this.setState(a,o)},n.setNextCallback=function(a){var o=this,c=!0;return this.nextCallback=function(u){c&&(c=!1,o.nextCallback=null,a(u))},this.nextCallback.cancel=function(){c=!1},this.nextCallback},n.onTransitionEnd=function(a,o){this.setNextCallback(o);var c=this.props.nodeRef?this.props.nodeRef.current:Vu.findDOMNode(this),u=a==null&&!this.props.addEndListener;if(!c||u){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var f=this.props.nodeRef?[this.nextCallback]:[c,this.nextCallback],p=f[0],m=f[1];this.props.addEndListener(p,m)}a!=null&&setTimeout(this.nextCallback,a)},n.render=function(){var a=this.state.status;if(a===Fu)return null;var o=this.props,c=o.children;o.in,o.mountOnEnter,o.unmountOnExit,o.appear,o.enter,o.exit,o.timeout,o.addEndListener,o.onEnter,o.onEntering,o.onEntered,o.onExit,o.onExiting,o.onExited,o.nodeRef;var u=f0(o,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return Cn.createElement(Oh.Provider,{value:null},typeof c=="function"?c(a,u):Cn.cloneElement(Cn.Children.only(c),u))},t}(Cn.Component);Xi.contextType=Oh;Xi.propTypes={};function ql(){}Xi.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:ql,onEntering:ql,onEntered:ql,onExit:ql,onExiting:ql,onExited:ql};Xi.UNMOUNTED=Fu;Xi.EXITED=Ss;Xi.ENTERING=ws;Xi.ENTERED=Zl;Xi.EXITING=ky;function Tz(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function H0(e,t){var n=function(o){return t&&y.isValidElement(o)?t(o):o},r=Object.create(null);return e&&y.Children.map(e,function(a){return a}).forEach(function(a){r[a.key]=n(a)}),r}function Rz(e,t){e=e||{},t=t||{};function n(m){return m in t?t[m]:e[m]}var r=Object.create(null),a=[];for(var o in e)o in t?a.length&&(r[o]=a,a=[]):a.push(o);var c,u={};for(var f in t){if(r[f])for(c=0;c<r[f].length;c++){var p=r[f][c];u[r[f][c]]=n(p)}u[f]=n(f)}for(c=0;c<a.length;c++)u[a[c]]=n(a[c]);return u}function As(e,t,n){return n[t]!=null?n[t]:e.props[t]}function Dz(e,t){return H0(e.children,function(n){return y.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:As(n,"appear",e),enter:As(n,"enter",e),exit:As(n,"exit",e)})})}function Az(e,t,n){var r=H0(e.children),a=Rz(t,r);return Object.keys(a).forEach(function(o){var c=a[o];if(y.isValidElement(c)){var u=o in t,f=o in r,p=t[o],m=y.isValidElement(p)&&!p.props.in;f&&(!u||m)?a[o]=y.cloneElement(c,{onExited:n.bind(null,c),in:!0,exit:As(c,"exit",e),enter:As(c,"enter",e)}):!f&&u&&!m?a[o]=y.cloneElement(c,{in:!1}):f&&u&&y.isValidElement(p)&&(a[o]=y.cloneElement(c,{onExited:n.bind(null,c),in:p.props.in,exit:As(c,"exit",e),enter:As(c,"enter",e)}))}}),a}var _z=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},kz={component:"div",childFactory:function(t){return t}},Oo=function(e){QD(t,e);function t(r,a){var o;o=e.call(this,r,a)||this;var c=o.handleExited.bind(Tz(o));return o.state={contextValue:{isMounting:!0},handleExited:c,firstRender:!0},o}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(a,o){var c=o.children,u=o.handleExited,f=o.firstRender;return{children:f?Dz(a,u):Az(a,c,u),firstRender:!1}},n.handleExited=function(a,o){var c=H0(this.props.children);a.key in c||(a.props.onExited&&a.props.onExited(o),this.mounted&&this.setState(function(u){var f=Ph({},u.children);return delete f[a.key],{children:f}}))},n.render=function(){var a=this.props,o=a.component,c=a.childFactory,u=f0(a,["component","childFactory"]),f=this.state.contextValue,p=_z(this.state.children).map(c);return delete u.appear,delete u.enter,delete u.exit,o===null?Cn.createElement(Oh.Provider,{value:f},p):Cn.createElement(Oh.Provider,{value:f},Cn.createElement(o,u,p))},t}(Cn.Component);Oo.propTypes={};Oo.defaultProps=kz;const WD=["bottom-center","bottom-left","bottom-right","top-center","top-left","top-right"];function Pz(e,t){return e.reduce((n,r)=>(n[r.position||t].push(r),n),WD.reduce((n,r)=>(n[r]=[],n),{}))}const XC={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},Nz={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function Oz({state:e,maxHeight:t,position:n,transitionDuration:r}){const[a,o]=n.split("-"),c=o==="center"?`${a}-center`:o,u={opacity:0,maxHeight:t,transform:XC[c],transitionDuration:`${r}ms, ${r}ms, ${r}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},f={opacity:1,transform:Nz[c]},p={opacity:0,maxHeight:0,transform:XC[c]};return{...u,...{entering:f,entered:f,exiting:p,exited:p}[e]}}function Mz(e,t){return typeof t=="number"?t:t===!1||e===!1?!1:e}const YD=y.forwardRef(({data:e,onHide:t,autoClose:n,...r},a)=>{const{autoClose:o,message:c,...u}=e,f=Mz(n,e.autoClose),p=y.useRef(-1),m=()=>window.clearTimeout(p.current),g=()=>{t(e.id),m()},v=()=>{typeof f=="number"&&(p.current=window.setTimeout(g,f))};return y.useEffect(()=>{var b;(b=e.onOpen)==null||b.call(e,e)},[]),y.useEffect(()=>(v(),m),[f]),s.jsx(E0,{...r,...u,onClose:g,ref:a,onMouseEnter:m,onMouseLeave:v,children:c})});YD.displayName="@mantine/notifications/NotificationContainer";var KD={root:"m_b37d9ac7",notification:"m_5ed0edd0"};const Iz=Xi,Lz={position:"bottom-right",autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:Wr("overlay"),store:el,withinPortal:!0},zz=(e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t==null?void 0:t.toString(),"--notifications-container-width":le(n)}}),Zi=ve((e,t)=>{const n=se("Notifications",Lz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,position:p,autoClose:m,transitionDuration:g,containerWidth:v,notificationMaxHeight:b,limit:S,zIndex:j,store:C,portalProps:R,withinPortal:D,...E}=n,T=Sn(),A=yz(C),k=uN(),M=cx(),L=y.useRef({}),$=y.useRef(0),Y=(T.respectReducedMotion?M:!1)?1:g,Q=Ie({name:"Notifications",classes:KD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:zz});y.useEffect(()=>{C==null||C.updateState(Z=>({...Z,limit:S||5,defaultPosition:p}))},[S,p]),zi(()=>{A.notifications.length>$.current&&setTimeout(()=>k(),0),$.current=A.notifications.length},[A.notifications]);const J=Pz(A.notifications,p),G=WD.reduce((Z,P)=>(Z[P]=J[P].map(({style:I,...z})=>s.jsx(Iz,{timeout:Y,onEnter:()=>L.current[z.id].offsetHeight,nodeRef:{current:L.current[z.id]},children:H=>s.jsx(YD,{ref:O=>{L.current[z.id]=O},data:z,onHide:O=>GD(O,C),autoClose:m,...Q("notification",{style:{...Oz({state:H,position:P,transitionDuration:Y,maxHeight:b}),...I}})})},z.id)),Z),{});return s.jsxs(qo,{withinPortal:D,...R,children:[s.jsx(ce,{...Q("root"),"data-position":"top-center",ref:t,...E,children:s.jsx(Oo,{children:G["top-center"]})}),s.jsx(ce,{...Q("root"),"data-position":"top-left",...E,children:s.jsx(Oo,{children:G["top-left"]})}),s.jsx(ce,{...Q("root",{className:lc.classNames.fullWidth}),"data-position":"top-right",...E,children:s.jsx(Oo,{children:G["top-right"]})}),s.jsx(ce,{...Q("root",{className:lc.classNames.fullWidth}),"data-position":"bottom-right",...E,children:s.jsx(Oo,{children:G["bottom-right"]})}),s.jsx(ce,{...Q("root"),"data-position":"bottom-left",...E,children:s.jsx(Oo,{children:G["bottom-left"]})}),s.jsx(ce,{...Q("root"),"data-position":"bottom-center",...E,children:s.jsx(Oo,{children:G["bottom-center"]})})]})});Zi.classes=KD;Zi.displayName="@mantine/notifications/Notifications";Zi.show=ua.show;Zi.hide=ua.hide;Zi.update=ua.update;Zi.clean=ua.clean;Zi.cleanQueue=ua.cleanQueue;Zi.updateState=ua.updateState;class $z{constructor(t,n){this.operator=t,this.child=n}toString(){return`${this.operator}(${this.child.toString()})`}}class Cd{constructor(t,n,r){this.operator=t,this.left=n,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}}class Uz{constructor(){this.prefixParselets={},this.infixParselets={}}registerInfix(t,n){return this.infixParselets[t]=n,this}registerPrefix(t,n){return this.prefixParselets[t]=n,this}prefix(t,n,r){return this.registerPrefix(t,{parse(a,o){const c=a.consumeAndParse(n);return r(o,c)}})}infixLeft(t,n,r){return this.registerInfix(t,{parse(a,o,c){const u=a.consumeAndParse(n);return r(o,c,u)},precedence:n})}construct(t){return new Bz(t,this.prefixParselets,this.infixParselets)}}class Bz{constructor(t,n,r){this.tokens=t,this.prefixParselets=n,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){const n=this.peek();return(n==null?void 0:n.id)!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){const n=this.consume(),r=this.prefixParselets[n.id];if(!r)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let a=r.parse(this,n);for(;t>this.getPrecedence();){const o=this.consume();a=this.getInfixParselet(o).parse(this,a,o)}return a}getPrecedence(){const t=this.peek();if(!t)return 1/0;const n=this.getInfixParselet(t);return n?n.precedence:1/0}consume(t,n){var r,a;if(!this.tokens.length)throw Error("Cant consume unknown more tokens.");if(t&&((r=this.peek())==null?void 0:r.id)!==t){const o=this.peek();throw Error(`Expected ${t} but got "${o.id}" (${o.value}) at line ${o.line} column ${o.column}.`)}if(n&&((a=this.peek())==null?void 0:a.value)!==n){const o=this.peek();throw Error(`Expected "${n}" but got "${o.value}" at line ${o.line} column ${o.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}}class XD{constructor(t=10){this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){const n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,n)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}}const Ed="http://hl7.org",ZD="ok",Vz="created",Fz="gone",Hz="not-modified",qz="not-found",Gz="unauthorized",Qz="forbidden",Wz="accepted",Yz={resourceType:"OperationOutcome",id:ZD,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},Kz={resourceType:"OperationOutcome",id:qz,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},nd={resourceType:"OperationOutcome",id:Gz,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Xz={...nd,issue:[...nd.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},ZC={...nd,issue:[...nd.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]},JD={resourceType:"OperationOutcome",id:Qz,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]};function ri(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},...t?{expression:[t]}:void 0}]}}function yn(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"structure",details:{text:e}}]}}function Zz(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"exception",details:{text:"Internal server error"},diagnostics:e.toString()}]}}function Fp(e){return typeof e=="object"&&e!==null&&e.resourceType==="OperationOutcome"}function eA(e){return e.id===ZD||e.id===Vz||e.id===Hz||e.id===Wz}function Jz(e){return e.id===Fz}class dt extends Error{constructor(t,n){super(tA(t)),this.outcome=t,this.cause=n}}function Zt(e){return e instanceof dt?e.outcome:Fp(e)?e:ri(Xe(e))}function Xe(e){return e?typeof e=="string"?e:e instanceof Error?e.message:Fp(e)?tA(e):typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:JSON.stringify(e):"Unknown error"}function tA(e){var n;const t=((n=e.issue)==null?void 0:n.map(nA))??[];return t.length>0?t.join("; "):"Unknown error"}function nA(e){var n,r;let t;return(n=e.details)!=null&&n.text?e.diagnostics?t=`${e.details.text} (${e.diagnostics})`:t=e.details.text:e.diagnostics?t=e.diagnostics:t="Unknown error",(r=e.expression)!=null&&r.length&&(t+=` (${e.expression.join(", ")})`),t}function e8(e,t){const n=t.max&&t.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:t.max;return{path:e,description:"",type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function t8(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([a,o])=>[a,e8(a,o)])),constraints:[],innerTypes:[]};return t}const n8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},r8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},a8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},i8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},o8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},s8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},l8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},c8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},u8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},d8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},f8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},h8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},p8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},m8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},g8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},v8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},x8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},b8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},S8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},w8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},j8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},C8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},E8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},T8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},R8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min:1,type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},D8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},A8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},_8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},k8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},P8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},N8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},O8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},M8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},I8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]}}},L8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},$8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},U8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},B8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},V8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},F8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},H8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},G8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},Q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},W8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},Y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},K8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min:1,type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},X8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},Z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},J8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},e$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},t$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},n$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min:1,type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},r$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},a$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},i$={elements:{authorizeUrl:{min:1,type:[{code:"string"}]},tokenUrl:{min:1,type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{min:1,type:[{code:"string"}]},clientId:{min:1,type:[{code:"string"}]},clientSecret:{min:1,type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]}}},o$={Element:n8,BackboneElement:r8,Address:a8,Age:i8,Annotation:o8,Attachment:s8,CodeableConcept:l8,Coding:c8,ContactDetail:u8,ContactPoint:d8,Contributor:f8,Count:h8,DataRequirement:p8,DataRequirementCodeFilter:m8,DataRequirementDateFilter:g8,DataRequirementSort:v8,Distance:y8,Dosage:x8,DosageDoseAndRate:b8,Duration:S8,ElementDefinition:w8,ElementDefinitionSlicingDiscriminator:j8,ElementDefinitionSlicing:C8,ElementDefinitionBase:E8,ElementDefinitionType:T8,ElementDefinitionExample:R8,ElementDefinitionConstraint:D8,ElementDefinitionBinding:A8,ElementDefinitionMapping:_8,Expression:k8,Extension:P8,HumanName:N8,Identifier:O8,MarketingStatus:M8,Meta:I8,Money:L8,Narrative:z8,ParameterDefinition:$8,Period:U8,Population:B8,ProdCharacteristic:V8,ProductShelfLife:F8,Quantity:H8,Range:q8,Ratio:G8,Reference:Q8,RelatedArtifact:W8,SampledData:Y8,Signature:K8,SubstanceAmount:X8,SubstanceAmountReferenceRange:Z8,Timing:J8,TimingRepeat:e$,TriggerDefinition:t$,UsageContext:n$,MoneyQuantity:r$,SimpleQuantity:a$,IdentityProvider:i$};function s$(e){return new c$(e).parse()}const Mh=t8(o$),q0=Object.create(null),JC=Object.create(null),l$={"http://hl7.org/fhir/StructureDefinition/MoneyQuantity":"MoneyQuantity","http://hl7.org/fhir/StructureDefinition/SimpleQuantity":"SimpleQuantity","http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition":"ViewDefinition"};function rA(e){let t;return t=JC[e],t||(t=JC[e]=Object.create(null)),t}function eE(e){var r;const n=(Array.isArray(e)?e:((r=e.entry)==null?void 0:r.map(a=>a.resource))??[]).filter(a=>(a==null?void 0:a.resourceType)==="StructureDefinition");eU(n);for(const a of n)aA(a)}function aA(e){var o,c;if(!(e!=null&&e.name))throw new Error("Failed loading StructureDefinition from bundle");if(e.resourceType!=="StructureDefinition")return;const t=s$(e),n=l$[e.url];let r,a;n?(r=Mh,a=n):e.url===`http://hl7.org/fhir/StructureDefinition/${e.type}`||e.url===`https://medplum.com/fhir/StructureDefinition/${e.type}`||(o=e.type)!=null&&o.startsWith("http://")||(c=e.type)!=null&&c.startsWith("https://")?(r=Mh,a=e.type):(r=rA(e.url),a=e.type),r[a]=t;for(const u of t.innerTypes)u.parentType=t,r[u.name]=u;q0[e.url]=t}function iA(e){return!!Mh[e]}function Hp(e,t){if(t){const n=rA(t)[e];if(n)return n}return Mh[e]}function oA(e,t){const n=Hp(e,t);if(!n)throw new dt(ri("Unknown data type: "+e));return n}function G0(e){return!!q0[e]}function Pc(e){return q0[e]}class c${constructor(t){var n;if(!((n=t.snapshot)!=null&&n.element)||t.snapshot.element.length===0)throw new Error(`No snapshot defined for StructureDefinition '${t.name}'`);this.root=t.snapshot.element[0],this.elements=t.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:t.name,path:this.root.path,title:t.title,type:t.type,url:t.url,version:t.version,kind:t.kind,description:f$(t),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){var n,r,a,o,c;let t=this.next();for(;t;){if(t.sliceName)this.parseSliceStart(t);else if((n=t.id)!=null&&n.includes(":")){if((r=this.slicingContext)!=null&&r.current){const u=Vv(t,this.slicingContext.path);this.slicingContext.current.elements[u]=this.parseElementDefinition(t)}}else{const u=this.parseElementDefinition(t);this.checkFieldEnter(t,u);let f=this.backboneContext;for(;f;){if((a=t.path)!=null&&a.startsWith(f.path+".")){f.type.elements[Vv(t,f.path)]=u;break}f=f.parent}if(!f){const p=Vv(t,this.root.path);t.isSummary&&((o=this.resourceSchema.summaryProperties)==null||o.add(p.replace("[x]",""))),u.min>0&&((c=this.resourceSchema.mandatoryProperties)==null||c.add(p.replace("[x]",""))),this.resourceSchema.elements[p]=u}this.checkFieldExit(t)}t=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(t,n){this.isInnerType(t)&&this.enterInnerType(t),this.slicingContext&&!Gl(this.slicingContext.path,t==null?void 0:t.path)&&(this.slicingContext=void 0),t.slicing&&!this.slicingContext&&this.enterSlice(t,n)}enterInnerType(t){var r,a,o;for(;this.backboneContext&&!Gl((r=this.backboneContext)==null?void 0:r.path,t.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;const n=cE(t);this.backboneContext={type:{name:n,type:n,path:t.path,title:t.label,description:t.definition,elements:{},constraints:this.parseElementDefinition(t).constraints,innerTypes:[]},path:t.path,parent:Gl((a=this.backboneContext)==null?void 0:a.path,t.path)?this.backboneContext:(o=this.backboneContext)==null?void 0:o.parent}}enterSlice(t,n){var r,a,o,c;d$(t)&&!((r=this.peek())!=null&&r.sliceName)||(n.slicing={discriminator:(((a=t.slicing)==null?void 0:a.discriminator)??[]).map(u=>{if(u.type!=="value"&&u.type!=="pattern"&&u.type!=="type")throw new Error(`Unsupported slicing discriminator type: ${u.type}`);return{path:u.path,type:u.type}}),slices:[],ordered:((o=t.slicing)==null?void 0:o.ordered)??!1,rule:(c=t.slicing)==null?void 0:c.rules},this.slicingContext={field:n.slicing,path:t.path??""})}checkFieldExit(t=void 0){if(this.backboneContext&&!Gl(this.backboneContext.path,t==null?void 0:t.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!Gl(this.backboneContext.path,t==null?void 0:t.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){const t=this.peek();if(t)return this.index++,t}peek(){var n,r,a,o,c;const t=this.elements[this.index];if(t){if(this.elementIndex[t.path??""]=t,t.contentReference){const u=t.contentReference.slice(t.contentReference.indexOf("#")+1),f=this.elementIndex[u];return f?{...f,id:t.id,path:t.path,min:t.min??f.min,max:t.max??f.max,base:{path:((n=f.base)==null?void 0:n.path)??u,min:((r=t.base)==null?void 0:r.min)??((a=f.base)==null?void 0:a.min)??f.min,max:((o=t.base)==null?void 0:o.max)??((c=f.base)==null?void 0:c.max)??f.max},contentReference:t.contentReference,definition:t.definition}:void 0}return t}}isInnerType(t){var r;const n=this.peek();return!!(Gl(t==null?void 0:t.path,n==null?void 0:n.path)&&((r=t.type)!=null&&r.some(a=>["BackboneElement","Element"].includes(a.code))))}parseSliceStart(t){if(!this.slicingContext)throw new Error(`Invalid slice start before discriminator: ${t.sliceName} (${t.id})`);this.slicingContext.current={...this.parseElementDefinition(t),name:t.sliceName??"",definition:t.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(t){return(t.type??[]).map(n=>{var a;let r;return(n.code==="BackboneElement"||n.code==="Element")&&(r=cE(t)),r||(r=(a=Ji(n,"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"))==null?void 0:a.valueUrl),r||(r=n.code??""),{code:r,targetProfile:n.targetProfile,profile:n.profile}})}parseElementDefinition(t){var o,c;const n=tE(t.max),r=(o=t.base)!=null&&o.max?tE(t.base.max):n,a={type:"ElementDefinition",value:t};return{description:t.definition||"",path:t.path||((c=t.base)==null?void 0:c.path)||"",min:t.min??0,max:n,isArray:r>1,constraints:(t.constraint??[]).map(u=>({key:u.key??"",severity:u.severity??"error",expression:u.expression??"",description:u.human??""})),type:this.parseElementDefinitionType(t),fixed:nE(gc(a,"fixed[x]")),pattern:nE(gc(a,"pattern[x]")),binding:t.binding}}}function tE(e){return e==="*"?Number.POSITIVE_INFINITY:Number.parseInt(e,10)}function Vv(e,t=""){return u$(e.path,t)}function u$(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:""}function Gl(e,t){return!e||!t?!1:t.startsWith(e+".")||t===e}function nE(e){return Array.isArray(e)&&e.length>0?e[0]:Tn(e)?void 0:e}function d$(e){var n,r;const t=(n=e.slicing)==null?void 0:n.discriminator;return!!((r=e.type)!=null&&r.some(a=>a.code==="Extension")&&(t==null?void 0:t.length)===1&&t[0].type==="value"&&t[0].path==="url")}function f$(e){let t=e.description;return t!=null&&t.startsWith(`Base StructureDefinition for ${e.name} Type: `)&&(t=t.substring(`Base StructureDefinition for ${e.name} Type: `.length)),t}function h$(e,t,n){if(e===void 0)return[void 0];if(t==="$this")return[e];const r=n!=null&&n.withPath?p$:gc,[a,...o]=t.split(".");let c=[r(e,a,n)];for(const u of o){const f=[];for(const p of c)if(Array.isArray(p))for(const m of p)f.push(r(m,u,n));else(n!=null&&n.withPath&&p&&p.value!==void 0||!(n!=null&&n.withPath)&&p!==void 0)&&f.push(r(p,u,n));c=f}return c}function p$(e,t,n){const r=e.path;return m$(gc(e,t,n),r,t)}function m$(e,t,n){const r=t?t+".":"";return e===void 0?{type:"undefined",value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((a,o)=>({...a,path:`${r}${n}[${o}]`})):{...e,path:`${r}${n}`}}const sA={date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/};function g$(e,t,n,r){var c;if(Array.isArray(e))return!1;let a;t.path==="$this"?a=n:a=(r??n.elements)[t.path];const o=n.type;switch(t.type){case"value":case"pattern":if(!e||!a)return!1;if(a.pattern)return Y0(e,a.pattern);if(a.fixed)return si(e,a.fixed);if(((c=a.binding)==null?void 0:c.strength)==="required"&&a.binding.valueSet)return!0;break;case"type":return!e||!(o!=null&&o.length)?!1:o.some(u=>u.code===e.type)}return!1}function Qe(e){return[{type:oe.boolean,value:e}]}function pa(e){return e==null?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:oe.integer,value:e}:typeof e=="number"?{type:oe.decimal,value:e}:typeof e=="boolean"?{type:oe.boolean,value:e}:typeof e=="string"?{type:oe.string,value:e}:da(e)?{type:oe.Quantity,value:e}:fi(e)?{type:e.resourceType,value:e}:vA(e)?{type:oe.CodeableConcept,value:e}:gA(e)?{type:oe.Coding,value:e}:{type:oe.BackboneElement,value:e}}function ei(e){return e.length===0?!1:!!e[0].value}function Bi(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw new Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function gc(e,t,n){if(!e.value)return;const r=Wo(e.type,t,n==null?void 0:n.profileUrl);return r?lA(e,t,r):Td(e,t)}function lA(e,t,n){const r=e.value,a=n.type;if(!a||a.length===0)return;let o,c="undefined",u;const f=n.path.lastIndexOf("."),p=n.path.substring(f+1);for(const m of a){const g=p.replace("[x]",Hn(m.code));if(o=r[g],u=r["_"+g],o!==void 0||u!==void 0){c=m.code;break}}if(u)if(Array.isArray(o)){o=o.slice();for(let m=0;m<Math.max(o.length,u.length);m++)o[m]=oE(o[m],u[m])}else o=oE(o,u);if(!Tn(o))return(c==="Element"||c==="BackboneElement")&&(c=n.type[0].code),Array.isArray(o)?o.map(m=>rE(m,c)):rE(o,c)}function rE(e,t){return t==="Resource"&&fi(e)&&(t=e.resourceType),{type:t,value:e}}function Td(e,t){const n=e.value;if(!n||typeof n!="object")return;let r;if(t in n){const a=n[t];Array.isArray(a)?r=a.map(pa):r=pa(a)}else{const a=t.endsWith("[x]")?t.substring(0,t.length-3):t;for(const o of Object.values(oe)){const c=a+Hn(o);if(c in n){const u=n[c];Array.isArray(u)?r=u.map(f=>({type:o,value:f})):r={type:o,value:u};break}}}if(Array.isArray(r)){if(r.length===0||Tn(r[0]))return}else if(Tn(r))return;return r}function cA(e){const t=[];for(const n of e){let r=!1;for(const a of t)if(ei(qp(n,a))){r=!0;break}r||t.push(n)}return t}function v$(e){return Qe(!ei(e))}function y$(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?Qe(!1):Qe(e.every((n,r)=>ei(qp(n,t[r]))))}function x$(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?Qe(!0):Qe(e.some((n,r)=>!ei(qp(n,t[r]))))}function qp(e,t){var a,o;const n=(a=e.value)==null?void 0:a.valueOf(),r=(o=t.value)==null?void 0:o.valueOf();return typeof n=="number"&&typeof r=="number"?Qe(Math.abs(n-r)<1e-8):da(n)&&da(r)?Qe(hA(n,r)):Qe(typeof n=="object"&&typeof r=="object"?Q0(e,t):n===r)}function uA(e,t){return e.length===0&&t.length===0?Qe(!0):e.length!==t.length?Qe(!1):(e.sort(aE),t.sort(aE),Qe(e.every((n,r)=>ei(b$(n,t[r])))))}function b$(e,t){const{type:n,value:r}=e,{type:a,value:o}=t,c=r==null?void 0:r.valueOf(),u=o==null?void 0:o.valueOf();return typeof c=="number"&&typeof u=="number"?Qe(Math.abs(c-u)<.01):da(c)&&da(u)?Qe(hA(c,u)):Qe(n==="Coding"&&a==="Coding"?typeof c!="object"||typeof u!="object"?!1:c.code===u.code&&c.system===u.system:typeof c=="object"&&typeof u=="object"?Q0({...c,id:void 0},{...u,id:void 0}):typeof c=="string"&&typeof u=="string"?c.toLowerCase()===u.toLowerCase():c===u)}function aE(e,t){var a,o;const n=(a=e.value)==null?void 0:a.valueOf(),r=(o=t.value)==null?void 0:o.valueOf();return typeof n=="number"&&typeof r=="number"?n-r:typeof n=="string"&&typeof r=="string"?n.localeCompare(r):0}function dA(e,t){const{value:n}=e;if(n==null)return!1;let r=t;switch(r.startsWith("System.")&&(r=r.substring(7)),r.startsWith("FHIR.")&&(r=r.substring(5)),r){case"Boolean":return typeof n=="boolean";case"Decimal":case"Integer":return typeof n=="number";case"Date":return S$(n);case"DateTime":return Ih(n);case"Time":return typeof n=="string"&&!!/^T\d/.exec(n);case"Period":return fA(n);case"Quantity":return da(n);default:return e.type===r||typeof n=="object"&&(n==null?void 0:n.resourceType)===r}}function S$(e){return typeof e=="string"&&!!sA.date.exec(e)}function Ih(e){return typeof e=="string"&&!!sA.dateTime.exec(e)}function fA(e){return!!(e&&typeof e=="object"&&("start"in e&&Ih(e.start)||"end"in e&&Ih(e.end)))}function da(e){return!!(e&&typeof e=="object"&&"value"in e&&typeof e.value=="number")}function hA(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function Q0(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const a of n){const o=e[a],c=t[a];if(iE(o)&&iE(c)){if(!Q0(o,c))return!1}else if(o!==c)return!1}return!0}function iE(e){return e!==null&&typeof e=="object"}function oE(e,t){if(t){if(typeof t!="object")throw new Error("Primitive extension must be an object");return w$(e??{},t)}return e}function w$(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function j$(e,t){return fi(e,t)&&"id"in e&&typeof e.id=="string"}function on(e){const t=zt(e)??"undefined/undefined",n=Vi(e);return n===t?{reference:t}:{reference:t,display:n}}function zt(e){if(Yo(e))return e.reference;if(j$(e))return`${e.resourceType}/${e.id}`}function $s(e){if(e)return Yo(e)?e.reference.split("/")[1]:e.id}function C$(e){return e.resourceType==="Patient"||e.resourceType==="Practitioner"||e.resourceType==="RelatedPerson"}function Vi(e){if(C$(e)){const t=E$(e);if(t)return t}if(e.resourceType==="Device"){const t=T$(e);if(t)return t}if(e.resourceType==="MedicationRequest"&&e.medicationCodeableConcept)return Vo(e.medicationCodeableConcept);if(e.resourceType==="Subscription"&&e.criteria)return e.criteria;if(e.resourceType==="User"&&e.email)return e.email;if("name"in e&&e.name&&typeof e.name=="string")return e.name;if("code"in e&&e.code){let t=e.code;if(Array.isArray(t)&&(t=t[0]),vA(t))return Vo(t);if(I$(t))return t.text}return zt(e)??""}function E$(e){const t=e.name;if(t&&t.length>0)return Nc(t[0])}function T$(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name}function R$(e){if(!("photo"in e))return;const t=e.photo;if(t)if(Array.isArray(t))for(const n of t){const r=sE(n);if(r)return r}else return sE(t)}function sE(e){var t;if(e.url&&((t=e.contentType)!=null&&t.startsWith("image/")))return e.url}function pA(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);const a=n.getUTCFullYear(),o=n.getUTCMonth(),c=n.getUTCDate(),u=r.getUTCFullYear(),f=r.getUTCMonth(),p=r.getUTCDate();let m=u-a;(f<o||f===o&&p<c)&&m--;let g=u*12+f-(a*12+o);p<c&&g--;const v=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:m,months:g,days:v}}function D$(e,t){const{years:n,months:r,days:a}=pA(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":r>=1?r.toString().padStart(3,"0")+"M":a.toString().padStart(3,"0")+"D"}function Ji(e,...t){var r;let n=e;for(let a=0;a<t.length&&n;a++)n=(r=n==null?void 0:n.extension)==null?void 0:r.find(o=>o.url===t[a]);return n}function Ia(e,t){const n=W0(e);return JSON.stringify(n,null,t?2:void 0)??""}function W0(e){if(!(e==null||e===""))return typeof e=="object"?Array.isArray(e)?A$(e):_$(e):e}function A$(e){const t=e.length;if(t===0)return;let n,r=0;for(let a=0;a<t;a++){const o=e[a],c=W0(o);c!==o&&!n&&(n=Array.from(e)),c===void 0?n&&(n[a]=null):(n&&(n[a]=c),r++)}if(r!==0)return n??e}function _$(e){let t,n=0;for(const r in e){const a=e[r],o=W0(a);o!==a&&!t&&(t={...e}),o===void 0?t&&delete t[r]:(t&&(t[r]=o),n++)}if(n!==0)return t??e}function Tn(e){if(e==null)return!0;const t=typeof e;return t==="string"||t==="object"?!En(e):!1}function En(e){if(e==null)return!1;const t=typeof e;return t==="string"&&e!==""||t==="object"&&("length"in e&&e.length>0||Object.keys(e).length>0)}function si(e,t,n){return e===t||Tn(e)&&Tn(t)?!0:Tn(e)||Tn(t)?!1:Array.isArray(e)&&Array.isArray(t)?k$(e,t):Array.isArray(e)||Array.isArray(t)?!1:sr(e)&&sr(t)?P$(e,t,n):(sr(e)||sr(t),!1)}function k$(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!si(e[n],t[n]))return!1;return!0}function P$(e,t,n){const r=new Set;Object.keys(e).forEach(a=>r.add(a)),Object.keys(t).forEach(a=>r.add(a)),n==="meta"&&(r.delete("versionId"),r.delete("lastUpdated"),r.delete("author"));for(const a of r){const o=e[a],c=t[a];if(!si(o,c,a))return!1}return!0}function Y0(e,t){return Tn(e)?!0:Tn(t)?!1:Array.isArray(e)&&Array.isArray(t)?N$(e,t):Array.isArray(e)||Array.isArray(t)?!1:sr(e)&&sr(t)?O$(e,t):sr(e)||sr(t)?!1:e===t}function N$(e,t){return t.every(n=>e.some(r=>Y0(r,n)))}function O$(e,t){return Object.entries(t).every(([n,r])=>n in e&&Y0(e[n],r))}function Qr(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function mA(e){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(e)}function sr(e){return e!==null&&typeof e=="object"}function M$(e){return typeof e=="string"}function gA(e){return sr(e)&&"code"in e&&typeof e.code=="string"}function vA(e){return sr(e)&&"coding"in e&&Array.isArray(e.coding)&&e.coding.every(gA)}function I$(e){return sr(e)&&"text"in e&&typeof e.text=="string"}const yA=[];for(let e=0;e<256;e++)yA.push(e.toString(16).padStart(2,"0"));function L$(e){const t=xA(e),n=new Uint8Array(t),r=new Array(n.length);for(let a=0;a<n.length;a++)r[a]=yA[n[a]];return r.join("")}function z$(e){const t=xA(e),n=new Uint8Array(t),r=new Array(n.length);for(let a=0;a<n.length;a++)r[a]=String.fromCharCode(n[a]);return window.btoa(r.join(""))}function xA(e){return ArrayBuffer.isView(e)?e.buffer:e}function Hn(e){return e?e.charAt(0).toUpperCase()+e.substring(1):""}function K0(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function _s(e,t){const n=e+".";if(t.startsWith(n))return t.slice(n.length)}function $$(e,t){var n,r;return(r=(n=e.coding)==null?void 0:n.find(a=>a.system===t))==null?void 0:r.code}function U$(e){if(e!==void 0)return Array.isArray(e)?e:[e]}const lE=e=>new Promise(t=>{setTimeout(t,e)});function Py(e,t,n){const r=[];for(let a=0;a<n-1;a++){const o=e.indexOf(t);if(o<0)break;r.push(e.slice(0,o)),e=e.slice(o+t.length)}return r.push(e),r}function B$(e){let t,n=!1;return function(){return n||(t=e(),n=!0),t}}function Mu(e,t){return e?(e.push(t),e):[t]}function rd(e){return e.sort((t,n)=>t.localeCompare(n))}function X0(e){return e.endsWith("/")?e:e+"/"}function V$(e){return e.startsWith("/")?e.slice(1):e}function Xa(e,t){return new URL(V$(t),X0(e.toString())).toString()}function F$(e,t){return Xa(e,t).toString().replace("http://","ws://").replace("https://","wss://")}function H$(e){return typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))),new URLSearchParams(e).toString()}function bA(e,t){var n,r;return(r=(n=e==null?void 0:e.meta)==null?void 0:n.profile)!=null&&r.includes(t)||(e.meta=e.meta??{},e.meta.profile=e.meta.profile??[],e.meta.profile.push(t)),e}function q$(e,t){var n,r;if((r=(n=e==null?void 0:e.meta)==null?void 0:n.profile)!=null&&r.includes(t)){const a=e.meta.profile.indexOf(t);e.meta.profile.splice(a,1)}return e}function vc(e){if(!e)return"";switch(e.type){case"Address":return SA(e.value);case"CodeableConcept":return Vo(e.value);case"Coding":return Rd(e.value);case"ContactPoint":return e.value.value;case"HumanName":return Nc(e.value);case"Quantity":return ks(e.value);case"Reference":return G$(e.value);default:return e.value.toString()}}function G$(e){return e?e.display??e.reference??Ia(e):""}function SA(e,t){if(!e)return"";const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const r=[];e.city&&r.push(e.city),e.state&&r.push(e.state),e.postalCode&&r.push(e.postalCode),n.push(r.join(", "))}return e.use&&(t!=null&&t.use)&&n.push("["+e.use+"]"),n.join(", ").trim()}function Nc(e,t){if(!e)return"";const n=[];if(e.prefix&&(t==null?void 0:t.prefix)!==!1&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&(t==null?void 0:t.suffix)!==!1&&n.push(...e.suffix),e.use&&(t!=null&&t.all||t!=null&&t.use)&&n.push("["+e.use+"]"),n.length===0){const r=id(e.text);if(r)return r}return n.join(" ").trim()}function Gp(e){return e instanceof Date&&!isNaN(e.getTime())}function Q$(e,t,n){if(!e)return"";const r=new Date("2000-01-01T"+e+"Z");return Gp(r)?r.toLocaleTimeString(t,n):""}function gr(e,t,n){if(!e)return"";const r=new Date(e);return Gp(r)?r.toLocaleString(t,n):""}function W$(e,t,n){return!e||!e.start&&!e.end?"":gr(e.start,t,n)+" - "+gr(e.end,t,n)}const Y$={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},K$={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},X$={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function wA(e){if(!e)return"";const t=[];return Z$(t,e.repeat),e.event&&t.push(e.event.map(n=>gr(n)).join(", ")),Hn(t.join(" ").trim())}function Z$(e,t){if(!(t!=null&&t.periodUnit))return;const n=t.frequency??1,r=t.period??1,a=t.periodUnit;n===1&&r===1?e.push(Y$[a]):(n===1?e.push("once"):e.push(n+" times"),r===1?e.push("per "+K$[a]):e.push("per "+r+" "+X$[a])),t.dayOfWeek&&e.push("on "+t.dayOfWeek.map(Hn).join(", ")),t.timeOfDay&&e.push("at "+t.timeOfDay.map(o=>Q$(o)).join(", "))}function ad(e,t,n=!1){if(n&&t===void 0)throw new Error("Precision must be specified for exclusive ranges");const r=(e==null?void 0:e.low)&&{...e.low,comparator:void 0},a=(e==null?void 0:e.high)&&{...e.high,comparator:void 0};return(r==null?void 0:r.value)===void 0&&(a==null?void 0:a.value)===void 0?"":(r==null?void 0:r.value)!==void 0&&(a==null?void 0:a.value)===void 0?`>= ${ks(r)}`:(r==null?void 0:r.value)===void 0&&(a==null?void 0:a.value)!==void 0?`<= ${ks(a)}`:((r==null?void 0:r.unit)===(a==null?void 0:a.unit)&&(r==null||delete r.unit),`${ks(r)} - ${ks(a)}`)}function ks(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),e.value!==void 0&&n.push(e.value),e.unit&&(e.unit!=="%"&&n[n.length-1]!==" "&&n.push(" "),n.push(e.unit)),n.join("").trim()}function J$(e){return(e==null?void 0:e.value)===void 0?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency??"USD",currencyDisplay:"narrowSymbol"})}function Vo(e){if(!e)return"";const t=id(e.text);return t||(e.coding?e.coding.map(n=>Rd(n)).join(", "):"")}function Rd(e,t){const n=id(e==null?void 0:e.display);return n?`${n}`:id(e==null?void 0:e.code)??""}function jA(e){if(!e)return"";const t=[];if(e.valueQuantity)t.push(ks(e.valueQuantity));else if(e.valueCodeableConcept)t.push(Vo(e.valueCodeableConcept));else{const n=id(e.valueString);n&&t.push(n)}return"component"in e&&t.push(e.component.map(n=>jA(n)).join(" / ")),t.join(" / ").trim()}function id(e){return typeof e=="string"?e:void 0}const oe={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid"};function eU(e){var n;const t=Array.isArray(e)?e:((n=e.entry)==null?void 0:n.map(r=>r.resource))??[];for(const r of t)(r==null?void 0:r.resourceType)==="StructureDefinition"&&r.kind==="resource"&&CA(r.type)}function CA(e){let t=li.types[e];return t||(t={searchParamsDetails:{}},li.types[e]=t),t.searchParams||(t.searchParams={_id:{base:[e],code:"_id",type:"token",expression:e+".id"},_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"},_compartment:{base:[e],code:"_compartment",type:"reference",expression:e+".meta.compartment"},_profile:{base:[e],code:"_profile",type:"uri",expression:e+".meta.profile"},_security:{base:[e],code:"_security",type:"token",expression:e+".meta.security"},_source:{base:[e],code:"_source",type:"uri",expression:e+".meta.source"},_tag:{base:[e],code:"_tag",type:"token",expression:e+".meta.tag"}}),t}function tU(e){for(const t of e.base??[]){const n=CA(t);n.searchParams||(n.searchParams={}),n.searchParams[e.code]=e}}function cE(e){var n,r,a,o;const t=(r=(n=e.type)==null?void 0:n[0])==null?void 0:r.code;return t==="BackboneElement"||t==="Element"?nU((o=((a=e.base)==null?void 0:a.path)??e.path)==null?void 0:o.split(".")):t}function nU(e){return e.length===1?e[0]:e.map(Hn).join("")}function Z0(e){var t;return(t=li.types[e])==null?void 0:t.searchParams}function rU(e,t){var n,r;return(r=(n=li.types[e])==null?void 0:n.searchParams)==null?void 0:r[t]}function Us(e){const t=e.replaceAll("[x]","").split(".").pop();return EA(t)}function EA(e){let t;return e.length<100?t=e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:t=e.split(/(?=[A-Z])/),t.map(iU).join(" ").replace("_"," ").replace(/\s+/g," ")}const aU=new Set(["ID","IP","PKCE","JWKS","URI","URL","OMB","UDI"]);function iU(e){const t=e.toUpperCase();return e===t?e:aU.has(t)?t:t.charAt(0)+e.slice(1)}function Wo(e,t,n){const r=Hp(e,n);if(r)return oU(r.elements,t)}function oU(e,t){const n=e[t]??e[t+"[x]"];if(n)return n;for(let r=0;r<t.length;r++){const a=t[r];if(a>="A"&&a<="Z"){const o=t.slice(0,r)+"[x]",c=e[o];if(c)return c}}}function fi(e,t){return!(!e||typeof e!="object"||!("resourceType"in e)||t&&e.resourceType!==t)}function Yo(e){return!!(e&&typeof e=="object"&&"reference"in e&&typeof e.reference=="string")}const li={types:{}};function yh(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch{return e}}const Pi=()=>[],Tr={empty:(e,t)=>Qe(t.length===0||t.every(n=>Tn(n.value))),hasValue:(e,t)=>Qe(t.length!==0),exists:(e,t,n)=>Qe(n?t.filter(r=>ei(n.eval(e,[r]))).length>0:t.length>0&&t.every(r=>!Tn(r.value))),all:(e,t,n)=>Qe(t.every(r=>ei(n.eval(e,[r])))),allTrue:(e,t)=>{for(const n of t)if(!n.value)return Qe(!1);return Qe(!0)},anyTrue:(e,t)=>{for(const n of t)if(n.value)return Qe(!0);return Qe(!1)},allFalse:(e,t)=>{for(const n of t)if(n.value)return Qe(!1);return Qe(!0)},anyFalse:(e,t)=>{for(const n of t)if(!n.value)return Qe(!0);return Qe(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return Qe(!0);const r=n.eval(e,ys(e));return r.length===0?Qe(!1):Qe(t.every(a=>r.some(o=>o.value===a.value)))},supersetOf:(e,t,n)=>{const r=n.eval(e,ys(e));return r.length===0?Qe(!0):t.length===0?Qe(!1):Qe(r.every(a=>t.some(o=>o.value===a.value)))},count:(e,t)=>[{type:oe.integer,value:t.length}],distinct:(e,t)=>{const n=[];for(const r of t)n.some(a=>a.value===r.value)||n.push(r);return n},isDistinct:(e,t)=>Qe(t.length===Tr.distinct(e,t).length),where:(e,t,n)=>t.filter(r=>ei(n.eval(e,[r]))),select:(e,t,n)=>t.map(r=>n.eval({parent:e,variables:{$this:r}},[r])).flat(),repeat:Pi,ofType:(e,t,n)=>t.filter(r=>r.type===n.name),single:(e,t)=>{if(t.length>1)throw new Error("Expected input length one for single()");return t.length===0?[]:t.slice(0,1)},first:(e,t)=>t.length===0?[]:t.slice(0,1),last:(e,t)=>t.length===0?[]:t.slice(t.length-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{var a;const r=(a=n.eval(e,t)[0])==null?void 0:a.value;if(typeof r!="number")throw new Error("Expected a number for skip(num)");return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{var a;const r=(a=n.eval(e,t)[0])==null?void 0:a.value;if(typeof r!="number")throw new Error("Expected a number for take(num)");return r>=t.length?t:r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e)),a=[];for(const o of t)!a.some(c=>c.value===o.value)&&r.some(c=>c.value===o.value)&&a.push(o);return a},exclude:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e)),a=[];for(const o of t)r.some(c=>c.value===o.value)||a.push(o);return a},union:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e));return cA([...t,...r])},combine:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e));return[...t,...r]},htmlChecks:(e,t,n)=>[pa(!0)],iif:(e,t,n,r,a)=>{const o=n.eval(e,t);if(o.length>1||o.length===1&&typeof o[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return ei(o)?r.eval(e,t):a?a.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);if(typeof n=="boolean")return[{type:oe.boolean,value:n}];if(typeof n=="number"&&(n===0||n===1))return Qe(!!n);if(typeof n=="string"){const r=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(r))return Qe(!0);if(["false","f","no","n","0","0.0"].includes(r))return Qe(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:Qe(Tr.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="number"?[{type:oe.integer,value:n}]:typeof n=="string"&&/^[+-]?\d+$/.exec(n)?[{type:oe.integer,value:parseInt(n,10)}]:typeof n=="boolean"?[{type:oe.integer,value:n?1:0}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:Qe(Tr.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:oe.date,value:yh(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:Qe(Tr.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:oe.dateTime,value:yh(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:Qe(Tr.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="number"?[{type:oe.decimal,value:n}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:oe.decimal,value:parseFloat(n)}]:typeof n=="boolean"?[{type:oe.decimal,value:n?1:0}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:Qe(Tr.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return da(n)?[{type:oe.Quantity,value:n}]:typeof n=="number"?[{type:oe.Quantity,value:{value:n,unit:"1"}}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:oe.Quantity,value:{value:parseFloat(n),unit:"1"}}]:typeof n=="boolean"?[{type:oe.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:Qe(Tr.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return n==null?[]:da(n)?[{type:oe.string,value:`${n.value} '${n.unit}'`}]:[{type:oe.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:Qe(Tr.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);if(typeof n=="string"){const r=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(r)return[{type:oe.time,value:yh("T"+r[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:Qe(Tr.toTime(e,t).length===1),indexOf:(e,t,n)=>sa((r,a)=>r.indexOf(a),e,t,n),substring:(e,t,n,r)=>sa((a,o,c)=>{const u=o,f=c?u+c:a.length;return u<0||u>=a.length?void 0:a.substring(u,f)},e,t,n,r),startsWith:(e,t,n)=>sa((r,a)=>r.startsWith(a),e,t,n),endsWith:(e,t,n)=>sa((r,a)=>r.endsWith(a),e,t,n),contains:(e,t,n)=>sa((r,a)=>r.includes(a),e,t,n),upper:(e,t)=>sa(n=>n.toUpperCase(),e,t),lower:(e,t)=>sa(n=>n.toLowerCase(),e,t),replace:(e,t,n,r)=>sa((a,o,c)=>a.replaceAll(o,c),e,t,n,r),matches:(e,t,n)=>sa((r,a)=>!!new RegExp(a).exec(r),e,t,n),replaceMatches:(e,t,n,r)=>sa((a,o,c)=>a.replaceAll(o,c),e,t,n,r),length:(e,t)=>sa(n=>n.length,e,t),toChars:(e,t)=>sa(n=>n?n.split(""):void 0,e,t),encode:Pi,decode:Pi,escape:Pi,unescape:Pi,trim:Pi,split:Pi,join:(e,t,n)=>{var a;const r=((a=n==null?void 0:n.eval(e,ys(e))[0])==null?void 0:a.value)??"";if(typeof r!="string")throw new Error("Separator must be a string.");return[{type:oe.string,value:t.map(o=>{var c;return((c=o.value)==null?void 0:c.toString())??""}).join(r)}]},abs:(e,t)=>Ya(Math.abs,e,t),ceiling:(e,t)=>Ya(Math.ceil,e,t),exp:(e,t)=>Ya(Math.exp,e,t),floor:(e,t)=>Ya(Math.floor,e,t),ln:(e,t)=>Ya(Math.log,e,t),log:(e,t,n)=>Ya((r,a)=>Math.log(r)/Math.log(a),e,t,n),power:(e,t,n)=>Ya(Math.pow,e,t,n),round:(e,t)=>Ya(Math.round,e,t),sqrt:(e,t)=>Ya(Math.sqrt,e,t),truncate:(e,t)=>Ya(n=>n|0,e,t),children:Pi,descendants:Pi,trace:(e,t,n)=>t,now:()=>[{type:oe.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:oe.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:oe.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,a)=>{var p;const o=Tr.toDateTime(e,n.eval(e,t));if(o.length===0)throw new Error("Invalid start date");const c=Tr.toDateTime(e,r.eval(e,t));if(c.length===0)throw new Error("Invalid end date");const u=(p=a.eval(e,t)[0])==null?void 0:p.value;if(u!=="years"&&u!=="months"&&u!=="days")throw new Error("Invalid units");const f=pA(o[0].value,c[0].value);return[{type:oe.Quantity,value:{value:f[u],unit:u}}]},is:(e,t,n)=>{let r="";return n instanceof Lh?r=n.name:n instanceof J0&&(r=n.left.name+"."+n.right.name),r?t.map(a=>({type:oe.boolean,value:dA(a,r)})):[]},not:(e,t)=>Tr.toBoolean(e,t).map(n=>({type:oe.boolean,value:!n.value})),resolve:(e,t)=>t.map(n=>{const r=n.value;let a;if(typeof r=="string")a=r;else if(typeof r=="object"){const o=r;if(o.resource)return pa(o.resource);o.reference?a=o.reference:o.type&&o.identifier&&(a=`${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`)}if(a!=null&&a.includes("?")){const[o]=a.split("?");return{type:o,value:{resourceType:o}}}if(a!=null&&a.includes("/")){const[o,c]=a.split("/");return{type:o,value:{resourceType:o,id:c}}}return{type:oe.BackboneElement,value:void 0}}).filter(n=>!!n.value),as:(e,t)=>t,type:(e,t)=>t.map(({value:n})=>typeof n=="boolean"?{type:oe.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof n=="number"?{type:oe.BackboneElement,value:{namespace:"System",name:"Integer"}}:fi(n)?{type:oe.BackboneElement,value:{namespace:"FHIR",name:n.resourceType}}:{type:oe.BackboneElement,value:null}),conformsTo:(e,t,n)=>{const r=n.eval(e,t)[0].value;if(!r.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const a=r.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map(o=>{var c;return{type:oe.boolean,value:((c=o.value)==null?void 0:c.resourceType)===a}})},getResourceKey:(e,t)=>{const n=t[0].value;return n!=null&&n.id?[{type:oe.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{const r=t[0].value;if(!(r!=null&&r.reference))return[];let a="";return n instanceof Lh&&(a=n.name),a&&!r.reference.startsWith(a+"/")?[]:[{type:oe.id,value:$s(r)}]},extension:(e,t,n)=>{var o;const r=n.eval(e,t)[0].value,a=(o=t==null?void 0:t[0])==null?void 0:o.value;if(a){const c=Ji(a,r);if(c)return[{type:oe.Extension,value:c}]}return[]}};function sa(e,t,n,...r){if(n.length===0)return[];const[{value:a}]=Za(n,1);if(typeof a!="string")throw new Error("String function cannot be called with non-string");const o=e(a,...r.map(c=>{var u;return(u=c==null?void 0:c.eval(t,n)[0])==null?void 0:u.value}));return o===void 0?[]:Array.isArray(o)?o.map(pa):[pa(o)]}function Ya(e,t,n,...r){if(n.length===0)return[];const[{value:a}]=Za(n,1),o=da(a),c=o?a.value:a;if(typeof c!="number")throw new Error("Math function cannot be called with non-number");const u=e(c,...r.map(m=>{var g;return(g=m.eval(t,n)[0])==null?void 0:g.value})),f=o?oe.Quantity:n[0].type,p=o?{...a,value:u}:u;return[{type:f,value:p}]}function Za(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const n of e)if(n==null)throw new Error("Expected non-null argument");return e}function ys(e){var n;let t=e;for(;(n=t.parent)!=null&&n.variables.$this;)t=t.parent;return[t.variables.$this]}class TA{constructor(t,n){this.original=t,this.child=n}eval(t,n){try{if(n.length>0){const r=[];for(const a of n)r.push(this.child.eval({parent:t,variables:{$this:a}},[a]));return r.flat()}else return this.child.eval(t,[])}catch(r){throw new Error(`FhirPathError on "${this.original}": ${r}`,{cause:r})}}toString(){return this.child.toString()}}class Ql{constructor(t){this.value=t}eval(){return[this.value]}toString(){const t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}}class Lh{constructor(t){this.name=t}eval(t,n){if(this.name==="$this")return n;const r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return n.flatMap(a=>this.evalValue(a)).filter(a=>(a==null?void 0:a.value)!==void 0)}getVariable(t){const n=t.variables[this.name];if(n!==void 0)return n;if(t.parent)return this.getVariable(t.parent)}evalValue(t){const n=t.value;if(!(!n||typeof n!="object"))return fi(n,this.name)?t:gc(t,this.name)}toString(){return this.name}}class sU{eval(){return[]}toString(){return"{}"}}class lU extends $z{constructor(t,n,r){super(t,n),this.impl=r}eval(t,n){return this.impl(this.child.eval(t,n))}toString(){return this.operator+this.child.toString()}}class zh extends Cd{constructor(t,n){super("as",t,n)}eval(t,n){return Tr.ofType(t,this.left.eval(t,n),this.right)}}class Nr extends Cd{}class Da extends Nr{constructor(t,n,r,a){super(t,n,r),this.impl=a}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const a=this.right.eval(t,n);if(a.length!==1)return[];const o=r[0].value,c=a[0].value,u=da(o)?o.value:o,f=da(c)?c.value:c,p=this.impl(u,f);return typeof p=="boolean"?Qe(p):da(o)?[{type:oe.Quantity,value:{...o,value:p}}]:[pa(p)]}}class cU extends Cd{constructor(t,n){super("&",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n),o=[...r,...a];return o.length>0&&o.every(c=>typeof c.value=="string")?[{type:oe.string,value:o.map(c=>c.value).join("")}]:o}}class uU extends Nr{constructor(t,n){super("contains",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return Qe(r.some(o=>o.value===a[0].value))}}class dU extends Nr{constructor(t,n){super("in",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n)),a=this.right.eval(t,n);return r?Qe(a.some(o=>qp(r,o)[0].value)):[]}}class J0 extends Cd{constructor(t,n){super(".",t,n)}eval(t,n){return this.right.eval(t,this.left.eval(t,n))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class eb extends Cd{constructor(t,n){super("|",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return cA([...r,...a])}}class fU extends Nr{constructor(t,n){super("=",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return y$(r,a)}}class hU extends Nr{constructor(t,n){super("!=",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return x$(r,a)}}class pU extends Nr{constructor(t,n){super("~",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return uA(r,a)}}class mU extends Nr{constructor(t,n){super("!~",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return v$(uA(r,a))}}class tb extends Nr{constructor(t,n){super("is",t,n)}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const a=this.right.name;return Qe(dA(r[0],a))}}class gU extends Nr{constructor(t,n){super("and",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!0&&(a==null?void 0:a.value)===!0?Qe(!0):(r==null?void 0:r.value)===!1||(a==null?void 0:a.value)===!1?Qe(!1):[]}}class vU extends Nr{constructor(t,n){super("or",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!1&&(a==null?void 0:a.value)===!1?Qe(!1):r!=null&&r.value||a!=null&&a.value?Qe(!0):[]}}class yU extends Nr{constructor(t,n){super("xor",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return!r||!a?[]:Qe(r.value!==a.value)}}class xU extends Nr{constructor(t,n){super("implies",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(a==null?void 0:a.value)===!0||(r==null?void 0:r.value)===!1?Qe(!0):!r||!a?[]:Qe(!1)}}class nb{constructor(t,n){this.name=t,this.args=n}eval(t,n){const r=Tr[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,n,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}}class rb{constructor(t,n){this.left=t,this.expr=n}eval(t,n){const r=this.expr.eval(t,n);if(r.length!==1)return[];const a=r[0].value;if(typeof a!="number")throw new Error("Invalid indexer expression: should return integer}");const o=this.left.eval(t,n);return a in o?[o[a]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const bU=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class SU{constructor(t,n,r,a){this.result=[],this.pos={index:0,line:1,column:0},this.markStack=[],this.str=t,this.keywords=n,this.operators=r,this.dateTimeLiterals=!!(a!=null&&a.dateTimeLiterals),this.symbolRegex=(a==null?void 0:a.symbolRegex)??/[$\w%]/}tokenize(){for(;this.pos.index<this.str.length;){const t=this.consumeToken();t&&this.result.push(t)}return this.result}prevToken(){return this.result.slice(-1)[0]}peekToken(){this.mark();const t=this.consumeToken();return this.reset(),t}consumeToken(){this.consumeWhitespace();const t=this.curr();if(!t)return;this.mark();const n=this.peek();return t==="/"&&n==="*"?this.consumeMultiLineComment():t==="/"&&n==="/"?this.consumeSingleLineComment():t==="'"||t==='"'||t==="`"?this.consumeString(t):t==="@"?this.consumeDateTime():/\d/.exec(t)?this.consumeNumber():/\w/.exec(t)?this.consumeSymbol():(t==="$"||t==="%")&&/\w/.exec(n)?this.consumeSymbol():(t==="$"||t==="%")&&(n==="'"||n==='"'||n==="`")?this.consumeQuotedSymbol(n):this.consumeOperator()}consumeWhitespace(){this.consumeWhile(()=>/\s/.exec(this.curr()))}consumeMultiLineComment(){const t=this.pos.index;return this.consumeWhile(()=>this.curr()!=="*"||this.peek()!=="/"),this.advance(),this.advance(),this.buildToken("Comment",this.str.substring(t,this.pos.index))}consumeSingleLineComment(){return this.buildToken("Comment",this.consumeWhile(()=>this.curr()!==`
76
+ `),o=!1),Object.assign(Object.assign({},e),{allowNegative:o})}function kL(e){e=_L(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,a=e.onKeyDown;a===void 0&&(a=Lo);var o=e.onBlur;o===void 0&&(o=Lo);var c=e.thousandSeparator,u=e.decimalScale,f=e.fixedDecimalScale,p=e.prefix;p===void 0&&(p="");var m=e.defaultValue,g=e.value,v=e.valueIsNumericString,b=e.onValueChange,S=mD(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),j=Np(e),C=j.decimalSeparator,R=j.allowedDecimalSeparators,D=function(P){return VC(P,e)},E=function(P,I){return DL(P,I,e)},T=ac(g)?m:g,A=v??RL(T,p,t);ac(g)?ac(m)||(A=A||typeof m=="number"):A=A||typeof g=="number";var k=function(P){return gD(P)?P:(typeof P=="number"&&(P=xD(P)),A&&typeof u=="number"?UC(P,u,!!f):P)},M=SD(k(g),k(m),!!A,D,E,b),L=M[0],$=L.numAsString,V=L.formattedValue,Y=M[1],Q=function(P){var I=P.target,z=P.key,H=I.selectionStart,O=I.selectionEnd,U=I.value;if(U===void 0&&(U=""),(z==="Backspace"||z==="Delete")&&O<p.length){P.preventDefault();return}if(H!==O){a(P);return}z==="Backspace"&&U[0]==="-"&&H===p.length+1&&n&&Cs(I,1),u&&f&&(z==="Backspace"&&U[H-1]===C?(Cs(I,H-1),P.preventDefault()):z==="Delete"&&U[H]===C&&P.preventDefault()),R!=null&&R.includes(z)&&U[H]===C&&Cs(I,H+1);var K=c===!0?",":c;z==="Backspace"&&U[H-1]===K&&Cs(I,H-1),z==="Delete"&&U[H]===K&&Cs(I,H+1),a(P)},J=function(P){var I=$;if(I.match(/\d/g)||(I=""),r||(I=pL(I)),f&&u&&(I=UC(I,u,f)),I!==$){var z=VC(I,e);Y({formattedValue:z,value:I,floatValue:parseFloat(I)},{event:P,source:ed.event})}o(P)},G=function(P){return P===C?!0:td(P)},Z=function(P){var I=P.currentValue,z=P.lastValue,H=P.formattedValue,O=P.currentValueIndex,U=P.formattedValueIndex,K=I[O],ee=H[U],be=bD(z,I),xe=be.to,ye=function(qe){return E(qe).indexOf(".")+p.length};return g===0&&f&&u&&I[xe.start]===C&&ye(I)<O&&ye(H)>U?!1:O>=xe.start&&O<xe.end&&R&&R.includes(K)&&ee===C?!0:K===ee};return Object.assign(Object.assign({},S),{value:V,valueIsNumericString:!1,isValidInputCharacter:G,isCharacterSame:Z,onValueChange:Y,format:D,removeFormatting:E,getCaretBoundary:function(P){return AL(P,e)},onKeyDown:Q,onBlur:J})}function PL(e){var t=kL(e);return Cn.createElement(CL,Object.assign({},t))}function FC({direction:e,style:t,...n}){return s.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:e==="up"?"rotate(180deg)":void 0,...t},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:s.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}var Ty={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};const NL=/^(0\.0*|-0(\.0*)?)$/,OL=/^-?0\d+(\.\d+)?\.?$/;function Ry(e){return typeof e=="string"&&e!==""&&!Number.isNaN(Number(e))}function Lv(e){return typeof e=="number"?e<Number.MAX_SAFE_INTEGER:e===""||Ry(e)&&Number(e)<Number.MAX_SAFE_INTEGER}function ML(e){return e.toString().replace(".","").length}function IL(e,t){return(typeof e=="number"?e<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&ML(t)<14&&t!==""}function HC(e,t,n){if(e===void 0)return!0;const r=t===void 0||e>=t,a=n===void 0||e<=n;return r&&a}const LL={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0},zL=(e,{size:t})=>({controls:{"--ni-chevron-size":rt(t,"ni-chevron-size")}});function $L(e,t,n){const r=e.toString().replace(/^0+/,""),a=parseFloat(r);return Number.isNaN(a)?r:a>Number.MAX_SAFE_INTEGER?t!==void 0?String(t):r:ph(a,n,t)}const Op=ve((e,t)=>{const n=se("NumberInput",LL,e),{className:r,classNames:a,styles:o,unstyled:c,vars:u,onChange:f,onValueChange:p,value:m,defaultValue:g,max:v,min:b,step:S,hideControls:j,rightSection:C,isAllowed:R,clampBehavior:D,onBlur:E,allowDecimal:T,decimalScale:A,onKeyDown:k,onKeyDownCapture:M,handlersRef:L,startValue:$,disabled:V,rightSectionPointerEvents:Y,allowNegative:Q,readOnly:J,size:G,rightSectionWidth:Z,stepHoldInterval:P,stepHoldDelay:I,allowLeadingZeros:z,withKeyboardEvents:H,trimLeadingZeroesOnBlur:O,...U}=n,K=Ie({name:"NumberInput",classes:Ty,props:n,classNames:a,styles:o,unstyled:c,vars:u,varsResolver:zL}),{resolvedClassNames:ee,resolvedStyles:be}=Qs({classNames:a,styles:o,props:n}),[xe,ye]=Yn({value:m,defaultValue:g,finalValue:"",onChange:f}),qe=I!==void 0&&P!==void 0,Ne=y.useRef(null),tt=y.useRef(null),Ae=y.useRef(0),gt=(Se,$e)=>{$e.source==="event"&&ye(IL(Se.floatValue,Se.value)&&!NL.test(Se.value)&&!(z&&OL.test(Se.value))?Se.floatValue:Se.value),p==null||p(Se,$e)},Mt=Se=>{const $e=String(Se).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return $e?Math.max(0,($e[1]?$e[1].length:0)-($e[2]?+$e[2]:0)):0},It=Se=>{Ne.current&&typeof Se<"u"&&Ne.current.setSelectionRange(Se,Se)},mt=y.useRef(Eh);mt.current=()=>{if(!Lv(xe))return;let Se;const $e=Mt(xe),vt=Mt(S),ft=Math.max($e,vt),Gt=10**ft;if(!Ry(xe)&&(typeof xe!="number"||Number.isNaN(xe)))Se=ph($,b,v);else if(v!==void 0){const un=(Math.round(Number(xe)*Gt)+Math.round(S*Gt))/Gt;Se=un<=v?un:v}else Se=(Math.round(Number(xe)*Gt)+Math.round(S*Gt))/Gt;const _t=Se.toFixed(ft);ye(parseFloat(_t)),p==null||p({floatValue:parseFloat(_t),formattedValue:_t,value:_t},{source:"increment"}),setTimeout(()=>{var un;return It((un=Ne.current)==null?void 0:un.value.length)},0)};const Dt=y.useRef(Eh);Dt.current=()=>{if(!Lv(xe))return;let Se;const $e=b!==void 0?b:Q?Number.MIN_SAFE_INTEGER:0,vt=Mt(xe),ft=Mt(S),Gt=Math.max(vt,ft),_t=10**Gt;if(!Ry(xe)&&typeof xe!="number"||Number.isNaN(xe))Se=ph($,$e,v);else{const wt=(Math.round(Number(xe)*_t)-Math.round(S*_t))/_t;Se=$e!==void 0&&wt<$e?$e:wt}const un=Se.toFixed(Gt);ye(parseFloat(un)),p==null||p({floatValue:parseFloat(un),formattedValue:un,value:un},{source:"decrement"}),setTimeout(()=>{var wt;return It((wt=Ne.current)==null?void 0:wt.value.length)},0)};const nn=Se=>{k==null||k(Se),!(J||!H)&&(Se.key==="ArrowUp"&&(Se.preventDefault(),mt.current()),Se.key==="ArrowDown"&&(Se.preventDefault(),Dt.current()))},Ce=Se=>{if(M==null||M(Se),Se.key==="Backspace"){const $e=Ne.current;$e.selectionStart===0&&$e.selectionStart===$e.selectionEnd&&(Se.preventDefault(),window.setTimeout(()=>It(0),0))}},Re=Se=>{let $e=xe;D==="blur"&&typeof $e=="number"&&($e=ph($e,b,v)),O&&typeof $e=="string"&&Mt($e)<15&&($e=$L($e,v,b)),xe!==$e&&ye($e),E==null||E(Se)};Ku(L,{increment:mt.current,decrement:Dt.current});const Ge=Se=>{Se?mt.current():Dt.current(),Ae.current+=1},Te=Se=>{if(Ge(Se),qe){const $e=typeof P=="number"?P:P(Ae.current);tt.current=window.setTimeout(()=>Te(Se),$e)}},me=(Se,$e)=>{var vt;Se.preventDefault(),(vt=Ne.current)==null||vt.focus(),Ge($e),qe&&(tt.current=window.setTimeout(()=>Te($e),I))},ge=()=>{tt.current&&window.clearTimeout(tt.current),tt.current=null,Ae.current=0},ke=s.jsxs("div",{...K("controls"),children:[s.jsx(tr,{...K("control"),tabIndex:-1,"aria-hidden":!0,disabled:V||typeof xe=="number"&&v!==void 0&&xe>=v,mod:{direction:"up"},onMouseDown:Se=>Se.preventDefault(),onPointerDown:Se=>{me(Se,!0)},onPointerUp:ge,onPointerLeave:ge,children:s.jsx(FC,{direction:"up"})}),s.jsx(tr,{...K("control"),tabIndex:-1,"aria-hidden":!0,disabled:V||typeof xe=="number"&&b!==void 0&&xe<=b,mod:{direction:"down"},onMouseDown:Se=>Se.preventDefault(),onPointerDown:Se=>{me(Se,!1)},onPointerUp:ge,onPointerLeave:ge,children:s.jsx(FC,{direction:"down"})})]});return s.jsx(Pr,{component:PL,allowNegative:Q,className:Ut(Ty.root,r),size:G,...U,readOnly:J,disabled:V,value:xe,getInputRef:zn(t,Ne),onValueChange:gt,rightSection:j||J||!Lv(xe)?C:C||ke,classNames:ee,styles:be,unstyled:c,__staticSelector:"NumberInput",decimalScale:T?A:0,onKeyDown:nn,onKeyDownCapture:Ce,rightSectionPointerEvents:Y??(V?"none":void 0),rightSectionWidth:Z??`var(--ni-right-section-width-${G||"sm"})`,allowLeadingZeros:z,onBlur:Re,isAllowed:Se=>D==="strict"?R?R(Se)&&HC(Se.floatValue,b,v):HC(Se.floatValue,b,v):R?R(Se):!0})});Op.classes={...Pr.classes,...Ty};Op.displayName="@mantine/core/NumberInput";const[UL,Mp]=vr("Pagination.Root component was not found in tree");var yd={root:"m_4addd315",control:"m_326d024a",dots:"m_4ad7767d"};const BL={withPadding:!0},xd=ve((e,t)=>{const n=se("PaginationControl",BL,e),{classNames:r,className:a,style:o,styles:c,vars:u,active:f,disabled:p,withPadding:m,mod:g,...v}=n,b=Mp(),S=p||b.disabled;return s.jsx(tr,{ref:t,disabled:S,mod:[{active:f,disabled:S,"with-padding":m},g],...b.getStyles("control",{className:a,style:o,classNames:r,styles:c,active:!S}),...v})});xd.classes=yd;xd.displayName="@mantine/core/PaginationControl";function bd({style:e,children:t,path:n,...r}){return s.jsx("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)",...e},...r,children:s.jsx("path",{d:n,fill:"currentColor"})})}const VL=e=>s.jsx(bd,{...e,path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"}),FL=e=>s.jsx(bd,{...e,path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"}),HL=e=>s.jsx(bd,{...e,path:"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z"}),qL=e=>s.jsx(bd,{...e,path:"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z"}),GL=e=>s.jsx(bd,{...e,path:"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z"}),QL={icon:GL},Ip=ve((e,t)=>{const n=se("PaginationDots",QL,e),{classNames:r,className:a,style:o,styles:c,vars:u,icon:f,...p}=n,m=Mp(),g=f;return s.jsx(ce,{ref:t,...m.getStyles("dots",{className:a,style:o,styles:c,classNames:r}),...p,children:s.jsx(g,{style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});Ip.classes=yd;Ip.displayName="@mantine/core/PaginationDots";function Lp({icon:e,name:t,action:n,type:r}){const a={icon:e},o=y.forwardRef((c,u)=>{const{icon:f,...p}=se(t,a,c),m=f,g=Mp(),v=r==="next"?g.active===g.total:g.active===1;return s.jsx(xd,{disabled:g.disabled||v,ref:u,onClick:g[n],withPadding:!1,...p,children:s.jsx(m,{className:"mantine-rotate-rtl",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});return o.displayName=`@mantine/core/${t}`,o}const wD=Lp({icon:VL,name:"PaginationNext",action:"onNext",type:"next"}),jD=Lp({icon:FL,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),CD=Lp({icon:HL,name:"PaginationFirst",action:"onFirst",type:"previous"}),ED=Lp({icon:qL,name:"PaginationLast",action:"onLast",type:"next"});function R0({dotsIcon:e}){const t=Mp(),n=t.range.map((r,a)=>{var o,c,u;return r==="dots"?s.jsx(Ip,{icon:e},a):s.jsx(xd,{active:r===t.active,"aria-current":r===t.active?"page":void 0,onClick:()=>t.onChange(r),disabled:t.disabled,...(o=t.getItemProps)==null?void 0:o.call(t,r),children:((u=(c=t.getItemProps)==null?void 0:c.call(t,r))==null?void 0:u.children)??r},a)});return s.jsx(s.Fragment,{children:n})}R0.displayName="@mantine/core/PaginationItems";const WL={siblings:1,boundaries:1},YL=(e,{size:t,radius:n,color:r,autoContrast:a})=>({root:{"--pagination-control-radius":n===void 0?void 0:Vt(n),"--pagination-control-size":rt(t,"pagination-control-size"),"--pagination-control-fz":On(t),"--pagination-active-bg":r?Ht(r,e):void 0,"--pagination-active-color":Ws(a,e)?Gi({color:r,theme:e,autoContrast:a}):void 0}}),zp=ve((e,t)=>{const n=se("PaginationRoot",WL,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,total:p,value:m,defaultValue:g,onChange:v,disabled:b,siblings:S,boundaries:j,color:C,radius:R,onNextPage:D,onPreviousPage:E,onFirstPage:T,onLastPage:A,getItemProps:k,autoContrast:M,...L}=n,$=Ie({name:"Pagination",classes:yd,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:YL}),{range:V,setPage:Y,next:Q,previous:J,active:G,first:Z,last:P}=pN({page:m,initialPage:g,onChange:v,total:p,siblings:S,boundaries:j}),I=Rr(D,Q),z=Rr(E,J),H=Rr(T,Z),O=Rr(A,P);return s.jsx(UL,{value:{total:p,range:V,active:G,disabled:b,getItemProps:k,onChange:Y,onNext:I,onPrevious:z,onFirst:H,onLast:O,getStyles:$},children:s.jsx(ce,{ref:t,...$("root"),...L})})});zp.classes=yd;zp.displayName="@mantine/core/PaginationRoot";const KL={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},$a=ve((e,t)=>{const n=se("Pagination",KL,e),{withEdges:r,withControls:a,getControlProps:o,nextIcon:c,previousIcon:u,lastIcon:f,firstIcon:p,dotsIcon:m,total:g,gap:v,hideWithOnePage:b,withPages:S,...j}=n;return g<=0||b&&g===1?null:s.jsx(zp,{ref:t,total:g,...j,children:s.jsxs(je,{gap:v,children:[r&&s.jsx(CD,{icon:p,...o==null?void 0:o("first")}),a&&s.jsx(jD,{icon:u,...o==null?void 0:o("previous")}),S&&s.jsx(R0,{dotsIcon:m}),a&&s.jsx(wD,{icon:c,...o==null?void 0:o("next")}),r&&s.jsx(ED,{icon:f,...o==null?void 0:o("last")})]})})});$a.classes=yd;$a.displayName="@mantine/core/Pagination";$a.Root=zp;$a.Control=xd;$a.Dots=Ip;$a.First=CD;$a.Last=ED;$a.Next=wD;$a.Previous=jD;$a.Items=R0;const XL=({reveal:e})=>s.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"var(--psi-icon-size)",height:"var(--psi-icon-size)"},children:s.jsx("path",{d:e?"M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z":"M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})});var Dy={root:"m_f61ca620",input:"m_ccf8da4c",innerInput:"m_f2d85dd2",visibilityToggle:"m_b1072d44"};const ZL={visibilityToggleIcon:XL},JL=(e,{size:t})=>({root:{"--psi-icon-size":rt(t,"psi-icon-size"),"--psi-button-size":rt(t,"psi-button-size")}}),Na=ve((e,t)=>{const n=se("PasswordInput",ZL,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,required:p,error:m,leftSection:g,disabled:v,id:b,variant:S,inputContainer:j,description:C,label:R,size:D,errorProps:E,descriptionProps:T,labelProps:A,withAsterisk:k,inputWrapperOrder:M,wrapperProps:L,radius:$,rightSection:V,rightSectionWidth:Y,rightSectionPointerEvents:Q,leftSectionWidth:J,visible:G,defaultVisible:Z,onVisibilityChange:P,visibilityToggleIcon:I,visibilityToggleButtonProps:z,rightSectionProps:H,leftSectionProps:O,leftSectionPointerEvents:U,withErrorStyles:K,mod:ee,...be}=n,xe=yr(b),[ye,qe]=Yn({value:G,defaultValue:Z,finalValue:!1,onChange:P}),Ne=()=>qe(!ye),tt=Ie({name:"PasswordInput",classes:Dy,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:JL}),{resolvedClassNames:Ae,resolvedStyles:gt}=Qs({classNames:r,styles:c,props:n}),{styleProps:Mt,rest:It}=Qi(be),mt=I,Dt=(E==null?void 0:E.id)||`${xe}-error`,nn=(T==null?void 0:T.id)||`${xe}-description`,Ge=`${!!m&&typeof m!="boolean"?Dt:""} ${!!C?nn:""}`,Te=Ge.trim().length>0?Ge.trim():void 0,me=s.jsx(_n,{...tt("visibilityToggle"),disabled:v,radius:$,"aria-hidden":!z,tabIndex:-1,...z,variant:(z==null?void 0:z.variant)??"subtle",color:"gray",unstyled:u,onTouchEnd:ge=>{var ke;ge.preventDefault(),(ke=z==null?void 0:z.onTouchEnd)==null||ke.call(z,ge),Ne()},onMouseDown:ge=>{var ke;ge.preventDefault(),(ke=z==null?void 0:z.onMouseDown)==null||ke.call(z,ge),Ne()},onKeyDown:ge=>{var ke;(ke=z==null?void 0:z.onKeyDown)==null||ke.call(z,ge),ge.key===" "&&(ge.preventDefault(),Ne())},children:s.jsx(mt,{reveal:ye})});return s.jsx(mn.Wrapper,{required:p,id:xe,label:R,error:m,description:C,size:D,classNames:Ae,styles:gt,__staticSelector:"PasswordInput",unstyled:u,withAsterisk:k,inputWrapperOrder:M,inputContainer:j,variant:S,labelProps:{...A,htmlFor:xe},descriptionProps:{...T,id:nn},errorProps:{...E,id:Dt},mod:ee,...tt("root"),...Mt,...L,children:s.jsx(mn,{component:"div",error:m,leftSection:g,size:D,classNames:{...Ae,input:Ut(Dy.input,Ae.input)},styles:gt,radius:$,disabled:v,__staticSelector:"PasswordInput",rightSectionWidth:Y,rightSection:V??me,variant:S,unstyled:u,leftSectionWidth:J,rightSectionPointerEvents:Q||"all",rightSectionProps:H,leftSectionProps:O,leftSectionPointerEvents:U,withAria:!1,withErrorStyles:K,children:s.jsx("input",{required:p,"data-invalid":!!m||void 0,"data-with-left-section":!!g||void 0,...tt("innerInput"),disabled:v,id:xe,ref:t,...It,"aria-describedby":Te,autoComplete:It.autoComplete||"off",type:ye?"text":"password"})})})});Na.classes={...Pr.classes,...Dy};Na.displayName="@mantine/core/PasswordInput";const[e6,TD]=Hi(),[t6,n6]=Hi();var RD={card:"m_9dc8ae12"};const r6={withBorder:!0},a6=(e,{radius:t})=>({card:{"--card-radius":Vt(t)}}),D0=ve((e,t)=>{const n=se("RadioCard",r6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,checked:p,mod:m,withBorder:g,value:v,onClick:b,name:S,onKeyDown:j,...C}=n,R=Ie({name:"RadioCard",classes:RD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:a6,rootSelector:"card"}),{dir:D}=Ks(),E=TD(),T=typeof p=="boolean"?p:(E==null?void 0:E.value)===v||!1,A=S||(E==null?void 0:E.name),k=M=>{if(j==null||j(M),["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(M.nativeEvent.code)){M.preventDefault();const L=Array.from(document.querySelectorAll(`[role="radio"][name="${A||"__mantine"}"]`)),$=L.findIndex(Q=>Q===M.target),V=$+1>=L.length?0:$+1,Y=$-1<0?L.length-1:$-1;M.nativeEvent.code==="ArrowDown"&&(L[V].focus(),L[V].click()),M.nativeEvent.code==="ArrowUp"&&(L[Y].focus(),L[Y].click()),M.nativeEvent.code==="ArrowLeft"&&(L[D==="ltr"?Y:V].focus(),L[D==="ltr"?Y:V].click()),M.nativeEvent.code==="ArrowRight"&&(L[D==="ltr"?V:Y].focus(),L[D==="ltr"?V:Y].click())}};return s.jsx(t6,{value:{checked:T},children:s.jsx(tr,{ref:t,mod:[{"with-border":g,checked:T},m],...R("card"),...C,role:"radio","aria-checked":T,name:A,onClick:M=>{b==null||b(M),E==null||E.onChange(v||"")},onKeyDown:k})})});D0.displayName="@mantine/core/RadioCard";D0.classes=RD;const i6={},A0=ve((e,t)=>{const{value:n,defaultValue:r,onChange:a,size:o,wrapperProps:c,children:u,name:f,readOnly:p,...m}=se("RadioGroup",i6,e),g=yr(f),[v,b]=Yn({value:n,defaultValue:r,finalValue:"",onChange:a}),S=j=>!p&&b(typeof j=="string"?j:j.currentTarget.value);return s.jsx(e6,{value:{value:v,onChange:S,size:o,name:g},children:s.jsx(mn.Wrapper,{size:o,ref:t,...c,...m,labelElement:"div",__staticSelector:"RadioGroup",children:s.jsx(t0,{role:"radiogroup",children:u})})})});A0.classes=mn.Wrapper.classes;A0.displayName="@mantine/core/RadioGroup";function DD({size:e,style:t,...n}){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:le(e),height:le(e),...t},"aria-hidden":!0,...n,children:s.jsx("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"})})}var AD={indicator:"m_717d7ff6",icon:"m_3e4da632","indicator--outline":"m_2980836c"};const o6={icon:DD},s6=(e,{radius:t,color:n,size:r,iconColor:a,variant:o,autoContrast:c})=>{const u=fa({color:n||e.primaryColor,theme:e}),f=u.isThemeColor&&u.shade===void 0?`var(--mantine-color-${u.color}-outline)`:u.color;return{indicator:{"--radio-size":rt(r,"radio-size"),"--radio-radius":t===void 0?void 0:Vt(t),"--radio-color":o==="outline"?f:Ht(n,e),"--radio-icon-size":rt(r,"radio-icon-size"),"--radio-icon-color":a?Ht(a,e):Ws(c,e)?Gi({color:n,theme:e,autoContrast:c}):void 0}}},_0=ve((e,t)=>{const n=se("RadioIndicator",o6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,icon:p,radius:m,color:g,iconColor:v,autoContrast:b,checked:S,mod:j,variant:C,disabled:R,...D}=n,E=p,T=Ie({name:"RadioIndicator",classes:AD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:s6,rootSelector:"indicator"}),A=n6(),k=typeof S=="boolean"?S:(A==null?void 0:A.checked)||!1;return s.jsx(ce,{ref:t,...T("indicator",{variant:C}),variant:C,mod:[{checked:k,disabled:R},j],...D,children:s.jsx(E,{...T("icon")})})});_0.displayName="@mantine/core/RadioIndicator";_0.classes=AD;var _D={root:"m_f3f1af94",inner:"m_89c4f5e4",icon:"m_f3ed6b2b",radio:"m_8a3dbb89","radio--outline":"m_1bfe9d39"};const l6={labelPosition:"right"},c6=(e,{size:t,radius:n,color:r,iconColor:a,variant:o,autoContrast:c})=>{const u=fa({color:r||e.primaryColor,theme:e}),f=u.isThemeColor&&u.shade===void 0?`var(--mantine-color-${u.color}-outline)`:u.color;return{root:{"--radio-size":rt(t,"radio-size"),"--radio-radius":n===void 0?void 0:Vt(n),"--radio-color":o==="outline"?f:Ht(r,e),"--radio-icon-color":a?Ht(a,e):Ws(c,e)?Gi({color:r,theme:e,autoContrast:c}):void 0,"--radio-icon-size":rt(t,"radio-icon-size")}}},zs=ve((e,t)=>{const n=se("Radio",l6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,id:p,size:m,label:g,labelPosition:v,description:b,error:S,radius:j,color:C,variant:R,disabled:D,wrapperProps:E,icon:T=DD,rootRef:A,iconColor:k,onChange:M,mod:L,...$}=n,V=Ie({name:"Radio",classes:_D,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:c6}),Y=TD(),Q=(Y==null?void 0:Y.size)??m,J=n.size?m:Q,{styleProps:G,rest:Z}=Qi($),P=yr(p),I=Y?{checked:Y.value===Z.value,name:Z.name??Y.name,onChange:z=>{Y.onChange(z),M==null||M(z)}}:{};return s.jsx(bp,{...V("root"),__staticSelector:"Radio",__stylesApiProps:n,id:P,size:J,labelPosition:v,label:g,description:b,error:S,disabled:D,classNames:r,styles:c,unstyled:u,"data-checked":I.checked||void 0,variant:R,ref:A,mod:L,...G,...E,children:s.jsxs(ce,{...V("inner"),mod:{"label-position":v},children:[s.jsx(ce,{...V("radio",{focusable:!0,variant:R}),onChange:M,...Z,...I,component:"input",mod:{error:!!S},ref:t,id:P,disabled:D,type:"radio"}),s.jsx(T,{...V("icon"),"aria-hidden":!0})]})})});zs.classes=_D;zs.displayName="@mantine/core/Radio";zs.Group=A0;zs.Card=D0;zs.Indicator=_0;const u6={duration:100,transition:"fade"};function d6(e,t){return{...u6,...t,...e}}function f6({offset:e,position:t,defaultOpened:n}){const[r,a]=y.useState(n),o=y.useRef(null),{x:c,y:u,elements:f,refs:p,update:m,placement:g}=Dx({placement:t,middleware:[Cx({crossAxis:!0,padding:5,rootBoundary:"document"})]}),v=g.includes("right")?e:t.includes("left")?e*-1:0,b=g.includes("bottom")?e:t.includes("top")?e*-1:0,S=y.useCallback(({clientX:j,clientY:C})=>{p.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:j,y:C,left:j+v,top:C+b,right:j,bottom:C}}})},[f.reference]);return y.useEffect(()=>{if(p.floating.current){const j=o.current;j.addEventListener("mousemove",S);const C=Ii(p.floating.current);return C.forEach(R=>{R.addEventListener("scroll",m)}),()=>{j.removeEventListener("mousemove",S),C.forEach(R=>{R.removeEventListener("scroll",m)})}}},[f.reference,p.floating.current,m,S,r]),{handleMouseMove:S,x:c,y:u,opened:r,setOpened:a,boundaryRef:o,floating:p.setFloating}}var $p={tooltip:"m_1b3c8819",arrow:"m_f898399f"};const h6={refProp:"ref",withinPortal:!0,offset:10,defaultOpened:!1,position:"right",zIndex:Wr("popover")},p6=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:Vt(t),"--tooltip-bg":n?Ht(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),k0=ve((e,t)=>{const n=se("TooltipFloating",h6,e),{children:r,refProp:a,withinPortal:o,style:c,className:u,classNames:f,styles:p,unstyled:m,radius:g,color:v,label:b,offset:S,position:j,multiline:C,zIndex:R,disabled:D,defaultOpened:E,variant:T,vars:A,portalProps:k,...M}=n,L=Sn(),$=Ie({name:"TooltipFloating",props:n,classes:$p,className:u,style:c,classNames:f,styles:p,unstyled:m,rootSelector:"tooltip",vars:A,varsResolver:p6}),{handleMouseMove:V,x:Y,y:Q,opened:J,boundaryRef:G,floating:Z,setOpened:P}=f6({offset:S,position:j,defaultOpened:E});if(!Fi(r))throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const I=zn(G,op(r),t),z=r.props,H=U=>{var K;(K=z.onMouseEnter)==null||K.call(z,U),V(U),P(!0)},O=U=>{var K;(K=z.onMouseLeave)==null||K.call(z,U),P(!1)};return s.jsxs(s.Fragment,{children:[s.jsx(qo,{...k,withinPortal:o,children:s.jsx(ce,{...M,...$("tooltip",{style:{...wR(c,L),zIndex:R,display:!D&&J?"block":"none",top:(Q&&Math.round(Q))??"",left:(Y&&Math.round(Y))??""}}),variant:T,ref:Z,mod:{multiline:C},children:b})}),y.cloneElement(r,{...z,[a]:I,onMouseEnter:H,onMouseLeave:O})]})});k0.classes=$p;k0.displayName="@mantine/core/TooltipFloating";const kD=y.createContext(!1),m6=kD.Provider,g6=()=>y.useContext(kD),v6={openDelay:0,closeDelay:0};function P0(e){const{openDelay:t,closeDelay:n,children:r}=se("TooltipGroup",v6,e);return s.jsx(m6,{value:!0,children:s.jsx(GM,{delay:{open:t,close:n},children:r})})}P0.displayName="@mantine/core/TooltipGroup";P0.extend=e=>e;function y6(e){if(e===void 0)return{shift:!0,flip:!0};const t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function x6(e){const t=y6(e.middlewares),n=[UR(e.offset)];return t.shift&&n.push(Cx(typeof t.shift=="boolean"?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip=="boolean"?kh():kh(t.flip)),n.push(BR({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline=="boolean"?Gu():Gu(t.inline)):e.inline&&n.push(Gu()),n}function b6(e){var k,M,L;const[t,n]=y.useState(e.defaultOpened),a=typeof e.opened=="boolean"?e.opened:t,o=g6(),c=yr(),u=y.useCallback($=>{n($),$&&D(c)},[c]),{x:f,y:p,context:m,refs:g,update:v,placement:b,middlewareData:{arrow:{x:S,y:j}={}}}=Dx({strategy:e.strategy,placement:e.position,open:a,onOpenChange:u,middleware:x6(e)}),{delay:C,currentId:R,setCurrentId:D}=QM(m,{id:c}),{getReferenceProps:E,getFloatingProps:T}=e9([HM(m,{enabled:(k=e.events)==null?void 0:k.hover,delay:o?C:{open:e.openDelay,close:e.closeDelay},mouseOnly:!((M=e.events)!=null&&M.touch)}),JM(m,{enabled:(L=e.events)==null?void 0:L.focus,visibleOnly:!0}),n9(m,{role:"tooltip"}),XM(m,{enabled:typeof e.opened>"u"})]);h2({opened:a,position:e.position,positionDependencies:e.positionDependencies,floating:{refs:g,update:v}}),zi(()=>{var $;($=e.onPositionChange)==null||$.call(e,b)},[b]);const A=a&&R&&R!==c;return{x:f,y:p,arrowX:S,arrowY:j,reference:g.setReference,floating:g.setFloating,getFloatingProps:T,getReferenceProps:E,isGroupPhase:A,opened:a,placement:b}}const qC={position:"top",refProp:"ref",withinPortal:!0,inline:!1,defaultOpened:!1,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:Wr("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},S6=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:Vt(t),"--tooltip-bg":n?Ht(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),Zs=ve((e,t)=>{const n=se("Tooltip",qC,e),{children:r,position:a,refProp:o,label:c,openDelay:u,closeDelay:f,onPositionChange:p,opened:m,defaultOpened:g,withinPortal:v,radius:b,color:S,classNames:j,styles:C,unstyled:R,style:D,className:E,withArrow:T,arrowSize:A,arrowOffset:k,arrowRadius:M,arrowPosition:L,offset:$,transitionProps:V,multiline:Y,events:Q,zIndex:J,disabled:G,positionDependencies:Z,onClick:P,onMouseEnter:I,onMouseLeave:z,inline:H,variant:O,keepMounted:U,vars:K,portalProps:ee,mod:be,floatingStrategy:xe,middlewares:ye,...qe}=se("Tooltip",qC,n),{dir:Ne}=Ks(),tt=y.useRef(null),Ae=b6({position:o2(Ne,a),closeDelay:f,openDelay:u,onPositionChange:p,opened:m,defaultOpened:g,events:Q,arrowRef:tt,arrowOffset:k,offset:typeof $=="number"?$+(T?A/2:0):$,positionDependencies:[...Z,r],inline:H,strategy:xe,middlewares:ye}),gt=Ie({name:"Tooltip",props:n,classes:$p,className:E,style:D,classNames:j,styles:C,unstyled:R,rootSelector:"tooltip",vars:K,varsResolver:S6});if(!Fi(r))throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const Mt=zn(Ae.reference,op(r),t),It=d6(V,{duration:100,transition:"fade"}),mt=r.props;return s.jsxs(s.Fragment,{children:[s.jsx(qo,{...ee,withinPortal:v,children:s.jsx(di,{...It,keepMounted:U,mounted:!G&&!!Ae.opened,duration:Ae.isGroupPhase?10:It.duration,children:Dt=>s.jsxs(ce,{...qe,"data-fixed":xe==="fixed"||void 0,variant:O,mod:[{multiline:Y},be],...Ae.getFloatingProps({ref:Ae.floating,className:gt("tooltip").className,style:{...gt("tooltip").style,...Dt,zIndex:J,top:Ae.y??0,left:Ae.x??0}}),children:[c,s.jsx(Px,{ref:tt,arrowX:Ae.arrowX,arrowY:Ae.arrowY,visible:T,position:Ae.placement,arrowSize:A,arrowOffset:k,arrowRadius:M,arrowPosition:L,...gt("arrow")})]})})}),y.cloneElement(r,Ae.getReferenceProps({onClick:P,onMouseEnter:I,onMouseLeave:z,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,className:Ut(E,mt.className),...mt,[o]:Mt}))]})});Zs.classes=$p;Zs.displayName="@mantine/core/Tooltip";Zs.Floating=k0;Zs.Group=P0;function w6({size:e,thickness:t,sum:n,value:r,root:a,offset:o}){const c=(e*.9-t*2)/2,u=Math.PI*c*2/100,f=a||r===void 0?`${(100-n)*u}, ${n*u}`:`${r*u}, ${(100-r)*u}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:c||0,transform:a?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:f,strokeDashoffset:a?0:o||0}}function PD({size:e,value:t,offset:n,sum:r,thickness:a,root:o,color:c,lineRoundCaps:u,tooltip:f,getStyles:p,display:m,...g}){const v=Sn();return s.jsx(Zs.Floating,{disabled:!f,label:f,children:s.jsx(ce,{component:"circle",...g,...p("curve"),__vars:{"--curve-color":c?Ht(c,v):void 0},fill:"none",strokeLinecap:u?"round":"butt",...w6({sum:r,size:e,thickness:a,value:t,offset:n,root:o})})})}PD.displayName="@mantine/core/Curve";function j6({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:a}){const o=n.reduce((m,g)=>m+g.value,0),c=Math.PI*((e*.9-t*2)/2)*2;let u=c;const f=[],p=[];for(let m=0;m<n.length;m+=1)f.push({sum:o,offset:u,data:n[m],root:!1}),u-=n[m].value/100*c;if(f.push({sum:o,offset:u,data:{color:a},root:!0}),p.push({...f[f.length-1],lineRoundCaps:!1}),f.length>2){p.push({...f[0],lineRoundCaps:r}),p.push({...f[f.length-2],lineRoundCaps:r});for(let m=1;m<=f.length-3;m+=1)p.push({...f[m],lineRoundCaps:!1})}else p.push({...f[0],lineRoundCaps:r});return p}var ND={root:"m_b32e4812",svg:"m_d43b5134",curve:"m_b1ca1fbf",label:"m_b23f9dc4"};function C6(e,t){return Math.min(e||12,(t||120)/4)}const E6={size:120,thickness:12},T6=(e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":le(t),"--rp-label-offset":le(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}}),Up=ve((e,t)=>{const n=se("RingProgress",E6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,label:p,sections:m,size:g,thickness:v,roundCaps:b,rootColor:S,transitionDuration:j,...C}=n,R=Ie({name:"RingProgress",classes:ND,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:T6}),D=C6(v,g),E=j6({size:g,thickness:D,sections:m,renderRoundedLineCaps:b,rootColor:S}).map(({data:T,sum:A,root:k,lineRoundCaps:M,offset:L},$)=>y.createElement(PD,{...T,key:$,size:g,thickness:D,sum:A,offset:L,color:T==null?void 0:T.color,root:k,lineRoundCaps:M,getStyles:R}));return s.jsxs(ce,{...R("root"),size:g,ref:t,...C,children:[s.jsx("svg",{...R("svg"),children:E}),p&&s.jsx("div",{...R("label"),children:p})]})});Up.classes=ND;Up.displayName="@mantine/core/RingProgress";var OD={root:"m_cf365364",indicator:"m_9e182ccd",label:"m_1738fcb2",input:"m_1714d588",control:"m_69686b9b",innerLabel:"m_78882f40"};const R6={withItemsBorders:!0},D6=(e,{radius:t,color:n,transitionDuration:r,size:a,transitionTimingFunction:o})=>({root:{"--sc-radius":t===void 0?void 0:Vt(t),"--sc-color":n?Ht(n,e):void 0,"--sc-shadow":n?void 0:"var(--mantine-shadow-xs)","--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":o,"--sc-padding":rt(a,"sc-padding"),"--sc-font-size":On(a)}}),Bp=ve((e,t)=>{var Ne,tt;const n=se("SegmentedControl",R6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,data:p,value:m,defaultValue:g,onChange:v,size:b,name:S,disabled:j,readOnly:C,fullWidth:R,orientation:D,radius:E,color:T,transitionDuration:A,transitionTimingFunction:k,variant:M,autoContrast:L,withItemsBorders:$,mod:V,...Y}=n,Q=Ie({name:"SegmentedControl",props:n,classes:OD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:D6}),J=Sn(),G=p.map(Ae=>typeof Ae=="string"?{label:Ae,value:Ae}:Ae),Z=bN(),[P,I]=y.useState(Th()),[z,H]=y.useState(null),[O,U]=y.useState({}),K=(Ae,gt)=>{O[gt]=Ae,U(O)},[ee,be]=Yn({value:m,defaultValue:g,finalValue:Array.isArray(p)?((Ne=G.find(Ae=>!Ae.disabled))==null?void 0:Ne.value)??((tt=p[0])==null?void 0:tt.value)??null:null,onChange:v}),xe=yr(S),ye=G.map(Ae=>y.createElement(ce,{...Q("control"),mod:{active:ee===Ae.value,orientation:D},key:Ae.value},y.createElement("input",{...Q("input"),disabled:j||Ae.disabled,type:"radio",name:xe,value:Ae.value,id:`${xe}-${Ae.value}`,checked:ee===Ae.value,onChange:()=>!C&&be(Ae.value),"data-focus-ring":J.focusRing,key:`${Ae.value}-input`}),y.createElement(ce,{component:"label",...Q("label"),mod:{active:ee===Ae.value&&!(j||Ae.disabled),disabled:j||Ae.disabled,"read-only":C},htmlFor:`${xe}-${Ae.value}`,ref:gt=>K(gt,Ae.value),__vars:{"--sc-label-color":T!==void 0?Gi({color:T,theme:J,autoContrast:L}):void 0},key:`${Ae.value}-label`},s.jsx("span",{...Q("innerLabel"),children:Ae.label})))),qe=zn(t,Ae=>H(Ae));return vN(()=>{I(Th())},[p.length]),p.length===0?null:s.jsxs(ce,{...Q("root"),variant:M,size:b,ref:qe,mod:[{"full-width":R,orientation:D,initialized:Z,"with-items-borders":$},V],...Y,role:"radiogroup","data-disabled":j,children:[typeof ee=="string"&&s.jsx(zx,{target:O[ee],parent:z,component:"span",transitionDuration:"var(--sc-transition-duration)",...Q("indicator")},P),ye]})});Bp.classes=OD;Bp.displayName="@mantine/core/SegmentedControl";function A6({spacing:e,verticalSpacing:t,cols:n,selector:r}){var m;const a=Sn(),o=t===void 0?e:t,c=Ho({"--sg-spacing-x":Nn(_a(e)),"--sg-spacing-y":Nn(_a(o)),"--sg-cols":(m=_a(n))==null?void 0:m.toString()}),u=sn(a.breakpoints).reduce((g,v)=>(g[v]||(g[v]={}),typeof e=="object"&&e[v]!==void 0&&(g[v]["--sg-spacing-x"]=Nn(e[v])),typeof o=="object"&&o[v]!==void 0&&(g[v]["--sg-spacing-y"]=Nn(o[v])),typeof n=="object"&&n[v]!==void 0&&(g[v]["--sg-cols"]=n[v]),g),{}),p=Yu(sn(u),a.breakpoints).filter(g=>sn(u[g.value]).length>0).map(g=>({query:`(min-width: ${a.breakpoints[g.value]})`,styles:u[g.value]}));return s.jsx(Ys,{styles:c,media:p,selector:r})}function zv(e){return typeof e=="object"&&e!==null?sn(e):[]}function _6(e){return e.sort((t,n)=>Wu(t)-Wu(n))}function k6({spacing:e,verticalSpacing:t,cols:n}){const r=Array.from(new Set([...zv(e),...zv(t),...zv(n)]));return _6(r)}function P6({spacing:e,verticalSpacing:t,cols:n,selector:r}){var p;const a=t===void 0?e:t,o=Ho({"--sg-spacing-x":Nn(_a(e)),"--sg-spacing-y":Nn(_a(a)),"--sg-cols":(p=_a(n))==null?void 0:p.toString()}),c=k6({spacing:e,verticalSpacing:t,cols:n}),u=c.reduce((m,g)=>(m[g]||(m[g]={}),typeof e=="object"&&e[g]!==void 0&&(m[g]["--sg-spacing-x"]=Nn(e[g])),typeof a=="object"&&a[g]!==void 0&&(m[g]["--sg-spacing-y"]=Nn(a[g])),typeof n=="object"&&n[g]!==void 0&&(m[g]["--sg-cols"]=n[g]),m),{}),f=c.map(m=>({query:`simple-grid (min-width: ${m})`,styles:u[m]}));return s.jsx(Ys,{styles:o,container:f,selector:r})}var MD={container:"m_925c2d2c",root:"m_2415a157"};const N6={cols:1,spacing:"md",type:"media"},N0=ve((e,t)=>{const n=se("SimpleGrid",N6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,cols:p,verticalSpacing:m,spacing:g,type:v,...b}=n,S=Ie({name:"SimpleGrid",classes:MD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f}),j=ud();return v==="container"?s.jsxs(s.Fragment,{children:[s.jsx(P6,{...n,selector:`.${j}`}),s.jsx("div",{...S("container"),children:s.jsx(ce,{ref:t,...S("root",{className:j}),...b})})]}):s.jsxs(s.Fragment,{children:[s.jsx(A6,{...n,selector:`.${j}`}),s.jsx(ce,{ref:t,...S("root",{className:j}),...b})]})});N0.classes=MD;N0.displayName="@mantine/core/SimpleGrid";const O6={},Vp=ve((e,t)=>{const{w:n,h:r,miw:a,mih:o,...c}=se("Space",O6,e);return s.jsx(ce,{ref:t,...c,w:n,miw:a??n,h:r,mih:o??r})});Vp.displayName="@mantine/core/Space";var ID={root:"m_6d731127"};const M6={gap:"md",align:"stretch",justify:"flex-start"},I6=(e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":Nn(t),"--stack-align":n,"--stack-justify":r}}),We=ve((e,t)=>{const n=se("Stack",M6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,align:p,justify:m,gap:g,variant:v,...b}=n,S=Ie({name:"Stack",props:n,classes:ID,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:I6});return s.jsx(ce,{ref:t,...S("root"),variant:v,...b})});We.classes=ID;We.displayName="@mantine/core/Stack";const[L6,z6]=vr("Stepper component was not found in tree"),Nh=()=>null;Nh.displayName="@mantine/core/StepperCompleted";var O0={root:"m_cbb4ea7e",steps:"m_aaf89d0b",separator:"m_2a371ac9",content:"m_78da155d",step:"m_cbb57068","step--horizontal":"m_f56b1e2c","step--vertical":"m_833edb7e",verticalSeparator:"m_6496b3f3",stepWrapper:"m_818e70b",stepIcon:"m_1959ad01",stepCompletedIcon:"m_a79331dc",stepBody:"m_1956aa2a",stepLabel:"m_12051f6c",stepDescription:"m_164eea74"};const ah=(e,t)=>typeof e=="function"?s.jsx(e,{step:t||0}):e,$6={withIcon:!0,allowStepClick:!0,iconPosition:"left"},M0=ve((e,t)=>{const{classNames:n,className:r,style:a,styles:o,vars:c,step:u,state:f,color:p,icon:m,completedIcon:g,progressIcon:v,label:b,description:S,withIcon:j,iconSize:C,loading:R,allowStepClick:D,allowStepSelect:E,iconPosition:T,orientation:A,mod:k,...M}=se("StepperStep",$6,e),L=z6(),$=Sn(),V={classNames:n,styles:o},Y=f==="stepCompleted"?null:f==="stepProgress"?v:m,Q={"data-progress":f==="stepProgress"||void 0,"data-completed":f==="stepCompleted"||void 0};return s.jsxs(tr,{...L.getStyles("step",{className:r,style:a,variant:L.orientation,...V}),mod:[{"icon-position":T||L.iconPosition,"allow-click":D},k],ref:t,...Q,...M,__vars:{"--step-color":p?Ht(p,$):void 0},tabIndex:D?0:-1,children:[j&&s.jsxs("span",{...L.getStyles("stepWrapper",V),children:[s.jsxs("span",{...L.getStyles("stepIcon",V),...Q,children:[s.jsx(di,{mounted:f==="stepCompleted",transition:"pop",duration:200,children:J=>s.jsx("span",{...L.getStyles("stepCompletedIcon",{style:J,...V}),children:R?s.jsx(_r,{color:"var(--mantine-color-white)",size:"calc(var(--stepper-icon-size) / 2)",...L.getStyles("stepLoader",V)}):ah(g,u)||s.jsx(Sp,{size:"60%"})})}),f!=="stepCompleted"?R?s.jsx(_r,{...L.getStyles("stepLoader",V),size:"calc(var(--stepper-icon-size) / 2)",color:p}):ah(Y||m,u):null]}),A==="vertical"&&s.jsx("span",{...L.getStyles("verticalSeparator",V),"data-active":f==="stepCompleted"||void 0})]}),(b||S)&&s.jsxs("span",{...L.getStyles("stepBody",V),"data-orientation":L.orientation,"data-icon-position":T||L.iconPosition,children:[b&&s.jsx("span",{...L.getStyles("stepLabel",V),children:ah(b,u)}),S&&s.jsx("span",{...L.getStyles("stepDescription",V),children:ah(S,u)})]})]})});M0.classes=O0;M0.displayName="@mantine/core/StepperStep";const U6={orientation:"horizontal",iconPosition:"left",allowNextStepsSelect:!0,wrap:!0},B6=(e,{color:t,iconSize:n,size:r,contentPadding:a,radius:o,autoContrast:c})=>({root:{"--stepper-color":t?Ht(t,e):void 0,"--stepper-icon-color":Ws(c,e)?Gi({color:t,theme:e,autoContrast:c}):void 0,"--stepper-icon-size":n===void 0?rt(r,"stepper-icon-size"):le(n),"--stepper-content-padding":Nn(a),"--stepper-radius":o===void 0?void 0:Vt(o),"--stepper-fz":On(r),"--stepper-spacing":Nn(r)}}),mc=ve((e,t)=>{var z,H,O;const n=se("Stepper",U6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,children:p,onStepClick:m,active:g,icon:v,completedIcon:b,progressIcon:S,color:j,iconSize:C,contentPadding:R,orientation:D,iconPosition:E,size:T,radius:A,allowNextStepsSelect:k,wrap:M,autoContrast:L,...$}=n,V=Ie({name:"Stepper",classes:O0,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:B6}),Y=y.Children.toArray(p),Q=Y.filter(U=>U.type!==Nh),J=Y.find(U=>U.type===Nh),G=Q.reduce((U,K,ee)=>{const be=g===ee?"stepProgress":g>ee?"stepCompleted":"stepInactive",ye=typeof m!="function"?!1:typeof K.props.allowStepSelect=="boolean"?K.props.allowStepSelect:be==="stepCompleted"||k;return U.push(y.cloneElement(K,{icon:K.props.icon||v||ee+1,key:ee,step:ee,state:be,onClick:()=>ye&&(m==null?void 0:m(ee)),allowStepClick:ye,completedIcon:K.props.completedIcon||b,progressIcon:K.props.progressIcon||S,color:K.props.color||j,iconSize:C,iconPosition:K.props.iconPosition||E,orientation:D})),D==="horizontal"&&ee!==Q.length-1&&U.push(y.createElement("div",{...V("separator"),"data-active":ee<g||void 0,"data-orientation":D,key:`separator-${ee}`})),U},[]),Z=(H=(z=Q[g])==null?void 0:z.props)==null?void 0:H.children,P=(O=J==null?void 0:J.props)==null?void 0:O.children,I=g>Q.length-1?P:Z;return s.jsx(L6,{value:{getStyles:V,orientation:D,iconPosition:E},children:s.jsxs(ce,{...V("root"),ref:t,size:T,...$,children:[s.jsx(ce,{...V("steps"),mod:{orientation:D,"icon-position":E,wrap:M&&D!=="vertical"},children:G}),I&&s.jsx("div",{...V("content"),children:I})]})})});mc.classes=O0;mc.displayName="@mantine/core/Stepper";mc.Completed=Nh;mc.Step=M0;const LD=y.createContext(null),V6=LD.Provider,F6=()=>y.useContext(LD),H6={},I0=ve((e,t)=>{const{value:n,defaultValue:r,onChange:a,size:o,wrapperProps:c,children:u,readOnly:f,...p}=se("SwitchGroup",H6,e),[m,g]=Yn({value:n,defaultValue:r,finalValue:[],onChange:a}),v=b=>{const S=b.currentTarget.value;!f&&g(m.includes(S)?m.filter(j=>j!==S):[...m,S])};return s.jsx(V6,{value:{value:m,onChange:v,size:o},children:s.jsx(mn.Wrapper,{size:o,ref:t,...c,...p,labelElement:"div",__staticSelector:"SwitchGroup",children:s.jsx(t0,{role:"group",children:u})})})});I0.classes=mn.Wrapper.classes;I0.displayName="@mantine/core/SwitchGroup";var zD={root:"m_5f93f3bb",input:"m_926b4011",track:"m_9307d992",thumb:"m_93039a1d",trackLabel:"m_8277e082"};const q6={labelPosition:"right"},G6=(e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:Vt(t),"--switch-height":rt(r,"switch-height"),"--switch-width":rt(r,"switch-width"),"--switch-thumb-size":rt(r,"switch-thumb-size"),"--switch-label-font-size":rt(r,"switch-label-font-size"),"--switch-track-label-padding":rt(r,"switch-track-label-padding"),"--switch-color":n?Ht(n,e):void 0}}),Sd=ve((e,t)=>{const n=se("Switch",q6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,color:p,label:m,offLabel:g,onLabel:v,id:b,size:S,radius:j,wrapperProps:C,thumbIcon:R,checked:D,defaultChecked:E,onChange:T,labelPosition:A,description:k,error:M,disabled:L,variant:$,rootRef:V,mod:Y,...Q}=n,J=F6(),G=S||(J==null?void 0:J.size),Z=Ie({name:"Switch",props:n,classes:zD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:G6}),{styleProps:P,rest:I}=Qi(Q),z=yr(b),H=J?{checked:J.value.includes(I.value),onChange:J.onChange}:{},[O,U]=Yn({value:H.checked??D,defaultValue:E,finalValue:!1});return s.jsxs(bp,{...Z("root"),__staticSelector:"Switch",__stylesApiProps:n,id:z,size:G,labelPosition:A,label:m,description:k,error:M,disabled:L,bodyElement:"label",labelElement:"span",classNames:r,styles:c,unstyled:u,"data-checked":H.checked||D||void 0,variant:$,ref:V,mod:Y,...P,...C,children:[s.jsx("input",{...I,disabled:L,checked:O,"data-checked":H.checked||D||void 0,onChange:K=>{var ee;J?(ee=H.onChange)==null||ee.call(H,K):T==null||T(K),U(K.currentTarget.checked)},id:z,ref:t,type:"checkbox",role:"switch",...Z("input")}),s.jsxs(ce,{"aria-hidden":"true",component:"span",mod:{error:M,"label-position":A,"without-labels":!v&&!g},...Z("track"),children:[s.jsx(ce,{component:"span",mod:"reduce-motion",...Z("thumb"),children:R}),s.jsx("span",{...Z("trackLabel"),children:O?v:g})]})]})});Sd.classes={...zD,...F2};Sd.displayName="@mantine/core/Switch";Sd.Group=I0;const[Q6,W6]=vr("Table component was not found in the tree");var wd={table:"m_b23fa0ef",th:"m_4e7aa4f3",tr:"m_4e7aa4fd",td:"m_4e7aa4ef",tbody:"m_b2404537",thead:"m_b242d975",caption:"m_9e5a3ac7",scrollContainer:"m_a100c15",scrollContainerInner:"m_62259741"};function Y6(e,t){if(!t)return;const n={};return t.columnBorder&&e.withColumnBorders&&(n["data-with-column-border"]=!0),t.rowBorder&&e.withRowBorders&&(n["data-with-row-border"]=!0),t.striped&&e.striped&&(n["data-striped"]=e.striped),t.highlightOnHover&&e.highlightOnHover&&(n["data-hover"]=!0),t.captionSide&&e.captionSide&&(n["data-side"]=e.captionSide),t.stickyHeader&&e.stickyHeader&&(n["data-sticky"]=!0),n}function Js(e,t){const n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=ve((a,o)=>{const c=se(n,{},a),{classNames:u,className:f,style:p,styles:m,...g}=c,v=W6();return s.jsx(ce,{component:e,ref:o,...Y6(v,t),...v.getStyles(e,{className:f,classNames:u,style:p,styles:m,props:c}),...g})});return r.displayName=`@mantine/core/${n}`,r.classes=wd,r}const Ay=Js("th",{columnBorder:!0}),$D=Js("td",{columnBorder:!0}),vh=Js("tr",{rowBorder:!0,striped:!0,highlightOnHover:!0}),UD=Js("thead",{stickyHeader:!0}),BD=Js("tbody"),VD=Js("tfoot"),FD=Js("caption",{captionSide:!0});function L0({data:e}){return s.jsxs(s.Fragment,{children:[e.caption&&s.jsx(FD,{children:e.caption}),e.head&&s.jsx(UD,{children:s.jsx(vh,{children:e.head.map((t,n)=>s.jsx(Ay,{children:t},n))})}),e.body&&s.jsx(BD,{children:e.body.map((t,n)=>s.jsx(vh,{children:t.map((r,a)=>s.jsx($D,{children:r},a))},n))}),e.foot&&s.jsx(VD,{children:s.jsx(vh,{children:e.foot.map((t,n)=>s.jsx(Ay,{children:t},n))})})]})}L0.displayName="@mantine/core/TableDataRenderer";const K6={type:"scrollarea"},X6=(e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":le(t),"--table-max-height":le(n),"--table-overflow":r==="native"?"auto":void 0}}),z0=ve((e,t)=>{const n=se("TableScrollContainer",K6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,children:p,minWidth:m,maxHeight:g,type:v,scrollAreaProps:b,...S}=n,j=Ie({name:"TableScrollContainer",classes:wd,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:X6,rootSelector:"scrollContainer"});return s.jsx(ce,{component:v==="scrollarea"?Yr:"div",...v==="scrollarea"?g?{offsetScrollbars:"xy",...b}:{offsetScrollbars:"x",...b}:{},ref:t,...j("scrollContainer"),...S,children:s.jsx("div",{...j("scrollContainerInner"),children:p})})});z0.classes=wd;z0.displayName="@mantine/core/TableScrollContainer";const Z6={withRowBorders:!0,verticalSpacing:7},J6=(e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:a,borderColor:o,stripedColor:c,highlightOnHoverColor:u,striped:f,highlightOnHover:p,stickyHeaderOffset:m,stickyHeader:g})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":Nn(r),"--table-vertical-spacing":Nn(a),"--table-border-color":o?Ht(o,e):void 0,"--table-striped-color":f&&c?Ht(c,e):void 0,"--table-highlight-on-hover-color":p&&u?Ht(u,e):void 0,"--table-sticky-header-offset":g?le(m):void 0}}),Me=ve((e,t)=>{const n=se("Table",Z6,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,horizontalSpacing:p,verticalSpacing:m,captionSide:g,stripedColor:v,highlightOnHoverColor:b,striped:S,highlightOnHover:j,withColumnBorders:C,withRowBorders:R,withTableBorder:D,borderColor:E,layout:T,variant:A,data:k,children:M,stickyHeader:L,stickyHeaderOffset:$,mod:V,tabularNums:Y,...Q}=n,J=Ie({name:"Table",props:n,className:a,style:o,classes:wd,classNames:r,styles:c,unstyled:u,rootSelector:"table",vars:f,varsResolver:J6});return s.jsx(Q6,{value:{getStyles:J,stickyHeader:L,striped:S===!0?"odd":S||void 0,highlightOnHover:j,withColumnBorders:C,withRowBorders:R,captionSide:g||"bottom"},children:s.jsx(ce,{component:"table",variant:A,ref:t,mod:[{"data-with-table-border":D,"data-tabular-nums":Y},V],...J("table"),...Q,children:M||!!k&&s.jsx(L0,{data:k})})})});Me.classes=wd;Me.displayName="@mantine/core/Table";Me.Td=$D;Me.Th=Ay;Me.Tr=vh;Me.Thead=UD;Me.Tbody=BD;Me.Tfoot=VD;Me.Caption=FD;Me.ScrollContainer=z0;Me.DataRenderer=L0;const[ez,$0]=vr("Tabs component was not found in the tree");var jd={root:"m_89d60db1","list--default":"m_576c9d4",list:"m_89d33d6d",panel:"m_b0c91715",tab:"m_4ec4dce6",tabSection:"m_fc420b1f","tab--default":"m_539e827b","list--outline":"m_6772fbd5","tab--outline":"m_b59ab47c","tab--pills":"m_c3381914"};const tz={},U0=ve((e,t)=>{const n=se("TabsList",tz,e),{children:r,className:a,grow:o,justify:c,classNames:u,styles:f,style:p,mod:m,...g}=n,v=$0();return s.jsx(ce,{...g,...v.getStyles("list",{className:a,style:p,classNames:u,styles:f,props:n,variant:v.variant}),ref:t,role:"tablist",variant:v.variant,mod:[{grow:o,orientation:v.orientation,placement:v.orientation==="vertical"&&v.placement,inverted:v.inverted},m],"aria-orientation":v.orientation,__vars:{"--tabs-justify":c},children:r})});U0.classes=jd;U0.displayName="@mantine/core/TabsList";const nz={},B0=ve((e,t)=>{const n=se("TabsPanel",nz,e),{children:r,className:a,value:o,classNames:c,styles:u,style:f,mod:p,keepMounted:m,...g}=n,v=$0(),b=v.value===o,S=v.keepMounted||m||b?r:null;return s.jsx(ce,{...g,...v.getStyles("panel",{className:a,classNames:c,styles:u,style:[f,b?void 0:{display:"none"}],props:n}),ref:t,mod:[{orientation:v.orientation},p],role:"tabpanel",id:v.getPanelId(o),"aria-labelledby":v.getTabId(o),children:S})});B0.classes=jd;B0.displayName="@mantine/core/TabsPanel";const rz={},V0=ve((e,t)=>{const n=se("TabsTab",rz,e),{className:r,children:a,rightSection:o,leftSection:c,value:u,onClick:f,onKeyDown:p,disabled:m,color:g,style:v,classNames:b,styles:S,vars:j,mod:C,tabIndex:R,...D}=n,E=Sn(),{dir:T}=Ks(),A=$0(),k=u===A.value,M=$=>{A.onChange(A.allowTabDeactivation&&u===A.value?null:u),f==null||f($)},L={classNames:b,styles:S,props:n};return s.jsxs(tr,{...D,...A.getStyles("tab",{className:r,style:v,variant:A.variant,...L}),disabled:m,unstyled:A.unstyled,variant:A.variant,mod:[{active:k,disabled:m,orientation:A.orientation,inverted:A.inverted,placement:A.orientation==="vertical"&&A.placement},C],ref:t,role:"tab",id:A.getTabId(u),"aria-selected":k,tabIndex:R!==void 0?R:k||A.value===null?0:-1,"aria-controls":A.getPanelId(u),onClick:M,__vars:{"--tabs-color":g?Ht(g,E):void 0},onKeyDown:iR({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:A.activateTabWithKeyboard,loop:A.loop,orientation:A.orientation||"horizontal",dir:T,onKeyDown:p}),children:[c&&s.jsx("span",{...A.getStyles("tabSection",L),"data-position":"left",children:c}),a&&s.jsx("span",{...A.getStyles("tabLabel",L),children:a}),o&&s.jsx("span",{...A.getStyles("tabSection",L),"data-position":"right",children:o})]})});V0.classes=jd;V0.displayName="@mantine/core/TabsTab";const GC="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",az={keepMounted:!0,orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,allowTabDeactivation:!1,unstyled:!1,inverted:!1,variant:"default",placement:"left"},iz=(e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":Vt(t),"--tabs-color":Ht(n,e),"--tabs-text-color":Ws(r,e)?Gi({color:n,theme:e,autoContrast:r}):void 0}}),Lt=ve((e,t)=>{const n=se("Tabs",az,e),{defaultValue:r,value:a,onChange:o,orientation:c,children:u,loop:f,id:p,activateTabWithKeyboard:m,allowTabDeactivation:g,variant:v,color:b,radius:S,inverted:j,placement:C,keepMounted:R,classNames:D,styles:E,unstyled:T,className:A,style:k,vars:M,autoContrast:L,mod:$,...V}=n,Y=yr(p),[Q,J]=Yn({value:a,defaultValue:r,finalValue:null,onChange:o}),G=Ie({name:"Tabs",props:n,classes:jd,className:A,style:k,classNames:D,styles:E,unstyled:T,vars:M,varsResolver:iz});return s.jsx(ez,{value:{placement:C,value:Q,orientation:c,id:Y,loop:f,activateTabWithKeyboard:m,getTabId:Vj(`${Y}-tab`,GC),getPanelId:Vj(`${Y}-panel`,GC),onChange:J,allowTabDeactivation:g,variant:v,color:b,radius:S,inverted:j,keepMounted:R,unstyled:T,getStyles:G},children:s.jsx(ce,{ref:t,id:Y,variant:v,mod:[{orientation:c,inverted:c==="horizontal"&&j,placement:c==="vertical"&&C},$],...G("root"),...V,children:u})})});Lt.classes=jd;Lt.displayName="@mantine/core/Tabs";Lt.Tab=V0;Lt.Panel=B0;Lt.List=U0;const oz={},ze=ve((e,t)=>{const n=se("TextInput",oz,e);return s.jsx(Pr,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});ze.classes=Pr.classes;ze.displayName="@mantine/core/TextInput";var HD={root:"m_7341320d"};const sz={},lz=(e,{size:t,radius:n,variant:r,gradient:a,color:o,autoContrast:c})=>{const u=e.variantColorResolver({color:o||e.primaryColor,theme:e,gradient:a,variant:r||"filled",autoContrast:c});return{root:{"--ti-size":rt(t,"ti-size"),"--ti-radius":n===void 0?void 0:Vt(n),"--ti-bg":o||r?u.background:void 0,"--ti-color":o||r?u.color:void 0,"--ti-bd":o||r?u.border:void 0}}},F0=ve((e,t)=>{const n=se("ThemeIcon",sz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,autoContrast:p,...m}=n,g=Ie({name:"ThemeIcon",classes:HD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:lz});return s.jsx(ce,{ref:t,...g("root"),...m})});F0.classes=HD;F0.displayName="@mantine/core/ThemeIcon";const cz=["h1","h2","h3","h4","h5","h6"],uz=["xs","sm","md","lg","xl"];function dz(e,t){const n=t!==void 0?t:`h${e}`;return cz.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:uz.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:le(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var qD={root:"m_8a5d1357"};const fz={order:1},hz=(e,{order:t,size:n,lineClamp:r,textWrap:a})=>{const o=dz(t,n);return{root:{"--title-fw":o.fontWeight,"--title-lh":o.lineHeight,"--title-fz":o.fontSize,"--title-line-clamp":typeof r=="number"?r.toString():void 0,"--title-text-wrap":a}}},Le=ve((e,t)=>{const n=se("Title",fz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,order:f,vars:p,size:m,variant:g,lineClamp:v,textWrap:b,mod:S,...j}=n,C=Ie({name:"Title",props:n,classes:qD,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:p,varsResolver:hz});return[1,2,3,4,5,6].includes(f)?s.jsx(ce,{...C("root"),component:`h${f}`,variant:g,ref:t,mod:[{order:f,"data-line-clamp":typeof v=="number"},S],size:m,...j}):null});Le.classes=qD;Le.displayName="@mantine/core/Title";function pz(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(a){t=typeof a=="function"?a(t):a},setState(a){this.updateState(a),r.forEach(o=>o(t))},initialize(a){n||(t=a,n=!0)},subscribe(a){return r.add(a),()=>r.delete(a)}}}function mz(e){return y.useSyncExternalStore(e.subscribe,()=>e.getState(),()=>e.getState())}function gz(e,t,n){const r=[],a=[],o={};for(const c of e){const u=c.position||t;o[u]=o[u]||0,o[u]+=1,o[u]<=n?a.push(c):r.push(c)}return{notifications:a,queue:r}}const vz=()=>pz({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),el=vz(),yz=(e=el)=>mz(e);function kc(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),a=gz(r,n.defaultPosition,n.limit);e.setState({notifications:a.notifications,queue:a.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Pe(e,t=el){const n=e.id||Th();return kc(t,r=>e.id&&r.some(a=>a.id===e.id)?r:[...r,{...e,id:n}]),n}function GD(e,t=el){return kc(t,n=>n.filter(r=>{var a;return r.id===e?((a=r.onClose)==null||a.call(r,r),!1):!0})),e}function Ds(e,t=el){return kc(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function xz(e=el){kc(e,()=>[])}function bz(e=el){kc(e,t=>t.slice(0,e.getState().limit))}const ua={show:Pe,hide:GD,update:Ds,clean:xz,cleanQueue:bz,updateState:kc};function _y(e,t){return _y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},_y(e,t)}function QD(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,_y(e,t)}var $v={exports:{}},Uv,QC;function Sz(){if(QC)return Uv;QC=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Uv=e,Uv}var Bv,WC;function wz(){if(WC)return Bv;WC=1;var e=Sz();function t(){}function n(){}return n.resetWarningCache=t,Bv=function(){function r(c,u,f,p,m,g){if(g!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}r.isRequired=r;function a(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:a,element:r,elementType:r,instanceOf:a,node:r,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:t};return o.PropTypes=o,o},Bv}var YC;function jz(){return YC||(YC=1,$v.exports=wz()()),$v.exports}var Cz=jz();const an=ax(Cz),KC={disabled:!1},Oh=Cn.createContext(null);var Ez=function(t){return t.scrollTop},Fu="unmounted",Ss="exited",ws="entering",Zl="entered",ky="exiting",Xi=function(e){QD(t,e);function t(r,a){var o;o=e.call(this,r,a)||this;var c=a,u=c&&!c.isMounting?r.enter:r.appear,f;return o.appearStatus=null,r.in?u?(f=Ss,o.appearStatus=ws):f=Zl:r.unmountOnExit||r.mountOnEnter?f=Fu:f=Ss,o.state={status:f},o.nextCallback=null,o}t.getDerivedStateFromProps=function(a,o){var c=a.in;return c&&o.status===Fu?{status:Ss}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(a){var o=null;if(a!==this.props){var c=this.state.status;this.props.in?c!==ws&&c!==Zl&&(o=ws):(c===ws||c===Zl)&&(o=ky)}this.updateStatus(!1,o)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var a=this.props.timeout,o,c,u;return o=c=u=a,a!=null&&typeof a!="number"&&(o=a.exit,c=a.enter,u=a.appear!==void 0?a.appear:c),{exit:o,enter:c,appear:u}},n.updateStatus=function(a,o){if(a===void 0&&(a=!1),o!==null)if(this.cancelNextCallback(),o===ws){if(this.props.unmountOnExit||this.props.mountOnEnter){var c=this.props.nodeRef?this.props.nodeRef.current:Vu.findDOMNode(this);c&&Ez(c)}this.performEnter(a)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Ss&&this.setState({status:Fu})},n.performEnter=function(a){var o=this,c=this.props.enter,u=this.context?this.context.isMounting:a,f=this.props.nodeRef?[u]:[Vu.findDOMNode(this),u],p=f[0],m=f[1],g=this.getTimeouts(),v=u?g.appear:g.enter;if(!a&&!c||KC.disabled){this.safeSetState({status:Zl},function(){o.props.onEntered(p)});return}this.props.onEnter(p,m),this.safeSetState({status:ws},function(){o.props.onEntering(p,m),o.onTransitionEnd(v,function(){o.safeSetState({status:Zl},function(){o.props.onEntered(p,m)})})})},n.performExit=function(){var a=this,o=this.props.exit,c=this.getTimeouts(),u=this.props.nodeRef?void 0:Vu.findDOMNode(this);if(!o||KC.disabled){this.safeSetState({status:Ss},function(){a.props.onExited(u)});return}this.props.onExit(u),this.safeSetState({status:ky},function(){a.props.onExiting(u),a.onTransitionEnd(c.exit,function(){a.safeSetState({status:Ss},function(){a.props.onExited(u)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(a,o){o=this.setNextCallback(o),this.setState(a,o)},n.setNextCallback=function(a){var o=this,c=!0;return this.nextCallback=function(u){c&&(c=!1,o.nextCallback=null,a(u))},this.nextCallback.cancel=function(){c=!1},this.nextCallback},n.onTransitionEnd=function(a,o){this.setNextCallback(o);var c=this.props.nodeRef?this.props.nodeRef.current:Vu.findDOMNode(this),u=a==null&&!this.props.addEndListener;if(!c||u){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var f=this.props.nodeRef?[this.nextCallback]:[c,this.nextCallback],p=f[0],m=f[1];this.props.addEndListener(p,m)}a!=null&&setTimeout(this.nextCallback,a)},n.render=function(){var a=this.state.status;if(a===Fu)return null;var o=this.props,c=o.children;o.in,o.mountOnEnter,o.unmountOnExit,o.appear,o.enter,o.exit,o.timeout,o.addEndListener,o.onEnter,o.onEntering,o.onEntered,o.onExit,o.onExiting,o.onExited,o.nodeRef;var u=f0(o,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return Cn.createElement(Oh.Provider,{value:null},typeof c=="function"?c(a,u):Cn.cloneElement(Cn.Children.only(c),u))},t}(Cn.Component);Xi.contextType=Oh;Xi.propTypes={};function ql(){}Xi.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:ql,onEntering:ql,onEntered:ql,onExit:ql,onExiting:ql,onExited:ql};Xi.UNMOUNTED=Fu;Xi.EXITED=Ss;Xi.ENTERING=ws;Xi.ENTERED=Zl;Xi.EXITING=ky;function Tz(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function H0(e,t){var n=function(o){return t&&y.isValidElement(o)?t(o):o},r=Object.create(null);return e&&y.Children.map(e,function(a){return a}).forEach(function(a){r[a.key]=n(a)}),r}function Rz(e,t){e=e||{},t=t||{};function n(m){return m in t?t[m]:e[m]}var r=Object.create(null),a=[];for(var o in e)o in t?a.length&&(r[o]=a,a=[]):a.push(o);var c,u={};for(var f in t){if(r[f])for(c=0;c<r[f].length;c++){var p=r[f][c];u[r[f][c]]=n(p)}u[f]=n(f)}for(c=0;c<a.length;c++)u[a[c]]=n(a[c]);return u}function As(e,t,n){return n[t]!=null?n[t]:e.props[t]}function Dz(e,t){return H0(e.children,function(n){return y.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:As(n,"appear",e),enter:As(n,"enter",e),exit:As(n,"exit",e)})})}function Az(e,t,n){var r=H0(e.children),a=Rz(t,r);return Object.keys(a).forEach(function(o){var c=a[o];if(y.isValidElement(c)){var u=o in t,f=o in r,p=t[o],m=y.isValidElement(p)&&!p.props.in;f&&(!u||m)?a[o]=y.cloneElement(c,{onExited:n.bind(null,c),in:!0,exit:As(c,"exit",e),enter:As(c,"enter",e)}):!f&&u&&!m?a[o]=y.cloneElement(c,{in:!1}):f&&u&&y.isValidElement(p)&&(a[o]=y.cloneElement(c,{onExited:n.bind(null,c),in:p.props.in,exit:As(c,"exit",e),enter:As(c,"enter",e)}))}}),a}var _z=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},kz={component:"div",childFactory:function(t){return t}},Oo=function(e){QD(t,e);function t(r,a){var o;o=e.call(this,r,a)||this;var c=o.handleExited.bind(Tz(o));return o.state={contextValue:{isMounting:!0},handleExited:c,firstRender:!0},o}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(a,o){var c=o.children,u=o.handleExited,f=o.firstRender;return{children:f?Dz(a,u):Az(a,c,u),firstRender:!1}},n.handleExited=function(a,o){var c=H0(this.props.children);a.key in c||(a.props.onExited&&a.props.onExited(o),this.mounted&&this.setState(function(u){var f=Ph({},u.children);return delete f[a.key],{children:f}}))},n.render=function(){var a=this.props,o=a.component,c=a.childFactory,u=f0(a,["component","childFactory"]),f=this.state.contextValue,p=_z(this.state.children).map(c);return delete u.appear,delete u.enter,delete u.exit,o===null?Cn.createElement(Oh.Provider,{value:f},p):Cn.createElement(Oh.Provider,{value:f},Cn.createElement(o,u,p))},t}(Cn.Component);Oo.propTypes={};Oo.defaultProps=kz;const WD=["bottom-center","bottom-left","bottom-right","top-center","top-left","top-right"];function Pz(e,t){return e.reduce((n,r)=>(n[r.position||t].push(r),n),WD.reduce((n,r)=>(n[r]=[],n),{}))}const XC={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},Nz={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function Oz({state:e,maxHeight:t,position:n,transitionDuration:r}){const[a,o]=n.split("-"),c=o==="center"?`${a}-center`:o,u={opacity:0,maxHeight:t,transform:XC[c],transitionDuration:`${r}ms, ${r}ms, ${r}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},f={opacity:1,transform:Nz[c]},p={opacity:0,maxHeight:0,transform:XC[c]};return{...u,...{entering:f,entered:f,exiting:p,exited:p}[e]}}function Mz(e,t){return typeof t=="number"?t:t===!1||e===!1?!1:e}const YD=y.forwardRef(({data:e,onHide:t,autoClose:n,...r},a)=>{const{autoClose:o,message:c,...u}=e,f=Mz(n,e.autoClose),p=y.useRef(-1),m=()=>window.clearTimeout(p.current),g=()=>{t(e.id),m()},v=()=>{typeof f=="number"&&(p.current=window.setTimeout(g,f))};return y.useEffect(()=>{var b;(b=e.onOpen)==null||b.call(e,e)},[]),y.useEffect(()=>(v(),m),[f]),s.jsx(E0,{...r,...u,onClose:g,ref:a,onMouseEnter:m,onMouseLeave:v,children:c})});YD.displayName="@mantine/notifications/NotificationContainer";var KD={root:"m_b37d9ac7",notification:"m_5ed0edd0"};const Iz=Xi,Lz={position:"bottom-right",autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:Wr("overlay"),store:el,withinPortal:!0},zz=(e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t==null?void 0:t.toString(),"--notifications-container-width":le(n)}}),Zi=ve((e,t)=>{const n=se("Notifications",Lz,e),{classNames:r,className:a,style:o,styles:c,unstyled:u,vars:f,position:p,autoClose:m,transitionDuration:g,containerWidth:v,notificationMaxHeight:b,limit:S,zIndex:j,store:C,portalProps:R,withinPortal:D,...E}=n,T=Sn(),A=yz(C),k=uN(),M=cx(),L=y.useRef({}),$=y.useRef(0),Y=(T.respectReducedMotion?M:!1)?1:g,Q=Ie({name:"Notifications",classes:KD,props:n,className:a,style:o,classNames:r,styles:c,unstyled:u,vars:f,varsResolver:zz});y.useEffect(()=>{C==null||C.updateState(Z=>({...Z,limit:S||5,defaultPosition:p}))},[S,p]),zi(()=>{A.notifications.length>$.current&&setTimeout(()=>k(),0),$.current=A.notifications.length},[A.notifications]);const J=Pz(A.notifications,p),G=WD.reduce((Z,P)=>(Z[P]=J[P].map(({style:I,...z})=>s.jsx(Iz,{timeout:Y,onEnter:()=>L.current[z.id].offsetHeight,nodeRef:{current:L.current[z.id]},children:H=>s.jsx(YD,{ref:O=>{L.current[z.id]=O},data:z,onHide:O=>GD(O,C),autoClose:m,...Q("notification",{style:{...Oz({state:H,position:P,transitionDuration:Y,maxHeight:b}),...I}})})},z.id)),Z),{});return s.jsxs(qo,{withinPortal:D,...R,children:[s.jsx(ce,{...Q("root"),"data-position":"top-center",ref:t,...E,children:s.jsx(Oo,{children:G["top-center"]})}),s.jsx(ce,{...Q("root"),"data-position":"top-left",...E,children:s.jsx(Oo,{children:G["top-left"]})}),s.jsx(ce,{...Q("root",{className:lc.classNames.fullWidth}),"data-position":"top-right",...E,children:s.jsx(Oo,{children:G["top-right"]})}),s.jsx(ce,{...Q("root",{className:lc.classNames.fullWidth}),"data-position":"bottom-right",...E,children:s.jsx(Oo,{children:G["bottom-right"]})}),s.jsx(ce,{...Q("root"),"data-position":"bottom-left",...E,children:s.jsx(Oo,{children:G["bottom-left"]})}),s.jsx(ce,{...Q("root"),"data-position":"bottom-center",...E,children:s.jsx(Oo,{children:G["bottom-center"]})})]})});Zi.classes=KD;Zi.displayName="@mantine/notifications/Notifications";Zi.show=ua.show;Zi.hide=ua.hide;Zi.update=ua.update;Zi.clean=ua.clean;Zi.cleanQueue=ua.cleanQueue;Zi.updateState=ua.updateState;class $z{constructor(t,n){this.operator=t,this.child=n}toString(){return`${this.operator}(${this.child.toString()})`}}class Cd{constructor(t,n,r){this.operator=t,this.left=n,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}}class Uz{constructor(){this.prefixParselets={},this.infixParselets={}}registerInfix(t,n){return this.infixParselets[t]=n,this}registerPrefix(t,n){return this.prefixParselets[t]=n,this}prefix(t,n,r){return this.registerPrefix(t,{parse(a,o){const c=a.consumeAndParse(n);return r(o,c)}})}infixLeft(t,n,r){return this.registerInfix(t,{parse(a,o,c){const u=a.consumeAndParse(n);return r(o,c,u)},precedence:n})}construct(t){return new Bz(t,this.prefixParselets,this.infixParselets)}}class Bz{constructor(t,n,r){this.tokens=t,this.prefixParselets=n,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){const n=this.peek();return(n==null?void 0:n.id)!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){const n=this.consume(),r=this.prefixParselets[n.id];if(!r)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let a=r.parse(this,n);for(;t>this.getPrecedence();){const o=this.consume();a=this.getInfixParselet(o).parse(this,a,o)}return a}getPrecedence(){const t=this.peek();if(!t)return 1/0;const n=this.getInfixParselet(t);return n?n.precedence:1/0}consume(t,n){var r,a;if(!this.tokens.length)throw Error("Cant consume unknown more tokens.");if(t&&((r=this.peek())==null?void 0:r.id)!==t){const o=this.peek();throw Error(`Expected ${t} but got "${o.id}" (${o.value}) at line ${o.line} column ${o.column}.`)}if(n&&((a=this.peek())==null?void 0:a.value)!==n){const o=this.peek();throw Error(`Expected "${n}" but got "${o.value}" at line ${o.line} column ${o.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}}class XD{constructor(t=10){this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){const n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,n)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}}const Ed="http://hl7.org",ZD="ok",Vz="created",Fz="gone",Hz="not-modified",qz="not-found",Gz="unauthorized",Qz="forbidden",Wz="accepted",Yz={resourceType:"OperationOutcome",id:ZD,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},Kz={resourceType:"OperationOutcome",id:qz,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},nd={resourceType:"OperationOutcome",id:Gz,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Xz={...nd,issue:[...nd.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},ZC={...nd,issue:[...nd.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]},JD={resourceType:"OperationOutcome",id:Qz,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]};function ri(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},...t?{expression:[t]}:void 0}]}}function yn(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"structure",details:{text:e}}]}}function Zz(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"exception",details:{text:"Internal server error"},diagnostics:e.toString()}]}}function Fp(e){return typeof e=="object"&&e!==null&&e.resourceType==="OperationOutcome"}function eA(e){return e.id===ZD||e.id===Vz||e.id===Hz||e.id===Wz}function Jz(e){return e.id===Fz}class dt extends Error{constructor(t,n){super(tA(t)),this.outcome=t,this.cause=n}}function Zt(e){return e instanceof dt?e.outcome:Fp(e)?e:ri(Xe(e))}function Xe(e){return e?typeof e=="string"?e:e instanceof Error?e.message:Fp(e)?tA(e):typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:JSON.stringify(e):"Unknown error"}function tA(e){var n;const t=((n=e.issue)==null?void 0:n.map(nA))??[];return t.length>0?t.join("; "):"Unknown error"}function nA(e){var n,r;let t;return(n=e.details)!=null&&n.text?e.diagnostics?t=`${e.details.text} (${e.diagnostics})`:t=e.details.text:e.diagnostics?t=e.diagnostics:t="Unknown error",(r=e.expression)!=null&&r.length&&(t+=` (${e.expression.join(", ")})`),t}function e8(e,t){const n=t.max&&t.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:t.max;return{path:e,description:"",type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function t8(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([a,o])=>[a,e8(a,o)])),constraints:[],innerTypes:[]};return t}const n8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},r8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},a8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},i8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},o8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},s8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},l8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},c8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},u8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},d8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},f8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},h8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},p8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},m8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},g8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},v8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},x8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},b8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},S8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},w8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},j8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},C8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},E8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},T8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},R8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min:1,type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},D8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},A8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},_8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},k8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},P8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},N8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},O8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},M8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},I8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]}}},L8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},$8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},U8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},B8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},V8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},F8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},H8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},G8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},Q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},W8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},Y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},K8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min:1,type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},X8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},Z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},J8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},e$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},t$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},n$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min:1,type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},r$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},a$={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},i$={elements:{authorizeUrl:{min:1,type:[{code:"string"}]},tokenUrl:{min:1,type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{min:1,type:[{code:"string"}]},clientId:{min:1,type:[{code:"string"}]},clientSecret:{min:1,type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]}}},o$={Element:n8,BackboneElement:r8,Address:a8,Age:i8,Annotation:o8,Attachment:s8,CodeableConcept:l8,Coding:c8,ContactDetail:u8,ContactPoint:d8,Contributor:f8,Count:h8,DataRequirement:p8,DataRequirementCodeFilter:m8,DataRequirementDateFilter:g8,DataRequirementSort:v8,Distance:y8,Dosage:x8,DosageDoseAndRate:b8,Duration:S8,ElementDefinition:w8,ElementDefinitionSlicingDiscriminator:j8,ElementDefinitionSlicing:C8,ElementDefinitionBase:E8,ElementDefinitionType:T8,ElementDefinitionExample:R8,ElementDefinitionConstraint:D8,ElementDefinitionBinding:A8,ElementDefinitionMapping:_8,Expression:k8,Extension:P8,HumanName:N8,Identifier:O8,MarketingStatus:M8,Meta:I8,Money:L8,Narrative:z8,ParameterDefinition:$8,Period:U8,Population:B8,ProdCharacteristic:V8,ProductShelfLife:F8,Quantity:H8,Range:q8,Ratio:G8,Reference:Q8,RelatedArtifact:W8,SampledData:Y8,Signature:K8,SubstanceAmount:X8,SubstanceAmountReferenceRange:Z8,Timing:J8,TimingRepeat:e$,TriggerDefinition:t$,UsageContext:n$,MoneyQuantity:r$,SimpleQuantity:a$,IdentityProvider:i$};function s$(e){return new c$(e).parse()}const Mh=t8(o$),q0=Object.create(null),JC=Object.create(null),l$={"http://hl7.org/fhir/StructureDefinition/MoneyQuantity":"MoneyQuantity","http://hl7.org/fhir/StructureDefinition/SimpleQuantity":"SimpleQuantity","http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition":"ViewDefinition"};function rA(e){let t;return t=JC[e],t||(t=JC[e]=Object.create(null)),t}function eE(e){var r;const n=(Array.isArray(e)?e:((r=e.entry)==null?void 0:r.map(a=>a.resource))??[]).filter(a=>(a==null?void 0:a.resourceType)==="StructureDefinition");eU(n);for(const a of n)aA(a)}function aA(e){var o,c;if(!(e!=null&&e.name))throw new Error("Failed loading StructureDefinition from bundle");if(e.resourceType!=="StructureDefinition")return;const t=s$(e),n=l$[e.url];let r,a;n?(r=Mh,a=n):e.url===`http://hl7.org/fhir/StructureDefinition/${e.type}`||e.url===`https://medplum.com/fhir/StructureDefinition/${e.type}`||(o=e.type)!=null&&o.startsWith("http://")||(c=e.type)!=null&&c.startsWith("https://")?(r=Mh,a=e.type):(r=rA(e.url),a=e.type),r[a]=t;for(const u of t.innerTypes)u.parentType=t,r[u.name]=u;q0[e.url]=t}function iA(e){return!!Mh[e]}function Hp(e,t){if(t){const n=rA(t)[e];if(n)return n}return Mh[e]}function oA(e,t){const n=Hp(e,t);if(!n)throw new dt(ri("Unknown data type: "+e));return n}function G0(e){return!!q0[e]}function Pc(e){return q0[e]}class c${constructor(t){var n;if(!((n=t.snapshot)!=null&&n.element)||t.snapshot.element.length===0)throw new Error(`No snapshot defined for StructureDefinition '${t.name}'`);this.root=t.snapshot.element[0],this.elements=t.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:t.name,path:this.root.path,title:t.title,type:t.type,url:t.url,version:t.version,kind:t.kind,description:f$(t),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){var n,r,a,o,c;let t=this.next();for(;t;){if(t.sliceName)this.parseSliceStart(t);else if((n=t.id)!=null&&n.includes(":")){if((r=this.slicingContext)!=null&&r.current){const u=Vv(t,this.slicingContext.path);this.slicingContext.current.elements[u]=this.parseElementDefinition(t)}}else{const u=this.parseElementDefinition(t);this.checkFieldEnter(t,u);let f=this.backboneContext;for(;f;){if((a=t.path)!=null&&a.startsWith(f.path+".")){f.type.elements[Vv(t,f.path)]=u;break}f=f.parent}if(!f){const p=Vv(t,this.root.path);t.isSummary&&((o=this.resourceSchema.summaryProperties)==null||o.add(p.replace("[x]",""))),u.min>0&&((c=this.resourceSchema.mandatoryProperties)==null||c.add(p.replace("[x]",""))),this.resourceSchema.elements[p]=u}this.checkFieldExit(t)}t=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(t,n){this.isInnerType(t)&&this.enterInnerType(t),this.slicingContext&&!Gl(this.slicingContext.path,t==null?void 0:t.path)&&(this.slicingContext=void 0),t.slicing&&!this.slicingContext&&this.enterSlice(t,n)}enterInnerType(t){var r,a,o;for(;this.backboneContext&&!Gl((r=this.backboneContext)==null?void 0:r.path,t.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;const n=cE(t);this.backboneContext={type:{name:n,type:n,path:t.path,title:t.label,description:t.definition,elements:{},constraints:this.parseElementDefinition(t).constraints,innerTypes:[]},path:t.path,parent:Gl((a=this.backboneContext)==null?void 0:a.path,t.path)?this.backboneContext:(o=this.backboneContext)==null?void 0:o.parent}}enterSlice(t,n){var r,a,o,c;d$(t)&&!((r=this.peek())!=null&&r.sliceName)||(n.slicing={discriminator:(((a=t.slicing)==null?void 0:a.discriminator)??[]).map(u=>{if(u.type!=="value"&&u.type!=="pattern"&&u.type!=="type")throw new Error(`Unsupported slicing discriminator type: ${u.type}`);return{path:u.path,type:u.type}}),slices:[],ordered:((o=t.slicing)==null?void 0:o.ordered)??!1,rule:(c=t.slicing)==null?void 0:c.rules},this.slicingContext={field:n.slicing,path:t.path??""})}checkFieldExit(t=void 0){if(this.backboneContext&&!Gl(this.backboneContext.path,t==null?void 0:t.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!Gl(this.backboneContext.path,t==null?void 0:t.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){const t=this.peek();if(t)return this.index++,t}peek(){var n,r,a,o,c;const t=this.elements[this.index];if(t){if(this.elementIndex[t.path??""]=t,t.contentReference){const u=t.contentReference.slice(t.contentReference.indexOf("#")+1),f=this.elementIndex[u];return f?{...f,id:t.id,path:t.path,min:t.min??f.min,max:t.max??f.max,base:{path:((n=f.base)==null?void 0:n.path)??u,min:((r=t.base)==null?void 0:r.min)??((a=f.base)==null?void 0:a.min)??f.min,max:((o=t.base)==null?void 0:o.max)??((c=f.base)==null?void 0:c.max)??f.max},contentReference:t.contentReference,definition:t.definition}:void 0}return t}}isInnerType(t){var r;const n=this.peek();return!!(Gl(t==null?void 0:t.path,n==null?void 0:n.path)&&((r=t.type)!=null&&r.some(a=>["BackboneElement","Element"].includes(a.code))))}parseSliceStart(t){if(!this.slicingContext)throw new Error(`Invalid slice start before discriminator: ${t.sliceName} (${t.id})`);this.slicingContext.current={...this.parseElementDefinition(t),name:t.sliceName??"",definition:t.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(t){return(t.type??[]).map(n=>{var a;let r;return(n.code==="BackboneElement"||n.code==="Element")&&(r=cE(t)),r||(r=(a=Ji(n,"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"))==null?void 0:a.valueUrl),r||(r=n.code??""),{code:r,targetProfile:n.targetProfile,profile:n.profile}})}parseElementDefinition(t){var o,c;const n=tE(t.max),r=(o=t.base)!=null&&o.max?tE(t.base.max):n,a={type:"ElementDefinition",value:t};return{description:t.definition||"",path:t.path||((c=t.base)==null?void 0:c.path)||"",min:t.min??0,max:n,isArray:r>1,constraints:(t.constraint??[]).map(u=>({key:u.key??"",severity:u.severity??"error",expression:u.expression??"",description:u.human??""})),type:this.parseElementDefinitionType(t),fixed:nE(gc(a,"fixed[x]")),pattern:nE(gc(a,"pattern[x]")),binding:t.binding}}}function tE(e){return e==="*"?Number.POSITIVE_INFINITY:Number.parseInt(e,10)}function Vv(e,t=""){return u$(e.path,t)}function u$(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:""}function Gl(e,t){return!e||!t?!1:t.startsWith(e+".")||t===e}function nE(e){return Array.isArray(e)&&e.length>0?e[0]:Tn(e)?void 0:e}function d$(e){var n,r;const t=(n=e.slicing)==null?void 0:n.discriminator;return!!((r=e.type)!=null&&r.some(a=>a.code==="Extension")&&(t==null?void 0:t.length)===1&&t[0].type==="value"&&t[0].path==="url")}function f$(e){let t=e.description;return t!=null&&t.startsWith(`Base StructureDefinition for ${e.name} Type: `)&&(t=t.substring(`Base StructureDefinition for ${e.name} Type: `.length)),t}function h$(e,t,n){if(e===void 0)return[void 0];if(t==="$this")return[e];const r=n!=null&&n.withPath?p$:gc,[a,...o]=t.split(".");let c=[r(e,a,n)];for(const u of o){const f=[];for(const p of c)if(Array.isArray(p))for(const m of p)f.push(r(m,u,n));else(n!=null&&n.withPath&&p&&p.value!==void 0||!(n!=null&&n.withPath)&&p!==void 0)&&f.push(r(p,u,n));c=f}return c}function p$(e,t,n){const r=e.path;return m$(gc(e,t,n),r,t)}function m$(e,t,n){const r=t?t+".":"";return e===void 0?{type:"undefined",value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((a,o)=>({...a,path:`${r}${n}[${o}]`})):{...e,path:`${r}${n}`}}const sA={date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/};function g$(e,t,n,r){var c;if(Array.isArray(e))return!1;let a;t.path==="$this"?a=n:a=(r??n.elements)[t.path];const o=n.type;switch(t.type){case"value":case"pattern":if(!e||!a)return!1;if(a.pattern)return Y0(e,a.pattern);if(a.fixed)return si(e,a.fixed);if(((c=a.binding)==null?void 0:c.strength)==="required"&&a.binding.valueSet)return!0;break;case"type":return!e||!(o!=null&&o.length)?!1:o.some(u=>u.code===e.type)}return!1}function Qe(e){return[{type:oe.boolean,value:e}]}function pa(e){return e==null?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:oe.integer,value:e}:typeof e=="number"?{type:oe.decimal,value:e}:typeof e=="boolean"?{type:oe.boolean,value:e}:typeof e=="string"?{type:oe.string,value:e}:da(e)?{type:oe.Quantity,value:e}:fi(e)?{type:e.resourceType,value:e}:vA(e)?{type:oe.CodeableConcept,value:e}:gA(e)?{type:oe.Coding,value:e}:{type:oe.BackboneElement,value:e}}function ei(e){return e.length===0?!1:!!e[0].value}function Bi(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw new Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function gc(e,t,n){if(!e.value)return;const r=Wo(e.type,t,n==null?void 0:n.profileUrl);return r?lA(e,t,r):Td(e,t)}function lA(e,t,n){const r=e.value,a=n.type;if(!a||a.length===0)return;let o,c="undefined",u;const f=n.path.lastIndexOf("."),p=n.path.substring(f+1);for(const m of a){const g=p.replace("[x]",Hn(m.code));if(o=r[g],u=r["_"+g],o!==void 0||u!==void 0){c=m.code;break}}if(u)if(Array.isArray(o)){o=o.slice();for(let m=0;m<Math.max(o.length,u.length);m++)o[m]=oE(o[m],u[m])}else o=oE(o,u);if(!Tn(o))return(c==="Element"||c==="BackboneElement")&&(c=n.type[0].code),Array.isArray(o)?o.map(m=>rE(m,c)):rE(o,c)}function rE(e,t){return t==="Resource"&&fi(e)&&(t=e.resourceType),{type:t,value:e}}function Td(e,t){const n=e.value;if(!n||typeof n!="object")return;let r;if(t in n){const a=n[t];Array.isArray(a)?r=a.map(pa):r=pa(a)}else{const a=t.endsWith("[x]")?t.substring(0,t.length-3):t;for(const o of Object.values(oe)){const c=a+Hn(o);if(c in n){const u=n[c];Array.isArray(u)?r=u.map(f=>({type:o,value:f})):r={type:o,value:u};break}}}if(Array.isArray(r)){if(r.length===0||Tn(r[0]))return}else if(Tn(r))return;return r}function cA(e){const t=[];for(const n of e){let r=!1;for(const a of t)if(ei(qp(n,a))){r=!0;break}r||t.push(n)}return t}function v$(e){return Qe(!ei(e))}function y$(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?Qe(!1):Qe(e.every((n,r)=>ei(qp(n,t[r]))))}function x$(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?Qe(!0):Qe(e.some((n,r)=>!ei(qp(n,t[r]))))}function qp(e,t){var a,o;const n=(a=e.value)==null?void 0:a.valueOf(),r=(o=t.value)==null?void 0:o.valueOf();return typeof n=="number"&&typeof r=="number"?Qe(Math.abs(n-r)<1e-8):da(n)&&da(r)?Qe(hA(n,r)):Qe(typeof n=="object"&&typeof r=="object"?Q0(e,t):n===r)}function uA(e,t){return e.length===0&&t.length===0?Qe(!0):e.length!==t.length?Qe(!1):(e.sort(aE),t.sort(aE),Qe(e.every((n,r)=>ei(b$(n,t[r])))))}function b$(e,t){const{type:n,value:r}=e,{type:a,value:o}=t,c=r==null?void 0:r.valueOf(),u=o==null?void 0:o.valueOf();return typeof c=="number"&&typeof u=="number"?Qe(Math.abs(c-u)<.01):da(c)&&da(u)?Qe(hA(c,u)):Qe(n==="Coding"&&a==="Coding"?typeof c!="object"||typeof u!="object"?!1:c.code===u.code&&c.system===u.system:typeof c=="object"&&typeof u=="object"?Q0({...c,id:void 0},{...u,id:void 0}):typeof c=="string"&&typeof u=="string"?c.toLowerCase()===u.toLowerCase():c===u)}function aE(e,t){var a,o;const n=(a=e.value)==null?void 0:a.valueOf(),r=(o=t.value)==null?void 0:o.valueOf();return typeof n=="number"&&typeof r=="number"?n-r:typeof n=="string"&&typeof r=="string"?n.localeCompare(r):0}function dA(e,t){const{value:n}=e;if(n==null)return!1;let r=t;switch(r.startsWith("System.")&&(r=r.substring(7)),r.startsWith("FHIR.")&&(r=r.substring(5)),r){case"Boolean":return typeof n=="boolean";case"Decimal":case"Integer":return typeof n=="number";case"Date":return S$(n);case"DateTime":return Ih(n);case"Time":return typeof n=="string"&&!!/^T\d/.exec(n);case"Period":return fA(n);case"Quantity":return da(n);default:return e.type===r||typeof n=="object"&&(n==null?void 0:n.resourceType)===r}}function S$(e){return typeof e=="string"&&!!sA.date.exec(e)}function Ih(e){return typeof e=="string"&&!!sA.dateTime.exec(e)}function fA(e){return!!(e&&typeof e=="object"&&("start"in e&&Ih(e.start)||"end"in e&&Ih(e.end)))}function da(e){return!!(e&&typeof e=="object"&&"value"in e&&typeof e.value=="number")}function hA(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function Q0(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const a of n){const o=e[a],c=t[a];if(iE(o)&&iE(c)){if(!Q0(o,c))return!1}else if(o!==c)return!1}return!0}function iE(e){return e!==null&&typeof e=="object"}function oE(e,t){if(t){if(typeof t!="object")throw new Error("Primitive extension must be an object");return w$(e??{},t)}return e}function w$(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function j$(e,t){return fi(e,t)&&"id"in e&&typeof e.id=="string"}function on(e){const t=zt(e)??"undefined/undefined",n=Vi(e);return n===t?{reference:t}:{reference:t,display:n}}function zt(e){if(Yo(e))return e.reference;if(j$(e))return`${e.resourceType}/${e.id}`}function $s(e){if(e)return Yo(e)?e.reference.split("/")[1]:e.id}function C$(e){return e.resourceType==="Patient"||e.resourceType==="Practitioner"||e.resourceType==="RelatedPerson"}function Vi(e){if(C$(e)){const t=E$(e);if(t)return t}if(e.resourceType==="Device"){const t=T$(e);if(t)return t}if(e.resourceType==="MedicationRequest"&&e.medicationCodeableConcept)return Vo(e.medicationCodeableConcept);if(e.resourceType==="Subscription"&&e.criteria)return e.criteria;if(e.resourceType==="User"&&e.email)return e.email;if("name"in e&&e.name&&typeof e.name=="string")return e.name;if("code"in e&&e.code){let t=e.code;if(Array.isArray(t)&&(t=t[0]),vA(t))return Vo(t);if(I$(t))return t.text}return zt(e)??""}function E$(e){const t=e.name;if(t&&t.length>0)return Nc(t[0])}function T$(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name}function R$(e){if(!("photo"in e))return;const t=e.photo;if(t)if(Array.isArray(t))for(const n of t){const r=sE(n);if(r)return r}else return sE(t)}function sE(e){var t;if(e.url&&((t=e.contentType)!=null&&t.startsWith("image/")))return e.url}function pA(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);const a=n.getUTCFullYear(),o=n.getUTCMonth(),c=n.getUTCDate(),u=r.getUTCFullYear(),f=r.getUTCMonth(),p=r.getUTCDate();let m=u-a;(f<o||f===o&&p<c)&&m--;let g=u*12+f-(a*12+o);p<c&&g--;const v=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:m,months:g,days:v}}function D$(e,t){const{years:n,months:r,days:a}=pA(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":r>=1?r.toString().padStart(3,"0")+"M":a.toString().padStart(3,"0")+"D"}function Ji(e,...t){var r;let n=e;for(let a=0;a<t.length&&n;a++)n=(r=n==null?void 0:n.extension)==null?void 0:r.find(o=>o.url===t[a]);return n}function Ia(e,t){const n=W0(e);return JSON.stringify(n,null,t?2:void 0)??""}function W0(e){if(!(e==null||e===""))return typeof e=="object"?Array.isArray(e)?A$(e):_$(e):e}function A$(e){const t=e.length;if(t===0)return;let n,r=0;for(let a=0;a<t;a++){const o=e[a],c=W0(o);c!==o&&!n&&(n=Array.from(e)),c===void 0?n&&(n[a]=null):(n&&(n[a]=c),r++)}if(r!==0)return n??e}function _$(e){let t,n=0;for(const r in e){const a=e[r],o=W0(a);o!==a&&!t&&(t={...e}),o===void 0?t&&delete t[r]:(t&&(t[r]=o),n++)}if(n!==0)return t??e}function Tn(e){if(e==null)return!0;const t=typeof e;return t==="string"||t==="object"?!En(e):!1}function En(e){if(e==null)return!1;const t=typeof e;return t==="string"&&e!==""||t==="object"&&("length"in e&&e.length>0||Object.keys(e).length>0)}function si(e,t,n){return e===t||Tn(e)&&Tn(t)?!0:Tn(e)||Tn(t)?!1:Array.isArray(e)&&Array.isArray(t)?k$(e,t):Array.isArray(e)||Array.isArray(t)?!1:sr(e)&&sr(t)?P$(e,t,n):(sr(e)||sr(t),!1)}function k$(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!si(e[n],t[n]))return!1;return!0}function P$(e,t,n){const r=new Set;Object.keys(e).forEach(a=>r.add(a)),Object.keys(t).forEach(a=>r.add(a)),n==="meta"&&(r.delete("versionId"),r.delete("lastUpdated"),r.delete("author"));for(const a of r){const o=e[a],c=t[a];if(!si(o,c,a))return!1}return!0}function Y0(e,t){return Tn(e)?!0:Tn(t)?!1:Array.isArray(e)&&Array.isArray(t)?N$(e,t):Array.isArray(e)||Array.isArray(t)?!1:sr(e)&&sr(t)?O$(e,t):sr(e)||sr(t)?!1:e===t}function N$(e,t){return t.every(n=>e.some(r=>Y0(r,n)))}function O$(e,t){return Object.entries(t).every(([n,r])=>n in e&&Y0(e[n],r))}function Qr(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function mA(e){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(e)}function sr(e){return e!==null&&typeof e=="object"}function M$(e){return typeof e=="string"}function gA(e){return sr(e)&&"code"in e&&typeof e.code=="string"}function vA(e){return sr(e)&&"coding"in e&&Array.isArray(e.coding)&&e.coding.every(gA)}function I$(e){return sr(e)&&"text"in e&&typeof e.text=="string"}const yA=[];for(let e=0;e<256;e++)yA.push(e.toString(16).padStart(2,"0"));function L$(e){const t=xA(e),n=new Uint8Array(t),r=new Array(n.length);for(let a=0;a<n.length;a++)r[a]=yA[n[a]];return r.join("")}function z$(e){const t=xA(e),n=new Uint8Array(t),r=new Array(n.length);for(let a=0;a<n.length;a++)r[a]=String.fromCharCode(n[a]);return window.btoa(r.join(""))}function xA(e){return ArrayBuffer.isView(e)?e.buffer:e}function Hn(e){return e?e.charAt(0).toUpperCase()+e.substring(1):""}function K0(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function _s(e,t){const n=e+".";if(t.startsWith(n))return t.slice(n.length)}function $$(e,t){var n,r;return(r=(n=e.coding)==null?void 0:n.find(a=>a.system===t))==null?void 0:r.code}function U$(e){if(e!==void 0)return Array.isArray(e)?e:[e]}const lE=e=>new Promise(t=>{setTimeout(t,e)});function Py(e,t,n){const r=[];for(let a=0;a<n-1;a++){const o=e.indexOf(t);if(o<0)break;r.push(e.slice(0,o)),e=e.slice(o+t.length)}return r.push(e),r}function B$(e){let t,n=!1;return function(){return n||(t=e(),n=!0),t}}function Mu(e,t){return e?(e.push(t),e):[t]}function rd(e){return e.sort((t,n)=>t.localeCompare(n))}function X0(e){return e.endsWith("/")?e:e+"/"}function V$(e){return e.startsWith("/")?e.slice(1):e}function Xa(e,t){return new URL(V$(t),X0(e.toString())).toString()}function F$(e,t){return Xa(e,t).toString().replace("http://","ws://").replace("https://","wss://")}function H$(e){return typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))),new URLSearchParams(e).toString()}function bA(e,t){var n,r;return(r=(n=e==null?void 0:e.meta)==null?void 0:n.profile)!=null&&r.includes(t)||(e.meta=e.meta??{},e.meta.profile=e.meta.profile??[],e.meta.profile.push(t)),e}function q$(e,t){var n,r;if((r=(n=e==null?void 0:e.meta)==null?void 0:n.profile)!=null&&r.includes(t)){const a=e.meta.profile.indexOf(t);e.meta.profile.splice(a,1)}return e}function vc(e){if(!e)return"";switch(e.type){case"Address":return SA(e.value);case"CodeableConcept":return Vo(e.value);case"Coding":return Rd(e.value);case"ContactPoint":return e.value.value;case"HumanName":return Nc(e.value);case"Quantity":return ks(e.value);case"Reference":return G$(e.value);default:return e.value.toString()}}function G$(e){return e?e.display??e.reference??Ia(e):""}function SA(e,t){if(!e)return"";const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const r=[];e.city&&r.push(e.city),e.state&&r.push(e.state),e.postalCode&&r.push(e.postalCode),n.push(r.join(", "))}return e.use&&(t!=null&&t.use)&&n.push("["+e.use+"]"),n.join(", ").trim()}function Nc(e,t){if(!e)return"";const n=[];if(e.prefix&&(t==null?void 0:t.prefix)!==!1&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&(t==null?void 0:t.suffix)!==!1&&n.push(...e.suffix),e.use&&(t!=null&&t.all||t!=null&&t.use)&&n.push("["+e.use+"]"),n.length===0){const r=id(e.text);if(r)return r}return n.join(" ").trim()}function Gp(e){return e instanceof Date&&!isNaN(e.getTime())}function Q$(e,t,n){if(!e)return"";const r=new Date("2000-01-01T"+e+"Z");return Gp(r)?r.toLocaleTimeString(t,n):""}function gr(e,t,n){if(!e)return"";const r=new Date(e);return Gp(r)?r.toLocaleString(t,n):""}function W$(e,t,n){return!e||!e.start&&!e.end?"":gr(e.start,t,n)+" - "+gr(e.end,t,n)}const Y$={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},K$={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},X$={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function wA(e){if(!e)return"";const t=[];return Z$(t,e.repeat),e.event&&t.push(e.event.map(n=>gr(n)).join(", ")),Hn(t.join(" ").trim())}function Z$(e,t){if(!(t!=null&&t.periodUnit))return;const n=t.frequency??1,r=t.period??1,a=t.periodUnit;n===1&&r===1?e.push(Y$[a]):(n===1?e.push("once"):e.push(n+" times"),r===1?e.push("per "+K$[a]):e.push("per "+r+" "+X$[a])),t.dayOfWeek&&e.push("on "+t.dayOfWeek.map(Hn).join(", ")),t.timeOfDay&&e.push("at "+t.timeOfDay.map(o=>Q$(o)).join(", "))}function ad(e,t,n=!1){if(n&&t===void 0)throw new Error("Precision must be specified for exclusive ranges");const r=(e==null?void 0:e.low)&&{...e.low,comparator:void 0},a=(e==null?void 0:e.high)&&{...e.high,comparator:void 0};return(r==null?void 0:r.value)===void 0&&(a==null?void 0:a.value)===void 0?"":(r==null?void 0:r.value)!==void 0&&(a==null?void 0:a.value)===void 0?`>= ${ks(r)}`:(r==null?void 0:r.value)===void 0&&(a==null?void 0:a.value)!==void 0?`<= ${ks(a)}`:((r==null?void 0:r.unit)===(a==null?void 0:a.unit)&&(r==null||delete r.unit),`${ks(r)} - ${ks(a)}`)}function ks(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),e.value!==void 0&&n.push(e.value),e.unit&&(e.unit!=="%"&&n[n.length-1]!==" "&&n.push(" "),n.push(e.unit)),n.join("").trim()}function J$(e){return(e==null?void 0:e.value)===void 0?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency??"USD",currencyDisplay:"narrowSymbol"})}function Vo(e){if(!e)return"";const t=id(e.text);return t||(e.coding?e.coding.map(n=>Rd(n)).join(", "):"")}function Rd(e,t){const n=id(e==null?void 0:e.display);return n?`${n}`:id(e==null?void 0:e.code)??""}function jA(e){if(!e)return"";const t=[];if(e.valueQuantity)t.push(ks(e.valueQuantity));else if(e.valueCodeableConcept)t.push(Vo(e.valueCodeableConcept));else{const n=id(e.valueString);n&&t.push(n)}return"component"in e&&t.push(e.component.map(n=>jA(n)).join(" / ")),t.join(" / ").trim()}function id(e){return typeof e=="string"?e:void 0}const oe={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid"};function eU(e){var n;const t=Array.isArray(e)?e:((n=e.entry)==null?void 0:n.map(r=>r.resource))??[];for(const r of t)(r==null?void 0:r.resourceType)==="StructureDefinition"&&r.kind==="resource"&&CA(r.type)}function CA(e){let t=li.types[e];return t||(t={searchParamsDetails:{}},li.types[e]=t),t.searchParams||(t.searchParams={_id:{base:[e],code:"_id",type:"token",expression:e+".id"},_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"},_compartment:{base:[e],code:"_compartment",type:"reference",expression:e+".meta.compartment"},_profile:{base:[e],code:"_profile",type:"uri",expression:e+".meta.profile"},_security:{base:[e],code:"_security",type:"token",expression:e+".meta.security"},_source:{base:[e],code:"_source",type:"uri",expression:e+".meta.source"},_tag:{base:[e],code:"_tag",type:"token",expression:e+".meta.tag"}}),t}function tU(e){for(const t of e.base??[]){const n=CA(t);n.searchParams||(n.searchParams={}),n.searchParams[e.code]=e}}function cE(e){var n,r,a,o;const t=(r=(n=e.type)==null?void 0:n[0])==null?void 0:r.code;return t==="BackboneElement"||t==="Element"?nU((o=((a=e.base)==null?void 0:a.path)??e.path)==null?void 0:o.split(".")):t}function nU(e){return e.length===1?e[0]:e.map(Hn).join("")}function Z0(e){var t;return(t=li.types[e])==null?void 0:t.searchParams}function rU(e,t){var n,r;return(r=(n=li.types[e])==null?void 0:n.searchParams)==null?void 0:r[t]}function Us(e){const t=e.replaceAll("[x]","").split(".").pop();return EA(t)}function EA(e){let t;return e.length<100?t=e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:t=e.split(/(?=[A-Z])/),t.map(iU).join(" ").replace("_"," ").replace(/\s+/g," ")}const aU=new Set(["ID","IP","PKCE","JWKS","URI","URL","OMB","UDI"]);function iU(e){const t=e.toUpperCase();return e===t?e:aU.has(t)?t:t.charAt(0)+e.slice(1)}function Wo(e,t,n){const r=Hp(e,n);if(r)return oU(r.elements,t)}function oU(e,t){const n=e[t]??e[t+"[x]"];if(n)return n;for(let r=0;r<t.length;r++){const a=t[r];if(a>="A"&&a<="Z"){const o=t.slice(0,r)+"[x]",c=e[o];if(c)return c}}}function fi(e,t){return!(!e||typeof e!="object"||!("resourceType"in e)||t&&e.resourceType!==t)}function Yo(e){return!!(e&&typeof e=="object"&&"reference"in e&&typeof e.reference=="string")}const li={types:{}};function yh(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch{return e}}const Pi=()=>[],Tr={empty:(e,t)=>Qe(t.length===0||t.every(n=>Tn(n.value))),hasValue:(e,t)=>Qe(t.length!==0),exists:(e,t,n)=>Qe(n?t.filter(r=>ei(n.eval(e,[r]))).length>0:t.length>0&&t.every(r=>!Tn(r.value))),all:(e,t,n)=>Qe(t.every(r=>ei(n.eval(e,[r])))),allTrue:(e,t)=>{for(const n of t)if(!n.value)return Qe(!1);return Qe(!0)},anyTrue:(e,t)=>{for(const n of t)if(n.value)return Qe(!0);return Qe(!1)},allFalse:(e,t)=>{for(const n of t)if(n.value)return Qe(!1);return Qe(!0)},anyFalse:(e,t)=>{for(const n of t)if(!n.value)return Qe(!0);return Qe(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return Qe(!0);const r=n.eval(e,ys(e));return r.length===0?Qe(!1):Qe(t.every(a=>r.some(o=>o.value===a.value)))},supersetOf:(e,t,n)=>{const r=n.eval(e,ys(e));return r.length===0?Qe(!0):t.length===0?Qe(!1):Qe(r.every(a=>t.some(o=>o.value===a.value)))},count:(e,t)=>[{type:oe.integer,value:t.length}],distinct:(e,t)=>{const n=[];for(const r of t)n.some(a=>a.value===r.value)||n.push(r);return n},isDistinct:(e,t)=>Qe(t.length===Tr.distinct(e,t).length),where:(e,t,n)=>t.filter(r=>ei(n.eval(e,[r]))),select:(e,t,n)=>t.map(r=>n.eval({parent:e,variables:{$this:r}},[r])).flat(),repeat:Pi,ofType:(e,t,n)=>t.filter(r=>r.type===n.name),single:(e,t)=>{if(t.length>1)throw new Error("Expected input length one for single()");return t.length===0?[]:t.slice(0,1)},first:(e,t)=>t.length===0?[]:t.slice(0,1),last:(e,t)=>t.length===0?[]:t.slice(t.length-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{var a;const r=(a=n.eval(e,t)[0])==null?void 0:a.value;if(typeof r!="number")throw new Error("Expected a number for skip(num)");return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{var a;const r=(a=n.eval(e,t)[0])==null?void 0:a.value;if(typeof r!="number")throw new Error("Expected a number for take(num)");return r>=t.length?t:r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e)),a=[];for(const o of t)!a.some(c=>c.value===o.value)&&r.some(c=>c.value===o.value)&&a.push(o);return a},exclude:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e)),a=[];for(const o of t)r.some(c=>c.value===o.value)||a.push(o);return a},union:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e));return cA([...t,...r])},combine:(e,t,n)=>{if(!n)return t;const r=n.eval(e,ys(e));return[...t,...r]},htmlChecks:(e,t,n)=>[pa(!0)],iif:(e,t,n,r,a)=>{const o=n.eval(e,t);if(o.length>1||o.length===1&&typeof o[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return ei(o)?r.eval(e,t):a?a.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);if(typeof n=="boolean")return[{type:oe.boolean,value:n}];if(typeof n=="number"&&(n===0||n===1))return Qe(!!n);if(typeof n=="string"){const r=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(r))return Qe(!0);if(["false","f","no","n","0","0.0"].includes(r))return Qe(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:Qe(Tr.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="number"?[{type:oe.integer,value:n}]:typeof n=="string"&&/^[+-]?\d+$/.exec(n)?[{type:oe.integer,value:parseInt(n,10)}]:typeof n=="boolean"?[{type:oe.integer,value:n?1:0}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:Qe(Tr.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:oe.date,value:yh(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:Qe(Tr.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:oe.dateTime,value:yh(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:Qe(Tr.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return typeof n=="number"?[{type:oe.decimal,value:n}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:oe.decimal,value:parseFloat(n)}]:typeof n=="boolean"?[{type:oe.decimal,value:n?1:0}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:Qe(Tr.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return da(n)?[{type:oe.Quantity,value:n}]:typeof n=="number"?[{type:oe.Quantity,value:{value:n,unit:"1"}}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:oe.Quantity,value:{value:parseFloat(n),unit:"1"}}]:typeof n=="boolean"?[{type:oe.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:Qe(Tr.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);return n==null?[]:da(n)?[{type:oe.string,value:`${n.value} '${n.unit}'`}]:[{type:oe.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:Qe(Tr.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Za(t,1);if(typeof n=="string"){const r=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(r)return[{type:oe.time,value:yh("T"+r[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:Qe(Tr.toTime(e,t).length===1),indexOf:(e,t,n)=>sa((r,a)=>r.indexOf(a),e,t,n),substring:(e,t,n,r)=>sa((a,o,c)=>{const u=o,f=c?u+c:a.length;return u<0||u>=a.length?void 0:a.substring(u,f)},e,t,n,r),startsWith:(e,t,n)=>sa((r,a)=>r.startsWith(a),e,t,n),endsWith:(e,t,n)=>sa((r,a)=>r.endsWith(a),e,t,n),contains:(e,t,n)=>sa((r,a)=>r.includes(a),e,t,n),upper:(e,t)=>sa(n=>n.toUpperCase(),e,t),lower:(e,t)=>sa(n=>n.toLowerCase(),e,t),replace:(e,t,n,r)=>sa((a,o,c)=>a.replaceAll(o,c),e,t,n,r),matches:(e,t,n)=>sa((r,a)=>!!new RegExp(a).exec(r),e,t,n),replaceMatches:(e,t,n,r)=>sa((a,o,c)=>a.replaceAll(new RegExp(o,"g"),c),e,t,n,r),length:(e,t)=>sa(n=>n.length,e,t),toChars:(e,t)=>sa(n=>n?n.split(""):void 0,e,t),encode:Pi,decode:Pi,escape:Pi,unescape:Pi,trim:Pi,split:Pi,join:(e,t,n)=>{var a;const r=((a=n==null?void 0:n.eval(e,ys(e))[0])==null?void 0:a.value)??"";if(typeof r!="string")throw new Error("Separator must be a string.");return[{type:oe.string,value:t.map(o=>{var c;return((c=o.value)==null?void 0:c.toString())??""}).join(r)}]},abs:(e,t)=>Ya(Math.abs,e,t),ceiling:(e,t)=>Ya(Math.ceil,e,t),exp:(e,t)=>Ya(Math.exp,e,t),floor:(e,t)=>Ya(Math.floor,e,t),ln:(e,t)=>Ya(Math.log,e,t),log:(e,t,n)=>Ya((r,a)=>Math.log(r)/Math.log(a),e,t,n),power:(e,t,n)=>Ya(Math.pow,e,t,n),round:(e,t)=>Ya(Math.round,e,t),sqrt:(e,t)=>Ya(Math.sqrt,e,t),truncate:(e,t)=>Ya(n=>n|0,e,t),children:Pi,descendants:Pi,trace:(e,t,n)=>t,now:()=>[{type:oe.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:oe.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:oe.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,a)=>{var p;const o=Tr.toDateTime(e,n.eval(e,t));if(o.length===0)throw new Error("Invalid start date");const c=Tr.toDateTime(e,r.eval(e,t));if(c.length===0)throw new Error("Invalid end date");const u=(p=a.eval(e,t)[0])==null?void 0:p.value;if(u!=="years"&&u!=="months"&&u!=="days")throw new Error("Invalid units");const f=pA(o[0].value,c[0].value);return[{type:oe.Quantity,value:{value:f[u],unit:u}}]},is:(e,t,n)=>{let r="";return n instanceof Lh?r=n.name:n instanceof J0&&(r=n.left.name+"."+n.right.name),r?t.map(a=>({type:oe.boolean,value:dA(a,r)})):[]},not:(e,t)=>Tr.toBoolean(e,t).map(n=>({type:oe.boolean,value:!n.value})),resolve:(e,t)=>t.map(n=>{const r=n.value;let a;if(typeof r=="string")a=r;else if(typeof r=="object"){const o=r;if(o.resource)return pa(o.resource);o.reference?a=o.reference:o.type&&o.identifier&&(a=`${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`)}if(a!=null&&a.includes("?")){const[o]=a.split("?");return{type:o,value:{resourceType:o}}}if(a!=null&&a.includes("/")){const[o,c]=a.split("/");return{type:o,value:{resourceType:o,id:c}}}return{type:oe.BackboneElement,value:void 0}}).filter(n=>!!n.value),as:(e,t)=>t,type:(e,t)=>t.map(({value:n})=>typeof n=="boolean"?{type:oe.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof n=="number"?{type:oe.BackboneElement,value:{namespace:"System",name:"Integer"}}:fi(n)?{type:oe.BackboneElement,value:{namespace:"FHIR",name:n.resourceType}}:{type:oe.BackboneElement,value:null}),conformsTo:(e,t,n)=>{const r=n.eval(e,t)[0].value;if(!r.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const a=r.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map(o=>{var c;return{type:oe.boolean,value:((c=o.value)==null?void 0:c.resourceType)===a}})},getResourceKey:(e,t)=>{const n=t[0].value;return n!=null&&n.id?[{type:oe.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{const r=t[0].value;if(!(r!=null&&r.reference))return[];let a="";return n instanceof Lh&&(a=n.name),a&&!r.reference.startsWith(a+"/")?[]:[{type:oe.id,value:$s(r)}]},extension:(e,t,n)=>{var o;const r=n.eval(e,t)[0].value,a=(o=t==null?void 0:t[0])==null?void 0:o.value;if(a){const c=Ji(a,r);if(c)return[{type:oe.Extension,value:c}]}return[]}};function sa(e,t,n,...r){if(n.length===0)return[];const[{value:a}]=Za(n,1);if(typeof a!="string")throw new Error("String function cannot be called with non-string");const o=e(a,...r.map(c=>{var u;return(u=c==null?void 0:c.eval(t,n)[0])==null?void 0:u.value}));return o===void 0?[]:Array.isArray(o)?o.map(pa):[pa(o)]}function Ya(e,t,n,...r){if(n.length===0)return[];const[{value:a}]=Za(n,1),o=da(a),c=o?a.value:a;if(typeof c!="number")throw new Error("Math function cannot be called with non-number");const u=e(c,...r.map(m=>{var g;return(g=m.eval(t,n)[0])==null?void 0:g.value})),f=o?oe.Quantity:n[0].type,p=o?{...a,value:u}:u;return[{type:f,value:p}]}function Za(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const n of e)if(n==null)throw new Error("Expected non-null argument");return e}function ys(e){var n;let t=e;for(;(n=t.parent)!=null&&n.variables.$this;)t=t.parent;return[t.variables.$this]}class TA{constructor(t,n){this.original=t,this.child=n}eval(t,n){try{if(n.length>0){const r=[];for(const a of n)r.push(this.child.eval({parent:t,variables:{$this:a}},[a]));return r.flat()}else return this.child.eval(t,[])}catch(r){throw new Error(`FhirPathError on "${this.original}": ${r}`,{cause:r})}}toString(){return this.child.toString()}}class Ql{constructor(t){this.value=t}eval(){return[this.value]}toString(){const t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}}class Lh{constructor(t){this.name=t}eval(t,n){if(this.name==="$this")return n;const r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return n.flatMap(a=>this.evalValue(a)).filter(a=>(a==null?void 0:a.value)!==void 0)}getVariable(t){const n=t.variables[this.name];if(n!==void 0)return n;if(t.parent)return this.getVariable(t.parent)}evalValue(t){const n=t.value;if(!(!n||typeof n!="object"))return fi(n,this.name)?t:gc(t,this.name)}toString(){return this.name}}class sU{eval(){return[]}toString(){return"{}"}}class lU extends $z{constructor(t,n,r){super(t,n),this.impl=r}eval(t,n){return this.impl(this.child.eval(t,n))}toString(){return this.operator+this.child.toString()}}class zh extends Cd{constructor(t,n){super("as",t,n)}eval(t,n){return Tr.ofType(t,this.left.eval(t,n),this.right)}}class Nr extends Cd{}class Da extends Nr{constructor(t,n,r,a){super(t,n,r),this.impl=a}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const a=this.right.eval(t,n);if(a.length!==1)return[];const o=r[0].value,c=a[0].value,u=da(o)?o.value:o,f=da(c)?c.value:c,p=this.impl(u,f);return typeof p=="boolean"?Qe(p):da(o)?[{type:oe.Quantity,value:{...o,value:p}}]:[pa(p)]}}class cU extends Cd{constructor(t,n){super("&",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n),o=[...r,...a];return o.length>0&&o.every(c=>typeof c.value=="string")?[{type:oe.string,value:o.map(c=>c.value).join("")}]:o}}class uU extends Nr{constructor(t,n){super("contains",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return Qe(r.some(o=>o.value===a[0].value))}}class dU extends Nr{constructor(t,n){super("in",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n)),a=this.right.eval(t,n);return r?Qe(a.some(o=>qp(r,o)[0].value)):[]}}class J0 extends Cd{constructor(t,n){super(".",t,n)}eval(t,n){return this.right.eval(t,this.left.eval(t,n))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class eb extends Cd{constructor(t,n){super("|",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return cA([...r,...a])}}class fU extends Nr{constructor(t,n){super("=",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return y$(r,a)}}class hU extends Nr{constructor(t,n){super("!=",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return x$(r,a)}}class pU extends Nr{constructor(t,n){super("~",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return uA(r,a)}}class mU extends Nr{constructor(t,n){super("!~",t,n)}eval(t,n){const r=this.left.eval(t,n),a=this.right.eval(t,n);return v$(uA(r,a))}}class tb extends Nr{constructor(t,n){super("is",t,n)}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const a=this.right.name;return Qe(dA(r[0],a))}}class gU extends Nr{constructor(t,n){super("and",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!0&&(a==null?void 0:a.value)===!0?Qe(!0):(r==null?void 0:r.value)===!1||(a==null?void 0:a.value)===!1?Qe(!1):[]}}class vU extends Nr{constructor(t,n){super("or",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!1&&(a==null?void 0:a.value)===!1?Qe(!1):r!=null&&r.value||a!=null&&a.value?Qe(!0):[]}}class yU extends Nr{constructor(t,n){super("xor",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return!r||!a?[]:Qe(r.value!==a.value)}}class xU extends Nr{constructor(t,n){super("implies",t,n)}eval(t,n){const r=Bi(this.left.eval(t,n),"boolean"),a=Bi(this.right.eval(t,n),"boolean");return(a==null?void 0:a.value)===!0||(r==null?void 0:r.value)===!1?Qe(!0):!r||!a?[]:Qe(!1)}}class nb{constructor(t,n){this.name=t,this.args=n}eval(t,n){const r=Tr[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,n,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}}class rb{constructor(t,n){this.left=t,this.expr=n}eval(t,n){const r=this.expr.eval(t,n);if(r.length!==1)return[];const a=r[0].value;if(typeof a!="number")throw new Error("Invalid indexer expression: should return integer}");const o=this.left.eval(t,n);return a in o?[o[a]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const bU=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class SU{constructor(t,n,r,a){this.result=[],this.pos={index:0,line:1,column:0},this.markStack=[],this.str=t,this.keywords=n,this.operators=r,this.dateTimeLiterals=!!(a!=null&&a.dateTimeLiterals),this.symbolRegex=(a==null?void 0:a.symbolRegex)??/[$\w%]/}tokenize(){for(;this.pos.index<this.str.length;){const t=this.consumeToken();t&&this.result.push(t)}return this.result}prevToken(){return this.result.slice(-1)[0]}peekToken(){this.mark();const t=this.consumeToken();return this.reset(),t}consumeToken(){this.consumeWhitespace();const t=this.curr();if(!t)return;this.mark();const n=this.peek();return t==="/"&&n==="*"?this.consumeMultiLineComment():t==="/"&&n==="/"?this.consumeSingleLineComment():t==="'"||t==='"'||t==="`"?this.consumeString(t):t==="@"?this.consumeDateTime():/\d/.exec(t)?this.consumeNumber():/\w/.exec(t)?this.consumeSymbol():(t==="$"||t==="%")&&/\w/.exec(n)?this.consumeSymbol():(t==="$"||t==="%")&&(n==="'"||n==='"'||n==="`")?this.consumeQuotedSymbol(n):this.consumeOperator()}consumeWhitespace(){this.consumeWhile(()=>/\s/.exec(this.curr()))}consumeMultiLineComment(){const t=this.pos.index;return this.consumeWhile(()=>this.curr()!=="*"||this.peek()!=="/"),this.advance(),this.advance(),this.buildToken("Comment",this.str.substring(t,this.pos.index))}consumeSingleLineComment(){return this.buildToken("Comment",this.consumeWhile(()=>this.curr()!==`
77
77
  `))}consumeString(t){this.advance();const r=this.consumeWhile(()=>this.prev()==="\\"||this.curr()!==t).replace(/\\u([0-9a-fA-F]{4})/g,(o,c)=>String.fromCodePoint(parseInt(c,16))),a=this.buildToken(t==="`"?"Symbol":"String",r);return this.advance(),a}consumeQuotedSymbol(t){this.mark();const n=this.pos.index;this.advance(),this.consumeString(t);const r=this.str.substring(n,this.pos.index);return this.buildToken("Symbol",r)}consumeDateTime(){this.advance();const t=this.pos.index;this.consumeWhile(()=>/[\d-]/.exec(this.curr()));let n=!1,r=!1;if(this.curr()==="T"&&(n=!0,this.advance(),this.consumeWhile(()=>/[\d:]/.exec(this.curr())),this.curr()==="."&&/\d/.exec(this.peek())&&(this.advance(),this.consumeWhile(()=>/\d/.exec(this.curr()))),this.curr()==="Z"?(r=!0,this.advance()):(this.curr()==="+"||this.curr()==="-")&&(r=!0,this.advance(),this.consumeWhile(()=>/[\d:]/.exec(this.curr())))),this.pos.index===t)throw new Error("Invalid DateTime literal");let a=this.str.substring(t,this.pos.index);return a.endsWith("T")?a=a.substring(0,a.length-1):!a.startsWith("T")&&n&&!r&&(a+="Z"),this.buildToken("DateTime",a)}consumeNumber(){const t=this.pos.index;let n="Number";return this.consumeWhile(()=>/\d/.exec(this.curr())),this.curr()==="."&&/\d/.exec(this.peek())&&(this.advance(),this.consumeWhile(()=>/\d/.exec(this.curr()))),this.curr()==="-"&&this.dateTimeLiterals?(this.pos.index=t-1,this.consumeDateTime()):(this.curr()===" "&&wU(this.peekToken())&&(n="Quantity",this.consumeToken()),this.buildToken(n,this.str.substring(t,this.pos.index)))}consumeSymbol(){var n;const t=this.consumeWhile(()=>this.symbolRegex.exec(this.curr()));return((n=this.prevToken())==null?void 0:n.value)!=="."&&this.keywords.includes(t)?this.buildToken(t,t):this.buildToken("Symbol",t)}consumeOperator(){const t=this.curr(),n=this.peek(),r=t+n;return this.operators.includes(r)?(this.advance(),this.advance(),this.buildToken(r,r)):(this.advance(),this.buildToken(t,t))}consumeWhile(t){const n=this.pos.index;for(;this.pos.index<this.str.length&&t();)this.advance();return this.str.substring(n,this.pos.index)}curr(){return this.str[this.pos.index]}prev(){return this.str[this.pos.index-1]??""}peek(){return this.str[this.pos.index+1]??""}mark(){this.markStack.push({...this.pos})}reset(){const t=this.markStack.pop();if(!t)throw new Error("No mark to reset to");this.pos.index=t.index,this.pos.line=t.line,this.pos.column=t.column}advance(){this.pos.index++,this.curr()===`
78
78
  `?(this.pos.line++,this.pos.column=0):this.pos.column++}buildToken(t,n){const r=this.markStack.pop();if(!r)throw new Error("No mark for token");return{id:t,value:n,...r}}}function wU(e){return!!(e&&(e.id==="String"||e.id==="Symbol"&&bU.includes(e.value)))}const jU=["true","false"],CU=["!=","!~","<=",">=","{}","->"];function EU(e){return new SU(e,jU,CU).tokenize()}const Xt={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,Modulo:4,Add:5,Subtract:5,Ampersand:5,Is:6,As:6,Union:7,GreaterThan:8,GreaterThanOrEquals:8,LessThan:8,LessThanOrEquals:8,Equals:9,Equivalent:9,NotEquals:9,NotEquivalent:9,In:10,Contains:10,And:11,Xor:12,Or:12,Implies:13},TU={parse(e){var n;const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)` got `"+((n=e.peek())==null?void 0:n.value)+"`");return t}},RU={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new rb(t,n)},precedence:Xt.Indexer},DU={parse(e,t){if(!(t instanceof Lh))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new nb(t.name,n)},precedence:Xt.FunctionCall};function AU(e){const t=e.split(" "),n=parseFloat(t[0]);let r=t[1];return r!=null&&r.startsWith("'")&&r.endsWith("'")?r=r.substring(1,r.length-1):r="{"+r+"}",{value:n,unit:r}}function _U(){return new Uz().registerPrefix("String",{parse:(e,t)=>new Ql({type:oe.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new Ql({type:oe.dateTime,value:yh(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new Ql({type:oe.Quantity,value:AU(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new Ql({type:t.value.includes(".")?oe.decimal:oe.integer,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new Ql({type:oe.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Ql({type:oe.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Lh(t.value)}).registerPrefix("{}",{parse:()=>new sU}).registerPrefix("(",TU).registerInfix("[",RU).registerInfix("(",DU).prefix("+",Xt.UnaryAdd,(e,t)=>new lU("+",t,n=>n)).prefix("-",Xt.UnarySubtract,(e,t)=>new Da("-",t,t,(n,r)=>-r)).infixLeft(".",Xt.Dot,(e,t,n)=>new J0(e,n)).infixLeft("/",Xt.Divide,(e,t,n)=>new Da("/",e,n,(r,a)=>r/a)).infixLeft("*",Xt.Multiply,(e,t,n)=>new Da("*",e,n,(r,a)=>r*a)).infixLeft("+",Xt.Add,(e,t,n)=>new Da("+",e,n,(r,a)=>r+a)).infixLeft("-",Xt.Subtract,(e,t,n)=>new Da("-",e,n,(r,a)=>r-a)).infixLeft("|",Xt.Union,(e,t,n)=>new eb(e,n)).infixLeft("=",Xt.Equals,(e,t,n)=>new fU(e,n)).infixLeft("!=",Xt.NotEquals,(e,t,n)=>new hU(e,n)).infixLeft("~",Xt.Equivalent,(e,t,n)=>new pU(e,n)).infixLeft("!~",Xt.NotEquivalent,(e,t,n)=>new mU(e,n)).infixLeft("<",Xt.LessThan,(e,t,n)=>new Da("<",e,n,(r,a)=>r<a)).infixLeft("<=",Xt.LessThanOrEquals,(e,t,n)=>new Da("<=",e,n,(r,a)=>r<=a)).infixLeft(">",Xt.GreaterThan,(e,t,n)=>new Da(">",e,n,(r,a)=>r>a)).infixLeft(">=",Xt.GreaterThanOrEquals,(e,t,n)=>new Da(">=",e,n,(r,a)=>r>=a)).infixLeft("&",Xt.Ampersand,(e,t,n)=>new cU(e,n)).infixLeft("and",Xt.And,(e,t,n)=>new gU(e,n)).infixLeft("as",Xt.As,(e,t,n)=>new zh(e,n)).infixLeft("contains",Xt.Contains,(e,t,n)=>new uU(e,n)).infixLeft("div",Xt.Divide,(e,t,n)=>new Da("div",e,n,(r,a)=>r/a|0)).infixLeft("in",Xt.In,(e,t,n)=>new dU(e,n)).infixLeft("is",Xt.Is,(e,t,n)=>new tb(e,n)).infixLeft("mod",Xt.Modulo,(e,t,n)=>new Da("mod",e,n,(r,a)=>r%a)).infixLeft("or",Xt.Or,(e,t,n)=>new vU(e,n)).infixLeft("xor",Xt.Xor,(e,t,n)=>new yU(e,n)).infixLeft("implies",Xt.Implies,(e,t,n)=>new xU(e,n))}const kU=_U();function ab(e){return new TA(e,kU.construct(EU(e)).consumeAndParse())}function Oc(e,t){const n=Array.isArray(t)?t:[t];for(let r=0;r<n.length;r++){const a=n[r];typeof a=="object"&&"type"in a&&"value"in a||(n[r]=pa(n[r]))}return Bs(e,n).map(r=>r.value)}function Bs(e,t,n={},r=void 0){let a;if(typeof e=="string"){const o=r==null?void 0:r.get(e);a=o??ab(e),r&&!o&&r.set(e,a)}else a=e;return a.eval({variables:n},t).map(o=>{var c;return{type:o.type,value:(c=o.value)==null?void 0:c.valueOf()}})}const Jn={BOOLEAN:"BOOLEAN",NUMBER:"NUMBER",QUANTITY:"QUANTITY",TEXT:"TEXT",REFERENCE:"REFERENCE",CANONICAL:"CANONICAL",DATE:"DATE",DATETIME:"DATETIME"};function Mc(e,t){var r,a;let n=(a=(r=li.types[e])==null?void 0:r.searchParamsDetails)==null?void 0:a[t.code];return n||(n=NU(e,t)),n}function PU(e,t,n){let r=li.types[e];r||(r={},li.types[e]=r),r.searchParamsDetails||(r.searchParamsDetails={}),r.searchParamsDetails[t]=n}function NU(e,t){const n=t.code,r=LU(e,t.expression),a={elementDefinitions:[],propertyTypes:new Set,array:!1};for(const c of r){const u=xh(c),f=B$(()=>u.join("."));u.length===1&&u[0]instanceof Nr?a.propertyTypes.add("boolean"):t.code.endsWith(":identifier")?a.propertyTypes.add("Identifier"):f().endsWith("extension.value.code")||f().endsWith("extension.value.coding.code")?(a.array=!0,a.propertyTypes.add("code")):RA(a,u,e,1),f().endsWith("extension.valueDateTime")&&(a.array=!1)}const o={type:IU(t,a.propertyTypes),elementDefinitions:a.elementDefinitions,parsedExpression:zU(e,t.expression),array:a.array};return PU(e,n,o),o}function RA(e,t,n,r){const a=t[r];if(a instanceof zh){e.propertyTypes.add(a.right.toString());return}if(a instanceof nb){OU(e,a);return}const o=a.toString(),c=Wo(n,o);if(!c)throw new Error(`Element definition not found for ${n} ${o}`);let u=!1,f=r+1;f<t.length&&t[f]instanceof rb&&(u=!0,f++);const p=t[f];if(c.isArray&&!u&&(e.array=!0),f===t.length-1&&p instanceof zh){e.elementDefinitions.push(c),e.propertyTypes.add(p.right.toString());return}if(f>=t.length){e.elementDefinitions.push(c);for(const m of c.type)e.propertyTypes.add(m.code);return}for(const m of c.type){let g=m.code;MU(g)&&(g=c.type[0].code),RA(e,t,g,f)}}function OU(e,t){if(t.name==="as"){e.propertyTypes.add(t.args[0].toString());return}if(t.name==="ofType"){e.propertyTypes.add(t.args[0].toString());return}if(t.name==="resolve"){e.propertyTypes.add("string");return}if(t.name==="where"&&t.args[0]instanceof tb){e.propertyTypes.add(t.args[0].right.toString());return}throw new Error(`Unhandled FHIRPath function: ${t.name}`)}function MU(e){return e==="Element"||e==="BackboneElement"}function IU(e,t){switch(e.type){case"date":return t.size===1&&t.has(oe.date)?Jn.DATE:Jn.DATETIME;case"number":return Jn.NUMBER;case"quantity":return Jn.QUANTITY;case"reference":return t.has(oe.canonical)?Jn.CANONICAL:Jn.REFERENCE;case"token":return t.size===1&&t.has(oe.boolean)?Jn.BOOLEAN:Jn.TEXT;default:return Jn.TEXT}}function LU(e,t){const n=[],r=ab(t);return $h(e,r.child,n),n}function zU(e,t){const n=[],r=ab(t);if($h(e,r.child,n),n.length===0)return r;let a=n[0];for(let o=1;o<n.length;o++)a=new eb(a,n[o]);return new TA("<original-not-available>",a)}function $h(e,t,n){t instanceof eb?($h(e,t.left,n),$h(e,t.right,n)):t.toString().includes(e+".")&&n.push(t)}function xh(e){if(e instanceof zh||e instanceof rb)return[xh(e.left),e].flat();if(e instanceof Nr)return[e];if(e instanceof J0)return[xh(e.left),xh(e.right)].flat();if(e instanceof nb){if(e.name==="where"&&!(e.args[0]instanceof tb))return[];if(e.name==="last")return[]}return[e]}const Qp=20,de={EQUALS:"eq",NOT_EQUALS:"ne",GREATER_THAN:"gt",LESS_THAN:"lt",GREATER_THAN_OR_EQUALS:"ge",LESS_THAN_OR_EQUALS:"le",STARTS_AFTER:"sa",ENDS_BEFORE:"eb",APPROXIMATELY:"ap",CONTAINS:"contains",STARTS_WITH:"sw",EXACT:"exact",TEXT:"text",NOT:"not",ABOVE:"above",BELOW:"below",IN:"in",NOT_IN:"not-in",OF_TYPE:"of-type",MISSING:"missing",PRESENT:"present",IDENTIFIER:"identifier",ITERATE:"iterate"},DA={contains:de.CONTAINS,exact:de.EXACT,above:de.ABOVE,below:de.BELOW,text:de.TEXT,not:de.NOT,in:de.IN,"not-in":de.NOT_IN,"of-type":de.OF_TYPE,missing:de.MISSING,identifier:de.IDENTIFIER,iterate:de.ITERATE},ib={eq:de.EQUALS,ne:de.NOT_EQUALS,lt:de.LESS_THAN,le:de.LESS_THAN_OR_EQUALS,gt:de.GREATER_THAN,ge:de.GREATER_THAN_OR_EQUALS,sa:de.STARTS_AFTER,eb:de.ENDS_BEFORE,ap:de.APPROXIMATELY,sw:de.STARTS_WITH};function AA(e,t){if(!e)throw new Error("Invalid search URL");let n="",r;if(typeof e=="string")if(e.includes("?")){const[c,u]=e.split("?");n=c,r=new URLSearchParams(u)}else n=e;else typeof e=="object"&&(n=e.pathname,r=e.searchParams);let a;n.includes("/")?a=n.split("/").filter(Boolean).pop():a=n;const o=[];return r&&o.push(...r.entries()),$U(a,o)}function $U(e,t){const n={resourceType:e};for(const[r,a]of t)UU(n,r,a);return n}function UU(e,t,n){var c,u;let r,a;const o=t.indexOf(":");if(o>=0?(r=t.substring(0,o),a=t.substring(o+1)):(r=t,a=""),r!=="_"){if(r==="_has"||t.includes(".")){e.filters=Mu(e.filters,{code:t,operator:de.EQUALS,value:n});return}switch(r){case"_sort":BU(e,n);break;case"_cursor":e.cursor=n;break;case"_count":e.count=parseInt(n,10);break;case"_offset":e.offset=parseInt(n,10);break;case"_total":e.total=n;break;case"_summary":n==="count"?(e.total="accurate",e.count=0):(n==="true"||n==="data"||n==="text")&&(e.summary=n);break;case"_include":{const f=uE(n);a==="iterate"&&(f.modifier=de.ITERATE),e.include=Mu(e.include,f);break}case"_revinclude":{const f=uE(n);a==="iterate"&&(f.modifier=de.ITERATE),e.revInclude=Mu(e.revInclude,f);break}case"_fields":case"_elements":e.fields=n.split(",");break;case"_type":e.types=n.split(",");break;case"_format":e.format=n;break;case"_pretty":e.pretty=n==="true";break;default:{const f=(u=(c=li.types[e.resourceType])==null?void 0:c.searchParams)==null?void 0:u[r];f?e.filters=Mu(e.filters,FU(f,a,n)):e.filters=Mu(e.filters,HU(r,a,n))}}}}function BU(e,t){for(const n of t.split(",")){let r,a=!1;n.startsWith("-")?(r=n.substring(1),a=!0):r=n,e.sortRules||(e.sortRules=[]),e.sortRules.push({code:r,descending:a})}}const VU=[de.MISSING,de.PRESENT];function FU(e,t,n){if(VU.includes(t))return{code:e.code,operator:t,value:n};switch(e.type){case"number":case"date":case"quantity":{const{operator:r,value:a}=qU(n);if(!dE(e,a))throw new dt(ri(`Invalid format for ${e.type} search parameter: ${a}`));return{code:e.code,operator:r,value:a}}case"reference":case"string":case"token":case"uri":if(!dE(e,n))throw new dt(ri(`Invalid format for ${e.type} search parameter: ${n}`));return{code:e.code,operator:GU(t),value:n};default:throw new Error("Unrecognized search parameter type: "+e.type)}}function HU(e,t,n){var a;let r=de.EQUALS;if(t)r=t;else if(n.length>=2){const o=n.substring(0,2);o in ib&&(n.length===2||(a=n.at(2))!=null&&a.match(/\d/))&&(r=o,n=n.substring(o.length))}return{code:e,operator:r,value:n}}function qU(e){const t=e.substring(0,2),n=ib[t];return n?{operator:n,value:e.substring(2)}:{operator:de.EQUALS,value:e}}function GU(e){return DA[e]??de.EQUALS}function uE(e){const t=e.split(":");if(t.includes("*"))throw new dt(ri("'*' is not supported as a value for search inclusion parameters"));if(t.length===1)throw new dt(ri(`Invalid include value '${e}': must be of the form ResourceType:search-parameter`));if(t.length===2)return{resourceType:t[0],searchParam:t[1]};if(t.length===3)return{resourceType:t[0],searchParam:t[1],targetType:t[2]};throw new dt(ri(`Invalid include value '${e}'`))}function dE(e,t){switch(e.type){case"date":return Ih(t);default:return!0}}function ec(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach(n=>t.push(QU(n))),e.sortRules&&e.sortRules.length>0&&t.push(WU(e.sortRules)),e.cursor!==void 0&&t.push("_cursor="+encodeURIComponent(e.cursor)),e.offset!==void 0&&e.offset!==0&&t.push("_offset="+e.offset),e.count!==void 0&&t.push("_count="+e.count),e.total!==void 0&&t.push("_total="+e.total),e.types&&e.types.length>0&&t.push("_type="+e.types.join(",")),e.include&&e.include.forEach(n=>t.push(fE("_include",n))),e.revInclude&&e.revInclude.forEach(n=>t.push(fE("_revinclude",n))),t.length===0?"":(rd(t),"?"+t.join("&"))}function QU(e){const t=e.operator in DA?":"+e.operator:"",n=e.operator!==de.EQUALS&&e.operator in ib?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function WU(e){return"_sort="+e.map(t=>t.descending?"-"+t.code:t.code).join(",")}function fE(e,t){return e+(t.modifier?":"+t.modifier:"")+"="+t.resourceType+":"+t.searchParam+(t.targetType?":"+t.targetType:"")}function ob(e){const t=[];let n="",r=!1;for(const a of e)r?(n+=a,r=!1):a==="\\"?r=!0:a===","?(t.push(n),n=""):n+=a;return t.push(n),t}function YU(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters){for(const n of t.filters)if(!KU(e,t,n))return!1}return!0}function KU(e,t,n){var a,o;const r=(o=(a=li.types[t.resourceType])==null?void 0:a.searchParams)==null?void 0:o[n.code];if(!r)return!1;if(n.operator===de.MISSING||n.operator===de.PRESENT)return XU(e,n,r);switch(r.type){case"reference":return ZU(e,n,r);case"string":case"uri":return _A(e,n,r);case"token":return JU(e,n,r);case"date":return rB(e,n,r);default:return!1}}function XU(e,t,n){const a=Oc(n.expression,e).length>0;return(t.operator===de.MISSING&&t.value==="false"||t.operator===de.PRESENT&&t.value==="true")===a}function ZU(e,t,n){const r=Oc(n.expression,e),a=Wp(t.operator);if(t.value===""&&r.length===0)return t.operator===de.EQUALS;const o=r.map(c=>typeof c=="string"?c:c.reference);for(const c of ob(t.value)){let u=o.includes(c);if(!u&&t.code==="_compartment"&&(u=o.some(f=>f==null?void 0:f.endsWith("/"+c))),u)return!a}return a}function JU(e,t,n){return Mc(e.resourceType,n).type===Jn.BOOLEAN?eB(e,t,n):_A(e,t,n,!0)}function eB(e,t,n){const r=Oc(n.expression,e),a=t.value==="true",o=r.includes(a);return Wp(t.operator)?!o:o}function _A(e,t,n,r){var p,m,g,v;const o=(v=(g=(m=(p=Mc(e.resourceType,n).elementDefinitions)==null?void 0:p[0])==null?void 0:m.type)==null?void 0:g[0])==null?void 0:v.code,c=Oc(n.expression,e),u=ob(t.value),f=Wp(t.operator);for(const b of c)for(const S of u){let j;if(o===oe.Identifier?j=tB(b,t.operator,S):o===oe.CodeableConcept?j=nB(b,t.operator,S):j=Ny(b,t.operator,S,r),j)return!f}return f}function Ny(e,t,n,r){if(r&&n.includes("|")){const[o,c]=n.split("|");return Ny(e,t,o,!1)&&(!c||Ny(e,t,c,!1))}let a="";return e&&(typeof e=="string"?a=e:typeof e=="object"&&(a=JSON.stringify(e))),a.toLowerCase().includes(n.toLowerCase())}function tB(e,t,n){var r,a,o,c;if(n.includes("|")){const[u,f]=n.split("|").map(p=>p.toLowerCase());return!u&&!f?!1:u?((a=e.system)==null?void 0:a.toLowerCase())===u&&(!f||((o=e.value)==null?void 0:o.toLowerCase())===f):!e.system&&((r=e.value)==null?void 0:r.toLowerCase())===f}return((c=e.value)==null?void 0:c.toLowerCase())===n.toLowerCase()}function nB(e,t,n){var r,a,o,c;if(n.includes("|")){const[u,f]=n.split("|").map(p=>p.toLowerCase());return!u&&!f?!1:u?((a=e.coding)==null?void 0:a.some(p=>{var m,g;return((m=p.system)==null?void 0:m.toLowerCase())===u&&(!f||((g=p.code)==null?void 0:g.toLowerCase())===f)}))??!1:((r=e.coding)==null?void 0:r.some(p=>{var m;return!p.system&&((m=p.code)==null?void 0:m.toLowerCase())===f}))??!1}return((o=e.text)==null?void 0:o.toLowerCase())===n.toLowerCase()||(((c=e.coding)==null?void 0:c.some(u=>{var f;return((f=u.code)==null?void 0:f.toLowerCase())===n.toLowerCase()}))??!1)}function rB(e,t,n){const r=Oc(n.expression,e),a=ob(t.value),o=Wp(t.operator);for(const c of r)for(const u of a)if(aB(Uh(c),t.operator,Uh(u)))return!o;return o}function aB(e,t,n){if(!e)return!1;switch(t){case de.STARTS_AFTER:case de.GREATER_THAN:return e>n;case de.GREATER_THAN_OR_EQUALS:return e>=n;case de.ENDS_BEFORE:case de.LESS_THAN:return e<n;case de.LESS_THAN_OR_EQUALS:return e<=n;case de.EQUALS:case de.NOT_EQUALS:return e===n;default:return!1}}function Uh(e){if(M$(e))try{return new Date(e).toISOString()}catch(t){console.debug("Failed to parse date",e,t)}else if(fA(e)){if("start"in e)return Uh(e.start);if("end"in e)return Uh(e.end)}}function Wp(e){return e===de.NOT_EQUALS||e===de.NOT}const iB={resourceType:"*"},oB=["DomainConfiguration","JsonWebKey","Login"],sB=["PasswordChangeRequest","UserSecurityRequest","Project","ProjectMembership","User"],tc={READ:"read",VREAD:"vread",HISTORY:"history",HISTORY_INSTANCE:"history-instance"},lB=[tc.READ,tc.VREAD,tc.HISTORY,tc.HISTORY_INSTANCE];function cB(e,t){if(oB.includes(t))return!1;if(e.resource){for(const n of e.resource)if(PA(n.resourceType,t)&&!n.readonly)return!0}return!1}function kA(e,t,n){if(!n)return iB;if(n.resource){for(const r of n.resource)if(uB(e,t,r))return r}}function uB(e,t,n){var a,o;const r=e.resourceType;return!(!PA(n.resourceType,r)||n.readonly&&!lB.includes(t)||n.compartment&&!((o=(a=e.meta)==null?void 0:a.compartment)!=null&&o.find(c=>{var u;return c.reference===((u=n.compartment)==null?void 0:u.reference)}))||n.criteria&&!YU(e,AA(n.criteria)))}function PA(e,t){return e===t||e==="*"&&!sB.includes(t)}function dB(e){if(typeof window<"u"){const t=window.atob(e),n=Uint8Array.from(t,r=>r.charCodeAt(0));return new window.TextDecoder().decode(n)}if(typeof Buffer<"u")return Buffer.from(e,"base64").toString("utf-8");throw new Error("Unable to decode base64")}function hE(e){if(typeof window<"u"){const t=new window.TextEncoder().encode(e),n=String.fromCharCode.apply(null,t);return window.btoa(n)}if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64");throw new Error("Unable to encode base64")}function pE(){const e=new Uint32Array(28);return crypto.getRandomValues(e),L$(e.buffer)}async function fB(e){return crypto.subtle.digest("SHA-256",new TextEncoder().encode(e))}function NA(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function OA(e){var a;const t={};e=Qr(e);for(const o of e.entry||[]){const c=o.resource;if(!c)continue;c.meta!==void 0&&(delete c.meta.author,delete c.meta.compartment,delete c.meta.lastUpdated,delete c.meta.project,delete c.meta.versionId,Object.keys(c.meta).length===0&&delete c.meta);const u=c==null?void 0:c.id;u&&(t[u]=NA(),o.fullUrl="urn:uuid:"+t[u],(a=o.resource)==null||delete a.id)}const n=e.entry,r=JSON.stringify({resourceType:"Bundle",type:"transaction",entry:n==null?void 0:n.map(o=>{var c;return{fullUrl:o.fullUrl,request:{method:"POST",url:(c=o.resource)==null?void 0:c.resourceType},resource:o.resource}})},(o,c)=>hB(o,c,t),2);return pB(JSON.parse(r))}function hB(e,t,n){if(e==="reference"&&typeof t=="string"){let r;if(t.includes("/")?r=t.split("/")[1]:t.startsWith("urn:uuid:")?r=t.slice(9):t.startsWith("#")&&(r=t.slice(1)),r){const a=n[r];if(a)return"urn:uuid:"+a}}return t}function pB(e){const t=gB(e),{sorted:n,cycles:r}=mB(t),a={};for(const c of e.entry??[])c.fullUrl&&(a[c.fullUrl]=c);const o=n.map(c=>a[c]);for(const c of r)for(const u of c){const f=a[u],p={...f,request:{...f.request,method:"PUT"}};o.push(p)}return{...e,entry:o}}const Wl={NotVisited:"NotVisited",Visiting:"Visiting",Visited:"Visited"};function mB(e){const t=[],n={},r=[];for(const o of Object.keys(e))n[o]=Wl.NotVisited;function a(o,c){if(n[o]===Wl.Visited)return!0;if(n[o]===Wl.Visiting){const f=c.lastIndexOf(o);return f!==-1&&r.push(c.slice(f)),!0}n[o]=Wl.Visiting,c.push(o);let u=!1;for(const f of e[o])a(f,c)||(u=!0);return n[o]=Wl.Visited,c.pop(),t.unshift(o),!u}for(const o in e)n[o]===Wl.NotVisited&&a(o,[]);return{sorted:t,cycles:r}}function MA(e,t){for(const n in e)if(e[n]&&typeof e[n]=="object"){const r=e[n];if(Yo(r)){const a=r.reference;a.startsWith("urn:uuid:")&&t(a)}else MA(r,t)}}function gB(e){const t={};for(const n of e.entry||[])n.fullUrl&&(t[n.fullUrl]=[]);for(const n of e.entry||[]){const r=n.fullUrl;n.resource&&MA(n.resource,a=>{t[a]&&t[a].push(r)})}return t}const hn={FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",JSON:"application/json",JSON_PATCH:"application/json-patch+json",TEXT:"text/plain",PING:"x-application/ping",XML:"text/xml",CDA_XML:"application/cda+xml"};class vB{constructor(){this.listeners={}}addEventListener(t,n){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n)}removeEventListener(t,n){const r=this.listeners[t];if(r){for(let a=0;a<r.length;a++)if(r[a]===n){r.splice(a,1);return}}}dispatchEvent(t){const n=this.listeners[t.type];if(n)for(const r of n)r.call(this,t);return!t.defaultPrevented}removeAllListeners(){this.listeners={}}}class Yp{constructor(){this.emitter=new vB}dispatchEvent(t){this.emitter.dispatchEvent(t)}addEventListener(t,n){this.emitter.addEventListener(t,n)}removeEventListener(t,n){this.emitter.removeEventListener(t,n)}removeAllListeners(){this.emitter.removeAllListeners()}}const Oy={"Patient-open":"Patient-open","Patient-close":"Patient-close","ImagingStudy-open":"ImagingStudy-open","ImagingStudy-close":"ImagingStudy-close","Encounter-open":"Encounter-open","Encounter-close":"Encounter-close","DiagnosticReport-open":"DiagnosticReport-open","DiagnosticReport-close":"DiagnosticReport-close","DiagnosticReport-select":"DiagnosticReport-select","DiagnosticReport-update":"DiagnosticReport-update",syncerror:"syncerror"},yB=["Patient","Encounter","ImagingStudy","DiagnosticReport","OperationOutcome","Bundle"],sb=["DiagnosticReport-update"];function xB(e){return sb.includes(e)}function bB(e){if(sb.includes(e))throw new dt(yn(`'context.version' is required for '${e}'.`))}const SB={"Patient-open":{patient:{resourceType:"Patient"},encounter:{resourceType:"Encounter",optional:!0}},"Patient-close":{patient:{resourceType:"Patient"},encounter:{resourceType:"Encounter",optional:!0}},"ImagingStudy-open":{study:{resourceType:"ImagingStudy"},encounter:{resourceType:"Encounter",optional:!0},patient:{resourceType:"Patient",optional:!0}},"ImagingStudy-close":{study:{resourceType:"ImagingStudy"},encounter:{resourceType:"Encounter",optional:!0},patient:{resourceType:"Patient",optional:!0}},"Encounter-open":{encounter:{resourceType:"Encounter"},patient:{resourceType:"Patient"}},"Encounter-close":{encounter:{resourceType:"Encounter"},patient:{resourceType:"Patient"}},"DiagnosticReport-open":{report:{resourceType:"DiagnosticReport"},encounter:{resourceType:"Encounter",optional:!0},study:{resourceType:"ImagingStudy",optional:!0,manyAllowed:!0},patient:{resourceType:"Patient"}},"DiagnosticReport-close":{report:{resourceType:"DiagnosticReport"},encounter:{resourceType:"Encounter",optional:!0},study:{resourceType:"ImagingStudy",optional:!0,manyAllowed:!0},patient:{resourceType:"Patient"}},"DiagnosticReport-select":{report:{resourceType:"DiagnosticReport",reference:!0},patient:{resourceType:"Patient",optional:!0,reference:!0},select:{resourceType:"*",reference:!0,manyAllowed:!0}},"DiagnosticReport-update":{report:{resourceType:"DiagnosticReport",reference:!0},patient:{resourceType:"Patient",optional:!0,reference:!0},updates:{resourceType:"Bundle"}},syncerror:{operationoutcome:{resourceType:"OperationOutcome"}}};function wB(e){return yB.includes(e)}function IA(e){return!!e.endpoint}function mE(e){if(!lb(e))throw new dt(yn("subscriptionRequest must be an object conforming to SubscriptionRequest type."));const{channelType:t,mode:n,topic:r,events:a}=e,o={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":a.join(",")};return IA(e)&&(o.endpoint=e.endpoint),new URLSearchParams(o).toString()}function lb(e){if(typeof e!="object")return!1;const{channelType:t,mode:n,topic:r,events:a}=e;if(!(t&&n&&r&&a)||typeof r!="string"||typeof a!="object"||!Array.isArray(a)||a.length<1||t!=="websocket"||n!=="subscribe"&&n!=="unsubscribe")return!1;for(const o of a)if(!Oy[o])return!1;return!(IA(e)&&!(typeof e.endpoint=="string"&&e.endpoint.startsWith("ws")))}function jB(e,t,n,r){if(typeof t!="object")throw new dt(yn(`context[${n}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));if(!(t.id&&typeof t.id=="string"))throw new dt(yn(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new dt(yn(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));const a=r.resourceType;if(a!=="*"){if(!wB(t.resourceType))throw new dt(yn(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(a&&t.resourceType!==a)throw new dt(yn(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${a}.`))}}function CB(e,t,n,r,a){if(a.set(t.key,(a.get(t.key)??0)+1),r.reference){if(!Yo(t.reference))throw new dt(yn(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else jB(e,t.resource,n,r)}function EB(e,t){const n=new Map,r=SB[e];for(let a=0;a<t.length;a++){const o=t[a].key;if(!r[o])throw new dt(yn(`Key '${o}' not found for event '${e}'. Make sure to add only valid keys.`));CB(e,t[a],a,r[o],n)}for(const[a,o]of Object.entries(r)){if(!(o.optional||n.has(a)))throw new dt(yn(`Missing required key '${a}' on context for '${e}' event.`));if(!o.manyAllowed&&(n.get(a)??0)>1)throw new dt(yn(`${n.get(a)} context entries with key '${a}' found for the '${e}' event when schema only allows for 1.`))}}function gE(e,t,n,r){if(!(e&&typeof e=="string"))throw new dt(yn("Must provide a topic."));if(!Oy[t])throw new dt(yn(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Oy).join(", ")}`));if(typeof n!="object")throw new dt(yn("context must be a context object or array of context objects."));if(sb.includes(t)&&!r)throw new dt(yn(`The '${t}' event must contain a 'context.versionId'.`));const a=Array.isArray(n)?n:[n];return EB(t,a),{timestamp:new Date().toISOString(),id:NA(),event:{"hub.topic":e,"hub.event":t,context:a,...r?{"context.versionId":r}:{}}}}class TB extends Yp{constructor(t){if(super(),this.subRequest=t,!t.endpoint)throw new dt(yn("Subscription request should contain an endpoint."));if(!lb(t))throw new dt(yn("Subscription request failed validation."));const n=new WebSocket(t.endpoint);n.addEventListener("open",()=>{this.dispatchEvent({type:"connect"}),n.addEventListener("message",r=>{const a=JSON.parse(r.data);if(a["hub.topic"])return;const o=a;o.event["hub.event"]!=="heartbeat"&&(this.dispatchEvent({type:"message",payload:o}),n.send(JSON.stringify({id:a==null?void 0:a.id,timestamp:new Date().toISOString()})))}),n.addEventListener("close",()=>{this.dispatchEvent({type:"disconnect"})})}),this.websocket=n}disconnect(){this.websocket.close()}}function RB(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=dB(t),r=Array.from(n).reduce((o,c)=>{const u=("00"+c.charCodeAt(0).toString(16)).slice(-2);return`${o}%${u}`},""),a=decodeURIComponent(r);return JSON.parse(a)}function DB(e){return e.split(".").length===3}function cb(e){const[t,n,r]=e.split(".");return RB(n)}function AB(e){try{return typeof cb(e).login_id=="string"}catch{return!1}}function _B(e){try{const n=cb(e).exp;return typeof n=="number"?n*1e3:void 0}catch{return}}class kB{constructor(t){this.medplum=t}async get(t){return this.medplum.get(`keyvalue/v1/${t}`)}async set(t,n){await this.medplum.put(`keyvalue/v1/${t}`,n,hn.TEXT)}async delete(t){await this.medplum.delete(`keyvalue/v1/${t}`)}}var LA;LA=Symbol.toStringTag;class Aa{constructor(t){this[LA]="ReadablePromise",this.status="pending",this.suspender=t.then(n=>(this.status="success",this.response=n,n),n=>{throw this.status="error",this.error=n,n})}isPending(){return this.status==="pending"}isOk(){return this.status==="success"}read(){switch(this.status){case"pending":throw this.suspender;case"error":throw this.error;default:return this.response}}then(t,n){return this.suspender.then(t,n)}catch(t){return this.suspender.catch(t)}finally(t){return this.suspender.finally(t)}}class PB{constructor(t){this.storage=t??(typeof localStorage<"u"?localStorage:new NB)}clear(){this.storage.clear()}getString(t){return this.storage.getItem(t)??void 0}setString(t,n){n?this.storage.setItem(t,n):this.storage.removeItem(t)}getObject(t){const n=this.getString(t);return n?JSON.parse(n):void 0}setObject(t,n){this.setString(t,n?Ia(n):void 0)}}class NB{constructor(){this.data=new Map}get length(){return this.data.size}clear(){this.data.clear()}getItem(t){return this.data.get(t)??null}setItem(t,n){n?this.data.set(t,n):this.data.delete(t)}removeItem(t){this.data.delete(t)}key(t){return Array.from(this.data.keys())[t]}}/*!
79
79
  * Reconnecting WebSocket
@@ -83,7 +83,7 @@ function n3(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
83
83
  *
84
84
  * Copy of "partysocket" from Partykit team, a fork of the original "Reconnecting WebSocket"
85
85
  * https://github.com/partykit/partykit/blob/main/packages/partysocket
86
- */const ic={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};let vE=!1;function OB(){if(typeof globalThis.Event>"u")throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");ic.Event=globalThis.Event,ic.ErrorEvent=class extends Event{constructor(t,n){super("error",n),this.message=t.message,this.error=t}},ic.CloseEvent=class extends Event{constructor(t=1e3,n="",r){super("close",r),this.wasClean=!0,this.code=t,this.reason=n}}}function MB(e,t){if(!e)throw new Error(t)}function ih(e){return new e.constructor(e.type,e)}const xs={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0};let yE=!1;class Mo extends Yp{constructor(t,n,r={}){vE||(OB(),vE=!0),super(),this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._closeCalled=!1,this._messageQueue=[],this._debugLogger=console.log.bind(console),this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=a=>{this._debug("open event");const{minUptime:o=xs.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),o),MB(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(c=>{var u;return(u=this._ws)==null?void 0:u.send(c)}),this._messageQueue=[],this.onopen&&this.onopen(a),this.dispatchEvent(ih(a))},this._handleMessage=a=>{this._debug("message event"),this.onmessage&&this.onmessage(a),this.dispatchEvent(ih(a))},this._handleError=a=>{this._debug("error event",a.message),this._disconnect(void 0,a.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(a),this._debug("exec error listeners"),this.dispatchEvent(ih(a)),this._connect()},this._handleClose=a=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(a),this.dispatchEvent(ih(a))},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._options.binaryType?this._binaryType=this._options.binaryType:this._binaryType="blob",this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return Mo.CONNECTING}get OPEN(){return Mo.OPEN}get CLOSING(){return Mo.CLOSING}get CLOSED(){return Mo.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){var n;return this._messageQueue.reduce((r,a)=>(typeof a=="string"?r+=a.length:a instanceof Blob?r+=a.size:r+=a.byteLength,r),0)+(((n=this._ws)==null?void 0:n.bufferedAmount)??0)}get extensions(){var t;return((t=this._ws)==null?void 0:t.extensions)??""}get protocol(){var t;return((t=this._ws)==null?void 0:t.protocol)??""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?Mo.CLOSED:Mo.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,n){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)}reconnect(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{const{maxEnqueuedMessages:n=xs.maxEnqueuedMessages}=this._options;this._messageQueue.length<n&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){const{reconnectionDelayGrowFactor:t=xs.reconnectionDelayGrowFactor,minReconnectionDelay:n=xs.minReconnectionDelay,maxReconnectionDelay:r=xs.maxReconnectionDelay}=this._options;let a=0;return this._retryCount>0&&(a=n*Math.pow(t,this._retryCount-1),a>r&&(a=r)),this._debug("next delay",a),a}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;const{maxRetries:t=xs.maxRetries,connectionTimeout:n=xs.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>"u"&&!yE&&(console.error("‼️ No WebSocket implementation available. You should define options.WebSocket."),yE=!0);const r=this._options.WebSocket||WebSocket;this._debug("connect",{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new r(this._url,this._protocols):new r(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),n)}).catch(r=>{this._connectLock=!1,this._handleError(new ic.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new ic.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,n){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new ic.CloseEvent(t,n,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}}const IB=5e3;class My extends Yp{constructor(...t){super(),this.criteria=new Set(t)}getCriteria(){return this.criteria}_addCriteria(t){this.criteria.add(t)}_removeCriteria(t){this.criteria.delete(t)}}class LB{constructor(t,n){this.connecting=!1,this.criteria=t,this.emitter=new My(t),this.refCount=1,this.subscriptionProps=n?{...n}:void 0}clearAttachedSubscription(){this.subscriptionId=void 0,this.token=void 0}}class zB{constructor(t,n,r){if(this.pingTimer=void 0,this.waitingForPong=!1,!(t instanceof $A))throw new dt(yn("First arg of constructor should be a `MedplumClient`"));let a;try{a=new URL(n).toString()}catch{throw new dt(yn("Not a valid URL"))}const o=r!=null&&r.ReconnectingWebSocket?new r.ReconnectingWebSocket(a,void 0,{debug:r==null?void 0:r.debug,debugLogger:r==null?void 0:r.debugLogger}):new Mo(a,void 0,{debug:r==null?void 0:r.debug,debugLogger:r==null?void 0:r.debugLogger});this.medplum=t,this.ws=o,this.masterSubEmitter=new My,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=(r==null?void 0:r.pingIntervalMs)??IB,this.currentProfile=t.getProfile(),this.setupListeners()}setupListeners(){const t=this.ws;t.addEventListener("message",n=>{var r,a,o,c,u,f;try{const p=JSON.parse(n.data);if(p.type==="pong"){this.waitingForPong=!1;return}const m=p,g=(a=(r=m==null?void 0:m.entry)==null?void 0:r[0])==null?void 0:a.resource;if(g.type==="heartbeat"){(o=this.masterSubEmitter)==null||o.dispatchEvent({type:"heartbeat",payload:m});return}if(g.type==="handshake"){const b=$s(g.subscription),S={type:"connect",payload:{subscriptionId:b}};(c=this.masterSubEmitter)==null||c.dispatchEvent(S);const j=this.criteriaEntriesBySubscriptionId.get(b);if(!j){console.warn("Received handshake for criteria the SubscriptionManager is not listening for yet");return}j.connecting=!1,j.emitter.dispatchEvent({...S});return}(u=this.masterSubEmitter)==null||u.dispatchEvent({type:"message",payload:m});const v=this.criteriaEntriesBySubscriptionId.get($s(g.subscription));if(!v){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}v.emitter.dispatchEvent({type:"message",payload:m})}catch(p){console.error(p);const m={type:"error",payload:p};(f=this.masterSubEmitter)==null||f.dispatchEvent(m);for(const g of this.getAllCriteriaEmitters())g.dispatchEvent({...m})}}),t.addEventListener("error",()=>{var r;const n={type:"error",payload:new dt(Zz(new Error("WebSocket error")))};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const a of this.getAllCriteriaEmitters())a.dispatchEvent({...n})}),t.addEventListener("close",()=>{var r,a;const n={type:"close"};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const o of this.getAllCriteriaEmitters())o.dispatchEvent({...n});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),(a=this.masterSubEmitter)==null||a.removeAllListeners())}),t.addEventListener("open",()=>{var r;const n={type:"open"};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const a of this.getAllCriteriaEmitters())a.dispatchEvent({...n});this.refreshAllSubscriptions().catch(console.error),this.pingTimer||(this.pingTimer=setInterval(()=>{if(this.waitingForPong){this.waitingForPong=!1,t.reconnect();return}t.send(JSON.stringify({type:"ping"})),this.waitingForPong=!0},this.pingIntervalMs))}),this.medplum.addEventListener("change",()=>{var r;const n=this.medplum.getProfile();this.currentProfile&&n===void 0?this.ws.close():n&&((r=this.currentProfile)==null?void 0:r.id)!==n.id&&this.ws.reconnect(),this.currentProfile=n})}emitError(t,n){var a;const r={type:"error",payload:n};(a=this.masterSubEmitter)==null||a.dispatchEvent(r),t.emitter.dispatchEvent({...r})}maybeEmitDisconnect(t){var r;const{subscriptionId:n}=t;if(n){const a={type:"disconnect",payload:{subscriptionId:n}};(r=this.masterSubEmitter)==null||r.dispatchEvent(a),t.emitter.dispatchEvent({...a})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}async getTokenForCriteria(t){var c,u;let n=t==null?void 0:t.subscriptionId;n||(n=(await this.medplum.createResource({...t.subscriptionProps,resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${zt(this.medplum.getProfile())}`,channel:{type:"websocket"},criteria:t.criteria})).id);const{parameter:r}=await this.medplum.get(`fhir/R4/Subscription/${n}/$get-ws-binding-token`),a=(c=r==null?void 0:r.find(f=>f.name==="token"))==null?void 0:c.valueString,o=(u=r==null?void 0:r.find(f=>f.name==="websocket-url"))==null?void 0:u.valueUrl;if(!a)throw new dt(yn("Failed to get token"));if(!o)throw new dt(yn("Failed to get URL from $get-ws-binding-token"));return[n,a]}maybeGetCriteriaEntry(t,n){const r=this.criteriaEntries.get(t);if(r){if(!n)return r.bareCriteria;for(const a of r.criteriaWithProps)if(si(n,a.subscriptionProps))return a}}getAllCriteriaEmitters(){const t=[];for(const n of this.criteriaEntries.values()){n.bareCriteria&&t.push(n.bareCriteria.emitter);for(const r of n.criteriaWithProps)t.push(r.emitter)}return t}addCriteriaEntry(t){const{criteria:n,subscriptionProps:r}=t;let a;this.criteriaEntries.has(n)?a=this.criteriaEntries.get(n):(a={criteriaWithProps:[]},this.criteriaEntries.set(n,a)),r?a.criteriaWithProps.push(t):a.bareCriteria=t}removeCriteriaEntry(t){var u;const{criteria:n,subscriptionProps:r,subscriptionId:a,token:o}=t;if(!this.criteriaEntries.has(n))return;const c=this.criteriaEntries.get(n);r?c.criteriaWithProps=c.criteriaWithProps.filter(f=>{const p=f.subscriptionProps;return!si(r,p)}):c.bareCriteria=void 0,!c.bareCriteria&&c.criteriaWithProps.length===0&&(this.criteriaEntries.delete(n),(u=this.masterSubEmitter)==null||u._removeCriteria(n)),a&&this.criteriaEntriesBySubscriptionId.delete(a),o&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"unbind-from-token",payload:{token:o}}))}async subscribeToCriteria(t){if(!(this.ws.readyState!==WebSocket.OPEN||t.connecting)){t.connecting=!0;try{const[n,r]=await this.getTokenForCriteria(t);t.subscriptionId=n,t.token=r,this.criteriaEntriesBySubscriptionId.set(n,t),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:r}}))}catch(n){console.error(Xe(n)),this.emitError(t,n),this.removeCriteriaEntry(t)}}}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();for(const t of this.criteriaEntries.values())for(const n of[...t.bareCriteria?[t.bareCriteria]:[],...t.criteriaWithProps])n.clearAttachedSubscription(),await this.subscribeToCriteria(n)}addCriteria(t,n){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const r=this.maybeGetCriteriaEntry(t,n);if(r)return r.refCount+=1,r.emitter;const a=new LB(t,n);return this.addCriteriaEntry(a),this.subscribeToCriteria(a).catch(console.error),a.emitter}removeCriteria(t,n){const r=this.maybeGetCriteriaEntry(t,n);if(!r){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}r.refCount-=1,!(r.refCount>0)&&(this.maybeEmitDisconnect(r),this.removeCriteriaEntry(r))}getWebSocket(){return this.ws}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new My(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const zA="4.1.7-c1d86acfc",$B=hn.FHIR_JSON+", */*; q=0.1",UB="https://api.medplum.com/",BB=1e3,VB=6e4,FB=0,HB=3e5,qB="Binary/",xE={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]},Yl={ClientCredentials:"client_credentials",AuthorizationCode:"authorization_code",RefreshToken:"refresh_token",JwtBearer:"urn:ietf:params:oauth:grant-type:jwt-bearer",TokenExchange:"urn:ietf:params:oauth:grant-type:token-exchange"},GB={AccessToken:"urn:ietf:params:oauth:token-type:access_token"},QB={JwtBearer:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"};class $A extends Yp{constructor(t){if(super(),this.initComplete=!0,t!=null&&t.baseUrl&&!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");this.options=t??{},this.fetch=(t==null?void 0:t.fetch)??WB(),this.storage=(t==null?void 0:t.storage)??new PB,this.createPdfImpl=t==null?void 0:t.createPdf,this.baseUrl=X0((t==null?void 0:t.baseUrl)??UB),this.fhirBaseUrl=Xa(this.baseUrl,(t==null?void 0:t.fhirUrlPath)??"fhir/R4"),this.authorizeUrl=Xa(this.baseUrl,(t==null?void 0:t.authorizeUrl)??"oauth2/authorize"),this.tokenUrl=Xa(this.baseUrl,(t==null?void 0:t.tokenUrl)??"oauth2/token"),this.logoutUrl=Xa(this.baseUrl,(t==null?void 0:t.logoutUrl)??"oauth2/logout"),this.fhircastHubUrl=Xa(this.baseUrl,(t==null?void 0:t.fhircastHubUrl)??"fhircast/STU3"),this.clientId=(t==null?void 0:t.clientId)??"",this.clientSecret=(t==null?void 0:t.clientSecret)??"",this.credentialsInHeader=(t==null?void 0:t.authCredentialsMethod)==="header",this.defaultHeaders=(t==null?void 0:t.defaultHeaders)??{},this.onUnauthenticated=t==null?void 0:t.onUnauthenticated,this.refreshGracePeriod=(t==null?void 0:t.refreshGracePeriod)??HB,this.cacheTime=(t==null?void 0:t.cacheTime)??(typeof window>"u"?FB:VB),this.cacheTime>0?this.requestCache=new XD((t==null?void 0:t.resourceCacheSize)??BB):this.requestCache=void 0,t!=null&&t.autoBatchTime?(this.autoBatchTime=t.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),t!=null&&t.accessToken&&this.setAccessToken(t.accessToken),this.storage.getInitPromise===void 0?(t!=null&&t.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initPromise=Promise.resolve(),this.dispatchEvent({type:"storageInitialized"})):(this.initComplete=!1,this.initPromise=this.storage.getInitPromise(),this.initPromise.then(()=>{t!=null&&t.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:"storageInitialized"})}).catch(n=>{console.error(n),this.initComplete=!0,this.dispatchEvent({type:"storageInitFailed",payload:{error:n}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}async attemptResumeActiveLogin(){const t=this.getActiveLogin();t&&(this.setAccessToken(t.accessToken,t.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.clear(),typeof window<"u"&&sessionStorage.clear(),this.clearActiveLogin()}clearActiveLogin(){var t;this.storage.setString("activeLogin",void 0),(t=this.requestCache)==null||t.clear(),this.accessToken=void 0,this.refreshToken=void 0,this.refreshPromise=void 0,this.accessTokenExpires=void 0,this.sessionDetails=void 0,this.medplumServer=void 0,this.dispatchEvent({type:"change"})}invalidateUrl(t){var n;t=t.toString(),(n=this.requestCache)==null||n.delete(t)}invalidateAll(){var t;(t=this.requestCache)==null||t.clear()}invalidateSearches(t){const n=Xa(this.fhirBaseUrl,t);if(this.requestCache)for(const r of this.requestCache.keys())(r.endsWith(n)||r.includes(n+"?"))&&this.requestCache.delete(r)}get(t,n={}){t=t.toString();const r=this.getCacheEntry(t,n);if(r)return r.value;let a;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!n.disableAutoBatch?a=new Promise((c,u)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:c,reject:u}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):a=this.request("GET",t,n);const o=new Aa(a);return this.setCacheEntry(t,o),o}post(t,n,r,a={}){return t=t.toString(),this.setRequestBody(a,n),r&&this.setRequestContentType(a,r),this.invalidateUrl(t),this.request("POST",t,a)}put(t,n,r,a={}){return t=t.toString(),this.setRequestBody(a,n),r&&this.setRequestContentType(a,r),this.invalidateUrl(t),this.request("PUT",t,a)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,hn.JSON_PATCH),this.invalidateUrl(t),this.request("PATCH",t,r)}delete(t,n){return t=t.toString(),this.invalidateUrl(t),this.request("DELETE",t,n)}async startNewUser(t,n){const{codeChallengeMethod:r,codeChallenge:a}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:a},void 0,n)}async startNewProject(t,n){return this.post("auth/newproject",t,void 0,n)}async startNewPatient(t,n){return this.post("auth/newpatient",t,void 0,n)}async startLogin(t,n){return this.post("auth/login",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async startGoogleLogin(t,n){return this.post("auth/google",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async ensureCodeChallenge(t){return t.codeChallenge?t:{...t,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(t){const r=new URLSearchParams(window.location.search).get("code");if(!r){await this.requestAuthorization(t);return}return this.processCode(r)}signOutWithRedirect(){window.location.assign(this.logoutUrl)}async signInWithExternalAuth(t,n,r,a,o=!0){let c=a;o&&(c=await this.ensureCodeChallenge(a)),window.location.assign(this.getExternalAuthRedirectUri(t,n,r,c,o))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");return this.fetchTokens({grant_type:Yl.TokenExchange,subject_token_type:GB.AccessToken,client_id:n,subject_token:t})}getExternalAuthRedirectUri(t,n,r,a,o=!0){const c=new URL(t);if(c.searchParams.set("response_type","code"),c.searchParams.set("client_id",n),c.searchParams.set("redirect_uri",r),c.searchParams.set("scope",a.scope??"openid profile email"),c.searchParams.set("state",JSON.stringify(a)),o){const{codeChallenge:u,codeChallengeMethod:f}=a;if(!f)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!u)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");c.searchParams.set("code_challenge_method",f),c.searchParams.set("code_challenge",u)}return c.toString()}fhirUrl(...t){return new URL(Xa(this.fhirBaseUrl,t.join("/")))}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=H$(n)),r}search(t,n,r){const a=this.fhirSearchUrl(t,n),o="search-"+a.toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=this.getBundle(a,r);return this.setCacheEntry(o,u),u}searchOne(t,n,r){const a=this.fhirSearchUrl(t,n);a.searchParams.set("_count","1"),a.searchParams.sort();const o="searchOne-"+a.toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=new Aa(this.search(t,a.searchParams,r).then(f=>{var p,m;return(m=(p=f.entry)==null?void 0:p[0])==null?void 0:m.resource}));return this.setCacheEntry(o,u),u}searchResources(t,n,r){const o="searchResources-"+this.fhirSearchUrl(t,n).toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=new Aa(this.search(t,n,r).then(wE));return this.setCacheEntry(o,u),u}async*searchResourcePages(t,n,r){var o,c;let a=this.fhirSearchUrl(t,n);for(;a;){const u=new URL(a).searchParams,f=await this.search(t,u,r),p=(o=f.link)==null?void 0:o.find(m=>m.relation==="next");if(!((c=f.entry)!=null&&c.length)&&!p)break;yield wE(f),a=p!=null&&p.url?new URL(p.url):void 0}}valueSetExpand(t,n){const r=this.fhirUrl("ValueSet","$expand");return r.search=new URLSearchParams(t).toString(),this.get(r.toString(),n)}getCached(t,n){var a,o;const r=(o=(a=this.requestCache)==null?void 0:a.get(this.fhirUrl(t,n).toString()))==null?void 0:o.value;return r!=null&&r.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return xE;const[r,a]=n.split("/");if(!(!r||!a))return this.getCached(r,a)}readResource(t,n,r){if(!n)throw new Error('The "id" parameter cannot be null, undefined, or an empty string.');return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Aa(Promise.reject(new Error("Missing reference")));if(r==="system")return new Aa(Promise.resolve(xE));const[a,o]=r.split("/");return!a||!o?new Aa(Promise.reject(new Error("Invalid reference"))):this.readResource(a,o,n)}requestSchema(t){if(iA(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const a=new Aa((async()=>{const o=`{
86
+ */const ic={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};let vE=!1;function OB(){if(typeof globalThis.Event>"u")throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");ic.Event=globalThis.Event,ic.ErrorEvent=class extends Event{constructor(t,n){super("error",n),this.message=t.message,this.error=t}},ic.CloseEvent=class extends Event{constructor(t=1e3,n="",r){super("close",r),this.wasClean=!0,this.code=t,this.reason=n}}}function MB(e,t){if(!e)throw new Error(t)}function ih(e){return new e.constructor(e.type,e)}const xs={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0};let yE=!1;class Mo extends Yp{constructor(t,n,r={}){vE||(OB(),vE=!0),super(),this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._closeCalled=!1,this._messageQueue=[],this._debugLogger=console.log.bind(console),this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=a=>{this._debug("open event");const{minUptime:o=xs.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),o),MB(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(c=>{var u;return(u=this._ws)==null?void 0:u.send(c)}),this._messageQueue=[],this.onopen&&this.onopen(a),this.dispatchEvent(ih(a))},this._handleMessage=a=>{this._debug("message event"),this.onmessage&&this.onmessage(a),this.dispatchEvent(ih(a))},this._handleError=a=>{this._debug("error event",a.message),this._disconnect(void 0,a.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(a),this._debug("exec error listeners"),this.dispatchEvent(ih(a)),this._connect()},this._handleClose=a=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(a),this.dispatchEvent(ih(a))},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._options.binaryType?this._binaryType=this._options.binaryType:this._binaryType="blob",this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return Mo.CONNECTING}get OPEN(){return Mo.OPEN}get CLOSING(){return Mo.CLOSING}get CLOSED(){return Mo.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){var n;return this._messageQueue.reduce((r,a)=>(typeof a=="string"?r+=a.length:a instanceof Blob?r+=a.size:r+=a.byteLength,r),0)+(((n=this._ws)==null?void 0:n.bufferedAmount)??0)}get extensions(){var t;return((t=this._ws)==null?void 0:t.extensions)??""}get protocol(){var t;return((t=this._ws)==null?void 0:t.protocol)??""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?Mo.CLOSED:Mo.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,n){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)}reconnect(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{const{maxEnqueuedMessages:n=xs.maxEnqueuedMessages}=this._options;this._messageQueue.length<n&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){const{reconnectionDelayGrowFactor:t=xs.reconnectionDelayGrowFactor,minReconnectionDelay:n=xs.minReconnectionDelay,maxReconnectionDelay:r=xs.maxReconnectionDelay}=this._options;let a=0;return this._retryCount>0&&(a=n*Math.pow(t,this._retryCount-1),a>r&&(a=r)),this._debug("next delay",a),a}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;const{maxRetries:t=xs.maxRetries,connectionTimeout:n=xs.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>"u"&&!yE&&(console.error("‼️ No WebSocket implementation available. You should define options.WebSocket."),yE=!0);const r=this._options.WebSocket||WebSocket;this._debug("connect",{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new r(this._url,this._protocols):new r(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),n)}).catch(r=>{this._connectLock=!1,this._handleError(new ic.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new ic.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,n){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new ic.CloseEvent(t,n,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}}const IB=5e3;class My extends Yp{constructor(...t){super(),this.criteria=new Set(t)}getCriteria(){return this.criteria}_addCriteria(t){this.criteria.add(t)}_removeCriteria(t){this.criteria.delete(t)}}class LB{constructor(t,n){this.connecting=!1,this.criteria=t,this.emitter=new My(t),this.refCount=1,this.subscriptionProps=n?{...n}:void 0}clearAttachedSubscription(){this.subscriptionId=void 0,this.token=void 0}}class zB{constructor(t,n,r){if(this.pingTimer=void 0,this.waitingForPong=!1,!(t instanceof $A))throw new dt(yn("First arg of constructor should be a `MedplumClient`"));let a;try{a=new URL(n).toString()}catch{throw new dt(yn("Not a valid URL"))}const o=r!=null&&r.ReconnectingWebSocket?new r.ReconnectingWebSocket(a,void 0,{debug:r==null?void 0:r.debug,debugLogger:r==null?void 0:r.debugLogger}):new Mo(a,void 0,{debug:r==null?void 0:r.debug,debugLogger:r==null?void 0:r.debugLogger});this.medplum=t,this.ws=o,this.masterSubEmitter=new My,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=(r==null?void 0:r.pingIntervalMs)??IB,this.currentProfile=t.getProfile(),this.setupListeners()}setupListeners(){const t=this.ws;t.addEventListener("message",n=>{var r,a,o,c,u,f;try{const p=JSON.parse(n.data);if(p.type==="pong"){this.waitingForPong=!1;return}const m=p,g=(a=(r=m==null?void 0:m.entry)==null?void 0:r[0])==null?void 0:a.resource;if(g.type==="heartbeat"){(o=this.masterSubEmitter)==null||o.dispatchEvent({type:"heartbeat",payload:m});return}if(g.type==="handshake"){const b=$s(g.subscription),S={type:"connect",payload:{subscriptionId:b}};(c=this.masterSubEmitter)==null||c.dispatchEvent(S);const j=this.criteriaEntriesBySubscriptionId.get(b);if(!j){console.warn("Received handshake for criteria the SubscriptionManager is not listening for yet");return}j.connecting=!1,j.emitter.dispatchEvent({...S});return}(u=this.masterSubEmitter)==null||u.dispatchEvent({type:"message",payload:m});const v=this.criteriaEntriesBySubscriptionId.get($s(g.subscription));if(!v){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}v.emitter.dispatchEvent({type:"message",payload:m})}catch(p){console.error(p);const m={type:"error",payload:p};(f=this.masterSubEmitter)==null||f.dispatchEvent(m);for(const g of this.getAllCriteriaEmitters())g.dispatchEvent({...m})}}),t.addEventListener("error",()=>{var r;const n={type:"error",payload:new dt(Zz(new Error("WebSocket error")))};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const a of this.getAllCriteriaEmitters())a.dispatchEvent({...n})}),t.addEventListener("close",()=>{var r,a;const n={type:"close"};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const o of this.getAllCriteriaEmitters())o.dispatchEvent({...n});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),(a=this.masterSubEmitter)==null||a.removeAllListeners())}),t.addEventListener("open",()=>{var r;const n={type:"open"};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const a of this.getAllCriteriaEmitters())a.dispatchEvent({...n});this.refreshAllSubscriptions().catch(console.error),this.pingTimer||(this.pingTimer=setInterval(()=>{if(this.waitingForPong){this.waitingForPong=!1,t.reconnect();return}t.send(JSON.stringify({type:"ping"})),this.waitingForPong=!0},this.pingIntervalMs))}),this.medplum.addEventListener("change",()=>{var r;const n=this.medplum.getProfile();this.currentProfile&&n===void 0?this.ws.close():n&&((r=this.currentProfile)==null?void 0:r.id)!==n.id&&this.ws.reconnect(),this.currentProfile=n})}emitError(t,n){var a;const r={type:"error",payload:n};(a=this.masterSubEmitter)==null||a.dispatchEvent(r),t.emitter.dispatchEvent({...r})}maybeEmitDisconnect(t){var r;const{subscriptionId:n}=t;if(n){const a={type:"disconnect",payload:{subscriptionId:n}};(r=this.masterSubEmitter)==null||r.dispatchEvent(a),t.emitter.dispatchEvent({...a})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}async getTokenForCriteria(t){var c,u;let n=t==null?void 0:t.subscriptionId;n||(n=(await this.medplum.createResource({...t.subscriptionProps,resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${zt(this.medplum.getProfile())}`,channel:{type:"websocket"},criteria:t.criteria})).id);const{parameter:r}=await this.medplum.get(`fhir/R4/Subscription/${n}/$get-ws-binding-token`),a=(c=r==null?void 0:r.find(f=>f.name==="token"))==null?void 0:c.valueString,o=(u=r==null?void 0:r.find(f=>f.name==="websocket-url"))==null?void 0:u.valueUrl;if(!a)throw new dt(yn("Failed to get token"));if(!o)throw new dt(yn("Failed to get URL from $get-ws-binding-token"));return[n,a]}maybeGetCriteriaEntry(t,n){const r=this.criteriaEntries.get(t);if(r){if(!n)return r.bareCriteria;for(const a of r.criteriaWithProps)if(si(n,a.subscriptionProps))return a}}getAllCriteriaEmitters(){const t=[];for(const n of this.criteriaEntries.values()){n.bareCriteria&&t.push(n.bareCriteria.emitter);for(const r of n.criteriaWithProps)t.push(r.emitter)}return t}addCriteriaEntry(t){const{criteria:n,subscriptionProps:r}=t;let a;this.criteriaEntries.has(n)?a=this.criteriaEntries.get(n):(a={criteriaWithProps:[]},this.criteriaEntries.set(n,a)),r?a.criteriaWithProps.push(t):a.bareCriteria=t}removeCriteriaEntry(t){var u;const{criteria:n,subscriptionProps:r,subscriptionId:a,token:o}=t;if(!this.criteriaEntries.has(n))return;const c=this.criteriaEntries.get(n);r?c.criteriaWithProps=c.criteriaWithProps.filter(f=>{const p=f.subscriptionProps;return!si(r,p)}):c.bareCriteria=void 0,!c.bareCriteria&&c.criteriaWithProps.length===0&&(this.criteriaEntries.delete(n),(u=this.masterSubEmitter)==null||u._removeCriteria(n)),a&&this.criteriaEntriesBySubscriptionId.delete(a),o&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"unbind-from-token",payload:{token:o}}))}async subscribeToCriteria(t){if(!(this.ws.readyState!==WebSocket.OPEN||t.connecting)){t.connecting=!0;try{const[n,r]=await this.getTokenForCriteria(t);t.subscriptionId=n,t.token=r,this.criteriaEntriesBySubscriptionId.set(n,t),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:r}}))}catch(n){console.error(Xe(n)),this.emitError(t,n),this.removeCriteriaEntry(t)}}}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();for(const t of this.criteriaEntries.values())for(const n of[...t.bareCriteria?[t.bareCriteria]:[],...t.criteriaWithProps])n.clearAttachedSubscription(),await this.subscribeToCriteria(n)}addCriteria(t,n){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const r=this.maybeGetCriteriaEntry(t,n);if(r)return r.refCount+=1,r.emitter;const a=new LB(t,n);return this.addCriteriaEntry(a),this.subscribeToCriteria(a).catch(console.error),a.emitter}removeCriteria(t,n){const r=this.maybeGetCriteriaEntry(t,n);if(!r){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}r.refCount-=1,!(r.refCount>0)&&(this.maybeEmitDisconnect(r),this.removeCriteriaEntry(r))}getWebSocket(){return this.ws}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new My(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const zA="4.1.8-a7cfaf522",$B=hn.FHIR_JSON+", */*; q=0.1",UB="https://api.medplum.com/",BB=1e3,VB=6e4,FB=0,HB=3e5,qB="Binary/",xE={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]},Yl={ClientCredentials:"client_credentials",AuthorizationCode:"authorization_code",RefreshToken:"refresh_token",JwtBearer:"urn:ietf:params:oauth:grant-type:jwt-bearer",TokenExchange:"urn:ietf:params:oauth:grant-type:token-exchange"},GB={AccessToken:"urn:ietf:params:oauth:token-type:access_token"},QB={JwtBearer:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"};class $A extends Yp{constructor(t){if(super(),this.initComplete=!0,t!=null&&t.baseUrl&&!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");this.options=t??{},this.fetch=(t==null?void 0:t.fetch)??WB(),this.storage=(t==null?void 0:t.storage)??new PB,this.createPdfImpl=t==null?void 0:t.createPdf,this.baseUrl=X0((t==null?void 0:t.baseUrl)??UB),this.fhirBaseUrl=Xa(this.baseUrl,(t==null?void 0:t.fhirUrlPath)??"fhir/R4"),this.authorizeUrl=Xa(this.baseUrl,(t==null?void 0:t.authorizeUrl)??"oauth2/authorize"),this.tokenUrl=Xa(this.baseUrl,(t==null?void 0:t.tokenUrl)??"oauth2/token"),this.logoutUrl=Xa(this.baseUrl,(t==null?void 0:t.logoutUrl)??"oauth2/logout"),this.fhircastHubUrl=Xa(this.baseUrl,(t==null?void 0:t.fhircastHubUrl)??"fhircast/STU3"),this.clientId=(t==null?void 0:t.clientId)??"",this.clientSecret=(t==null?void 0:t.clientSecret)??"",this.credentialsInHeader=(t==null?void 0:t.authCredentialsMethod)==="header",this.defaultHeaders=(t==null?void 0:t.defaultHeaders)??{},this.onUnauthenticated=t==null?void 0:t.onUnauthenticated,this.refreshGracePeriod=(t==null?void 0:t.refreshGracePeriod)??HB,this.cacheTime=(t==null?void 0:t.cacheTime)??(typeof window>"u"?FB:VB),this.cacheTime>0?this.requestCache=new XD((t==null?void 0:t.resourceCacheSize)??BB):this.requestCache=void 0,t!=null&&t.autoBatchTime?(this.autoBatchTime=t.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),t!=null&&t.accessToken&&this.setAccessToken(t.accessToken),this.storage.getInitPromise===void 0?(t!=null&&t.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initPromise=Promise.resolve(),this.dispatchEvent({type:"storageInitialized"})):(this.initComplete=!1,this.initPromise=this.storage.getInitPromise(),this.initPromise.then(()=>{t!=null&&t.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:"storageInitialized"})}).catch(n=>{console.error(n),this.initComplete=!0,this.dispatchEvent({type:"storageInitFailed",payload:{error:n}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}async attemptResumeActiveLogin(){const t=this.getActiveLogin();t&&(this.setAccessToken(t.accessToken,t.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.clear(),typeof window<"u"&&sessionStorage.clear(),this.clearActiveLogin()}clearActiveLogin(){var t;this.storage.setString("activeLogin",void 0),(t=this.requestCache)==null||t.clear(),this.accessToken=void 0,this.refreshToken=void 0,this.refreshPromise=void 0,this.accessTokenExpires=void 0,this.sessionDetails=void 0,this.medplumServer=void 0,this.dispatchEvent({type:"change"})}invalidateUrl(t){var n;t=t.toString(),(n=this.requestCache)==null||n.delete(t)}invalidateAll(){var t;(t=this.requestCache)==null||t.clear()}invalidateSearches(t){const n=Xa(this.fhirBaseUrl,t);if(this.requestCache)for(const r of this.requestCache.keys())(r.endsWith(n)||r.includes(n+"?"))&&this.requestCache.delete(r)}get(t,n={}){t=t.toString();const r=this.getCacheEntry(t,n);if(r)return r.value;let a;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!n.disableAutoBatch?a=new Promise((c,u)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:c,reject:u}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):a=this.request("GET",t,n);const o=new Aa(a);return this.setCacheEntry(t,o),o}post(t,n,r,a={}){return t=t.toString(),this.setRequestBody(a,n),r&&this.setRequestContentType(a,r),this.invalidateUrl(t),this.request("POST",t,a)}put(t,n,r,a={}){return t=t.toString(),this.setRequestBody(a,n),r&&this.setRequestContentType(a,r),this.invalidateUrl(t),this.request("PUT",t,a)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,hn.JSON_PATCH),this.invalidateUrl(t),this.request("PATCH",t,r)}delete(t,n){return t=t.toString(),this.invalidateUrl(t),this.request("DELETE",t,n)}async startNewUser(t,n){const{codeChallengeMethod:r,codeChallenge:a}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:a},void 0,n)}async startNewProject(t,n){return this.post("auth/newproject",t,void 0,n)}async startNewPatient(t,n){return this.post("auth/newpatient",t,void 0,n)}async startLogin(t,n){return this.post("auth/login",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async startGoogleLogin(t,n){return this.post("auth/google",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async ensureCodeChallenge(t){return t.codeChallenge?t:{...t,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(t){const r=new URLSearchParams(window.location.search).get("code");if(!r){await this.requestAuthorization(t);return}return this.processCode(r)}signOutWithRedirect(){window.location.assign(this.logoutUrl)}async signInWithExternalAuth(t,n,r,a,o=!0){let c=a;o&&(c=await this.ensureCodeChallenge(a)),window.location.assign(this.getExternalAuthRedirectUri(t,n,r,c,o))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");return this.fetchTokens({grant_type:Yl.TokenExchange,subject_token_type:GB.AccessToken,client_id:n,subject_token:t})}getExternalAuthRedirectUri(t,n,r,a,o=!0){const c=new URL(t);if(c.searchParams.set("response_type","code"),c.searchParams.set("client_id",n),c.searchParams.set("redirect_uri",r),c.searchParams.set("scope",a.scope??"openid profile email"),c.searchParams.set("state",JSON.stringify(a)),o){const{codeChallenge:u,codeChallengeMethod:f}=a;if(!f)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!u)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");c.searchParams.set("code_challenge_method",f),c.searchParams.set("code_challenge",u)}return c.toString()}fhirUrl(...t){return new URL(Xa(this.fhirBaseUrl,t.join("/")))}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=H$(n)),r}search(t,n,r){const a=this.fhirSearchUrl(t,n),o="search-"+a.toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=this.getBundle(a,r);return this.setCacheEntry(o,u),u}searchOne(t,n,r){const a=this.fhirSearchUrl(t,n);a.searchParams.set("_count","1"),a.searchParams.sort();const o="searchOne-"+a.toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=new Aa(this.search(t,a.searchParams,r).then(f=>{var p,m;return(m=(p=f.entry)==null?void 0:p[0])==null?void 0:m.resource}));return this.setCacheEntry(o,u),u}searchResources(t,n,r){const o="searchResources-"+this.fhirSearchUrl(t,n).toString(),c=this.getCacheEntry(o,r);if(c)return c.value;const u=new Aa(this.search(t,n,r).then(wE));return this.setCacheEntry(o,u),u}async*searchResourcePages(t,n,r){var o,c;let a=this.fhirSearchUrl(t,n);for(;a;){const u=new URL(a).searchParams,f=await this.search(t,u,r),p=(o=f.link)==null?void 0:o.find(m=>m.relation==="next");if(!((c=f.entry)!=null&&c.length)&&!p)break;yield wE(f),a=p!=null&&p.url?new URL(p.url):void 0}}valueSetExpand(t,n){const r=this.fhirUrl("ValueSet","$expand");return r.search=new URLSearchParams(t).toString(),this.get(r.toString(),n)}getCached(t,n){var a,o;const r=(o=(a=this.requestCache)==null?void 0:a.get(this.fhirUrl(t,n).toString()))==null?void 0:o.value;return r!=null&&r.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return xE;const[r,a]=n.split("/");if(!(!r||!a))return this.getCached(r,a)}readResource(t,n,r){if(!n)throw new Error('The "id" parameter cannot be null, undefined, or an empty string.');return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Aa(Promise.reject(new Error("Missing reference")));if(r==="system")return new Aa(Promise.resolve(xE));const[a,o]=r.split("/");return!a||!o?new Aa(Promise.reject(new Error("Invalid reference"))):this.readResource(a,o,n)}requestSchema(t){if(iA(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const a=new Aa((async()=>{const o=`{
87
87
  StructureDefinitionList(_filter: "name eq ${t}") {
88
88
  resourceType,
89
89
  name,
@@ -578,4 +578,4 @@ Please change the parent <Route path="${D}"> to <Route path="${D==="/"?"*":`${D}
578
578
  }
579
579
  ]
580
580
  }`,_J="MSH|^~\\&|ADT1|MCM|LABADT|MCM|198808181126|SECURITY|ADT|MSG00001|P|2.1\rPID|||PATID1234^5^M11||JONES^WILLIAM^A^III||19610615|M-||C|1200 N ELM STREET^^GREENSBORO^NC^27401-1020|GL|(919)379-1212|(919)271-3434||S||PATID12345001^2^M10|123456789|987654^NC\rNK1|1|JONES^BARBARA^K|SPO|||||20011105\rPV1|1|I|2000^2012^01||||004777^LEBAUER^SIDNEY^J.|||SUR||-||1|A0-";function kJ(){const e=_e(),{id:t}=qt(),[n,r]=y.useState(),[a,o]=y.useState(),[c,u]=y.useState(AJ),[f,p]=y.useState(_J),[m,g]=y.useState(hn.FHIR_JSON),v=y.useRef(null),b=y.useRef(null),[S,j]=y.useState(!1);y.useEffect(()=>{e.readResource("Bot",t).then(async k=>{r(k),o(await PJ(e,k))}).catch(k=>Pe({color:"red",message:Xe(k),autoClose:!1}))},[e,t]);const C=y.useCallback(async()=>Qu(v.current,{command:"getValue"}),[]),R=y.useCallback(async()=>Qu(v.current,{command:"getOutput"}),[]),D=y.useCallback(async()=>m===hn.FHIR_JSON?JSON.parse(c):f,[m,c,f]),E=y.useCallback(async k=>{k.preventDefault(),k.stopPropagation(),j(!0);try{const M=await C(),L=await R(),$=await e.createAttachment({data:M,filename:"index.ts",contentType:"text/typescript"}),V=await e.createAttachment({data:L,filename:"index.js",contentType:"text/typescript"}),Y=[{op:"add",path:"/sourceCode",value:$},{op:"add",path:"/executableCode",value:V}];await e.patchResource("Bot",t,Y),Pe({color:"green",message:"Saved"})}catch(M){Pe({color:"red",message:Xe(M),autoClose:!1})}finally{j(!1)}},[e,t,C,R]),T=y.useCallback(async k=>{k.preventDefault(),k.stopPropagation(),j(!0);try{await e.post(e.fhirUrl("Bot",t,"$deploy")),Pe({color:"green",message:"Deployed"})}catch(M){Pe({color:"red",message:Xe(M),autoClose:!1})}finally{j(!1)}},[e,t]),A=y.useCallback(async k=>{k.preventDefault(),k.stopPropagation(),j(!0);try{const M=await D(),L=await e.post(e.fhirUrl("Bot",t,"$execute"),M,m);await Qu(b.current,{command:"setValue",value:L}),Pe({color:"green",message:"Success"})}catch(M){Pe({color:"red",message:Xe(M),autoClose:!1})}finally{j(!1)}},[e,t,D,m]);return!n||a===void 0?null:s.jsxs(or,{m:0,gutter:0,style:{overflow:"hidden"},children:[s.jsx(or.Col,{span:8,children:s.jsxs(mr,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",mih:400,children:[s.jsx(DJ,{iframeRef:v,language:"typescript",module:"commonjs",testId:"code-frame",defaultValue:a,minHeight:"528px"}),s.jsxs(je,{justify:"flex-end",gap:"xs",children:[s.jsx(Oe,{type:"button",onClick:E,loading:S,leftSection:s.jsx($V,{size:"1rem"}),children:"Save"}),s.jsx(Oe,{type:"button",onClick:T,loading:S,leftSection:s.jsx(fb,{size:"1rem"}),children:"Deploy"}),s.jsx(Oe,{type:"button",onClick:A,loading:S,leftSection:s.jsx(JV,{size:"1rem"}),children:"Execute"})]})]})}),s.jsxs(or.Col,{span:4,children:[s.jsxs(mr,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",children:[s.jsx(ln,{data:[{label:"FHIR",value:hn.FHIR_JSON},{label:"HL7",value:hn.HL7_V2}],onChange:k=>g(k.currentTarget.value)}),m===hn.FHIR_JSON?s.jsx(Dc,{value:c,onChange:k=>u(k),autosize:!0,minRows:15}):s.jsx("textarea",{className:TJ.hl7Input,value:f,onChange:k=>p(k.currentTarget.value),rows:15})]}),s.jsx(mr,{m:2,p:"xs",shadow:"md",children:s.jsx(RJ,{iframeRef:b,className:"medplum-bot-output-frame",testId:"output-frame",minHeight:"200px"})})]})]})}async function PJ(e,t){var n,r,a;if((n=t.sourceCode)!=null&&n.url){const o=(a=(r=t.sourceCode.url)==null?void 0:r.split("/"))==null?void 0:a.find(mA);return(await e.download(e.fhirUrl("Binary",o))).text()}return t.code??""}function il(e){let t=e.meta;return t&&(t={...t,lastUpdated:void 0,versionId:void 0,author:void 0}),{...e,meta:t}}function NJ(){const e=_e(),{resourceType:t,id:n}=qt(),r={reference:t+"/"+n},a=y.useCallback(o=>{e.updateResource(il(o)).then(()=>{Pe({color:"green",message:"Success"})}).catch(c=>{Pe({color:"red",message:Xe(c),autoClose:!1})})},[e]);switch(t){case"PlanDefinition":return s.jsx(ot,{children:s.jsx(MQ,{value:r,onSubmit:a})});case"Questionnaire":return s.jsx(ot,{children:s.jsx(wW,{questionnaire:r,onSubmit:a})});default:return null}}function OJ(){const{resourceType:e,id:t}=qt(),n=Qt({reference:e+"/"+t}),r=Rn();return n?s.jsx(ot,{children:s.jsx(QW,{value:n,onStart:(a,o)=>{var c;return(c=r(`/forms/${$s(o)}`))==null?void 0:c.catch(console.error)},onEdit:(a,o,c)=>{var u;return(u=r(`/${c.reference}}`))==null?void 0:u.catch(console.error)}})}):null}function MJ(){const e=_e(),{resourceType:t,id:n}=qt(),r=Rn();return s.jsxs(ot,{children:[s.jsxs("p",{children:["Are you sure you want to delete this ",t,"?"]}),s.jsx(Oe,{color:"red",onClick:()=>{e.deleteResource(t,n).then(()=>{var a;return(a=r(`/${t}`))==null?void 0:a.catch(console.error)}).catch(a=>Pe({color:"red",message:Xe(a),autoClose:!1}))},children:"Delete"})]})}const IJ="_selectProfileBtn_tbaz6_1",LJ="_chevron_tbaz6_13",GT={selectProfileBtn:IJ,chevron:LJ};function zJ(){var f,p;const{resourceType:e,id:t}=qt(),n=Qt({reference:e+"/"+t}),[r,a]=y.useState(),o=gd({onDropdownClose:()=>o.resetSelectedOption()}),c=y.useMemo(()=>{var m;if(En((m=n==null?void 0:n.meta)==null?void 0:m.profile))return[s.jsx(ct.Option,{value:"",children:"None"},""),...n.meta.profile.map(g=>s.jsx(ct.Option,{value:g,children:g},g))]},[(f=n==null?void 0:n.meta)==null?void 0:f.profile]);if(y.useEffect(()=>{var m,g;((g=(m=n==null?void 0:n.meta)==null?void 0:m.profile)==null?void 0:g.length)===1&&a(n.meta.profile[0])},[(p=n==null?void 0:n.meta)==null?void 0:p.profile]),!n)return null;let u;return En(c)&&(u=s.jsx(je,{justify:"flex-end",children:s.jsxs(We,{align:"flex-end",gap:"xs",children:[s.jsxs(ct,{store:o,width:250,position:"bottom-end",withinPortal:!1,onOptionSubmit:m=>{a(m),o.closeDropdown()},children:[s.jsx(ct.Target,{children:s.jsx(tr,{onClick:()=>o.toggleDropdown(),children:s.jsxs(l0,{fw:"bold",fs:"sm",className:GT.selectProfileBtn,children:[s.jsx("span",{children:"Pick profile"}),s.jsx(db,{stroke:1.5,className:GT.chevron})]})})}),s.jsx(ct.Dropdown,{w:"max-content",children:s.jsx(ct.Options,{children:c})})]}),s.jsx(ce,{children:r?s.jsxs(s.Fragment,{children:[s.jsx(De,{span:!0,size:"sm",c:"dimmed",children:"Displaying profile: "}),s.jsx(De,{span:!0,size:"sm",children:r||"Nothing selected"})]}):s.jsx(De,{span:!0,size:"sm",c:"dimmed",children:"No profile displayed"})})]})})),s.jsx(ot,{children:s.jsxs(We,{gap:"xl",children:[u,s.jsx(_b,{value:n,profileUrl:r})]})})}function $J(){const e=_e(),{resourceType:t,id:n}=qt(),[r,a]=y.useState(),[o,c]=y.useState(),u=Rn(),[f,p]=y.useState();y.useEffect(()=>{e.readResource(t,n).then(b=>{a(Qr(b)),c(Qr(b))}).catch(b=>{p(Zt(b)),Pe({color:"red",message:Xe(b),autoClose:!1})})},[e,t,n]);const m=y.useCallback(b=>{p(void 0),e.updateResource(il(b)).then(()=>{var S;(S=u(`/${t}/${n}/details`))==null||S.catch(console.error),Pe({id:"succes",color:"green",message:"Success"})}).catch(S=>{p(Zt(S)),Pe({color:"red",message:Xe(S),autoClose:!1})})},[e,t,n,u]),g=y.useCallback(b=>{p(void 0);const S=__.createPatch(r,b);e.patchResource(t,n,S).then(()=>{var j;(j=u(`/${t}/${n}/details`))==null||j.catch(console.error),Pe({id:"succes",color:"green",message:"Success"})}).catch(j=>{p(Zt(j)),Pe({color:"red",message:Xe(j),autoClose:!1})})},[e,t,n,r,u]),v=y.useCallback(()=>{var b;return(b=u(`/${t}/${n}/delete`))==null?void 0:b.catch(console.error)},[u,t,n]);return o?s.jsx(ot,{children:s.jsx(Wh,{defaultValue:o,onSubmit:m,onPatch:g,onDelete:v,outcome:f})}):null}function UJ(){const{resourceType:e,id:t}=qt(),n=Qt({reference:e+"/"+t});return n?s.jsx(ot,{maw:700,children:n.resourceType==="Patient"?s.jsx(AQ,{patient:n}):s.jsx(Yi,{icon:s.jsx(tl,{size:16}),title:"Unsupported export type",color:"red",children:"This page is only supported for Patient resources"})}):null}function Gk({resource:e,currentProfile:t,onChange:n}){const r=e.resourceType,a=_e(),[o,c]=y.useState();return y.useEffect(()=>{a.searchResources("StructureDefinition",{type:r,derivation:"constraint",_count:50}).then(u=>{c(u.filter(KH))}).catch(console.error)},[a,n,r]),s.jsx(Lt,{value:t==null?void 0:t.url,onChange:u=>{const f=o==null?void 0:o.find(p=>p.url===u);f&&n(f)},children:s.jsx(Lt.List,{children:o==null?void 0:o.map(u=>{var m,g;const f=(g=(m=e.meta)==null?void 0:m.profile)==null?void 0:g.includes(u.url),p=f?"This profile is present in this resource's meta.profile property.":"This profile is not included in this resource's meta.profile property.";return s.jsx(Lt.Tab,{value:u.url,title:p,rightSection:f&&s.jsx(F0,{variant:"outline",color:"green",size:"xs",style:{borderStyle:"none"},children:s.jsx(hF,{size:"90%"})}),children:u.title||u.name},u.url)})})})}function Qk(e,t){const n=_e(),r=Rn();return{defaultValue:{resourceType:e},handleSubmit:c=>{t&&t(void 0),n.createResource(c).then(u=>r("/"+u.resourceType+"/"+u.id)).catch(u=>{t&&t(Zt(u)),Pe({color:"red",message:Xe(u),autoClose:!1,styles:{description:{whiteSpace:"pre-line"}}})})}}}function uy(){const{resourceType:e}=qt(),t=Mr(),[n,r]=y.useState(),{defaultValue:a,handleSubmit:o}=Qk(e,r),[c,u]=y.useState(),f=t.pathname.toLowerCase().endsWith("profiles"),p=y.useCallback(m=>{const g=il(m);c&&bA(g,c.url),o(g)},[c,o]);return f?s.jsx(ot,{children:s.jsxs(We,{children:[s.jsx(Gk,{resource:a,currentProfile:c,onChange:u}),c?s.jsx(Wh,{defaultValue:a,onSubmit:p,outcome:n,profileUrl:c.url},c.url):s.jsx(De,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})}):s.jsx(ot,{children:s.jsx(Wh,{defaultValue:a,onSubmit:o,outcome:n})})}function BJ(){const e=_e(),{resourceType:t,id:n}=qt(),r=e.readHistory(t,n).read();return s.jsx(ot,{children:s.jsx(yY,{history:r})})}function VJ(){const{resourceType:e}=qt(),[t,n]=y.useState(),{defaultValue:r,handleSubmit:a}=Qk(e,n),o=y.useCallback(c=>{a(JSON.parse(c["new-resource"]))},[a]);return s.jsxs(ot,{children:[t&&s.jsx(ba,{outcome:t}),s.jsxs(pt,{onSubmit:o,children:[s.jsx(Dc,{name:"new-resource","data-testid":"create-resource-json",autosize:!0,minRows:24,defaultValue:Ia(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),s.jsx(je,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:s.jsx(Oe,{type:"submit",children:"OK"})})]})]})}function FJ(){const e=_e(),{resourceType:t,id:n}=qt(),r=Qt({reference:t+"/"+n}),a=Rn(),[o,c]=y.useState(),u=y.useCallback(f=>{e.updateResource(il(JSON.parse(f.resource))).then(()=>{var p;c(void 0),(p=a(`/${t}/${n}/details`))==null||p.catch(console.error),Pe({color:"green",message:"Success"})}).catch(p=>{Pe({color:"red",message:Xe(p),autoClose:!1})})},[e,t,n,a]);return r?s.jsxs(ot,{children:[o&&s.jsx(ba,{outcome:o}),s.jsxs(pt,{onSubmit:u,children:[s.jsx(Dc,{name:"resource","data-testid":"resource-json",autosize:!0,minRows:24,defaultValue:Ia(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),s.jsx(je,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:s.jsx(Oe,{type:"submit",children:"OK"})})]})]}):null}function HJ(){const{resourceType:e,id:t}=qt();return Qt({reference:e+"/"+t})?s.jsxs(ot,{children:[s.jsxs(Yi,{icon:s.jsx(tl,{size:16}),mb:"xl",children:["This is just a preview! Access your form here:",s.jsx("br",{}),s.jsx(Pt,{href:`/forms/${t}`,children:`/forms/${t}`})]}),s.jsx(nk,{questionnaire:{reference:e+"/"+t},onSubmit:()=>alert("You submitted the preview")})]}):null}function qJ(){const e=_e(),{resourceType:t,id:n}=qt(),[r,a]=y.useState(),[o,c]=y.useState();return y.useEffect(()=>{e.readResource(t,n).then(u=>a(Qr(u))).catch(u=>{Pe({color:"red",message:Xe(u)})})},[e,t,n]),r?s.jsxs(ot,{children:[s.jsxs(Le,{order:2,children:["Available ",t," profiles"]}),s.jsx(We,{children:s.jsxs(s.Fragment,{children:[s.jsx(Gk,{resource:r,currentProfile:o,onChange:c}),o?s.jsx(GJ,{profile:o,resource:r,onResourceUpdated:u=>a(u)},o.url):s.jsx(De,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})})]}):null}const GJ=({profile:e,resource:t,onResourceUpdated:n})=>{const r=_e(),[a,o]=y.useState(),[c,u]=y.useState(()=>{var p,m;return(m=(p=t.meta)==null?void 0:p.profile)==null?void 0:m.includes(e.url)}),f=y.useCallback(p=>{o(void 0);const m=il(p);c?bA(m,e.url):q$(m,e.url),r.updateResource(m).then(g=>{n(g),Pe({color:"green",message:"Success"})}).catch(g=>{o(Zt(g)),Pe({color:"red",message:Xe(g),autoClose:!1})})},[r,e.url,n,c]);return s.jsxs(We,{children:[s.jsx(Sd,{size:"md",checked:c,label:`Conform resource to ${e.title}`,onChange:p=>u(p.currentTarget.checked),"data-testid":"profile-toggle"}),c?s.jsx(Wh,{profileUrl:e.url,defaultValue:t,onSubmit:f,outcome:a}):s.jsx("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),f(t)},children:s.jsx(je,{justify:"flex-end",mt:"xl",children:s.jsx(Oe,{type:"submit",children:"OK"})})})]})},Wk={"Create Only":"create","Update Only":"update","Delete Only":"delete","All Interactions":void 0},QJ=Object.keys(Wk);function WJ(){const e=_e(),{id:t}=qt(),n=Qt({reference:`Questionnaire/${t}`}),[r,a]=y.useState(),[o,c]=y.useState("create"),[u,f]=y.useState(0),p=e.searchResources("Subscription","status=active&_count=100").read().filter(g=>YJ(g,n));function m(){r&&n&&e.createResource({resourceType:"Subscription",status:"active",reason:`Connect bot ${r.name} to questionnaire responses`,criteria:`QuestionnaireResponse?questionnaire=${n.url?`${n.url},${zt(n)}`:zt(n)}`,channel:{type:"rest-hook",endpoint:zt(r)},...o?{extension:[{url:"https://medplum.com/fhir/StructureDefinition/subscription-supported-interaction",valueCode:o}]}:void 0}).then(()=>{a(void 0),f(Date.now()),e.invalidateSearches("Subscription"),Pe({color:"green",message:"Success"})}).catch(g=>Pe({color:"red",message:Xe(g),autoClose:!1}))}return s.jsxs(ot,{children:[s.jsx(Le,{children:"Bots"}),s.jsxs(We,{children:[p.length===0&&s.jsx("p",{children:"No bots found."}),p.map(g=>{var v;return s.jsxs("div",{children:[s.jsx("h3",{children:s.jsx(Ic,{value:{reference:(v=g.channel)==null?void 0:v.endpoint},link:!0})}),s.jsxs("p",{children:["Criteria: ",g.criteria]})]},g.id)})]}),s.jsx(jn,{}),s.jsxs(We,{mt:10,children:[s.jsx(fd,{size:"lg",htmlFor:"bot",children:"Connect to bot"}),s.jsxs(je,{children:[s.jsx(nl,{name:"bot",resourceType:"Bot",onChange:g=>a(g)}),s.jsx(Oe,{onClick:m,children:"Connect"})]}),s.jsx(je,{children:s.jsx(ln,{name:"subscription-trigger-event",defaultValue:"Create Only",label:"Subscription Trigger Event",data:QJ,onChange:g=>c(Wk[g.target.value])})})]}),s.jsx("div",{style:{display:"none"},children:u})]})}function YJ(e,t){var a;if(!t)return!1;const n=e.criteria||"",r=((a=e.channel)==null?void 0:a.endpoint)||"";return n.startsWith("QuestionnaireResponse?")&&r.startsWith("Bot/")&&(n.includes(zt(t))||(t.url?n.includes(t.url):!1))}function KJ(){const{id:e}=qt(),t=Rn(),r=_e().readReference({reference:`Questionnaire/${e}`}).read(),[a,o]=y.useState({resourceType:"QuestionnaireResponse",filters:[{code:"questionnaire",operator:de.EQUALS,value:r.url?`${r.url},Questionnaire/${e}`:`Questionnaire/${e}`}],fields:["id","_lastUpdated"]});return s.jsx(ot,{children:s.jsx(Id,{search:a,onClick:c=>{var u;return(u=t(`/${c.resource.resourceType}/${c.resource.id}`))==null?void 0:u.catch(console.error)},onChange:c=>o(c.definition),hideFilters:!0,hideToolbar:!0})})}function XJ(){const e=_e(),{resourceType:t,id:n}=qt(),r=Qt({reference:t+"/"+n}),a=y.useCallback(o=>{e.updateResource(il(o)).then(()=>{Pe({color:"green",message:"Success"})}).catch(c=>{Pe({color:"red",message:Xe(c),autoClose:!1})})},[e]);return r?s.jsx(ot,{children:s.jsx($W,{onSubmit:a,definition:r})}):null}function ZJ(){const{resourceType:e,id:t}=qt(),n=Qt({reference:e+"/"+t});return n?s.jsx(ot,{children:e==="MeasureReport"?s.jsx(RQ,{measureReport:n}):s.jsx(Ab,{value:n})}):null}const JJ="_container_1ue98_1",eee="_entry_1ue98_14",tee="_active_1ue98_21",dy={container:JJ,entry:eee,active:tee};function nee(e){const t=_e(),n=Qt(e.value),[r,a]=y.useState();return y.useEffect(()=>{if(!n)return;const o=e1(n);if(!o)return;const c="reference"in o?o.reference:zt(o);t.search("ServiceRequest","subject="+c).then(u=>{const p=(u.entry??[]).map(m=>m.resource);k_(p),p.reverse(),a(p)}).catch(u=>Pe({color:"red",message:Xe(u),autoClose:!1}))},[t,n]),r?s.jsx("div",{"data-testid":"quick-service-requests",className:dy.container,children:r.map(o=>{var c,u,f,p,m,g,v;return s.jsxs("div",{className:Ut(dy.entry,{[dy.active]:o.id===(n==null?void 0:n.id)}),children:[s.jsx("p",{children:s.jsx(bt,{to:o,children:ree(o)})}),((u=(c=o.category)==null?void 0:c[0])==null?void 0:u.text)&&s.jsx("p",{children:(f=o.category[0])==null?void 0:f.text}),((g=(m=(p=o.code)==null?void 0:p.coding)==null?void 0:m[0])==null?void 0:g.code)&&s.jsx("p",{children:(v=o.code.coding[0])==null?void 0:v.code}),s.jsx("p",{children:aee(o)})]},o.id)})}):null}function ree(e){if(e.identifier){for(const t of e.identifier)if(t.value)return t.value}return e.id||""}function aee(e){var t;return e.authoredOn?e.authoredOn.substring(0,10):(t=e.meta)!=null&&t.lastUpdated?e.meta.lastUpdated.substring(0,10):""}const iee="_container_1l2dh_1",oee={container:iee};function see(e){var a,o,c,u;const t=Qt(e.valueSet);if(!t)return null;const n=[""],r=(u=(c=(o=(a=t.compose)==null?void 0:a.include)==null?void 0:o[0])==null?void 0:c.concept)==null?void 0:u.map(f=>f.code);return r&&n.push(...r),e.defaultValue&&!n.includes(e.defaultValue)&&n.push(e.defaultValue),s.jsx("div",{className:oee.container,children:s.jsx(ln,{defaultValue:e.defaultValue,onChange:f=>e.onChange(f.currentTarget.value),data:n})})}function lee(e){var n,r;const t=Qt(e.specimen);return t?s.jsxs(ht,{children:[s.jsxs(ht.Entry,{children:[s.jsx(ht.Key,{children:"Type"}),s.jsx(ht.Value,{children:"Specimen"})]}),s.jsxs(ht.Entry,{children:[s.jsx(ht.Key,{children:"Collected"}),s.jsx(ht.Value,{children:gr((n=t.collection)==null?void 0:n.collectedDateTime)})]}),s.jsxs(ht.Entry,{children:[s.jsx(ht.Key,{children:"Specimen Age"}),s.jsx(ht.Value,{children:cee(t)})]}),(r=t.collection)!=null&&r.collectedDateTime&&t.receivedTime?s.jsxs(ht.Entry,{children:[s.jsx(ht.Key,{children:"Specimen Stability"}),s.jsx(ht.Value,{children:uee(t)})]}):s.jsx(s.Fragment,{})]}):null}function cee(e){var a;const t=(a=e.collection)==null?void 0:a.collectedDateTime;if(!t)return;const n=new Date(t);return Yk(Kk(n,new Date))}function uee(e){var r;if(!((r=e.collection)!=null&&r.collectedDateTime)||!e.receivedTime)return;const t=new Date(e.collection.collectedDateTime),n=new Date(e.receivedTime);return Yk(Kk(t,n))}function Yk(e){return e.toString().padStart(3,"0")+"D"}function Kk(e,t){const n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function dee(e){const t=["Timeline"];return e==="Bot"&&t.push("Editor","Subscriptions"),e==="PlanDefinition"&&t.push("Apply","Builder"),e==="Questionnaire"&&t.push("Preview","Builder","Bots","Responses"),(e==="DiagnosticReport"||e==="MeasureReport")&&t.push("Report"),e==="RequestGroup"&&t.push("Checklist"),e==="ObservationDefinition"&&t.push("Ranges"),e==="Agent"&&t.push("Tools"),t.push("Details","Edit","Event","History","Blame","JSON","Apps","Profiles"),e==="Patient"&&t.push("Export"),t}function fee(){var D,E,T,A,k,M,L;const e=_e(),{resourceType:t,id:n}=qt(),r={reference:t+"/"+n},a=Rn(),[o,c]=y.useState(),u=Qt(r,c),f=dee(t),[p,m]=y.useState(()=>{const $=window.location.pathname.split("/").pop();return $&&f.map(V=>V.toLowerCase()).includes($)?$:f[0].toLowerCase()});async function g(){var Y,Q;const V=(Q=(Y=(await e.readHistory(t,n)).entry)==null?void 0:Y.find(J=>!!J.resource))==null?void 0:Q.resource;V?v(V):Pe({color:"red",message:"No history to restore",autoClose:!1})}function v($){e.updateResource(il($)).then(()=>{c(void 0),Pe({color:"green",message:"Success"})}).catch(V=>{Pe({color:"red",message:Xe(V),autoClose:!1})})}if(o)return Jz(o)?s.jsxs(ot,{children:[s.jsx(Le,{children:"Deleted"}),s.jsx("p",{children:"The resource was deleted."}),s.jsx(Oe,{color:"red",onClick:g,children:"Restore"})]}):s.jsx(ba,{outcome:o});function b($){var V;$||($=f[0].toLowerCase()),m($),(V=a(`/${t}/${n}/${$}`))==null||V.catch(console.error)}function S($){const V=u,Y=V.orderDetail||[];Y.length===0&&Y.push({}),Y[0].text!==$&&(Y[0].text=$,v({...V,orderDetail:Y}))}const j=u&&e1(u),C=u&&IZ(u),R=(T=(E=(D=e.getUserConfiguration())==null?void 0:D.option)==null?void 0:E.find($=>$.id==="statusValueSet"))==null?void 0:T.valueString;return s.jsxs(s.Fragment,{children:[(u==null?void 0:u.resourceType)==="ServiceRequest"&&R&&s.jsx(see,{valueSet:{reference:R},defaultValue:(k=(A=u.orderDetail)==null?void 0:A[0])==null?void 0:k.text,onChange:S},zt(u)+"-"+((L=(M=u.orderDetail)==null?void 0:M[0])==null?void 0:L.text)),u&&s.jsx(nee,{value:u}),u&&s.jsxs(mr,{children:[j&&s.jsx($_,{patient:j}),C&&s.jsx(lee,{specimen:C}),t!=="Patient"&&s.jsx(Vk,{resource:r}),s.jsx(Yr,{children:s.jsx(Lt,{value:p.toLowerCase(),onChange:b,children:s.jsx(Lt.List,{style:{whiteSpace:"nowrap",flexWrap:"nowrap"},children:f.map($=>s.jsx(Lt.Tab,{value:$.toLowerCase(),children:$},$))})})})]}),s.jsx(Qb,{})]})}function QT(){var R,D,E,T;const e=Rn(),{resourceType:t,id:n,versionId:r,tab:a}=qt(),o=_e(),[c,u]=y.useState(!0),[f,p]=y.useState(),[m,g]=y.useState();if(y.useEffect(()=>{g(void 0),u(!0),o.readHistory(t,n).then(A=>p(A)).then(()=>u(!1)).catch(A=>{g(A),u(!1)})},[o,t,n]),c)return s.jsx(ma,{});if(!f)return s.jsxs(ot,{children:[s.jsx(Le,{children:"Resource not found"}),s.jsx(bt,{to:`/${t}`,children:"Return to search page"})]});const v=f.entry??[],b=v.findIndex(A=>{var k,M;return((M=(k=A.resource)==null?void 0:k.meta)==null?void 0:M.versionId)===r});if(b===-1)return s.jsxs(ot,{children:[s.jsx(Le,{children:"Version not found"}),s.jsx(bt,{to:`/${t}/${n}`,children:"Return to resource"})]});const S=v[b].resource,j=b<v.length-1?v[b+1].resource:void 0,C="diff";return s.jsxs(Lt,{value:a||C,onChange:A=>{var k;return(k=e(`/${t}/${n}/_history/${r}/${A||C}`))==null?void 0:k.catch(console.error)},children:[s.jsxs(mr,{children:[s.jsx(kd,{fluid:!0,p:"md",children:s.jsx(De,{children:`${t} ${n}`})}),s.jsxs(Lt.List,{children:[s.jsx(Lt.Tab,{value:"diff",children:"Diff"}),s.jsx(Lt.Tab,{value:"raw",children:"Raw"})]})]}),s.jsxs(ot,{children:[m&&s.jsx("pre",{"data-testid":"error",children:JSON.stringify(m,void 0,2)}),s.jsx(Lt.Panel,{value:"diff",children:j?s.jsxs(s.Fragment,{children:[s.jsxs("ul",{children:[s.jsxs("li",{children:["Current: ",(R=S.meta)==null?void 0:R.versionId]}),s.jsxs("li",{children:["Previous:"," ",s.jsx(bt,{to:`/${t}/${n}/_history/${(D=j.meta)==null?void 0:D.versionId}`,children:(E=j.meta)==null?void 0:E.versionId})]})]}),s.jsx(pY,{original:j,revised:S})]}):s.jsxs(s.Fragment,{children:[s.jsxs("ul",{children:[s.jsxs("li",{children:["Current: ",(T=S.meta)==null?void 0:T.versionId]}),s.jsx("li",{children:"Previous: (none)"})]}),s.jsx("pre",{children:JSON.stringify(S,void 0,2)})]})}),s.jsx(Lt.Panel,{value:"raw",children:s.jsx("pre",{children:JSON.stringify(S,void 0,2)})})]})]})}function hee(){const{resourceType:e,id:t}=qt(),n=Rn(),[r,a]=y.useState({resourceType:"Subscription",filters:[{code:"url",operator:de.EQUALS,value:`${e}/${t}`}],fields:["id","criteria","status","_lastUpdated"]});return s.jsx(ot,{children:s.jsx(dQ,{search:r,onClick:o=>{var c;return(c=n(`/${o.resource.resourceType}/${o.resource.id}`))==null?void 0:c.catch(console.error)},onChange:o=>a(o.definition),hideFilters:!0})})}function pee(e){const t=_e(),{resource:n,opened:r,onClose:a}=e,[o,c]=y.useState(!1),[u,f]=y.useState(),[p,m]=y.useState(!1),g=y.useCallback(async()=>{if(n!=null&&n.id)try{await t.post(t.fhirUrl(n.resourceType,n.id,"$resend"),{subscription:o&&u?zt(u):void 0,verbose:p}),Pe({color:"green",message:"Done"}),a()}catch(v){Pe({color:"red",message:Xe(v),autoClose:!1})}},[t,n,a,o,u,p]);return s.jsx($n,{opened:r,onClose:a,title:"Resend Subscriptions",children:s.jsx(pt,{onSubmit:g,children:s.jsxs(We,{children:[s.jsx(Fn,{label:"Choose subscription (all subscriptions by default)",onChange:v=>c(v.currentTarget.checked)}),o&&s.jsx(nl,{name:"subscription",resourceType:"Subscription",placeholder:"Subscription",onChange:f}),s.jsx(Fn,{label:"Verbose mode",onChange:v=>m(v.currentTarget.checked)}),s.jsx(je,{justify:"flex-end",children:s.jsx(Oe,{type:"submit",children:"Resend"})})]})})})}function WT(){const e=_e(),t=Xp(),{resourceType:n,id:r}=qt(),a={reference:n+"/"+r},[o,c]=y.useState(),u=ip(!1);function f(D,E){return e.updateResource({...D,priority:E})}function p(D,E){f(D,"stat").then(E).catch(console.error)}function m(D,E){f(D,"routine").then(E).catch(console.error)}function g(D){t(`/${D.resourceType}/${D.id}`)}function v(D){t(`/${D.resourceType}/${D.id}/edit`)}function b(D){t(`/${D.resourceType}/${D.id}/delete`)}function S(D){c(D),u[1].open()}function j(D){var E;t(`/${D.resourceType}/${D.id}/_history/${(E=D.meta)==null?void 0:E.versionId}`)}function C(D,E){const T="aws-textract";Pe({id:T,title:"AWS Textract in Progress",message:"Extracting text... This may take a moment...",loading:!0,autoClose:!1}),e.post(e.fhirUrl(D.resourceType,D.id,"$aws-textract"),{}).then(()=>{E(),Ds({id:T,title:"AWS Textract Successful",message:"Text successfully extracted.",color:"green",icon:s.jsx(eo,{size:"1rem"}),loading:!1,withCloseButton:!0})}).catch(A=>Ds({id:T,title:"AWS Textract Error",color:"red",message:Xe(A),icon:s.jsx(Vs,{size:"1rem"}),loading:!1,withCloseButton:!0}))}function R(D){var P;const{primaryResource:E,currentResource:T,reloadTimeline:A}=D,k=T.resourceType===E.resourceType&&T.id===E.id,M=T.resourceType==="Communication"&&T.priority!=="stat",L=T.resourceType==="Communication"&&T.priority==="stat",$=k,V=!k,Y=!k,Q=!k,J=(P=e.getProjectMembership())==null?void 0:P.admin,G=J,Z=WZ()&&(T.resourceType==="DocumentReference"||T.resourceType==="Media");return s.jsxs(we.Dropdown,{children:[s.jsx(we.Label,{children:"Resource"}),M&&s.jsx(we.Item,{leftSection:s.jsx(XV,{size:14}),onClick:()=>p(T,A),"aria-label":`Pin ${zt(T)}`,children:"Pin"}),L&&s.jsx(we.Item,{leftSection:s.jsx(ZV,{size:14}),onClick:()=>m(T,A),"aria-label":`Unpin ${zt(T)}`,children:"Unpin"}),V&&s.jsx(we.Item,{leftSection:s.jsx(kE,{size:14}),onClick:()=>g(T),"aria-label":`Details ${zt(T)}`,children:"Details"}),$&&s.jsx(we.Item,{leftSection:s.jsx(kE,{size:14}),onClick:()=>j(T),"aria-label":`Details ${zt(T)}`,children:"Details"}),Y&&s.jsx(we.Item,{leftSection:s.jsx(YA,{size:14}),onClick:()=>v(T),"aria-label":`Edit ${zt(T)}`,children:"Edit"}),J&&s.jsxs(s.Fragment,{children:[s.jsx(we.Divider,{}),s.jsx(we.Label,{children:"Admin"}),G&&s.jsx(we.Item,{leftSection:s.jsx(rF,{size:14}),onClick:()=>S(T),"aria-label":`Resend Subscriptions ${zt(T)}`,children:"Resend Subscriptions"})]}),Z&&s.jsxs(s.Fragment,{children:[s.jsx(we.Divider,{}),s.jsx(we.Label,{children:"AWS AI"}),s.jsx(we.Item,{leftSection:s.jsx(dF,{size:14}),onClick:()=>C(T,A),"aria-label":`AWS Textract ${zt(T)}`,children:"AWS Textract"})]}),Q&&s.jsxs(s.Fragment,{children:[s.jsx(we.Divider,{}),s.jsx(we.Label,{children:"Danger zone"}),s.jsx(we.Item,{color:"red",leftSection:s.jsx(mb,{size:14}),onClick:()=>b(T),"aria-label":`Delete ${zt(T)}`,children:"Delete"})]})]})}return s.jsxs(s.Fragment,{children:[n==="Encounter"&&s.jsx(xG,{encounter:a,getMenu:R}),n==="Patient"&&s.jsx(PQ,{patient:a,getMenu:R}),n==="ServiceRequest"&&s.jsx(SY,{serviceRequest:a,getMenu:R}),n!=="Encounter"&&n!=="Patient"&&n!=="ServiceRequest"&&s.jsx(yG,{resource:a,getMenu:R}),s.jsx(pee,{resource:o,opened:u[0],onClose:u[1].close},`resend-subscriptions-${o==null?void 0:o.id}`)]})}function mee(e){const{opened:t,close:n,version:r,loadingStatus:a,handleStatus:o,handleUpgrade:c}=e,[u,f]=y.useState();return y.useEffect(()=>{t&&(u||dV("app-tools-page").then(f).catch(console.error),o())},[t,u,o]),u&&r&&!a?r==="unknown"?s.jsx("p",{children:"Unable to determine the current version of the agent. Check the network connectivity of the agent."}):r.startsWith(u)?s.jsxs("p",{children:["This agent is already on the latest version (",u,")."]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{children:["Are you sure you want to upgrade this agent from version ",r," to version ",u,"?"]}),s.jsx(Oe,{onClick:()=>{c(),n()},"aria-label":"Confirm upgrade",children:"Confirm Upgrade"})]}):s.jsx(ma,{})}function gee(){const e=_e(),{id:t}=qt(),n=y.useMemo(()=>({reference:"Agent/"+t}),[t]),[r,a]=y.useState(!1),[o,c]=y.useState(!1),[u,f]=y.useState(!1),[p,m]=y.useState(),[g,v]=y.useState(),[b,S]=y.useState(),[j,C]=y.useState(),[R,D]=y.useState(!1),[E,T]=y.useState(!1),[A,{open:k,close:M}]=ip(!1);y.useEffect(()=>{if(r||o||u||R){T(!0);return}T(!1)},[r,o,u,R]);const L=y.useCallback(()=>{a(!0),e.get(e.fhirUrl("Agent",t,"$status"),{cache:"reload"}).then(G=>{var Z,P,I,z,H,O;m((P=(Z=G.parameter)==null?void 0:Z.find(U=>U.name==="status"))==null?void 0:P.valueCode),v((z=(I=G.parameter)==null?void 0:I.find(U=>U.name==="version"))==null?void 0:z.valueString),S((O=(H=G.parameter)==null?void 0:H.find(U=>U.name==="lastUpdated"))==null?void 0:O.valueInstant)}).catch(G=>J(Xe(G))).finally(()=>a(!1))},[e,t]),$=y.useCallback(G=>{const Z=G.host,P=G.pingCount||1;Z&&(D(!0),e.pushToAgent(n,Z,`PING ${P}`,hn.PING,!0).then(I=>C(I)).catch(I=>J(Xe(I))).finally(()=>D(!1)))},[e,n]),V=y.useCallback(()=>{c(!0),e.get(e.fhirUrl("Agent",t,"$reload-config"),{cache:"reload"}).then(G=>{Q("Agent config reloaded successfully.")}).catch(G=>J(Xe(G))).finally(()=>c(!1))},[e,t]),Y=y.useCallback(()=>{f(!0),e.get(e.fhirUrl("Agent",t,"$upgrade"),{cache:"reload"}).then(G=>{Q("Agent upgraded successfully.")}).catch(G=>J(Xe(G))).finally(()=>f(!1))},[e,t]);function Q(G){Pe({color:"green",title:"Success",icon:s.jsx(eo,{size:"1rem"}),message:G})}function J(G){Pe({color:"red",title:"Error",message:G,autoClose:!1})}return s.jsxs(ot,{children:[s.jsx($n,{opened:A,onClose:M,title:"Upgrade Agent",centered:!0,children:s.jsx(mee,{opened:A,close:M,version:g,loadingStatus:r,handleStatus:L,handleUpgrade:Y})}),s.jsx(Le,{order:1,children:"Agent Tools"}),s.jsxs("div",{style:{marginBottom:10},children:["Agent: ",s.jsx(Ic,{value:n,link:!0})]}),s.jsx(jn,{my:"lg"}),s.jsx(Le,{order:2,children:"Agent Status"}),s.jsx("p",{children:"Retrieve the status of the agent. This tests whether the agent is connected to the Medplum server, and the last time it was able to communicate."}),s.jsx(Oe,{onClick:L,loading:r,disabled:E&&!r,children:"Get Status"}),!r&&p&&s.jsx(Me,{children:s.jsxs(Me.Tbody,{children:[s.jsxs(Me.Tr,{children:[s.jsx(Me.Td,{children:"Status"}),s.jsx(Me.Td,{children:s.jsx(nm,{status:p})})]}),s.jsxs(Me.Tr,{children:[s.jsx(Me.Td,{children:"Version"}),s.jsx(Me.Td,{children:g})]}),s.jsxs(Me.Tr,{children:[s.jsx(Me.Td,{children:"Last Updated"}),s.jsx(Me.Td,{children:gr(b,void 0,{timeZoneName:"longOffset"})})]})]})}),s.jsx(jn,{my:"lg"}),s.jsx(Le,{order:2,children:"Reload Config"}),s.jsx("p",{children:"Reload the configuration of this agent, syncing it with the current version of the Agent resource on the Medplum server."}),s.jsx(Oe,{onClick:V,loading:o,disabled:E&&!o,"aria-label":"Reload config",children:"Reload Config"}),s.jsx(jn,{my:"lg"}),s.jsx(Le,{order:2,children:"Upgrade Agent"}),s.jsx("p",{children:"Upgrade the version of this agent, to either the latest (default) or a specified version."}),s.jsx(Oe,{onClick:k,loading:u,disabled:E&&!u,"aria-label":"Upgrade agent",children:"Upgrade"}),s.jsx(jn,{my:"lg"}),s.jsx(Le,{order:2,children:"Ping from Agent"}),s.jsx("p",{children:"Send a ping command from the agent to a valid IP address or hostname. Use this tool to troubleshoot local network connectivity."}),s.jsx(pt,{onSubmit:$,children:s.jsxs(je,{children:[s.jsx(ze,{id:"host",name:"host",placeholder:"ex. 127.0.0.1",label:"IP Address / Hostname",rightSection:s.jsx(_n,{size:24,radius:"xl",variant:"filled",type:"submit","aria-label":"Ping",loading:R,disabled:E&&!R,children:s.jsx(iF,{style:{width:"1rem",height:"1rem"},stroke:1.5})})}),s.jsx(Op,{id:"pingCount",name:"pingCount",placeholder:"1",label:"Ping Count"})]})}),!R&&j&&s.jsxs(s.Fragment,{children:[s.jsx(Le,{order:5,mt:"sm",mb:0,children:"Last Ping"}),s.jsx("pre",{children:j})]})]})}function vee(){return s.jsx(JK,{children:s.jsxs(He,{errorElement:s.jsx(MZ,{}),children:[s.jsx(He,{path:"/signin",element:s.jsx(eJ,{})}),s.jsx(He,{path:"/oauth",element:s.jsx(YZ,{})}),s.jsx(He,{path:"/resetpassword",element:s.jsx(XZ,{})}),s.jsx(He,{path:"/setpassword/:id/:secret",element:s.jsx(JZ,{})}),s.jsx(He,{path:"/register",element:s.jsx(KZ,{})}),s.jsx(He,{path:"/changepassword",element:s.jsx(PZ,{})}),s.jsx(He,{path:"/security",element:s.jsx(ZZ,{})}),s.jsx(He,{path:"/mfa",element:s.jsx(QZ,{})}),s.jsx(He,{path:"/batch",element:s.jsx(_Z,{})}),s.jsx(He,{path:"/bulk/:resourceType",element:s.jsx(kZ,{})}),s.jsx(He,{path:"/smart",element:s.jsx(tJ,{})}),s.jsx(He,{path:"/forms/:id",element:s.jsx(LZ,{})}),s.jsx(He,{path:"/admin/super",element:s.jsx(pJ,{})}),s.jsx(He,{path:"/admin/config",element:s.jsx(uJ,{})}),s.jsxs(He,{path:"/admin",element:s.jsx(dJ,{}),children:[s.jsx(He,{path:"patients",element:s.jsx(cJ,{})}),s.jsx(He,{path:"bots/new",element:s.jsx(aJ,{})}),s.jsx(He,{path:"bots",element:s.jsx(nJ,{})}),s.jsx(He,{path:"clients/new",element:s.jsx(iJ,{})}),s.jsx(He,{path:"clients",element:s.jsx(rJ,{})}),s.jsx(He,{path:"details",element:s.jsx(FT,{})}),s.jsx(He,{path:"invite",element:s.jsx(lJ,{})}),s.jsx(He,{path:"users",element:s.jsx(gJ,{})}),s.jsx(He,{path:"project",element:s.jsx(FT,{})}),s.jsx(He,{path:"secrets",element:s.jsx(fJ,{})}),s.jsx(He,{path:"sites",element:s.jsx(hJ,{})}),s.jsx(He,{path:"members/:membershipId",element:s.jsx(sJ,{})})]}),s.jsx(He,{path:"/lab/assays",element:s.jsx(vJ,{})}),s.jsx(He,{path:"/lab/panels",element:s.jsx(yJ,{})}),s.jsx(He,{path:"/:resourceType/:id/_history/:versionId/:tab",element:s.jsx(QT,{})}),s.jsx(He,{path:"/:resourceType/:id/_history/:versionId",element:s.jsx(QT,{})}),s.jsxs(He,{path:"/:resourceType/new",element:s.jsx(OZ,{}),children:[s.jsx(He,{index:!0,element:s.jsx(uy,{})}),s.jsx(He,{path:"form",element:s.jsx(uy,{})}),s.jsx(He,{path:"json",element:s.jsx(VJ,{})}),s.jsx(He,{path:"profiles",element:s.jsx(uy,{})})]}),s.jsxs(He,{path:"/:resourceType/:id",element:s.jsx(fee,{}),children:[s.jsx(He,{index:!0,element:s.jsx(WT,{})}),s.jsx(He,{path:"apply",element:s.jsx(bJ,{})}),s.jsx(He,{path:"apps",element:s.jsx(SJ,{})}),s.jsx(He,{path:"event",element:s.jsx(jJ,{})}),s.jsx(He,{path:"blame",element:s.jsx(CJ,{})}),s.jsx(He,{path:"bots",element:s.jsx(WJ,{})}),s.jsx(He,{path:"builder",element:s.jsx(NJ,{})}),s.jsx(He,{path:"checklist",element:s.jsx(OJ,{})}),s.jsx(He,{path:"delete",element:s.jsx(MJ,{})}),s.jsx(He,{path:"details",element:s.jsx(zJ,{})}),s.jsx(He,{path:"edit",element:s.jsx($J,{})}),s.jsx(He,{path:"editor",element:s.jsx(kJ,{})}),s.jsx(He,{path:"history",element:s.jsx(BJ,{})}),s.jsx(He,{path:"json",element:s.jsx(FJ,{})}),s.jsx(He,{path:"preview",element:s.jsx(HJ,{})}),s.jsx(He,{path:"responses",element:s.jsx(KJ,{})}),s.jsx(He,{path:"report",element:s.jsx(ZJ,{})}),s.jsx(He,{path:"ranges",element:s.jsx(XJ,{})}),s.jsx(He,{path:"subscriptions",element:s.jsx(hee,{})}),s.jsx(He,{path:"timeline",element:s.jsx(WT,{})}),s.jsx(He,{path:"tools",element:s.jsx(gee,{})}),s.jsx(He,{path:"profiles",element:s.jsx(qJ,{})}),s.jsx(He,{path:"export",element:s.jsx(UJ,{})})]}),s.jsx(He,{path:"/:resourceType",element:s.jsx(VT,{})}),s.jsx(He,{path:"/",element:s.jsx(VT,{})})]})})}function yee(){const e=_e(),t=e.getUserConfiguration(),n=Mr(),[r]=Kb();return e.isLoading()?s.jsx(ma,{}):s.jsx(iH,{logo:s.jsx(Ua,{size:24}),pathname:n.pathname,searchParams:r,version:zA,menus:xee(t),displayAddBookmark:!!(t!=null&&t.id),children:s.jsx(y.Suspense,{fallback:s.jsx(ma,{}),children:s.jsx(vee,{})})})}function xee(e){var n;const t=((n=e==null?void 0:e.menu)==null?void 0:n.map(r=>{var a;return{title:r.title,links:((a=r.link)==null?void 0:a.map(o=>({label:o.name,href:o.target,icon:bee(o.target)})))||[]}}))||[];return t.push({title:"Settings",links:[{label:"Security",href:"/security",icon:s.jsx(GV,{})}]}),t}const YT={Patient:lF,Practitioner:HV,Organization:OV,ServiceRequest:tF,DiagnosticReport:aF,Questionnaire:FV,admin:kV,AccessPolicy:qV,Subscription:fF,batch:KV,Observation:YV};function bee(e){try{const t=new URL(e,"https://app.medplum.com").pathname.split("/")[1];if(t in YT){const n=YT[t];return s.jsx(n,{})}}catch{}return s.jsx(Vp,{w:30})}"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.getRegistrations().then(e=>Promise.all(e.map(t=>t.unregister()))).catch(e=>console.error("SW registration failed: ",e))});async function See(){const e=Bd(),t=new $A({baseUrl:e.baseUrl,clientId:e.clientId,cacheTime:6e4,autoBatchTime:100,onUnauthenticated:()=>{window.location.pathname!=="/signin"&&window.location.pathname!=="/oauth"&&(window.location.href="/signin?next="+encodeURIComponent(window.location.pathname+window.location.search))}}),n={headings:{sizes:{h1:{fontSize:"1.125rem",fontWeight:"500",lineHeight:"2.0"}}},fontSizes:{xs:"0.6875rem",sm:"0.875rem",md:"0.875rem",lg:"1.0rem",xl:"1.125rem"}},r=CX([{path:"*",element:s.jsx(yee,{})}]),a=c=>r.navigate(c);RY.createRoot(document.getElementById("root")).render(s.jsx(y.StrictMode,{children:s.jsx(fV,{medplum:t,navigate:a,children:s.jsxs(bR,{theme:n,children:[s.jsx(Zi,{position:"bottom-right"}),s.jsx(YK,{router:r})]})})}))}See().catch(console.error);
581
- //# sourceMappingURL=index-Dm1ffk1H.js.map
581
+ //# sourceMappingURL=index-trEqgKyP.js.map