@medplum/app 3.0.12 → 3.0.13

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.
@@ -82,7 +82,7 @@ function fS(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
82
82
  Error generating stack: `+i.message+`
83
83
  `+i.stack}return{value:e,source:t,stack:o,digest:null}}function Gh(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function tm(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var g_=typeof WeakMap=="function"?WeakMap:Map;function RC(e,t,n){n=xo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){bd||(bd=!0,dm=r),tm(e,t)},n}function DC(e,t,n){n=xo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){tm(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){tm(e,t),typeof r!="function"&&(di===null?di=new Set([this]):di.add(this));var s=t.stack;this.componentDidCatch(t.value,{componentStack:s!==null?s:""})}),n}function Ax(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new g_;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=D_.bind(null,e,t,n),t.then(e,e))}function Nx(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Ox(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=xo(-1,1),t.tag=2,ui(n,t,1))),n.lanes|=1),e)}var y_=Oo.ReactCurrentOwner,Mn=!1;function wn(e,t,n,r){t.child=e===null?lC(t,null,n,r):xa(t,e.child,n,r)}function Mx(e,t,n,r,o){n=n.render;var i=t.ref;return fa(t,o),r=zg(e,t,n,r,i,o),n=Bg(),e!==null&&!Mn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,To(e,t,o)):(bt&&n&&kg(t),t.flags|=1,wn(e,t,r,o),t.child)}function Lx(e,t,n,r,o){if(e===null){var i=n.type;return typeof i=="function"&&!Xg(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,IC(e,t,i,r,o)):(e=qu(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&o)){var s=i.memoizedProps;if(n=n.compare,n=n!==null?n:Hl,n(s,r)&&e.ref===t.ref)return To(e,t,o)}return t.flags|=1,e=hi(i,r),e.ref=t.ref,e.return=t,t.child=e}function IC(e,t,n,r,o){if(e!==null){var i=e.memoizedProps;if(Hl(i,r)&&e.ref===t.ref)if(Mn=!1,t.pendingProps=r=i,(e.lanes&o)!==0)e.flags&131072&&(Mn=!0);else return t.lanes=e.lanes,To(e,t,o)}return nm(e,t,n,r,o)}function _C(e,t,n){var r=t.pendingProps,o=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},dt(ta,qn),qn|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,dt(ta,qn),qn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,dt(ta,qn),qn|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,dt(ta,qn),qn|=r;return wn(e,t,o,n),t.child}function AC(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function nm(e,t,n,r,o){var i=$n(n)?Yi:yn.current;return i=ya(t,i),fa(t,o),n=zg(e,t,n,r,i,o),r=Bg(),e!==null&&!Mn?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,To(e,t,o)):(bt&&r&&kg(t),t.flags|=1,wn(e,t,n,o),t.child)}function $x(e,t,n,r,o){if($n(n)){var i=!0;fd(t)}else i=!1;if(fa(t,o),t.stateNode===null)Vu(e,t),sC(t,n,r),em(t,n,r,o),r=!0;else if(e===null){var s=t.stateNode,l=t.memoizedProps;s.props=l;var c=s.context,u=n.contextType;typeof u=="object"&&u!==null?u=pr(u):(u=$n(n)?Yi:yn.current,u=ya(t,u));var d=n.getDerivedStateFromProps,f=typeof d=="function"||typeof s.getSnapshotBeforeUpdate=="function";f||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Rx(t,s,r,u),Yo=!1;var h=t.memoizedState;s.state=h,yd(t,r,s,o),c=t.memoizedState,l!==r||h!==c||Ln.current||Yo?(typeof d=="function"&&(Zp(t,n,d,r),c=t.memoizedState),(l=Yo||kx(t,n,l,r,h,c,u))?(f||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(t.flags|=4194308)):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),s.props=r,s.state=c,s.context=u,r=l):(typeof s.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{s=t.stateNode,oC(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Tr(t.type,l),s.props=u,f=t.pendingProps,h=s.context,c=n.contextType,typeof c=="object"&&c!==null?c=pr(c):(c=$n(n)?Yi:yn.current,c=ya(t,c));var m=n.getDerivedStateFromProps;(d=typeof m=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==f||h!==c)&&Rx(t,s,r,c),Yo=!1,h=t.memoizedState,s.state=h,yd(t,r,s,o);var g=t.memoizedState;l!==f||h!==g||Ln.current||Yo?(typeof m=="function"&&(Zp(t,n,m,r),g=t.memoizedState),(u=Yo||kx(t,n,u,r,h,g,c)||!1)?(d||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(r,g,c),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(r,g,c)),typeof s.componentDidUpdate=="function"&&(t.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof s.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=g),s.props=r,s.state=g,s.context=c,r=u):(typeof s.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return rm(e,t,n,r,i,o)}function rm(e,t,n,r,o,i){AC(e,t);var s=(t.flags&128)!==0;if(!r&&!s)return o&&Cx(t,n,!1),To(e,t,i);r=t.stateNode,y_.current=t;var l=s&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&s?(t.child=xa(t,e.child,null,i),t.child=xa(t,null,l,i)):wn(e,t,l,i),t.memoizedState=r.state,o&&Cx(t,n,!0),t.child}function NC(e){var t=e.stateNode;t.pendingContext?bx(e,t.pendingContext,t.pendingContext!==t.context):t.context&&bx(e,t.context,!1),Mg(e,t.containerInfo)}function Fx(e,t,n,r,o){return va(),Dg(o),t.flags|=256,wn(e,t,n,r),t.child}var om={dehydrated:null,treeContext:null,retryLane:0};function im(e){return{baseLanes:e,cachePool:null,transitions:null}}function OC(e,t,n){var r=t.pendingProps,o=Et.current,i=!1,s=(t.flags&128)!==0,l;if((l=s)||(l=e!==null&&e.memoizedState===null?!1:(o&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),dt(Et,o&1),e===null)return Xp(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(s=r.children,e=r.fallback,i?(r=t.mode,i=t.child,s={mode:"hidden",children:s},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=s):i=uf(s,r,0,null),e=Qi(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=im(n),t.memoizedState=om,e):Wg(t,s));if(o=e.memoizedState,o!==null&&(l=o.dehydrated,l!==null))return v_(e,t,s,r,l,o,n);if(i){i=r.fallback,s=t.mode,o=e.child,l=o.sibling;var c={mode:"hidden",children:r.children};return!(s&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=hi(o,c),r.subtreeFlags=o.subtreeFlags&14680064),l!==null?i=hi(l,i):(i=Qi(i,s,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,s=e.child.memoizedState,s=s===null?im(n):{baseLanes:s.baseLanes|n,cachePool:null,transitions:s.transitions},i.memoizedState=s,i.childLanes=e.childLanes&~n,t.memoizedState=om,r}return i=e.child,e=i.sibling,r=hi(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Wg(e,t){return t=uf({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function wu(e,t,n,r){return r!==null&&Dg(r),xa(t,e.child,null,n),e=Wg(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function v_(e,t,n,r,o,i,s){if(n)return t.flags&256?(t.flags&=-257,r=Gh(Error(K(422))),wu(e,t,s,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,o=t.mode,r=uf({mode:"visible",children:r.children},o,0,null),i=Qi(i,o,s,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&xa(t,e.child,null,s),t.child.memoizedState=im(s),t.memoizedState=om,i);if(!(t.mode&1))return wu(e,t,s,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(K(419)),r=Gh(i,r,void 0),wu(e,t,s,r)}if(l=(s&e.childLanes)!==0,Mn||l){if(r=Yt,r!==null){switch(s&-s){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|s)?0:o,o!==0&&o!==i.retryLane&&(i.retryLane=o,Po(e,o),Ar(r,e,o,-1))}return Yg(),r=Gh(Error(K(421))),wu(e,t,s,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=I_.bind(null,e),o._reactRetry=t,null):(e=i.treeContext,Qn=ci(o.nextSibling),Yn=t,bt=!0,Dr=null,e!==null&&(cr[ur++]=yo,cr[ur++]=vo,cr[ur++]=Xi,yo=e.id,vo=e.overflow,Xi=t),t=Wg(t,r.children),t.flags|=4096,t)}function zx(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Jp(e.return,t,n)}function Qh(e,t,n,r,o){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=o)}function MC(e,t,n){var r=t.pendingProps,o=r.revealOrder,i=r.tail;if(wn(e,t,r.children,n),r=Et.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&zx(e,n,t);else if(e.tag===19)zx(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(dt(Et,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&vd(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Qh(t,!1,o,n,i);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&vd(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}Qh(t,!0,n,null,i);break;case"together":Qh(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Vu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function To(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Zi|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(K(153));if(t.child!==null){for(e=t.child,n=hi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=hi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function x_(e,t,n){switch(t.tag){case 3:NC(t),va();break;case 5:cC(t);break;case 1:$n(t.type)&&fd(t);break;case 4:Mg(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;dt(md,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(dt(Et,Et.current&1),t.flags|=128,null):n&t.child.childLanes?OC(e,t,n):(dt(Et,Et.current&1),e=To(e,t,n),e!==null?e.sibling:null);dt(Et,Et.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return MC(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),dt(Et,Et.current),r)break;return null;case 22:case 23:return t.lanes=0,_C(e,t,n)}return To(e,t,n)}var LC,sm,$C,FC;LC=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};sm=function(){};$C=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,Ui(ro.current);var i=null;switch(n){case"input":o=kp(e,o),r=kp(e,r),i=[];break;case"select":o=Tt({},o,{value:void 0}),r=Tt({},r,{value:void 0}),i=[];break;case"textarea":o=Ip(e,o),r=Ip(e,r),i=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=ud)}Ap(n,r);var s;n=null;for(u in o)if(!r.hasOwnProperty(u)&&o.hasOwnProperty(u)&&o[u]!=null)if(u==="style"){var l=o[u];for(s in l)l.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&($l.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(l=o!=null?o[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(s in l)!l.hasOwnProperty(s)||c&&c.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in c)c.hasOwnProperty(s)&&l[s]!==c[s]&&(n||(n={}),n[s]=c[s])}else n||(i||(i=[]),i.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&($l.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&yt("scroll",e),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};FC=function(e,t,n,r){n!==r&&(t.flags|=4)};function ll(e,t){if(!bt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function dn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function w_(e,t,n){var r=t.pendingProps;switch(Rg(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dn(t),null;case 1:return $n(t.type)&&dd(),dn(t),null;case 3:return r=t.stateNode,wa(),xt(Ln),xt(yn),$g(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(vu(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Dr!==null&&(pm(Dr),Dr=null))),sm(e,t),dn(t),null;case 5:Lg(t);var o=Ui(Yl.current);if(n=t.type,e!==null&&t.stateNode!=null)$C(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(K(166));return dn(t),null}if(e=Ui(ro.current),vu(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[to]=t,r[Ql]=i,e=(t.mode&1)!==0,n){case"dialog":yt("cancel",r),yt("close",r);break;case"iframe":case"object":case"embed":yt("load",r);break;case"video":case"audio":for(o=0;o<Cl.length;o++)yt(Cl[o],r);break;case"source":yt("error",r);break;case"img":case"image":case"link":yt("error",r),yt("load",r);break;case"details":yt("toggle",r);break;case"input":K0(r,i),yt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},yt("invalid",r);break;case"textarea":X0(r,i),yt("invalid",r)}Ap(n,i),o=null;for(var s in i)if(i.hasOwnProperty(s)){var l=i[s];s==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&yu(r.textContent,l,e),o=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&yu(r.textContent,l,e),o=["children",""+l]):$l.hasOwnProperty(s)&&l!=null&&s==="onScroll"&&yt("scroll",r)}switch(n){case"input":cu(r),Y0(r,i,!0);break;case"textarea":cu(r),J0(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=ud)}r=o,t.updateQueue=r,r!==null&&(t.flags|=4)}else{s=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=fb(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=s.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[to]=t,e[Ql]=r,LC(e,t,!1,!1),t.stateNode=e;e:{switch(s=Np(n,r),n){case"dialog":yt("cancel",e),yt("close",e),o=r;break;case"iframe":case"object":case"embed":yt("load",e),o=r;break;case"video":case"audio":for(o=0;o<Cl.length;o++)yt(Cl[o],e);o=r;break;case"source":yt("error",e),o=r;break;case"img":case"image":case"link":yt("error",e),yt("load",e),o=r;break;case"details":yt("toggle",e),o=r;break;case"input":K0(e,r),o=kp(e,r),yt("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=Tt({},r,{value:void 0}),yt("invalid",e);break;case"textarea":X0(e,r),o=Ip(e,r),yt("invalid",e);break;default:o=r}Ap(n,o),l=o;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?mb(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&hb(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Fl(e,c):typeof c=="number"&&Fl(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&($l.hasOwnProperty(i)?c!=null&&i==="onScroll"&&yt("scroll",e):c!=null&&pg(e,i,c,s))}switch(n){case"input":cu(e),Y0(e,r,!1);break;case"textarea":cu(e),J0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+gi(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?la(e,!!r.multiple,i,!1):r.defaultValue!=null&&la(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=ud)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return dn(t),null;case 6:if(e&&t.stateNode!=null)FC(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(K(166));if(n=Ui(Yl.current),Ui(ro.current),vu(t)){if(r=t.stateNode,n=t.memoizedProps,r[to]=t,(i=r.nodeValue!==n)&&(e=Yn,e!==null))switch(e.tag){case 3:yu(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&yu(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[to]=t,t.stateNode=r}return dn(t),null;case 13:if(xt(Et),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(bt&&Qn!==null&&t.mode&1&&!(t.flags&128))nC(),va(),t.flags|=98560,i=!1;else if(i=vu(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(K(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(K(317));i[to]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dn(t),i=!1}else Dr!==null&&(pm(Dr),Dr=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Et.current&1?Ht===0&&(Ht=3):Yg())),t.updateQueue!==null&&(t.flags|=4),dn(t),null);case 4:return wa(),sm(e,t),e===null&&ql(t.stateNode.containerInfo),dn(t),null;case 10:return Ag(t.type._context),dn(t),null;case 17:return $n(t.type)&&dd(),dn(t),null;case 19:if(xt(Et),i=t.memoizedState,i===null)return dn(t),null;if(r=(t.flags&128)!==0,s=i.rendering,s===null)if(r)ll(i,!1);else{if(Ht!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(s=vd(e),s!==null){for(t.flags|=128,ll(i,!1),r=s.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,s=i.alternate,s===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=s.childLanes,i.lanes=s.lanes,i.child=s.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=s.memoizedProps,i.memoizedState=s.memoizedState,i.updateQueue=s.updateQueue,i.type=s.type,e=s.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return dt(Et,Et.current&1|2),t.child}e=e.sibling}i.tail!==null&&Bt()>ba&&(t.flags|=128,r=!0,ll(i,!1),t.lanes=4194304)}else{if(!r)if(e=vd(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ll(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!bt)return dn(t),null}else 2*Bt()-i.renderingStartTime>ba&&n!==1073741824&&(t.flags|=128,r=!0,ll(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Bt(),t.sibling=null,n=Et.current,dt(Et,r?n&1|2:n&1),t):(dn(t),null);case 22:case 23:return Kg(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?qn&1073741824&&(dn(t),t.subtreeFlags&6&&(t.flags|=8192)):dn(t),null;case 24:return null;case 25:return null}throw Error(K(156,t.tag))}function S_(e,t){switch(Rg(t),t.tag){case 1:return $n(t.type)&&dd(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wa(),xt(Ln),xt(yn),$g(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Lg(t),null;case 13:if(xt(Et),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(K(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return xt(Et),null;case 4:return wa(),null;case 10:return Ag(t.type._context),null;case 22:case 23:return Kg(),null;case 24:return null;default:return null}}var Su=!1,hn=!1,b_=typeof WeakSet=="function"?WeakSet:Set,ce=null;function ea(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){_t(e,t,r)}else n.current=null}function am(e,t,n){try{n()}catch(r){_t(e,t,r)}}var Bx=!1;function C_(e,t){if(Wp=ad,e=Vb(),Tg(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,l=-1,c=-1,u=0,d=0,f=e,h=null;t:for(;;){for(var m;f!==n||o!==0&&f.nodeType!==3||(l=s+o),f!==i||r!==0&&f.nodeType!==3||(c=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)h=f,f=m;for(;;){if(f===e)break t;if(h===n&&++u===o&&(l=s),h===i&&++d===r&&(c=s),(m=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Hp={focusedElem:e,selectionRange:n},ad=!1,ce=t;ce!==null;)if(t=ce,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ce=e;else for(;ce!==null;){t=ce;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var y=g.memoizedProps,S=g.memoizedState,v=t.stateNode,x=v.getSnapshotBeforeUpdate(t.elementType===t.type?y:Tr(t.type,y),S);v.__reactInternalSnapshotBeforeUpdate=x}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(K(163))}}catch(b){_t(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,ce=e;break}ce=t.return}return g=Bx,Bx=!1,g}function _l(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&am(t,n,i)}o=o.next}while(o!==r)}}function lf(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function lm(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function zC(e){var t=e.alternate;t!==null&&(e.alternate=null,zC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[to],delete t[Ql],delete t[Qp],delete t[i_],delete t[s_])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function BC(e){return e.tag===5||e.tag===3||e.tag===4}function Ux(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||BC(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cm(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ud));else if(r!==4&&(e=e.child,e!==null))for(cm(e,t,n),e=e.sibling;e!==null;)cm(e,t,n),e=e.sibling}function um(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(um(e,t,n),e=e.sibling;e!==null;)um(e,t,n),e=e.sibling}var tn=null,kr=!1;function Go(e,t,n){for(n=n.child;n!==null;)UC(e,t,n),n=n.sibling}function UC(e,t,n){if(no&&typeof no.onCommitFiberUnmount=="function")try{no.onCommitFiberUnmount(Zd,n)}catch{}switch(n.tag){case 5:hn||ea(n,t);case 6:var r=tn,o=kr;tn=null,Go(e,t,n),tn=r,kr=o,tn!==null&&(kr?(e=tn,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):tn.removeChild(n.stateNode));break;case 18:tn!==null&&(kr?(e=tn,n=n.stateNode,e.nodeType===8?Bh(e.parentNode,n):e.nodeType===1&&Bh(e,n),Vl(e)):Bh(tn,n.stateNode));break;case 4:r=tn,o=kr,tn=n.stateNode.containerInfo,kr=!0,Go(e,t,n),tn=r,kr=o;break;case 0:case 11:case 14:case 15:if(!hn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&am(n,t,s),o=o.next}while(o!==r)}Go(e,t,n);break;case 1:if(!hn&&(ea(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){_t(n,t,l)}Go(e,t,n);break;case 21:Go(e,t,n);break;case 22:n.mode&1?(hn=(r=hn)||n.memoizedState!==null,Go(e,t,n),hn=r):Go(e,t,n);break;default:Go(e,t,n)}}function Vx(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new b_),t.forEach(function(r){var o=__.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Er(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];try{var i=e,s=t,l=s;e:for(;l!==null;){switch(l.tag){case 5:tn=l.stateNode,kr=!1;break e;case 3:tn=l.stateNode.containerInfo,kr=!0;break e;case 4:tn=l.stateNode.containerInfo,kr=!0;break e}l=l.return}if(tn===null)throw Error(K(160));UC(i,s,o),tn=null,kr=!1;var c=o.alternate;c!==null&&(c.return=null),o.return=null}catch(u){_t(o,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)VC(t,e),t=t.sibling}function VC(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Er(t,e),Kr(e),r&4){try{_l(3,e,e.return),lf(3,e)}catch(y){_t(e,e.return,y)}try{_l(5,e,e.return)}catch(y){_t(e,e.return,y)}}break;case 1:Er(t,e),Kr(e),r&512&&n!==null&&ea(n,n.return);break;case 5:if(Er(t,e),Kr(e),r&512&&n!==null&&ea(n,n.return),e.flags&32){var o=e.stateNode;try{Fl(o,"")}catch(y){_t(e,e.return,y)}}if(r&4&&(o=e.stateNode,o!=null)){var i=e.memoizedProps,s=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&ub(o,i),Np(l,s);var u=Np(l,i);for(s=0;s<c.length;s+=2){var d=c[s],f=c[s+1];d==="style"?mb(o,f):d==="dangerouslySetInnerHTML"?hb(o,f):d==="children"?Fl(o,f):pg(o,d,f,u)}switch(l){case"input":Rp(o,i);break;case"textarea":db(o,i);break;case"select":var h=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?la(o,!!i.multiple,m,!1):h!==!!i.multiple&&(i.defaultValue!=null?la(o,!!i.multiple,i.defaultValue,!0):la(o,!!i.multiple,i.multiple?[]:"",!1))}o[Ql]=i}catch(y){_t(e,e.return,y)}}break;case 6:if(Er(t,e),Kr(e),r&4){if(e.stateNode===null)throw Error(K(162));o=e.stateNode,i=e.memoizedProps;try{o.nodeValue=i}catch(y){_t(e,e.return,y)}}break;case 3:if(Er(t,e),Kr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vl(t.containerInfo)}catch(y){_t(e,e.return,y)}break;case 4:Er(t,e),Kr(e);break;case 13:Er(t,e),Kr(e),o=e.child,o.flags&8192&&(i=o.memoizedState!==null,o.stateNode.isHidden=i,!i||o.alternate!==null&&o.alternate.memoizedState!==null||(Gg=Bt())),r&4&&Vx(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(hn=(u=hn)||d,Er(t,e),hn=u):Er(t,e),Kr(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(ce=e,d=e.child;d!==null;){for(f=ce=d;ce!==null;){switch(h=ce,m=h.child,h.tag){case 0:case 11:case 14:case 15:_l(4,h,h.return);break;case 1:ea(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(y){_t(r,n,y)}}break;case 5:ea(h,h.return);break;case 22:if(h.memoizedState!==null){Hx(f);continue}}m!==null?(m.return=h,ce=m):Hx(f)}d=d.sibling}e:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{o=f.stateNode,u?(i=o.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=f.stateNode,c=f.memoizedProps.style,s=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=pb("display",s))}catch(y){_t(e,e.return,y)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(y){_t(e,e.return,y)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Er(t,e),Kr(e),r&4&&Vx(e);break;case 21:break;default:Er(t,e),Kr(e)}}function Kr(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(BC(n)){var r=n;break e}n=n.return}throw Error(K(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(Fl(o,""),r.flags&=-33);var i=Ux(e);um(e,i,o);break;case 3:case 4:var s=r.stateNode.containerInfo,l=Ux(e);cm(e,l,s);break;default:throw Error(K(161))}}catch(c){_t(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function E_(e,t,n){ce=e,WC(e)}function WC(e,t,n){for(var r=(e.mode&1)!==0;ce!==null;){var o=ce,i=o.child;if(o.tag===22&&r){var s=o.memoizedState!==null||Su;if(!s){var l=o.alternate,c=l!==null&&l.memoizedState!==null||hn;l=Su;var u=hn;if(Su=s,(hn=c)&&!u)for(ce=o;ce!==null;)s=ce,c=s.child,s.tag===22&&s.memoizedState!==null?qx(o):c!==null?(c.return=s,ce=c):qx(o);for(;i!==null;)ce=i,WC(i),i=i.sibling;ce=o,Su=l,hn=u}Wx(e)}else o.subtreeFlags&8772&&i!==null?(i.return=o,ce=i):Wx(e)}}function Wx(e){for(;ce!==null;){var t=ce;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:hn||lf(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!hn)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:Tr(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Tx(t,i,r);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Tx(t,s,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&Vl(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(K(163))}hn||t.flags&512&&lm(t)}catch(h){_t(t,t.return,h)}}if(t===e){ce=null;break}if(n=t.sibling,n!==null){n.return=t.return,ce=n;break}ce=t.return}}function Hx(e){for(;ce!==null;){var t=ce;if(t===e){ce=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ce=n;break}ce=t.return}}function qx(e){for(;ce!==null;){var t=ce;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{lf(4,t)}catch(c){_t(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(c){_t(t,o,c)}}var i=t.return;try{lm(t)}catch(c){_t(t,i,c)}break;case 5:var s=t.return;try{lm(t)}catch(c){_t(t,s,c)}}}catch(c){_t(t,t.return,c)}if(t===e){ce=null;break}var l=t.sibling;if(l!==null){l.return=t.return,ce=l;break}ce=t.return}}var j_=Math.ceil,Sd=Oo.ReactCurrentDispatcher,Hg=Oo.ReactCurrentOwner,fr=Oo.ReactCurrentBatchConfig,Qe=0,Yt=null,Ut=null,sn=0,qn=0,ta=Ci(0),Ht=0,ec=null,Zi=0,cf=0,qg=0,Al=null,On=null,Gg=0,ba=1/0,mo=null,bd=!1,dm=null,di=null,bu=!1,oi=null,Cd=0,Nl=0,fm=null,Wu=-1,Hu=0;function En(){return Qe&6?Bt():Wu!==-1?Wu:Wu=Bt()}function fi(e){return e.mode&1?Qe&2&&sn!==0?sn&-sn:l_.transition!==null?(Hu===0&&(Hu=Tb()),Hu):(e=Ze,e!==0||(e=window.event,e=e===void 0?16:Nb(e.type)),e):1}function Ar(e,t,n,r){if(50<Nl)throw Nl=0,fm=null,Error(K(185));vc(e,n,r),(!(Qe&2)||e!==Yt)&&(e===Yt&&(!(Qe&2)&&(cf|=n),Ht===4&&ti(e,sn)),Fn(e,r),n===1&&Qe===0&&!(t.mode&1)&&(ba=Bt()+500,of&&Ei()))}function Fn(e,t){var n=e.callbackNode;lI(e,t);var r=sd(e,e===Yt?sn:0);if(r===0)n!==null&&tx(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&tx(n),t===1)e.tag===0?a_(Gx.bind(null,e)):Zb(Gx.bind(null,e)),r_(function(){!(Qe&6)&&Ei()}),n=null;else{switch(kb(r)){case 1:n=xg;break;case 4:n=jb;break;case 16:n=id;break;case 536870912:n=Pb;break;default:n=id}n=JC(n,HC.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function HC(e,t){if(Wu=-1,Hu=0,Qe&6)throw Error(K(327));var n=e.callbackNode;if(ha()&&e.callbackNode!==n)return null;var r=sd(e,e===Yt?sn:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ed(e,r);else{t=r;var o=Qe;Qe|=2;var i=GC();(Yt!==e||sn!==t)&&(mo=null,ba=Bt()+500,Gi(e,t));do try{k_();break}catch(l){qC(e,l)}while(!0);_g(),Sd.current=i,Qe=o,Ut!==null?t=0:(Yt=null,sn=0,t=Ht)}if(t!==0){if(t===2&&(o=Fp(e),o!==0&&(r=o,t=hm(e,o))),t===1)throw n=ec,Gi(e,0),ti(e,r),Fn(e,Bt()),n;if(t===6)ti(e,r);else{if(o=e.current.alternate,!(r&30)&&!P_(o)&&(t=Ed(e,r),t===2&&(i=Fp(e),i!==0&&(r=i,t=hm(e,i))),t===1))throw n=ec,Gi(e,0),ti(e,r),Fn(e,Bt()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(K(345));case 2:Oi(e,On,mo);break;case 3:if(ti(e,r),(r&130023424)===r&&(t=Gg+500-Bt(),10<t)){if(sd(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){En(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=Gp(Oi.bind(null,e,On,mo),t);break}Oi(e,On,mo);break;case 4:if(ti(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var s=31-_r(r);i=1<<s,s=t[s],s>o&&(o=s),r&=~i}if(r=o,r=Bt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*j_(r/1960))-r,10<r){e.timeoutHandle=Gp(Oi.bind(null,e,On,mo),r);break}Oi(e,On,mo);break;case 5:Oi(e,On,mo);break;default:throw Error(K(329))}}}return Fn(e,Bt()),e.callbackNode===n?HC.bind(null,e):null}function hm(e,t){var n=Al;return e.current.memoizedState.isDehydrated&&(Gi(e,t).flags|=256),e=Ed(e,t),e!==2&&(t=On,On=n,t!==null&&pm(t)),e}function pm(e){On===null?On=e:On.push.apply(On,e)}function P_(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var o=n[r],i=o.getSnapshot;o=o.value;try{if(!Or(i(),o))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ti(e,t){for(t&=~qg,t&=~cf,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-_r(t),r=1<<n;e[n]=-1,t&=~r}}function Gx(e){if(Qe&6)throw Error(K(327));ha();var t=sd(e,0);if(!(t&1))return Fn(e,Bt()),null;var n=Ed(e,t);if(e.tag!==0&&n===2){var r=Fp(e);r!==0&&(t=r,n=hm(e,r))}if(n===1)throw n=ec,Gi(e,0),ti(e,t),Fn(e,Bt()),n;if(n===6)throw Error(K(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Oi(e,On,mo),Fn(e,Bt()),null}function Qg(e,t){var n=Qe;Qe|=1;try{return e(t)}finally{Qe=n,Qe===0&&(ba=Bt()+500,of&&Ei())}}function es(e){oi!==null&&oi.tag===0&&!(Qe&6)&&ha();var t=Qe;Qe|=1;var n=fr.transition,r=Ze;try{if(fr.transition=null,Ze=1,e)return e()}finally{Ze=r,fr.transition=n,Qe=t,!(Qe&6)&&Ei()}}function Kg(){qn=ta.current,xt(ta)}function Gi(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,n_(n)),Ut!==null)for(n=Ut.return;n!==null;){var r=n;switch(Rg(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&dd();break;case 3:wa(),xt(Ln),xt(yn),$g();break;case 5:Lg(r);break;case 4:wa();break;case 13:xt(Et);break;case 19:xt(Et);break;case 10:Ag(r.type._context);break;case 22:case 23:Kg()}n=n.return}if(Yt=e,Ut=e=hi(e.current,null),sn=qn=t,Ht=0,ec=null,qg=cf=Zi=0,On=Al=null,Bi!==null){for(t=0;t<Bi.length;t++)if(n=Bi[t],r=n.interleaved,r!==null){n.interleaved=null;var o=r.next,i=n.pending;if(i!==null){var s=i.next;i.next=o,r.next=s}n.pending=r}Bi=null}return e}function qC(e,t){do{var n=Ut;try{if(_g(),Bu.current=wd,xd){for(var r=Pt.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}xd=!1}if(Ji=0,Qt=Wt=Pt=null,Il=!1,Xl=0,Hg.current=null,n===null||n.return===null){Ht=1,ec=t,Ut=null;break}e:{var i=e,s=n.return,l=n,c=t;if(t=sn,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var h=d.alternate;h?(d.updateQueue=h.updateQueue,d.memoizedState=h.memoizedState,d.lanes=h.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Nx(s);if(m!==null){m.flags&=-257,Ox(m,s,l,i,t),m.mode&1&&Ax(i,u,t),t=m,c=u;var g=t.updateQueue;if(g===null){var y=new Set;y.add(c),t.updateQueue=y}else g.add(c);break e}else{if(!(t&1)){Ax(i,u,t),Yg();break e}c=Error(K(426))}}else if(bt&&l.mode&1){var S=Nx(s);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Ox(S,s,l,i,t),Dg(Sa(c,l));break e}}i=c=Sa(c,l),Ht!==4&&(Ht=2),Al===null?Al=[i]:Al.push(i),i=s;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var v=RC(i,c,t);Px(i,v);break e;case 1:l=c;var x=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof x.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(di===null||!di.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var b=DC(i,l,t);Px(i,b);break e}}i=i.return}while(i!==null)}KC(n)}catch(j){t=j,Ut===n&&n!==null&&(Ut=n=n.return);continue}break}while(!0)}function GC(){var e=Sd.current;return Sd.current=wd,e===null?wd:e}function Yg(){(Ht===0||Ht===3||Ht===2)&&(Ht=4),Yt===null||!(Zi&268435455)&&!(cf&268435455)||ti(Yt,sn)}function Ed(e,t){var n=Qe;Qe|=2;var r=GC();(Yt!==e||sn!==t)&&(mo=null,Gi(e,t));do try{T_();break}catch(o){qC(e,o)}while(!0);if(_g(),Qe=n,Sd.current=r,Ut!==null)throw Error(K(261));return Yt=null,sn=0,Ht}function T_(){for(;Ut!==null;)QC(Ut)}function k_(){for(;Ut!==null&&!ZD();)QC(Ut)}function QC(e){var t=XC(e.alternate,e,qn);e.memoizedProps=e.pendingProps,t===null?KC(e):Ut=t,Hg.current=null}function KC(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=S_(n,t),n!==null){n.flags&=32767,Ut=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Ht=6,Ut=null;return}}else if(n=w_(n,t,qn),n!==null){Ut=n;return}if(t=t.sibling,t!==null){Ut=t;return}Ut=t=e}while(t!==null);Ht===0&&(Ht=5)}function Oi(e,t,n){var r=Ze,o=fr.transition;try{fr.transition=null,Ze=1,R_(e,t,n,r)}finally{fr.transition=o,Ze=r}return null}function R_(e,t,n,r){do ha();while(oi!==null);if(Qe&6)throw Error(K(327));n=e.finishedWork;var o=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(K(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(cI(e,i),e===Yt&&(Ut=Yt=null,sn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||bu||(bu=!0,JC(id,function(){return ha(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=fr.transition,fr.transition=null;var s=Ze;Ze=1;var l=Qe;Qe|=4,Hg.current=null,C_(e,n),VC(n,e),KI(Hp),ad=!!Wp,Hp=Wp=null,e.current=n,E_(n),eI(),Qe=l,Ze=s,fr.transition=i}else e.current=n;if(bu&&(bu=!1,oi=e,Cd=o),i=e.pendingLanes,i===0&&(di=null),rI(n.stateNode),Fn(e,Bt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(bd)throw bd=!1,e=dm,dm=null,e;return Cd&1&&e.tag!==0&&ha(),i=e.pendingLanes,i&1?e===fm?Nl++:(Nl=0,fm=e):Nl=0,Ei(),null}function ha(){if(oi!==null){var e=kb(Cd),t=fr.transition,n=Ze;try{if(fr.transition=null,Ze=16>e?16:e,oi===null)var r=!1;else{if(e=oi,oi=null,Cd=0,Qe&6)throw Error(K(331));var o=Qe;for(Qe|=4,ce=e.current;ce!==null;){var i=ce,s=i.child;if(ce.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(ce=u;ce!==null;){var d=ce;switch(d.tag){case 0:case 11:case 15:_l(8,d,i)}var f=d.child;if(f!==null)f.return=d,ce=f;else for(;ce!==null;){d=ce;var h=d.sibling,m=d.return;if(zC(d),d===u){ce=null;break}if(h!==null){h.return=m,ce=h;break}ce=m}}}var g=i.alternate;if(g!==null){var y=g.child;if(y!==null){g.child=null;do{var S=y.sibling;y.sibling=null,y=S}while(y!==null)}}ce=i}}if(i.subtreeFlags&2064&&s!==null)s.return=i,ce=s;else e:for(;ce!==null;){if(i=ce,i.flags&2048)switch(i.tag){case 0:case 11:case 15:_l(9,i,i.return)}var v=i.sibling;if(v!==null){v.return=i.return,ce=v;break e}ce=i.return}}var x=e.current;for(ce=x;ce!==null;){s=ce;var w=s.child;if(s.subtreeFlags&2064&&w!==null)w.return=s,ce=w;else e:for(s=x;ce!==null;){if(l=ce,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:lf(9,l)}}catch(j){_t(l,l.return,j)}if(l===s){ce=null;break e}var b=l.sibling;if(b!==null){b.return=l.return,ce=b;break e}ce=l.return}}if(Qe=o,Ei(),no&&typeof no.onPostCommitFiberRoot=="function")try{no.onPostCommitFiberRoot(Zd,e)}catch{}r=!0}return r}finally{Ze=n,fr.transition=t}}return!1}function Qx(e,t,n){t=Sa(n,t),t=RC(e,t,1),e=ui(e,t,1),t=En(),e!==null&&(vc(e,1,t),Fn(e,t))}function _t(e,t,n){if(e.tag===3)Qx(e,e,n);else for(;t!==null;){if(t.tag===3){Qx(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(di===null||!di.has(r))){e=Sa(n,e),e=DC(t,e,1),t=ui(t,e,1),e=En(),t!==null&&(vc(t,1,e),Fn(t,e));break}}t=t.return}}function D_(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=En(),e.pingedLanes|=e.suspendedLanes&n,Yt===e&&(sn&n)===n&&(Ht===4||Ht===3&&(sn&130023424)===sn&&500>Bt()-Gg?Gi(e,0):qg|=n),Fn(e,t)}function YC(e,t){t===0&&(e.mode&1?(t=fu,fu<<=1,!(fu&130023424)&&(fu=4194304)):t=1);var n=En();e=Po(e,t),e!==null&&(vc(e,t,n),Fn(e,n))}function I_(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),YC(e,n)}function __(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(K(314))}r!==null&&r.delete(t),YC(e,n)}var XC;XC=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ln.current)Mn=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Mn=!1,x_(e,t,n);Mn=!!(e.flags&131072)}else Mn=!1,bt&&t.flags&1048576&&eC(t,pd,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vu(e,t),e=t.pendingProps;var o=ya(t,yn.current);fa(t,n),o=zg(null,t,r,e,o,n);var i=Bg();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,$n(r)?(i=!0,fd(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,Og(t),o.updater=sf,t.stateNode=o,o._reactInternals=t,em(t,r,e,n),t=rm(null,t,r,!0,i,n)):(t.tag=0,bt&&i&&kg(t),wn(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vu(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=N_(r),e=Tr(r,e),o){case 0:t=nm(null,t,r,e,n);break e;case 1:t=$x(null,t,r,e,n);break e;case 11:t=Mx(null,t,r,e,n);break e;case 14:t=Lx(null,t,r,Tr(r.type,e),n);break e}throw Error(K(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tr(r,o),nm(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tr(r,o),$x(e,t,r,o,n);case 3:e:{if(NC(t),e===null)throw Error(K(387));r=t.pendingProps,i=t.memoizedState,o=i.element,oC(e,t),yd(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=Sa(Error(K(423)),t),t=Fx(e,t,r,n,o);break e}else if(r!==o){o=Sa(Error(K(424)),t),t=Fx(e,t,r,n,o);break e}else for(Qn=ci(t.stateNode.containerInfo.firstChild),Yn=t,bt=!0,Dr=null,n=lC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(va(),r===o){t=To(e,t,n);break e}wn(e,t,r,n)}t=t.child}return t;case 5:return cC(t),e===null&&Xp(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,s=o.children,qp(r,o)?s=null:i!==null&&qp(r,i)&&(t.flags|=32),AC(e,t),wn(e,t,s,n),t.child;case 6:return e===null&&Xp(t),null;case 13:return OC(e,t,n);case 4:return Mg(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=xa(t,null,r,n):wn(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tr(r,o),Mx(e,t,r,o,n);case 7:return wn(e,t,t.pendingProps,n),t.child;case 8:return wn(e,t,t.pendingProps.children,n),t.child;case 12:return wn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,s=o.value,dt(md,r._currentValue),r._currentValue=s,i!==null)if(Or(i.value,s)){if(i.children===o.children&&!Ln.current){t=To(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){s=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=xo(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Jp(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(K(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),Jp(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}wn(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,fa(t,n),o=pr(o),r=r(o),t.flags|=1,wn(e,t,r,n),t.child;case 14:return r=t.type,o=Tr(r,t.pendingProps),o=Tr(r.type,o),Lx(e,t,r,o,n);case 15:return IC(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Tr(r,o),Vu(e,t),t.tag=1,$n(r)?(e=!0,fd(t)):e=!1,fa(t,n),sC(t,r,o),em(t,r,o,n),rm(null,t,r,!0,e,n);case 19:return MC(e,t,n);case 22:return _C(e,t,n)}throw Error(K(156,t.tag))};function JC(e,t){return Eb(e,t)}function A_(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dr(e,t,n,r){return new A_(e,t,n,r)}function Xg(e){return e=e.prototype,!(!e||!e.isReactComponent)}function N_(e){if(typeof e=="function")return Xg(e)?1:0;if(e!=null){if(e=e.$$typeof,e===gg)return 11;if(e===yg)return 14}return 2}function hi(e,t){var n=e.alternate;return n===null?(n=dr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qu(e,t,n,r,o,i){var s=2;if(r=e,typeof e=="function")Xg(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case Hs:return Qi(n.children,o,i,t);case mg:s=8,o|=8;break;case Ep:return e=dr(12,n,t,o|2),e.elementType=Ep,e.lanes=i,e;case jp:return e=dr(13,n,t,o),e.elementType=jp,e.lanes=i,e;case Pp:return e=dr(19,n,t,o),e.elementType=Pp,e.lanes=i,e;case ab:return uf(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ib:s=10;break e;case sb:s=9;break e;case gg:s=11;break e;case yg:s=14;break e;case Ko:s=16,r=null;break e}throw Error(K(130,e==null?e:typeof e,""))}return t=dr(s,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function Qi(e,t,n,r){return e=dr(7,e,r,t),e.lanes=n,e}function uf(e,t,n,r){return e=dr(22,e,r,t),e.elementType=ab,e.lanes=n,e.stateNode={isHidden:!1},e}function Kh(e,t,n){return e=dr(6,e,null,t),e.lanes=n,e}function Yh(e,t,n){return t=dr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function O_(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dh(0),this.expirationTimes=Dh(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dh(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Jg(e,t,n,r,o,i,s,l,c){return e=new O_(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=dr(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Og(i),e}function M_(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Ws,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function ZC(e){if(!e)return yi;e=e._reactInternals;e:{if(ms(e)!==e||e.tag!==1)throw Error(K(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if($n(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(K(171))}if(e.tag===1){var n=e.type;if($n(n))return Jb(e,n,t)}return t}function eE(e,t,n,r,o,i,s,l,c){return e=Jg(n,r,!0,e,o,i,s,l,c),e.context=ZC(null),n=e.current,r=En(),o=fi(n),i=xo(r,o),i.callback=t??null,ui(n,i,o),e.current.lanes=o,vc(e,o,r),Fn(e,r),e}function df(e,t,n,r){var o=t.current,i=En(),s=fi(o);return n=ZC(n),t.context===null?t.context=n:t.pendingContext=n,t=xo(i,s),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ui(o,t,s),e!==null&&(Ar(e,o,s,i),zu(e,o,s)),s}function jd(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Kx(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Zg(e,t){Kx(e,t),(e=e.alternate)&&Kx(e,t)}function L_(){return null}var tE=typeof reportError=="function"?reportError:function(e){console.error(e)};function ey(e){this._internalRoot=e}ff.prototype.render=ey.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(K(409));df(e,t,null,null)};ff.prototype.unmount=ey.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;es(function(){df(null,e,null,null)}),t[jo]=null}};function ff(e){this._internalRoot=e}ff.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ib();e={blockedOn:null,target:e,priority:t};for(var n=0;n<ei.length&&t!==0&&t<ei[n].priority;n++);ei.splice(n,0,e),n===0&&Ab(e)}};function ty(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function hf(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Yx(){}function $_(e,t,n,r,o){if(o){if(typeof r=="function"){var i=r;r=function(){var u=jd(s);i.call(u)}}var s=eE(t,r,e,0,null,!1,!1,"",Yx);return e._reactRootContainer=s,e[jo]=s.current,ql(e.nodeType===8?e.parentNode:e),es(),s}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var l=r;r=function(){var u=jd(c);l.call(u)}}var c=Jg(e,0,!1,null,null,!1,!1,"",Yx);return e._reactRootContainer=c,e[jo]=c.current,ql(e.nodeType===8?e.parentNode:e),es(function(){df(t,c,n,r)}),c}function pf(e,t,n,r,o){var i=n._reactRootContainer;if(i){var s=i;if(typeof o=="function"){var l=o;o=function(){var c=jd(s);l.call(c)}}df(t,s,e,o)}else s=$_(n,t,e,o,r);return jd(s)}Rb=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=bl(t.pendingLanes);n!==0&&(wg(t,n|1),Fn(t,Bt()),!(Qe&6)&&(ba=Bt()+500,Ei()))}break;case 13:es(function(){var r=Po(e,1);if(r!==null){var o=En();Ar(r,e,1,o)}}),Zg(e,1)}};Sg=function(e){if(e.tag===13){var t=Po(e,134217728);if(t!==null){var n=En();Ar(t,e,134217728,n)}Zg(e,134217728)}};Db=function(e){if(e.tag===13){var t=fi(e),n=Po(e,t);if(n!==null){var r=En();Ar(n,e,t,r)}Zg(e,t)}};Ib=function(){return Ze};_b=function(e,t){var n=Ze;try{return Ze=e,t()}finally{Ze=n}};Mp=function(e,t,n){switch(t){case"input":if(Rp(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=rf(r);if(!o)throw Error(K(90));cb(r),Rp(r,o)}}}break;case"textarea":db(e,n);break;case"select":t=n.value,t!=null&&la(e,!!n.multiple,t,!1)}};vb=Qg;xb=es;var F_={usingClientEntryPoint:!1,Events:[wc,Ks,rf,gb,yb,Qg]},cl={findFiberByHostInstance:zi,bundleType:0,version:"18.2.0",rendererPackageName:"react-dom"},z_={bundleType:cl.bundleType,version:cl.version,rendererPackageName:cl.rendererPackageName,rendererConfig:cl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Oo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=bb(e),e===null?null:e.stateNode},findFiberByHostInstance:cl.findFiberByHostInstance||L_,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.2.0-next-9e3b772b8-20220608"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cu.isDisabled&&Cu.supportsFiber)try{Zd=Cu.inject(z_),no=Cu}catch{}}nr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=F_;nr.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ty(t))throw Error(K(200));return M_(e,t,null,n)};nr.createRoot=function(e,t){if(!ty(e))throw Error(K(299));var n=!1,r="",o=tE;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=Jg(e,1,!1,null,null,n,!1,r,o),e[jo]=t.current,ql(e.nodeType===8?e.parentNode:e),new ey(t)};nr.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(K(188)):(e=Object.keys(e).join(","),Error(K(268,e)));return e=bb(t),e=e===null?null:e.stateNode,e};nr.flushSync=function(e){return es(e)};nr.hydrate=function(e,t,n){if(!hf(t))throw Error(K(200));return pf(null,e,t,!0,n)};nr.hydrateRoot=function(e,t,n){if(!ty(e))throw Error(K(405));var r=n!=null&&n.hydratedSources||null,o=!1,i="",s=tE;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=eE(t,null,e,1,n??null,o,!1,i,s),e[jo]=t.current,ql(e),r)for(e=0;e<r.length;e++)n=r[e],o=n._getVersion,o=o(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new ff(t)};nr.render=function(e,t,n){if(!hf(t))throw Error(K(200));return pf(null,e,t,!1,n)};nr.unmountComponentAtNode=function(e){if(!hf(e))throw Error(K(40));return e._reactRootContainer?(es(function(){pf(null,null,e,!1,function(){e._reactRootContainer=null,e[jo]=null})}),!0):!1};nr.unstable_batchedUpdates=Qg;nr.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!hf(n))throw Error(K(200));if(e==null||e._reactInternals===void 0)throw Error(K(38));return pf(e,t,n,!1,r)};nr.version="18.2.0-next-9e3b772b8-20220608";function nE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(nE)}catch(e){console.error(e)}}nE(),eb.exports=nr;var bc=eb.exports;const na=Km(bc),B_=fS({__proto__:null,default:na},[bc]),[U_,yr]=Tn("ScrollArea.Root component was not found in tree");function Ca(e,t){const n=$i(t);Oa(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}const V_=C.forwardRef((e,t)=>{const{style:n,...r}=e,o=yr(),[i,s]=C.useState(0),[l,c]=C.useState(0),u=!!(i&&l);return Ca(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),Ca(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),s(d)}),u?C.createElement("div",{...r,ref:t,style:{...n,width:i,height:l}}):null}),W_=C.forwardRef((e,t)=>{const n=yr(),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?C.createElement(V_,{...e,ref:t}):null}),H_={scrollHideDelay:1e3,type:"hover"},rE=p.forwardRef((e,t)=>{const n=U("ScrollAreaRoot",H_,e),{type:r,scrollHideDelay:o,scrollbars:i,...s}=n,[l,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,g]=p.useState(null),[y,S]=p.useState(null),[v,x]=p.useState(0),[w,b]=p.useState(0),[j,E]=p.useState(!1),[P,T]=p.useState(!1),D=Zt(t,_=>c(_));return C.createElement(U_,{value:{type:r,scrollHideDelay:o,scrollArea:l,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:j,onScrollbarXEnabledChange:E,scrollbarY:y,onScrollbarYChange:S,scrollbarYEnabled:P,onScrollbarYEnabledChange:T,onCornerWidthChange:x,onCornerHeightChange:b}},C.createElement(W,{...s,ref:D,__vars:{"--sa-corner-width":i!=="xy"?"0px":`${v}px`,"--sa-corner-height":i!=="xy"?"0px":`${w}px`}}))});rE.displayName="@mantine/core/ScrollAreaRoot";function oE(e,t){const n=e/t;return Number.isNaN(n)?0:n}function mf(e){const t=oE(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function iE(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function q_(e,[t,n]){return Math.min(n,Math.max(t,e))}function Xx(e,t,n="ltr"){const r=mf(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,s=t.content-t.viewport,l=i-r,c=n==="ltr"?[0,s]:[s*-1,0],u=q_(e,c);return iE([0,s],[0,l])(u)}function G_(e,t,n,r="ltr"){const o=mf(n),i=o/2,s=t||i,l=o-s,c=n.scrollbar.paddingStart+s,u=n.scrollbar.size-n.scrollbar.paddingEnd-l,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return iE([c,u],f)(e)}function sE(e,t){return e>0&&e<t}function Pd(e){return e?parseInt(e,10):0}function Ki(e,t,{checkForDefaultPrevented:n=!0}={}){return r=>{e==null||e(r),(n===!1||!r.defaultPrevented)&&(t==null||t(r))}}const[Q_,aE]=Tn("ScrollAreaScrollbar was not found in tree"),lE=p.forwardRef((e,t)=>{const{sizes:n,hasThumb:r,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:s,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:d,...f}=e,h=yr(),[m,g]=C.useState(null),y=Zt(t,T=>g(T)),S=C.useRef(null),v=C.useRef(""),{viewport:x}=h,w=n.content-n.viewport,b=$i(u),j=$i(l),E=Yd(d,10),P=T=>{if(S.current){const D=T.clientX-S.current.left,_=T.clientY-S.current.top;c({x:D,y:_})}};return p.useEffect(()=>{const T=D=>{const _=D.target;(m==null?void 0:m.contains(_))&&b(D,w)};return document.addEventListener("wheel",T,{passive:!1}),()=>document.removeEventListener("wheel",T,{passive:!1})},[x,m,w,b]),p.useEffect(j,[n,j]),Ca(m,E),Ca(h.content,E),C.createElement(Q_,{value:{scrollbar:m,hasThumb:r,onThumbChange:$i(o),onThumbPointerUp:$i(i),onThumbPositionChange:j,onThumbPointerDown:$i(s)}},C.createElement("div",{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Ki(e.onPointerDown,T=>{T.button===0&&(T.target.setPointerCapture(T.pointerId),S.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",P(T))}),onPointerMove:Ki(e.onPointerMove,P),onPointerUp:Ki(e.onPointerUp,T=>{const D=T.target;D.hasPointerCapture(T.pointerId)&&D.releasePointerCapture(T.pointerId),document.body.style.webkitUserSelect=v.current,S.current=null})}))}),K_=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,style:o,...i}=e,s=yr(),[l,c]=p.useState(),u=p.useRef(null),d=Zt(t,u,s.onScrollbarXChange);return p.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),C.createElement(lE,{"data-orientation":"horizontal",...i,ref:d,sizes:n,style:{...o,"--sa-thumb-width":`${mf(n)}px`},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+f.deltaX;e.onWheelScroll(m),sE(m,h)&&f.preventDefault()}},onResize:()=>{u.current&&s.viewport&&l&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:Pd(l.paddingLeft),paddingEnd:Pd(l.paddingRight)}})}})}),Y_=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,style:o,...i}=e,s=yr(),[l,c]=C.useState(),u=p.useRef(null),d=Zt(t,u,s.onScrollbarYChange);return p.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),C.createElement(lE,{...i,"data-orientation":"vertical",ref:d,sizes:n,style:{"--sa-thumb-height":`${mf(n)}px`,...o},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,h)=>{if(s.viewport){const m=s.viewport.scrollTop+f.deltaY;e.onWheelScroll(m),sE(m,h)&&f.preventDefault()}},onResize:()=>{u.current&&s.viewport&&l&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:Pd(l.paddingTop),paddingEnd:Pd(l.paddingBottom)}})}})}),ny=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,{dir:o}=hs(),i=yr(),s=p.useRef(null),l=p.useRef(0),[c,u]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=oE(c.viewport,c.content),f={...r,sizes:c,onSizesChange:u,hasThumb:d>0&&d<1,onThumbChange:m=>{s.current=m},onThumbPointerUp:()=>{l.current=0},onThumbPointerDown:m=>{l.current=m}},h=(m,g)=>G_(m,l.current,c,g);return n==="horizontal"?C.createElement(K_,{...f,ref:t,onThumbPositionChange:()=>{if(i.viewport&&s.current){const m=i.viewport.scrollLeft,g=Xx(m,c,o);s.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollLeft=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollLeft=h(m,o))}}):n==="vertical"?C.createElement(Y_,{...f,ref:t,onThumbPositionChange:()=>{if(i.viewport&&s.current){const m=i.viewport.scrollTop,g=Xx(m,c);s.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:m=>{i.viewport&&(i.viewport.scrollTop=m)},onDragScroll:m=>{i.viewport&&(i.viewport.scrollTop=h(m))}}):null}),cE=p.forwardRef((e,t)=>{const n=yr(),{forceMount:r,...o}=e,[i,s]=p.useState(!1),l=e.orientation==="horizontal",c=Yd(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;s(l?u:d)}},10);return Ca(n.viewport,c),Ca(n.content,c),r||i?C.createElement(ny,{"data-state":i?"visible":"hidden",...o,ref:t}):null}),X_=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yr(),[i,s]=p.useState(!1);return p.useEffect(()=>{const{scrollArea:l}=o;let c=0;if(l){const u=()=>{window.clearTimeout(c),s(!0)},d=()=>{c=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),n||i?C.createElement(cE,{"data-state":i?"visible":"hidden",...r,ref:t}):null}),J_=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yr(),i=e.orientation==="horizontal",[s,l]=p.useState("hidden"),c=Yd(()=>l("idle"),100);return p.useEffect(()=>{if(s==="idle"){const u=window.setTimeout(()=>l("hidden"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[s,o.scrollHideDelay]),p.useEffect(()=>{const{viewport:u}=o,d=i?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(l("scrolling"),c()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,i,c]),n||s!=="hidden"?C.createElement(ny,{"data-state":s==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ki(e.onPointerEnter,()=>l("interacting")),onPointerLeave:Ki(e.onPointerLeave,()=>l("idle"))}):null}),Jx=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=yr(),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=o,l=e.orientation==="horizontal";return C.useEffect(()=>(l?i(!0):s(!0),()=>{l?i(!1):s(!1)}),[l,i,s]),o.type==="hover"?C.createElement(X_,{...r,ref:t,forceMount:n}):o.type==="scroll"?C.createElement(J_,{...r,ref:t,forceMount:n}):o.type==="auto"?C.createElement(cE,{...r,ref:t,forceMount:n}):o.type==="always"?C.createElement(ny,{...r,ref:t}):null});function Z_(e,t=()=>{}){let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const i={left:e.scrollLeft,top:e.scrollTop},s=n.left!==i.left,l=n.top!==i.top;(s||l)&&t(),n=i,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)}const eA=p.forwardRef((e,t)=>{const{style:n,...r}=e,o=yr(),i=aE(),{onThumbPositionChange:s}=i,l=Zt(t,d=>i.onThumbChange(d)),c=p.useRef(),u=Yd(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const{viewport:d}=o;if(d){const f=()=>{if(u(),!c.current){const h=Z_(d,s);c.current=h,s()}};return s(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[o.viewport,u,s]),C.createElement("div",{"data-state":i.hasThumb?"visible":"hidden",...r,ref:l,style:{width:"var(--sa-thumb-width)",height:"var(--sa-thumb-height)",...n},onPointerDownCapture:Ki(e.onPointerDownCapture,d=>{const h=d.target.getBoundingClientRect(),m=d.clientX-h.left,g=d.clientY-h.top;i.onThumbPointerDown({x:m,y:g})}),onPointerUp:Ki(e.onPointerUp,i.onThumbPointerUp)})}),Zx=C.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=aE();return n||o.hasThumb?C.createElement(eA,{ref:t,...r}):null}),uE=p.forwardRef(({children:e,style:t,...n},r)=>{const o=yr(),i=Zt(r,o.onViewportChange);return C.createElement(W,{...n,ref:i,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...t}},C.createElement("div",{style:{minWidth:"100%",display:"table"},ref:o.onContentChange},e))});uE.displayName="@mantine/core/ScrollAreaViewport";var ry={root:"m-d57069b5",viewport:"m-c0783ff9",viewportInner:"m-f8f631dd",scrollbar:"m-c44ba933",thumb:"m-d8b5e363",corner:"m-21657268"};const dE={scrollHideDelay:1e3,type:"hover",scrollbars:"xy"},tA=(e,{scrollbarSize:t})=>({root:{"--scrollarea-scrollbar-size":B(t)}}),vr=Q((e,t)=>{const n=U("ScrollArea",dE,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,scrollbarSize:c,vars:u,type:d,scrollHideDelay:f,viewportProps:h,viewportRef:m,onScrollPositionChange:g,children:y,offsetScrollbars:S,scrollbars:v,...x}=n,[w,b]=p.useState(!1),j=de({name:"ScrollArea",props:n,classes:ry,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:u,varsResolver:tA});return C.createElement(rE,{type:d==="never"?"always":d,scrollHideDelay:f,ref:t,scrollbars:v,...j("root"),...x},C.createElement(uE,{...h,...j("viewport",{style:h==null?void 0:h.style}),ref:m,"data-offset-scrollbars":S===!0?"xy":S||void 0,"data-scrollbars":v||void 0,onScroll:typeof g=="function"?({currentTarget:E})=>g({x:E.scrollLeft,y:E.scrollTop}):void 0},y),(v==="xy"||v==="x")&&C.createElement(Jx,{...j("scrollbar"),orientation:"horizontal","data-hidden":d==="never"||void 0,forceMount:!0,onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1)},C.createElement(Zx,{...j("thumb")})),(v==="xy"||v==="y")&&C.createElement(Jx,{...j("scrollbar"),orientation:"vertical","data-hidden":d==="never"||void 0,forceMount:!0,onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1)},C.createElement(Zx,{...j("thumb")})),C.createElement(W_,{...j("corner"),"data-hovered":w||void 0,"data-hidden":d==="never"||void 0}))});vr.displayName="@mantine/core/ScrollArea";const oy=Q((e,t)=>{const{children:n,classNames:r,styles:o,scrollbarSize:i,scrollHideDelay:s,type:l,dir:c,offsetScrollbars:u,viewportRef:d,onScrollPositionChange:f,unstyled:h,variant:m,viewportProps:g,scrollbars:y,style:S,vars:v,...x}=U("ScrollAreaAutosize",dE,e);return C.createElement(W,{...x,ref:t,style:[{display:"flex",overflow:"auto"},S]},C.createElement(W,{style:{display:"flex",flexDirection:"column",flex:1}},C.createElement(vr,{classNames:r,styles:o,scrollHideDelay:s,scrollbarSize:i,type:l,dir:c,offsetScrollbars:u,viewportRef:d,onScrollPositionChange:f,unstyled:h,variant:m,viewportProps:g,vars:v,scrollbars:y},n)))});vr.classes=ry;oy.displayName="@mantine/core/ScrollAreaAutosize";oy.classes=ry;vr.Autosize=oy;var fE={root:"m-87cf2631"};const nA={__staticSelector:"UnstyledButton"},Jn=vn((e,t)=>{const n=U("UnstyledButton",nA,e),{className:r,component:o="button",__staticSelector:i,unstyled:s,classNames:l,styles:c,style:u,...d}=n,f=de({name:i,props:n,classes:fE,className:r,style:u,classNames:l,styles:c,unstyled:s});return C.createElement(W,{...f("root",{focusable:!0}),component:o,ref:t,type:o==="button"?"button":void 0,...d})});Jn.classes=fE;Jn.displayName="@mantine/core/UnstyledButton";var hE={root:"m-515a97f8"};const rA={},iy=Q((e,t)=>{const n=U("VisuallyHidden",rA,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,...u}=n,d=de({name:"VisuallyHidden",classes:hE,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l});return C.createElement(W,{component:"span",ref:t,...d("root"),...u})});iy.classes=hE;iy.displayName="@mantine/core/VisuallyHidden";var pE={root:"m-1b7284a3"};const oA={},iA=(e,{radius:t,shadow:n})=>({root:{"--paper-radius":t===void 0?void 0:gt(t),"--paper-shadow":ng(n)}}),zn=vn((e,t)=>{const n=U("Paper",oA,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,withBorder:c,vars:u,radius:d,shadow:f,variant:h,mod:m,...g}=n,y=de({name:"Paper",props:n,classes:pE,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:u,varsResolver:iA});return C.createElement(W,{ref:t,mod:[{"data-with-border":c},m],...y("root"),variant:h,...g})});zn.classes=pE;zn.displayName="@mantine/core/Paper";function vi(e){return mE(e)?(e.nodeName||"").toLowerCase():"#document"}function Bn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mo(e){var t;return(t=(mE(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function mE(e){return e instanceof Node||e instanceof Bn(e).Node}function jt(e){return e instanceof Element||e instanceof Bn(e).Element}function Zn(e){return e instanceof HTMLElement||e instanceof Bn(e).HTMLElement}function mm(e){return typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Bn(e).ShadowRoot}function Cc(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=er(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function sA(e){return["table","td","th"].includes(vi(e))}function sy(e){const t=ay(),n=er(e);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function aA(e){let t=ts(e);for(;Zn(t)&&!Ea(t);){if(sy(t))return t;t=ts(t)}return null}function ay(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ea(e){return["html","body","#document"].includes(vi(e))}function er(e){return Bn(e).getComputedStyle(e)}function gf(e){return jt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function ts(e){if(vi(e)==="html")return e;const t=e.assignedSlot||e.parentNode||mm(e)&&e.host||Mo(e);return mm(t)?t.host:t}function gE(e){const t=ts(e);return Ea(t)?e.ownerDocument?e.ownerDocument.body:e.body:Zn(t)&&Cc(t)?t:gE(t)}function wo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gE(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),s=Bn(o);return i?t.concat(s,s.visualViewport||[],Cc(o)?o:[],s.frameElement&&n?wo(s.frameElement):[]):t.concat(o,wo(o,[],n))}function e1(e){let t=e.activeElement;for(;((n=t)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;t=t.shadowRoot.activeElement}return t}function tc(e,t){if(!e||!t)return!1;const n=t.getRootNode==null?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&mm(n)){let r=t;for(;r;){if(e===r)return!0;r=r.parentNode||r.host}}return!1}function yE(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function vE(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(t=>{let{brand:n,version:r}=t;return n+"/"+r}).join(" "):navigator.userAgent}function lA(e){return dA()?!1:!t1()&&e.width===0&&e.height===0||t1()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function cA(){return/apple/i.test(navigator.vendor)}function t1(){const e=/android/i;return e.test(yE())||e.test(vE())}function uA(){return yE().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function dA(){return vE().includes("jsdom/")}function xE(e,t){const n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}function fA(e){return"nativeEvent"in e}function hA(e){return e.matches("html,body")}function Vi(e){return(e==null?void 0:e.ownerDocument)||document}function Xh(e,t){if(t==null)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return n.target!=null&&t.contains(n.target)}function Bs(e){return"composedPath"in e?e.composedPath()[0]:e.target}const pA="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function mA(e){return Zn(e)&&e.matches(pA)}const Mr=Math.min,pn=Math.max,Td=Math.round,Eu=Math.floor,xi=e=>({x:e,y:e}),gA={left:"right",right:"left",bottom:"top",top:"bottom"},yA={start:"end",end:"start"};function gm(e,t,n){return pn(e,Mr(t,n))}function ko(e,t){return typeof e=="function"?e(t):e}function Lr(e){return e.split("-")[0]}function za(e){return e.split("-")[1]}function ly(e){return e==="x"?"y":"x"}function cy(e){return e==="y"?"height":"width"}function gs(e){return["top","bottom"].includes(Lr(e))?"y":"x"}function uy(e){return ly(gs(e))}function vA(e,t,n){n===void 0&&(n=!1);const r=za(e),o=uy(e),i=cy(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=kd(s)),[s,kd(s)]}function xA(e){const t=kd(e);return[ym(e),t,ym(t)]}function ym(e){return e.replace(/start|end/g,t=>yA[t])}function wA(e,t,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?i:s;default:return[]}}function SA(e,t,n,r){const o=za(e);let i=wA(Lr(e),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),t&&(i=i.concat(i.map(ym)))),i}function kd(e){return e.replace(/left|right|bottom|top/g,t=>gA[t])}function bA(e){return{top:0,right:0,bottom:0,left:0,...e}}function dy(e){return typeof e!="number"?bA(e):{top:e,right:e,bottom:e,left:e}}function ja(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}function n1(e,t,n){let{reference:r,floating:o}=e;const i=gs(t),s=uy(t),l=cy(s),c=Lr(t),u=i==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(za(t)){case"start":m[s]-=h*(n&&u?-1:1);break;case"end":m[s]+=h*(n&&u?-1:1);break}return m}const CA=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=n1(u,r,c),h=r,m={},g=0;for(let y=0;y<l.length;y++){const{name:S,fn:v}=l[y],{x,y:w,data:b,reset:j}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:s,elements:{reference:e,floating:t}});d=x??d,f=w??f,m={...m,[S]:{...m[S],...b}},j&&g<=50&&(g++,typeof j=="object"&&(j.placement&&(h=j.placement),j.rects&&(u=j.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:d,y:f}=n1(u,h,c)),y=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function fy(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=ko(t,e),g=dy(m),S=l[h?f==="floating"?"reference":"floating":f],v=ja(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(S)))==null||n?S:S.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),x=f==="floating"?{...s.floating,x:r,y:o}:s.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),b=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},j=ja(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:w,strategy:c}):x);return{top:(v.top-j.top+g.top)/b.y,bottom:(j.bottom-v.bottom+g.bottom)/b.y,left:(v.left-j.left+g.left)/b.x,right:(j.right-v.right+g.right)/b.x}}const EA=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=ko(e,t)||{};if(u==null)return{};const f=dy(d),h={x:n,y:r},m=uy(o),g=cy(m),y=await s.getDimensions(u),S=m==="y",v=S?"top":"left",x=S?"bottom":"right",w=S?"clientHeight":"clientWidth",b=i.reference[g]+i.reference[m]-h[m]-i.floating[g],j=h[m]-i.reference[m],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let P=E?E[w]:0;(!P||!await(s.isElement==null?void 0:s.isElement(E)))&&(P=l.floating[w]||i.floating[g]);const T=b/2-j/2,D=P/2-y[g]/2-1,_=Mr(f[v],D),O=Mr(f[x],D),I=_,$=P-y[g]-O,N=P/2-y[g]/2+T,L=gm(I,N,$),M=!c.arrow&&za(o)!=null&&N!==L&&i.reference[g]/2-(N<I?_:O)-y[g]/2<0,R=M?N<I?N-I:N-$:0;return{[m]:h[m]+R,data:{[m]:L,centerOffset:N-L-R,...M&&{alignmentOffset:R}},reset:M}}}),jA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...S}=ko(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=Lr(o),x=Lr(l)===l,w=await(c.isRTL==null?void 0:c.isRTL(u.floating)),b=h||(x||!y?[kd(l)]:xA(l));!h&&g!=="none"&&b.push(...SA(l,y,g,w));const j=[l,...b],E=await fy(t,S),P=[];let T=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&P.push(E[v]),f){const I=vA(o,s,w);P.push(E[I[0]],E[I[1]])}if(T=[...T,{placement:o,overflows:P}],!P.every(I=>I<=0)){var D,_;const I=(((D=i.flip)==null?void 0:D.index)||0)+1,$=j[I];if($)return{data:{index:I,overflows:T},reset:{placement:$}};let N=(_=T.filter(L=>L.overflows[0]<=0).sort((L,M)=>L.overflows[1]-M.overflows[1])[0])==null?void 0:_.placement;if(!N)switch(m){case"bestFit":{var O;const L=(O=T.map(M=>[M.placement,M.overflows.filter(R=>R>0).reduce((R,k)=>R+k,0)]).sort((M,R)=>M[1]-R[1])[0])==null?void 0:O[0];L&&(N=L);break}case"initialPlacement":N=l;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function wE(e){const t=Mr(...e.map(i=>i.left)),n=Mr(...e.map(i=>i.top)),r=pn(...e.map(i=>i.right)),o=pn(...e.map(i=>i.bottom));return{x:t,y:n,width:r-t,height:o-n}}function PA(e){const t=e.slice().sort((o,i)=>o.y-i.y),n=[];let r=null;for(let o=0;o<t.length;o++){const i=t[o];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>ja(wE(o)))}const TA=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:n,elements:r,rects:o,platform:i,strategy:s}=t,{padding:l=2,x:c,y:u}=ko(e,t),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),f=PA(d),h=ja(wE(d)),m=dy(l);function g(){if(f.length===2&&f[0].left>f[1].right&&c!=null&&u!=null)return f.find(S=>c>S.left-m.left&&c<S.right+m.right&&u>S.top-m.top&&u<S.bottom+m.bottom)||h;if(f.length>=2){if(gs(n)==="y"){const _=f[0],O=f[f.length-1],I=Lr(n)==="top",$=_.top,N=O.bottom,L=I?_.left:O.left,M=I?_.right:O.right,R=M-L,k=N-$;return{top:$,bottom:N,left:L,right:M,width:R,height:k,x:L,y:$}}const S=Lr(n)==="left",v=pn(...f.map(_=>_.right)),x=Mr(...f.map(_=>_.left)),w=f.filter(_=>S?_.left===x:_.right===v),b=w[0].top,j=w[w.length-1].bottom,E=x,P=v,T=P-E,D=j-b;return{top:b,bottom:j,left:E,right:P,width:T,height:D,x:E,y:b}}return h}const y=await i.getElementRects({reference:{getBoundingClientRect:g},floating:r.floating,strategy:s});return o.reference.x!==y.reference.x||o.reference.y!==y.reference.y||o.reference.width!==y.reference.width||o.reference.height!==y.reference.height?{reset:{rects:y}}:{}}}};async function kA(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Lr(n),l=za(n),c=gs(n)==="y",u=["left","top"].includes(s)?-1:1,d=i&&c?-1:1,f=ko(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const SE=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=t,c=await kA(t,e);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:i+c.y,data:{...c,placement:s}}}}},RA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:S=>{let{x:v,y:x}=S;return{x:v,y:x}}},...c}=ko(e,t),u={x:n,y:r},d=await fy(t,c),f=gs(Lr(o)),h=ly(f);let m=u[h],g=u[f];if(i){const S=h==="y"?"top":"left",v=h==="y"?"bottom":"right",x=m+d[S],w=m-d[v];m=gm(x,m,w)}if(s){const S=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[S],w=g-d[v];g=gm(x,g,w)}const y=l.fn({...t,[h]:m,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r}}}}},DA=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=ko(e,t),d={x:n,y:r},f=gs(o),h=ly(f);let m=d[h],g=d[f];const y=ko(l,t),S=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const w=h==="y"?"height":"width",b=i.reference[h]-i.floating[w]+S.mainAxis,j=i.reference[h]+i.reference[w]-S.mainAxis;m<b?m=b:m>j&&(m=j)}if(u){var v,x;const w=h==="y"?"width":"height",b=["top","left"].includes(Lr(o)),j=i.reference[f]-i.floating[w]+(b&&((v=s.offset)==null?void 0:v[f])||0)+(b?0:S.crossAxis),E=i.reference[f]+i.reference[w]+(b?0:((x=s.offset)==null?void 0:x[f])||0)-(b?S.crossAxis:0);g<j?g=j:g>E&&(g=E)}return{[h]:m,[f]:g}}}},IA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:o,elements:i}=t,{apply:s=()=>{},...l}=ko(e,t),c=await fy(t,l),u=Lr(n),d=za(n),f=gs(n)==="y",{width:h,height:m}=r.floating;let g,y;u==="top"||u==="bottom"?(g=u,y=d===(await(o.isRTL==null?void 0:o.isRTL(i.floating))?"start":"end")?"left":"right"):(y=u,g=d==="end"?"top":"bottom");const S=m-c[g],v=h-c[y],x=!t.middlewareData.shift;let w=S,b=v;if(f){const E=h-c.left-c.right;b=d||x?Mr(v,E):E}else{const E=m-c.top-c.bottom;w=d||x?Mr(S,E):E}if(x&&!d){const E=pn(c.left,0),P=pn(c.right,0),T=pn(c.top,0),D=pn(c.bottom,0);f?b=h-2*(E!==0||P!==0?E+P:pn(c.left,c.right)):w=m-2*(T!==0||D!==0?T+D:pn(c.top,c.bottom))}await s({...t,availableWidth:b,availableHeight:w});const j=await o.getDimensions(i.floating);return h!==j.width||m!==j.height?{reset:{rects:!0}}:{}}}};function bE(e){const t=er(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Zn(e),i=o?e.offsetWidth:n,s=o?e.offsetHeight:r,l=Td(n)!==i||Td(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function hy(e){return jt(e)?e:e.contextElement}function pa(e){const t=hy(e);if(!Zn(t))return xi(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=bE(t);let s=(i?Td(n.width):n.width)/r,l=(i?Td(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const _A=xi(0);function CE(e){const t=Bn(e);return!ay()||!t.visualViewport?_A:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function AA(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Bn(e)?!1:t}function ns(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=hy(e);let s=xi(1);t&&(r?jt(r)&&(s=pa(r)):s=pa(e));const l=AA(i,n,r)?CE(i):xi(0);let c=(o.left+l.x)/s.x,u=(o.top+l.y)/s.y,d=o.width/s.x,f=o.height/s.y;if(i){const h=Bn(i),m=r&&jt(r)?Bn(r):r;let g=h,y=g.frameElement;for(;y&&r&&m!==g;){const S=pa(y),v=y.getBoundingClientRect(),x=er(y),w=v.left+(y.clientLeft+parseFloat(x.paddingLeft))*S.x,b=v.top+(y.clientTop+parseFloat(x.paddingTop))*S.y;c*=S.x,u*=S.y,d*=S.x,f*=S.y,c+=w,u+=b,g=Bn(y),y=g.frameElement}}return ja({width:d,height:f,x:c,y:u})}const NA=[":popover-open",":modal"];function EE(e){return NA.some(t=>{try{return e.matches(t)}catch{return!1}})}function OA(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",s=Mo(r),l=t?EE(t.floating):!1;if(r===s||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=xi(1);const d=xi(0),f=Zn(r);if((f||!f&&!i)&&((vi(r)!=="body"||Cc(s))&&(c=gf(r)),Zn(r))){const h=ns(r);u=pa(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x,y:n.y*u.y-c.scrollTop*u.y+d.y}}function MA(e){return Array.from(e.getClientRects())}function jE(e){return ns(Mo(e)).left+gf(e).scrollLeft}function LA(e){const t=Mo(e),n=gf(e),r=e.ownerDocument.body,o=pn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=pn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+jE(e);const l=-n.scrollTop;return er(r).direction==="rtl"&&(s+=pn(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}function $A(e,t){const n=Bn(e),r=Mo(e),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,c=0;if(o){i=o.width,s=o.height;const u=ay();(!u||u&&t==="fixed")&&(l=o.offsetLeft,c=o.offsetTop)}return{width:i,height:s,x:l,y:c}}function FA(e,t){const n=ns(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Zn(e)?pa(e):xi(1),s=e.clientWidth*i.x,l=e.clientHeight*i.y,c=o*i.x,u=r*i.y;return{width:s,height:l,x:c,y:u}}function r1(e,t,n){let r;if(t==="viewport")r=$A(e,n);else if(t==="document")r=LA(Mo(e));else if(jt(t))r=FA(t,n);else{const o=CE(e);r={...t,x:t.x-o.x,y:t.y-o.y}}return ja(r)}function PE(e,t){const n=ts(e);return n===t||!jt(n)||Ea(n)?!1:er(n).position==="fixed"||PE(n,t)}function zA(e,t){const n=t.get(e);if(n)return n;let r=wo(e,[],!1).filter(l=>jt(l)&&vi(l)!=="body"),o=null;const i=er(e).position==="fixed";let s=i?ts(e):e;for(;jt(s)&&!Ea(s);){const l=er(s),c=sy(s);!c&&l.position==="fixed"&&(o=null),(i?!c&&!o:!c&&l.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Cc(s)&&!c&&PE(e,s))?r=r.filter(d=>d!==s):o=l,s=ts(s)}return t.set(e,r),r}function BA(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const s=[...n==="clippingAncestors"?zA(t,this._c):[].concat(n),r],l=s[0],c=s.reduce((u,d)=>{const f=r1(t,d,o);return u.top=pn(f.top,u.top),u.right=Mr(f.right,u.right),u.bottom=Mr(f.bottom,u.bottom),u.left=pn(f.left,u.left),u},r1(t,l,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function UA(e){const{width:t,height:n}=bE(e);return{width:t,height:n}}function VA(e,t,n){const r=Zn(t),o=Mo(t),i=n==="fixed",s=ns(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=xi(0);if(r||!r&&!i)if((vi(t)!=="body"||Cc(o))&&(l=gf(t)),r){const f=ns(t,!0,i,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else o&&(c.x=jE(o));const u=s.left+l.scrollLeft-c.x,d=s.top+l.scrollTop-c.y;return{x:u,y:d,width:s.width,height:s.height}}function o1(e,t){return!Zn(e)||er(e).position==="fixed"?null:t?t(e):e.offsetParent}function TE(e,t){const n=Bn(e);if(!Zn(e)||EE(e))return n;let r=o1(e,t);for(;r&&sA(r)&&er(r).position==="static";)r=o1(r,t);return r&&(vi(r)==="html"||vi(r)==="body"&&er(r).position==="static"&&!sy(r))?n:r||aA(e)||n}const WA=async function(e){const t=this.getOffsetParent||TE,n=this.getDimensions;return{reference:VA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,...await n(e.floating)}}};function HA(e){return er(e).direction==="rtl"}const qA={convertOffsetParentRelativeRectToViewportRelativeRect:OA,getDocumentElement:Mo,getClippingRect:BA,getOffsetParent:TE,getElementRects:WA,getClientRects:MA,getDimensions:UA,getScale:pa,isElement:jt,isRTL:HA};function GA(e,t){let n=null,r;const o=Mo(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const{left:u,top:d,width:f,height:h}=e.getBoundingClientRect();if(l||t(),!f||!h)return;const m=Eu(d),g=Eu(o.clientWidth-(u+f)),y=Eu(o.clientHeight-(d+h)),S=Eu(u),x={rootMargin:-m+"px "+-g+"px "+-y+"px "+-S+"px",threshold:pn(0,Mr(1,c))||1};let w=!0;function b(j){const E=j[0].intersectionRatio;if(E!==c){if(!w)return s();E?s(!1,E):r=setTimeout(()=>{s(!1,1e-7)},100)}w=!1}try{n=new IntersectionObserver(b,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(b,x)}n.observe(e)}return s(!0),i}function QA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=hy(e),d=o||i?[...u?wo(u):[],...wo(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),i&&v.addEventListener("resize",n)});const f=u&&l?GA(u,n):null;let h=-1,m=null;s&&(m=new ResizeObserver(v=>{let[x]=v;x&&x.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=m)==null||w.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let g,y=c?ns(e):null;c&&S();function S(){const v=ns(e);y&&(v.x!==y.x||v.y!==y.y||v.width!==y.width||v.height!==y.height)&&n(),y=v,g=requestAnimationFrame(S)}return n(),()=>{var v;d.forEach(x=>{o&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),f==null||f(),(v=m)==null||v.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const py=RA,kE=jA,KA=IA,i1=EA,RE=TA,YA=DA,XA=(e,t,n)=>{const r=new Map,o={platform:qA,...n},i={...o.platform,_c:r};return CA(e,t,{...o,platform:i})},DE=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?i1({element:r.current,padding:o}).fn(n):{}:r?i1({element:r,padding:o}).fn(n):{}}}};var Gu=typeof document<"u"?p.useLayoutEffect:p.useEffect;function Rd(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Rd(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Rd(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function IE(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function s1(e,t){const n=IE(e);return Math.round(t*n)/n}function a1(e){const t=p.useRef(e);return Gu(()=>{t.current=e}),t}function JA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);Rd(h,r)||m(r);const[g,y]=p.useState(null),[S,v]=p.useState(null),x=p.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),w=p.useCallback(R=>{R!==P.current&&(P.current=R,v(R))},[]),b=i||g,j=s||S,E=p.useRef(null),P=p.useRef(null),T=p.useRef(d),D=c!=null,_=a1(c),O=a1(o),I=p.useCallback(()=>{if(!E.current||!P.current)return;const R={placement:t,strategy:n,middleware:h};O.current&&(R.platform=O.current),XA(E.current,P.current,R).then(k=>{const F={...k,isPositioned:!0};$.current&&!Rd(T.current,F)&&(T.current=F,bc.flushSync(()=>{f(F)}))})},[h,t,n,O]);Gu(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[u]);const $=p.useRef(!1);Gu(()=>($.current=!0,()=>{$.current=!1}),[]),Gu(()=>{if(b&&(E.current=b),j&&(P.current=j),b&&j){if(_.current)return _.current(b,j,I);I()}},[b,j,I,_,D]);const N=p.useMemo(()=>({reference:E,floating:P,setReference:x,setFloating:w}),[x,w]),L=p.useMemo(()=>({reference:b,floating:j}),[b,j]),M=p.useMemo(()=>{const R={position:n,left:0,top:0};if(!L.floating)return R;const k=s1(L.floating,d.x),F=s1(L.floating,d.y);return l?{...R,transform:"translate("+k+"px, "+F+"px)",...IE(L.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:k,top:F}},[n,l,L.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:I,refs:N,elements:L,floatingStyles:M}),[d,I,N,L,M])}const ZA=eg.useInsertionEffect,e4=ZA||(e=>e());function Us(e){const t=p.useRef(()=>{});return e4(()=>{t.current=e}),p.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var So=typeof document<"u"?p.useLayoutEffect:p.useEffect;let Jh=!1,t4=0;const l1=()=>"floating-ui-"+t4++;function n4(){const[e,t]=p.useState(()=>Jh?l1():void 0);return So(()=>{e==null&&t(l1())},[]),p.useEffect(()=>{Jh||(Jh=!0)},[]),e}const r4=eg.useId,_E=r4||n4;function o4(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,((r=e.get(t))==null?void 0:r.filter(o=>o!==n))||[])}}}const i4=p.createContext(null),s4=p.createContext(null),my=()=>{var e;return((e=p.useContext(i4))==null?void 0:e.id)||null},gy=()=>p.useContext(s4);function yy(e){return"data-floating-ui-"+e}function c1(e){const t=p.useRef(e);return So(()=>{t.current=e}),t}const u1=yy("safe-polygon");function Qu(e,t,n){return n&&!xE(n)?0:typeof e=="number"?e:e==null?void 0:e[t]}function a4(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:{domReference:s,floating:l},refs:c}=e,{enabled:u=!0,delay:d=0,handleClose:f=null,mouseOnly:h=!1,restMs:m=0,move:g=!0}=t,y=gy(),S=my(),v=c1(f),x=c1(d),w=p.useRef(),b=p.useRef(),j=p.useRef(),E=p.useRef(),P=p.useRef(!0),T=p.useRef(!1),D=p.useRef(()=>{}),_=p.useCallback(()=>{var N;const L=(N=o.current.openEvent)==null?void 0:N.type;return(L==null?void 0:L.includes("mouse"))&&L!=="mousedown"},[o]);p.useEffect(()=>{if(!u)return;function N(L){let{open:M}=L;M||(clearTimeout(b.current),clearTimeout(E.current),P.current=!0)}return i.on("openchange",N),()=>{i.off("openchange",N)}},[u,i]),p.useEffect(()=>{if(!u||!v.current||!n)return;function N(M){_()&&r(!1,M,"hover")}const L=Vi(l).documentElement;return L.addEventListener("mouseleave",N),()=>{L.removeEventListener("mouseleave",N)}},[l,n,r,u,v,_]);const O=p.useCallback(function(N,L,M){L===void 0&&(L=!0),M===void 0&&(M="hover");const R=Qu(x.current,"close",w.current);R&&!j.current?(clearTimeout(b.current),b.current=setTimeout(()=>r(!1,N,M),R)):L&&(clearTimeout(b.current),r(!1,N,M))},[x,r]),I=p.useCallback(()=>{D.current(),j.current=void 0},[]),$=p.useCallback(()=>{if(T.current){const N=Vi(c.floating.current).body;N.style.pointerEvents="",N.removeAttribute(u1),T.current=!1}},[c]);return p.useEffect(()=>{if(!u)return;function N(){return o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1}function L(k){if(clearTimeout(b.current),P.current=!1,h&&!xE(w.current)||m>0&&Qu(x.current,"open")===0)return;const F=Qu(x.current,"open",w.current);F?b.current=setTimeout(()=>{r(!0,k,"hover")},F):r(!0,k,"hover")}function M(k){if(N())return;D.current();const F=Vi(l);if(clearTimeout(E.current),v.current){n||clearTimeout(b.current),j.current=v.current({...e,tree:y,x:k.clientX,y:k.clientY,onClose(){$(),I(),O(k,!0,"safe-polygon")}});const G=j.current;F.addEventListener("mousemove",G),D.current=()=>{F.removeEventListener("mousemove",G)};return}(w.current==="touch"?!tc(l,k.relatedTarget):!0)&&O(k)}function R(k){N()||v.current==null||v.current({...e,tree:y,x:k.clientX,y:k.clientY,onClose(){$(),I(),O(k)}})(k)}if(jt(s)){const k=s;return n&&k.addEventListener("mouseleave",R),l==null||l.addEventListener("mouseleave",R),g&&k.addEventListener("mousemove",L,{once:!0}),k.addEventListener("mouseenter",L),k.addEventListener("mouseleave",M),()=>{n&&k.removeEventListener("mouseleave",R),l==null||l.removeEventListener("mouseleave",R),g&&k.removeEventListener("mousemove",L),k.removeEventListener("mouseenter",L),k.removeEventListener("mouseleave",M)}}},[s,l,u,e,h,m,g,O,I,$,r,n,y,x,v,o]),So(()=>{var N;if(u&&n&&(N=v.current)!=null&&N.__options.blockPointerEvents&&_()){const M=Vi(l).body;if(M.setAttribute(u1,""),M.style.pointerEvents="none",T.current=!0,jt(s)&&l){var L;const R=s,k=y==null||(L=y.nodesRef.current.find(F=>F.id===S))==null||(L=L.context)==null?void 0:L.elements.floating;return k&&(k.style.pointerEvents=""),R.style.pointerEvents="auto",l.style.pointerEvents="auto",()=>{R.style.pointerEvents="",l.style.pointerEvents=""}}}},[u,n,S,l,s,y,v,_]),So(()=>{n||(w.current=void 0,I(),$())},[n,I,$]),p.useEffect(()=>()=>{I(),clearTimeout(b.current),clearTimeout(E.current),$()},[u,s,I,$]),p.useMemo(()=>{if(!u)return{};function N(L){w.current=L.pointerType}return{reference:{onPointerDown:N,onPointerEnter:N,onMouseMove(L){n||m===0||(clearTimeout(E.current),E.current=setTimeout(()=>{P.current||r(!0,L.nativeEvent,"hover")},m))}},floating:{onMouseEnter(){clearTimeout(b.current)},onMouseLeave(L){O(L.nativeEvent,!1)}}}},[u,m,n,r,O])}const AE=p.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:()=>{},setState:()=>{},isInstantPhase:!1}),NE=()=>p.useContext(AE),l4=e=>{let{children:t,delay:n,timeoutMs:r=0}=e;const[o,i]=p.useReducer((c,u)=>({...c,...u}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),s=p.useRef(null),l=p.useCallback(c=>{i({currentId:c})},[]);return So(()=>{o.currentId?s.current===null?s.current=o.currentId:i({isInstantPhase:!0}):(i({isInstantPhase:!1}),s.current=null)},[o.currentId]),p.createElement(AE.Provider,{value:p.useMemo(()=>({...o,setState:i,setCurrentId:l}),[o,l])},t)},c4=(e,t)=>{let{open:n,onOpenChange:r}=e,{id:o}=t;const{currentId:i,setCurrentId:s,initialDelay:l,setState:c,timeoutMs:u}=NE();So(()=>{i&&(c({delay:{open:1,close:Qu(l,"close")}}),i!==o&&r(!1))},[o,r,c,i,l]),So(()=>{function d(){r(!1),c({delay:l,currentId:null})}if(!n&&i===o){if(u){const f=window.setTimeout(d,u);return()=>{clearTimeout(f)}}d()}},[n,c,i,o,r,l,u]),So(()=>{n&&s(o)},[n,s,o])};function Zh(e,t){let n=e.filter(o=>{var i;return o.parentId===t&&((i=o.context)==null?void 0:i.open)}),r=n;for(;r.length;)r=e.filter(o=>{var i;return(i=r)==null?void 0:i.some(s=>{var l;return o.parentId===s.id&&((l=o.context)==null?void 0:l.open)})}),n=n.concat(r);return n}const u4={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},d4={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},d1=e=>{var t,n;return{escapeKey:typeof e=="boolean"?e:(t=e==null?void 0:e.escapeKey)!=null?t:!1,outsidePress:typeof e=="boolean"?e:(n=e==null?void 0:e.outsidePress)!=null?n:!0}};function f4(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,nodeId:o,elements:{reference:i,domReference:s,floating:l},dataRef:c}=e,{enabled:u=!0,escapeKey:d=!0,outsidePress:f=!0,outsidePressEvent:h="pointerdown",referencePress:m=!1,referencePressEvent:g="pointerdown",ancestorScroll:y=!1,bubbles:S,capture:v}=t,x=gy(),w=Us(typeof f=="function"?f:()=>!1),b=typeof f=="function"?w:f,j=p.useRef(!1),E=p.useRef(!1),{escapeKey:P,outsidePress:T}=d1(S),{escapeKey:D,outsidePress:_}=d1(v),O=Us(L=>{if(!n||!u||!d||L.key!=="Escape")return;const M=x?Zh(x.nodesRef.current,o):[];if(!P&&(L.stopPropagation(),M.length>0)){let R=!0;if(M.forEach(k=>{var F;if((F=k.context)!=null&&F.open&&!k.context.dataRef.current.__escapeKeyBubbles){R=!1;return}}),!R)return}r(!1,fA(L)?L.nativeEvent:L,"escape-key")}),I=Us(L=>{var M;const R=()=>{var k;O(L),(k=Bs(L))==null||k.removeEventListener("keydown",R)};(M=Bs(L))==null||M.addEventListener("keydown",R)}),$=Us(L=>{const M=j.current;j.current=!1;const R=E.current;if(E.current=!1,h==="click"&&R||M||typeof b=="function"&&!b(L))return;const k=Bs(L),F="["+yy("inert")+"]",q=Vi(l).querySelectorAll(F);let G=jt(k)?k:null;for(;G&&!Ea(G);){const me=ts(G);if(Ea(me)||!jt(me))break;G=me}if(q.length&&jt(k)&&!hA(k)&&!tc(k,l)&&Array.from(q).every(me=>!tc(G,me)))return;if(Zn(k)&&l){const me=k.clientWidth>0&&k.scrollWidth>k.clientWidth,Ce=k.clientHeight>0&&k.scrollHeight>k.clientHeight;let je=Ce&&L.offsetX>k.clientWidth;if(Ce&&er(k).direction==="rtl"&&(je=L.offsetX<=k.offsetWidth-k.clientWidth),je||me&&L.offsetY>k.clientHeight)return}const oe=x&&Zh(x.nodesRef.current,o).some(me=>{var Ce;return Xh(L,(Ce=me.context)==null?void 0:Ce.elements.floating)});if(Xh(L,l)||Xh(L,s)||oe)return;const xe=x?Zh(x.nodesRef.current,o):[];if(xe.length>0){let me=!0;if(xe.forEach(Ce=>{var je;if((je=Ce.context)!=null&&je.open&&!Ce.context.dataRef.current.__outsidePressBubbles){me=!1;return}}),!me)return}r(!1,L,"outside-press")}),N=Us(L=>{var M;const R=()=>{var k;$(L),(k=Bs(L))==null||k.removeEventListener(h,R)};(M=Bs(L))==null||M.addEventListener(h,R)});return p.useEffect(()=>{if(!n||!u)return;c.current.__escapeKeyBubbles=P,c.current.__outsidePressBubbles=T;function L(k){r(!1,k,"ancestor-scroll")}const M=Vi(l);d&&M.addEventListener("keydown",D?I:O,D),b&&M.addEventListener(h,_?N:$,_);let R=[];return y&&(jt(s)&&(R=wo(s)),jt(l)&&(R=R.concat(wo(l))),!jt(i)&&i&&i.contextElement&&(R=R.concat(wo(i.contextElement)))),R=R.filter(k=>{var F;return k!==((F=M.defaultView)==null?void 0:F.visualViewport)}),R.forEach(k=>{k.addEventListener("scroll",L,{passive:!0})}),()=>{d&&M.removeEventListener("keydown",D?I:O,D),b&&M.removeEventListener(h,_?N:$,_),R.forEach(k=>{k.removeEventListener("scroll",L)})}},[c,l,s,i,d,b,h,n,r,y,u,P,T,O,D,I,$,_,N]),p.useEffect(()=>{j.current=!1},[b,h]),p.useMemo(()=>u?{reference:{onKeyDown:O,[u4[g]]:L=>{m&&r(!1,L.nativeEvent,"reference-press")}},floating:{onKeyDown:O,onMouseDown(){E.current=!0},onMouseUp(){E.current=!0},[d4[h]]:()=>{j.current=!0}}}:{},[u,m,h,g,r,O])}function vy(e){var t;e===void 0&&(e={});const{open:n=!1,onOpenChange:r,nodeId:o}=e,[i,s]=p.useState(null),l=((t=e.elements)==null?void 0:t.reference)||i,c=JA(e),u=gy(),d=my()!=null,f=Us((j,E,P)=>{j&&(m.current.openEvent=E),g.emit("openchange",{open:j,event:E,reason:P,nested:d}),r==null||r(j,E,P)}),h=p.useRef(null),m=p.useRef({}),g=p.useState(()=>o4())[0],y=_E(),S=p.useCallback(j=>{const E=jt(j)?{getBoundingClientRect:()=>j.getBoundingClientRect(),contextElement:j}:j;c.refs.setReference(E)},[c.refs]),v=p.useCallback(j=>{(jt(j)||j===null)&&(h.current=j,s(j)),(jt(c.refs.reference.current)||c.refs.reference.current===null||j!==null&&!jt(j))&&c.refs.setReference(j)},[c.refs]),x=p.useMemo(()=>({...c.refs,setReference:v,setPositionReference:S,domReference:h}),[c.refs,v,S]),w=p.useMemo(()=>({...c.elements,domReference:l}),[c.elements,l]),b=p.useMemo(()=>({...c,refs:x,elements:w,dataRef:m,nodeId:o,floatingId:y,events:g,open:n,onOpenChange:f}),[c,o,y,g,n,f,x,w]);return So(()=>{const j=u==null?void 0:u.nodesRef.current.find(E=>E.id===o);j&&(j.context=b)}),p.useMemo(()=>({...c,context:b,refs:x,elements:w}),[c,x,w,b])}function h4(e,t){t===void 0&&(t={});const{open:n,onOpenChange:r,events:o,refs:i,elements:{domReference:s}}=e,{enabled:l=!0,visibleOnly:c=!0}=t,u=p.useRef(!1),d=p.useRef(),f=p.useRef(!0);return p.useEffect(()=>{if(!l)return;const h=Bn(s);function m(){!n&&Zn(s)&&s===e1(Vi(s))&&(u.current=!0)}function g(){f.current=!0}return h.addEventListener("blur",m),h.addEventListener("keydown",g,!0),()=>{h.removeEventListener("blur",m),h.removeEventListener("keydown",g,!0)}},[s,n,l]),p.useEffect(()=>{if(!l)return;function h(m){let{reason:g}=m;(g==="reference-press"||g==="escape-key")&&(u.current=!0)}return o.on("openchange",h),()=>{o.off("openchange",h)}},[o,l]),p.useEffect(()=>()=>{clearTimeout(d.current)},[]),p.useMemo(()=>l?{reference:{onPointerDown(h){lA(h.nativeEvent)||(f.current=!1)},onMouseLeave(){u.current=!1},onFocus(h){if(u.current)return;const m=Bs(h.nativeEvent);if(c&&jt(m))try{if(cA()&&uA())throw Error();if(!m.matches(":focus-visible"))return}catch{if(!f.current&&!mA(m))return}r(!0,h.nativeEvent,"focus")},onBlur(h){u.current=!1;const m=h.relatedTarget,g=jt(m)&&m.hasAttribute(yy("focus-guard"))&&m.getAttribute("data-type")==="outside";d.current=window.setTimeout(()=>{const y=e1(s?s.ownerDocument:document);!m&&y===s||tc(i.floating.current,y)||tc(s,y)||g||r(!1,h.nativeEvent,"focus")})}}}:{},[l,c,s,i,r])}const f1="active",h1="selected";function ep(e,t,n){const r=new Map,o=n==="item";let i=e;if(o&&e){const{[f1]:s,[h1]:l,...c}=e;i=c}return{...n==="floating"&&{tabIndex:-1},...i,...t.map(s=>{const l=s?s[n]:null;return typeof l=="function"?e?l(e):null:l}).concat(e).reduce((s,l)=>(l&&Object.entries(l).forEach(c=>{let[u,d]=c;if(!(o&&[f1,h1].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),s[u]=function(){for(var h,m=arguments.length,g=new Array(m),y=0;y<m;y++)g[y]=arguments[y];return(h=r.get(u))==null?void 0:h.map(S=>S(...g)).find(S=>S!==void 0)}}}else s[u]=d}),s),{})}}function p4(e){e===void 0&&(e=[]);const t=e,n=p.useCallback(i=>ep(i,e,"reference"),t),r=p.useCallback(i=>ep(i,e,"floating"),t),o=p.useCallback(i=>ep(i,e,"item"),e.map(i=>i==null?void 0:i.item));return p.useMemo(()=>({getReferenceProps:n,getFloatingProps:r,getItemProps:o}),[n,r,o])}const m4=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function g4(e,t){var n;t===void 0&&(t={});const{open:r,floatingId:o}=e,{enabled:i=!0,role:s="dialog"}=t,l=(n=m4.get(s))!=null?n:s,c=_E(),d=my()!=null;return p.useMemo(()=>{if(!i)return{};const f={id:o,...l&&{role:l}};return l==="tooltip"||s==="label"?{reference:{["aria-"+(s==="label"?"labelledby":"describedby")]:r?o:void 0},floating:f}:{reference:{"aria-expanded":r?"true":"false","aria-haspopup":l==="alertdialog"?"dialog":l,"aria-controls":r?o:void 0,...l==="listbox"&&{role:"combobox"},...l==="menu"&&{id:c},...l==="menu"&&d&&{role:"menuitem"},...s==="select"&&{"aria-autocomplete":"none"},...s==="combobox"&&{"aria-autocomplete":"list"}},floating:{...f,...l==="menu"&&{"aria-labelledby":c}},item(h){let{active:m,selected:g}=h;const y={role:"option",...m&&{id:o+"-option"}};switch(s){case"select":return{...y,"aria-selected":m&&g};case"combobox":return{...y,...m&&{"aria-selected":!0}}}return{}}}},[i,s,l,r,o,c,d])}function OE(e,t){if(e==="rtl"&&(t.includes("right")||t.includes("left"))){const[n,r]=t.split("-"),o=n==="right"?"left":"right";return r===void 0?o:`${o}-${r}`}return t}function p1(e,t,n,r){return e==="center"||r==="center"?{top:t}:e==="end"?{bottom:n}:e==="start"?{top:n}:{}}function m1(e,t,n,r,o){return e==="center"||r==="center"?{left:t}:e==="end"?{[o==="ltr"?"right":"left"]:n}:e==="start"?{[o==="ltr"?"left":"right"]:n}:{}}const y4={bottom:"borderTopLeftRadius",left:"borderTopRightRadius",right:"borderBottomLeftRadius",top:"borderBottomRightRadius"};function v4({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:o,arrowX:i,arrowY:s,dir:l}){const[c,u="center"]=e.split("-"),d={width:B(t),height:B(t),transform:"rotate(45deg)",position:"absolute",[y4[c]]:B(r)},f=B(-t/2);return c==="left"?{...d,...p1(u,s,n,o),right:f,borderLeftColor:"transparent",borderBottomColor:"transparent"}:c==="right"?{...d,...p1(u,s,n,o),left:f,borderRightColor:"transparent",borderTopColor:"transparent"}:c==="top"?{...d,...m1(u,i,n,o,l),bottom:f,borderTopColor:"transparent",borderLeftColor:"transparent"}:c==="bottom"?{...d,...m1(u,i,n,o,l),top:f,borderBottomColor:"transparent",borderRightColor:"transparent"}:{}}const xy=p.forwardRef(({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:o,visible:i,arrowX:s,arrowY:l,style:c,...u},d)=>{const{dir:f}=hs();return i?C.createElement("div",{...u,ref:d,style:{...c,...v4({position:e,arrowSize:t,arrowOffset:n,arrowRadius:r,arrowPosition:o,dir:f,arrowX:s,arrowY:l})}}):null});xy.displayName="@mantine/core/FloatingArrow";const[x4,ME]=Tn("Popover component was not found in the tree");function yf({children:e,active:t=!0,refProp:n="ref"}){const r=b2(t),o=Zt(r,e==null?void 0:e.ref);return Ao(e)?p.cloneElement(e,{[n]:o}):e}function LE(e){return C.createElement(iy,{tabIndex:-1,"data-autofocus":!0,...e})}yf.displayName="@mantine/core/FocusTrap";LE.displayName="@mantine/core/FocusTrapInitialFocus";yf.InitialFocus=LE;function w4(e){const t=document.createElement("div");return t.setAttribute("data-portal","true"),typeof e.className=="string"&&t.classList.add(...e.className.split(" ").filter(Boolean)),typeof e.style=="object"&&Object.assign(t.style,e.style),typeof e.id=="string"&&t.setAttribute("id",e.id),t}const S4={},$E=p.forwardRef((e,t)=>{const{children:n,target:r,...o}=U("Portal",S4,e),[i,s]=p.useState(!1),l=p.useRef(null);return Oa(()=>(s(!0),l.current=r?typeof r=="string"?document.querySelector(r):r:w4(o),ig(t,l.current),!r&&l.current&&document.body.appendChild(l.current),()=>{!r&&l.current&&document.body.removeChild(l.current)}),[r]),!i||!l.current?null:bc.createPortal(C.createElement(C.Fragment,null,n),l.current)});$E.displayName="@mantine/core/Portal";function ys({withinPortal:e=!0,children:t,...n}){return e?C.createElement($E,{...n},t):C.createElement(C.Fragment,null,t)}ys.displayName="@mantine/core/OptionalPortal";const ul=e=>({in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:`scale(.9) translateY(${B(e==="bottom"?10:-10)})`},transitionProperty:"transform, opacity"}),ju={fade:{in:{opacity:1},out:{opacity:0},transitionProperty:"opacity"},scale:{in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:"scale(0)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"scale-y":{in:{opacity:1,transform:"scaleY(1)"},out:{opacity:0,transform:"scaleY(0)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"scale-x":{in:{opacity:1,transform:"scaleX(1)"},out:{opacity:0,transform:"scaleX(0)"},common:{transformOrigin:"left"},transitionProperty:"transform, opacity"},"skew-up":{in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:`translateY(${B(-20)}) skew(-10deg, -5deg)`},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"skew-down":{in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:`translateY(${B(20)}) skew(-10deg, -5deg)`},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"rotate-left":{in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:`translateY(${B(20)}) rotate(-5deg)`},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"rotate-right":{in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:`translateY(${B(20)}) rotate(5deg)`},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"slide-down":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(-100%)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"slide-up":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(100%)"},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"slide-left":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(100%)"},common:{transformOrigin:"left"},transitionProperty:"transform, opacity"},"slide-right":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(-100%)"},common:{transformOrigin:"right"},transitionProperty:"transform, opacity"},pop:{...ul("bottom"),common:{transformOrigin:"center center"}},"pop-bottom-left":{...ul("bottom"),common:{transformOrigin:"bottom left"}},"pop-bottom-right":{...ul("bottom"),common:{transformOrigin:"bottom right"}},"pop-top-left":{...ul("top"),common:{transformOrigin:"top left"}},"pop-top-right":{...ul("top"),common:{transformOrigin:"top right"}}},g1={entering:"in",entered:"in",exiting:"out",exited:"out","pre-exiting":"out","pre-entering":"out"};function b4({transition:e,state:t,duration:n,timingFunction:r}){const o={transitionDuration:`${n}ms`,transitionTimingFunction:r};return typeof e=="string"?e in ju?{transitionProperty:ju[e].transitionProperty,...o,...ju[e].common,...ju[e][g1[t]]}:{}:{transitionProperty:e.transitionProperty,...o,...e.common,...e[g1[t]]}}function C4({duration:e,exitDuration:t,timingFunction:n,mounted:r,onEnter:o,onExit:i,onEntered:s,onExited:l}){const c=kt(),u=sg(),d=c.respectReducedMotion?u:!1,[f,h]=p.useState(d?0:e),[m,g]=p.useState(r?"entered":"exited"),y=p.useRef(-1),S=p.useRef(-1),v=x=>{const w=x?o:i,b=x?s:l;window.clearTimeout(y.current);const j=d?0:x?e:t;h(j),j===0?(typeof w=="function"&&w(),typeof b=="function"&&b(),g(x?"entered":"exited")):S.current=requestAnimationFrame(()=>{na.flushSync(()=>{g(x?"pre-entering":"pre-exiting")}),S.current=requestAnimationFrame(()=>{typeof w=="function"&&w(),g(x?"entering":"exiting"),y.current=window.setTimeout(()=>{typeof b=="function"&&b(),g(x?"entered":"exited")},j)})})};return Co(()=>{v(r)},[r]),p.useEffect(()=>()=>{window.clearTimeout(y.current),cancelAnimationFrame(S.current)},[]),{transitionDuration:f,transitionStatus:m,transitionTimingFunction:n||"ease"}}function Lo({keepMounted:e,transition:t="fade",duration:n=250,exitDuration:r=n,mounted:o,children:i,timingFunction:s="ease",onExit:l,onEntered:c,onEnter:u,onExited:d}){const{transitionDuration:f,transitionStatus:h,transitionTimingFunction:m}=C4({mounted:o,exitDuration:r,duration:n,timingFunction:s,onExit:l,onEntered:c,onEnter:u,onExited:d});return f===0?o?C.createElement(C.Fragment,null,i({})):e?i({display:"none"}):null:h==="exited"?e?i({display:"none"}):null:C.createElement(C.Fragment,null,i(b4({transition:t,duration:f,state:h,timingFunction:m})))}Lo.displayName="@mantine/core/Transition";var FE={dropdown:"m-38a85659",arrow:"m-a31dc6c1"};const E4={},wy=Q((e,t)=>{var S,v,x,w;const n=U("PopoverDropdown",E4,e),{className:r,style:o,vars:i,children:s,onKeyDownCapture:l,variant:c,classNames:u,styles:d,...f}=n,h=ME(),m=MS({opened:h.opened,shouldReturnFocus:h.returnFocus}),g=h.withRoles?{"aria-labelledby":h.getTargetId(),id:h.getDropdownId(),role:"dialog",tabIndex:-1}:{},y=Zt(t,h.floating);return h.disabled?null:C.createElement(ys,{...h.portalProps,withinPortal:h.withinPortal},C.createElement(Lo,{mounted:h.opened,...h.transitionProps,transition:((S=h.transitionProps)==null?void 0:S.transition)||"fade",duration:((v=h.transitionProps)==null?void 0:v.duration)??150,keepMounted:h.keepMounted,exitDuration:typeof((x=h.transitionProps)==null?void 0:x.exitDuration)=="number"?h.transitionProps.exitDuration:(w=h.transitionProps)==null?void 0:w.duration},b=>C.createElement(yf,{active:h.trapFocus},C.createElement(W,{...g,...f,variant:c,ref:y,onKeyDownCapture:c2(h.onClose,{active:h.closeOnEscape,onTrigger:m,onKeyDown:l}),"data-position":h.placement,...h.getStyles("dropdown",{className:r,props:n,classNames:u,styles:d,style:[{...b,zIndex:h.zIndex,top:h.y??0,left:h.x??0,width:h.width==="target"?void 0:B(h.width)},o]})},s,C.createElement(xy,{ref:h.arrowRef,arrowX:h.arrowX,arrowY:h.arrowY,visible:h.withArrow,position:h.placement,arrowSize:h.arrowSize,arrowRadius:h.arrowRadius,arrowOffset:h.arrowOffset,arrowPosition:h.arrowPosition,...h.getStyles("arrow",{props:n,classNames:u,styles:d})})))))});wy.classes=FE;wy.displayName="@mantine/core/PopoverDropdown";const j4={refProp:"ref",popupType:"dialog"},zE=Q((e,t)=>{const{children:n,refProp:r,popupType:o,...i}=U("PopoverTarget",j4,e);if(!Ao(n))throw new Error("Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const s=i,l=ME(),c=Zt(l.reference,n.ref,t),u=l.withRoles?{"aria-haspopup":o,"aria-expanded":l.opened,"aria-controls":l.getDropdownId(),id:l.getTargetId()}:{};return p.cloneElement(n,{...s,...u,...l.targetProps,className:et(l.targetProps.className,s.className,n.props.className),[r]:c,...l.controlled?null:{onClick:l.onToggle}})});zE.displayName="@mantine/core/PopoverTarget";function BE({opened:e,floating:t,position:n,positionDependencies:r}){const[o,i]=p.useState(0);p.useEffect(()=>{if(t.refs.reference.current&&t.refs.floating.current)return QA(t.refs.reference.current,t.refs.floating.current,t.update)},[t.refs.reference.current,t.refs.floating.current,e,o,n]),Co(()=>{t.update()},r),Co(()=>{i(s=>s+1)},[e])}function P4(e,t){var r,o,i,s;const n=[SE(e.offset)];return(r=e.middlewares)!=null&&r.shift&&n.push(py({limiter:YA()})),(o=e.middlewares)!=null&&o.flip&&n.push(kE()),(i=e.middlewares)!=null&&i.inline&&n.push(RE()),n.push(DE({element:e.arrowRef,padding:e.arrowOffset})),((s=e.middlewares)!=null&&s.size||e.width==="target")&&n.push(KA({apply({rects:l,availableWidth:c,availableHeight:u}){var h,m;const f=((h=t().refs.floating.current)==null?void 0:h.style)??{};(m=e.middlewares)!=null&&m.size&&Object.assign(f,{maxWidth:`${c}px`,maxHeight:`${u}px`}),e.width==="target"&&Object.assign(f,{width:`${l.reference.width}px`})}})),n}function T4(e){const[t,n]=gn({value:e.opened,defaultValue:e.defaultOpened,finalValue:!1,onChange:e.onChange}),r=()=>{var s;t&&((s=e.onClose)==null||s.call(e),n(!1))},o=()=>{var s,l;t?((s=e.onClose)==null||s.call(e),n(!1)):((l=e.onOpen)==null||l.call(e),n(!0))},i=vy({strategy:e.strategy,placement:e.position,middleware:P4(e,()=>i)});return BE({opened:e.opened,position:e.position,positionDependencies:e.positionDependencies||[],floating:i}),Co(()=>{var s;(s=e.onPositionChange)==null||s.call(e,i.placement)},[i.placement]),Co(()=>{var s,l;e.opened?(l=e.onOpen)==null||l.call(e):(s=e.onClose)==null||s.call(e)},[e.opened]),{floating:i,controlled:typeof e.opened=="boolean",opened:t,onClose:r,onToggle:o}}const k4={position:"bottom",offset:8,positionDependencies:[],transitionProps:{transition:"fade",duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:"side",closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,clickOutsideEvents:["mousedown","touchstart"],zIndex:zr("popover"),__staticSelector:"Popover",width:"max-content"},R4=(e,{radius:t,shadow:n})=>({dropdown:{"--popover-radius":t===void 0?void 0:gt(t),"--popover-shadow":ng(n)}});function Br(e){var ln,br,en,uo,re,De;const t=U("Popover",k4,e),{children:n,position:r,offset:o,onPositionChange:i,positionDependencies:s,opened:l,transitionProps:c,width:u,middlewares:d,withArrow:f,arrowSize:h,arrowOffset:m,arrowRadius:g,arrowPosition:y,unstyled:S,classNames:v,styles:x,closeOnClickOutside:w,withinPortal:b,portalProps:j,closeOnEscape:E,clickOutsideEvents:P,trapFocus:T,onClose:D,onOpen:_,onChange:O,zIndex:I,radius:$,shadow:N,id:L,defaultOpened:M,__staticSelector:R,withRoles:k,disabled:F,returnFocus:q,variant:G,keepMounted:oe,vars:xe,floatingStrategy:me,...Ce}=t,je=de({name:R,props:t,classes:FE,classNames:v,styles:x,unstyled:S,rootSelector:"dropdown",vars:xe,varsResolver:R4}),Be=p.useRef(null),[Me,Ke]=p.useState(null),[St,X]=p.useState(null),{dir:ke}=hs(),tt=kn(L),Ne=T4({middlewares:d,width:u,position:OE(ke,r),offset:typeof o=="number"?o+(f?h/2:0):o,arrowRef:Be,arrowOffset:m,onPositionChange:i,positionDependencies:s,opened:l,defaultOpened:M,onChange:O,onOpen:_,onClose:D,strategy:me});f2(()=>w&&Ne.onClose(),P,[Me,St]);const Ve=p.useCallback(qe=>{Ke(qe),Ne.floating.refs.setReference(qe)},[Ne.floating.refs.setReference]),Rt=p.useCallback(qe=>{X(qe),Ne.floating.refs.setFloating(qe)},[Ne.floating.refs.setFloating]);return C.createElement(x4,{value:{returnFocus:q,disabled:F,controlled:Ne.controlled,reference:Ve,floating:Rt,x:Ne.floating.x,y:Ne.floating.y,arrowX:(en=(br=(ln=Ne.floating)==null?void 0:ln.middlewareData)==null?void 0:br.arrow)==null?void 0:en.x,arrowY:(De=(re=(uo=Ne.floating)==null?void 0:uo.middlewareData)==null?void 0:re.arrow)==null?void 0:De.y,opened:Ne.opened,arrowRef:Be,transitionProps:c,width:u,withArrow:f,arrowSize:h,arrowOffset:m,arrowRadius:g,arrowPosition:y,placement:Ne.floating.placement,trapFocus:T,withinPortal:b,portalProps:j,zIndex:I,radius:$,shadow:N,closeOnEscape:E,onClose:Ne.onClose,onToggle:Ne.onToggle,getTargetId:()=>`${tt}-target`,getDropdownId:()=>`${tt}-dropdown`,withRoles:k,targetProps:Ce,__staticSelector:R,classNames:v,styles:x,unstyled:S,variant:G,keepMounted:oe,getStyles:je}},n)}Br.Target=zE;Br.Dropdown=wy;Br.displayName="@mantine/core/Popover";Br.extend=e=>e;var Ir={root:"m-5ae2e3c",barsLoader:"m-7a2bd4cd",bar:"m-870bb79","bars-loader-animation":"m-5d2b3b9d",dotsLoader:"m-4e3f22d7",dot:"m-870c4af","loader-dots-animation":"m-aac34a1",ovalLoader:"m-b34414df","oval-loader-animation":"m-f8e89c4b"};const D4=p.forwardRef(({className:e,...t},n)=>C.createElement(W,{component:"span",className:et(Ir.barsLoader,e),...t,ref:n},C.createElement("span",{className:Ir.bar}),C.createElement("span",{className:Ir.bar}),C.createElement("span",{className:Ir.bar}))),I4=p.forwardRef(({className:e,...t},n)=>C.createElement(W,{component:"span",className:et(Ir.dotsLoader,e),...t,ref:n},C.createElement("span",{className:Ir.dot}),C.createElement("span",{className:Ir.dot}),C.createElement("span",{className:Ir.dot}))),_4=p.forwardRef(({className:e,...t},n)=>C.createElement(W,{component:"span",className:et(Ir.ovalLoader,e),...t,ref:n})),UE={bars:D4,oval:_4,dots:I4},A4={loaders:UE,type:"oval"},N4=(e,{size:t,color:n})=>({root:{"--loader-size":Pe(t,"loader-size"),"--loader-color":n?mt(n,e):void 0}}),Vn=Q((e,t)=>{const n=U("Loader",A4,e),{size:r,color:o,type:i,vars:s,className:l,style:c,classNames:u,styles:d,unstyled:f,loaders:h,variant:m,children:g,...y}=n,S=de({name:"Loader",props:n,classes:Ir,className:l,style:c,classNames:u,styles:d,unstyled:f,vars:s,varsResolver:N4});return g?C.createElement(W,{...S("root"),ref:t,...y},g):C.createElement(W,{...S("root"),ref:t,component:h[i],variant:m,size:r,...y})});Vn.defaultLoaders=UE;Vn.classes=Ir;Vn.displayName="@mantine/core/Loader";var vf={root:"m-8d3f4000",icon:"m-8d3afb97",loader:"m-302b9fb1",group:"m-1a0f1b21"};const y1={orientation:"horizontal"},O4=(e,{borderWidth:t})=>({group:{"--ai-border-width":B(t)}}),Sy=Q((e,t)=>{const n=U("ActionIconGroup",y1,e),{className:r,style:o,classNames:i,styles:s,unstyled:l,orientation:c,vars:u,borderWidth:d,variant:f,mod:h,...m}=U("ActionIconGroup",y1,e),g=de({name:"ActionIconGroup",props:n,classes:vf,className:r,style:o,classNames:i,styles:s,unstyled:l,vars:u,varsResolver:O4,rootSelector:"group"});return C.createElement(W,{...g("group"),ref:t,variant:f,mod:[{"data-orientation":c},h],role:"group",...m})});Sy.classes=vf;Sy.displayName="@mantine/core/ActionIconGroup";const M4={},L4=(e,{size:t,radius:n,variant:r,gradient:o,color:i,autoContrast:s})=>{const l=e.variantColorResolver({color:i||e.primaryColor,theme:e,gradient:o,variant:r||"filled",autoContrast:s});return{root:{"--ai-size":Pe(t,"ai-size"),"--ai-radius":n===void 0?void 0:gt(n),"--ai-bg":i||r?l.background:void 0,"--ai-hover":i||r?l.hover:void 0,"--ai-hover-color":i||r?l.hoverColor:void 0,"--ai-color":l.color,"--ai-bd":i||r?l.border:void 0}}},qt=vn((e,t)=>{const n=U("ActionIcon",M4,e),{className:r,unstyled:o,variant:i,classNames:s,styles:l,style:c,loading:u,loaderProps:d,size:f,color:h,radius:m,__staticSelector:g,gradient:y,vars:S,children:v,disabled:x,"data-disabled":w,autoContrast:b,mod:j,...E}=n,P=de({name:["ActionIcon",g],props:n,className:r,style:c,classes:vf,classNames:s,styles:l,unstyled:o,vars:S,varsResolver:L4});return C.createElement(Jn,{...P("root",{active:!x&&!u&&!w}),...E,unstyled:o,variant:i,size:f,disabled:x||u,ref:t,mod:[{loading:u,disabled:x||w},j]},C.createElement(Lo,{mounted:!!u,transition:"slide-down",duration:150},T=>C.createElement(W,{component:"span",...P("loader",{style:T}),"aria-hidden":!0},C.createElement(Vn,{color:"var(--ai-color)",size:"calc(var(--ai-size) * 0.55)",...d}))),C.createElement(W,{component:"span",mod:{loading:u},...P("icon")},v))});qt.classes=vf;qt.displayName="@mantine/core/ActionIcon";qt.Group=Sy;const VE=p.forwardRef(({size:e="var(--cb-icon-size, 70%)",style:t,...n},r)=>C.createElement("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{...t,width:e,height:e},ref:r,...n},C.createElement("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})));VE.displayName="@mantine/core/CloseIcon";var WE={root:"m-86a44da5","root--subtle":"m-220c80f2"};const $4={variant:"subtle"},F4=(e,{size:t,radius:n,iconSize:r})=>({root:{"--cb-size":Pe(t,"cb-size"),"--cb-radius":n===void 0?void 0:gt(n),"--cb-icon-size":B(r)}}),vs=vn((e,t)=>{const n=U("CloseButton",$4,e),{iconSize:r,children:o,vars:i,radius:s,className:l,classNames:c,style:u,styles:d,unstyled:f,"data-disabled":h,disabled:m,variant:g,icon:y,mod:S,...v}=n,x=de({name:"CloseButton",props:n,className:l,style:u,classes:WE,classNames:c,styles:d,unstyled:f,vars:i,varsResolver:F4});return C.createElement(Jn,{ref:t,...v,unstyled:f,variant:g,disabled:m,mod:[{disabled:m||h},S],...x("root",{variant:g,active:!0})},y||C.createElement(VE,null),o)});vs.classes=WE;vs.displayName="@mantine/core/CloseButton";function z4(e){return p.Children.toArray(e).filter(Boolean)}var HE={root:"m-4081bf90"};const B4={preventGrowOverflow:!0,gap:"md",align:"center",justify:"flex-start",wrap:"wrap"},U4=(e,{grow:t,preventGrowOverflow:n,gap:r,align:o,justify:i,wrap:s},{childWidth:l})=>({root:{"--group-child-width":t&&n?l:void 0,"--group-gap":rn(r),"--group-align":o,"--group-justify":i,"--group-wrap":s}}),Y=Q((e,t)=>{const n=U("Group",B4,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,children:c,gap:u,align:d,justify:f,wrap:h,grow:m,preventGrowOverflow:g,vars:y,variant:S,__size:v,mod:x,...w}=n,b=z4(c),j=b.length,E=rn(u??"md"),T={childWidth:`calc(${100/j}% - (${E} - ${E} / ${j}))`},D=de({name:"Group",props:n,stylesCtx:T,className:o,style:i,classes:HE,classNames:r,styles:s,unstyled:l,vars:y,varsResolver:U4});return C.createElement(W,{...D("root"),ref:t,variant:S,mod:[{grow:m},x],size:v,...w},b)});Y.classes=HE;Y.displayName="@mantine/core/Group";var qE={root:"m-9814e45f"};const V4={zIndex:zr("modal")},W4=(e,{gradient:t,color:n,backgroundOpacity:r,blur:o,radius:i,zIndex:s})=>({root:{"--overlay-bg":t||(n!==void 0||r!==void 0)&&nn(n||"#000",r??.6)||void 0,"--overlay-filter":o?`blur(${B(o)})`:void 0,"--overlay-radius":i===void 0?void 0:gt(i),"--overlay-z-index":s==null?void 0:s.toString()}}),nc=vn((e,t)=>{const n=U("Overlay",V4,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,fixed:u,center:d,children:f,radius:h,zIndex:m,gradient:g,blur:y,color:S,backgroundOpacity:v,mod:x,...w}=n,b=de({name:"Overlay",props:n,classes:qE,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:W4});return C.createElement(W,{ref:t,...b("root"),mod:[{center:d,fixed:u},x],...w},f)});nc.classes=qE;nc.displayName="@mantine/core/Overlay";const[H4,$o]=Tn("ModalBase component was not found in tree");function q4({opened:e,transitionDuration:t}){const[n,r]=p.useState(e),o=p.useRef(),s=sg()?0:t;return p.useEffect(()=>(e?(r(!0),window.clearTimeout(o.current)):s===0?r(!1):o.current=window.setTimeout(()=>r(!1),s),()=>window.clearTimeout(o.current)),[e,s]),n}function G4({id:e,transitionProps:t,opened:n,trapFocus:r,closeOnEscape:o,onClose:i,returnFocus:s}){const l=kn(e),[c,u]=p.useState(!1),[d,f]=p.useState(!1),h=typeof(t==null?void 0:t.duration)=="number"?t==null?void 0:t.duration:200,m=q4({opened:n,transitionDuration:h});return zS("keydown",g=>{var y;g.key==="Escape"&&o&&((y=g.target)==null?void 0:y.getAttribute("data-mantine-stop-propagation"))!=="true"&&i()},{capture:!0}),MS({opened:n,shouldReturnFocus:r&&s}),{_id:l,titleMounted:c,bodyMounted:d,shouldLockScroll:m,setTitleMounted:u,setBodyMounted:f}}const Q4=p.forwardRef(({keepMounted:e,opened:t,onClose:n,id:r,transitionProps:o,trapFocus:i,closeOnEscape:s,returnFocus:l,closeOnClickOutside:c,withinPortal:u,portalProps:d,lockScroll:f,children:h,zIndex:m,shadow:g,padding:y,__vars:S,unstyled:v,removeScrollProps:x,...w},b)=>{const{_id:j,titleMounted:E,bodyMounted:P,shouldLockScroll:T,setTitleMounted:D,setBodyMounted:_}=G4({id:r,transitionProps:o,opened:t,trapFocus:i,closeOnEscape:s,onClose:n,returnFocus:l});return C.createElement(ys,{...d,withinPortal:u},C.createElement(H4,{value:{opened:t,onClose:n,closeOnClickOutside:c,transitionProps:{...o,keepMounted:e},getTitleId:()=>`${j}-title`,getBodyId:()=>`${j}-body`,titleMounted:E,bodyMounted:P,setTitleMounted:D,setBodyMounted:_,trapFocus:i,closeOnEscape:s,zIndex:m,unstyled:v}},C.createElement(Kd,{enabled:T&&f,...x},C.createElement(W,{ref:b,...w,__vars:{...S,"--mb-z-index":(m||zr("modal")).toString(),"--mb-shadow":ng(g),"--mb-padding":rn(y)}},h))))});function K4(){const e=$o();return p.useEffect(()=>(e.setBodyMounted(!0),()=>e.setBodyMounted(!1)),[]),e.getBodyId()}var Pa={title:"m-615af6c9",header:"m-b5489c3c",inner:"m-60c222c7",content:"m-fd1ab0aa",close:"m-606cb269",body:"m-5df29311"};const GE=p.forwardRef(({className:e,...t},n)=>{const r=K4(),o=$o();return C.createElement(W,{ref:n,...t,id:r,className:et({[Pa.body]:!o.unstyled},e)})});GE.displayName="@mantine/core/ModalBaseBody";const QE=p.forwardRef(({className:e,onClick:t,...n},r)=>{const o=$o();return C.createElement(vs,{ref:r,...n,onClick:i=>{o.onClose(),t==null||t(i)},className:et({[Pa.close]:!o.unstyled},e),unstyled:o.unstyled})});QE.displayName="@mantine/core/ModalBaseCloseButton";const Y4=p.forwardRef(({transitionProps:e,className:t,innerProps:n,onKeyDown:r,style:o,...i},s)=>{const l=$o();return C.createElement(Lo,{mounted:l.opened,transition:"pop",...l.transitionProps,...e},c=>C.createElement("div",{...n,className:et({[Pa.inner]:!l.unstyled},n.className)},C.createElement(yf,{active:l.opened&&l.trapFocus},C.createElement(zn,{...i,component:"section",role:"dialog",tabIndex:-1,"aria-modal":!0,"aria-describedby":l.bodyMounted?l.getBodyId():void 0,"aria-labelledby":l.titleMounted?l.getTitleId():void 0,ref:s,style:[o,c],className:et({[Pa.content]:!l.unstyled},t),unstyled:l.unstyled},i.children))))}),KE=p.forwardRef(({className:e,...t},n)=>{const r=$o();return C.createElement(W,{component:"header",ref:n,className:et({[Pa.header]:!r.unstyled},e),...t})});KE.displayName="@mantine/core/ModalBaseHeader";const X4={duration:200,timingFunction:"ease",transition:"fade"};function J4(e){const t=$o();return{...X4,...t.transitionProps,...e}}const YE=p.forwardRef(({onClick:e,transitionProps:t,style:n,...r},o)=>{const i=$o(),s=J4(t);return C.createElement(Lo,{mounted:i.opened,...s,transition:"fade"},l=>C.createElement(nc,{ref:o,fixed:!0,style:[n,l],zIndex:i.zIndex,unstyled:i.unstyled,onClick:c=>{e==null||e(c),i.closeOnClickOutside&&i.onClose()},...r}))});YE.displayName="@mantine/core/ModalBaseOverlay";function Z4(){const e=$o();return p.useEffect(()=>(e.setTitleMounted(!0),()=>e.setTitleMounted(!1)),[]),e.getTitleId()}const XE=p.forwardRef(({className:e,...t},n)=>{const r=Z4(),o=$o();return C.createElement(W,{component:"h2",ref:n,className:et({[Pa.title]:!o.unstyled},e),...t,id:r})});XE.displayName="@mantine/core/ModalBaseTitle";function eN({children:e}){return C.createElement(C.Fragment,null,e)}const[tN,Ba]=mc({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0});var xr={wrapper:"m-6c018570",input:"m-8fb7ebe7",section:"m-82577fc2",placeholder:"m-88bacfd0",root:"m-46b77525",label:"m-8fdc1311",required:"m-78a94662",error:"m-8f816625",description:"m-fe47ce59"};const v1={},nN=(e,{size:t})=>({description:{"--input-description-size":t===void 0?void 0:`calc(${Kt(t)} - ${B(2)})`}}),xf=Q((e,t)=>{const n=U("InputDescription",v1,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,size:u,__staticSelector:d,__inheritStyles:f=!0,variant:h,...m}=U("InputDescription",v1,n),g=Ba(),y=de({name:["InputWrapper",d],props:n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,rootSelector:"description",vars:c,varsResolver:nN}),S=f&&(g==null?void 0:g.getStyles)||y;return C.createElement(W,{component:"p",ref:t,variant:h,size:u,...S("description",g!=null&&g.getStyles?{className:o,style:i}:void 0),...m})});xf.classes=xr;xf.displayName="@mantine/core/InputDescription";const rN={},oN=(e,{size:t})=>({error:{"--input-error-size":t===void 0?void 0:`calc(${Kt(t)} - ${B(2)})`}}),wf=Q((e,t)=>{const n=U("InputError",rN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,size:u,__staticSelector:d,__inheritStyles:f=!0,variant:h,...m}=n,g=de({name:["InputWrapper",d],props:n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,rootSelector:"error",vars:c,varsResolver:oN}),y=Ba(),S=f&&(y==null?void 0:y.getStyles)||g;return C.createElement(W,{component:"p",ref:t,variant:h,size:u,...S("error",y!=null&&y.getStyles?{className:o,style:i}:void 0),...m})});wf.classes=xr;wf.displayName="@mantine/core/InputError";const x1={labelElement:"label"},iN=(e,{size:t})=>({label:{"--input-label-size":Kt(t),"--input-asterisk-color":void 0}}),Sf=Q((e,t)=>{const n=U("InputLabel",x1,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,labelElement:u,size:d,required:f,htmlFor:h,onMouseDown:m,children:g,__staticSelector:y,variant:S,mod:v,...x}=U("InputLabel",x1,n),w=de({name:["InputWrapper",y],props:n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,rootSelector:"label",vars:c,varsResolver:iN}),b=Ba(),j=(b==null?void 0:b.getStyles)||w;return C.createElement(W,{...j("label",b!=null&&b.getStyles?{className:o,style:i}:void 0),component:u,variant:S,size:d,ref:t,htmlFor:u==="label"?h:void 0,mod:[{required:f},v],onMouseDown:E=>{m==null||m(E),!E.defaultPrevented&&E.detail>1&&E.preventDefault()},...x},g,f&&C.createElement("span",{...j("required"),"aria-hidden":!0}," *"))});Sf.classes=xr;Sf.displayName="@mantine/core/InputLabel";const w1={},by=Q((e,t)=>{const n=U("InputPlaceholder",w1,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,__staticSelector:u,variant:d,error:f,mod:h,...m}=U("InputPlaceholder",w1,n),g=de({name:["InputPlaceholder",u],props:n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,rootSelector:"placeholder"});return C.createElement(W,{...g("placeholder"),mod:[{error:!!f},h],component:"span",variant:d,ref:t,...m})});by.classes=xr;by.displayName="@mantine/core/InputPlaceholder";function sN(e,{hasDescription:t,hasError:n}){const r=e.findIndex(c=>c==="input"),o=e[r-1],i=e[r+1];return{offsetBottom:t&&i==="description"||n&&i==="error",offsetTop:t&&o==="description"||n&&o==="error"}}const aN={labelElement:"label",inputContainer:e=>e,inputWrapperOrder:["label","description","input","error"]},lN=(e,{size:t})=>({label:{"--input-label-size":Kt(t),"--input-asterisk-color":void 0},error:{"--input-error-size":t===void 0?void 0:`calc(${Kt(t)} - ${B(2)})`},description:{"--input-description-size":t===void 0?void 0:`calc(${Kt(t)} - ${B(2)})`}}),Cy=Q((e,t)=>{const n=U("InputWrapper",aN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,size:u,variant:d,__staticSelector:f,inputContainer:h,inputWrapperOrder:m,label:g,error:y,description:S,labelProps:v,descriptionProps:x,errorProps:w,labelElement:b,children:j,withAsterisk:E,id:P,required:T,__stylesApiProps:D,mod:_,...O}=n,I=de({name:["InputWrapper",f],props:D||n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:lN}),$={size:u,variant:d,__staticSelector:f},N=kn(P),L=typeof E=="boolean"?E:T,M=(w==null?void 0:w.id)||`${N}-error`,R=(x==null?void 0:x.id)||`${N}-description`,k=N,F=!!y&&typeof y!="boolean",q=!!S,G=`${F?M:""} ${q?R:""}`,oe=G.trim().length>0?G.trim():void 0,xe=(v==null?void 0:v.id)||`${N}-label`,me=g&&C.createElement(Sf,{key:"label",labelElement:b,id:xe,htmlFor:k,required:L,...$,...v},g),Ce=q&&C.createElement(xf,{key:"description",...x,...$,size:(x==null?void 0:x.size)||$.size,id:(x==null?void 0:x.id)||R},S),je=C.createElement(C.Fragment,{key:"input"},h(j)),Be=F&&C.createElement(wf,{...w,...$,size:(w==null?void 0:w.size)||$.size,key:"error",id:(w==null?void 0:w.id)||M},y),Me=m.map(Ke=>{switch(Ke){case"label":return me;case"input":return je;case"description":return Ce;case"error":return Be;default:return null}});return C.createElement(tN,{value:{getStyles:I,describedBy:oe,inputId:k,labelId:xe,...sN(m,{hasDescription:q,hasError:F})}},C.createElement(W,{ref:t,variant:d,size:u,mod:[{error:!!y},_],...I("root"),...O},Me))});Cy.classes=xr;Cy.displayName="@mantine/core/InputWrapper";const cN={variant:"default",leftSectionPointerEvents:"none",rightSectionPointerEvents:"none",withAria:!0,withErrorStyles:!0},uN=(e,t,n)=>({wrapper:{"--input-margin-top":n.offsetTop?"calc(var(--mantine-spacing-xs) / 2)":void 0,"--input-margin-bottom":n.offsetBottom?"calc(var(--mantine-spacing-xs) / 2)":void 0,"--input-height":Pe(t.size,"input-height"),"--input-fz":Kt(t.size),"--input-radius":t.radius===void 0?void 0:gt(t.radius),"--input-left-section-width":t.leftSectionWidth!==void 0?B(t.leftSectionWidth):void 0,"--input-right-section-width":t.rightSectionWidth!==void 0?B(t.rightSectionWidth):void 0,"--input-padding-y":t.multiline?Pe(t.size,"input-padding-y"):void 0,"--input-left-section-pointer-events":t.leftSectionPointerEvents,"--input-right-section-pointer-events":t.rightSectionPointerEvents}}),Ct=vn((e,t)=>{const n=U("Input",cN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,required:c,__staticSelector:u,__stylesApiProps:d,size:f,wrapperProps:h,error:m,disabled:g,leftSection:y,leftSectionProps:S,leftSectionWidth:v,rightSection:x,rightSectionProps:w,rightSectionWidth:b,rightSectionPointerEvents:j,leftSectionPointerEvents:E,variant:P,vars:T,pointer:D,multiline:_,radius:O,id:I,withAria:$,withErrorStyles:N,mod:L,...M}=n,{styleProps:R,rest:k}=No(M),F=Ba(),q={offsetBottom:F==null?void 0:F.offsetBottom,offsetTop:F==null?void 0:F.offsetTop},G=de({name:["Input",u],props:d||n,classes:xr,className:o,style:i,classNames:r,styles:s,unstyled:l,stylesCtx:q,rootSelector:"wrapper",vars:T,varsResolver:uN}),oe=$?{required:c,disabled:g,"aria-invalid":!!m,"aria-describedby":F==null?void 0:F.describedBy,id:(F==null?void 0:F.inputId)||I}:{};return C.createElement(W,{...G("wrapper"),...R,...h,mod:[{error:!!m&&N,pointer:D,disabled:g,multiline:_,"data-with-right-section":!!x,"data-with-left-section":!!y},L],variant:P,size:f},y&&C.createElement("div",{...S,"data-position":"left",...G("section",{className:S==null?void 0:S.className,style:S==null?void 0:S.style})},y),C.createElement(W,{component:"input",...k,...oe,ref:t,required:c,mod:{disabled:g,error:!!m&&N},variant:P,...G("input")}),x&&C.createElement("div",{...w,"data-position":"right",...G("section",{className:w==null?void 0:w.className,style:w==null?void 0:w.style})},x))});Ct.classes=xr;Ct.Wrapper=Cy;Ct.Label=Sf;Ct.Error=wf;Ct.Description=xf;Ct.Placeholder=by;Ct.displayName="@mantine/core/Input";function dN(e,t,n){const r=U(e,t,n),{label:o,description:i,error:s,required:l,classNames:c,styles:u,className:d,unstyled:f,__staticSelector:h,__stylesApiProps:m,errorProps:g,labelProps:y,descriptionProps:S,wrapperProps:v,id:x,size:w,style:b,inputContainer:j,inputWrapperOrder:E,withAsterisk:P,variant:T,vars:D,mod:_,...O}=r,{styleProps:I,rest:$}=No(O),N={label:o,description:i,error:s,required:l,classNames:c,className:d,__staticSelector:h,__stylesApiProps:m||r,errorProps:g,labelProps:y,descriptionProps:S,unstyled:f,styles:u,size:w,style:b,inputContainer:j,inputWrapperOrder:E,withAsterisk:P,variant:T,id:x,mod:_,...v};return{...$,classNames:c,styles:u,unstyled:f,wrapperProps:{...N,...I},inputProps:{required:l,classNames:c,styles:u,unstyled:f,size:w,__staticSelector:h,__stylesApiProps:m||r,error:s,variant:T,id:x}}}const fN={__staticSelector:"InputBase",withAria:!0},wr=vn((e,t)=>{const{inputProps:n,wrapperProps:r,...o}=dN("InputBase",fN,e);return C.createElement(Ct.Wrapper,{...r},C.createElement(Ct,{...n,...o,ref:t}))});wr.classes={...Ct.classes,...Ct.Wrapper.classes};wr.displayName="@mantine/core/InputBase";const hN={gap:{type:"spacing",property:"gap"},rowGap:{type:"spacing",property:"rowGap"},columnGap:{type:"spacing",property:"columnGap"},align:{type:"identity",property:"alignItems"},justify:{type:"identity",property:"justifyContent"},wrap:{type:"identity",property:"flexWrap"},direction:{type:"identity",property:"flexDirection"}};var JE={root:"m-8bffd616"};const pN={},rs=vn((e,t)=>{const n=U("Flex",pN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,gap:u,rowGap:d,columnGap:f,align:h,justify:m,wrap:g,direction:y,...S}=n,v=de({name:"Flex",classes:JE,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c}),x=kt(),w=yc(),b=QS({styleProps:{gap:u,rowGap:d,columnGap:f,align:h,justify:m,wrap:g,direction:y},theme:x,data:hN});return C.createElement(C.Fragment,null,b.hasResponsiveStyles&&C.createElement(La,{selector:`.${w}`,styles:b.styles,media:b.media}),C.createElement(W,{ref:t,...v("root",{className:w,style:ds(b.inlineStyles)}),...S}))});rs.classes=JE;rs.displayName="@mantine/core/Flex";var ZE={root:"m-66836ed3",wrapper:"m-a5d60502",body:"m-667c2793",title:"m-6a03f287",label:"m-698f4f23",icon:"m-667f2a6a",message:"m-7fa78076",closeButton:"m-87f54839"};const mN={},gN=(e,{radius:t,color:n,variant:r,autoContrast:o})=>{const i=e.variantColorResolver({color:n||e.primaryColor,theme:e,variant:r||"light",autoContrast:o});return{root:{"--alert-radius":t===void 0?void 0:gt(t),"--alert-bg":n||r?i.background:void 0,"--alert-color":i.color,"--alert-bd":n||r?i.border:void 0}}},xs=Q((e,t)=>{const n=U("Alert",mN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,radius:u,color:d,title:f,children:h,id:m,icon:g,withCloseButton:y,onClose:S,closeButtonLabel:v,variant:x,autoContrast:w,...b}=n,j=de({name:"Alert",classes:ZE,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:gN}),E=kn(m),P=f&&`${E}-title`||void 0,T=`${E}-body`;return C.createElement(W,{id:E,...j("root",{variant:x}),variant:x,ref:t,...b,role:"alert","aria-describedby":T,"aria-labelledby":P},C.createElement("div",{...j("wrapper")},g&&C.createElement("div",{...j("icon")},g),C.createElement("div",{...j("body")},f&&C.createElement("div",{...j("title"),"data-with-close-button":y||void 0},C.createElement("span",{id:P,...j("label")},f)),h&&C.createElement("div",{id:T,...j("message"),"data-variant":x},h)),y&&C.createElement(vs,{...j("closeButton"),onClick:S,variant:"transparent",size:16,iconSize:16,"aria-label":v,unstyled:l})))});xs.classes=ZE;xs.displayName="@mantine/core/Alert";var ej={root:"m-b6d8b162"};function yN(e){if(e==="start")return"start";if(e==="end"||e)return"end"}const vN={inherit:!1},xN=(e,{variant:t,lineClamp:n,gradient:r,size:o,color:i})=>({root:{"--text-fz":Kt(o),"--text-lh":AS(o),"--text-gradient":t==="gradient"?wp(r,e):void 0,"--text-line-clamp":typeof n=="number"?n.toString():void 0,"--text-color":i?mt(i,e):void 0}}),se=vn((e,t)=>{const n=U("Text",vN,e),{lineClamp:r,truncate:o,inline:i,inherit:s,gradient:l,span:c,__staticSelector:u,vars:d,className:f,style:h,classNames:m,styles:g,unstyled:y,variant:S,mod:v,size:x,...w}=n,b=de({name:["Text",u],props:n,classes:ej,className:f,style:h,classNames:m,styles:g,unstyled:y,vars:d,varsResolver:xN});return C.createElement(W,{...b("root",{focusable:!0}),ref:t,component:c?"span":"p",variant:S,mod:[{"data-truncate":yN(o),"data-line-clamp":typeof r=="number","data-inline":i,"data-inherit":s},v],size:x,...w})});se.classes=ej;se.displayName="@mantine/core/Text";var tj={root:"m-849cf0da"};const wN={underline:"hover"},He=vn((e,t)=>{const{underline:n,className:r,unstyled:o,mod:i,...s}=U("Anchor",wN,e);return C.createElement(se,{component:"a",ref:t,className:et({[tj.root]:!o},r),...s,mod:[{underline:n},i],__staticSelector:"Anchor",unstyled:o})});He.classes=tj;He.displayName="@mantine/core/Anchor";const[SN,Ua]=Tn("AppShell was not found in tree");var ji={root:"m-89ab340",navbar:"m-45252eee",aside:"m-9cdde9a",header:"m-3b16f56b",main:"m-8983817",footer:"m-3840c879",section:"m-6dcfc7c7"};const bN={},Ey=Q((e,t)=>{const n=U("AppShellAside",bN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,withBorder:u,zIndex:d,mod:f,...h}=n,m=Ua();return m.disabled?null:C.createElement(W,{component:"aside",ref:t,mod:[{"with-border":u??m.withBorder},f],...m.getStyles("aside",{className:o,classNames:r,styles:s,style:i}),...h,__vars:{"--app-shell-aside-z-index":`calc(${d??m.zIndex} + 1)`}})});Ey.classes=ji;Ey.displayName="@mantine/core/AppShellAside";const CN={},jy=Q((e,t)=>{var g;const n=U("AppShellFooter",CN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,withBorder:u,zIndex:d,mod:f,...h}=n,m=Ua();return m.disabled?null:C.createElement(W,{component:"footer",ref:t,mod:[{"with-border":u??m.withBorder},f],...m.getStyles("footer",{className:et({[Kd.classNames.zeroRight]:m.offsetScrollbars},o),classNames:r,styles:s,style:i}),...h,__vars:{"--app-shell-footer-z-index":(g=d??m.zIndex)==null?void 0:g.toString()}})});jy.classes=ji;jy.displayName="@mantine/core/AppShellFooter";const EN={},Py=Q((e,t)=>{var g;const n=U("AppShellHeader",EN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,withBorder:u,zIndex:d,mod:f,...h}=n,m=Ua();return m.disabled?null:C.createElement(W,{component:"header",ref:t,mod:[{"with-border":u??m.withBorder},f],...m.getStyles("header",{className:et({[Kd.classNames.zeroRight]:m.offsetScrollbars},o),classNames:r,styles:s,style:i}),...h,__vars:{"--app-shell-header-z-index":(g=d??m.zIndex)==null?void 0:g.toString()}})});Py.classes=ji;Py.displayName="@mantine/core/AppShellHeader";const jN={},Ty=Q((e,t)=>{const n=U("AppShellMain",jN,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ua();return C.createElement(W,{component:"main",ref:t,...u.getStyles("main",{className:o,style:i,classNames:r,styles:s}),...c})});Ty.classes=ji;Ty.displayName="@mantine/core/AppShellMain";function Ec(e){return typeof e=="object"?e.base:e}function jc(e){const t=typeof e=="object"&&e!==null&&typeof e.base<"u"&&Object.keys(e).length===1;return typeof e=="number"||typeof e=="string"||t}function Pc(e){return!(typeof e!="object"||e===null||Object.keys(e).length===1&&"base"in e)}function PN({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,aside:r,theme:o}){var c,u,d;const i=r==null?void 0:r.width,s="translateX(var(--app-shell-aside-width))",l="translateX(calc(var(--app-shell-aside-width) * -1))";if(r!=null&&r.breakpoint&&!((c=r==null?void 0:r.collapsed)!=null&&c.mobile)&&(n[r==null?void 0:r.breakpoint]=n[r==null?void 0:r.breakpoint]||{},n[r==null?void 0:r.breakpoint]["--app-shell-aside-width"]="100%",n[r==null?void 0:r.breakpoint]["--app-shell-aside-offset"]="0px"),jc(i)){const f=B(Ec(i));e["--app-shell-aside-width"]=f,e["--app-shell-aside-offset"]=f}if(Pc(i)&&(typeof i.base<"u"&&(e["--app-shell-aside-width"]=B(i.base),e["--app-shell-aside-offset"]=B(i.base)),pt(i).forEach(f=>{f!=="base"&&(t[f]=t[f]||{},t[f]["--app-shell-aside-width"]=B(i[f]),t[f]["--app-shell-aside-offset"]=B(i[f]))})),(u=r==null?void 0:r.collapsed)!=null&&u.desktop){const f=r.breakpoint;t[f]=t[f]||{},t[f]["--app-shell-aside-transform"]=s,t[f]["--app-shell-aside-transform-rtl"]=l,t[f]["--app-shell-aside-offset"]="0px !important"}if((d=r==null?void 0:r.collapsed)!=null&&d.mobile){const f=rg(r.breakpoint,o)-.1;n[f]=n[f]||{},n[f]["--app-shell-aside-width"]="100%",n[f]["--app-shell-aside-offset"]="0px",n[f]["--app-shell-aside-transform"]=s,n[f]["--app-shell-aside-transform-rtl"]=l}}function TN({baseStyles:e,minMediaStyles:t,footer:n}){const r=n==null?void 0:n.height,o="translateY(var(--app-shell-footer-height))",i=(n==null?void 0:n.offset)??!0;if(jc(r)){const s=B(Ec(r));e["--app-shell-footer-height"]=s,i&&(e["--app-shell-footer-offset"]=s)}Pc(r)&&(typeof r.base<"u"&&(e["--app-shell-footer-height"]=B(r.base),i&&(e["--app-shell-footer-offset"]=B(r.base))),pt(r).forEach(s=>{s!=="base"&&(t[s]=t[s]||{},t[s]["--app-shell-footer-height"]=B(r[s]),i&&(t[s]["--app-shell-footer-offset"]=B(r[s])))})),n!=null&&n.collapsed&&(e["--app-shell-footer-transform"]=o,e["--app-shell-footer-offset"]="0px !important")}function kN({baseStyles:e,minMediaStyles:t,header:n}){const r=n==null?void 0:n.height,o="translateY(calc(var(--app-shell-header-height) * -1))",i=(n==null?void 0:n.offset)??!0;if(jc(r)){const s=B(Ec(r));e["--app-shell-header-height"]=s,i&&(e["--app-shell-header-offset"]=s)}Pc(r)&&(typeof r.base<"u"&&(e["--app-shell-header-height"]=B(r.base),i&&(e["--app-shell-header-offset"]=B(r.base))),pt(r).forEach(s=>{s!=="base"&&(t[s]=t[s]||{},t[s]["--app-shell-header-height"]=B(r[s]),i&&(t[s]["--app-shell-header-offset"]=B(r[s])))})),n!=null&&n.collapsed&&(e["--app-shell-header-transform"]=o,e["--app-shell-header-offset"]="0px !important")}function RN({baseStyles:e,minMediaStyles:t,maxMediaStyles:n,navbar:r,theme:o}){var c,u,d;const i=r==null?void 0:r.width,s="translateX(calc(var(--app-shell-navbar-width) * -1))",l="translateX(var(--app-shell-navbar-width))";if(r!=null&&r.breakpoint&&!((c=r==null?void 0:r.collapsed)!=null&&c.mobile)&&(n[r==null?void 0:r.breakpoint]=n[r==null?void 0:r.breakpoint]||{},n[r==null?void 0:r.breakpoint]["--app-shell-navbar-width"]="100%",n[r==null?void 0:r.breakpoint]["--app-shell-navbar-offset"]="0px"),jc(i)){const f=B(Ec(i));e["--app-shell-navbar-width"]=f,e["--app-shell-navbar-offset"]=f}if(Pc(i)&&(typeof i.base<"u"&&(e["--app-shell-navbar-width"]=B(i.base),e["--app-shell-navbar-offset"]=B(i.base)),pt(i).forEach(f=>{f!=="base"&&(t[f]=t[f]||{},t[f]["--app-shell-navbar-width"]=B(i[f]),t[f]["--app-shell-navbar-offset"]=B(i[f]))})),(u=r==null?void 0:r.collapsed)!=null&&u.desktop){const f=r.breakpoint;t[f]=t[f]||{},t[f]["--app-shell-navbar-transform"]=s,t[f]["--app-shell-navbar-transform-rtl"]=l,t[f]["--app-shell-navbar-offset"]="0px !important"}if((d=r==null?void 0:r.collapsed)!=null&&d.mobile){const f=rg(r.breakpoint,o)-.1;n[f]=n[f]||{},n[f]["--app-shell-navbar-width"]="100%",n[f]["--app-shell-navbar-offset"]="0px",n[f]["--app-shell-navbar-transform"]=s,n[f]["--app-shell-navbar-transform-rtl"]=l}}function tp(e){return Number(e)===0?"0px":rn(e)}function DN({padding:e,baseStyles:t,minMediaStyles:n}){jc(e)&&(t["--app-shell-padding"]=tp(Ec(e))),Pc(e)&&(e.base&&(t["--app-shell-padding"]=tp(e.base)),pt(e).forEach(r=>{r!=="base"&&(n[r]=n[r]||{},n[r]["--app-shell-padding"]=tp(e[r]))}))}function IN({navbar:e,header:t,footer:n,aside:r,padding:o,theme:i}){const s={},l={},c={};RN({baseStyles:c,minMediaStyles:s,maxMediaStyles:l,navbar:e,theme:i}),PN({baseStyles:c,minMediaStyles:s,maxMediaStyles:l,aside:r,theme:i}),kN({baseStyles:c,minMediaStyles:s,header:t}),TN({baseStyles:c,minMediaStyles:s,footer:n}),DN({baseStyles:c,minMediaStyles:s,padding:o});const u=Ll(pt(s),i).map(h=>({query:`(min-width: ${Ju(h.px)})`,styles:s[h.value]})),d=Ll(pt(l),i).map(h=>({query:`(max-width: ${Ju(h.px)})`,styles:l[h.value]})),f=[...u,...d];return{baseStyles:c,media:f}}function _N({navbar:e,header:t,aside:n,footer:r,padding:o}){const i=kt(),s=Ma(),{media:l,baseStyles:c}=IN({navbar:e,header:t,footer:r,aside:n,padding:o,theme:i});return C.createElement(La,{media:l,styles:c,selector:s.cssVariablesSelector})}const AN={},ky=Q((e,t)=>{const n=U("AppShellNavbar",AN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,withBorder:u,zIndex:d,mod:f,...h}=n,m=Ua();return m.disabled?null:C.createElement(W,{component:"nav",ref:t,mod:[{"with-border":u??m.withBorder},f],...m.getStyles("navbar",{className:o,classNames:r,styles:s,style:i}),...h,__vars:{"--app-shell-navbar-z-index":`calc(${d??m.zIndex} + 1)`}})});ky.classes=ji;ky.displayName="@mantine/core/AppShellNavbar";const NN={},Ry=vn((e,t)=>{const n=U("AppShellSection",NN,e),{classNames:r,className:o,style:i,styles:s,vars:l,grow:c,mod:u,...d}=n,f=Ua();return C.createElement(W,{ref:t,mod:[{grow:c},u],...f.getStyles("section",{className:o,style:i,classNames:r,styles:s}),...d})});Ry.classes=ji;Ry.displayName="@mantine/core/AppShellSection";function ON({transitionDuration:e,disabled:t}){const[n,r]=p.useState(!1),o=p.useRef(),i=p.useRef();return zS("resize",()=>{r(!0),clearTimeout(o.current),o.current=window.setTimeout(()=>r(!1),200)}),Oa(()=>{r(!0),clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),e||0)},[t,e]),n}const MN={withBorder:!0,offsetScrollbars:!0,padding:0,transitionDuration:200,transitionTimingFunction:"ease",zIndex:zr("app")},LN=(e,{transitionDuration:t,transitionTimingFunction:n})=>({root:{"--app-shell-transition-duration":`${t}ms`,"--app-shell-transition-timing-function":n}}),Un=Q((e,t)=>{const n=U("AppShell",MN,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,navbar:u,withBorder:d,padding:f,transitionDuration:h,transitionTimingFunction:m,header:g,zIndex:y,layout:S,disabled:v,aside:x,footer:w,offsetScrollbars:b,mod:j,...E}=n,P=de({name:"AppShell",classes:ji,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:LN}),T=ON({disabled:v,transitionDuration:h});return C.createElement(SN,{value:{getStyles:P,withBorder:d,zIndex:y,disabled:v,offsetScrollbars:b}},C.createElement(_N,{navbar:u,header:g,aside:x,footer:w,padding:f}),C.createElement(W,{ref:t,...P("root"),mod:[{resizing:T,layout:S,disabled:v},j],...E}))});Un.classes=ji;Un.displayName="@mantine/core/AppShell";Un.Navbar=ky;Un.Header=Py;Un.Main=Ty;Un.Aside=Ey;Un.Footer=jy;Un.Section=Ry;function nj(e){return typeof e=="string"?{value:e,label:e}:"value"in e&&!("label"in e)?{value:e.value,label:e.value,disabled:e.disabled}:typeof e=="number"?{value:e.toString(),label:e.toString()}:"group"in e?{group:e.group,items:e.items.map(t=>nj(t))}:e}function rj(e){return e?e.map(t=>nj(t)):[]}function oj(e){return e.reduce((t,n)=>"group"in n?{...t,...oj(n.items)}:(t[n.value]=n,t),{})}var Wn={dropdown:"m-88b62a41",options:"m-b2821a6e",option:"m-92253aa5",search:"m-985517d8",empty:"m-2530cd1d",header:"m-858f94bd",footer:"m-82b967cb",group:"m-254f3e4f",groupLabel:"m-2bb2e9e5",chevron:"m-2943220b",optionsDropdownOption:"m-390b5f4",optionsDropdownCheckIcon:"m-8ee53fc2"};const $N={error:null},FN=(e,{size:t})=>({chevron:{"--combobox-chevron-size":Pe(t,"combobox-chevron-size")}}),bf=Q((e,t)=>{const n=U("ComboboxChevron",$N,e),{size:r,error:o,style:i,className:s,classNames:l,styles:c,unstyled:u,vars:d,mod:f,...h}=n,m=de({name:"ComboboxChevron",classes:Wn,props:n,style:i,className:s,classNames:l,styles:c,unstyled:u,vars:d,varsResolver:FN,rootSelector:"chevron"});return C.createElement(W,{component:"svg",...h,...m("chevron"),size:r,viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",mod:["combobox-chevron",{error:o},f],ref:t},C.createElement("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.35753 11.9939 7.64245 11.9939 7.81819 11.8182L10.0682 9.56819Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))});bf.classes=Wn;bf.displayName="@mantine/core/ComboboxChevron";const[zN,Sr]=Tn("Combobox component was not found in tree"),ij=p.forwardRef(({size:e,onMouseDown:t,onClick:n,onClear:r,...o},i)=>C.createElement(vs,{ref:i,size:e||"sm",variant:"transparent",tabIndex:-1,"aria-hidden":!0,...o,onMouseDown:s=>{s.preventDefault(),t==null||t(s)},onClick:s=>{r(),n==null||n(s)}}));ij.displayName="@mantine/core/ComboboxClearButton";const BN={},Dy=Q((e,t)=>{const{classNames:n,styles:r,className:o,style:i,hidden:s,...l}=U("ComboboxDropdown",BN,e),c=Sr();return C.createElement(Br.Dropdown,{...l,ref:t,role:"presentation","data-hidden":s||void 0,...c.getStyles("dropdown",{className:o,style:i,classNames:n,styles:r})})});Dy.classes=Wn;Dy.displayName="@mantine/core/ComboboxDropdown";const UN={refProp:"ref"},sj=Q((e,t)=>{const{children:n,refProp:r}=U("ComboboxDropdownTarget",UN,e);if(Sr(),!Ao(n))throw new Error("Combobox.DropdownTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");return C.createElement(Br.Target,{ref:t,refProp:r},n)});sj.displayName="@mantine/core/ComboboxDropdownTarget";const VN={},Iy=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,...l}=U("ComboboxEmpty",VN,e),c=Sr();return C.createElement(W,{ref:t,...c.getStyles("empty",{className:r,classNames:n,styles:i,style:o}),...l})});Iy.classes=Wn;Iy.displayName="@mantine/core/ComboboxEmpty";function _y({onKeyDown:e,withKeyboardNavigation:t,withAriaAttributes:n,withExpandedAttribute:r,targetType:o,autoComplete:i}){const s=Sr(),[l,c]=p.useState(null),u=f=>{if(e==null||e(f),!s.readOnly&&t){if(f.nativeEvent.code==="ArrowDown"&&(f.preventDefault(),s.store.dropdownOpened?c(s.store.selectNextOption()):(s.store.openDropdown("keyboard"),c(s.store.selectActiveOption()))),f.nativeEvent.code==="ArrowUp"&&(f.preventDefault(),s.store.dropdownOpened?c(s.store.selectPreviousOption()):(s.store.openDropdown("keyboard"),c(s.store.selectActiveOption()))),f.nativeEvent.code==="Enter"||f.nativeEvent.code==="NumpadEnter"){const h=s.store.getSelectedOptionIndex();s.store.dropdownOpened&&h!==-1?(f.preventDefault(),s.store.clickSelectedOption()):o==="button"&&(f.preventDefault(),s.store.openDropdown("keyboard"))}f.nativeEvent.code==="Escape"&&s.store.closeDropdown("keyboard"),f.nativeEvent.code==="Space"&&o==="button"&&(f.preventDefault(),s.store.toggleDropdown("keyboard"))}};return{...n?{"aria-haspopup":"listbox","aria-expanded":r&&!!(s.store.listId&&s.store.dropdownOpened)||void 0,"aria-controls":s.store.listId,"aria-activedescendant":s.store.dropdownOpened&&l||void 0,autoComplete:i,"data-expanded":s.store.dropdownOpened||void 0,"data-mantine-stop-propagation":s.store.dropdownOpened||void 0}:{},onKeyDown:u}}const WN={refProp:"ref",targetType:"input",withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:"off"},aj=Q((e,t)=>{const{children:n,refProp:r,withKeyboardNavigation:o,withAriaAttributes:i,withExpandedAttribute:s,targetType:l,autoComplete:c,...u}=U("ComboboxEventsTarget",WN,e);if(!Ao(n))throw new Error("Combobox.EventsTarget component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const d=Sr(),f=_y({targetType:l,withAriaAttributes:i,withKeyboardNavigation:o,withExpandedAttribute:s,onKeyDown:n.props.onKeyDown,autoComplete:c});return p.cloneElement(n,{...f,...u,[r]:Zt(t,d.store.targetRef,n==null?void 0:n.ref)})});aj.displayName="@mantine/core/ComboboxEventsTarget";const HN={},Ay=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,...l}=U("ComboboxFooter",HN,e),c=Sr();return C.createElement(W,{ref:t,...c.getStyles("footer",{className:r,classNames:n,style:o,styles:i}),...l})});Ay.classes=Wn;Ay.displayName="@mantine/core/ComboboxFooter";const qN={},Ny=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,children:l,label:c,...u}=U("ComboboxGroup",qN,e),d=Sr();return C.createElement(W,{ref:t,...d.getStyles("group",{className:r,classNames:n,style:o,styles:i}),...u},c&&C.createElement("div",{...d.getStyles("groupLabel",{classNames:n,styles:i})},c),l)});Ny.classes=Wn;Ny.displayName="@mantine/core/ComboboxGroup";const GN={},Oy=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,...l}=U("ComboboxHeader",GN,e),c=Sr();return C.createElement(W,{ref:t,...c.getStyles("header",{className:r,classNames:n,style:o,styles:i}),...l})});Oy.classes=Wn;Oy.displayName="@mantine/core/ComboboxHeader";const QN={},My=Q((e,t)=>{const n=U("ComboboxOption",QN,e),{classNames:r,className:o,style:i,styles:s,vars:l,onClick:c,id:u,active:d,onMouseDown:f,onMouseOver:h,disabled:m,selected:g,mod:y,...S}=n,v=Sr(),x=p.useId(),w=u||x;return C.createElement(W,{...v.getStyles("option",{className:o,classNames:r,styles:s,style:i}),...S,ref:t,id:w,mod:["combobox-option",{"combobox-active":d,"combobox-disabled":m,"combobox-selected":g},y],role:"option",onClick:b=>{var j;m?b.preventDefault():((j=v.onOptionSubmit)==null||j.call(v,n.value,n),c==null||c(b))},onMouseDown:b=>{b.preventDefault(),f==null||f(b)},onMouseOver:b=>{v.resetSelectionOnOptionHover&&v.store.resetSelectedOption(),h==null||h(b)}})});My.classes=Wn;My.displayName="@mantine/core/ComboboxOption";const KN={},Ly=Q((e,t)=>{const n=U("ComboboxOptions",KN,e),{classNames:r,className:o,style:i,styles:s,id:l,onMouseDown:c,labelledBy:u,...d}=n,f=Sr(),h=kn(l);return p.useEffect(()=>{f.store.setListId(h)},[h]),C.createElement(W,{ref:t,...f.getStyles("options",{className:o,style:i,classNames:r,styles:s}),...d,id:h,role:"listbox","aria-labelledby":u,onMouseDown:m=>{m.preventDefault(),c==null||c(m)}})});Ly.classes=Wn;Ly.displayName="@mantine/core/ComboboxOptions";const YN={withAriaAttributes:!0,withKeyboardNavigation:!0},$y=Q((e,t)=>{const n=U("ComboboxSearch",YN,e),{classNames:r,styles:o,unstyled:i,vars:s,withAriaAttributes:l,onKeyDown:c,withKeyboardNavigation:u,size:d,...f}=n,h=Sr(),m=h.getStyles("search"),g=_y({targetType:"input",withAriaAttributes:l,withKeyboardNavigation:u,withExpandedAttribute:!1,onKeyDown:c,autoComplete:"off"});return C.createElement(Ct,{ref:Zt(t,h.store.searchRef),classNames:[{input:m.className},r],styles:[{input:m.style},o],size:d||h.size,...g,...f,__staticSelector:"Combobox"})});$y.classes=Wn;$y.displayName="@mantine/core/ComboboxSearch";const XN={refProp:"ref",targetType:"input",withKeyboardNavigation:!0,withAriaAttributes:!0,withExpandedAttribute:!1,autoComplete:"off"},lj=Q((e,t)=>{const{children:n,refProp:r,withKeyboardNavigation:o,withAriaAttributes:i,withExpandedAttribute:s,targetType:l,autoComplete:c,...u}=U("ComboboxTarget",XN,e);if(!Ao(n))throw new Error("Combobox.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const d=Sr(),f=_y({targetType:l,withAriaAttributes:i,withKeyboardNavigation:o,withExpandedAttribute:s,onKeyDown:n.props.onKeyDown,autoComplete:c}),h=p.cloneElement(n,{...f,...u});return C.createElement(Br.Target,{ref:Zt(t,d.store.targetRef)},h)});lj.displayName="@mantine/core/ComboboxTarget";function JN(e,t,n){for(let r=e-1;r>=0;r-=1)if(!t[r].hasAttribute("data-combobox-disabled"))return r;if(n){for(let r=t.length-1;r>-1;r-=1)if(!t[r].hasAttribute("data-combobox-disabled"))return r}return e}function ZN(e,t,n){for(let r=e+1;r<t.length;r+=1)if(!t[r].hasAttribute("data-combobox-disabled"))return r;if(n){for(let r=0;r<t.length;r+=1)if(!t[r].hasAttribute("data-combobox-disabled"))return r}return e}function e3(e){for(let t=0;t<e.length;t+=1)if(!e[t].hasAttribute("data-combobox-disabled"))return t;return-1}function Tc({defaultOpened:e,opened:t,onOpenedChange:n,onDropdownClose:r,onDropdownOpen:o,loop:i=!0,scrollBehavior:s="instant"}={}){const[l,c]=gn({value:t,defaultValue:e,finalValue:!1,onChange:n}),u=p.useRef(null),d=p.useRef(-1),f=p.useRef(null),h=p.useRef(null),m=p.useRef(-1),g=p.useRef(-1),y=p.useRef(-1),S=p.useCallback((M="unknown")=>{l||(c(!0),o==null||o(M))},[c,o,l]),v=p.useCallback((M="unknown")=>{l&&(c(!1),r==null||r(M))},[c,r,l]),x=p.useCallback((M="unknown")=>{l?v(M):S(M)},[v,S,l]),w=p.useCallback(()=>{const M=document.querySelector(`#${u.current} [data-combobox-selected]`);M==null||M.removeAttribute("data-combobox-selected"),M==null||M.removeAttribute("aria-selected")},[]),b=p.useCallback(M=>{const R=document.getElementById(u.current),k=R==null?void 0:R.querySelectorAll("[data-combobox-option]");if(!k)return null;const F=M>=k.length?0:M<0?k.length-1:M;return d.current=F,k!=null&&k[F]&&!k[F].hasAttribute("data-combobox-disabled")?(w(),k[F].setAttribute("data-combobox-selected","true"),k[F].setAttribute("aria-selected","true"),k[F].scrollIntoView({block:"nearest",behavior:s}),k[F].id):null},[s,w]),j=p.useCallback(()=>{const M=document.querySelector(`#${u.current} [data-combobox-active]`);if(M){const R=document.querySelectorAll(`#${u.current} [data-combobox-option]`),k=Array.from(R).findIndex(F=>F===M);return b(k)}return b(0)},[b]),E=p.useCallback(()=>b(ZN(d.current,document.querySelectorAll(`#${u.current} [data-combobox-option]`),i)),[b,i]),P=p.useCallback(()=>b(JN(d.current,document.querySelectorAll(`#${u.current} [data-combobox-option]`),i)),[b,i]),T=p.useCallback(()=>b(e3(document.querySelectorAll(`#${u.current} [data-combobox-option]`))),[b]),D=p.useCallback((M="selected",R)=>{y.current=window.setTimeout(()=>{var q;const k=document.querySelectorAll(`#${u.current} [data-combobox-option]`),F=Array.from(k).findIndex(G=>G.hasAttribute(`data-combobox-${M}`));d.current=F,R!=null&&R.scrollIntoView&&((q=k[F])==null||q.scrollIntoView({block:"nearest",behavior:s}))},0)},[]),_=p.useCallback(()=>{d.current=-1,w()},[w]),O=p.useCallback(()=>{const M=document.querySelectorAll(`#${u.current} [data-combobox-option]`),R=M==null?void 0:M[d.current];R==null||R.click()},[]),I=p.useCallback(M=>{u.current=M},[]),$=p.useCallback(()=>{m.current=window.setTimeout(()=>f.current.focus(),0)},[]),N=p.useCallback(()=>{g.current=window.setTimeout(()=>h.current.focus(),0)},[]),L=p.useCallback(()=>d.current,[]);return p.useEffect(()=>()=>{window.clearTimeout(m.current),window.clearTimeout(g.current),window.clearTimeout(y.current)},[]),{dropdownOpened:l,openDropdown:S,closeDropdown:v,toggleDropdown:x,selectedOptionIndex:d.current,getSelectedOptionIndex:L,selectOption:b,selectFirstOption:T,selectActiveOption:j,selectNextOption:E,selectPreviousOption:P,resetSelectedOption:_,updateSelectedOptionIndex:D,listId:u.current,setListId:I,clickSelectedOption:O,searchRef:f,focusSearchInput:$,targetRef:h,focusTarget:N}}const t3={keepMounted:!0,withinPortal:!0,resetSelectionOnOptionHover:!1,width:"target",transitionProps:{transition:"fade",duration:0}},n3=(e,{size:t,dropdownPadding:n})=>({options:{"--combobox-option-fz":Kt(t),"--combobox-option-padding":Pe(t,"combobox-option-padding")},dropdown:{"--combobox-padding":n===void 0?void 0:B(n),"--combobox-option-fz":Kt(t),"--combobox-option-padding":Pe(t,"combobox-option-padding")}});function Ee(e){const t=U("Combobox",t3,e),{classNames:n,styles:r,unstyled:o,children:i,store:s,vars:l,onOptionSubmit:c,onClose:u,size:d,dropdownPadding:f,resetSelectionOnOptionHover:h,__staticSelector:m,readOnly:g,...y}=t,S=Tc(),v=s||S,x=de({name:m||"Combobox",classes:Wn,props:t,classNames:n,styles:r,unstyled:o,vars:l,varsResolver:n3}),w=()=>{u==null||u(),v.closeDropdown()};return C.createElement(zN,{value:{getStyles:x,store:v,onOptionSubmit:c,size:d,resetSelectionOnOptionHover:h,readOnly:g}},C.createElement(Br,{opened:v.dropdownOpened,...y,onClose:w,withRoles:!1,unstyled:o},i))}const r3=e=>e;Ee.extend=r3;Ee.classes=Wn;Ee.displayName="@mantine/core/Combobox";Ee.Target=lj;Ee.Dropdown=Dy;Ee.Options=Ly;Ee.Option=My;Ee.Search=$y;Ee.Empty=Iy;Ee.Chevron=bf;Ee.Footer=Ay;Ee.Header=Oy;Ee.EventsTarget=aj;Ee.DropdownTarget=sj;Ee.Group=Ny;Ee.ClearButton=ij;var cj={root:"m-5f75b09e",body:"m-5f6e695e",labelWrapper:"m-d3ea56bb",label:"m-8ee546b8",description:"m-328f68c0",error:"m-8e8a99cc"};const uj=cj,Cf=p.forwardRef(({__staticSelector:e,__stylesApiProps:t,className:n,classNames:r,styles:o,unstyled:i,children:s,label:l,description:c,id:u,disabled:d,error:f,size:h,labelPosition:m="left",bodyElement:g="div",labelElement:y="label",variant:S,style:v,vars:x,mod:w,...b},j)=>{const E=de({name:e,props:t,className:n,style:v,classes:cj,classNames:r,styles:o,unstyled:i});return C.createElement(W,{...E("root"),ref:j,__vars:{"--label-fz":Kt(h),"--label-lh":Pe(h,"label-lh")},mod:[{"label-position":m},w],variant:S,size:h,...b},C.createElement(W,{component:g,htmlFor:g==="label"?u:void 0,...E("body")},s,C.createElement("div",{...E("labelWrapper"),"data-disabled":d||void 0},l&&C.createElement(W,{component:y,htmlFor:y==="label"?u:void 0,...E("label"),"data-disabled":d||void 0},l),c&&C.createElement(Ct.Description,{size:h,__inheritStyles:!1,...E("description")},c),f&&f!=="boolean"&&C.createElement(Ct.Error,{size:h,__inheritStyles:!1,...E("error")},f))))});Cf.displayName="@mantine/core/InlineInput";const dj=p.createContext(null),o3=dj.Provider,i3=()=>p.useContext(dj);function Fy({children:e,role:t}){const n=Ba();return n?C.createElement("div",{role:t,"aria-labelledby":n.labelId,"aria-describedby":n.describedBy},e):C.createElement(C.Fragment,null,e)}const s3={},zy=Q((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:i,wrapperProps:s,children:l,readOnly:c,...u}=U("CheckboxGroup",s3,e),[d,f]=gn({value:n,defaultValue:r,finalValue:[],onChange:o}),h=m=>{const g=m.currentTarget.value;!c&&f(d.includes(g)?d.filter(y=>y!==g):[...d,g])};return C.createElement(o3,{value:{value:d,onChange:h,size:i}},C.createElement(Ct.Wrapper,{size:i,ref:t,...s,...u,labelElement:"div",__staticSelector:"CheckboxGroup"},C.createElement(Fy,{role:"group"},l)))});zy.classes=Ct.Wrapper.classes;zy.displayName="@mantine/core/CheckboxGroup";function Ef({size:e,style:t,...n}){const r=e!==void 0?{width:B(e),height:B(e),...t}:t;return C.createElement("svg",{viewBox:"0 0 10 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:r,"aria-hidden":!0,...n},C.createElement("path",{d:"M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}function a3({indeterminate:e,...t}){return e?C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 6","aria-hidden":!0,...t},C.createElement("rect",{width:"32",height:"6",fill:"currentColor",rx:"3"})):C.createElement(Ef,{...t})}var fj={root:"m-bf2d988c",inner:"m-26062bec",input:"m-26063560",icon:"m-bf295423","input--outline":"m-215c4542"};const l3={labelPosition:"right",icon:a3},c3=(e,{radius:t,color:n,size:r,iconColor:o,variant:i,autoContrast:s})=>{const l=ao({color:n||e.primaryColor,theme:e}),c=l.isThemeColor&&l.shade===void 0?`var(--mantine-color-${l.color}-outline)`:l.color;return{root:{"--checkbox-size":Pe(r,"checkbox-size"),"--checkbox-radius":t===void 0?void 0:gt(t),"--checkbox-color":i==="outline"?c:mt(n,e),"--checkbox-icon-color":o?mt(o,e):gc(s,e)?fs({color:n,theme:e}):void 0}}},gr=Q((e,t)=>{const n=U("Checkbox",l3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,color:u,label:d,id:f,size:h,radius:m,wrapperProps:g,children:y,checked:S,labelPosition:v,description:x,error:w,disabled:b,variant:j,indeterminate:E,icon:P,rootRef:T,iconColor:D,onChange:_,autoContrast:O,mod:I,...$}=n,N=i3(),L=h||(N==null?void 0:N.size),M=P,R=de({name:"Checkbox",props:n,classes:fj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:c3}),{styleProps:k,rest:F}=No($),q=kn(f),G=N?{checked:N.value.includes(F.value),onChange:oe=>{N.onChange(oe),_==null||_(oe)}}:{};return C.createElement(Cf,{...R("root"),__staticSelector:"Checkbox",__stylesApiProps:n,id:q,size:L,labelPosition:v,label:d,description:x,error:w,disabled:b,classNames:r,styles:s,unstyled:l,"data-checked":G.checked||S||void 0,variant:j,ref:T,mod:I,...k,...g},C.createElement(W,{...R("inner"),mod:{"data-label-position":v}},C.createElement(W,{component:"input",id:q,ref:t,checked:S,disabled:b,mod:{error:!!w,indeterminate:E},...R("input",{focusable:!0,variant:j}),onChange:_,...F,...G,type:"checkbox"}),C.createElement(M,{indeterminate:E,...R("icon")})))});gr.classes={...fj,...uj};gr.displayName="@mantine/core/Checkbox";gr.Group=zy;function Ta(e){return"group"in e}function hj({options:e,search:t,limit:n}){const r=t.trim().toLowerCase(),o=[];for(let i=0;i<e.length;i+=1){const s=e[i];if(o.length===n)return o;Ta(s)&&o.push({group:s.group,items:hj({options:s.items,search:t,limit:n-o.length})}),Ta(s)||s.label.toLowerCase().includes(r)&&o.push(s)}return o}function u3(e){if(e.length===0)return!0;for(const t of e)if(!("group"in t)||t.items.length>0)return!1;return!0}function pj(e,t=new Set){if(Array.isArray(e))for(const n of e)if(Ta(n))pj(n.items,t);else{if(typeof n.value>"u")throw new Error("[@mantine/core] Each option must have value property");if(typeof n.value!="string")throw new Error(`[@mantine/core] Option value must be a string, other data formats are not supported, got ${typeof n.value}`);if(t.has(n.value))throw new Error(`[@mantine/core] Duplicate options are not supported. Option with value "${n.value}" was provided more than once`);t.add(n.value)}}function d3(e,t){return Array.isArray(e)?e.includes(t):e===t}function mj({data:e,withCheckIcon:t,value:n,checkIconPosition:r,unstyled:o,renderOption:i}){if(!Ta(e)){const l=d3(n,e.value),c=t&&l&&C.createElement(Ef,{className:Wn.optionsDropdownCheckIcon}),u=C.createElement(C.Fragment,null,r==="left"&&c,C.createElement("span",null,e.label),r==="right"&&c);return C.createElement(Ee.Option,{value:e.value,disabled:e.disabled,className:et({[Wn.optionsDropdownOption]:!o}),"data-reverse":r==="right"||void 0,"data-checked":l||void 0,"aria-selected":l,active:l},typeof i=="function"?i({option:e,checked:l}):u)}const s=e.items.map(l=>C.createElement(mj,{data:l,value:n,key:l.value,unstyled:o,withCheckIcon:t,checkIconPosition:r}));return C.createElement(Ee.Group,{label:e.group},s)}function f3({data:e,hidden:t,hiddenWhenEmpty:n,filter:r,search:o,limit:i,maxDropdownHeight:s,withScrollArea:l=!0,filterOptions:c=!0,withCheckIcon:u=!1,value:d,checkIconPosition:f,nothingFoundMessage:h,unstyled:m,labelId:g,renderOption:y}){pj(e);const v=typeof o=="string"?(r||hj)({options:e,search:c?o:"",limit:i??1/0}):e,x=u3(v),w=v.map(b=>C.createElement(mj,{data:b,key:Ta(b)?b.group:b.value,withCheckIcon:u,value:d,checkIconPosition:f,unstyled:m,renderOption:y}));return C.createElement(Ee.Dropdown,{hidden:t||n&&x},C.createElement(Ee.Options,{labelledBy:g},l?C.createElement(vr.Autosize,{mah:s??220,type:"scroll",scrollbarSize:"var(--combobox-padding)",offsetScrollbars:"y"},w):w,x&&h&&C.createElement(Ee.Empty,null,h)))}const gj=p.createContext(null),h3=gj.Provider;function p3(){return{withinGroup:!!p.useContext(gj)}}var jf={group:"m-11def92b",root:"m-f85678b6",image:"m-11f8ac07",placeholder:"m-104cd71f"};const m3={},g3=(e,{spacing:t})=>({group:{"--ag-spacing":rn(t)}}),By=Q((e,t)=>{const n=U("AvatarGroup",m3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,spacing:u,...d}=n,f=de({name:"AvatarGroup",classes:jf,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:g3,rootSelector:"group"});return C.createElement(h3,{value:!0},C.createElement(W,{ref:t,...f("group"),...d}))});By.classes=jf;By.displayName="@mantine/core/AvatarGroup";function y3(e){return C.createElement("svg",{...e,"data-avatar-placeholder-icon":!0,viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},C.createElement("path",{d:"M0.877014 7.49988C0.877014 3.84219 3.84216 0.877045 7.49985 0.877045C11.1575 0.877045 14.1227 3.84219 14.1227 7.49988C14.1227 11.1575 11.1575 14.1227 7.49985 14.1227C3.84216 14.1227 0.877014 11.1575 0.877014 7.49988ZM7.49985 1.82704C4.36683 1.82704 1.82701 4.36686 1.82701 7.49988C1.82701 8.97196 2.38774 10.3131 3.30727 11.3213C4.19074 9.94119 5.73818 9.02499 7.50023 9.02499C9.26206 9.02499 10.8093 9.94097 11.6929 11.3208C12.6121 10.3127 13.1727 8.97172 13.1727 7.49988C13.1727 4.36686 10.6328 1.82704 7.49985 1.82704ZM10.9818 11.9787C10.2839 10.7795 8.9857 9.97499 7.50023 9.97499C6.01458 9.97499 4.71624 10.7797 4.01845 11.9791C4.97952 12.7272 6.18765 13.1727 7.49985 13.1727C8.81227 13.1727 10.0206 12.727 10.9818 11.9787ZM5.14999 6.50487C5.14999 5.207 6.20212 4.15487 7.49999 4.15487C8.79786 4.15487 9.84999 5.207 9.84999 6.50487C9.84999 7.80274 8.79786 8.85487 7.49999 8.85487C6.20212 8.85487 5.14999 7.80274 5.14999 6.50487ZM7.49999 5.10487C6.72679 5.10487 6.09999 5.73167 6.09999 6.50487C6.09999 7.27807 6.72679 7.90487 7.49999 7.90487C8.27319 7.90487 8.89999 7.27807 8.89999 6.50487C8.89999 5.73167 8.27319 5.10487 7.49999 5.10487Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}))}const v3={},x3=(e,{size:t,radius:n,variant:r,gradient:o,color:i,autoContrast:s})=>{const l=e.variantColorResolver({color:i||"gray",theme:e,gradient:o,variant:r||"light",autoContrast:s});return{root:{"--avatar-size":Pe(t,"avatar-size"),"--avatar-radius":n===void 0?void 0:gt(n),"--avatar-bg":i||r?l.background:void 0,"--avatar-color":i||r?l.color:void 0,"--avatar-bd":i||r?l.border:void 0}}},os=vn((e,t)=>{const n=U("Avatar",v3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,src:u,alt:d,radius:f,color:h,gradient:m,imageProps:g,children:y,autoContrast:S,mod:v,...x}=n,w=p3(),[b,j]=p.useState(!u),E=de({name:"Avatar",props:n,classes:jf,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:x3});return p.useEffect(()=>j(!u),[u]),C.createElement(W,{...E("root"),mod:[{"within-group":w.withinGroup},v],ref:t,...x},b?C.createElement("span",{...E("placeholder"),title:d},y||C.createElement(y3,null)):C.createElement("img",{...g,...E("image"),src:u,alt:d,onError:P=>{var T;j(!0),(T=g==null?void 0:g.onError)==null||T.call(g,P)}}))});os.classes=jf;os.displayName="@mantine/core/Avatar";os.Group=By;var yj={root:"m-347db0ec","root--dot":"m-fbd81e3d",label:"m-5add502a",section:"m-91fdda9b"};const w3={},S3=(e,{radius:t,color:n,gradient:r,variant:o,size:i,autoContrast:s})=>{const l=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:o||"filled",autoContrast:s});return{root:{"--badge-height":Pe(i,"badge-height"),"--badge-padding-x":Pe(i,"badge-padding-x"),"--badge-fz":Pe(i,"badge-fz"),"--badge-radius":t===void 0?void 0:gt(t),"--badge-bg":n||o?l.background:void 0,"--badge-color":n||o?l.color:void 0,"--badge-bd":n||o?l.border:void 0,"--badge-dot-color":o==="dot"?mt(n,e):void 0}}},kc=vn((e,t)=>{const n=U("Badge",w3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,radius:u,color:d,gradient:f,leftSection:h,rightSection:m,children:g,variant:y,fullWidth:S,autoContrast:v,circle:x,mod:w,...b}=n,j=de({name:"Badge",props:n,classes:yj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:S3});return C.createElement(W,{variant:y,mod:[{block:S,circle:x},w],...j("root",{variant:y}),ref:t,...b},h&&C.createElement("span",{...j("section"),"data-position":"left"},h),C.createElement("span",{...j("label")},g),m&&C.createElement("span",{...j("section"),"data-position":"right"},m))});kc.classes=yj;kc.displayName="@mantine/core/Badge";var vj={root:"m-ddec01c0",icon:"m-dde7bd57",cite:"m-dde51a35"};const b3={iconSize:48},C3=(e,{color:t,iconSize:n,radius:r})=>{const o=ao({color:t||e.primaryColor,theme:e,colorScheme:"dark"}),i=ao({color:t||e.primaryColor,theme:e,colorScheme:"light"});return{root:{"--bq-bg-light":nn(i.value,.07),"--bq-bg-dark":nn(o.value,.06),"--bq-bd":mt(t,e),"--bq-icon-size":B(n),"--bq-radius":gt(r)}}},Uy=Q((e,t)=>{const n=U("Blockquote",b3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,children:u,icon:d,iconSize:f,cite:h,...m}=n,g=de({name:"Blockquote",classes:vj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:C3});return C.createElement(W,{component:"blockquote",ref:t,...g("root"),...m},d&&C.createElement("span",{...g("icon")},d),u,h&&C.createElement("cite",{...g("cite")},h))});Uy.classes=vj;Uy.displayName="@mantine/core/Blockquote";var Pf={root:"m-77c9d27d",inner:"m-80f1301b",label:"m-811560b9",section:"m-a74036a",loader:"m-a25b86ee",group:"m-80d6d844"};const S1={orientation:"horizontal"},E3=(e,{borderWidth:t})=>({group:{"--button-border-width":B(t)}}),Vy=Q((e,t)=>{const n=U("ButtonGroup",S1,e),{className:r,style:o,classNames:i,styles:s,unstyled:l,orientation:c,vars:u,borderWidth:d,variant:f,mod:h,...m}=U("ButtonGroup",S1,e),g=de({name:"ButtonGroup",props:n,classes:Pf,className:r,style:o,classNames:i,styles:s,unstyled:l,vars:u,varsResolver:E3,rootSelector:"group"});return C.createElement(W,{...g("group"),ref:t,variant:f,mod:[{"data-orientation":c},h],role:"group",...m})});Vy.classes=Pf;Vy.displayName="@mantine/core/ButtonGroup";const j3={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${B(1)}))`},out:{opacity:0,transform:"translate(-50%, -200%)"},common:{transformOrigin:"center"},transitionProperty:"transform, opacity"},P3={},T3=(e,{radius:t,color:n,gradient:r,variant:o,size:i,justify:s,autoContrast:l})=>{const c=e.variantColorResolver({color:n||e.primaryColor,theme:e,gradient:r,variant:o||"filled",autoContrast:l});return{root:{"--button-justify":s,"--button-height":Pe(i,"button-height"),"--button-padding-x":Pe(i,"button-padding-x"),"--button-fz":i!=null&&i.includes("compact")?Kt(i.replace("compact-","")):Kt(i),"--button-radius":t===void 0?void 0:gt(t),"--button-bg":n||o?c.background:void 0,"--button-hover":n||o?c.hover:void 0,"--button-color":c.color,"--button-bd":n||o?c.border:void 0,"--button-hover-color":n||o?c.hoverColor:void 0}}},te=vn((e,t)=>{const n=U("Button",P3,e),{style:r,vars:o,className:i,color:s,disabled:l,children:c,leftSection:u,rightSection:d,fullWidth:f,variant:h,radius:m,loading:g,loaderProps:y,gradient:S,classNames:v,styles:x,unstyled:w,"data-disabled":b,autoContrast:j,mod:E,...P}=n,T=de({name:"Button",props:n,classes:Pf,className:i,style:r,classNames:v,styles:x,unstyled:w,vars:o,varsResolver:T3}),D=!!u,_=!!d;return C.createElement(Jn,{ref:t,...T("root",{active:!l&&!g&&!b}),unstyled:w,variant:h,disabled:l||g,mod:[{disabled:l||b,loading:g,block:f,"with-left-section":D,"with-right-section":_},E],...P},C.createElement(Lo,{mounted:!!g,transition:j3,duration:150},O=>C.createElement(W,{component:"span",...T("loader",{style:O}),"aria-hidden":!0},C.createElement(Vn,{color:"var(--button-color)",size:"calc(var(--button-height) / 1.8)",...y}))),C.createElement("span",{...T("inner")},u&&C.createElement(W,{component:"span",...T("section"),mod:{position:"left"}},u),C.createElement(W,{component:"span",mod:{loading:g},...T("label")},c),d&&C.createElement(W,{component:"span",...T("section"),mod:{position:"right"}},d)))});te.classes=Pf;te.displayName="@mantine/core/Button";te.Group=Vy;var xj={root:"m-4451eb3a"};const k3={},on=vn((e,t)=>{const n=U("Center",k3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,inline:u,mod:d,...f}=n,h=de({name:"Center",props:n,classes:xj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c});return C.createElement(W,{ref:t,mod:[{inline:u},d],...h("root"),...f})});on.classes=xj;on.displayName="@mantine/core/Center";const[R3,D3]=mc(),I3={};function wj(e){const{value:t,defaultValue:n,onChange:r,multiple:o,children:i}=U("ChipGroup",I3,e),[s,l]=gn({value:t,defaultValue:n,finalValue:o?[]:null,onChange:r}),c=d=>Array.isArray(s)?s.includes(d):d===s,u=d=>{const f=d.currentTarget.value;Array.isArray(s)?l(s.includes(f)?s.filter(h=>h!==f):[...s,f]):l(f)};return C.createElement(R3,{value:{isChipSelected:c,onChange:u,multiple:o}},i)}wj.displayName="@mantine/core/ChipGroup";var Sj={root:"m-f59ffda3",label:"m-be049a53","label--outline":"m-3904c1af","label--filled":"m-fa109255","label--light":"m-f7e165c3",iconWrapper:"m-9ac86df9",checkIcon:"m-d6d72580",input:"m-bde07329"};const _3={type:"checkbox"},A3=(e,{size:t,radius:n,variant:r,color:o,autoContrast:i})=>{const s=e.variantColorResolver({color:o||e.primaryColor,theme:e,variant:r||"filled",autoContrast:i});return{root:{"--chip-fz":Kt(t),"--chip-size":Pe(t,"chip-size"),"--chip-radius":n===void 0?void 0:gt(n),"--chip-checked-padding":Pe(t,"chip-checked-padding"),"--chip-padding":Pe(t,"chip-padding"),"--chip-icon-size":Pe(t,"chip-icon-size"),"--chip-bg":o||r?s.background:void 0,"--chip-hover":o||r?s.hover:void 0,"--chip-color":o||r?s.color:void 0,"--chip-bd":o||r?s.border:void 0,"--chip-spacing":Pe(t,"chip-spacing")}}},rc=Q((e,t)=>{const n=U("Chip",_3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,id:u,checked:d,defaultChecked:f,onChange:h,value:m,wrapperProps:g,type:y,disabled:S,children:v,size:x,variant:w,icon:b,rootRef:j,autoContrast:E,mod:P,...T}=n,D=de({name:"Chip",classes:Sj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:A3}),_=D3(),O=kn(u),{styleProps:I,rest:$}=No(T),[N,L]=gn({value:d,defaultValue:f,finalValue:!1,onChange:h}),M=_?{checked:_.isChipSelected(m),onChange:k=>{_.onChange(k),h==null||h(k.currentTarget.checked)},type:_.multiple?"checkbox":"radio"}:{},R=M.checked||N;return C.createElement(W,{size:x,variant:w,ref:j,mod:P,...D("root"),...I,...g},C.createElement("input",{type:y,...D("input"),checked:R,onChange:k=>L(k.currentTarget.checked),id:O,disabled:S,ref:t,value:m,...M,...$}),C.createElement("label",{htmlFor:O,"data-checked":R||void 0,"data-disabled":S||void 0,...D("label",{variant:w||"filled"})},R&&C.createElement("span",{...D("iconWrapper")},b||C.createElement(Ef,{...D("checkIcon")})),C.createElement("span",null,v)))});rc.classes=Sj;rc.displayName="@mantine/core/Chip";rc.Group=wj;var bj={root:"m-b183c0a2"};const N3={},O3=(e,{color:t})=>({root:{"--code-bg":t?mt(t,e):void 0}}),Wy=Q((e,t)=>{const n=U("Code",N3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,color:u,block:d,variant:f,mod:h,...m}=n,g=de({name:"Code",props:n,classes:bj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:O3});return C.createElement(W,{component:d?"pre":"code",variant:f,ref:t,mod:[{block:d},h],...g("root"),...m,dir:"ltr"})});Wy.classes=bj;Wy.displayName="@mantine/core/Code";var Cj={root:"m-7485cace"};const M3={},L3=(e,{size:t,fluid:n})=>({root:{"--container-size":n?void 0:Pe(t,"container-size")}}),Hy=Q((e,t)=>{const n=U("Container",M3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,fluid:u,mod:d,...f}=n,h=de({name:"Container",classes:Cj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:L3});return C.createElement(W,{ref:t,mod:[{fluid:u},d],...h("root"),...f})});Hy.classes=Cj;Hy.displayName="@mantine/core/Container";const $3={timeout:1e3};function Ej(e){const{children:t,timeout:n,value:r,...o}=U("CopyButton",$3,e),i=NS({timeout:n}),s=()=>i.copy(r);return C.createElement(C.Fragment,null,t({copy:s,copied:i.copied,...o}))}Ej.displayName="@mantine/core/CopyButton";var jj={root:"m-3eebeb36",label:"m-9e365f20"};const F3={orientation:"horizontal"},z3=(e,{color:t,variant:n,size:r})=>({root:{"--divider-color":t?mt(t,e):void 0,"--divider-border-style":n,"--divider-size":Pe(r,"divider-size")}}),fn=Q((e,t)=>{const n=U("Divider",F3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,color:u,orientation:d,label:f,labelPosition:h,mod:m,...g}=n,y=de({name:"Divider",classes:jj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:z3});return C.createElement(W,{ref:t,mod:[{orientation:d,"with-label":!!f},m],...y("root"),...g,role:"separator"},f&&C.createElement(W,{component:"span",mod:{position:h},...y("label")},f))});fn.classes=jj;fn.displayName="@mantine/core/Divider";function B3({open:e,close:t,openDelay:n,closeDelay:r}){const o=p.useRef(-1),i=p.useRef(-1),s=()=>{window.clearTimeout(o.current),window.clearTimeout(i.current)},l=()=>{s(),n===0||n===void 0?e():o.current=window.setTimeout(e,n)},c=()=>{s(),r===0||r===void 0?t():i.current=window.setTimeout(t,r)};return p.useEffect(()=>s,[]),{openDropdown:l,closeDropdown:c}}const[U3,Pj]=Tn("Grid component was not found in tree"),vm=(e,t)=>e==="content"?"auto":e==="auto"?"0rem":e?`${100/(t/e)}%`:void 0,b1=(e,t,n)=>n||e==="auto"?"100%":e==="content"?"unset":vm(e,t),C1=(e,t)=>{if(e)return e==="auto"||t?"1":"auto"},E1=(e,t)=>e===0?"0":e?`${100/(t/e)}%`:void 0;function V3({span:e,order:t,offset:n,selector:r}){var h;const o=kt(),i=Pj(),l=ni(e)===void 0?12:ni(e),c=ds({"--col-order":(h=ni(t))==null?void 0:h.toString(),"--col-flex-grow":C1(l,i.grow),"--col-flex-basis":vm(l,i.columns),"--col-width":l==="content"?"auto":void 0,"--col-max-width":b1(l,i.columns,i.grow),"--col-offset":E1(ni(n),i.columns)}),u=pt(o.breakpoints).reduce((m,g)=>{var y;return m[g]||(m[g]={}),typeof t=="object"&&t[g]!==void 0&&(m[g]["--col-order"]=(y=t[g])==null?void 0:y.toString()),typeof e=="object"&&e[g]!==void 0&&(m[g]["--col-flex-grow"]=C1(e[g],i.grow),m[g]["--col-flex-basis"]=vm(e[g],i.columns),m[g]["--col-width"]=e[g]==="content"?"auto":void 0,m[g]["--col-max-width"]=b1(e[g],i.columns,i.grow)),typeof n=="object"&&n[g]!==void 0&&(m[g]["--col-offset"]=E1(n[g],i.columns)),m},{}),f=Ll(pt(u),o).filter(m=>pt(u[m.value]).length>0).map(m=>({query:`(min-width: ${o.breakpoints[m.value]})`,styles:u[m.value]}));return C.createElement(La,{styles:c,media:f,selector:r})}var qy={root:"m-410352e9",inner:"m-dee7bd2f",col:"m-96bdd299"};const W3={span:12},Gy=Q((e,t)=>{const n=U("GridCol",W3,e),{classNames:r,className:o,style:i,styles:s,vars:l,span:c,order:u,offset:d,...f}=n,h=Pj(),m=yc();return C.createElement(C.Fragment,null,C.createElement(V3,{selector:`.${m}`,span:c,order:u,offset:d}),C.createElement(W,{ref:t,...h.getStyles("col",{className:et(o,m),style:i,classNames:r,styles:s}),...f}))});Gy.classes=qy;Gy.displayName="@mantine/core/GridCol";function H3({gutter:e,selector:t}){const n=kt(),r=ds({"--grid-gutter":rn(ni(e))}),o=pt(n.breakpoints).reduce((l,c)=>(l[c]||(l[c]={}),typeof e=="object"&&e[c]!==void 0&&(l[c]["--grid-gutter"]=rn(e[c])),l),{}),s=Ll(pt(o),n).filter(l=>pt(o[l.value]).length>0).map(l=>({query:`(min-width: ${n.breakpoints[l.value]})`,styles:o[l.value]}));return C.createElement(La,{styles:r,media:s,selector:t})}const q3={gutter:"md",grow:!1,columns:12},G3=(e,{justify:t,align:n,overflow:r})=>({root:{"--grid-justify":t,"--grid-align":n,"--grid-overflow":r}}),Kn=Q((e,t)=>{const n=U("Grid",q3,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,grow:u,gutter:d,columns:f,align:h,justify:m,children:g,...y}=n,S=de({name:"Grid",classes:qy,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:G3}),v=yc();return C.createElement(U3,{value:{getStyles:S,grow:u,columns:f}},C.createElement(H3,{selector:`.${v}`,...n}),C.createElement(W,{ref:t,...S("root",{className:v}),...y},C.createElement("div",{...S("inner")},g)))});Kn.classes=qy;Kn.displayName="@mantine/core/Grid";Kn.Col=Gy;function Dd(){return Dd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dd.apply(this,arguments)}function Qy(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var Q3=p.useLayoutEffect,K3=function(t){var n=p.useRef(t);return Q3(function(){n.current=t}),n},j1=function(t,n){if(typeof t=="function"){t(n);return}t.current=n},Y3=function(t,n){var r=p.useRef();return p.useCallback(function(o){t.current=o,r.current&&j1(r.current,null),r.current=n,n&&j1(n,o)},[n])},P1={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0"},X3=function(t){Object.keys(P1).forEach(function(n){t.style.setProperty(n,P1[n],"important")})},T1=X3,xn=null,k1=function(t,n){var r=t.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function J3(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),xn||(xn=document.createElement("textarea"),xn.setAttribute("tabindex","-1"),xn.setAttribute("aria-hidden","true"),T1(xn)),xn.parentNode===null&&document.body.appendChild(xn);var o=e.paddingSize,i=e.borderSize,s=e.sizingStyle,l=s.boxSizing;Object.keys(s).forEach(function(h){var m=h;xn.style[m]=s[m]}),T1(xn),xn.value=t;var c=k1(xn,e);xn.value=t,c=k1(xn,e),xn.value="x";var u=xn.scrollHeight-o,d=u*n;l==="border-box"&&(d=d+o+i),c=Math.max(d,c);var f=u*r;return l==="border-box"&&(f=f+o+i),c=Math.min(f,c),[c,u]}var R1=function(){},Z3=function(t,n){return t.reduce(function(r,o){return r[o]=n[o],r},{})},e9=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak"],t9=!!document.documentElement.currentStyle,n9=function(t){var n=window.getComputedStyle(t);if(n===null)return null;var r=Z3(e9,n),o=r.boxSizing;if(o==="")return null;t9&&o==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),s=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:s}},r9=n9;function Tj(e,t,n){var r=K3(n);p.useLayoutEffect(function(){var o=function(s){return r.current(s)};if(e)return e.addEventListener(t,o),function(){return e.removeEventListener(t,o)}},[])}var o9=function(t){Tj(window,"resize",t)},i9=function(t){Tj(document.fonts,"loadingdone",t)},s9=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],a9=function(t,n){var r=t.cacheMeasurements,o=t.maxRows,i=t.minRows,s=t.onChange,l=s===void 0?R1:s,c=t.onHeightChange,u=c===void 0?R1:c,d=Qy(t,s9),f=d.value!==void 0,h=p.useRef(null),m=Y3(h,n),g=p.useRef(0),y=p.useRef(),S=function(){var w=h.current,b=r&&y.current?y.current:r9(w);if(b){y.current=b;var j=J3(b,w.value||w.placeholder||"x",i,o),E=j[0],P=j[1];g.current!==E&&(g.current=E,w.style.setProperty("height",E+"px","important"),u(E,{rowHeight:P}))}},v=function(w){f||S(),l(w)};return p.useLayoutEffect(S),o9(S),i9(S),p.createElement("textarea",Dd({},d,{onChange:v,ref:m}))},l9=p.forwardRef(a9);const c9={},ws=Q((e,t)=>{const{autosize:n,maxRows:r,minRows:o,__staticSelector:i,resize:s,...l}=U("Textarea",c9,e),c=n&&BS()!=="test",u=c?{maxRows:r,minRows:o}:{};return C.createElement(wr,{component:c?l9:"textarea",ref:t,...l,__staticSelector:i||"Textarea",multiline:!0,"data-no-overflow":n&&r===void 0||void 0,__vars:{"--input-resize":s},...u})});ws.classes=wr.classes;ws.displayName="@mantine/core/Textarea";function D1(e,t){if(typeof e=="string"&&e.trim().length===0)return!0;try{return t(e),!0}catch{return!1}}const u9={serialize:JSON.stringify,deserialize:JSON.parse},Va=Q((e,t)=>{const{value:n,defaultValue:r,onChange:o,formatOnBlur:i,validationError:s,serialize:l,deserialize:c,onFocus:u,onBlur:d,readOnly:f,error:h,...m}=U("JsonInput",u9,e),[g,y]=gn({value:n,defaultValue:r,finalValue:"",onChange:o}),[S,v]=p.useState(D1(g,c)),x=b=>{u==null||u(b),v(!0)},w=b=>{typeof d=="function"&&d(b);const j=D1(b.currentTarget.value,c);i&&!f&&j&&b.currentTarget.value.trim()!==""&&y(l(c(b.currentTarget.value),null,2)),v(j)};return C.createElement(ws,{value:g,onChange:b=>y(b.currentTarget.value),onFocus:x,onBlur:w,ref:t,readOnly:f,...m,autoComplete:"off",__staticSelector:"JsonInput",error:S?h:s||!0,"data-monospace":!0})});Va.classes=wr.classes;Va.displayName="@mantine/core/JsonInput";const[d9,f9]=Tn("List component was not found in tree");var Ky={root:"m-abbac491",item:"m-abb6bec2",itemWrapper:"m-75cd9f71",itemIcon:"m-60f83e5b"};const h9={},Yy=Q((e,t)=>{const n=U("ListItem",h9,e),{classNames:r,className:o,style:i,styles:s,vars:l,icon:c,children:u,mod:d,...f}=n,h=f9(),m=c||h.icon,g={classNames:r,styles:s};return C.createElement(W,{...h.getStyles("item",{...g,className:o,style:i}),component:"li",mod:[{"with-icon":!!m,centered:h.center},d],ref:t,...f},C.createElement("div",{...h.getStyles("itemWrapper",g)},m&&C.createElement("span",{...h.getStyles("itemIcon",g)},m),C.createElement("span",{...h.getStyles("itemLabel",g)},u)))});Yy.classes=Ky;Yy.displayName="@mantine/core/ListItem";const p9={type:"unordered"},m9=(e,{size:t,spacing:n})=>({root:{"--list-fz":Kt(t),"--list-lh":AS(t),"--list-spacing":rn(n)}}),Cn=Q((e,t)=>{const n=U("List",p9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,children:u,type:d,withPadding:f,icon:h,spacing:m,center:g,listStyleType:y,mod:S,...v}=n,x=de({name:"List",classes:Ky,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:m9});return C.createElement(d9,{value:{center:g,icon:h,getStyles:x}},C.createElement(W,{...x("root",{style:{listStyleType:y}}),component:d==="unordered"?"ul":"ol",mod:[{"with-padding":f},S],ref:t,...v},u))});Cn.classes=Ky;Cn.displayName="@mantine/core/List";Cn.Item=Yy;var kj={root:"m-6e45937b",loader:"m-e8eb006c",overlay:"m-df587f17"};const I1={transitionProps:{transition:"fade",duration:0},overlayProps:{backgroundOpacity:.75},zIndex:zr("overlay")},g9=(e,{zIndex:t})=>({root:{"--lo-z-index":t==null?void 0:t.toString()}}),Xy=Q((e,t)=>{const n=U("LoadingOverlay",I1,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,transitionProps:u,loaderProps:d,overlayProps:f,visible:h,zIndex:m,...g}=n,y=kt(),S=de({name:"LoadingOverlay",classes:kj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:g9}),v={...I1.overlayProps,...f};return C.createElement(Lo,{transition:"fade",...u,mounted:!!h},x=>C.createElement(W,{...S("root",{style:x}),ref:t,...g},C.createElement(Vn,{...S("loader"),unstyled:l,...d}),C.createElement(nc,{...v,...S("overlay"),darkHidden:!0,unstyled:l,color:(f==null?void 0:f.color)||y.white}),C.createElement(nc,{...v,...S("overlay"),lightHidden:!0,unstyled:l,color:(f==null?void 0:f.color)||y.colors.dark[5]})))});Xy.classes=kj;Xy.displayName="@mantine/core/LoadingOverlay";const[y9,Rc]=Tn("Menu component was not found in the tree");var Wa={dropdown:"m-dc9b7c9f",label:"m-9bfac126",divider:"m-efdf90cb",item:"m-99ac2aa1",itemLabel:"m-5476e0d3",itemSection:"m-8b75e504"};const v9={},Jy=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,...l}=U("MenuDivider",v9,e),c=Rc();return C.createElement(W,{ref:t,...c.getStyles("divider",{className:r,style:o,styles:i,classNames:n}),...l})});Jy.classes=Wa;Jy.displayName="@mantine/core/MenuDivider";const x9={},Zy=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,onMouseEnter:l,onMouseLeave:c,children:u,...d}=U("MenuDropdown",x9,e),f=p.useRef(null),h=Rc(),m=S=>{var v,x;(S.key==="ArrowUp"||S.key==="ArrowDown")&&(S.preventDefault(),(x=(v=f.current)==null?void 0:v.querySelectorAll("[data-menu-item]:not(:disabled)")[0])==null||x.focus())},g=Gn(l,()=>(h.trigger==="hover"||h.trigger==="click-hover")&&h.openDropdown()),y=Gn(c,()=>(h.trigger==="hover"||h.trigger==="click-hover")&&h.closeDropdown());return C.createElement(Br.Dropdown,{...d,onMouseEnter:g,onMouseLeave:y,role:"menu","aria-orientation":"vertical",ref:Zt(t,f),...h.getStyles("dropdown",{className:r,style:o,styles:i,classNames:n,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:m},C.createElement("div",{tabIndex:-1,"data-autofocus":!0,"aria-hidden":!0}),u)});Zy.classes=Wa;Zy.displayName="@mantine/core/MenuDropdown";const w9={},ev=vn((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,color:l,closeMenuOnClick:c,leftSection:u,rightSection:d,children:f,disabled:h,...m}=U("MenuItem",w9,e),g=Rc(),y=kt(),{dir:S}=hs(),v=p.useRef(),x=g.getItemIndex(v.current),w=m,b=Gn(w.onMouseLeave,()=>g.setHovered(-1)),j=Gn(w.onMouseEnter,()=>g.setHovered(g.getItemIndex(v.current))),E=Gn(w.onClick,()=>{typeof c=="boolean"?c&&g.closeDropdownImmediately():g.closeOnItemClick&&g.closeDropdownImmediately()}),P=Gn(w.onFocus,()=>g.setHovered(g.getItemIndex(v.current))),T=l?y.variantColorResolver({color:l,theme:y,variant:"light"}):void 0,D=l?ao({color:l,theme:y}):null;return C.createElement(Jn,{...m,unstyled:g.unstyled,tabIndex:g.menuItemTabIndex,onFocus:P,...g.getStyles("item",{className:r,style:o,styles:i,classNames:n}),ref:Zt(v,t),role:"menuitem",disabled:h,"data-menu-item":!0,"data-disabled":h||void 0,"data-hovered":g.hovered===x?!0:void 0,onMouseEnter:j,onMouseLeave:b,onClick:E,onKeyDown:_S({siblingSelector:"[data-menu-item]",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:g.loop,dir:S,orientation:"vertical",onKeyDown:w.onKeydown}),__vars:{"--menu-item-color":D!=null&&D.isThemeColor&&(D==null?void 0:D.shade)===void 0?`var(--mantine-color-${D.color}-6)`:T==null?void 0:T.color,"--menu-item-hover":T==null?void 0:T.hover}},u&&C.createElement("div",{...g.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"left"},u),f&&C.createElement("div",{...g.getStyles("itemLabel",{styles:i,classNames:n})},f),d&&C.createElement("div",{...g.getStyles("itemSection",{styles:i,classNames:n}),"data-position":"right"},d))});ev.classes=Wa;ev.displayName="@mantine/core/MenuItem";const S9={},tv=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,...l}=U("MenuLabel",S9,e),c=Rc();return C.createElement(W,{ref:t,...c.getStyles("label",{className:r,style:o,styles:i,classNames:n}),...l})});tv.classes=Wa;tv.displayName="@mantine/core/MenuLabel";const b9={refProp:"ref"},Rj=p.forwardRef((e,t)=>{const{children:n,refProp:r,...o}=U("MenuTarget",b9,e);if(!Ao(n))throw new Error("Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const i=Rc(),s=Gn(n.props.onClick,()=>{i.trigger==="click"?i.toggleDropdown():i.trigger==="click-hover"&&(i.setOpenedViaClick(!0),i.opened||i.openDropdown())}),l=Gn(n.props.onMouseEnter,()=>(i.trigger==="hover"||i.trigger==="click-hover")&&i.openDropdown()),c=Gn(n.props.onMouseLeave,()=>{(i.trigger==="hover"||i.trigger==="click-hover"&&!i.openedViaClick)&&i.closeDropdown()});return C.createElement(Br.Target,{refProp:r,popupType:"menu",ref:t,...o},p.cloneElement(n,{onClick:s,onMouseEnter:l,onMouseLeave:c,"data-expanded":i.opened?!0:void 0}))});Rj.displayName="@mantine/core/MenuTarget";const C9={trapFocus:!0,closeOnItemClick:!0,clickOutsideEvents:["mousedown","touchstart","keydown"],loop:!0,trigger:"click",openDelay:0,closeDelay:100,menuItemTabIndex:-1};function Z(e){const t=U("Menu",C9,e),{children:n,onOpen:r,onClose:o,opened:i,defaultOpened:s,trapFocus:l,onChange:c,closeOnItemClick:u,loop:d,closeOnEscape:f,trigger:h,openDelay:m,closeDelay:g,classNames:y,styles:S,unstyled:v,variant:x,vars:w,menuItemTabIndex:b,keepMounted:j,...E}=t,P=de({name:"Menu",classes:Wa,props:t,classNames:y,styles:S,unstyled:v}),[T,{setHovered:D,resetHovered:_}]=d2(),[O,I]=gn({value:i,defaultValue:s,finalValue:!1,onChange:c}),[$,N]=p.useState(!1),L=()=>{I(!1),N(!1),O&&(o==null||o())},M=()=>{I(!0),!O&&(r==null||r())},R=()=>{O?L():M()},{openDropdown:k,closeDropdown:F}=B3({open:M,close:L,closeDelay:g,openDelay:m}),q=xe=>u2("[data-menu-item]","[data-menu-dropdown]",xe),{resolvedClassNames:G,resolvedStyles:oe}=Jd({classNames:y,styles:S,props:t});return Co(()=>{_()},[O]),C.createElement(y9,{value:{getStyles:P,opened:O,toggleDropdown:R,getItemIndex:q,hovered:T,setHovered:D,openedViaClick:$,setOpenedViaClick:N,closeOnItemClick:u,closeDropdown:h==="click"?L:F,openDropdown:h==="click"?M:k,closeDropdownImmediately:L,loop:d,trigger:h,unstyled:v,menuItemTabIndex:b}},C.createElement(Br,{...E,opened:O,onChange:R,defaultOpened:s,trapFocus:j?!1:l,closeOnEscape:f,__staticSelector:"Menu",classNames:G,styles:oe,unstyled:v,variant:x,keepMounted:j},n))}Z.extend=e=>e;Z.classes=Wa;Z.displayName="@mantine/core/Menu";Z.Item=ev;Z.Label=tv;Z.Dropdown=Zy;Z.Target=Rj;Z.Divider=Jy;const[E9,Ha]=Tn("Modal component was not found in tree");var Fo={root:"m-9df02822",content:"m-54c44539",inner:"m-1f958f16",header:"m-d0e2b9cd"};const j9={},Tf=Q((e,t)=>{const n=U("ModalBody",j9,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ha();return C.createElement(GE,{ref:t,...u.getStyles("body",{classNames:r,style:i,styles:s,className:o}),...c})});Tf.classes=Fo;Tf.displayName="@mantine/core/ModalBody";const P9={},kf=Q((e,t)=>{const n=U("ModalCloseButton",P9,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ha();return C.createElement(QE,{ref:t,...u.getStyles("close",{classNames:r,style:i,styles:s,className:o}),...c})});kf.classes=Fo;kf.displayName="@mantine/core/ModalCloseButton";const T9={},Rf=Q((e,t)=>{const n=U("ModalContent",T9,e),{classNames:r,className:o,style:i,styles:s,vars:l,children:c,...u}=n,d=Ha(),f=d.scrollAreaComponent||eN;return C.createElement(Y4,{...d.getStyles("content",{className:o,style:i,styles:s,classNames:r}),innerProps:d.getStyles("inner",{className:o,style:i,styles:s,classNames:r}),"data-full-screen":d.fullScreen||void 0,ref:t,...u},C.createElement(f,{style:{maxHeight:d.fullScreen?"100dvh":`calc(100dvh - (${B(d.yOffset)} * 2))`}},c))});Rf.classes=Fo;Rf.displayName="@mantine/core/ModalContent";const k9={},Df=Q((e,t)=>{const n=U("ModalHeader",k9,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ha();return C.createElement(KE,{ref:t,...u.getStyles("header",{classNames:r,style:i,styles:s,className:o}),...c})});Df.classes=Fo;Df.displayName="@mantine/core/ModalHeader";const R9={},If=Q((e,t)=>{const n=U("ModalOverlay",R9,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ha();return C.createElement(YE,{ref:t,...u.getStyles("overlay",{classNames:r,style:i,styles:s,className:o}),...c})});If.classes=Fo;If.displayName="@mantine/core/ModalOverlay";const D9={__staticSelector:"Modal",closeOnClickOutside:!0,withinPortal:!0,lockScroll:!0,trapFocus:!0,returnFocus:!0,closeOnEscape:!0,keepMounted:!1,zIndex:zr("modal"),transitionProps:{duration:200,transition:"pop"},yOffset:"5dvh"},I9=(e,{radius:t,size:n,yOffset:r,xOffset:o})=>({root:{"--modal-radius":t===void 0?void 0:gt(t),"--modal-size":Pe(n,"modal-size"),"--modal-y-offset":B(r),"--modal-x-offset":B(o)}}),_f=Q((e,t)=>{const n=U("ModalRoot",D9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,yOffset:u,scrollAreaComponent:d,radius:f,fullScreen:h,centered:m,xOffset:g,__staticSelector:y,...S}=n,v=de({name:y,classes:Fo,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:I9});return C.createElement(E9,{value:{yOffset:u,scrollAreaComponent:d,getStyles:v,fullScreen:h}},C.createElement(Q4,{ref:t,...v("root"),"data-full-screen":h||void 0,"data-centered":m||void 0,unstyled:l,...S}))});_f.classes=Fo;_f.displayName="@mantine/core/ModalRoot";const _9={},Af=Q((e,t)=>{const n=U("ModalTitle",_9,e),{classNames:r,className:o,style:i,styles:s,vars:l,...c}=n,u=Ha();return C.createElement(XE,{ref:t,...u.getStyles("title",{classNames:r,style:i,styles:s,className:o}),...c})});Af.classes=Fo;Af.displayName="@mantine/core/ModalTitle";const A9={closeOnClickOutside:!0,withinPortal:!0,lockScroll:!0,trapFocus:!0,returnFocus:!0,closeOnEscape:!0,keepMounted:!1,zIndex:zr("modal"),transitionProps:{duration:200,transition:"pop"},withOverlay:!0,withCloseButton:!0},Dn=Q((e,t)=>{const{title:n,withOverlay:r,overlayProps:o,withCloseButton:i,closeButtonProps:s,children:l,radius:c,...u}=U("Modal",A9,e),d=!!n||i;return C.createElement(_f,{ref:t,radius:c,...u},r&&C.createElement(If,{...o}),C.createElement(Rf,{radius:c},d&&C.createElement(Df,null,n&&C.createElement(Af,null,n),i&&C.createElement(kf,{...s})),C.createElement(Tf,null,l)))});Dn.classes=Fo;Dn.displayName="@mantine/core/Modal";Dn.Root=_f;Dn.Overlay=If;Dn.Content=Rf;Dn.Body=Tf;Dn.Header=Df;Dn.Title=Af;Dn.CloseButton=kf;const[N9,nv]=mc(),[O9,M9]=mc();var Nf={root:"m-7cda1cd6","root--default":"m-44da308b","root--contrast":"m-e3a01f8",label:"m-1e0e6180",remove:"m-ae386778",group:"m-1dcfd90b"};const L9={},$9=(e,{gap:t},{size:n})=>({group:{"--pg-gap":t!==void 0?Pe(t):Pe(n,"pg-gap")}}),rv=Q((e,t)=>{const n=U("PillGroup",L9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,size:u,disabled:d,...f}=n,h=nv(),m=(h==null?void 0:h.size)||u||void 0,g=de({name:"PillGroup",classes:Nf,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:$9,stylesCtx:{size:m},rootSelector:"group"});return C.createElement(O9,{value:{size:m,disabled:d}},C.createElement(W,{ref:t,size:m,...g("group"),...f}))});rv.classes=Nf;rv.displayName="@mantine/core/PillGroup";const F9={variant:"default"},z9=(e,{radius:t},{size:n})=>({root:{"--pill-fz":Pe(n,"pill-fz"),"--pill-height":Pe(n,"pill-height"),"--pill-radius":t===void 0?void 0:gt(t)}}),is=Q((e,t)=>{const n=U("Pill",F9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,variant:u,children:d,withRemoveButton:f,onRemove:h,removeButtonProps:m,radius:g,size:y,disabled:S,mod:v,...x}=n,w=M9(),b=nv(),j=y||(w==null?void 0:w.size)||void 0,E=(b==null?void 0:b.variant)==="filled"?"contrast":u||"default",P=de({name:"Pill",classes:Nf,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:z9,stylesCtx:{size:j}});return C.createElement(W,{component:"span",ref:t,variant:E,size:j,...P("root",{variant:E}),mod:[{"with-remove":f,disabled:S||(w==null?void 0:w.disabled)},v],...x},C.createElement("span",{...P("label")},d),f&&C.createElement(vs,{variant:"transparent",radius:g,tabIndex:-1,"aria-hidden":!0,unstyled:l,...m,...P("remove",{className:m==null?void 0:m.className,style:m==null?void 0:m.style}),onMouseDown:T=>{var D;T.preventDefault(),T.stopPropagation(),(D=m==null?void 0:m.onMouseDown)==null||D.call(m,T)},onClick:T=>{var D;T.stopPropagation(),h==null||h(),(D=m==null?void 0:m.onClick)==null||D.call(m,T)}}))});is.classes=Nf;is.displayName="@mantine/core/Pill";is.Group=rv;var Dj={field:"m-45c4369d"};const B9={type:"visible"},ov=Q((e,t)=>{const n=U("PillsInputField",B9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,type:u,disabled:d,id:f,pointer:h,mod:m,...g}=n,y=nv(),S=Ba(),v=de({name:"PillsInputField",classes:Dj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,rootSelector:"field"}),x=d||(y==null?void 0:y.disabled);return C.createElement(W,{component:"input",ref:Zt(t,y==null?void 0:y.fieldRef),"data-type":u,disabled:x,mod:[{disabled:x,pointer:h},m],...v("field"),...g,id:(S==null?void 0:S.inputId)||f,"aria-invalid":y==null?void 0:y.hasError,"aria-describedby":S==null?void 0:S.describedBy,type:"text",onMouseDown:w=>!h&&w.stopPropagation()})});ov.classes=Dj;ov.displayName="@mantine/core/PillsInputField";const U9={},ka=Q((e,t)=>{const n=U("PillsInput",U9,e),{children:r,onMouseDown:o,onClick:i,size:s,disabled:l,__staticSelector:c,error:u,variant:d,...f}=n,h=p.useRef();return C.createElement(N9,{value:{fieldRef:h,size:s,disabled:l,hasError:!!u,variant:d}},C.createElement(wr,{size:s,error:u,variant:d,component:"div",ref:t,onMouseDown:m=>{var g;m.preventDefault(),o==null||o(m),(g=h.current)==null||g.focus()},onClick:m=>{var g;m.preventDefault(),i==null||i(m),(g=h.current)==null||g.focus()},...f,multiline:!0,disabled:l,__staticSelector:c||"PillsInput",withAria:!1},r))});ka.displayName="@mantine/core/PillsInput";ka.Field=ov;function V9({data:e,value:t}){const n=t.map(o=>o.trim().toLowerCase());return e.reduce((o,i)=>(Ta(i)?o.push({group:i.group,items:i.items.filter(s=>n.indexOf(s.value.toLowerCase().trim())===-1)}):n.indexOf(i.value.toLowerCase().trim())===-1&&o.push(i),o),[])}const W9={maxValues:1/0,withCheckIcon:!0,checkIconPosition:"left",hiddenInputValuesDivider:","},Of=Q((e,t)=>{const n=U("MultiSelect",W9,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,size:u,value:d,defaultValue:f,onChange:h,onKeyDown:m,variant:g,data:y,dropdownOpened:S,defaultDropdownOpened:v,onDropdownOpen:x,onDropdownClose:w,selectFirstOptionOnChange:b,onOptionSubmit:j,comboboxProps:E,filter:P,limit:T,withScrollArea:D,maxDropdownHeight:_,searchValue:O,defaultSearchValue:I,onSearchChange:$,readOnly:N,disabled:L,onFocus:M,onBlur:R,onPaste:k,radius:F,rightSection:q,rightSectionWidth:G,rightSectionPointerEvents:oe,rightSectionProps:xe,leftSection:me,leftSectionWidth:Ce,leftSectionPointerEvents:je,leftSectionProps:Be,inputContainer:Me,inputWrapperOrder:Ke,withAsterisk:St,labelProps:X,descriptionProps:ke,errorProps:tt,wrapperProps:Ne,description:Ve,label:Rt,error:ln,maxValues:br,searchable:en,nothingFoundMessage:uo,withCheckIcon:re,checkIconPosition:De,hidePickedOptions:qe,withErrorStyles:nt,name:Lt,form:Hr,id:or,clearable:Di,clearButtonProps:In,hiddenInputProps:qr,placeholder:Cr,hiddenInputValuesDivider:Ho,required:Ja,mod:eu,renderOption:ks,onRemove:ir,onClear:Ii,...dh}=n,Rs=kn(or),Za=rj(y),fo=oj(Za),_n=Tc({opened:S,defaultOpened:v,onDropdownOpen:x,onDropdownClose:()=>{w==null||w(),_n.resetSelectedOption()}}),{styleProps:A,rest:{type:z,autoComplete:H,...J}}=No(dh),[ee,Re]=gn({value:d,defaultValue:f,finalValue:[],onChange:h}),[we,ye]=gn({value:O,defaultValue:I,finalValue:"",onChange:$}),ge=de({name:"MultiSelect",classes:{},props:n,classNames:r,styles:s,unstyled:l}),{resolvedClassNames:Le,resolvedStyles:$t}=Jd({props:n,styles:s,classNames:r}),_e=Ae=>{m==null||m(Ae),Ae.key===" "&&!en&&(Ae.preventDefault(),_n.toggleDropdown()),Ae.key==="Backspace"&&we.length===0&&ee.length>0&&(ir==null||ir(ee[ee.length-1]),Re(ee.slice(0,ee.length-1)))},rt=ee.map((Ae,Gr)=>{var Ds,ho;return C.createElement(is,{key:`${Ae}-${Gr}`,withRemoveButton:!N&&!((Ds=fo[Ae])!=null&&Ds.disabled),onRemove:()=>{Re(ee.filter(Qr=>Ae!==Qr)),ir==null||ir(Ae)},unstyled:l,...ge("pill")},((ho=fo[Ae])==null?void 0:ho.label)||Ae)});p.useEffect(()=>{b&&_n.selectFirstOption()},[b,ee]);const Ft=Di&&ee.length>0&&!L&&!N&&C.createElement(Ee.ClearButton,{size:u,...In,onClear:()=>{Ii==null||Ii(),Re([]),ye("")}}),cn=V9({data:Za,value:ee});return C.createElement(C.Fragment,null,C.createElement(Ee,{store:_n,classNames:Le,styles:$t,unstyled:l,size:u,readOnly:N,__staticSelector:"MultiSelect",onOptionSubmit:Ae=>{j==null||j(Ae),ye(""),_n.updateSelectedOptionIndex("selected"),ee.includes(fo[Ae].value)?(Re(ee.filter(Gr=>Gr!==fo[Ae].value)),ir==null||ir(fo[Ae].value)):ee.length<br&&Re([...ee,fo[Ae].value])},...E},C.createElement(Ee.DropdownTarget,null,C.createElement(ka,{...A,__staticSelector:"MultiSelect",classNames:Le,styles:$t,unstyled:l,size:u,className:o,style:i,variant:g,disabled:L,radius:F,rightSection:q||Ft||C.createElement(Ee.Chevron,{size:u,error:ln,unstyled:l}),rightSectionPointerEvents:oe||(Ft?"all":"none"),rightSectionWidth:G,rightSectionProps:xe,leftSection:me,leftSectionWidth:Ce,leftSectionPointerEvents:je,leftSectionProps:Be,inputContainer:Me,inputWrapperOrder:Ke,withAsterisk:St,labelProps:X,descriptionProps:ke,errorProps:tt,wrapperProps:Ne,description:Ve,label:Rt,error:ln,multiline:!0,withErrorStyles:nt,__stylesApiProps:{...n,rightSectionPointerEvents:oe||(Ft?"all":"none"),multiline:!0},pointer:!en,onClick:()=>en?_n.openDropdown():_n.toggleDropdown(),"data-expanded":_n.dropdownOpened||void 0,id:Rs,required:Ja,mod:eu},C.createElement(is.Group,{disabled:L,unstyled:l,...ge("pillsList")},rt,C.createElement(Ee.EventsTarget,{autoComplete:H},C.createElement(ka.Field,{...J,ref:t,id:Rs,placeholder:Cr,type:!en&&!Cr?"hidden":"visible",...ge("inputField"),unstyled:l,onFocus:Ae=>{M==null||M(Ae),en&&_n.openDropdown()},onBlur:Ae=>{R==null||R(Ae),_n.closeDropdown(),ye("")},onKeyDown:_e,value:we,onChange:Ae=>{ye(Ae.currentTarget.value),en&&_n.openDropdown(),b&&_n.selectFirstOption()},disabled:L,readOnly:N||!en,pointer:!en}))))),C.createElement(f3,{data:qe?cn:Za,hidden:N||L,filter:P,search:we,limit:T,hiddenWhenEmpty:!en||!uo||qe&&cn.length===0&&we.trim().length===0,withScrollArea:D,maxDropdownHeight:_,filterOptions:en,value:ee,checkIconPosition:De,withCheckIcon:re,nothingFoundMessage:uo,unstyled:l,labelId:`${Rs}-label`,renderOption:ks})),C.createElement("input",{type:"hidden",name:Lt,value:ee.join(Ho),form:Hr,disabled:L,...qr}))});Of.classes={...wr.classes,...Ee.classes};Of.displayName="@mantine/core/MultiSelect";function H9(e){return"group"in e}function iv({data:e}){if(H9(e)){const o=e.items.map(i=>C.createElement(iv,{key:i.value,data:i}));return C.createElement("optgroup",{label:e.group},o)}const{value:t,label:n,...r}=e;return C.createElement("option",{key:e.value,value:e.value,...r},e.label)}iv.displayName="@mantine/core/NativeSelectOption";const q9={rightSectionPointerEvents:"none"},wt=Q((e,t)=>{const{data:n,children:r,size:o,error:i,rightSection:s,unstyled:l,...c}=U("NativeSelect",q9,e),u=rj(n).map((d,f)=>C.createElement(iv,{key:f,data:d}));return C.createElement(wr,{component:"select",ref:t,...c,__staticSelector:"NativeSelect",size:o,pointer:!0,error:i,unstyled:l,rightSection:s||C.createElement(bf,{size:o,error:i,unstyled:l})},r||u)});wt.classes=wr.classes;wt.displayName="@mantine/core/NativeSelect";var Ij={root:"m-a513464",icon:"m-a4ceffb",loader:"m-b0920b15",body:"m-a49ed24",title:"m-3feedf16",description:"m-3d733a3a",closeButton:"m-919a4d88"};const G9={withCloseButton:!0},Q9=(e,{radius:t,color:n})=>({root:{"--notification-radius":t===void 0?void 0:gt(t),"--notification-color":n?mt(n,e):void 0}}),sv=Q((e,t)=>{const n=U("Notification",G9,e),{className:r,color:o,radius:i,loading:s,withCloseButton:l,withBorder:c,title:u,icon:d,children:f,onClose:h,closeButtonProps:m,classNames:g,style:y,styles:S,unstyled:v,variant:x,vars:w,mod:b,...j}=n,E=de({name:"Notification",classes:Ij,props:n,className:r,style:y,classNames:g,styles:S,unstyled:v,vars:w,varsResolver:Q9});return C.createElement(W,{...E("root"),mod:[{"data-with-icon":!!d||s,"data-with-border":c},b],ref:t,variant:x,...j,role:"alert"},d&&!s&&C.createElement("div",{...E("icon")},d),s&&C.createElement(Vn,{size:28,color:o,...E("loader")}),C.createElement("div",{...E("body")},u&&C.createElement("div",{...E("title")},u),C.createElement(W,{...E("description"),mod:{"data-with-title":!!u}},f)),l&&C.createElement(vs,{iconSize:16,color:"gray",...m,unstyled:v,onClick:h,...E("closeButton")}))});sv.classes=Ij;sv.displayName="@mantine/core/Notification";const[K9,Mf]=Tn("Pagination.Root component was not found in tree");var Dc={root:"m-4addd315",control:"m-326d024a",dots:"m-4ad7767d"};const Y9={withPadding:!0},Ic=Q((e,t)=>{const n=U("PaginationControl",Y9,e),{classNames:r,className:o,style:i,styles:s,vars:l,active:c,disabled:u,withPadding:d,mod:f,...h}=n,m=Mf(),g=u||m.disabled;return C.createElement(Jn,{ref:t,disabled:g,mod:[{active:c,disabled:g,"with-padding":d},f],...m.getStyles("control",{className:o,style:i,classNames:r,styles:s,active:!g}),...h})});Ic.classes=Dc;Ic.displayName="@mantine/core/PaginationControl";function _c({style:e,children:t,path:n,...r}){return C.createElement("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},C.createElement("path",{d:n,fill:"currentColor"}))}const X9=e=>C.createElement(_c,{...e,path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"}),J9=e=>C.createElement(_c,{...e,path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"}),Z9=e=>C.createElement(_c,{...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"}),e5=e=>C.createElement(_c,{...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"}),t5=e=>C.createElement(_c,{...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"}),n5={icon:t5},Lf=Q((e,t)=>{const n=U("PaginationDots",n5,e),{classNames:r,className:o,style:i,styles:s,vars:l,icon:c,...u}=n,d=Mf(),f=c;return C.createElement(W,{ref:t,...d.getStyles("dots",{className:o,style:i,styles:s,classNames:r}),...u},C.createElement(f,{style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}}))});Lf.classes=Dc;Lf.displayName="@mantine/core/PaginationDots";function $f({icon:e,name:t,action:n,type:r}){const o={icon:e},i=p.forwardRef((s,l)=>{const{icon:c,...u}=U(t,o,s),d=c,f=Mf(),h=r==="next"?f.active===f.total:f.active===1;return C.createElement(Ic,{disabled:f.disabled||h,ref:l,onClick:f[n],withPadding:!1,...u},C.createElement(d,{className:"mantine-rotate-rtl",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}}))});return i.displayName=`@mantine/core/${t}`,i}const _j=$f({icon:X9,name:"PaginationNext",action:"onNext",type:"next"}),Aj=$f({icon:J9,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),Nj=$f({icon:Z9,name:"PaginationFirst",action:"onFirst",type:"previous"}),Oj=$f({icon:e5,name:"PaginationLast",action:"onLast",type:"next"});function av({dotsIcon:e}){const t=Mf(),n=t.range.map((r,o)=>{var i;return r==="dots"?C.createElement(Lf,{icon:e,key:o}):C.createElement(Ic,{key:o,active:r===t.active,"aria-current":r===t.active?"page":void 0,onClick:()=>t.onChange(r),disabled:t.disabled,...(i=t.getItemProps)==null?void 0:i.call(t,r)},r)});return C.createElement(C.Fragment,null,n)}av.displayName="@mantine/core/PaginationItems";const r5={siblings:1,boundaries:1},o5=(e,{size:t,radius:n,color:r,autoContrast:o})=>({root:{"--pagination-control-radius":n===void 0?void 0:gt(n),"--pagination-control-size":Pe(t,"pagination-control-size"),"--pagination-control-fz":Kt(t),"--pagination-active-bg":r?mt(r,e):void 0,"--pagination-active-color":gc(o,e)?fs({color:r,theme:e}):void 0}}),Ff=Q((e,t)=>{const n=U("PaginationRoot",r5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,total:u,value:d,defaultValue:f,onChange:h,disabled:m,siblings:g,boundaries:y,color:S,radius:v,onNextPage:x,onPreviousPage:w,onFirstPage:b,onLastPage:j,getItemProps:E,autoContrast:P,...T}=n,D=de({name:"Pagination",classes:Dc,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:o5}),{range:_,setPage:O,next:I,previous:$,active:N,first:L,last:M}=k2({page:d,initialPage:f,onChange:h,total:u,siblings:g,boundaries:y}),R=Gn(x,I),k=Gn(w,$),F=Gn(b,L),q=Gn(j,M);return C.createElement(K9,{value:{total:u,range:_,active:N,disabled:m,getItemProps:E,onChange:O,onNext:R,onPrevious:k,onFirst:F,onLast:q,getStyles:D}},C.createElement(W,{ref:t,...D("root"),...T}))});Ff.classes=Dc;Ff.displayName="@mantine/core/PaginationRoot";const i5={withControls:!0,siblings:1,boundaries:1,gap:8},Ur=Q((e,t)=>{const n=U("Pagination",i5,e),{withEdges:r,withControls:o,getControlProps:i,nextIcon:s,previousIcon:l,lastIcon:c,firstIcon:u,dotsIcon:d,total:f,gap:h,...m}=n;return f<=0?null:C.createElement(Ff,{ref:t,total:f,...m},C.createElement(Y,{gap:h},r&&C.createElement(Nj,{icon:u,...i==null?void 0:i("first")}),o&&C.createElement(Aj,{icon:l,...i==null?void 0:i("previous")}),C.createElement(av,{dotsIcon:d}),o&&C.createElement(_j,{icon:s,...i==null?void 0:i("next")}),r&&C.createElement(Oj,{icon:c,...i==null?void 0:i("last")})))});Ur.classes=Dc;Ur.displayName="@mantine/core/Pagination";Ur.Root=Ff;Ur.Control=Ic;Ur.Dots=Lf;Ur.First=Nj;Ur.Last=Oj;Ur.Next=_j;Ur.Previous=Aj;Ur.Items=av;const s5=({reveal:e})=>C.createElement("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)"}},C.createElement("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 xm={root:"m-f61ca620",input:"m-ccf8da4c",innerInput:"m-f2d85dd2",visibilityToggle:"m-b1072d44"};const a5={visibilityToggleIcon:s5},l5=(e,{size:t})=>({root:{"--psi-icon-size":Pe(t,"psi-icon-size"),"--psi-button-size":Pe(t,"psi-button-size")}}),Nr=Q((e,t)=>{const n=U("PasswordInput",a5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,required:u,error:d,leftSection:f,disabled:h,id:m,variant:g,inputContainer:y,description:S,label:v,size:x,errorProps:w,descriptionProps:b,labelProps:j,withAsterisk:E,inputWrapperOrder:P,wrapperProps:T,radius:D,rightSection:_,rightSectionWidth:O,rightSectionPointerEvents:I,leftSectionWidth:$,visible:N,defaultVisible:L,onVisibilityChange:M,visibilityToggleIcon:R,visibilityToggleButtonProps:k,rightSectionProps:F,leftSectionProps:q,leftSectionPointerEvents:G,mod:oe,...xe}=n,me=kn(m),[Ce,je]=gn({value:N,defaultValue:L,finalValue:!1,onChange:M}),Be=()=>je(!Ce),Me=de({name:"PasswordInput",classes:xm,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:l5}),{resolvedClassNames:Ke,resolvedStyles:St}=Jd({classNames:r,styles:s,props:n}),{styleProps:X,rest:ke}=No(xe),tt=R,Ne=C.createElement(qt,{...Me("visibilityToggle"),disabled:h,radius:D,"aria-hidden":!k,tabIndex:-1,...k,variant:"subtle",color:"gray",unstyled:l,onMouseDown:Ve=>{var Rt;Ve.preventDefault(),(Rt=k==null?void 0:k.onMouseDown)==null||Rt.call(k,Ve),Be()},onKeyDown:Ve=>{var Rt;(Rt=k==null?void 0:k.onKeyDown)==null||Rt.call(k,Ve),Ve.key===" "&&(Ve.preventDefault(),Be())}},C.createElement(tt,{reveal:Ce}));return C.createElement(Ct.Wrapper,{required:u,id:me,label:v,error:d,description:S,size:x,classNames:Ke,styles:St,__staticSelector:"PasswordInput",errorProps:w,descriptionProps:b,unstyled:l,withAsterisk:E,inputWrapperOrder:P,inputContainer:y,variant:g,labelProps:{...j,htmlFor:me},mod:oe,...Me("root"),...X,...T},C.createElement(Ct,{component:"div",error:d,leftSection:f,size:x,classNames:{...Ke,input:et(xm.input,Ke.input)},styles:St,radius:D,disabled:h,__staticSelector:"PasswordInput",rightSectionWidth:O,rightSection:_??Ne,variant:g,unstyled:l,leftSectionWidth:$,rightSectionPointerEvents:I||"all",rightSectionProps:F,leftSectionProps:q,leftSectionPointerEvents:G,withAria:!1},C.createElement("input",{required:u,"data-invalid":!!d||void 0,"data-with-left-section":!!f||void 0,...Me("innerInput"),disabled:h,id:me,ref:t,...ke,autoComplete:ke.autoComplete||"off",type:Ce?"text":"password"})))});Nr.classes={...wr.classes,...xm};Nr.displayName="@mantine/core/PasswordInput";const[c5,u5]=mc(),d5={},lv=Q((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:i,wrapperProps:s,children:l,name:c,readOnly:u,...d}=U("RadioGroup",d5,e),f=kn(c),[h,m]=gn({value:n,defaultValue:r,finalValue:"",onChange:o}),g=y=>!u&&m(y.currentTarget.value);return C.createElement(c5,{value:{value:h,onChange:g,size:i,name:f}},C.createElement(Ct.Wrapper,{size:i,ref:t,...s,...d,labelElement:"div",__staticSelector:"RadioGroup"},C.createElement(Fy,{role:"radiogroup"},l)))});lv.classes=Ct.Wrapper.classes;lv.displayName="@mantine/core/RadioGroup";function f5({size:e,style:t,...n}){return C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:B(e),height:B(e),...t},"aria-hidden":!0,...n},C.createElement("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"}))}var Mj={root:"m-f3f1af94",inner:"m-89c4f5e4",icon:"m-f3ed6b2b",radio:"m-8a3dbb89","radio--outline":"m-1bfe9d39"};const h5={labelPosition:"right"},p5=(e,{size:t,radius:n,color:r,iconColor:o,variant:i,autoContrast:s})=>{const l=ao({color:r||e.primaryColor,theme:e}),c=l.isThemeColor&&l.shade===void 0?`var(--mantine-color-${l.color}-outline)`:l.color;return{root:{"--radio-size":Pe(t,"radio-size"),"--radio-radius":n===void 0?void 0:gt(n),"--radio-color":i==="outline"?c:mt(r,e),"--radio-icon-color":o?mt(o,e):gc(s,e)?fs({color:r,theme:e}):void 0,"--radio-icon-size":Pe(t,"radio-icon-size")}}},oc=Q((e,t)=>{const n=U("Radio",h5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,id:u,size:d,label:f,labelPosition:h,description:m,error:g,radius:y,color:S,variant:v,disabled:x,wrapperProps:w,icon:b=f5,rootRef:j,iconColor:E,onChange:P,mod:T,...D}=n,_=de({name:"Radio",classes:Mj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:p5}),O=u5(),I=(O==null?void 0:O.size)??d,$=n.size?d:I,{styleProps:N,rest:L}=No(D),M=kn(u),R=O?{checked:O.value===L.value,name:L.name??O.name,onChange:k=>{O.onChange(k),P==null||P(k)}}:{};return C.createElement(Cf,{..._("root"),__staticSelector:"Radio",__stylesApiProps:n,id:M,size:$,labelPosition:h,label:f,description:m,error:g,disabled:x,classNames:r,styles:s,unstyled:l,"data-checked":R.checked||void 0,variant:v,ref:j,mod:T,...N,...w},C.createElement(W,{..._("inner"),mod:{"label-position":h}},C.createElement(W,{..._("radio",{focusable:!0,variant:v}),onChange:P,...L,...R,component:"input",mod:{error:!!g},ref:t,id:M,disabled:x,type:"radio"}),C.createElement(b,{..._("icon"),"aria-hidden":!0})))});oc.classes=Mj;oc.displayName="@mantine/core/Radio";oc.Group=lv;const m5={duration:100,transition:"fade"};function g5(e,t){return{...m5,...t,...e}}function y5({offset:e,position:t}){const[n,r]=p.useState(!1),o=p.useRef(),{x:i,y:s,elements:l,refs:c,update:u,placement:d}=vy({placement:t,middleware:[py({crossAxis:!0,padding:5,rootBoundary:"document"})]}),f=d.includes("right")?e:t.includes("left")?e*-1:0,h=d.includes("bottom")?e:t.includes("top")?e*-1:0,m=p.useCallback(({clientX:g,clientY:y})=>{c.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:g,y,left:g+f,top:y+h,right:g,bottom:y}}})},[l.reference]);return p.useEffect(()=>{if(c.floating.current){const g=o.current;g.addEventListener("mousemove",m);const y=wo(c.floating.current);return y.forEach(S=>{S.addEventListener("scroll",u)}),()=>{g.removeEventListener("mousemove",m),y.forEach(S=>{S.removeEventListener("scroll",u)})}}},[l.reference,c.floating.current,u,m,n]),{handleMouseMove:m,x:i,y:s,opened:n,setOpened:r,boundaryRef:o,floating:c.setFloating}}var zf={tooltip:"m-1b3c8819",arrow:"m-f898399f"};const v5={refProp:"ref",withinPortal:!0,offset:10,position:"right",zIndex:zr("popover")},x5=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:gt(t),"--tooltip-bg":n?mt(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),cv=Q((e,t)=>{const n=U("TooltipFloating",v5,e),{children:r,refProp:o,withinPortal:i,style:s,className:l,classNames:c,styles:u,unstyled:d,radius:f,color:h,label:m,offset:g,position:y,multiline:S,zIndex:v,disabled:x,variant:w,vars:b,portalProps:j,...E}=n,P=kt(),T=de({name:"TooltipFloating",props:n,classes:zf,className:l,style:s,classNames:c,styles:u,unstyled:d,rootSelector:"tooltip",vars:b,varsResolver:x5}),{handleMouseMove:D,x:_,y:O,opened:I,boundaryRef:$,floating:N,setOpened:L}=y5({offset:g,position:y});if(!Ao(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 M=Zt($,r.ref,t),R=F=>{var q,G;(G=(q=r.props).onMouseEnter)==null||G.call(q,F),D(F),L(!0)},k=F=>{var q,G;(G=(q=r.props).onMouseLeave)==null||G.call(q,F),L(!1)};return C.createElement(C.Fragment,null,C.createElement(ys,{...j,withinPortal:i},C.createElement(W,{...E,...T("tooltip",{style:{...KS(s,P),zIndex:v,display:!x&&I?"block":"none",top:(O&&Math.round(O))??"",left:(_&&Math.round(_))??""}}),variant:w,ref:N,mod:{multiline:S}},m)),p.cloneElement(r,{...r.props,[o]:M,onMouseEnter:R,onMouseLeave:k}))});cv.classes=zf;cv.displayName="@mantine/core/TooltipFloating";const Lj=p.createContext(!1),w5=Lj.Provider,S5=()=>p.useContext(Lj),b5={openDelay:0,closeDelay:0};function $j(e){const{openDelay:t,closeDelay:n,children:r}=U("TooltipGroup",b5,e);return C.createElement(w5,{value:!0},C.createElement(l4,{delay:{open:t,close:n}},r))}$j.displayName="@mantine/core/TooltipGroup";function C5(e){var E,P,T;const[t,n]=p.useState(!1),o=typeof e.opened=="boolean"?e.opened:t,i=S5(),s=kn(),{delay:l,currentId:c,setCurrentId:u}=NE(),d=p.useCallback(D=>{n(D),D&&u(s)},[u,s]),{x:f,y:h,context:m,refs:g,update:y,placement:S,middlewareData:{arrow:{x:v,y:x}={}}}=vy({strategy:e.strategy,placement:e.position,open:o,onOpenChange:d,middleware:[SE(e.offset),py({padding:8}),kE(),DE({element:e.arrowRef,padding:e.arrowOffset}),...e.inline?[RE()]:[]]}),{getReferenceProps:w,getFloatingProps:b}=p4([a4(m,{enabled:(E=e.events)==null?void 0:E.hover,delay:i?l:{open:e.openDelay,close:e.closeDelay},mouseOnly:!((P=e.events)!=null&&P.touch)}),h4(m,{enabled:(T=e.events)==null?void 0:T.focus,visibleOnly:!0}),g4(m,{role:"tooltip"}),f4(m,{enabled:typeof e.opened>"u"}),c4(m,{id:s})]);BE({opened:o,position:e.position,positionDependencies:e.positionDependencies,floating:{refs:g,update:y}}),Co(()=>{var D;(D=e.onPositionChange)==null||D.call(e,S)},[S]);const j=o&&c&&c!==s;return{x:f,y:h,arrowX:v,arrowY:x,reference:g.setReference,floating:g.setFloating,getFloatingProps:b,getReferenceProps:w,isGroupPhase:j,opened:o,placement:S}}const _1={position:"top",refProp:"ref",withinPortal:!0,inline:!1,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:zr("popover"),positionDependencies:[]},E5=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:gt(t),"--tooltip-bg":n?mt(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),qa=Q((e,t)=>{const n=U("Tooltip",_1,e),{children:r,position:o,refProp:i,label:s,openDelay:l,closeDelay:c,onPositionChange:u,opened:d,withinPortal:f,radius:h,color:m,classNames:g,styles:y,unstyled:S,style:v,className:x,withArrow:w,arrowSize:b,arrowOffset:j,arrowRadius:E,arrowPosition:P,offset:T,transitionProps:D,multiline:_,events:O,zIndex:I,disabled:$,positionDependencies:N,onClick:L,onMouseEnter:M,onMouseLeave:R,inline:k,variant:F,keepMounted:q,vars:G,portalProps:oe,mod:xe,floatingStrategy:me,...Ce}=U("Tooltip",_1,n),{dir:je}=hs(),Be=p.useRef(null),Me=C5({position:OE(je,o),closeDelay:c,openDelay:l,onPositionChange:u,opened:d,events:O,arrowRef:Be,arrowOffset:j,offset:typeof T=="number"?T+(w?b/2:0):T,positionDependencies:[...N,r],inline:k,strategy:me}),Ke=de({name:"Tooltip",props:n,classes:zf,className:x,style:v,classNames:g,styles:y,unstyled:S,rootSelector:"tooltip",vars:G,varsResolver:E5});if(!Ao(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 St=Zt(Me.reference,r.ref,t),X=g5(D,{duration:100,transition:"fade"});return C.createElement(C.Fragment,null,C.createElement(ys,{...oe,withinPortal:f},C.createElement(Lo,{...X,keepMounted:q,mounted:!$&&!!Me.opened,duration:Me.isGroupPhase?10:X.duration},ke=>C.createElement(W,{...Ce,variant:F,mod:[{multiline:_},xe],...Me.getFloatingProps({ref:Me.floating,className:Ke("tooltip").className,style:{...Ke("tooltip").style,...ke,zIndex:I,top:Me.y??0,left:Me.x??0}})},s,C.createElement(xy,{ref:Be,arrowX:Me.arrowX,arrowY:Me.arrowY,visible:w,position:Me.placement,arrowSize:b,arrowOffset:j,arrowRadius:E,arrowPosition:P,...Ke("arrow")})))),p.cloneElement(r,Me.getReferenceProps({onClick:L,onMouseEnter:M,onMouseLeave:R,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,[i]:St,className:et(x,r.props.className),...r.props})))});qa.classes=zf;qa.displayName="@mantine/core/Tooltip";qa.Floating=cv;qa.Group=$j;function j5({size:e,thickness:t,sum:n,value:r,root:o,offset:i}){const s=(e*.9-t*2)/2,l=Math.PI*s*2/100,c=o||r===void 0?`${(100-n)*l}, ${n*l}`:`${r*l}, ${(100-r)*l}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:s||0,transform:o?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:c,strokeDashoffset:o?0:i||0}}function Fj({size:e,value:t,offset:n,sum:r,thickness:o,root:i,color:s,lineRoundCaps:l,tooltip:c,getStyles:u,display:d,...f}){const h=kt();return C.createElement(qa.Floating,{disabled:!c,label:c},C.createElement(W,{component:"circle",...f,...u("curve"),__vars:{"--curve-color":s?mt(s,h):void 0},fill:"none",strokeLinecap:l?"round":"butt",...j5({sum:r,size:e,thickness:o,value:t,offset:n,root:i})}))}Fj.displayName="@mantine/core/Curve";function P5({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:o}){const i=n.reduce((d,f)=>d+f.value,0),s=Math.PI*((e*.9-t*2)/2)*2;let l=s;const c=[],u=[];for(let d=0;d<n.length;d+=1)c.push({sum:i,offset:l,data:n[d],root:!1}),l-=n[d].value/100*s;if(c.push({sum:i,offset:l,data:{color:o},root:!0}),u.push({...c[c.length-1],lineRoundCaps:!1}),c.length>2){u.push({...c[0],lineRoundCaps:r}),u.push({...c[c.length-2],lineRoundCaps:r});for(let d=1;d<=c.length-3;d+=1)u.push({...c[d],lineRoundCaps:!1})}else u.push({...c[0],lineRoundCaps:r});return u}var zj={root:"m-b32e4812",svg:"m-d43b5134",curve:"m-b1ca1fbf",label:"m-b23f9dc4"};function T5(e,t){return Math.min(e||12,(t||120)/4)}const k5={size:120,thickness:12},R5=(e,{size:t,thickness:n})=>({root:{"--rp-size":B(t),"--rp-label-offset":B(n*2)}}),Bf=Q((e,t)=>{const n=U("RingProgress",k5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,label:u,sections:d,size:f,thickness:h,roundCaps:m,rootColor:g,...y}=n,S=de({name:"RingProgress",classes:zj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:R5}),v=T5(h,f),x=P5({size:f,thickness:v,sections:d,renderRoundedLineCaps:m,rootColor:g}).map(({data:w,sum:b,root:j,lineRoundCaps:E,offset:P},T)=>C.createElement(Fj,{...w,key:T,size:f,thickness:v,sum:b,offset:P,color:w==null?void 0:w.color,root:j,lineRoundCaps:E,getStyles:S}));return C.createElement(W,{...S("root"),size:f,ref:t,...y},C.createElement("svg",{...S("svg")},x),u&&C.createElement("div",{...S("label")},u))});Bf.classes=zj;Bf.displayName="@mantine/core/RingProgress";function Pu(e,t){const n=parseFloat(e.replace("px",""));return Number.isNaN(n)?t:n}function D5(e,t){const n=window.getComputedStyle(e);return{top:Pu(n.getPropertyValue("padding-top"),t),right:Pu(n.getPropertyValue("padding-right"),t),bottom:Pu(n.getPropertyValue("padding-bottom"),t),left:Pu(n.getPropertyValue("padding-left"),t)}}var Bj={root:"m-cf365364",indicator:"m-9e182ccd",label:"m-1738fcb2",input:"m-1714d588",control:"m-69686b9b"};const I5=4,_5={withItemsBorders:!0},A5=(e,{radius:t,color:n,transitionDuration:r,size:o,transitionTimingFunction:i})=>({root:{"--sc-radius":t===void 0?void 0:gt(t),"--sc-color":n?mt(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":i,"--sc-padding":Pe(o,"sc-padding"),"--sc-font-size":Kt(o)}}),uv=Q((e,t)=>{var Ke,St;const n=U("SegmentedControl",_5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,data:u,value:d,defaultValue:f,onChange:h,size:m,name:g,disabled:y,readOnly:S,fullWidth:v,orientation:x,radius:w,color:b,transitionDuration:j,transitionTimingFunction:E,variant:P,autoContrast:T,withItemsBorders:D,mod:_,...O}=n,I=de({name:"SegmentedControl",props:n,classes:Bj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:A5}),{dir:$}=hs(),N=kt(),L=u.map(X=>typeof X=="string"?{label:X,value:X}:X),[M,R]=gn({value:d,defaultValue:f,finalValue:Array.isArray(u)?((Ke=L.find(X=>!X.disabled))==null?void 0:Ke.value)??((St=u[0])==null?void 0:St.value)??null:null,onChange:h}),[k,F]=p.useState({width:0,height:0,translate:[0,0]}),q=kn(g),G=p.useRef({}),oe=p.useRef(null),[xe,me]=p.useState(!1),[Ce,je]=D2();p.useEffect(()=>{if(Ce.current){const X=G.current[M];if(X){const ke=D5(oe.current,I5),tt=X.getBoundingClientRect(),Ne=X.offsetWidth/tt.width,Ve=X.clientWidth*Ne||0,Rt=X.clientHeight*Ne||0,ln=je.width-X.parentElement.offsetLeft+($==="rtl"?ke.left:ke.right)-Ve,br=X.parentElement.offsetLeft-($==="rtl"?ke.right:ke.left);F({width:Ve,height:Rt,translate:[$==="rtl"?ln*-1:br,X.parentElement.offsetTop-ke.top]})}else F({width:0,height:0,translate:[0,0]})}},[M,je,$]),_2(()=>{BS()!=="test"&&me(!0)},20,{autoInvoke:!0});const Be=L.map(X=>C.createElement(W,{...I("control"),mod:{active:M===X.value,orientation:x},key:X.value},C.createElement("input",{...I("input"),disabled:y||X.disabled,type:"radio",name:q,value:X.value,id:`${q}-${X.value}`,checked:M===X.value,onChange:()=>!S&&R(X.value),"data-focus-ring":N.focusRing}),C.createElement(W,{component:"label",...I("label"),mod:{active:M===X.value&&!(y||X.disabled),disabled:y||X.disabled,"read-only":S},htmlFor:`${q}-${X.value}`,ref:ke=>{G.current[X.value]=ke},__vars:{"--sc-label-color":b!==void 0?fs({color:b,theme:N,autoContrast:T}):void 0}},X.label))),Me=Zt(Ce,oe,t);return u.length===0?null:C.createElement(W,{...I("root"),variant:P,size:m,ref:Me,mod:[{"full-width":v,orientation:x,initialization:!xe,"with-items-borders":D},_],...O,role:"radiogroup"},typeof M=="string"&&C.createElement(W,{component:"span",...I("indicator"),__vars:{"--sc-indicator-width":`${k.width}px`,"--sc-indicator-height":`${k.height}px`,"--sc-indicator-transform":`translate(${k.translate[0]}px, ${k.translate[1]}px)`}}),Be)});uv.classes=Bj;uv.displayName="@mantine/core/SegmentedControl";function N5({spacing:e,verticalSpacing:t,cols:n,selector:r}){var d;const o=kt(),i=t===void 0?e:t,s=ds({"--sg-spacing-x":rn(ni(e)),"--sg-spacing-y":rn(ni(i)),"--sg-cols":(d=ni(n))==null?void 0:d.toString()}),l=pt(o.breakpoints).reduce((f,h)=>(f[h]||(f[h]={}),typeof e=="object"&&e[h]!==void 0&&(f[h]["--sg-spacing-x"]=rn(e[h])),typeof i=="object"&&i[h]!==void 0&&(f[h]["--sg-spacing-y"]=rn(i[h])),typeof n=="object"&&n[h]!==void 0&&(f[h]["--sg-cols"]=n[h]),f),{}),u=Ll(pt(l),o).filter(f=>pt(l[f.value]).length>0).map(f=>({query:`(min-width: ${o.breakpoints[f.value]})`,styles:l[f.value]}));return C.createElement(La,{styles:s,media:u,selector:r})}var Uj={root:"m-2415a157"};const O5={cols:1,spacing:"md"},dv=Q((e,t)=>{const n=U("SimpleGrid",O5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,cols:u,verticalSpacing:d,spacing:f,...h}=n,m=de({name:"SimpleGrid",classes:Uj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c}),g=yc();return C.createElement(C.Fragment,null,C.createElement(N5,{...n,selector:`.${g}`}),C.createElement(W,{ref:t,...m("root",{className:g}),...h}))});dv.classes=Uj;dv.displayName="@mantine/core/SimpleGrid";const M5={},Uf=Q((e,t)=>{const{w:n,h:r,miw:o,mih:i,...s}=U("Space",M5,e);return C.createElement(W,{ref:t,...s,w:n,miw:o??n,h:r,mih:i??r})});Uf.displayName="@mantine/core/Space";var Vj={root:"m-6d731127"};const L5={gap:"md",align:"stretch",justify:"flex-start"},$5=(e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":rn(t),"--stack-align":n,"--stack-justify":r}}),be=Q((e,t)=>{const n=U("Stack",L5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,align:u,justify:d,gap:f,variant:h,...m}=n,g=de({name:"Stack",props:n,classes:Vj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:$5});return C.createElement(W,{ref:t,...g("root"),variant:h,...m})});be.classes=Vj;be.displayName="@mantine/core/Stack";const[F5,z5]=Tn("Stepper component was not found in tree"),Id=()=>null;Id.displayName="@mantine/core/StepperCompleted";var fv={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 Tu=(e,t)=>typeof e=="function"?C.createElement(e,{step:t||0}):e,B5={withIcon:!0,allowStepClick:!0,iconPosition:"left"},hv=Q((e,t)=>{const{classNames:n,className:r,style:o,styles:i,vars:s,step:l,state:c,color:u,icon:d,completedIcon:f,progressIcon:h,label:m,description:g,withIcon:y,iconSize:S,loading:v,allowStepClick:x,allowStepSelect:w,iconPosition:b,orientation:j,mod:E,...P}=U("StepperStep",B5,e),T=z5(),D=kt(),_={classNames:n,styles:i},O=c==="stepCompleted"?null:c==="stepProgress"?h:d,I={"data-progress":c==="stepProgress"||void 0,"data-completed":c==="stepCompleted"||void 0};return C.createElement(Jn,{...T.getStyles("step",{className:r,style:o,variant:T.orientation,..._}),mod:[{"icon-position":b||T.iconPosition,"allow-click":x},E],ref:t,...I,...P,__vars:{"--step-color":u?mt(u,D):void 0},tabIndex:x?0:-1},y&&C.createElement("span",{...T.getStyles("stepWrapper",_)},C.createElement("span",{...T.getStyles("stepIcon",_),...I},C.createElement(Lo,{mounted:c==="stepCompleted",transition:"pop",duration:200},$=>C.createElement("span",{...T.getStyles("stepCompletedIcon",{style:$,..._})},v?C.createElement(Vn,{color:"var(--mantine-color-white)",size:"calc(var(--stepper-icon-size) / 2)",...T.getStyles("stepLoader",_)}):Tu(f,l)||C.createElement(Ef,{size:"60%"}))),c!=="stepCompleted"?v?C.createElement(Vn,{...T.getStyles("stepLoader",_),size:"calc(var(--stepper-icon-size) / 2)",color:u}):Tu(O||d,l):null),j==="vertical"&&C.createElement("span",{...T.getStyles("verticalSeparator",_),"data-active":c==="stepCompleted"||void 0})),(m||g)&&C.createElement("span",{...T.getStyles("stepBody",_),"data-orientation":T.orientation,"data-icon-position":b||T.iconPosition},m&&C.createElement("span",{...T.getStyles("stepLabel",_)},Tu(m,l)),g&&C.createElement("span",{...T.getStyles("stepDescription",_)},Tu(g,l))))});hv.classes=fv;hv.displayName="@mantine/core/StepperStep";const U5={orientation:"horizontal",iconPosition:"left",allowNextStepsSelect:!0,wrap:!0},V5=(e,{color:t,iconSize:n,size:r,contentPadding:o,radius:i,autoContrast:s})=>({root:{"--stepper-color":t?mt(t,e):void 0,"--stepper-icon-color":gc(s,e)?fs({color:t,theme:e}):void 0,"--stepper-icon-size":n===void 0?Pe(r,"stepper-icon-size"):B(n),"--stepper-content-padding":rn(o),"--stepper-radius":i===void 0?void 0:gt(i),"--stepper-fz":Kt(r),"--stepper-spacing":rn(r)}}),Ra=Q((e,t)=>{var R,k,F;const n=U("Stepper",U5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,children:u,onStepClick:d,active:f,icon:h,completedIcon:m,progressIcon:g,color:y,iconSize:S,contentPadding:v,orientation:x,iconPosition:w,size:b,radius:j,allowNextStepsSelect:E,wrap:P,...T}=n,D=de({name:"Stepper",classes:fv,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:V5}),_=p.Children.toArray(u),O=_.filter(q=>q.type!==Id),I=_.find(q=>q.type===Id),$=O.reduce((q,G,oe)=>{const xe=f===oe?"stepProgress":f>oe?"stepCompleted":"stepInactive",Ce=typeof d!="function"?!1:typeof G.props.allowStepSelect=="boolean"?G.props.allowStepSelect:xe==="stepCompleted"||E;return q.push(p.cloneElement(G,{icon:G.props.icon||h||oe+1,key:oe,step:oe,state:xe,onClick:()=>Ce&&(d==null?void 0:d(oe)),allowStepClick:Ce,completedIcon:G.props.completedIcon||m,progressIcon:G.props.progressIcon||g,color:G.props.color||y,iconSize:S,radius:j,iconPosition:G.props.iconPosition||w,orientation:x,unstyled:l})),x==="horizontal"&&oe!==O.length-1&&q.push(C.createElement("div",{...D("separator"),"data-active":oe<f||void 0,"data-orientation":x,key:`separator-${oe}`})),q},[]),N=(k=(R=O[f])==null?void 0:R.props)==null?void 0:k.children,L=(F=I==null?void 0:I.props)==null?void 0:F.children,M=f>O.length-1?L:N;return C.createElement(F5,{value:{getStyles:D,orientation:x,iconPosition:w}},C.createElement(W,{...D("root"),ref:t,size:b,...T},C.createElement(W,{...D("steps"),mod:{orientation:x,"icon-position":w,wrap:P&&x!=="vertical"}},$),M&&C.createElement("div",{...D("content")},M)))});Ra.classes=fv;Ra.displayName="@mantine/core/Stepper";Ra.Completed=Id;Ra.Step=hv;const Wj=p.createContext(null),W5=Wj.Provider,H5=()=>p.useContext(Wj),q5={},pv=Q((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:i,wrapperProps:s,children:l,readOnly:c,...u}=U("SwitchGroup",q5,e),[d,f]=gn({value:n,defaultValue:r,finalValue:[],onChange:o}),h=m=>{const g=m.currentTarget.value;!c&&f(d.includes(g)?d.filter(y=>y!==g):[...d,g])};return C.createElement(W5,{value:{value:d,onChange:h,size:i}},C.createElement(Ct.Wrapper,{size:i,ref:t,...s,...u,labelElement:"div",__staticSelector:"SwitchGroup"},C.createElement(Fy,{role:"group"},l)))});pv.classes=Ct.Wrapper.classes;pv.displayName="@mantine/core/SwitchGroup";var Hj={root:"m-5f93f3bb",input:"m-926b4011",track:"m-9307d992",thumb:"m-93039a1d",trackLabel:"m-8277e082"};const G5={labelPosition:"right"},Q5=(e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:gt(t),"--switch-height":Pe(r,"switch-height"),"--switch-width":Pe(r,"switch-width"),"--switch-thumb-size":Pe(r,"switch-thumb-size"),"--switch-label-font-size":Pe(r,"switch-label-font-size"),"--switch-track-label-padding":Pe(r,"switch-track-label-padding"),"--switch-color":n?mt(n,e):void 0}}),Ac=Q((e,t)=>{const n=U("Switch",G5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,color:u,label:d,offLabel:f,onLabel:h,id:m,size:g,radius:y,wrapperProps:S,children:v,thumbIcon:x,checked:w,defaultChecked:b,onChange:j,labelPosition:E,description:P,error:T,disabled:D,variant:_,rootRef:O,mod:I,...$}=n,N=H5(),L=g||(N==null?void 0:N.size),M=de({name:"Switch",props:n,classes:Hj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:Q5}),{styleProps:R,rest:k}=No($),F=kn(m),q=N?{checked:N.value.includes(k.value),onChange:N.onChange}:{},[G,oe]=gn({value:q.checked??w,defaultValue:b,finalValue:!1});return C.createElement(Cf,{...M("root"),__staticSelector:"Switch",__stylesApiProps:n,id:F,size:L,labelPosition:E,label:d,description:P,error:T,disabled:D,bodyElement:"label",labelElement:"span",classNames:r,styles:s,unstyled:l,"data-checked":q.checked||void 0,variant:_,ref:O,mod:I,...R,...S},C.createElement("input",{...k,disabled:D,checked:G,onChange:xe=>{var me;N?(me=q.onChange)==null||me.call(q,xe):j==null||j(xe),oe(xe.currentTarget.checked)},id:F,ref:t,type:"checkbox",role:"switch",...M("input")}),C.createElement(W,{"aria-hidden":"true",mod:{error:T,"label-position":E},...M("track")},C.createElement(W,{component:"span",mod:"reduce-motion",...M("thumb")},x),C.createElement("span",{...M("trackLabel")},G?h:f)))});Ac.classes={...Hj,...uj};Ac.displayName="@mantine/core/Switch";Ac.Group=pv;const[K5,Y5]=Tn("Table component was not found in the tree");var Nc={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 X5(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 Ss(e,t){const n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=Q((o,i)=>{const s=U(n,{},o),{classNames:l,className:c,style:u,styles:d,...f}=s,h=Y5();return C.createElement(W,{component:e,ref:i,...X5(h,t),...h.getStyles(e,{className:c,classNames:l,style:u,styles:d,props:s}),...f})});return r.displayName=`@mantine/core/${n}`,r.classes=Nc,r}const wm=Ss("th",{columnBorder:!0}),qj=Ss("td",{columnBorder:!0}),Ku=Ss("tr",{rowBorder:!0,striped:!0,highlightOnHover:!0}),Gj=Ss("thead",{stickyHeader:!0}),Qj=Ss("tbody"),Kj=Ss("tfoot"),Yj=Ss("caption",{captionSide:!0});function mv({data:e}){return C.createElement(C.Fragment,null,e.caption&&C.createElement(Yj,null,e.caption),e.head&&C.createElement(Gj,null,C.createElement(Ku,null,e.head.map((t,n)=>C.createElement(wm,{key:n},t)))),e.body&&C.createElement(Qj,null,e.body.map((t,n)=>C.createElement(Ku,{key:n},t.map((r,o)=>C.createElement(qj,{key:o},r))))),e.foot&&C.createElement(Kj,null,C.createElement(Ku,null,e.foot.map((t,n)=>C.createElement(wm,{key:n},t)))))}mv.displayName="@mantine/core/TableDataRenderer";const J5={type:"scrollarea"},Z5=(e,{minWidth:t,type:n})=>({scrollContainer:{"--table-min-width":B(t),"--table-overflow":n==="native"?"auto":void 0}}),gv=Q((e,t)=>{const n=U("TableScrollContainer",J5,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,children:u,minWidth:d,type:f,...h}=n,m=de({name:"TableScrollContainer",classes:Nc,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:Z5,rootSelector:"scrollContainer"});return C.createElement(W,{component:f==="scrollarea"?vr:"div",...f==="scrollarea"?{offsetScrollbars:"x"}:{},ref:t,...m("scrollContainer"),...h},C.createElement("div",{...m("scrollContainerInner")},u))});gv.classes=Nc;gv.displayName="@mantine/core/TableScrollContainer";const eO={withRowBorders:!0,verticalSpacing:7},tO=(e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:o,borderColor:i,stripedColor:s,highlightOnHoverColor:l,striped:c,highlightOnHover:u,stickyHeaderOffset:d,stickyHeader:f})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":rn(r),"--table-vertical-spacing":rn(o),"--table-border-color":i?mt(i,e):void 0,"--table-striped-color":c&&s?mt(s,e):void 0,"--table-highlight-on-hover-color":u&&l?mt(l,e):void 0,"--table-sticky-header-offset":f?B(d):void 0}}),le=Q((e,t)=>{const n=U("Table",eO,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,horizontalSpacing:u,verticalSpacing:d,captionSide:f,stripedColor:h,highlightOnHoverColor:m,striped:g,highlightOnHover:y,withColumnBorders:S,withRowBorders:v,withTableBorder:x,borderColor:w,layout:b,variant:j,data:E,children:P,stickyHeader:T,stickyHeaderOffset:D,mod:_,...O}=n,I=de({name:"Table",props:n,className:o,style:i,classes:Nc,classNames:r,styles:s,unstyled:l,rootSelector:"table",vars:c,varsResolver:tO});return C.createElement(K5,{value:{getStyles:I,stickyHeader:T,striped:g===!0?"odd":g||void 0,highlightOnHover:y,withColumnBorders:S,withRowBorders:v,captionSide:f||"bottom"}},C.createElement(W,{component:"table",variant:j,ref:t,mod:[{"data-with-table-border":x},_],...I("table"),...O},P||!!E&&C.createElement(mv,{data:E})))});le.classes=Nc;le.displayName="@mantine/core/Table";le.Td=qj;le.Th=wm;le.Tr=Ku;le.Thead=Gj;le.Tbody=Qj;le.Tfoot=Kj;le.Caption=Yj;le.ScrollContainer=gv;le.DataRenderer=mv;const[nO,yv]=Tn("Tabs component was not found in the tree");var Oc={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 rO={},vv=Q((e,t)=>{const n=U("TabsList",rO,e),{children:r,className:o,grow:i,justify:s,classNames:l,styles:c,style:u,mod:d,...f}=n,h=yv();return C.createElement(W,{...f,...h.getStyles("list",{className:o,style:u,classNames:l,styles:c,props:n,variant:h.variant}),ref:t,role:"tablist",variant:h.variant,mod:[{grow:i,orientation:h.orientation,placement:h.orientation==="vertical"&&h.placement,inverted:h.inverted},d],"aria-orientation":h.orientation,__vars:{"--tabs-justify":s}},r)});vv.classes=Oc;vv.displayName="@mantine/core/TabsList";const oO={},xv=Q((e,t)=>{const n=U("TabsPanel",oO,e),{children:r,className:o,value:i,classNames:s,styles:l,style:c,mod:u,...d}=n,f=yv(),h=f.value===i,m=f.keepMounted||n.keepMounted||h?r:null;return C.createElement(W,{...d,...f.getStyles("panel",{className:o,classNames:s,styles:l,style:[c,h?void 0:{display:"none"}],props:n}),ref:t,mod:[{orientation:f.orientation},u],role:"tabpanel",id:f.getPanelId(i),"aria-labelledby":f.getTabId(i)},m)});xv.classes=Oc;xv.displayName="@mantine/core/TabsPanel";const iO={},wv=Q((e,t)=>{const n=U("TabsTab",iO,e),{className:r,children:o,rightSection:i,leftSection:s,value:l,onClick:c,onKeyDown:u,disabled:d,color:f,style:h,classNames:m,styles:g,vars:y,mod:S,...v}=n,x=kt(),{dir:w}=hs(),b=yv(),j=l===b.value,E=T=>{b.onChange(b.allowTabDeactivation&&l===b.value?null:l),c==null||c(T)},P={classNames:m,styles:g,props:n};return C.createElement(Jn,{...v,...b.getStyles("tab",{className:r,style:h,variant:b.variant,...P}),disabled:d,unstyled:b.unstyled,variant:b.variant,mod:[{active:j,disabled:d,orientation:b.orientation,inverted:b.inverted,placement:b.orientation==="vertical"&&b.placement},S],ref:t,role:"tab",id:b.getTabId(l),"aria-selected":j,tabIndex:j||b.value===null?0:-1,"aria-controls":b.getPanelId(l),onClick:E,__vars:{"--tabs-color":f?mt(f,x):void 0},onKeyDown:_S({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:b.activateTabWithKeyboard,loop:b.loop,orientation:b.orientation||"horizontal",dir:w,onKeyDown:u})},s&&C.createElement("span",{...b.getStyles("tabSection",P),"data-position":"left"},s),o&&C.createElement("span",{...b.getStyles("tabLabel",P)},o),i&&C.createElement("span",{...b.getStyles("tabSection",P),"data-position":"right"},i))});wv.classes=Oc;wv.displayName="@mantine/core/TabsTab";const A1="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",sO={keepMounted:!0,orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,allowTabDeactivation:!1,unstyled:!1,inverted:!1,variant:"default",placement:"left"},aO=(e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":gt(t),"--tabs-color":mt(n,e),"--tabs-text-color":gc(r,e)?fs({color:n,theme:e}):void 0}}),Ge=Q((e,t)=>{const n=U("Tabs",sO,e),{defaultValue:r,value:o,onChange:i,orientation:s,children:l,loop:c,id:u,activateTabWithKeyboard:d,allowTabDeactivation:f,variant:h,color:m,radius:g,inverted:y,placement:S,keepMounted:v,classNames:x,styles:w,unstyled:b,className:j,style:E,vars:P,autoContrast:T,mod:D,..._}=n,O=kn(u),[I,$]=gn({value:o,defaultValue:r,finalValue:null,onChange:i}),N=de({name:"Tabs",props:n,classes:Oc,className:j,style:E,classNames:x,styles:w,unstyled:b,vars:P,varsResolver:aO});return C.createElement(nO,{value:{placement:S,value:I,orientation:s,id:O,loop:c,activateTabWithKeyboard:d,getTabId:N0(`${O}-tab`,A1),getPanelId:N0(`${O}-panel`,A1),onChange:$,allowTabDeactivation:f,variant:h,color:m,radius:g,inverted:y,keepMounted:v,unstyled:b,getStyles:N}},C.createElement(W,{ref:t,id:O,variant:h,mod:[{orientation:s,inverted:s==="horizontal"&&y,placement:s==="vertical"&&S},D],...N("root"),..._},l))});Ge.classes=Oc;Ge.displayName="@mantine/core/Tabs";Ge.Tab=wv;Ge.Panel=xv;Ge.List=vv;const lO={},ae=Q((e,t)=>{const n=U("TextInput",lO,e);return C.createElement(wr,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});ae.classes=wr.classes;ae.displayName="@mantine/core/TextInput";var Xj={root:"m-7341320d"};const cO={},uO=(e,{size:t,radius:n,variant:r,gradient:o,color:i,autoContrast:s})=>{const l=e.variantColorResolver({color:i||e.primaryColor,theme:e,gradient:o,variant:r||"filled",autoContrast:s});return{root:{"--ti-size":Pe(t,"ti-size"),"--ti-radius":n===void 0?void 0:gt(n),"--ti-bg":i||r?l.background:void 0,"--ti-color":i||r?l.color:void 0,"--ti-bd":i||r?l.border:void 0}}},Sv=Q((e,t)=>{const n=U("ThemeIcon",cO,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,autoContrast:u,...d}=n,f=de({name:"ThemeIcon",classes:Xj,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:uO});return C.createElement(W,{ref:t,...f("root"),...d})});Sv.classes=Xj;Sv.displayName="@mantine/core/ThemeIcon";const dO=["h1","h2","h3","h4","h5","h6"];function fO(e,t){const n=t!==void 0?t:`h${e}`;return dO.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:{fontSize:B(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var Jj={root:"m-8a5d1357"};const hO={order:1},pO=(e,{order:t,size:n,lineClamp:r,textWrap:o})=>{const i=fO(t,n);return{root:{"--title-fw":i.fontWeight,"--title-lh":i.lineHeight,"--title-fz":i.fontSize,"--title-line-clamp":typeof r=="number"?r.toString():void 0,"--title-text-wrap":o}}},ue=Q((e,t)=>{const n=U("Title",hO,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,order:c,vars:u,size:d,variant:f,lineClamp:h,textWrap:m,mod:g,...y}=n,S=de({name:"Title",props:n,classes:Jj,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:u,varsResolver:pO});return[1,2,3,4,5,6].includes(c)?C.createElement(W,{...S("root"),component:`h${c}`,variant:f,ref:t,mod:[{order:c,"data-line-clamp":typeof h=="number"},g],size:d,...y}):null});ue.classes=Jj;ue.displayName="@mantine/core/Title";function mO(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(o){t=typeof o=="function"?o(t):o},setState(o){this.updateState(o),r.forEach(i=>i(t))},initialize(o){n||(t=o,n=!0)},subscribe(o){return r.add(o),()=>r.delete(o)}}}function gO(e){return p.useSyncExternalStore(e.subscribe,()=>e.getState(),()=>e.getState())}const yO=()=>mO({notifications:[],queue:[],limit:5}),bs=yO(),vO=(e=bs)=>gO(e);function Ga(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]);e.setState({notifications:r.slice(0,n.limit),queue:r.slice(n.limit),limit:n.limit})}function fe(e,t=bs){const n=e.id||og();return Ga(t,r=>e.id&&r.some(o=>o.id===e.id)?r:[...r,{...e,id:n}]),n}function Zj(e,t=bs){return Ga(t,n=>n.filter(r=>{var o;return r.id===e?((o=r.onClose)==null||o.call(r,r),!1):!0})),e}function El(e,t=bs){return Ga(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function xO(e=bs){Ga(e,()=>[])}function wO(e=bs){Ga(e,t=>t.slice(0,e.getState().limit))}const oo={show:fe,hide:Zj,update:El,clean:xO,cleanQueue:wO,updateState:Ga};function Sm(e,t){return Sm=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Sm(e,t)}function eP(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Sm(e,t)}var tP={exports:{}},SO="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",bO=SO,CO=bO;function nP(){}function rP(){}rP.resetWarningCache=nP;var EO=function(){function e(r,o,i,s,l,c){if(c!==CO){var u=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 u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:rP,resetWarningCache:nP};return n.PropTypes=n,n};tP.exports=EO();var jO=tP.exports;const st=Km(jO),N1={disabled:!1},_d=C.createContext(null);var PO=function(t){return t.scrollTop},jl="unmounted",Mi="exited",Li="entering",Vs="entered",bm="exiting",zo=function(e){eP(t,e);function t(r,o){var i;i=e.call(this,r,o)||this;var s=o,l=s&&!s.isMounting?r.enter:r.appear,c;return i.appearStatus=null,r.in?l?(c=Mi,i.appearStatus=Li):c=Vs:r.unmountOnExit||r.mountOnEnter?c=jl:c=Mi,i.state={status:c},i.nextCallback=null,i}t.getDerivedStateFromProps=function(o,i){var s=o.in;return s&&i.status===jl?{status:Mi}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var i=null;if(o!==this.props){var s=this.state.status;this.props.in?s!==Li&&s!==Vs&&(i=Li):(s===Li||s===Vs)&&(i=bm)}this.updateStatus(!1,i)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,i,s,l;return i=s=l=o,o!=null&&typeof o!="number"&&(i=o.exit,s=o.enter,l=o.appear!==void 0?o.appear:s),{exit:i,enter:s,appear:l}},n.updateStatus=function(o,i){if(o===void 0&&(o=!1),i!==null)if(this.cancelNextCallback(),i===Li){if(this.props.unmountOnExit||this.props.mountOnEnter){var s=this.props.nodeRef?this.props.nodeRef.current:na.findDOMNode(this);s&&PO(s)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Mi&&this.setState({status:jl})},n.performEnter=function(o){var i=this,s=this.props.enter,l=this.context?this.context.isMounting:o,c=this.props.nodeRef?[l]:[na.findDOMNode(this),l],u=c[0],d=c[1],f=this.getTimeouts(),h=l?f.appear:f.enter;if(!o&&!s||N1.disabled){this.safeSetState({status:Vs},function(){i.props.onEntered(u)});return}this.props.onEnter(u,d),this.safeSetState({status:Li},function(){i.props.onEntering(u,d),i.onTransitionEnd(h,function(){i.safeSetState({status:Vs},function(){i.props.onEntered(u,d)})})})},n.performExit=function(){var o=this,i=this.props.exit,s=this.getTimeouts(),l=this.props.nodeRef?void 0:na.findDOMNode(this);if(!i||N1.disabled){this.safeSetState({status:Mi},function(){o.props.onExited(l)});return}this.props.onExit(l),this.safeSetState({status:bm},function(){o.props.onExiting(l),o.onTransitionEnd(s.exit,function(){o.safeSetState({status:Mi},function(){o.props.onExited(l)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,i){i=this.setNextCallback(i),this.setState(o,i)},n.setNextCallback=function(o){var i=this,s=!0;return this.nextCallback=function(l){s&&(s=!1,i.nextCallback=null,o(l))},this.nextCallback.cancel=function(){s=!1},this.nextCallback},n.onTransitionEnd=function(o,i){this.setNextCallback(i);var s=this.props.nodeRef?this.props.nodeRef.current:na.findDOMNode(this),l=o==null&&!this.props.addEndListener;if(!s||l){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var c=this.props.nodeRef?[this.nextCallback]:[s,this.nextCallback],u=c[0],d=c[1];this.props.addEndListener(u,d)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===jl)return null;var i=this.props,s=i.children;i.in,i.mountOnEnter,i.unmountOnExit,i.appear,i.enter,i.exit,i.timeout,i.addEndListener,i.onEnter,i.onEntering,i.onEntered,i.onExit,i.onExiting,i.onExited,i.nodeRef;var l=Qy(i,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return C.createElement(_d.Provider,{value:null},typeof s=="function"?s(o,l):C.cloneElement(C.Children.only(s),l))},t}(C.Component);zo.contextType=_d;zo.propTypes={};function Ls(){}zo.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ls,onEntering:Ls,onEntered:Ls,onExit:Ls,onExiting:Ls,onExited:Ls};zo.UNMOUNTED=jl;zo.EXITED=Mi;zo.ENTERING=Li;zo.ENTERED=Vs;zo.EXITING=bm;const TO=zo;function kO(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bv(e,t){var n=function(i){return t&&p.isValidElement(i)?t(i):i},r=Object.create(null);return e&&p.Children.map(e,function(o){return o}).forEach(function(o){r[o.key]=n(o)}),r}function RO(e,t){e=e||{},t=t||{};function n(d){return d in t?t[d]:e[d]}var r=Object.create(null),o=[];for(var i in e)i in t?o.length&&(r[i]=o,o=[]):o.push(i);var s,l={};for(var c in t){if(r[c])for(s=0;s<r[c].length;s++){var u=r[c][s];l[r[c][s]]=n(u)}l[c]=n(c)}for(s=0;s<o.length;s++)l[o[s]]=n(o[s]);return l}function Wi(e,t,n){return n[t]!=null?n[t]:e.props[t]}function DO(e,t){return bv(e.children,function(n){return p.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:Wi(n,"appear",e),enter:Wi(n,"enter",e),exit:Wi(n,"exit",e)})})}function IO(e,t,n){var r=bv(e.children),o=RO(t,r);return Object.keys(o).forEach(function(i){var s=o[i];if(p.isValidElement(s)){var l=i in t,c=i in r,u=t[i],d=p.isValidElement(u)&&!u.props.in;c&&(!l||d)?o[i]=p.cloneElement(s,{onExited:n.bind(null,s),in:!0,exit:Wi(s,"exit",e),enter:Wi(s,"enter",e)}):!c&&l&&!d?o[i]=p.cloneElement(s,{in:!1}):c&&l&&p.isValidElement(u)&&(o[i]=p.cloneElement(s,{onExited:n.bind(null,s),in:u.props.in,exit:Wi(s,"exit",e),enter:Wi(s,"enter",e)}))}}),o}var _O=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},AO={component:"div",childFactory:function(t){return t}},Cv=function(e){eP(t,e);function t(r,o){var i;i=e.call(this,r,o)||this;var s=i.handleExited.bind(kO(i));return i.state={contextValue:{isMounting:!0},handleExited:s,firstRender:!0},i}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(o,i){var s=i.children,l=i.handleExited,c=i.firstRender;return{children:c?DO(o,l):IO(o,s,l),firstRender:!1}},n.handleExited=function(o,i){var s=bv(this.props.children);o.key in s||(o.props.onExited&&o.props.onExited(i),this.mounted&&this.setState(function(l){var c=Dd({},l.children);return delete c[o.key],{children:c}}))},n.render=function(){var o=this.props,i=o.component,s=o.childFactory,l=Qy(o,["component","childFactory"]),c=this.state.contextValue,u=_O(this.state.children).map(s);return delete l.appear,delete l.enter,delete l.exit,i===null?C.createElement(_d.Provider,{value:c},u):C.createElement(_d.Provider,{value:c},C.createElement(i,l,u))},t}(C.Component);Cv.propTypes={};Cv.defaultProps=AO;const NO=Cv,O1={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},OO={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function MO({state:e,maxHeight:t,position:n,transitionDuration:r}){const[o,i]=n.split("-"),s=i==="center"?`${o}-center`:i,l={opacity:0,maxHeight:t,transform:O1[s],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"},c={opacity:1,transform:OO[s]},u={opacity:0,maxHeight:0,transform:O1[s]};return{...l,...{entering:c,entered:c,exiting:u,exited:u}[e]}}function LO(e,t){return typeof t=="number"?t:t===!1||e===!1?!1:e}const oP=p.forwardRef(({data:e,onHide:t,autoClose:n,...r},o)=>{const{autoClose:i,message:s,...l}=e,c=LO(n,e.autoClose),u=p.useRef(),d=()=>window.clearTimeout(u.current),f=()=>{t(e.id),d()},h=()=>{typeof c=="number"&&(u.current=window.setTimeout(f,c))};return p.useEffect(()=>{var m;(m=e.onOpen)==null||m.call(e,e)},[]),p.useEffect(()=>(h(),d),[c]),C.createElement(sv,{...r,...l,onClose:f,ref:o,onMouseEnter:d,onMouseLeave:h},s)});oP.displayName="@mantine/notifications/NotificationContainer";var iP={root:"m-b37d9ac7",notification:"m-5ed0edd0"};const $O=TO,FO={position:"bottom-right",autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:zr("overlay"),store:bs,withinPortal:!0},zO=(e,{zIndex:t,position:n,containerWidth:r})=>{const[o,i]=n.split("-");return{root:{"--notifications-z-index":t==null?void 0:t.toString(),"--notifications-top":o==="top"?"var(--mantine-spacing-md)":void 0,"--notifications-bottom":o==="bottom"?"var(--mantine-spacing-md)":void 0,"--notifications-left":i==="left"?"var(--mantine-spacing-md)":i==="center"?"50%":void 0,"--notifications-right":i==="right"?"var(--mantine-spacing-md)":void 0,"--notifications-transform":i==="center"?"translateX(-50%)":void 0,"--notifications-container-width":B(r)}}},Bo=Q((e,t)=>{const n=U("Notifications",FO,e),{classNames:r,className:o,style:i,styles:s,unstyled:l,vars:c,position:u,autoClose:d,transitionDuration:f,containerWidth:h,notificationMaxHeight:m,limit:g,zIndex:y,store:S,portalProps:v,withinPortal:x,...w}=n,b=kt(),j=vO(S),E=E2(),P=sg(),T=p.useRef({}),D=p.useRef(0),O=(b.respectReducedMotion?P:!1)?1:f,I=de({name:"Notifications",classes:iP,props:n,className:o,style:i,classNames:r,styles:s,unstyled:l,vars:c,varsResolver:zO});p.useEffect(()=>{S==null||S.updateState(N=>({...N,limit:g||5}))},[g]),Co(()=>{j.notifications.length>D.current&&setTimeout(()=>E(),0),D.current=j.notifications.length},[j.notifications]);const $=j.notifications.map(({style:N,...L})=>C.createElement($O,{key:L.id,timeout:O,onEnter:()=>T.current[L.id].offsetHeight,nodeRef:{current:T.current[L.id]}},M=>C.createElement(oP,{ref:R=>{T.current[L.id]=R},data:L,onHide:R=>Zj(R,S),autoClose:d,...I("notification",{style:{...MO({state:M,position:u,transitionDuration:O,maxHeight:m}),...N}})})));return C.createElement(ys,{withinPortal:x,...v},C.createElement(W,{...I("root"),ref:t,...w},C.createElement(NO,null,$)))});Bo.classes=iP;Bo.displayName="@mantine/notifications/Notifications";Bo.show=oo.show;Bo.hide=oo.hide;Bo.update=oo.update;Bo.clean=oo.clean;Bo.cleanQueue=oo.cleanQueue;Bo.updateState=oo.updateState;class BO{constructor(t,n){this.operator=t,this.child=n}toString(){return`${this.operator}(${this.child.toString()})`}}class Mc{constructor(t,n,r){this.operator=t,this.left=n,this.right=r}toString(){return`${this.left.toString()} ${this.operator} ${this.right.toString()}`}}class UO{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(o,i){const s=o.consumeAndParse(n);return r(i,s)}})}infixLeft(t,n,r){return this.registerInfix(t,{parse(o,i,s){const l=o.consumeAndParse(n);return r(i,s,l)},precedence:n})}construct(t){return new VO(t,this.prefixParselets,this.infixParselets)}}class VO{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 o=r.parse(this,n);for(;t>this.getPrecedence();){const i=this.consume();o=this.getInfixParselet(i).parse(this,o,i)}return o}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,o;if(!this.tokens.length)throw Error("Cant consume unknown more tokens.");if(t&&((r=this.peek())==null?void 0:r.id)!==t){const i=this.peek();throw Error(`Expected ${t} but got "${i.id}" (${i.value}) at line ${i.line} column ${i.column}.`)}if(n&&((o=this.peek())==null?void 0:o.value)!==n){const i=this.peek();throw Error(`Expected "${n}" but got "${i.value}" at line ${i.line} column ${i.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]}}const WO="http://hl7.org",sP="ok",HO="created",qO="gone",GO="not-modified",QO="not-found",KO="forbidden",YO="accepted",XO={resourceType:"OperationOutcome",id:sP,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},JO={resourceType:"OperationOutcome",id:QO,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},aP={resourceType:"OperationOutcome",id:KO,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]};function pi(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},expression:t?[t]:void 0}]}}function vt(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"structure",details:{text:e}}]}}function ZO(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"exception",details:{text:"Internal server error"},diagnostics:e.toString()}]}}function Vf(e){return typeof e=="object"&&e!==null&&e.resourceType==="OperationOutcome"}function lP(e){return e.id===sP||e.id===HO||e.id===GO||e.id===YO}function eM(e){return e.id===qO}class $e extends Error{constructor(t,n){super(cP(t)),this.outcome=t,this.cause=n}}function lt(e){return e instanceof $e?e.outcome:Vf(e)?e:pi(Te(e))}function Te(e){return e?typeof e=="string"?e:e instanceof Error?e.message:Vf(e)?cP(e):typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:JSON.stringify(e):"Unknown error"}function cP(e){var n;const t=((n=e.issue)==null?void 0:n.map(uP))??[];return t.length>0?t.join("; "):"Unknown error"}function uP(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 tM(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 nM(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={name:n,elements:Object.fromEntries(Object.entries(r.elements).map(([o,i])=>[o,tM(o,i)])),constraints:[],innerTypes:[]};return t}const rM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},oM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},iM={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"}]}}},sM={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"}]}}},aM={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"}]}}},lM={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"}]}}},cM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},uM={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"}]}}},dM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},fM={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"}]}}},hM={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"}]}}},pM={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"}]}}},mM={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"}]}}},gM={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"}]}}},yM={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"]}]}}},vM={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"}]}}},xM={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"}]}}},wM={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"}]}}},SM={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"}]}}},bM={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"}]}}},CM={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"]}]}}},EM={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"}]}}},jM={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"}]},account:{type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]}}},PM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},TM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},kM={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"]}]}}},RM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},DM={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"}]}}},IM={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"}]}}},_M={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"}]}}},AM={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"}]}}},NM={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"]}]}}},OM={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},MM={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"}]}}},LM={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"]}]}}},$M={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"}]}}},FM={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"}]}}},zM={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"}]}}},BM={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"}]}}},UM={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"}]}}},VM={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"]}]}}},WM={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"}]}}},HM={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"}]}}},qM={elements:{id:{type:[{code:"string"}]},meta:{type:[{code:"Meta"}]},implicitRules:{type:[{code:"uri"}]},language:{type:[{code:"code"}]},text:{type:[{code:"Narrative"}]},contained:{max:9007199254740991,type:[{code:"Resource"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},url:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},name:{type:[{code:"string"}]},title:{type:[{code:"string"}]},status:{min:1,type:[{code:"code"}]},experimental:{type:[{code:"boolean"}]},date:{type:[{code:"dateTime"}]},publisher:{type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]},description:{type:[{code:"markdown"}]},useContext:{max:9007199254740991,type:[{code:"UsageContext"}]},jurisdiction:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},GM={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"}]}}},QM={Element:rM,BackboneElement:oM,Address:iM,Age:sM,Annotation:aM,Attachment:lM,CodeableConcept:cM,Coding:uM,ContactDetail:dM,ContactPoint:fM,Contributor:hM,Count:pM,DataRequirement:mM,Distance:gM,Dosage:yM,Duration:vM,ElementDefinition:xM,Expression:wM,Extension:SM,HumanName:bM,Identifier:CM,MarketingStatus:EM,Meta:jM,Money:PM,Narrative:TM,ParameterDefinition:kM,Period:RM,Population:DM,ProdCharacteristic:IM,ProductShelfLife:_M,Quantity:AM,Range:NM,Ratio:OM,Reference:MM,RelatedArtifact:LM,SampledData:$M,Signature:FM,SubstanceAmount:zM,Timing:BM,TriggerDefinition:UM,UsageContext:VM,MoneyQuantity:WM,SimpleQuantity:HM,MetadataResource:qM,IdentityProvider:GM};function KM(e){return new YM(e).parse()}const dP=nM(QM),Ev=Object.create(null),M1=Object.create(null);function Cm(e){let t;return e?(t=M1[e],t||(t=M1[e]=Object.create(null))):t=dP,t}function L1(e,t){var r;const n=Array.isArray(e)?e:((r=e.entry)==null?void 0:r.map(o=>o.resource))??[];for(const o of n)fP(o,t)}function fP(e,t){if(!(e!=null&&e.name))throw new Error("Failed loading StructureDefinition from bundle");if(e.resourceType!=="StructureDefinition")return;const n=KM(e),r=Cm(t);r[e.name]=n,t&&e.url===t&&(Ev[t]=n);for(const o of n.innerTypes)o.parentType=n,r[o.name]=o}function hP(e){return!!dP[e]}function Wf(e,t){let n=Cm(t)[e];return!n&&t&&(n=Cm()[e]),n}function pP(e,t){const n=Wf(e,t);if(!n)throw new $e(pi("Unknown data type: "+e));return n}function jv(e){return!!Ev[e]}function Cs(e){return Ev[e]}class YM{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,title:t.title,type:t.type,url:t.url,kind:t.kind,description:ZM(t),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){var n,r,o,i,s;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 l=np(t,this.slicingContext.path);this.slicingContext.current.elements[l]=this.parseElementDefinition(t)}}else{const l=this.parseElementDefinition(t);this.checkFieldEnter(t,l);let c=this.backboneContext;for(;c;){if((o=t.path)!=null&&o.startsWith(c.path+".")){c.type.elements[np(t,c.path)]=l;break}c=c.parent}if(!c){const u=np(t,this.root.path);t.isSummary&&((i=this.resourceSchema.summaryProperties)==null||i.add(u.replace("[x]",""))),l.min>0&&((s=this.resourceSchema.mandatoryProperties)==null||s.add(u.replace("[x]",""))),this.resourceSchema.elements[u]=l}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),t.slicing&&!this.slicingContext&&this.enterSlice(t,n)}enterInnerType(t){var n,r,o;for(;this.backboneContext&&!$s((n=this.backboneContext)==null?void 0:n.path,t.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;this.backboneContext={type:{name:q1(t),title:t.label,description:t.definition,elements:{},constraints:this.parseElementDefinition(t).constraints,innerTypes:[]},path:t.path??"",parent:$s((r=this.backboneContext)==null?void 0:r.path,t.path)?this.backboneContext:(o=this.backboneContext)==null?void 0:o.parent}}enterSlice(t,n){var r,o,i,s;JM(t)&&!((r=this.peek())!=null&&r.sliceName)||(n.slicing={discriminator:(((o=t.slicing)==null?void 0:o.discriminator)??[]).map(l=>{if(l.type!=="value"&&l.type!=="pattern"&&l.type!=="type")throw new Error(`Unsupported slicing discriminator type: ${l.type}`);return{path:l.path,type:l.type}}),slices:[],ordered:((i=t.slicing)==null?void 0:i.ordered)??!1,rule:(s=t.slicing)==null?void 0:s.rules},this.slicingContext={field:n.slicing,path:t.path??""})}checkFieldExit(t=void 0){var n;if(this.backboneContext&&!$s(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&&!$s(this.backboneContext.path,t==null?void 0:t.path));else this.innerTypes.push(this.backboneContext.type),delete this.backboneContext;this.slicingContext&&!$s(this.slicingContext.path,t==null?void 0:t.path)&&((n=this.slicingContext)!=null&&n.current&&this.slicingContext.field.slices.push(this.slicingContext.current),delete this.slicingContext)}next(){const t=this.peek();if(t)return this.index++,t}peek(){const t=this.elements[this.index];if(t){if(this.elementIndex[t.path??""]=t,t.contentReference){const n=this.elementIndex[t.contentReference.slice(t.contentReference.indexOf("#")+1)];return n?{...n,id:t.id,path:t.path,min:t.min??n.min,max:t.max??n.max,contentReference:t.contentReference,definition:t.definition}:void 0}return t}}isInnerType(t){var r;const n=this.peek();return!!($s(t==null?void 0:t.path,n==null?void 0:n.path)&&((r=t.type)!=null&&r.some(o=>["BackboneElement","Element"].includes(o.code))))}parseSliceStart(t){if(!this.slicingContext)throw new Error(`Invalid slice start before discriminator: ${t.sliceName} (${t.id})`);this.slicingContext.current&&this.slicingContext.field.slices.push(this.slicingContext.current),this.slicingContext.current={name:t.sliceName??"",path:t.path??"",definition:t.definition,type:this.parseElementDefinitionType(t),elements:{},min:t.min??0,max:t.max==="*"?Number.POSITIVE_INFINITY:Number.parseInt(t.max,10),binding:t.binding}}parseElementDefinitionType(t){return(t.type??[]).map(n=>{var o;let r;return(n.code==="BackboneElement"||n.code==="Element")&&(r=q1(t)),r||(r=(o=Lc(n,"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type"))==null?void 0:o.valueUrl),r||(r=n.code??""),{code:r,targetProfile:n.targetProfile,profile:n.profile}})}parseElementDefinition(t){var i,s;const n=$1(t.max),r=(i=t.base)!=null&&i.max?$1(t.base.max):n,o={type:"ElementDefinition",value:t};return{description:t.definition||"",path:t.path||((s=t.base)==null?void 0:s.path)||"",min:t.min??0,max:n,isArray:r>1,constraints:(t.constraint??[]).map(l=>({key:l.key??"",severity:l.severity??"error",expression:l.expression??"",description:l.human??""})),type:this.parseElementDefinitionType(t),fixed:F1(Xt(o,"fixed[x]")),pattern:F1(Xt(o,"pattern[x]")),binding:t.binding}}}function $1(e){return e==="*"?Number.POSITIVE_INFINITY:Number.parseInt(e,10)}function np(e,t=""){return XM(e.path,t)}function XM(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:""}function $s(e,t){return!e||!t?!1:t.startsWith(e+".")||t===e}function F1(e){return Array.isArray(e)&&e.length>0?e[0]:Ot(e)?void 0:e}function JM(e){var n,r;const t=(n=e.slicing)==null?void 0:n.discriminator;return!!((r=e.type)!=null&&r.some(o=>o.code==="Extension")&&(t==null?void 0:t.length)===1&&t[0].type==="value"&&t[0].path==="url")}function ZM(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 eL(e,t,n){if(t==="$this")return[e];const[r,...o]=t.split(".");let i=[Xt(e,r,n)];for(const s of o){const l=[];for(const c of i)if(Array.isArray(c))for(const u of c)l.push(Xt(u,s,n));else c!==void 0&&l.push(Xt(c,s,n));i=l}return i}const mP={base64Binary:/^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/,canonical:/^\S*$/,code:/^[^\s]+( [^\s]+)*$/,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)?)?)?$/,id:/^[A-Za-z0-9\-.]{1,64}$/,instant:/^(\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))$/,markdown:/^[\s\S]+$/,oid:/^urn:oid:[0-2](\.(0|[1-9]\d*))+$/,string:/^[\s\S]+$/,time:/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/,uri:/^\S*$/,url:/^\S*$/,uuid:/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,xhtml:/.*/};function tL(e,t){return!(t.pattern&&!Tv(e,t.pattern)||t.fixed&&!$c(e,t.fixed))}function nL(e,t,n,r){if(Array.isArray(e))return!1;const o=(r??n.elements)[t.path],i=n.type;switch(t.type){case"value":case"pattern":if(!e||!o)return!1;if(tL(e,o))return!0;break;case"type":return!e||!(i!=null&&i.length)?!1:i.some(s=>s.code===e.type)}return!1}function ve(e){return[{type:V.boolean,value:e}]}function lo(e){return e==null?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:V.integer,value:e}:typeof e=="number"?{type:V.decimal,value:e}:typeof e=="boolean"?{type:V.boolean,value:e}:typeof e=="string"?{type:V.string,value:e}:hr(e)?{type:V.Quantity,value:e}:Uo(e)?{type:e.resourceType,value:e}:{type:V.BackboneElement,value:e}}function ii(e){return e.length===0?!1:!!e[0].value}function Ro(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 Xt(e,t,n){if(!e.value)return;const r=js(e.type,t,n==null?void 0:n.profileUrl);return r?gP(e,t,r):rL(e,t)}function gP(e,t,n){const r=e.value,o=n.type;if(!o||o.length===0)return;let i,s="undefined",l;if(n.path.endsWith("[x]")){const c=n.path.split(".").pop().replace("[x]","");for(const u of o){const d=c+Vt(u.code);if(i=r[d],l=r["_"+d],i!==void 0||l!==void 0){s=u.code;break}}}else console.assert(o.length===1,"Expected single type",n.path),i=r[t],s=o[0].code,l=r["_"+t];if(l)if(Array.isArray(i)){i=i.slice();for(let c=0;c<Math.max(i.length,l.length);c++)i[c]=V1(i[c],l[c])}else i=V1(i,l);if(!Ot(i))return(s==="Element"||s==="BackboneElement")&&(s=n.type[0].code),Array.isArray(i)?i.map(c=>z1(c,s)):z1(i,s)}function z1(e,t){return t==="Resource"&&Uo(e)&&(t=e.resourceType),{type:t,value:e}}function rL(e,t){const n=e.value;if(!n||typeof n!="object")return;let r;if(t in n)r=n[t];else for(const o in V){const i=t+Vt(o);if(i in n){r=n[i];break}}if(!Ot(r))return Array.isArray(r)?r.map(lo):lo(r)}function yP(e){const t=[];for(const n of e){let r=!1;for(const o of t)if(ii(wP(n,o))){r=!0;break}r||t.push(n)}return t}function vP(e){return ve(!ii(e))}function xP(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?ve(!1):ve(e.every((n,r)=>ii(wP(n,t[r]))))}function wP(e,t){var o,i;const n=(o=e.value)==null?void 0:o.valueOf(),r=(i=t.value)==null?void 0:i.valueOf();return typeof n=="number"&&typeof r=="number"?ve(Math.abs(n-r)<1e-8):hr(n)&&hr(r)?ve(CP(n,r)):ve(typeof n=="object"&&typeof r=="object"?Pv(e,t):n===r)}function SP(e,t){return e.length===0&&t.length===0?ve(!0):e.length!==t.length?ve(!1):(e.sort(B1),t.sort(B1),ve(e.every((n,r)=>ii(oL(n,t[r])))))}function oL(e,t){const{type:n,value:r}=e,{type:o,value:i}=t,s=r==null?void 0:r.valueOf(),l=i==null?void 0:i.valueOf();return typeof s=="number"&&typeof l=="number"?ve(Math.abs(s-l)<.01):hr(s)&&hr(l)?ve(CP(s,l)):ve(n==="Coding"&&o==="Coding"?typeof s!="object"||typeof l!="object"?!1:s.code===l.code&&s.system===l.system:typeof s=="object"&&typeof l=="object"?Pv({...s,id:void 0},{...l,id:void 0}):typeof s=="string"&&typeof l=="string"?s.toLowerCase()===l.toLowerCase():s===l)}function B1(e,t){var o,i;const n=(o=e.value)==null?void 0:o.valueOf(),r=(i=t.value)==null?void 0:i.valueOf();return typeof n=="number"&&typeof r=="number"?n-r:typeof n=="string"&&typeof r=="string"?n.localeCompare(r):0}function bP(e,t){const{value:n}=e;if(n==null)return!1;switch(t){case"Boolean":return typeof n=="boolean";case"Decimal":case"Integer":return typeof n=="number";case"Date":return iL(n);case"DateTime":return Em(n);case"Time":return typeof n=="string"&&!!/^T\d/.exec(n);case"Period":return sL(n);case"Quantity":return hr(n);default:return typeof n=="object"&&(n==null?void 0:n.resourceType)===t}}function iL(e){return typeof e=="string"&&!!mP.date.exec(e)}function Em(e){return typeof e=="string"&&!!mP.dateTime.exec(e)}function sL(e){return!!(e&&typeof e=="object"&&("start"in e&&Em(e.start)||"end"in e&&Em(e.end)))}function hr(e){return!!(e&&typeof e=="object"&&"value"in e&&typeof e.value=="number")}function CP(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 Pv(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const i=e[o],s=t[o];if(U1(i)&&U1(s)){if(!Pv(i,s))return!1}else if(i!==s)return!1}return!0}function U1(e){return e!==null&&typeof e=="object"}function V1(e,t){if(t){if(typeof t!="object")throw new Error("Primitive extension must be an object");return aL(e??{},t)}return e}function aL(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function ft(e){const t=ht(e),n=Do(e);return n===t?{reference:t}:{reference:t,display:n}}function ht(e){return Ps(e)?e.reference:`${e.resourceType}/${e.id}`}function Hf(e){if(e)return Ps(e)?e.reference.split("/")[1]:e.id}function lL(e){return e.resourceType==="Patient"||e.resourceType==="Practitioner"||e.resourceType==="RelatedPerson"}function Do(e){if(lL(e)){const t=cL(e);if(t)return t}if(e.resourceType==="Device"){const t=uL(e);if(t)return t}if(e.resourceType==="MedicationRequest"){const t=e.medicationCodeableConcept;if(t)return wi(t)}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]),wL(t))return wi(t);if(SL(t))return t.text}return ht(e)}function cL(e){const t=e.name;if(t&&t.length>0)return Fc(t[0])}function uL(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name}function dL(e){if(!("photo"in e))return;const t=e.photo;if(t)if(Array.isArray(t))for(const n of t){const r=W1(n);if(r)return r}else return W1(t)}function W1(e){if(e.url&&e.contentType&&e.contentType.startsWith("image/"))return e.url}function EP(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 o=n.getUTCFullYear(),i=n.getUTCMonth(),s=n.getUTCDate(),l=r.getUTCFullYear(),c=r.getUTCMonth(),u=r.getUTCDate();let d=l-o;(c<i||c===i&&u<s)&&d--;let f=l*12+c-(o*12+i);u<s&&f--;const h=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:d,months:f,days:h}}function fL(e,t){const{years:n,months:r,days:o}=EP(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":r>=1?r.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"}function Lc(e,...t){var r;let n=e;for(let o=0;o<t.length&&n;o++)n=(r=n==null?void 0:n.extension)==null?void 0:r.find(i=>i.url===t[o]);return n}function tr(e,t){return JSON.stringify(e,hL,t?2:void 0)}function hL(e,t){return!pL(e)&&Ot(t)?void 0:t}function pL(e){return!!/\d+$/.exec(e)}function Ot(e){if(e==null)return!0;const t=typeof e;return t==="string"||t==="object"?!Nt(e):!1}function Nt(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 $c(e,t,n){return e===t||Ot(e)&&Ot(t)?!0:Ot(e)||Ot(t)?!1:Array.isArray(e)&&Array.isArray(t)?mL(e,t):Array.isArray(e)||Array.isArray(t)?!1:mn(e)&&mn(t)?gL(e,t,n):(mn(e)||mn(t),!1)}function mL(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!$c(e[n],t[n]))return!1;return!0}function gL(e,t,n){const r=new Set;Object.keys(e).forEach(o=>r.add(o)),Object.keys(t).forEach(o=>r.add(o)),n==="meta"&&(r.delete("versionId"),r.delete("lastUpdated"),r.delete("author"));for(const o of r){const i=e[o],s=t[o];if(!$c(i,s,o))return!1}return!0}function Tv(e,t){return Ot(e)?!0:Ot(t)?!1:Array.isArray(e)&&Array.isArray(t)?yL(e,t):Array.isArray(e)||Array.isArray(t)?!1:mn(e)&&mn(t)?vL(e,t):mn(e)||mn(t)?!1:e===t}function yL(e,t){return t.every(n=>e.some(r=>Tv(r,n)))}function vL(e,t){return Object.entries(t).every(([n,r])=>n in e&&Tv(e[n],r))}function co(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function jP(e){return!!/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i.exec(e)}function mn(e){return e!==null&&typeof e=="object"}function xL(e){return mn(e)&&"code"in e&&typeof e.code=="string"}function wL(e){return mn(e)&&"coding"in e&&Array.isArray(e.coding)&&e.coding.every(xL)}function SL(e){return mn(e)&&"text"in e&&typeof e.text=="string"}const PP=[];for(let e=0;e<256;e++)PP.push(e.toString(16).padStart(2,"0"));function bL(e){const t=new Uint8Array(e),n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=PP[t[r]];return n.join("")}function CL(e){const t=new Uint8Array(e),n=[];for(let r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return window.btoa(n.join(""))}function Vt(e){return e?e.charAt(0).toUpperCase()+e.substring(1):""}function kv(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function ic(e,t){const n=e+".";if(t.startsWith(n))return t.slice(n.length)}function EL(e,t){var n,r;return(r=(n=e.coding)==null?void 0:n.find(o=>o.system===t))==null?void 0:r.code}function jL(e){if(e)return Array.isArray(e)?e:[e]}const H1=e=>new Promise(t=>{setTimeout(t,e)});function PL(e,t,n){const r=[];for(let o=0;o<n-1;o++){const i=e.indexOf(t);if(i<0)break;r.push(e.slice(0,i)),e=e.slice(i+t.length)}return r.push(e),r}function TL(e){let t,n=!1;return function(){return n||(t=e(),n=!0),t}}function dl(e,t){return e?(e.push(t),e):[t]}function kL(e,t){return new URL(e,t).toString().replace("http://","ws://").replace("https://","wss://")}function RL(e,t){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.all||t!=null&&t.use)&&n.push("["+e.use+"]"),n.join((t==null?void 0:t.lineSeparator)??", ").trim()}function Fc(e,t){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=ac(e.text);if(r)return r}return n.join(" ").trim()}function qf(e){return e instanceof Date&&!isNaN(e.getTime())}function DL(e,t,n){if(!e)return"";const r=new Date("2000-01-01T"+e+"Z");return qf(r)?r.toLocaleTimeString(t,n):""}function jn(e,t,n){if(!e)return"";const r=new Date(e);return qf(r)?r.toLocaleString(t,n):""}function IL(e,t,n){return!e||!e.start&&!e.end?"":jn(e.start,t,n)+" - "+jn(e.end,t,n)}const _L={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},AL={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},NL={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function TP(e){if(!e)return"";const t=[];return OL(t,e.repeat),e.event&&t.push(e.event.map(n=>jn(n)).join(", ")),Vt(t.join(" ").trim())}function OL(e,t){if(!(t!=null&&t.periodUnit))return;const n=t.frequency??1,r=t.period??1,o=t.periodUnit;n===1&&r===1?e.push(_L[o]):(n===1?e.push("once"):e.push(n+" times"),r===1?e.push("per "+AL[o]):e.push("per "+r+" "+NL[o])),t.dayOfWeek&&e.push("on "+t.dayOfWeek.map(Vt).join(", ")),t.timeOfDay&&e.push("at "+t.timeOfDay.map(i=>DL(i)).join(", "))}function sc(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},o=(e==null?void 0:e.high)&&{...e.high,comparator:void 0};return(r==null?void 0:r.value)===void 0&&(o==null?void 0:o.value)===void 0?"":(r==null?void 0:r.value)!==void 0&&(o==null?void 0:o.value)===void 0?n&&t!==void 0?(r.value=$L(r.value,t),`> ${Xo(r,t)}`):`>= ${Xo(r,t)}`:(r==null?void 0:r.value)===void 0&&(o==null?void 0:o.value)!==void 0?n&&t!==void 0?(o.value=LL(o.value,t),`< ${Xo(o,t)}`):`<= ${Xo(o,t)}`:((r==null?void 0:r.unit)===(o==null?void 0:o.unit)&&(r==null||delete r.unit),`${Xo(r,t)} - ${Xo(o,t)}`)}function Xo(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),e.value!==void 0&&(t!==void 0?n.push(e.value.toFixed(t)):n.push(e.value)),e.unit&&(e.unit!=="%"&&n[n.length-1]!==" "&&n.push(" "),n.push(e.unit)),n.join("").trim()}function ML(e){return(e==null?void 0:e.value)===void 0?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency??"USD",currencyDisplay:"narrowSymbol"})}function wi(e){if(!e)return"";const t=ac(e.text);return t||(e.coding?e.coding.map(n=>Es(n)).join(", "):"")}function Es(e){return ac(e==null?void 0:e.display)??ac(e==null?void 0:e.code)??""}function kP(e){if(!e)return"";if("component"in e)return e.component.map(n=>kP(n)).join(" / ");if(e.valueQuantity)return Xo(e.valueQuantity);if(e.valueCodeableConcept)return wi(e.valueCodeableConcept);const t=ac(e.valueString);return t||""}function ac(e){return typeof e=="string"?e:void 0}function LL(e,t,n=1){return(RP(e,t)+n)*Math.pow(10,-t)}function $L(e,t,n=1){return(RP(e,t)-n)*Math.pow(10,-t)}function RP(e,t){return t===void 0?e:Math.round(e*Math.pow(10,t))}const V={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 FL(e){for(const t of e.base??[]){let n=Io.types[t];n||(n={searchParamsDetails:{}},Io.types[t]=n),n.searchParams||(n.searchParams={_id:{base:[t],code:"_id",type:"token",expression:t+".id"},_lastUpdated:{base:[t],code:"_lastUpdated",type:"date",expression:t+".meta.lastUpdated"},_compartment:{base:[t],code:"_compartment",type:"reference",expression:t+".meta.compartment"},_profile:{base:[t],code:"_profile",type:"uri",expression:t+".meta.profile"},_security:{base:[t],code:"_security",type:"token",expression:t+".meta.security"},_source:{base:[t],code:"_source",type:"uri",expression:t+".meta.source"},_tag:{base:[t],code:"_tag",type:"token",expression:t+".meta.tag"}}),n.searchParams[e.code]=e}}function q1(e){var n,r,o,i;const t=(r=(n=e.type)==null?void 0:n[0])==null?void 0:r.code;return t==="BackboneElement"||t==="Element"?zL((i=((o=e.base)==null?void 0:o.path)??e.path)==null?void 0:i.split(".")):t}function zL(e){return e.length===1?e[0]:e.map(Vt).join("")}function Rv(e){var t;return(t=Io.types[e])==null?void 0:t.searchParams}function BL(e,t){var n,r;return(r=(n=Io.types[e])==null?void 0:n.searchParams)==null?void 0:r[t]}function ss(e){const t=e.replaceAll("[x]","").split(".").pop();return DP(t)}function DP(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(VL).join(" ").replace("_"," ").replace(/\s+/g," ")}const UL=new Set(["ID","IP","PKCE","JWKS","URI","URL","OMB","UDI"]);function VL(e){const t=e.toUpperCase();return e===t?e:UL.has(t)?t:t.charAt(0)+e.slice(1)}function js(e,t,n){const r=Wf(e,n);if(r)return WL(r.elements,t)}function WL(e,t){const n=e[t]??e[t+"[x]"];if(n)return n;for(let r=0;r<t.length;r++){const o=t[r];if(o>="A"&&o<="Z"){const i=t.slice(0,r)+"[x]",s=e[i];if(s)return s}}}function Uo(e){return!!(e&&typeof e=="object"&&"resourceType"in e)}function Ps(e){return!!(e&&typeof e=="object"&&"reference"in e&&typeof e.reference=="string")}const Io={types:{}};function Yu(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 fl=()=>[],Nn={empty:(e,t)=>ve(t.length===0||t.every(n=>Ot(n.value))),hasValue:(e,t)=>ve(t.length!==0),exists:(e,t,n)=>ve(n?t.filter(r=>ii(n.eval(e,[r]))).length>0:t.length>0&&t.every(r=>!Ot(r.value))),all:(e,t,n)=>ve(t.every(r=>ii(n.eval(e,[r])))),allTrue:(e,t)=>{for(const n of t)if(!n.value)return ve(!1);return ve(!0)},anyTrue:(e,t)=>{for(const n of t)if(n.value)return ve(!0);return ve(!1)},allFalse:(e,t)=>{for(const n of t)if(n.value)return ve(!1);return ve(!0)},anyFalse:(e,t)=>{for(const n of t)if(!n.value)return ve(!0);return ve(!1)},subsetOf:fl,supersetOf:fl,count:(e,t)=>[{type:V.integer,value:t.length}],distinct:(e,t)=>{const n=[];for(const r of t)n.some(o=>o.value===r.value)||n.push(r);return n},isDistinct:(e,t)=>ve(t.length===Nn.distinct(e,t).length),where:(e,t,n)=>t.filter(r=>ii(n.eval({parent:e,variables:{$this:r}},[r]))),select:(e,t,n)=>t.map(r=>n.eval(e,[r])).flat(),repeat:fl,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 o;const r=(o=n.eval(e,t)[0])==null?void 0:o.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 o;const r=(o=n.eval(e,t)[0])==null?void 0:o.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,t),o=[];for(const i of t)!o.some(s=>s.value===i.value)&&r.some(s=>s.value===i.value)&&o.push(i);return o},exclude:(e,t,n)=>{if(!n)return t;const r=n.eval(e,t),o=[];for(const i of t)r.some(s=>s.value===i.value)||o.push(i);return o},union:(e,t,n)=>{if(!n)return t;const r=n.eval(e,t);return yP([...t,...r])},combine:(e,t,n)=>{if(!n)return t;const r=n.eval(e,t);return[...t,...r]},htmlChecks:(e,t,n)=>[lo(!0)],iif:(e,t,n,r,o)=>{const i=n.eval(e,t);if(i.length>1||i.length===1&&typeof i[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return ii(i)?r.eval(e,t):o?o.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);if(typeof n=="boolean")return[{type:V.boolean,value:n}];if(typeof n=="number"&&(n===0||n===1))return ve(!!n);if(typeof n=="string"){const r=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(r))return ve(!0);if(["false","f","no","n","0","0.0"].includes(r))return ve(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:ve(Nn.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return typeof n=="number"?[{type:V.integer,value:n}]:typeof n=="string"&&/^[+-]?\d+$/.exec(n)?[{type:V.integer,value:parseInt(n,10)}]:typeof n=="boolean"?[{type:V.integer,value:n?1:0}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:ve(Nn.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:V.date,value:Yu(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:ve(Nn.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:V.dateTime,value:Yu(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:ve(Nn.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return typeof n=="number"?[{type:V.decimal,value:n}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:V.decimal,value:parseFloat(n)}]:typeof n=="boolean"?[{type:V.decimal,value:n?1:0}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:ve(Nn.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return hr(n)?[{type:V.Quantity,value:n}]:typeof n=="number"?[{type:V.Quantity,value:{value:n,unit:"1"}}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:V.Quantity,value:{value:parseFloat(n),unit:"1"}}]:typeof n=="boolean"?[{type:V.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:ve(Nn.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);return n==null?[]:hr(n)?[{type:V.string,value:`${n.value} '${n.unit}'`}]:[{type:V.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:ve(Nn.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=Zr(t,1);if(typeof n=="string"){const r=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(r)return[{type:V.time,value:Yu("T"+r[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:ve(Nn.toTime(e,t).length===1),indexOf:(e,t,n)=>sr((r,o)=>r.indexOf(o),e,t,n),substring:(e,t,n,r)=>sr((o,i,s)=>{const l=i,c=s?l+s:o.length;return l<0||l>=o.length?void 0:o.substring(l,c)},e,t,n,r),startsWith:(e,t,n)=>sr((r,o)=>r.startsWith(o),e,t,n),endsWith:(e,t,n)=>sr((r,o)=>r.endsWith(o),e,t,n),contains:(e,t,n)=>sr((r,o)=>r.includes(o),e,t,n),upper:(e,t)=>sr(n=>n.toUpperCase(),e,t),lower:(e,t)=>sr(n=>n.toLowerCase(),e,t),replace:(e,t,n,r)=>sr((o,i,s)=>o.replaceAll(i,s),e,t,n,r),matches:(e,t,n)=>sr((r,o)=>!!new RegExp(o).exec(r),e,t,n),replaceMatches:(e,t,n,r)=>sr((o,i,s)=>o.replaceAll(i,s),e,t,n,r),length:(e,t)=>sr(n=>n.length,e,t),toChars:(e,t)=>sr(n=>n?n.split(""):void 0,e,t),abs:(e,t)=>Yr(Math.abs,e,t),ceiling:(e,t)=>Yr(Math.ceil,e,t),exp:(e,t)=>Yr(Math.exp,e,t),floor:(e,t)=>Yr(Math.floor,e,t),ln:(e,t)=>Yr(Math.log,e,t),log:(e,t,n)=>Yr((r,o)=>Math.log(r)/Math.log(o),e,t,n),power:(e,t,n)=>Yr(Math.pow,e,t,n),round:(e,t)=>Yr(Math.round,e,t),sqrt:(e,t)=>Yr(Math.sqrt,e,t),truncate:(e,t)=>Yr(n=>n|0,e,t),children:fl,descendants:fl,trace:(e,t,n)=>t,now:()=>[{type:V.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:V.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:V.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,o)=>{var u;const i=Nn.toDateTime(e,n.eval(e,t));if(i.length===0)throw new Error("Invalid start date");const s=Nn.toDateTime(e,r.eval(e,t));if(s.length===0)throw new Error("Invalid end date");const l=(u=o.eval(e,t)[0])==null?void 0:u.value;if(l!=="years"&&l!=="months"&&l!=="days")throw new Error("Invalid units");const c=EP(i[0].value,s[0].value);return[{type:V.Quantity,value:{value:c[l],unit:l}}]},is:(e,t,n)=>{let r="";return n instanceof Dv?r=n.name:n instanceof _v&&(r=n.left.name+"."+n.right.name),r?t.map(o=>({type:V.boolean,value:bP(o,r)})):[]},not:(e,t)=>Nn.toBoolean(e,t).map(n=>({type:V.boolean,value:!n.value})),resolve:(e,t)=>t.map(n=>{const r=n.value;let o;if(typeof r=="string")o=r;else if(typeof r=="object"){const i=r;if(i.resource)return lo(i.resource);i.reference?o=i.reference:i.type&&i.identifier&&(o=`${i.type}?identifier=${i.identifier.system}|${i.identifier.value}`)}if(o!=null&&o.includes("?")){const[i]=o.split("?");return{type:i,value:{resourceType:i}}}if(o!=null&&o.includes("/")){const[i,s]=o.split("/");return{type:i,value:{resourceType:i,id:s}}}return{type:V.BackboneElement,value:void 0}}).filter(n=>!!n.value),as:(e,t)=>t,type:(e,t)=>t.map(({value:n})=>typeof n=="boolean"?{type:V.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof n=="number"?{type:V.BackboneElement,value:{namespace:"System",name:"Integer"}}:Uo(n)?{type:V.BackboneElement,value:{namespace:"FHIR",name:n.resourceType}}:{type:V.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 o=r.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map(i=>{var s;return{type:V.boolean,value:((s=i.value)==null?void 0:s.resourceType)===o}})}};function sr(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=Zr(n,1);if(typeof o!="string")throw new Error("String function cannot be called with non-string");const i=e(o,...r.map(s=>{var l;return(l=s==null?void 0:s.eval(t,n)[0])==null?void 0:l.value}));return i===void 0?[]:Array.isArray(i)?i.map(lo):[lo(i)]}function Yr(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=Zr(n,1),i=hr(o),s=i?o.value:o;if(typeof s!="number")throw new Error("Math function cannot be called with non-number");const l=e(s,...r.map(d=>{var f;return(f=d.eval(t,n)[0])==null?void 0:f.value})),c=i?V.Quantity:n[0].type,u=i?{...o,value:l}:l;return[{type:c,value:u}]}function Zr(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}class HL{constructor(t,n){this.original=t,this.child=n}eval(t,n){try{if(n.length>0){const r=[];for(const o of n)r.push(this.child.eval({parent:t,variables:{$this:o}},[o]));return r.flat()}else return this.child.eval(t,[])}catch(r){throw new Error(`FhirPathError on "${this.original}": ${r}`)}}toString(){return this.child.toString()}}class Fs{constructor(t){this.value=t}eval(){return[this.value]}toString(){const t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}}class Dv{constructor(t){this.name=t}eval(t,n){const r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return n.flatMap(o=>this.evalValue(o)).filter(o=>(o==null?void 0:o.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 Uo(n)&&n.resourceType===this.name?t:Xt(t,this.name)}toString(){return this.name}}class qL{eval(){return[]}toString(){return"{}"}}class GL extends BO{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 Iv extends Mc{constructor(t,n){super("as",t,n)}eval(t,n){return Nn.ofType(t,this.left.eval(t,n),this.right)}}class Hn extends Mc{}class jr extends Hn{constructor(t,n,r,o){super(t,n,r),this.impl=o}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.eval(t,n);if(o.length!==1)return[];const i=r[0].value,s=o[0].value,l=hr(i)?i.value:i,c=hr(s)?s.value:s,u=this.impl(l,c);return typeof u=="boolean"?ve(u):hr(i)?[{type:V.Quantity,value:{...i,value:u}}]:[lo(u)]}}class QL extends Mc{constructor(t,n){super("&",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n),i=[...r,...o];return i.length>0&&i.every(s=>typeof s.value=="string")?[{type:V.string,value:i.map(s=>s.value).join("")}]:i}}class KL extends Hn{constructor(t,n){super("contains",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return ve(r.some(i=>i.value===o[0].value))}}class YL extends Hn{constructor(t,n){super("in",t,n)}eval(t,n){const r=Ro(this.left.eval(t,n)),o=this.right.eval(t,n);return r?ve(o.some(i=>i.value===r.value)):[]}}class _v extends Mc{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 IP extends Mc{constructor(t,n){super("|",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return yP([...r,...o])}}class XL extends Hn{constructor(t,n){super("=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return xP(r,o)}}class JL extends Hn{constructor(t,n){super("!=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return vP(xP(r,o))}}class ZL extends Hn{constructor(t,n){super("~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return SP(r,o)}}class e$ extends Hn{constructor(t,n){super("!~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return vP(SP(r,o))}}class Av extends Hn{constructor(t,n){super("is",t,n)}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.name;return ve(bP(r[0],o))}}class t$ extends Hn{constructor(t,n){super("and",t,n)}eval(t,n){const r=Ro(this.left.eval(t,n),"boolean"),o=Ro(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!0&&(o==null?void 0:o.value)===!0?ve(!0):(r==null?void 0:r.value)===!1||(o==null?void 0:o.value)===!1?ve(!1):[]}}class n$ extends Hn{constructor(t,n){super("or",t,n)}eval(t,n){const r=Ro(this.left.eval(t,n),"boolean"),o=Ro(this.right.eval(t,n),"boolean");return(r==null?void 0:r.value)===!1&&(o==null?void 0:o.value)===!1?ve(!1):r!=null&&r.value||o!=null&&o.value?ve(!0):[]}}class r$ extends Hn{constructor(t,n){super("xor",t,n)}eval(t,n){const r=Ro(this.left.eval(t,n),"boolean"),o=Ro(this.right.eval(t,n),"boolean");return!r||!o?[]:ve(r.value!==o.value)}}class o$ extends Hn{constructor(t,n){super("implies",t,n)}eval(t,n){const r=Ro(this.left.eval(t,n),"boolean"),o=Ro(this.right.eval(t,n),"boolean");return(o==null?void 0:o.value)===!0||(r==null?void 0:r.value)===!1?ve(!0):!r||!o?[]:ve(!1)}}class Nv{constructor(t,n){this.name=t,this.args=n}eval(t,n){const r=Nn[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 Ov{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 o=r[0].value;if(typeof o!="number")throw new Error("Invalid indexer expression: should return integer}");const i=this.left.eval(t,n);return o in i?[i[o]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const i$=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"];class s${constructor(t,n,r,o){this.result=[],this.pos={index:0,line:1,column:0},this.markStack=[],this.str=t,this.keywords=n,this.operators=r,this.dateTimeLiterals=!!(o!=null&&o.dateTimeLiterals),this.symbolRegex=(o==null?void 0:o.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==='"'?this.consumeString(t):t==="`"?this.consumeBacktickSymbol():t==="@"?this.consumeDateTime():/\d/.exec(t)?this.consumeNumber():/\w/.exec(t)?this.consumeSymbol():(t==="$"||t==="%")&&/\w/.exec(n)?this.consumeSymbol():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()!==`
84
84
  `))}consumeString(t){this.advance();const n=this.buildToken("String",this.consumeWhile(()=>this.prev()==="\\"||this.curr()!==t));return this.advance(),n}consumeBacktickSymbol(){this.advance();const t=this.buildToken("Symbol",this.consumeWhile(()=>this.curr()!=="`"));return this.advance(),t}consumeDateTime(){this.advance();const t=this.pos.index;this.consumeWhile(()=>/[\d-]/.exec(this.curr()));let n=!1,r=!1;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()))));let o=this.str.substring(t,this.pos.index);return o.endsWith("T")?o=o.substring(0,o.length-1):!o.startsWith("T")&&n&&!r&&(o+="Z"),this.buildToken("DateTime",o)}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()===" "&&a$(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()===`
85
- `?(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 a$(e){return!!(e&&(e.id==="String"||e.id==="Symbol"&&i$.includes(e.value)))}const l$=["true","false"],c$=["!=","!~","<=",">=","{}","->"];function u$(e){return new s$(e,l$,c$).tokenize()}const Je={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide: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,Arrow:100,Semicolon:200},d$={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}},f$={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Ov(t,n)},precedence:Je.Indexer},h$={parse(e,t){if(!(t instanceof Dv))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Nv(t.name,n)},precedence:Je.FunctionCall};function p$(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 m$(){return new UO().registerPrefix("String",{parse:(e,t)=>new Fs({type:V.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new Fs({type:V.dateTime,value:Yu(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new Fs({type:V.Quantity,value:p$(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new Fs({type:t.value.includes(".")?V.decimal:V.integer,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new Fs({type:V.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Fs({type:V.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Dv(t.value)}).registerPrefix("{}",{parse:()=>new qL}).registerPrefix("(",d$).registerInfix("[",f$).registerInfix("(",h$).prefix("+",Je.UnaryAdd,(e,t)=>new GL("+",t,n=>n)).prefix("-",Je.UnarySubtract,(e,t)=>new jr("-",t,t,(n,r)=>-r)).infixLeft(".",Je.Dot,(e,t,n)=>new _v(e,n)).infixLeft("/",Je.Divide,(e,t,n)=>new jr("/",e,n,(r,o)=>r/o)).infixLeft("*",Je.Multiply,(e,t,n)=>new jr("*",e,n,(r,o)=>r*o)).infixLeft("+",Je.Add,(e,t,n)=>new jr("+",e,n,(r,o)=>r+o)).infixLeft("-",Je.Subtract,(e,t,n)=>new jr("-",e,n,(r,o)=>r-o)).infixLeft("|",Je.Union,(e,t,n)=>new IP(e,n)).infixLeft("=",Je.Equals,(e,t,n)=>new XL(e,n)).infixLeft("!=",Je.NotEquals,(e,t,n)=>new JL(e,n)).infixLeft("~",Je.Equivalent,(e,t,n)=>new ZL(e,n)).infixLeft("!~",Je.NotEquivalent,(e,t,n)=>new e$(e,n)).infixLeft("<",Je.LessThan,(e,t,n)=>new jr("<",e,n,(r,o)=>r<o)).infixLeft("<=",Je.LessThanOrEquals,(e,t,n)=>new jr("<=",e,n,(r,o)=>r<=o)).infixLeft(">",Je.GreaterThan,(e,t,n)=>new jr(">",e,n,(r,o)=>r>o)).infixLeft(">=",Je.GreaterThanOrEquals,(e,t,n)=>new jr(">=",e,n,(r,o)=>r>=o)).infixLeft("&",Je.Ampersand,(e,t,n)=>new QL(e,n)).infixLeft("and",Je.And,(e,t,n)=>new t$(e,n)).infixLeft("as",Je.As,(e,t,n)=>new Iv(e,n)).infixLeft("contains",Je.Contains,(e,t,n)=>new KL(e,n)).infixLeft("div",Je.Divide,(e,t,n)=>new jr("div",e,n,(r,o)=>r/o|0)).infixLeft("in",Je.In,(e,t,n)=>new YL(e,n)).infixLeft("is",Je.Is,(e,t,n)=>new Av(e,n)).infixLeft("mod",Je.Modulo,(e,t,n)=>new jr("mod",e,n,(r,o)=>r%o)).infixLeft("or",Je.Or,(e,t,n)=>new n$(e,n)).infixLeft("xor",Je.Xor,(e,t,n)=>new r$(e,n)).infixLeft("implies",Je.Implies,(e,t,n)=>new o$(e,n))}const g$=m$();function _P(e){return new HL(e,g$.construct(u$(e)).consumeAndParse())}function y$(e,t){const n=Array.isArray(t)?t:[t];for(let r=0;r<n.length;r++){const o=n[r];typeof o=="object"&&"type"in o&&"value"in o||(n[r]=lo(n[r]))}return lc(e,n).map(r=>r.value)}function lc(e,t,n){const r=n??{};return _P(e).eval({variables:r},t).map(i=>{var s;return{type:i.type,value:(s=i.value)==null?void 0:s.valueOf()}})}var Jo=(e=>(e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.CANONICAL="CANONICAL",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD",e.UUID="UUID",e))(Jo||{});function Gf(e,t){var r,o;let n=(o=(r=Io.types[e])==null?void 0:r.searchParamsDetails)==null?void 0:o[t.code];return n||(n=x$(e,t)),n}function v$(e,t,n){let r=Io.types[e];r||(r={},Io.types[e]=r),r.searchParamsDetails||(r.searchParamsDetails={}),r.searchParamsDetails[t]=n}function x$(e,t){const n=t.code,r=b$(n),o=E$(e,t.expression),i={elementDefinitions:[],propertyTypes:new Set,array:!1};for(const l of o){const c=Ol(l),u=TL(()=>c.join("."));c.length===1&&c[0]instanceof Hn?i.propertyTypes.add("boolean"):u().endsWith("extension.value.code")||u().endsWith("extension.value.coding.code")?(i.array=!0,i.propertyTypes.add("code")):AP(i,Ol(l),e,1),u().endsWith("extension.valueDateTime")&&(i.array=!1)}const s={columnName:r,type:C$(t,i.propertyTypes),elementDefinitions:i.elementDefinitions,array:i.array};return v$(e,n,s),s}function AP(e,t,n,r){const o=t[r];if(o instanceof Iv){e.propertyTypes.add(o.right.toString());return}if(o instanceof Nv){w$(e,o);return}const i=o.toString(),s=js(n,i);if(!s)throw new Error(`Element definition not found for ${n} ${i}`);let l=!1,c=r+1;if(c<t.length&&t[c]instanceof Ov&&(l=!0,c++),s.isArray&&!l&&(e.array=!0),c>=t.length){e.elementDefinitions.push(s);for(const u of s.type)e.propertyTypes.add(u.code);return}for(const u of s.type){let d=u.code;S$(d)&&(d=s.type[0].code),AP(e,t,d,c)}}function w$(e,t){if(t.name==="as"){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 Av){e.propertyTypes.add(t.args[0].right.toString());return}throw new Error(`Unhandled FHIRPath function: ${t.name}`)}function S$(e){return e==="Element"||e==="BackboneElement"}function b$(e){return e.split("-").reduce((t,n,r)=>t+(r?Vt(n):n),"")}function C$(e,t){switch(e.type){case"date":return t.size===1&&t.has(V.date)?"DATE":"DATETIME";case"number":return"NUMBER";case"quantity":return"QUANTITY";case"reference":return t.has(V.canonical)?"CANONICAL":"REFERENCE";case"token":return t.size===1&&t.has(V.boolean)?"BOOLEAN":"TEXT";default:return"TEXT"}}function E$(e,t){const n=[],r=_P(t);return jm(e,r.child,n),n}function jm(e,t,n){t instanceof IP?(jm(e,t.left,n),jm(e,t.right,n)):t.toString().startsWith(e+".")&&n.push(t)}function Ol(e){if(e instanceof Iv||e instanceof Ov)return[Ol(e.left),e].flat();if(e instanceof Hn)return[e];if(e instanceof _v)return[Ol(e.left),Ol(e.right)].flat();if(e instanceof Nv){if(e.name==="where"&&!(e.args[0]instanceof Av))return[];if(e.name==="last")return[]}return[e]}const Qf=20;var ie=(e=>(e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing",e.IDENTIFIER="identifier",e.ITERATE="iterate",e))(ie||{});const NP={contains:"contains",exact:"exact",above:"above",below:"below",text:"text",not:"not",in:"in","not-in":"not-in","of-type":"of-type",missing:"missing",identifier:"identifier",iterate:"iterate"},Mv={eq:"eq",ne:"ne",lt:"lt",le:"le",gt:"gt",ge:"ge",sa:"sa",eb:"eb",ap:"ap"};function j$(e,t){if(!e)throw new Error("Invalid search URL");let n="",r;if(typeof e=="string")if(e.includes("?")){const[s,l]=e.split("?");n=s,r=new URLSearchParams(l)}else n=e;else typeof e=="object"&&(n=e.pathname,r=e.searchParams);let o;n.includes("/")?o=n.split("/").filter(Boolean).pop():o=n;const i=[];if(r&&i.push(...r.entries()),t)for(const[s,l]of Object.entries(t))if(Array.isArray(l))for(const c of l)i.push([s,c]);else i.push([s,l??""]);return P$(o,i)}function P$(e,t){const n={resourceType:e};for(const[r,o]of t)T$(n,r,o);return n}function T$(e,t,n){var s,l;let r,o;const i=t.indexOf(":");if(i>=0?(r=t.substring(0,i),o=t.substring(i+1)):(r=t,o=""),r!=="_"){if(r==="_has"||t.includes(".")){e.filters=dl(e.filters,{code:t,operator:"eq",value:n});return}switch(r){case"_sort":k$(e,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 c=G1(n);o==="iterate"&&(c.modifier="iterate"),e.include=dl(e.include,c);break}case"_revinclude":{const c=G1(n);o==="iterate"&&(c.modifier="iterate"),e.revInclude=dl(e.revInclude,c);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 c=(l=(s=Io.types[e.resourceType])==null?void 0:s.searchParams)==null?void 0:l[r];c?e.filters=dl(e.filters,R$(c,o,n)):e.filters=dl(e.filters,_$(r,o,n))}}}}function k$(e,t){for(const n of t.split(",")){let r,o=!1;n.startsWith("-")?(r=n.substring(1),o=!0):r=n,e.sortRules||(e.sortRules=[]),e.sortRules.push({code:r,descending:o})}}function R$(e,t,n){if(t==="missing")return{code:e.code,operator:"missing",value:n};switch(e.type){case"number":case"date":case"quantity":return D$(e,n);case"reference":case"string":case"token":case"uri":return I$(e,t,n);default:throw new Error("Unrecognized search parameter type: "+e.type)}}function D$(e,t){const{operator:n,value:r}=A$(t);return{code:e.code,operator:n,value:r}}function I$(e,t,n){return{code:e.code,operator:N$(t),value:n}}function _$(e,t,n){var o;let r="eq";if(t)r=t;else if(n.length>=2){const i=n.substring(0,2);i in Mv&&(n.length===2||(o=n.at(2))!=null&&o.match(/\d/))&&(r=i,n=n.substring(i.length))}return{code:e,operator:r,value:n}}function A$(e){const t=e.substring(0,2),n=Mv[t];return n?{operator:n,value:e.substring(2)}:{operator:"eq",value:e}}function N$(e){return NP[e]??"eq"}function G1(e){const t=e.split(":");if(t.includes("*"))throw new $e(pi("'*' is not supported as a value for search inclusion parameters"));if(t.length===1)throw new $e(pi(`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 $e(pi(`Invalid include value '${e}'`))}function ra(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach(n=>t.push(O$(n))),e.sortRules&&e.sortRules.length>0&&t.push(M$(e.sortRules)),e.offset!==void 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.include&&e.include.forEach(n=>t.push(Q1("_include",n))),e.revInclude&&e.revInclude.forEach(n=>t.push(Q1("_revinclude",n))),t.length===0?"":(t.sort((n,r)=>n.localeCompare(r)),"?"+t.join("&"))}function O$(e){const t=e.operator in NP?":"+e.operator:"",n=e.operator!=="eq"&&e.operator in Mv?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function M$(e){return"_sort="+e.map(t=>t.descending?"-"+t.code:t.code).join(",")}function Q1(e,t){return e+"="+t.resourceType+":"+t.searchParam+(t.targetType?":"+t.targetType:"")}function L$(e){if(typeof window<"u")return window.atob(e);if(typeof Buffer<"u")return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}function $$(e){if(typeof window<"u")return window.btoa(e);if(typeof Buffer<"u")return Buffer.from(e,"binary").toString("base64");throw new Error("Unable to encode base64")}function K1(){const e=new Uint32Array(28);return crypto.getRandomValues(e),bL(e.buffer)}async function F$(e){return crypto.subtle.digest("SHA-256",new TextEncoder().encode(e))}function OP(){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 MP(e){var o,i,s;const t={};e=co(e);for(const l of e.entry||[]){((o=l.resource)==null?void 0:o.meta)!==void 0&&(delete l.resource.meta.author,delete l.resource.meta.compartment,delete l.resource.meta.lastUpdated,delete l.resource.meta.project,delete l.resource.meta.versionId);const c=(i=l.resource)==null?void 0:i.id;c&&(t[c]=OP(),l.fullUrl="urn:uuid:"+t[c],(s=l.resource)==null||delete s.id)}const n=e.entry,r=JSON.stringify({resourceType:"Bundle",type:"transaction",entry:n==null?void 0:n.map(l=>({fullUrl:l.fullUrl,request:{method:"POST",url:l.resource.resourceType},resource:l.resource}))},(l,c)=>z$(l,c,t),2);return B$(JSON.parse(r))}function z$(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 o=n[r];if(o)return"urn:uuid:"+o}}return t}function B$(e){const t=V$(e),{sorted:n,cycles:r}=U$(t),o={};for(const s of e.entry||[])s.fullUrl&&(o[s.fullUrl]=s);const i=n.map(s=>o[s]);for(const s of r)for(const l of s){const c=o[l],u={...c,request:{...c.request,method:"PUT"}};i.push(u)}return{...e,entry:i}}function U$(e){const t=[],n={},r=[];for(const i of Object.keys(e))n[i]=0;function o(i,s){if(n[i]===2)return!0;if(n[i]===1){const c=s.lastIndexOf(i);return c!==-1&&r.push(s.slice(c)),!0}n[i]=1,s.push(i);let l=!1;for(const c of e[i])o(c,s)||(l=!0);return n[i]=2,s.pop(),t.unshift(i),!l}for(const i in e)n[i]===0&&o(i,[]);return{sorted:t,cycles:r}}function LP(e,t){for(const n in e)if(e[n]&&typeof e[n]=="object"){const r=e[n];if(Ps(r)){const o=r.reference;o.startsWith("urn:uuid:")&&t(o)}else LP(r,t)}}function V$(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&&LP(n.resource,o=>{t[o]&&t[o].push(r)})}return t}class $P{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 Gt={CSS:"text/css",DICOM:"application/dicom",FAVICON:"image/vnd.microsoft.icon",FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",HTML:"text/html",JAVASCRIPT:"text/javascript",JSON:"application/json",JSON_PATCH:"application/json-patch+json",PNG:"image/png",SCIM_JSON:"application/scim+json",SVG:"image/svg+xml",TEXT:"text/plain",TYPESCRIPT:"text/typescript",PING:"x-application/ping"};class FP{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 o=0;o<r.length;o++)if(r[o]===n){r.splice(o,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 Lv{constructor(){this.emitter=new FP}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 Pm={"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"},W$=["Patient","Encounter","ImagingStudy","DiagnosticReport","OperationOutcome","Bundle"],$v=["DiagnosticReport-update"];function H$(e){return $v.includes(e)}function q$(e){if($v.includes(e))throw new $e(vt(`'context.version' is required for '${e}'.`))}const G$={"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"},select:{resourceType:"*",isArray:!0}},"DiagnosticReport-update":{report:{resourceType:"DiagnosticReport"},patient:{resourceType:"Patient",optional:!0},study:{resourceType:"ImagingStudy",optional:!0},updates:{resourceType:"Bundle"}},syncerror:{operationoutcome:{resourceType:"OperationOutcome"}}};function Q$(e){return W$.includes(e)}function zP(e){return!!e.endpoint}function Y1(e){if(!Fv(e))throw new $e(vt("subscriptionRequest must be an object conforming to SubscriptionRequest type."));const{channelType:t,mode:n,topic:r,events:o}=e,i={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":o.join(",")};return zP(e)&&(i.endpoint=e.endpoint),new URLSearchParams(i).toString()}function Fv(e){if(typeof e!="object")return!1;const{channelType:t,mode:n,topic:r,events:o}=e;if(!(t&&n&&r&&o)||typeof r!="string"||typeof o!="object"||!Array.isArray(o)||o.length<1||t!=="websocket"||n!=="subscribe"&&n!=="unsubscribe")return!1;for(const i of o)if(!Pm[i])return!1;return!(zP(e)&&!(typeof e.endpoint=="string"&&e.endpoint.startsWith("ws")))}function X1(e,t,n,r){if(typeof t!="object")throw new $e(vt(`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 $e(vt(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new $e(vt(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));const o=r.resourceType;if(o!=="*"){if(!Q$(t.resourceType))throw new $e(vt(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(o&&t.resourceType!==o)throw new $e(vt(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${o}.`))}}function K$(e,t,n,r,o){if(o.set(t.key,(o.get(t.key)??0)+1),!r.isArray)X1(e,t.resource,n,r);else{const{resources:i}=t;if(!i)throw new $e(vt(`context[${n}] is invalid. context[${n}] for the '${e}' with key '${String(t.key)}' should contain an array of resources on the key 'resources'.`));for(const s of i)X1(e,s,n,r)}}function Y$(e,t){const n=new Map,r=G$[e];for(let o=0;o<t.length;o++){const i=t[o].key;if(!r[i])throw new $e(vt(`Key '${i}' not found for event '${e}'. Make sure to add only valid keys.`));K$(e,t[o],o,r[i],n)}for(const[o,i]of Object.entries(r)){if(!(i.optional||n.has(o)))throw new $e(vt(`Missing required key '${o}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(o)||0)>1)throw new $e(vt(`${n.get(o)} context entries with key '${o}' found for the '${e}' event when schema only allows for 1.`))}}function J1(e,t,n,r){if(!(e&&typeof e=="string"))throw new $e(vt("Must provide a topic."));if(!Pm[t])throw new $e(vt(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Pm).join(", ")}`));if(typeof n!="object")throw new $e(vt("context must be a context object or array of context objects."));if($v.includes(t)&&!r)throw new $e(vt(`The '${t}' event must contain a 'context.versionId'.`));const o=Array.isArray(n)?n:[n];return Y$(t,o),{timestamp:new Date().toISOString(),id:OP(),event:{"hub.topic":e,"hub.event":t,context:o,...r?{"context.versionId":r}:{}}}}class X$ extends Lv{constructor(t){if(super(),this.subRequest=t,!t.endpoint)throw new $e(vt("Subscription request should contain an endpoint."));if(!Fv(t))throw new $e(vt("Subscription request failed validation."));const n=new WebSocket(t.endpoint);n.addEventListener("open",()=>{this.dispatchEvent({type:"connect"}),n.addEventListener("message",r=>{const o=JSON.parse(r.data);if(o["hub.topic"])return;const i=o;i.event["hub.event"]!=="heartbeat"&&(this.dispatchEvent({type:"message",payload:i}),n.send(JSON.stringify({id:o==null?void 0:o.id,timestamp:new Date().toISOString()})))}),n.addEventListener("close",()=>{this.dispatchEvent({type:"disconnect"})})}),this.websocket=n}disconnect(){this.websocket.close()}}function J$(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=L$(t),r=Array.from(n).reduce((i,s)=>{const l=("00"+s.charCodeAt(0).toString(16)).slice(-2);return`${i}%${l}`},""),o=decodeURIComponent(r);return JSON.parse(o)}function Z$(e){return e.split(".").length===3}function zv(e){const[t,n,r]=e.split(".");return J$(n)}function e7(e){try{return typeof zv(e).login_id=="string"}catch{return!1}}function t7(e){try{const n=zv(e).exp;return typeof n=="number"?n*1e3:void 0}catch{return}}class n7{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)}async delete(t){await this.medplum.delete(`keyvalue/v1/${t}`)}}var Z1;class Pr{constructor(t){this[Z1]="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)}}Z1=Symbol.toStringTag;class r7{constructor(t){this.storage=t??(typeof localStorage<"u"?localStorage:new o7)}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?tr(n):void 0)}}class o7{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]}}class i7 extends Lv{constructor(t){super(),this.bufferedAmount=-1/0,this.extensions="NOT_IMPLEMENTED",this.messageBuffer=[];const n=new WebSocket(t);n.addEventListener("open",()=>{if(this.messageBuffer.length){const r=this.messageBuffer;for(const o of r)n.send(o)}this.dispatchEvent(new Event("open"))}),n.addEventListener("error",r=>{this.dispatchEvent(r)}),n.addEventListener("message",r=>{this.dispatchEvent(r)}),n.addEventListener("close",r=>{this.dispatchEvent(r)}),this.ws=n}get readyState(){return this.ws.readyState}close(){this.ws.close()}send(t){if(this.ws.readyState!==WebSocket.OPEN){this.messageBuffer.push(t);return}try{this.ws.send(t)}catch(n){this.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message})),this.messageBuffer.push(t)}}}class Tm extends Lv{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 s7{constructor(t){this.criteria=t,this.emitter=new Tm(t),this.refCount=1}}class a7{constructor(t,n,r){if(!(t instanceof BP))throw new $e(vt("First arg of constructor should be a `MedplumClient`"));let o;try{o=new URL(n).toString()}catch{throw new $e(vt("Not a valid URL"))}const i=r!=null&&r.RobustWebSocket?new r.RobustWebSocket(o):new i7(o);this.medplum=t,this.ws=i,this.masterSubEmitter=new Tm,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.setupWebSocketListeners()}setupWebSocketListeners(){const t=this.ws;t.addEventListener("message",n=>{var r,o,i,s,l;try{const c=JSON.parse(n.data),u=(o=(r=c==null?void 0:c.entry)==null?void 0:r[0])==null?void 0:o.resource;if(u.type==="heartbeat"){(i=this.masterSubEmitter)==null||i.dispatchEvent({type:"heartbeat",payload:c});return}(s=this.masterSubEmitter)==null||s.dispatchEvent({type:"message",payload:c});const d=this.criteriaEntriesBySubscriptionId.get(Hf(u.subscription));if(!d){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}d.emitter.dispatchEvent({type:"message",payload:c})}catch(c){console.error(c);const u={type:"error",payload:c};(l=this.masterSubEmitter)==null||l.dispatchEvent(u);for(const{emitter:d}of this.criteriaEntries.values())d.dispatchEvent(u)}}),t.addEventListener("error",()=>{var r;const n={type:"error",payload:new $e(ZO(new Error("WebSocket error")))};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)}),t.addEventListener("close",()=>{var r;const n={type:"close"};this.wsClosed&&((r=this.masterSubEmitter)==null||r.dispatchEvent(n));for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)})}emitConnect(t){var r;const n={type:"connect",payload:{subscriptionId:t}};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)}emitError(t,n){var o,i,s;const r={type:"error",payload:n};(o=this.masterSubEmitter)==null||o.dispatchEvent(r),(s=(i=this.criteriaEntries.get(t))==null?void 0:i.emitter)==null||s.dispatchEvent(r)}async getTokenForCriteria(t){var s,l;let n=t==null?void 0:t.subscriptionId;n||(n=(await this.medplum.createResource({resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${ht(this.medplum.getProfile())}`,criteria:t.criteria,channel:{type:"websocket"}})).id);const{parameter:r}=await this.medplum.get(`/fhir/R4/Subscription/${n}/$get-ws-binding-token`),o=(s=r==null?void 0:r.find(c=>c.name==="token"))==null?void 0:s.valueString,i=(l=r==null?void 0:r.find(c=>c.name==="websocket-url"))==null?void 0:l.valueUrl;if(!o)throw new $e(vt("Failed to get token"));if(!i)throw new $e(vt("Failed to get URL from $get-ws-binding-token"));return[n,o]}addCriteria(t){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const n=this.criteriaEntries.get(t);if(n)return n.refCount+=1,n.emitter;const r=new s7(t);return this.criteriaEntries.set(t,r),this.getTokenForCriteria(r).then(([o,i])=>{r.subscriptionId=o,this.criteriaEntriesBySubscriptionId.set(o,r),this.emitConnect(o),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:i}}))}).catch(o=>{console.error(o.message),this.emitError(t,o),this.criteriaEntries.delete(t)}),r.emitter}removeCriteria(t){var i,s,l;const n=this.criteriaEntries.get(t);if(!n){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}if(n.refCount-=1,n.refCount>0)return;const r=(i=this.criteriaEntries.get(t))==null?void 0:i.subscriptionId,o={type:"disconnect",payload:{subscriptionId:r}};this.masterSubEmitter&&(this.masterSubEmitter._removeCriteria(t),this.masterSubEmitter.dispatchEvent(o)),(l=(s=this.criteriaEntries.get(t))==null?void 0:s.emitter)==null||l.dispatchEvent(o),this.criteriaEntries.delete(t),r&&this.criteriaEntriesBySubscriptionId.delete(r)}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}getCriteriaCount(){return this.criteriaEntries.size}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new Tm(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const l7="3.0.12-787031d28",c7=Gt.FHIR_JSON+", */*; q=0.1",u7="https://api.medplum.com/",d7=1e3,f7=6e4,h7=0,p7="Binary/",ew={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]};class BP extends FP{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");if(this.options=t??{},this.fetch=(t==null?void 0:t.fetch)??m7(),this.storage=(t==null?void 0:t.storage)??new r7,this.createPdfImpl=t==null?void 0:t.createPdf,this.baseUrl=nw((t==null?void 0:t.baseUrl)??u7),this.fhirBaseUrl=nw(ku(this.baseUrl,(t==null?void 0:t.fhirUrlPath)??"fhir/R4/")),this.authorizeUrl=ku(this.baseUrl,(t==null?void 0:t.authorizeUrl)??"oauth2/authorize"),this.tokenUrl=ku(this.baseUrl,(t==null?void 0:t.tokenUrl)??"oauth2/token"),this.logoutUrl=ku(this.baseUrl,(t==null?void 0:t.logoutUrl)??"oauth2/logout"),this.clientId=(t==null?void 0:t.clientId)??"",this.clientSecret=(t==null?void 0:t.clientSecret)??"",this.onUnauthenticated=t==null?void 0:t.onUnauthenticated,this.cacheTime=(t==null?void 0:t.cacheTime)??(typeof window>"u"?h7:f7),this.cacheTime>0?this.requestCache=new $P((t==null?void 0:t.resourceCacheSize)??d7):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.initPromise=Promise.resolve();else if(this.storage.getInitPromise!==void 0){const n=this.storage.getInitPromise(),r=new Promise((o,i)=>{n.then(()=>{this.attemptResumeActiveLogin().then(o).catch(s=>{console.error(s),o()}),this.initComplete=!0}).catch(i)});this.initPromise=r,this.initComplete=!1}else this.initPromise=this.attemptResumeActiveLogin().catch(console.error);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}clear(){this.storage.clear(),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=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 o;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue?o=new Promise((s,l)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:s,reject:l}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):o=this.request("GET",t,n);const i=new Pr(o);return this.setCacheEntry(t,i),i}post(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("POST",t,o)}put(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("PUT",t,o)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,Gt.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:o}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:o},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,o,i=!0){let s=o;i&&(s=await this.ensureCodeChallenge(o)),window.location.assign(this.getExternalAuthRedirectUri(t,n,r,s,i))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");const r=new URLSearchParams;return r.set("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),r.set("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),r.set("client_id",n),r.set("subject_token",t),this.fetchTokens(r)}getExternalAuthRedirectUri(t,n,r,o,i=!0){const s=new URL(t);if(s.searchParams.set("response_type","code"),s.searchParams.set("client_id",n),s.searchParams.set("redirect_uri",r),s.searchParams.set("scope",o.scope??"openid profile email"),s.searchParams.set("state",JSON.stringify(o)),i){const{codeChallenge:l,codeChallengeMethod:c}=o;if(!c)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!l)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");s.searchParams.set("code_challenge_method",c),s.searchParams.set("code_challenge",l)}return s.toString()}fhirUrl(...t){return new URL(t.join("/"),this.fhirBaseUrl)}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=new URLSearchParams(n).toString()),r}search(t,n,r){const o=this.fhirSearchUrl(t,n),i="search-"+o.toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr((async()=>{const c=await this.get(o,r);if(c.entry)for(const u of c.entry)this.cacheResource(u.resource);return c})());return this.setCacheEntry(i,l),l}searchOne(t,n,r){const o=this.fhirSearchUrl(t,n);o.searchParams.set("_count","1"),o.searchParams.sort();const i="searchOne-"+o.toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr(this.search(t,o.searchParams,r).then(c=>{var u,d;return(d=(u=c.entry)==null?void 0:u[0])==null?void 0:d.resource}));return this.setCacheEntry(i,l),l}searchResources(t,n,r){const i="searchResources-"+this.fhirSearchUrl(t,n).toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr(this.search(t,n,r).then(rp));return this.setCacheEntry(i,l),l}async*searchResourcePages(t,n,r){var i,s;let o=this.fhirSearchUrl(t,n);for(;o;){const l=new URL(o).searchParams,c=await this.search(t,l,r),u=(i=c.link)==null?void 0:i.find(d=>d.relation==="next");if(!((s=c.entry)!=null&&s.length)&&!u)break;yield rp(c),o=u!=null&&u.url?new URL(u.url):void 0}}searchValueSet(t,n,r){return this.valueSetExpand({url:t,filter:n},r)}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 o,i;const r=(i=(o=this.requestCache)==null?void 0:o.get(this.fhirUrl(t,n).toString()))==null?void 0:i.value;return r!=null&&r.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return ew;const[r,o]=n.split("/");if(!(!r||!o))return this.getCached(r,o)}readResource(t,n,r){return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Pr(Promise.reject(new Error("Missing reference")));if(r==="system")return new Pr(Promise.resolve(ew));const[o,i]=r.split("/");return!o||!i?new Pr(Promise.reject(new Error("Invalid reference"))):this.readResource(o,i,n)}requestSchema(t){if(hP(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const o=new Pr((async()=>{const i=`{
85
+ `?(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 a$(e){return!!(e&&(e.id==="String"||e.id==="Symbol"&&i$.includes(e.value)))}const l$=["true","false"],c$=["!=","!~","<=",">=","{}","->"];function u$(e){return new s$(e,l$,c$).tokenize()}const Je={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide: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,Arrow:100,Semicolon:200},d$={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}},f$={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new Ov(t,n)},precedence:Je.Indexer},h$={parse(e,t){if(!(t instanceof Dv))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Nv(t.name,n)},precedence:Je.FunctionCall};function p$(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 m$(){return new UO().registerPrefix("String",{parse:(e,t)=>new Fs({type:V.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new Fs({type:V.dateTime,value:Yu(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new Fs({type:V.Quantity,value:p$(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new Fs({type:t.value.includes(".")?V.decimal:V.integer,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new Fs({type:V.boolean,value:!0})}).registerPrefix("false",{parse:()=>new Fs({type:V.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new Dv(t.value)}).registerPrefix("{}",{parse:()=>new qL}).registerPrefix("(",d$).registerInfix("[",f$).registerInfix("(",h$).prefix("+",Je.UnaryAdd,(e,t)=>new GL("+",t,n=>n)).prefix("-",Je.UnarySubtract,(e,t)=>new jr("-",t,t,(n,r)=>-r)).infixLeft(".",Je.Dot,(e,t,n)=>new _v(e,n)).infixLeft("/",Je.Divide,(e,t,n)=>new jr("/",e,n,(r,o)=>r/o)).infixLeft("*",Je.Multiply,(e,t,n)=>new jr("*",e,n,(r,o)=>r*o)).infixLeft("+",Je.Add,(e,t,n)=>new jr("+",e,n,(r,o)=>r+o)).infixLeft("-",Je.Subtract,(e,t,n)=>new jr("-",e,n,(r,o)=>r-o)).infixLeft("|",Je.Union,(e,t,n)=>new IP(e,n)).infixLeft("=",Je.Equals,(e,t,n)=>new XL(e,n)).infixLeft("!=",Je.NotEquals,(e,t,n)=>new JL(e,n)).infixLeft("~",Je.Equivalent,(e,t,n)=>new ZL(e,n)).infixLeft("!~",Je.NotEquivalent,(e,t,n)=>new e$(e,n)).infixLeft("<",Je.LessThan,(e,t,n)=>new jr("<",e,n,(r,o)=>r<o)).infixLeft("<=",Je.LessThanOrEquals,(e,t,n)=>new jr("<=",e,n,(r,o)=>r<=o)).infixLeft(">",Je.GreaterThan,(e,t,n)=>new jr(">",e,n,(r,o)=>r>o)).infixLeft(">=",Je.GreaterThanOrEquals,(e,t,n)=>new jr(">=",e,n,(r,o)=>r>=o)).infixLeft("&",Je.Ampersand,(e,t,n)=>new QL(e,n)).infixLeft("and",Je.And,(e,t,n)=>new t$(e,n)).infixLeft("as",Je.As,(e,t,n)=>new Iv(e,n)).infixLeft("contains",Je.Contains,(e,t,n)=>new KL(e,n)).infixLeft("div",Je.Divide,(e,t,n)=>new jr("div",e,n,(r,o)=>r/o|0)).infixLeft("in",Je.In,(e,t,n)=>new YL(e,n)).infixLeft("is",Je.Is,(e,t,n)=>new Av(e,n)).infixLeft("mod",Je.Modulo,(e,t,n)=>new jr("mod",e,n,(r,o)=>r%o)).infixLeft("or",Je.Or,(e,t,n)=>new n$(e,n)).infixLeft("xor",Je.Xor,(e,t,n)=>new r$(e,n)).infixLeft("implies",Je.Implies,(e,t,n)=>new o$(e,n))}const g$=m$();function _P(e){return new HL(e,g$.construct(u$(e)).consumeAndParse())}function y$(e,t){const n=Array.isArray(t)?t:[t];for(let r=0;r<n.length;r++){const o=n[r];typeof o=="object"&&"type"in o&&"value"in o||(n[r]=lo(n[r]))}return lc(e,n).map(r=>r.value)}function lc(e,t,n){const r=n??{};return _P(e).eval({variables:r},t).map(i=>{var s;return{type:i.type,value:(s=i.value)==null?void 0:s.valueOf()}})}var Jo=(e=>(e.BOOLEAN="BOOLEAN",e.NUMBER="NUMBER",e.QUANTITY="QUANTITY",e.TEXT="TEXT",e.REFERENCE="REFERENCE",e.CANONICAL="CANONICAL",e.DATE="DATE",e.DATETIME="DATETIME",e.PERIOD="PERIOD",e.UUID="UUID",e))(Jo||{});function Gf(e,t){var r,o;let n=(o=(r=Io.types[e])==null?void 0:r.searchParamsDetails)==null?void 0:o[t.code];return n||(n=x$(e,t)),n}function v$(e,t,n){let r=Io.types[e];r||(r={},Io.types[e]=r),r.searchParamsDetails||(r.searchParamsDetails={}),r.searchParamsDetails[t]=n}function x$(e,t){const n=t.code,r=b$(n),o=E$(e,t.expression),i={elementDefinitions:[],propertyTypes:new Set,array:!1};for(const l of o){const c=Ol(l),u=TL(()=>c.join("."));c.length===1&&c[0]instanceof Hn?i.propertyTypes.add("boolean"):u().endsWith("extension.value.code")||u().endsWith("extension.value.coding.code")?(i.array=!0,i.propertyTypes.add("code")):AP(i,Ol(l),e,1),u().endsWith("extension.valueDateTime")&&(i.array=!1)}const s={columnName:r,type:C$(t,i.propertyTypes),elementDefinitions:i.elementDefinitions,array:i.array};return v$(e,n,s),s}function AP(e,t,n,r){const o=t[r];if(o instanceof Iv){e.propertyTypes.add(o.right.toString());return}if(o instanceof Nv){w$(e,o);return}const i=o.toString(),s=js(n,i);if(!s)throw new Error(`Element definition not found for ${n} ${i}`);let l=!1,c=r+1;if(c<t.length&&t[c]instanceof Ov&&(l=!0,c++),s.isArray&&!l&&(e.array=!0),c>=t.length){e.elementDefinitions.push(s);for(const u of s.type)e.propertyTypes.add(u.code);return}for(const u of s.type){let d=u.code;S$(d)&&(d=s.type[0].code),AP(e,t,d,c)}}function w$(e,t){if(t.name==="as"){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 Av){e.propertyTypes.add(t.args[0].right.toString());return}throw new Error(`Unhandled FHIRPath function: ${t.name}`)}function S$(e){return e==="Element"||e==="BackboneElement"}function b$(e){return e.split("-").reduce((t,n,r)=>t+(r?Vt(n):n),"")}function C$(e,t){switch(e.type){case"date":return t.size===1&&t.has(V.date)?"DATE":"DATETIME";case"number":return"NUMBER";case"quantity":return"QUANTITY";case"reference":return t.has(V.canonical)?"CANONICAL":"REFERENCE";case"token":return t.size===1&&t.has(V.boolean)?"BOOLEAN":"TEXT";default:return"TEXT"}}function E$(e,t){const n=[],r=_P(t);return jm(e,r.child,n),n}function jm(e,t,n){t instanceof IP?(jm(e,t.left,n),jm(e,t.right,n)):t.toString().startsWith(e+".")&&n.push(t)}function Ol(e){if(e instanceof Iv||e instanceof Ov)return[Ol(e.left),e].flat();if(e instanceof Hn)return[e];if(e instanceof _v)return[Ol(e.left),Ol(e.right)].flat();if(e instanceof Nv){if(e.name==="where"&&!(e.args[0]instanceof Av))return[];if(e.name==="last")return[]}return[e]}const Qf=20;var ie=(e=>(e.EQUALS="eq",e.NOT_EQUALS="ne",e.GREATER_THAN="gt",e.LESS_THAN="lt",e.GREATER_THAN_OR_EQUALS="ge",e.LESS_THAN_OR_EQUALS="le",e.STARTS_AFTER="sa",e.ENDS_BEFORE="eb",e.APPROXIMATELY="ap",e.CONTAINS="contains",e.EXACT="exact",e.TEXT="text",e.NOT="not",e.ABOVE="above",e.BELOW="below",e.IN="in",e.NOT_IN="not-in",e.OF_TYPE="of-type",e.MISSING="missing",e.IDENTIFIER="identifier",e.ITERATE="iterate",e))(ie||{});const NP={contains:"contains",exact:"exact",above:"above",below:"below",text:"text",not:"not",in:"in","not-in":"not-in","of-type":"of-type",missing:"missing",identifier:"identifier",iterate:"iterate"},Mv={eq:"eq",ne:"ne",lt:"lt",le:"le",gt:"gt",ge:"ge",sa:"sa",eb:"eb",ap:"ap"};function j$(e,t){if(!e)throw new Error("Invalid search URL");let n="",r;if(typeof e=="string")if(e.includes("?")){const[s,l]=e.split("?");n=s,r=new URLSearchParams(l)}else n=e;else typeof e=="object"&&(n=e.pathname,r=e.searchParams);let o;n.includes("/")?o=n.split("/").filter(Boolean).pop():o=n;const i=[];if(r&&i.push(...r.entries()),t)for(const[s,l]of Object.entries(t))if(Array.isArray(l))for(const c of l)i.push([s,c]);else i.push([s,l??""]);return P$(o,i)}function P$(e,t){const n={resourceType:e};for(const[r,o]of t)T$(n,r,o);return n}function T$(e,t,n){var s,l;let r,o;const i=t.indexOf(":");if(i>=0?(r=t.substring(0,i),o=t.substring(i+1)):(r=t,o=""),r!=="_"){if(r==="_has"||t.includes(".")){e.filters=dl(e.filters,{code:t,operator:"eq",value:n});return}switch(r){case"_sort":k$(e,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 c=G1(n);o==="iterate"&&(c.modifier="iterate"),e.include=dl(e.include,c);break}case"_revinclude":{const c=G1(n);o==="iterate"&&(c.modifier="iterate"),e.revInclude=dl(e.revInclude,c);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 c=(l=(s=Io.types[e.resourceType])==null?void 0:s.searchParams)==null?void 0:l[r];c?e.filters=dl(e.filters,R$(c,o,n)):e.filters=dl(e.filters,_$(r,o,n))}}}}function k$(e,t){for(const n of t.split(",")){let r,o=!1;n.startsWith("-")?(r=n.substring(1),o=!0):r=n,e.sortRules||(e.sortRules=[]),e.sortRules.push({code:r,descending:o})}}function R$(e,t,n){if(t==="missing")return{code:e.code,operator:"missing",value:n};switch(e.type){case"number":case"date":case"quantity":return D$(e,n);case"reference":case"string":case"token":case"uri":return I$(e,t,n);default:throw new Error("Unrecognized search parameter type: "+e.type)}}function D$(e,t){const{operator:n,value:r}=A$(t);return{code:e.code,operator:n,value:r}}function I$(e,t,n){return{code:e.code,operator:N$(t),value:n}}function _$(e,t,n){var o;let r="eq";if(t)r=t;else if(n.length>=2){const i=n.substring(0,2);i in Mv&&(n.length===2||(o=n.at(2))!=null&&o.match(/\d/))&&(r=i,n=n.substring(i.length))}return{code:e,operator:r,value:n}}function A$(e){const t=e.substring(0,2),n=Mv[t];return n?{operator:n,value:e.substring(2)}:{operator:"eq",value:e}}function N$(e){return NP[e]??"eq"}function G1(e){const t=e.split(":");if(t.includes("*"))throw new $e(pi("'*' is not supported as a value for search inclusion parameters"));if(t.length===1)throw new $e(pi(`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 $e(pi(`Invalid include value '${e}'`))}function ra(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach(n=>t.push(O$(n))),e.sortRules&&e.sortRules.length>0&&t.push(M$(e.sortRules)),e.offset!==void 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.include&&e.include.forEach(n=>t.push(Q1("_include",n))),e.revInclude&&e.revInclude.forEach(n=>t.push(Q1("_revinclude",n))),t.length===0?"":(t.sort((n,r)=>n.localeCompare(r)),"?"+t.join("&"))}function O$(e){const t=e.operator in NP?":"+e.operator:"",n=e.operator!=="eq"&&e.operator in Mv?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function M$(e){return"_sort="+e.map(t=>t.descending?"-"+t.code:t.code).join(",")}function Q1(e,t){return e+"="+t.resourceType+":"+t.searchParam+(t.targetType?":"+t.targetType:"")}function L$(e){if(typeof window<"u")return window.atob(e);if(typeof Buffer<"u")return Buffer.from(e,"base64").toString("binary");throw new Error("Unable to decode base64")}function $$(e){if(typeof window<"u")return window.btoa(e);if(typeof Buffer<"u")return Buffer.from(e,"binary").toString("base64");throw new Error("Unable to encode base64")}function K1(){const e=new Uint32Array(28);return crypto.getRandomValues(e),bL(e.buffer)}async function F$(e){return crypto.subtle.digest("SHA-256",new TextEncoder().encode(e))}function OP(){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 MP(e){var o,i,s;const t={};e=co(e);for(const l of e.entry||[]){((o=l.resource)==null?void 0:o.meta)!==void 0&&(delete l.resource.meta.author,delete l.resource.meta.compartment,delete l.resource.meta.lastUpdated,delete l.resource.meta.project,delete l.resource.meta.versionId);const c=(i=l.resource)==null?void 0:i.id;c&&(t[c]=OP(),l.fullUrl="urn:uuid:"+t[c],(s=l.resource)==null||delete s.id)}const n=e.entry,r=JSON.stringify({resourceType:"Bundle",type:"transaction",entry:n==null?void 0:n.map(l=>({fullUrl:l.fullUrl,request:{method:"POST",url:l.resource.resourceType},resource:l.resource}))},(l,c)=>z$(l,c,t),2);return B$(JSON.parse(r))}function z$(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 o=n[r];if(o)return"urn:uuid:"+o}}return t}function B$(e){const t=V$(e),{sorted:n,cycles:r}=U$(t),o={};for(const s of e.entry||[])s.fullUrl&&(o[s.fullUrl]=s);const i=n.map(s=>o[s]);for(const s of r)for(const l of s){const c=o[l],u={...c,request:{...c.request,method:"PUT"}};i.push(u)}return{...e,entry:i}}function U$(e){const t=[],n={},r=[];for(const i of Object.keys(e))n[i]=0;function o(i,s){if(n[i]===2)return!0;if(n[i]===1){const c=s.lastIndexOf(i);return c!==-1&&r.push(s.slice(c)),!0}n[i]=1,s.push(i);let l=!1;for(const c of e[i])o(c,s)||(l=!0);return n[i]=2,s.pop(),t.unshift(i),!l}for(const i in e)n[i]===0&&o(i,[]);return{sorted:t,cycles:r}}function LP(e,t){for(const n in e)if(e[n]&&typeof e[n]=="object"){const r=e[n];if(Ps(r)){const o=r.reference;o.startsWith("urn:uuid:")&&t(o)}else LP(r,t)}}function V$(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&&LP(n.resource,o=>{t[o]&&t[o].push(r)})}return t}class $P{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 Gt={CSS:"text/css",DICOM:"application/dicom",FAVICON:"image/vnd.microsoft.icon",FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",HTML:"text/html",JAVASCRIPT:"text/javascript",JSON:"application/json",JSON_PATCH:"application/json-patch+json",PNG:"image/png",SCIM_JSON:"application/scim+json",SVG:"image/svg+xml",TEXT:"text/plain",TYPESCRIPT:"text/typescript",PING:"x-application/ping"};class FP{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 o=0;o<r.length;o++)if(r[o]===n){r.splice(o,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 Lv{constructor(){this.emitter=new FP}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 Pm={"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"},W$=["Patient","Encounter","ImagingStudy","DiagnosticReport","OperationOutcome","Bundle"],$v=["DiagnosticReport-update"];function H$(e){return $v.includes(e)}function q$(e){if($v.includes(e))throw new $e(vt(`'context.version' is required for '${e}'.`))}const G$={"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"},select:{resourceType:"*",isArray:!0}},"DiagnosticReport-update":{report:{resourceType:"DiagnosticReport"},patient:{resourceType:"Patient",optional:!0},study:{resourceType:"ImagingStudy",optional:!0},updates:{resourceType:"Bundle"}},syncerror:{operationoutcome:{resourceType:"OperationOutcome"}}};function Q$(e){return W$.includes(e)}function zP(e){return!!e.endpoint}function Y1(e){if(!Fv(e))throw new $e(vt("subscriptionRequest must be an object conforming to SubscriptionRequest type."));const{channelType:t,mode:n,topic:r,events:o}=e,i={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":o.join(",")};return zP(e)&&(i.endpoint=e.endpoint),new URLSearchParams(i).toString()}function Fv(e){if(typeof e!="object")return!1;const{channelType:t,mode:n,topic:r,events:o}=e;if(!(t&&n&&r&&o)||typeof r!="string"||typeof o!="object"||!Array.isArray(o)||o.length<1||t!=="websocket"||n!=="subscribe"&&n!=="unsubscribe")return!1;for(const i of o)if(!Pm[i])return!1;return!(zP(e)&&!(typeof e.endpoint=="string"&&e.endpoint.startsWith("ws")))}function X1(e,t,n,r){if(typeof t!="object")throw new $e(vt(`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 $e(vt(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new $e(vt(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));const o=r.resourceType;if(o!=="*"){if(!Q$(t.resourceType))throw new $e(vt(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(o&&t.resourceType!==o)throw new $e(vt(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${o}.`))}}function K$(e,t,n,r,o){if(o.set(t.key,(o.get(t.key)??0)+1),!r.isArray)X1(e,t.resource,n,r);else{const{resources:i}=t;if(!i)throw new $e(vt(`context[${n}] is invalid. context[${n}] for the '${e}' with key '${String(t.key)}' should contain an array of resources on the key 'resources'.`));for(const s of i)X1(e,s,n,r)}}function Y$(e,t){const n=new Map,r=G$[e];for(let o=0;o<t.length;o++){const i=t[o].key;if(!r[i])throw new $e(vt(`Key '${i}' not found for event '${e}'. Make sure to add only valid keys.`));K$(e,t[o],o,r[i],n)}for(const[o,i]of Object.entries(r)){if(!(i.optional||n.has(o)))throw new $e(vt(`Missing required key '${o}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(o)||0)>1)throw new $e(vt(`${n.get(o)} context entries with key '${o}' found for the '${e}' event when schema only allows for 1.`))}}function J1(e,t,n,r){if(!(e&&typeof e=="string"))throw new $e(vt("Must provide a topic."));if(!Pm[t])throw new $e(vt(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Pm).join(", ")}`));if(typeof n!="object")throw new $e(vt("context must be a context object or array of context objects."));if($v.includes(t)&&!r)throw new $e(vt(`The '${t}' event must contain a 'context.versionId'.`));const o=Array.isArray(n)?n:[n];return Y$(t,o),{timestamp:new Date().toISOString(),id:OP(),event:{"hub.topic":e,"hub.event":t,context:o,...r?{"context.versionId":r}:{}}}}class X$ extends Lv{constructor(t){if(super(),this.subRequest=t,!t.endpoint)throw new $e(vt("Subscription request should contain an endpoint."));if(!Fv(t))throw new $e(vt("Subscription request failed validation."));const n=new WebSocket(t.endpoint);n.addEventListener("open",()=>{this.dispatchEvent({type:"connect"}),n.addEventListener("message",r=>{const o=JSON.parse(r.data);if(o["hub.topic"])return;const i=o;i.event["hub.event"]!=="heartbeat"&&(this.dispatchEvent({type:"message",payload:i}),n.send(JSON.stringify({id:o==null?void 0:o.id,timestamp:new Date().toISOString()})))}),n.addEventListener("close",()=>{this.dispatchEvent({type:"disconnect"})})}),this.websocket=n}disconnect(){this.websocket.close()}}function J$(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=L$(t),r=Array.from(n).reduce((i,s)=>{const l=("00"+s.charCodeAt(0).toString(16)).slice(-2);return`${i}%${l}`},""),o=decodeURIComponent(r);return JSON.parse(o)}function Z$(e){return e.split(".").length===3}function zv(e){const[t,n,r]=e.split(".");return J$(n)}function e7(e){try{return typeof zv(e).login_id=="string"}catch{return!1}}function t7(e){try{const n=zv(e).exp;return typeof n=="number"?n*1e3:void 0}catch{return}}class n7{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)}async delete(t){await this.medplum.delete(`keyvalue/v1/${t}`)}}var Z1;class Pr{constructor(t){this[Z1]="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)}}Z1=Symbol.toStringTag;class r7{constructor(t){this.storage=t??(typeof localStorage<"u"?localStorage:new o7)}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?tr(n):void 0)}}class o7{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]}}class i7 extends Lv{constructor(t){super(),this.bufferedAmount=-1/0,this.extensions="NOT_IMPLEMENTED",this.messageBuffer=[];const n=new WebSocket(t);n.addEventListener("open",()=>{if(this.messageBuffer.length){const r=this.messageBuffer;for(const o of r)n.send(o)}this.dispatchEvent(new Event("open"))}),n.addEventListener("error",r=>{this.dispatchEvent(r)}),n.addEventListener("message",r=>{this.dispatchEvent(r)}),n.addEventListener("close",r=>{this.dispatchEvent(r)}),this.ws=n}get readyState(){return this.ws.readyState}close(){this.ws.close()}send(t){if(this.ws.readyState!==WebSocket.OPEN){this.messageBuffer.push(t);return}try{this.ws.send(t)}catch(n){this.dispatchEvent(new ErrorEvent("error",{error:n,message:n.message})),this.messageBuffer.push(t)}}}class Tm extends Lv{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 s7{constructor(t){this.criteria=t,this.emitter=new Tm(t),this.refCount=1}}class a7{constructor(t,n,r){if(!(t instanceof BP))throw new $e(vt("First arg of constructor should be a `MedplumClient`"));let o;try{o=new URL(n).toString()}catch{throw new $e(vt("Not a valid URL"))}const i=r!=null&&r.RobustWebSocket?new r.RobustWebSocket(o):new i7(o);this.medplum=t,this.ws=i,this.masterSubEmitter=new Tm,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.setupWebSocketListeners()}setupWebSocketListeners(){const t=this.ws;t.addEventListener("message",n=>{var r,o,i,s,l;try{const c=JSON.parse(n.data),u=(o=(r=c==null?void 0:c.entry)==null?void 0:r[0])==null?void 0:o.resource;if(u.type==="heartbeat"){(i=this.masterSubEmitter)==null||i.dispatchEvent({type:"heartbeat",payload:c});return}(s=this.masterSubEmitter)==null||s.dispatchEvent({type:"message",payload:c});const d=this.criteriaEntriesBySubscriptionId.get(Hf(u.subscription));if(!d){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}d.emitter.dispatchEvent({type:"message",payload:c})}catch(c){console.error(c);const u={type:"error",payload:c};(l=this.masterSubEmitter)==null||l.dispatchEvent(u);for(const{emitter:d}of this.criteriaEntries.values())d.dispatchEvent(u)}}),t.addEventListener("error",()=>{var r;const n={type:"error",payload:new $e(ZO(new Error("WebSocket error")))};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)}),t.addEventListener("close",()=>{var r;const n={type:"close"};this.wsClosed&&((r=this.masterSubEmitter)==null||r.dispatchEvent(n));for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)})}emitConnect(t){var r;const n={type:"connect",payload:{subscriptionId:t}};(r=this.masterSubEmitter)==null||r.dispatchEvent(n);for(const{emitter:o}of this.criteriaEntries.values())o.dispatchEvent(n)}emitError(t,n){var o,i,s;const r={type:"error",payload:n};(o=this.masterSubEmitter)==null||o.dispatchEvent(r),(s=(i=this.criteriaEntries.get(t))==null?void 0:i.emitter)==null||s.dispatchEvent(r)}async getTokenForCriteria(t){var s,l;let n=t==null?void 0:t.subscriptionId;n||(n=(await this.medplum.createResource({resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${ht(this.medplum.getProfile())}`,criteria:t.criteria,channel:{type:"websocket"}})).id);const{parameter:r}=await this.medplum.get(`/fhir/R4/Subscription/${n}/$get-ws-binding-token`),o=(s=r==null?void 0:r.find(c=>c.name==="token"))==null?void 0:s.valueString,i=(l=r==null?void 0:r.find(c=>c.name==="websocket-url"))==null?void 0:l.valueUrl;if(!o)throw new $e(vt("Failed to get token"));if(!i)throw new $e(vt("Failed to get URL from $get-ws-binding-token"));return[n,o]}addCriteria(t){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const n=this.criteriaEntries.get(t);if(n)return n.refCount+=1,n.emitter;const r=new s7(t);return this.criteriaEntries.set(t,r),this.getTokenForCriteria(r).then(([o,i])=>{r.subscriptionId=o,this.criteriaEntriesBySubscriptionId.set(o,r),this.emitConnect(o),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:i}}))}).catch(o=>{console.error(o.message),this.emitError(t,o),this.criteriaEntries.delete(t)}),r.emitter}removeCriteria(t){var i,s,l;const n=this.criteriaEntries.get(t);if(!n){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}if(n.refCount-=1,n.refCount>0)return;const r=(i=this.criteriaEntries.get(t))==null?void 0:i.subscriptionId,o={type:"disconnect",payload:{subscriptionId:r}};this.masterSubEmitter&&(this.masterSubEmitter._removeCriteria(t),this.masterSubEmitter.dispatchEvent(o)),(l=(s=this.criteriaEntries.get(t))==null?void 0:s.emitter)==null||l.dispatchEvent(o),this.criteriaEntries.delete(t),r&&this.criteriaEntriesBySubscriptionId.delete(r)}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}getCriteriaCount(){return this.criteriaEntries.size}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new Tm(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const l7="3.0.13-ced876fb4",c7=Gt.FHIR_JSON+", */*; q=0.1",u7="https://api.medplum.com/",d7=1e3,f7=6e4,h7=0,p7="Binary/",ew={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]};class BP extends FP{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)??m7(),this.storage=(t==null?void 0:t.storage)??new r7,this.createPdfImpl=t==null?void 0:t.createPdf,this.baseUrl=nw((t==null?void 0:t.baseUrl)??u7),this.fhirBaseUrl=nw(ku(this.baseUrl,(t==null?void 0:t.fhirUrlPath)??"fhir/R4/")),this.authorizeUrl=ku(this.baseUrl,(t==null?void 0:t.authorizeUrl)??"oauth2/authorize"),this.tokenUrl=ku(this.baseUrl,(t==null?void 0:t.tokenUrl)??"oauth2/token"),this.logoutUrl=ku(this.baseUrl,(t==null?void 0:t.logoutUrl)??"oauth2/logout"),this.clientId=(t==null?void 0:t.clientId)??"",this.clientSecret=(t==null?void 0:t.clientSecret)??"",this.onUnauthenticated=t==null?void 0:t.onUnauthenticated,this.cacheTime=(t==null?void 0:t.cacheTime)??(typeof window>"u"?h7:f7),this.cacheTime>0?this.requestCache=new $P((t==null?void 0:t.resourceCacheSize)??d7):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.initComplete=!1,this.initPromise=this.storage.getInitPromise(),this.initPromise.then(()=>{t!=null&&t.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0}).catch(console.error)),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}clear(){this.storage.clear(),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=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 o;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue?o=new Promise((s,l)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:s,reject:l}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):o=this.request("GET",t,n);const i=new Pr(o);return this.setCacheEntry(t,i),i}post(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("POST",t,o)}put(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("PUT",t,o)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,Gt.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:o}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:o},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,o,i=!0){let s=o;i&&(s=await this.ensureCodeChallenge(o)),window.location.assign(this.getExternalAuthRedirectUri(t,n,r,s,i))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");const r=new URLSearchParams;return r.set("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),r.set("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),r.set("client_id",n),r.set("subject_token",t),this.fetchTokens(r)}getExternalAuthRedirectUri(t,n,r,o,i=!0){const s=new URL(t);if(s.searchParams.set("response_type","code"),s.searchParams.set("client_id",n),s.searchParams.set("redirect_uri",r),s.searchParams.set("scope",o.scope??"openid profile email"),s.searchParams.set("state",JSON.stringify(o)),i){const{codeChallenge:l,codeChallengeMethod:c}=o;if(!c)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!l)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");s.searchParams.set("code_challenge_method",c),s.searchParams.set("code_challenge",l)}return s.toString()}fhirUrl(...t){return new URL(t.join("/"),this.fhirBaseUrl)}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=new URLSearchParams(n).toString()),r}search(t,n,r){const o=this.fhirSearchUrl(t,n),i="search-"+o.toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr((async()=>{const c=await this.get(o,r);if(c.entry)for(const u of c.entry)this.cacheResource(u.resource);return c})());return this.setCacheEntry(i,l),l}searchOne(t,n,r){const o=this.fhirSearchUrl(t,n);o.searchParams.set("_count","1"),o.searchParams.sort();const i="searchOne-"+o.toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr(this.search(t,o.searchParams,r).then(c=>{var u,d;return(d=(u=c.entry)==null?void 0:u[0])==null?void 0:d.resource}));return this.setCacheEntry(i,l),l}searchResources(t,n,r){const i="searchResources-"+this.fhirSearchUrl(t,n).toString(),s=this.getCacheEntry(i,r);if(s)return s.value;const l=new Pr(this.search(t,n,r).then(rp));return this.setCacheEntry(i,l),l}async*searchResourcePages(t,n,r){var i,s;let o=this.fhirSearchUrl(t,n);for(;o;){const l=new URL(o).searchParams,c=await this.search(t,l,r),u=(i=c.link)==null?void 0:i.find(d=>d.relation==="next");if(!((s=c.entry)!=null&&s.length)&&!u)break;yield rp(c),o=u!=null&&u.url?new URL(u.url):void 0}}searchValueSet(t,n,r){return this.valueSetExpand({url:t,filter:n},r)}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 o,i;const r=(i=(o=this.requestCache)==null?void 0:o.get(this.fhirUrl(t,n).toString()))==null?void 0:i.value;return r!=null&&r.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return ew;const[r,o]=n.split("/");if(!(!r||!o))return this.getCached(r,o)}readResource(t,n,r){return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Pr(Promise.reject(new Error("Missing reference")));if(r==="system")return new Pr(Promise.resolve(ew));const[o,i]=r.split("/");return!o||!i?new Pr(Promise.reject(new Error("Invalid reference"))):this.readResource(o,i,n)}requestSchema(t){if(hP(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const o=new Pr((async()=>{const i=`{
86
86
  StructureDefinitionList(name: "${t}") {
87
87
  resourceType,
88
88
  name,
@@ -505,7 +505,7 @@ Error generating stack: `+i.message+`
505
505
  }
506
506
  }
507
507
  }`.replace(/\s+/g," ")}function U6(e,t){const n=[];return e.data.Patients1&&n.push(...e.data.Patients1),e.data.Patients2&&n.push(...e.data.Patients2),e.data.ServiceRequestList&&n.push(...e.data.ServiceRequestList),W6(V6(n),t).slice(0,5)}function V6(e){const t=new Set,n=[];for(const r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function W6(e,t){return e.sort((n,r)=>hw(r,t)-hw(n,t))}function hw(e,t){let n=0;if(e.identifier)for(const r of e.identifier)n=Math.max(n,pw(r.value,t));if(e.resourceType==="Patient"&&e.name)for(const r of e.name)n=Math.max(n,pw(Fc(r),t));return n}function pw(e,t){if(!e)return 0;const n=e.toLowerCase().indexOf(t.toLowerCase());return n<0?0:100-n}function H6(e){var o;const t=Xf(),[n,r]=p.useState(!1);return a.jsx(Un.Header,{p:8,style:{zIndex:101},children:a.jsxs(Y,{justify:"space-between",children:[a.jsxs(Y,{gap:"xs",children:[a.jsx(Jn,{className:Ru.logoButton,onClick:e.navbarToggle,children:e.logo}),!e.headerSearchDisabled&&a.jsx(F6,{pathname:e.pathname,searchParams:e.searchParams})]}),a.jsxs(Y,{gap:"lg",pr:"sm",children:[e.notifications,a.jsxs(Z,{width:260,shadow:"xl",position:"bottom-end",transitionProps:{transition:"pop-top-right"},opened:n,onClose:()=>r(!1),children:[a.jsx(Z.Target,{children:a.jsx(Jn,{className:et(Ru.user,{[Ru.userActive]:n}),onClick:()=>r(i=>!i),children:a.jsxs(Y,{gap:7,children:[a.jsx(Pi,{value:t,radius:"xl",size:24}),a.jsx(se,{size:"sm",className:Ru.userName,children:Fc((o=t==null?void 0:t.name)==null?void 0:o[0])}),a.jsx(QP,{size:12,stroke:1.5})]})})}),a.jsx(Z.Dropdown,{children:a.jsx(A6,{version:e.version})})]})]})]})})}function q6(e){const t={};for(const n of Array.from(e.elements))n instanceof HTMLInputElement?G6(t,n):n instanceof HTMLTextAreaElement?t[n.name]=n.value:n instanceof HTMLSelectElement&&Q6(t,n);return t}function G6(e,t){t.disabled||(t.type==="checkbox"||t.type==="radio")&&!t.checked||(e[t.name]=t.value)}function Q6(e,t){e[t.name]=t.value}function We(e){return a.jsx("form",{style:e.style,"data-testid":e.testid,onSubmit:t=>{t.preventDefault();const n=q6(t.target);e.onSubmit&&e.onSubmit(n)},children:e.children})}function K6(e){const t=ne(),n=t.getUserConfiguration();function r(o){var d,f;const{menuname:i,bookmarkname:s}=o,l=`${e.pathname}?${e.searchParams.toString()}`,c=co(n),u=(d=c.menu)==null?void 0:d.find(({title:h})=>h===i);(f=u==null?void 0:u.link)==null||f.push({name:s,target:l}),t.updateResource(c).then(h=>{n.menu=h.menu,t.dispatchEvent({type:"change"}),fe({color:"green",message:"Success"}),e.onOk()}).catch(h=>{fe({color:"red",message:Te(h)})})}return a.jsx(Dn,{title:"Add Bookmark",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:e.onCancel,children:a.jsx(We,{onSubmit:r,children:a.jsxs(be,{children:[a.jsx(Y6,{config:n}),a.jsx(ae,{label:"Bookmark Name",type:"text",name:"bookmarkname",placeholder:"Bookmark Name",withAsterisk:!0}),a.jsx(Y,{justify:"flex-end",children:a.jsx(te,{mt:"sm",type:"submit",children:"OK"})})]})})})}function Y6(e){function t(r){var o;return(o=r==null?void 0:r.menu)==null?void 0:o.map(i=>i.title)}const n=t(e.config);return a.jsx(wt,{name:"menuname",defaultValue:n[0],label:"Select Menu Option",data:n,withAsterisk:!0})}function tT(e){return typeof e.code=="string"?e.code:JSON.stringify(e)}function X6(e){return typeof e.display=="string"?e.display:tT(e)}function J6(e){return{value:tT(e),label:X6(e),resource:e}}function Z6(e){return{code:e,display:e}}function qv(e){const t=ne(),{binding:n,creatable:r,clearable:o,expandParams:i,withHelpText:s,...l}=e,c=p.useCallback(async(u,d)=>{var g;if(!n)return[];const h=(g=(await t.valueSetExpand({...i,url:n,filter:u},{signal:d})).expansion)==null?void 0:g.contains,m=[];for(const y of h)y.code&&!m.some(S=>S.code===y.code)&&m.push(y);return m},[t,i,n]);return a.jsx(Hv,{...l,creatable:r??!0,clearable:o??!0,toOption:J6,loadOptions:c,onCreate:Z6,itemComponent:s?eF:void 0})}const eF=p.forwardRef(({label:e,resource:t,...n},r)=>a.jsx("div",{ref:r,...n,children:a.jsx(Y,{wrap:"nowrap",children:a.jsxs("div",{children:[a.jsx(se,{children:e}),a.jsx(se,{size:"xs",c:"dimmed",children:`${t.system}#${t.code}`})]})})}));function nT(e){const{defaultValue:t,onChange:n,withHelpText:r,...o}=e,[i,s]=p.useState(t);function l(c){const u=c[0],d=nF(u);s(d),n&&n(d)}return a.jsx(qv,{defaultValue:tF(i),onChange:l,withHelpText:r??!0,...o})}function tF(e){return e?{code:e}:void 0}function nF(e){return e==null?void 0:e.code}function Gv(e){const[t,n]=p.useState(e.defaultValue),r=e.onChange,o=p.useCallback(i=>{n(i),r&&r(i)},[r]);return a.jsx(nT,{"data-autofocus":e.autoFocus,"data-testid":e.testId,defaultValue:t,onChange:o,name:e.name,placeholder:e.placeholder,binding:"https://medplum.com/fhir/ValueSet/resource-types",creatable:!1,maxValues:e.maxValues??1,clearable:!1,withHelpText:!1})}const rF="_menuTitle_9g6l5_1",oF="_link_9g6l5_9",iF="_linkActive_9g6l5_38",Im={menuTitle:rF,link:oF,linkActive:iF};function sF(e){var l;const t=Yf(),n=cF(e.pathname,e.searchParams,e.menus),[r,o]=p.useState(!1);function i(c,u){c.stopPropagation(),c.preventDefault(),t(u),window.innerWidth<768&&e.closeNavbar()}function s(c){c&&t(`/${c}`)}return a.jsxs(a.Fragment,{children:[a.jsx(Un.Navbar,{children:a.jsxs(vr,{p:"xs",children:[!e.resourceTypeSearchDisabled&&a.jsx(Un.Section,{mb:"sm",children:a.jsx(Gv,{name:"resourceType",placeholder:"Resource Type",maxValues:0,onChange:c=>s(c)},window.location.pathname)}),a.jsxs(Un.Section,{grow:!0,children:[(l=e.menus)==null?void 0:l.map(c=>{var u;return a.jsxs(p.Fragment,{children:[a.jsx(se,{className:Im.menuTitle,children:c.title}),(u=c.links)==null?void 0:u.map(d=>a.jsxs(aF,{to:d.href,active:d.href===(n==null?void 0:n.href),onClick:f=>i(f,d.href),children:[a.jsx(lF,{to:d.href,icon:d.icon}),a.jsx("span",{children:d.label})]},d.href))]},`menu-${c.title}`)}),e.displayAddBookmark&&a.jsx(te,{variant:"subtle",size:"xs",mt:"xl",leftSection:a.jsx(u6,{size:"0.75rem"}),onClick:()=>o(!0),children:"Add Bookmark"})]})]})}),e.pathname&&e.searchParams&&a.jsx(K6,{pathname:e.pathname,searchParams:e.searchParams,visible:r,onOk:()=>o(!1),onCancel:()=>o(!1)})]})}function aF(e){return a.jsx(Fe,{onClick:e.onClick,to:e.to,className:et(Im.link,{[Im.linkActive]:e.active}),children:e.children})}function lF(e){return e.icon?e.icon:a.jsx(Uf,{w:30})}function cF(e,t,n){if(!e||!t||!n)return;let r,o=0;for(const i of n)if(i.links)for(const s of i.links){const l=uF(e,t,s.href);l>o&&(o=l,r=s)}return r}function uF(e,t,n){const r=new URL(n,"https://example.com");if(e!==r.pathname)return 0;const o=["_count","_offset"];for(const[s,l]of r.searchParams.entries())if(!o.includes(s)&&t.get(s)!==l)return 0;let i=1;for(const[s,l]of t.entries())o.includes(s)||r.searchParams.get(s)===l&&i++;return i}function dF(e){const[t,n]=p.useState(localStorage.navbarOpen==="true"),r=ne(),o=Xf();p.useEffect(()=>{function c(){fe({color:"red",message:"No connection to server",autoClose:!1})}return r.addEventListener("offline",c),()=>r.removeEventListener("offline",c)},[r]);function i(c){localStorage.navbarOpen=c.toString(),n(c)}function s(){i(!1)}function l(){i(!t)}return r.isLoading()?a.jsx($r,{}):a.jsxs(Un,{header:{height:60},navbar:{width:250,breakpoint:"sm",collapsed:{desktop:!o||!t,mobile:!o||!t}},padding:0,children:[o&&a.jsx(H6,{pathname:e.pathname,searchParams:e.searchParams,headerSearchDisabled:e.headerSearchDisabled,logo:e.logo,version:e.version,navbarToggle:l,notifications:e.notifications}),o&&t?a.jsx(sF,{pathname:e.pathname,searchParams:e.searchParams,menus:e.menus,closeNavbar:s,displayAddBookmark:e.displayAddBookmark,resourceTypeSearchDisabled:e.resourceTypeSearchDisabled}):void 0,a.jsx(Un.Main,{className:C6.main,children:a.jsx(ZP,{children:a.jsx(p.Suspense,{fallback:a.jsx($r,{}),children:e.children})})})]})}function Vc(e){const{contentType:t,url:n,title:r}=e.value??{},o=qP(n);return o?a.jsxs("div",{"data-testid":"attachment-display",children:[(t==null?void 0:t.startsWith("image/"))&&a.jsx("img",{"data-testid":"attachment-image",style:{maxWidth:e.maxWidth},src:o,alt:r}),(t==null?void 0:t.startsWith("video/"))&&a.jsx("video",{"data-testid":"attachment-video",style:{maxWidth:e.maxWidth},controls:!0,children:a.jsx("source",{type:t,src:o})}),t==="application/pdf"&&a.jsx("div",{"data-testid":"attachment-pdf",style:{maxWidth:e.maxWidth,minHeight:400},children:a.jsx("iframe",{width:"100%",height:"400",src:o+"#navpanes=0",allowFullScreen:!0,frameBorder:0,seamless:!0})}),a.jsx("div",{"data-testid":"download-link",style:{padding:"2px 16px 16px 16px"},children:a.jsx(He,{href:o,"data-testid":"attachment-details",target:"_blank",rel:"noopener noreferrer",download:fF(r),children:r||"Download"})})]}):null}function fF(e){return e!=null&&e.includes(".")?e:void 0}const hF="_root_17n8t_1",pF="_compact_17n8t_25",mw={root:hF,compact:pF};function Qv(e){const{children:t,compact:n}=e;return a.jsx("dl",{className:et(mw.root,{[mw.compact]:n}),children:t})}function bo(e){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:e.term}),a.jsx("dd",{children:e.children})]})}function mF(e){var r;const t=(r=e.values)==null?void 0:r.map((o,i)=>a.jsx("div",{children:a.jsx(Vc,{value:o,maxWidth:e.maxWidth})},"attatchment-"+i));let n;if(e.includeDescriptionListEntry){if(e.property===void 0)throw new Error("props.property is required when includeDescriptionListEntry is true");if(!Nt(e.path))throw new Error("props.path is required when includeDescriptionListEntry is true");const o=e.path.split(".").pop();n=a.jsx(bo,{term:ss(o),children:t})}else n=a.jsx(a.Fragment,{children:t});return n}function Kv(e){const t=ne(),n=p.useRef(null);function r(s){var l;it(s),(l=n.current)==null||l.click()}function o(s){it(s);const l=s.target.files;l&&Array.from(l).forEach(i)}function i(s){!s||!s.name||(e.onUploadStart&&e.onUploadStart(),t.createAttachment({data:s,contentType:s.type||"application/octet-stream",filename:s.name,securityContext:e.securityContext,onProgress:e.onUploadProgress}).then(c=>e.onUpload(c)).catch(c=>{e.onUploadError&&e.onUploadError(lt(c))}))}return a.jsxs(a.Fragment,{children:[a.jsx("input",{type:"file","data-testid":"upload-file-input",style:{display:"none"},ref:n,onChange:s=>o(s)}),e.children({onClick:r})]})}function gF(e){const[t,n]=p.useState(e.defaultValue??[]),r=p.useRef();r.current=t;function o(i){n(i),e.onChange&&e.onChange(i)}return a.jsxs("table",{style:{width:"100%"},children:[a.jsxs("colgroup",{children:[a.jsx("col",{width:"97%"}),a.jsx("col",{width:"3%"})]}),a.jsxs("tbody",{children:[t.map((i,s)=>a.jsxs("tr",{children:[a.jsx("td",{children:a.jsx(Vc,{value:i,maxWidth:200})}),a.jsx("td",{children:a.jsx(qt,{title:"Remove",variant:"subtle",size:"sm",color:"gray",onClick:l=>{it(l);const c=t.slice();c.splice(s,1),o(c)},children:a.jsx(Nd,{})})})]},`${s}-${t.length}`)),a.jsxs("tr",{children:[a.jsx("td",{}),a.jsx("td",{children:a.jsx(Kv,{onUpload:i=>{o([...r.current,i])},children:i=>a.jsx(qt,{...i,title:"Add",variant:"subtle",size:"sm",color:"green",children:a.jsx(Bv,{})})})})]})]})]})}function rT(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return t?a.jsxs(a.Fragment,{children:[a.jsx(Vc,{value:t,maxWidth:200}),a.jsx(te,{onClick:o=>{it(o),r(void 0)},children:"Remove"})]}):a.jsx(Kv,{securityContext:e.securityContext,onUpload:r,children:o=>a.jsx(te,{...o,children:"Upload..."})})}const oT=["meta","implicitRules","contained","extension","modifierExtension"],iT=["language","text"];function io(e){return a.jsx(a.Fragment,{children:wi(e.value)})}function yF(e){return a.jsx(a.Fragment,{children:Es(e.value)})}function sT(e){const t=e.value;if(!t)return null;const n=[];return t.value&&n.push(t.value),(t.use||t.system)&&(n.push(" ["),t.use&&n.push(t.use),t.use&&t.system&&n.push(" "),t.system&&n.push(t.system),n.push("]")),a.jsx(a.Fragment,{children:n.join("").trim()})}function vF(e){var n;const t=e.value;return t?a.jsxs(a.Fragment,{children:[t.name,t.name&&": ",(n=t.telecom)==null?void 0:n.map(r=>a.jsx(sT,{value:r},`telecom-${t.name}-${r.value}`))]}):null}function xF(e){var t,n;return a.jsxs("div",{children:[(t=e.value)==null?void 0:t.system,": ",(n=e.value)==null?void 0:n.value]})}function wF(e){return a.jsx(a.Fragment,{children:ML(e.value)})}function cc(e){return a.jsx(a.Fragment,{children:Xo(e.value)})}function Yv(e){return a.jsx(a.Fragment,{children:sc(e.value)})}function SF(e){const t=e.value;return t?a.jsxs(a.Fragment,{children:[a.jsx(cc,{value:t.numerator})," / ",a.jsx(cc,{value:t.denominator})]}):null}function Ld(e){if(!e.value)return null;const t=e.value.display||e.value.reference||tr(e.value);return e.link!==!1&&e.value.reference?a.jsx(Fe,{to:e.value,children:t}):a.jsx(a.Fragment,{children:t})}const Jt=C.createContext({path:"",profileUrl:void 0,elements:Object.create(null),elementsByPath:Object.create(null),debugMode:!1});Jt.displayName="ElementsContext";function aT(e,t,n,r){if(!Nt(n==null?void 0:n.slices))return[e];const o=new Array(t.length+1);for(let i=0;i<o.length;i++)o[i]=[];for(const i of e){const s=VP(i,t,n.discriminator,r);let l=s?t.findIndex(c=>c.name===s):-1;l===-1&&(l=t.length),o[l].push(i)}return o}async function lT({medplum:e,property:t}){return new Promise((n,r)=>{var l,c;if(!t.slicing){n([]);return}const o=[],i=[],s=[];for(const u of t.slicing.slices){if(!UP(u)){console.debug("Unsupported slice definition",u);continue}let d;Nt(u.elements)||(d=(c=(l=u.type[0])==null?void 0:l.profile)==null?void 0:c[0]),o.push(u),i.push(d),d?s.push(e.requestProfileSchema(d)):s.push(Promise.resolve([]))}Promise.all(s).then(()=>{for(let u=0;u<o.length;u++){const d=o[u],f=i[u];if(f){const h=Cs(f);d.typeSchema=h}}n(o)}).catch(r)})}function Zf(e,t,n){return t!==void 0?a.jsx(e,{value:t,children:n}):n}function bF(e){var s,l;const{slice:t,property:n}=e,r=((s=t.typeSchema)==null?void 0:s.elements)??t.elements,o=p.useContext(Jt),i=p.useMemo(()=>{var c;if(Nt(r))return Da({parentContext:o,elements:r,path:e.path,profileUrl:(c=t.typeSchema)==null?void 0:c.url})},[o,e.path,(l=t.typeSchema)==null?void 0:l.url,r]);return Zf(Jt.Provider,i,a.jsx(a.Fragment,{children:e.value.map((c,u)=>a.jsx("div",{children:a.jsx(Fr,{property:n,path:e.path,arrayElement:!0,elementDefinitionType:t.type[0],propertyType:t.type[0].code,value:c,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${u}-${e.value.length}`))}))}function CF(e){var g;const{property:t,propertyType:n}=e,r=ne(),o=p.useMemo(()=>Array.isArray(e.values)?e.values:[],[e.values]),[i,s]=p.useState(!0),[l,c]=p.useState([]),[u,d]=p.useState(()=>[o]),f=p.useContext(Jt);if(p.useEffect(()=>{lT({medplum:r,property:t}).then(y=>{c(y);const S=aT(o,y,t.slicing,f.profileUrl);d(S),s(!1)}).catch(y=>{console.error(y),s(!1)})},[r,t,f.profileUrl,d,o]),i)return a.jsx("div",{children:"Loading..."});let h;if(((g=t.type[0])==null?void 0:g.code)!=="Extension"){const y=u[l.length],S=y.map((v,x)=>a.jsx("div",{children:a.jsx(Fr,{path:e.path,arrayElement:!0,property:t,propertyType:n,value:v,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${x}-${y.length}`));if(e.includeDescriptionListEntry){if(!Nt(e.path))throw new Error("props.path is required when includeDescriptionListEntry is true");const v=e.path.split(".").pop();h=a.jsx(bo,{term:ss(v),children:S})}else h=a.jsx(a.Fragment,{children:S})}return a.jsxs(a.Fragment,{children:[l.map((y,S)=>{if(!e.path)throw Error(`Displaying a resource property with slices of type ${e.propertyType} requires path`);let v=a.jsx(bF,{path:e.path,slice:y,property:t,value:u[S],ignoreMissingValues:e.ignoreMissingValues,link:e.link},y.name);return e.includeDescriptionListEntry&&(v=a.jsx(bo,{term:ss(y.name),children:v},y.name)),v}),h]})}function Wc(e,t,n){const r=Xt(e,t,{profileUrl:n});return r?Array.isArray(r)?[r.map(o=>o.value),r[0].type]:[r.value,r.type]:[void 0,"undefined"]}function EF(e,t,n){const r=gP(e,t,n);return r?Array.isArray(r)?[r.map(o=>o.value),r[0].type]:[r.value,r.type]:[void 0,"undefined"]}function jF(e){const{elementDefinitionType:t}=e,n=ne(),r=p.useContext(Jt),[o,i]=p.useState(pP("Extension")),s=p.useMemo(()=>{if(Nt(t==null?void 0:t.profile))return t.profile[0]},[t]),[l,c]=p.useState(s!==void 0);if(p.useEffect(()=>{s&&(c(!0),n.requestProfileSchema(s).then(()=>{const f=Cs(s);c(!1),f&&i(f)}).catch(f=>{c(!1),console.warn(f)}))},[n,s]),s&&(l||!jv(s)))return a.jsx("div",{children:"Loading..."});const u=o.elements["value[x]"];if((u==null?void 0:u.max)!==0){const[f,h]=Wc({type:"Extension",value:e.value},"value[x]",s??r.profileUrl);return a.jsx(Fr,{propertyType:h,value:f})}return a.jsx($d,{path:e.path,value:{type:o.name,value:e.value},compact:e.compact,ignoreMissingValues:e.ignoreMissingValues,link:e.link,profileUrl:s})}function Fr(e){var s;const{property:t,propertyType:n,value:r}=e;if((s=t==null?void 0:t.path)==null?void 0:s.endsWith(".id"))return a.jsxs(W,{component:"div",style:{display:"flex",gap:3,alignItems:"center"},children:[r,!Ot(r)&&a.jsx(Ej,{value:r,timeout:2e3,children:({copied:l,copy:c})=>a.jsx(qa,{label:l?"Copied":"Copy",withArrow:!0,position:"right",children:a.jsx(qt,{variant:"subtle",color:l?"teal":"gray",onClick:c,children:l?a.jsx(Jf,{size:"1rem"}):a.jsx(KP,{size:"1rem"})})})})]});const i=!!e.arrayElement;if(t!=null&&t.max&&t.max>1&&!i)return n===V.Attachment?a.jsx(mF,{values:r,maxWidth:e.maxWidth,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,property:t,path:e.path}):a.jsx(CF,{path:e.path,property:t,propertyType:n,values:r,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,ignoreMissingValues:e.ignoreMissingValues,link:e.link});switch(n){case V.boolean:return a.jsx(a.Fragment,{children:r===void 0?"":(!!r).toString()});case V.SystemString:case V.string:return a.jsx("div",{style:{whiteSpace:"pre-wrap"},children:r});case V.code:case V.date:case V.decimal:case V.id:case V.integer:case V.positiveInt:case V.unsignedInt:case V.uri:case V.url:return a.jsx(a.Fragment,{children:r});case V.canonical:return a.jsx(Ld,{value:{reference:r},link:e.link});case V.dateTime:case V.instant:return a.jsx(a.Fragment,{children:jn(r)});case V.markdown:return a.jsx("pre",{children:r});case V.Address:return a.jsx(R7,{value:r});case V.Annotation:return a.jsx(a.Fragment,{children:r==null?void 0:r.text});case V.Attachment:return a.jsx(Vc,{value:r,maxWidth:e.maxWidth});case V.CodeableConcept:return a.jsx(io,{value:r});case V.Coding:return a.jsx(yF,{value:r});case V.ContactDetail:return a.jsx(vF,{value:r});case V.ContactPoint:return a.jsx(sT,{value:r});case V.HumanName:return a.jsx(Wv,{value:r});case V.Identifier:return a.jsx(xF,{value:r});case V.Money:return a.jsx(wF,{value:r});case V.Period:return a.jsx(a.Fragment,{children:IL(r)});case V.Quantity:case V.Duration:return a.jsx(cc,{value:r});case V.Range:return a.jsx(Yv,{value:r});case V.Ratio:return a.jsx(SF,{value:r});case V.Reference:return a.jsx(Ld,{value:r,link:e.link});case V.Timing:return a.jsx(a.Fragment,{children:TP(r)});case V.Dosage:case V.UsageContext:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return a.jsx($d,{path:e.path,value:{type:n,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues});case V.Extension:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return a.jsx(jF,{path:e.path,value:r,compact:!0,ignoreMissingValues:e.ignoreMissingValues,elementDefinitionType:e.elementDefinitionType});default:if(!t)throw Error(`Displaying property of type ${e.propertyType} requires element schema`);if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return a.jsx($d,{path:e.path,value:{type:t.type[0].code,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues})}}const cT=["extension","modifierExtension"],PF=oT.filter(e=>!cT.includes(e));function $d(e){const t=e.value,{value:n,type:r}=t,o=p.useContext(Jt),i=e.profileUrl??(o==null?void 0:o.profileUrl),s=p.useMemo(()=>Wf(r,i),[i,r]),l=p.useMemo(()=>{if(s)return Da({parentContext:o,elements:s.elements,path:e.path,profileUrl:s.url})},[s,e.path,o]);if(Ot(n))return null;if(!s)return a.jsxs("div",{children:[r," not implemented"]});if(typeof n=="object"&&"name"in n&&Object.keys(n).length===1&&typeof n.name=="string")return a.jsx("div",{children:n.name});const c=l??o;return Zf(Jt.Provider,l,a.jsx(Qv,{compact:e.compact,children:Object.entries(c.elements).map(([u,d])=>{var y;if(cT.includes(u)&&Ot((y=d.slicing)==null?void 0:y.slices))return null;if(PF.includes(u))return null;if(iT.includes(u)&&d.path.split(".").length===2||u.includes("."))return null;const[f,h]=Wc(t,u,c.profileUrl);if((e.ignoreMissingValues||d.max===0)&&Ot(f)||e.path.endsWith(".extension")&&(u==="url"||u==="id"))return null;const m=d.max>1||d.isArray,g=a.jsx(Fr,{property:d,propertyType:h,path:e.path+"."+u,value:f,ignoreMissingValues:e.ignoreMissingValues,includeArrayDescriptionListEntry:m,link:e.link},u);return m?g:a.jsx(bo,{term:ss(u),children:g},u)})}))}function uT(e){const{debugMode:t}=p.useContext(Jt);let n;return t&&e.fhirPath?n=`${e.title} - ${e.fhirPath}`:n=e.title,a.jsxs(Y,{wrap:"nowrap","data-testid":e.testId,children:[a.jsx("div",{children:e.children}),a.jsx("div",{children:a.jsx(Ct.Wrapper,{id:e.htmlFor,label:n,description:e.description,withAsterisk:e.withAsterisk,children:null})})]})}function ze(e,t){var n,r,o;return(o=(r=(n=e==null?void 0:e.issue)==null?void 0:n.filter(i=>{var s;return dT((s=i.expression)==null?void 0:s[0],t)}))==null?void 0:r.map(i=>{var s;return(s=i.details)==null?void 0:s.text}))==null?void 0:o.join(`
508
- `)}function Hc(e,t){var n;return(n=e==null?void 0:e.issue)==null?void 0:n.filter(r=>{var o;return dT((o=r.expression)==null?void 0:o[0],t)})}function dT(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=e.indexOf(".");if(n>=0&&e.substring(n+1)===t)return!0;const r=t.indexOf(".");return r>=0&&t.substring(r+1)===e}function at(e){const{debugMode:t}=p.useContext(Jt);let n;return t&&e.fhirPath?n=`${e.title} - ${e.fhirPath}`:n=e.title,a.jsx(Ct.Wrapper,{id:e.htmlFor,label:n,description:e.description,withAsterisk:e.withAsterisk,error:ze(e.outcome,e.htmlFor),"data-testid":e.testId,children:e.children})}function fT(e,t,n,r,o){const i=r.type;if(i.length>1)for(const s of i){const l=t.replace("[x]",Vt(s.code));l in e&&delete e[l]}return e[n]=o,e}function TF(e){return!!e&&!Ot(e.url)&&!Ot(e.name)}function kF(e){const{defaultValue:t,onChange:n,withHelpText:r,...o}=e,[i,s]=p.useState(t);function l(c){const u=DF(c);s(u),n&&n(u)}return a.jsx(qv,{defaultValue:i&&RF(i),onChange:l,withHelpText:r??!0,...o})}function RF(e){var t;return(t=e.coding)==null?void 0:t.map(n=>({system:n.system,code:n.code,display:n.display}))}function DF(e){if(e.length!==0)return{coding:e.map(t=>({system:t.system,code:t.code,display:t.display}))}}function hT(e){const{defaultValue:t,onChange:n,withHelpText:r,...o}=e,[i,s]=p.useState(t);function l(c){const u=c[0],d=u&&_F(u);s(d),n&&n(d)}return a.jsx(qv,{defaultValue:i&&IF(i),maxValues:1,onChange:l,withHelpText:r??!0,...o})}function IF(e){return{system:e.system,code:e.code,display:e.display}}function _F(e){return{system:e.system,code:e.code,display:e.display}}function pT(e){const{path:t,outcome:n}=e,{elementsByPath:r}=p.useContext(Jt),[o,i]=p.useState(e.defaultValue),s=p.useRef();s.current=o;const[l,c,u]=p.useMemo(()=>["system","use","value"].map(g=>r[t+"."+g]),[r,t]);function d(g){g&&Object.keys(g).length===0&&(g=void 0),i(g),e.onChange&&e.onChange(g)}function f(g){const y={...s.current,system:g};g||delete y.system,d(y)}function h(g){const y={...s.current,use:g};g||delete y.use,d(y)}function m(g){const y={...s.current,value:g};g||delete y.value,d(y)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(wt,{"data-testid":"system",defaultValue:o==null?void 0:o.system,required:((l==null?void 0:l.min)??0)>0,onChange:g=>f(g.currentTarget.value),data:["","email","phone","fax","pager","sms","other"],error:ze(n,t+".system")}),a.jsx(wt,{"data-testid":"use",defaultValue:o==null?void 0:o.use,required:((c==null?void 0:c.min)??0)>0,onChange:g=>h(g.currentTarget.value),data:["","home","work","temp","old","mobile"],error:ze(n,t+".use")}),a.jsx(ae,{placeholder:"Value",defaultValue:o==null?void 0:o.value,required:((u==null?void 0:u.min)??0)>0,onChange:g=>m(g.currentTarget.value),error:ze(n,t+".value")})]})}function AF(e){var l;const[t,n]=p.useState(e.defaultValue),r=p.useRef();r.current=t;function o(c){n(c),e.onChange&&e.onChange(c)}function i(c){const u={...r.current,name:c};c||delete u.name,o(u)}function s(c){const u={...r.current,telecom:c&&[c]};c||delete u.telecom,o(u)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ae,{"data-testid":e.name+"-name",name:e.name+"-name",placeholder:"Name",style:{width:180},defaultValue:t==null?void 0:t.name,onChange:c=>i(c.currentTarget.value)}),a.jsx(pT,{name:e.name+"-telecom",path:e.path+".telecom",defaultValue:(l=t==null?void 0:t.telecom)==null?void 0:l[0],onChange:s,outcome:e.outcome})]})}function NF(e){if(!e)return"";const t=new Date(e);return qf(t)?t.toLocaleDateString("sv")+"T"+t.toLocaleTimeString("sv"):""}function mT(e){if(!e)return"";const t=new Date(e);return qf(t)?t.toISOString():""}var OF={MEDPLUM_BASE_URL:"__MEDPLUM_BASE_URL__",MEDPLUM_CLIENT_ID:"__MEDPLUM_CLIENT_ID__",GOOGLE_CLIENT_ID:"__GOOGLE_CLIENT_ID__",RECAPTCHA_SITE_KEY:"__RECAPTCHA_SITE_KEY__",MEDPLUM_REGISTER_ENABLED:"__MEDPLUM_REGISTER_ENABLED__",MEDPLUM_VERSION:"3.0.12-787031d28",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function as(e){return a.jsx(ae,{id:e.name,name:e.name,label:e.label,"data-autofocus":e.autoFocus,"data-testid":e.name,placeholder:e.placeholder,required:e.required,type:MF(),defaultValue:NF(e.defaultValue),autoFocus:e.autoFocus,error:ze(e.outcome,e.name),onChange:t=>{if(e.onChange){const n=t.currentTarget.value;e.onChange(mT(n))}}})}function MF(){return OF.NODE_ENV==="test"?"text":"datetime-local"}function LF(e){const{propertyType:t}=e,n=ne(),[r,o]=p.useState(),i=p.useMemo(()=>{if(Nt(t.profile))return t.profile[0]},[t]),[s,l]=p.useState(i!==void 0);return p.useEffect(()=>{i&&(l(!0),n.requestProfileSchema(i).then(()=>{const c=Cs(i);l(!1),o(c)}).catch(c=>{l(!1),console.warn(c)}))},[n,i]),i&&(s||!jv(i))?a.jsx("div",{children:"Loading..."}):a.jsx(e0,{profileUrl:i,path:e.path,typeName:(r==null?void 0:r.name)??"Extension",defaultValue:e.defaultValue,onChange:e.onChange})}function $F(e){var f,h,m;const{outcome:t,path:n}=e,[r,o]=p.useState(e.defaultValue);function i(g){o(g),e.onChange&&e.onChange(g)}function s(g){i({...r,use:g||void 0})}function l(g){i({...r,prefix:g?g.split(" "):void 0})}function c(g){i({...r,given:g?g.split(" "):void 0})}function u(g){i({...r,family:g||void 0})}function d(g){i({...r,suffix:g?g.split(" "):void 0})}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(wt,{defaultValue:r==null?void 0:r.use,name:e.name+"-use","data-testid":"use",onChange:g=>s(g.currentTarget.value),data:["","temp","old","usual","official","nickname","anonymous","maiden"],error:ze(t,n+".use")}),a.jsx(ae,{placeholder:"Prefix",name:e.name+"-prefix",defaultValue:(f=r==null?void 0:r.prefix)==null?void 0:f.join(" "),onChange:g=>l(g.currentTarget.value),error:ze(t,n+".prefix")}),a.jsx(ae,{placeholder:"Given",name:e.name+"-given",defaultValue:(h=r==null?void 0:r.given)==null?void 0:h.join(" "),onChange:g=>c(g.currentTarget.value),error:ze(t,n+".given")}),a.jsx(ae,{name:e.name+"-family",placeholder:"Family",defaultValue:r==null?void 0:r.family,onChange:g=>u(g.currentTarget.value),error:ze(t,n+".family")}),a.jsx(ae,{placeholder:"Suffix",name:e.name+"-suffix",defaultValue:(m=r==null?void 0:r.suffix)==null?void 0:m.join(" "),onChange:g=>d(g.currentTarget.value),error:ze(t,n+".suffix")})]})}function FF(e){const{path:t,outcome:n}=e,[r,o]=p.useState(e.defaultValue),{elementsByPath:i}=p.useContext(Jt),[s,l]=p.useMemo(()=>["system","value"].map(u=>i[t+"."+u]),[i,t]);function c(u){o(u),e.onChange&&e.onChange(u)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(ae,{placeholder:"System",required:((s==null?void 0:s.min)??0)>0,defaultValue:r==null?void 0:r.system,onChange:u=>c({...r,system:u.currentTarget.value}),error:ze(n,t+".system")}),a.jsx(ae,{placeholder:"Value",required:((l==null?void 0:l.min)??0)>0,defaultValue:r==null?void 0:r.value,onChange:u=>c({...r,value:u.currentTarget.value}),error:ze(n,t+".value")})]})}const zF=["USD","EUR","CAD","GBP","AUD"];function BF(e){var c;const{onChange:t}=e,[n,r]=p.useState(e.defaultValue),o=p.useCallback(u=>{r(u),t&&t(u)},[t]),i=p.useCallback(u=>{o({...n,currency:u.currentTarget.value})},[n,o]),s=p.useCallback(u=>{o({...n,value:u.currentTarget.valueAsNumber})},[n,o]),l=a.jsx(wt,{defaultValue:n==null?void 0:n.currency,data:zF,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:i});return a.jsx(ae,{type:"number",name:e.name,label:e.label,placeholder:e.placeholder??"Value",defaultValue:((c=n==null?void 0:n.value)==null?void 0:c.toString())??"USD",leftSection:a.jsx(q7,{size:14}),rightSection:l,rightSectionWidth:92,onChange:s})}function UF(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(as,{name:e.name+".start",placeholder:"Start",defaultValue:t==null?void 0:t.start,onChange:o=>r({...t,start:o})}),a.jsx(as,{name:e.name+".end",placeholder:"End",defaultValue:t==null?void 0:t.end,onChange:o=>r({...t,end:o})})]})}function ls(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(wt,{style:{width:80},"data-testid":e.name+"-comparator",defaultValue:t==null?void 0:t.comparator,data:["","<","<=",">=",">"],onChange:o=>r({...t,comparator:o.currentTarget.value})}),a.jsx(ae,{id:e.name,name:e.name,required:e.required,"data-autofocus":e.autoFocus,"data-testid":e.name+"-value",type:"number",placeholder:"Value",defaultValue:t==null?void 0:t.value,autoFocus:e.autoFocus,step:"any",onWheel:o=>{e.disableWheel&&o.currentTarget.blur()},onChange:o=>{r({...t,value:VF(o.currentTarget.value)})}}),a.jsx(ae,{placeholder:"Unit","data-testid":e.name+"-unit",defaultValue:t==null?void 0:t.unit,onChange:o=>r({...t,unit:o.currentTarget.value})})]})}function VF(e){if(e)return parseFloat(e)}function Xv(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ls,{name:e.name+"-low",defaultValue:t==null?void 0:t.low,onChange:o=>r({...t,low:o})}),a.jsx(ls,{name:e.name+"-high",defaultValue:t==null?void 0:t.high,onChange:o=>r({...t,high:o})})]})}function WF(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ls,{name:e.name+"-numerator",defaultValue:t==null?void 0:t.numerator,onChange:o=>r({...t,numerator:o})}),a.jsx(ls,{name:e.name+"-denominator",defaultValue:t==null?void 0:t.denominator,onChange:o=>r({...t,denominator:o})})]})}const HF={Observation:"code",User:"email:contains"},qF=["AccessPolicy","Account","ActivityDefinition","Bot","CapabilityStatement","CareTeam","ClientApplication","CodeSystem","CompartmentDefinition","ConceptMap","EffectEvidenceSynthesis","Endpoint","EventDefinition","Evidence","EvidenceVariable","ExampleScenario","GraphDefinition","Group","HealthcareService","ImplementationGuide","InsurancePlan","Library","Location","Measure","MedicinalProduct","MessageDefinition","NamingSystem","OperationDefinition","Organization","Patient","Person","PlanDefinition","Practitioner","Project","Questionnaire","RelatedPerson","ResearchDefinition","ResearchElementDefinition","RiskEvidenceSynthesis","SearchParameter","StructureDefinition","StructureMap","TerminologyCapabilities","TestScript","UserConfiguration","ValueSet"];function GF(e){return{value:ht(e),label:Do(e),resource:e}}function Qa(e){const t=ne(),{resourceType:n,searchCriteria:r}=e,[o,i]=p.useState(),s=ct(e.defaultValue,i),l=e.onChange,c=p.useCallback(async(d,f)=>{const h=KF(n),m=new URLSearchParams({[h]:d??"",_count:"10",...r});return await t.searchResources(n,m,{signal:f})},[t,n,r]),u=p.useCallback(d=>{l&&l(d[0])},[l]);return Nt(e.defaultValue)&&!o&&!s?null:a.jsx(Hv,{name:e.name,required:e.required,itemComponent:QF,defaultValue:s,placeholder:e.placeholder,maxValues:1,toOption:GF,loadOptions:c,onChange:u,clearable:!0})}const QF=p.forwardRef(({label:e,resource:t,...n},r)=>a.jsx("div",{ref:r,...n,children:a.jsxs(Y,{wrap:"nowrap",children:[a.jsx(Pi,{value:t}),a.jsxs("div",{children:[a.jsx(se,{children:e}),a.jsx(se,{size:"xs",c:"dimmed",children:t.birthDate})]})]})}));function KF(e){return HF[e]??(qF.includes(e)?"name":"_id")}function eh(e){const{onChange:t}=e,n=ne(),[r,o]=p.useState(e.defaultValue),[i,s]=p.useState(()=>YF(e.targetTypes)),[l,c]=p.useState(()=>XF(e.defaultValue,i)),u=p.useRef(new $P),d=p.useMemo(()=>(l==null?void 0:l.type)==="profile"?{...e.searchCriteria,_profile:l.value}:e.searchCriteria,[e.searchCriteria,l]);p.useEffect(()=>{let m=!1;const g=i==null?void 0:i.map(y=>{if(!ZF(y))return Promise.resolve(y);m=!0;const S=y.value,v=u.current.get(S);if(v)return v;const x=JF(n,y.value).then(b=>{const j={...y};return b?Nt(b.type)?(j.resourceType=b.type,j.name=b.name,j.title=b.title):(console.error(`StructureDefinition.type missing for ${y.value}`),j.error="StructureDefinition.type missing"):(console.error(`StructureDefinition not found for ${y.value}`),j.error="StructureDefinition not found"),j}).catch(b=>(console.error(b),{...y,error:b})),w=new Pr(x);return u.current.set(S,w),w});!g||!m||Promise.all(g).then(y=>{if(s(y),!l)return;const S=y.findIndex(v=>v.value===l.value||v.resourceType===l.resourceType);if(S===-1){console.debug(`defaultValue had unexpected resourceType: ${l.resourceType}`);return}c(y[S])}).catch(console.error)},[n,l,i]);const f=p.useCallback(m=>{const g=m?ft(m):void 0;o(g),t&&t(g)},[t]),h=p.useMemo(()=>i?i.map(m=>({value:m.value,label:m.type==="profile"?m.title??m.name??m.resourceType??m.value:m.value})):[],[i]);return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[i&&i.length>1&&a.jsx(wt,{"data-autofocus":e.autoFocus,"data-testid":"reference-input-resource-type-select",defaultValue:l==null?void 0:l.resourceType,autoFocus:e.autoFocus,onChange:m=>{const g=m.currentTarget.value,y=i.find(S=>S.value===g);c(y)},data:h}),!i&&a.jsx(Gv,{autoFocus:e.autoFocus,testId:"reference-input-resource-type-input",defaultValue:l==null?void 0:l.resourceType,onChange:m=>{c(m?{type:"resourceType",value:m,resourceType:m}:void 0)},name:e.name+"-resourceType",placeholder:"Resource Type"}),a.jsx(Qa,{resourceType:l==null?void 0:l.resourceType,name:e.name+"-id",required:e.required,placeholder:e.placeholder,defaultValue:r,searchCriteria:d,onChange:f})]})}function YF(e){if(!e||e.length===0||e.length===1&&e[0]==="Resource")return;const t=[];for(const n of e)n.includes("/")?t.push({type:"profile",value:n}):t.push({type:"resourceType",value:n,resourceType:n});return t}function XF(e,t){var r;const n=(r=e==null?void 0:e.reference)==null?void 0:r.split("/")[0];if(n){const o=t==null?void 0:t.find(i=>i.resourceType===n);return o||{type:"resourceType",value:n,resourceType:n}}if(t&&t.length>0)return t[0]}async function JF(e,t){const n=Cs(t);if(n)return{type:n.type,name:n.name,title:n.title};const r=`{
508
+ `)}function Hc(e,t){var n;return(n=e==null?void 0:e.issue)==null?void 0:n.filter(r=>{var o;return dT((o=r.expression)==null?void 0:o[0],t)})}function dT(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=e.indexOf(".");if(n>=0&&e.substring(n+1)===t)return!0;const r=t.indexOf(".");return r>=0&&t.substring(r+1)===e}function at(e){const{debugMode:t}=p.useContext(Jt);let n;return t&&e.fhirPath?n=`${e.title} - ${e.fhirPath}`:n=e.title,a.jsx(Ct.Wrapper,{id:e.htmlFor,label:n,description:e.description,withAsterisk:e.withAsterisk,error:ze(e.outcome,e.htmlFor),"data-testid":e.testId,children:e.children})}function fT(e,t,n,r,o){const i=r.type;if(i.length>1)for(const s of i){const l=t.replace("[x]",Vt(s.code));l in e&&delete e[l]}return e[n]=o,e}function TF(e){return!!e&&!Ot(e.url)&&!Ot(e.name)}function kF(e){const{defaultValue:t,onChange:n,withHelpText:r,...o}=e,[i,s]=p.useState(t);function l(c){const u=DF(c);s(u),n&&n(u)}return a.jsx(qv,{defaultValue:i&&RF(i),onChange:l,withHelpText:r??!0,...o})}function RF(e){var t;return(t=e.coding)==null?void 0:t.map(n=>({system:n.system,code:n.code,display:n.display}))}function DF(e){if(e.length!==0)return{coding:e.map(t=>({system:t.system,code:t.code,display:t.display}))}}function hT(e){const{defaultValue:t,onChange:n,withHelpText:r,...o}=e,[i,s]=p.useState(t);function l(c){const u=c[0],d=u&&_F(u);s(d),n&&n(d)}return a.jsx(qv,{defaultValue:i&&IF(i),maxValues:1,onChange:l,withHelpText:r??!0,...o})}function IF(e){return{system:e.system,code:e.code,display:e.display}}function _F(e){return{system:e.system,code:e.code,display:e.display}}function pT(e){const{path:t,outcome:n}=e,{elementsByPath:r}=p.useContext(Jt),[o,i]=p.useState(e.defaultValue),s=p.useRef();s.current=o;const[l,c,u]=p.useMemo(()=>["system","use","value"].map(g=>r[t+"."+g]),[r,t]);function d(g){g&&Object.keys(g).length===0&&(g=void 0),i(g),e.onChange&&e.onChange(g)}function f(g){const y={...s.current,system:g};g||delete y.system,d(y)}function h(g){const y={...s.current,use:g};g||delete y.use,d(y)}function m(g){const y={...s.current,value:g};g||delete y.value,d(y)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(wt,{"data-testid":"system",defaultValue:o==null?void 0:o.system,required:((l==null?void 0:l.min)??0)>0,onChange:g=>f(g.currentTarget.value),data:["","email","phone","fax","pager","sms","other"],error:ze(n,t+".system")}),a.jsx(wt,{"data-testid":"use",defaultValue:o==null?void 0:o.use,required:((c==null?void 0:c.min)??0)>0,onChange:g=>h(g.currentTarget.value),data:["","home","work","temp","old","mobile"],error:ze(n,t+".use")}),a.jsx(ae,{placeholder:"Value",defaultValue:o==null?void 0:o.value,required:((u==null?void 0:u.min)??0)>0,onChange:g=>m(g.currentTarget.value),error:ze(n,t+".value")})]})}function AF(e){var l;const[t,n]=p.useState(e.defaultValue),r=p.useRef();r.current=t;function o(c){n(c),e.onChange&&e.onChange(c)}function i(c){const u={...r.current,name:c};c||delete u.name,o(u)}function s(c){const u={...r.current,telecom:c&&[c]};c||delete u.telecom,o(u)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ae,{"data-testid":e.name+"-name",name:e.name+"-name",placeholder:"Name",style:{width:180},defaultValue:t==null?void 0:t.name,onChange:c=>i(c.currentTarget.value)}),a.jsx(pT,{name:e.name+"-telecom",path:e.path+".telecom",defaultValue:(l=t==null?void 0:t.telecom)==null?void 0:l[0],onChange:s,outcome:e.outcome})]})}function NF(e){if(!e)return"";const t=new Date(e);return qf(t)?t.toLocaleDateString("sv")+"T"+t.toLocaleTimeString("sv"):""}function mT(e){if(!e)return"";const t=new Date(e);return qf(t)?t.toISOString():""}var OF={MEDPLUM_BASE_URL:"__MEDPLUM_BASE_URL__",MEDPLUM_CLIENT_ID:"__MEDPLUM_CLIENT_ID__",GOOGLE_CLIENT_ID:"__GOOGLE_CLIENT_ID__",RECAPTCHA_SITE_KEY:"__RECAPTCHA_SITE_KEY__",MEDPLUM_REGISTER_ENABLED:"__MEDPLUM_REGISTER_ENABLED__",MEDPLUM_VERSION:"3.0.13-ced876fb4",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function as(e){return a.jsx(ae,{id:e.name,name:e.name,label:e.label,"data-autofocus":e.autoFocus,"data-testid":e.name,placeholder:e.placeholder,required:e.required,type:MF(),defaultValue:NF(e.defaultValue),autoFocus:e.autoFocus,error:ze(e.outcome,e.name),onChange:t=>{if(e.onChange){const n=t.currentTarget.value;e.onChange(mT(n))}}})}function MF(){return OF.NODE_ENV==="test"?"text":"datetime-local"}function LF(e){const{propertyType:t}=e,n=ne(),[r,o]=p.useState(),i=p.useMemo(()=>{if(Nt(t.profile))return t.profile[0]},[t]),[s,l]=p.useState(i!==void 0);return p.useEffect(()=>{i&&(l(!0),n.requestProfileSchema(i).then(()=>{const c=Cs(i);l(!1),o(c)}).catch(c=>{l(!1),console.warn(c)}))},[n,i]),i&&(s||!jv(i))?a.jsx("div",{children:"Loading..."}):a.jsx(e0,{profileUrl:i,path:e.path,typeName:(r==null?void 0:r.name)??"Extension",defaultValue:e.defaultValue,onChange:e.onChange})}function $F(e){var f,h,m;const{outcome:t,path:n}=e,[r,o]=p.useState(e.defaultValue);function i(g){o(g),e.onChange&&e.onChange(g)}function s(g){i({...r,use:g||void 0})}function l(g){i({...r,prefix:g?g.split(" "):void 0})}function c(g){i({...r,given:g?g.split(" "):void 0})}function u(g){i({...r,family:g||void 0})}function d(g){i({...r,suffix:g?g.split(" "):void 0})}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(wt,{defaultValue:r==null?void 0:r.use,name:e.name+"-use","data-testid":"use",onChange:g=>s(g.currentTarget.value),data:["","temp","old","usual","official","nickname","anonymous","maiden"],error:ze(t,n+".use")}),a.jsx(ae,{placeholder:"Prefix",name:e.name+"-prefix",defaultValue:(f=r==null?void 0:r.prefix)==null?void 0:f.join(" "),onChange:g=>l(g.currentTarget.value),error:ze(t,n+".prefix")}),a.jsx(ae,{placeholder:"Given",name:e.name+"-given",defaultValue:(h=r==null?void 0:r.given)==null?void 0:h.join(" "),onChange:g=>c(g.currentTarget.value),error:ze(t,n+".given")}),a.jsx(ae,{name:e.name+"-family",placeholder:"Family",defaultValue:r==null?void 0:r.family,onChange:g=>u(g.currentTarget.value),error:ze(t,n+".family")}),a.jsx(ae,{placeholder:"Suffix",name:e.name+"-suffix",defaultValue:(m=r==null?void 0:r.suffix)==null?void 0:m.join(" "),onChange:g=>d(g.currentTarget.value),error:ze(t,n+".suffix")})]})}function FF(e){const{path:t,outcome:n}=e,[r,o]=p.useState(e.defaultValue),{elementsByPath:i}=p.useContext(Jt),[s,l]=p.useMemo(()=>["system","value"].map(u=>i[t+"."+u]),[i,t]);function c(u){o(u),e.onChange&&e.onChange(u)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(ae,{placeholder:"System",required:((s==null?void 0:s.min)??0)>0,defaultValue:r==null?void 0:r.system,onChange:u=>c({...r,system:u.currentTarget.value}),error:ze(n,t+".system")}),a.jsx(ae,{placeholder:"Value",required:((l==null?void 0:l.min)??0)>0,defaultValue:r==null?void 0:r.value,onChange:u=>c({...r,value:u.currentTarget.value}),error:ze(n,t+".value")})]})}const zF=["USD","EUR","CAD","GBP","AUD"];function BF(e){var c;const{onChange:t}=e,[n,r]=p.useState(e.defaultValue),o=p.useCallback(u=>{r(u),t&&t(u)},[t]),i=p.useCallback(u=>{o({...n,currency:u.currentTarget.value})},[n,o]),s=p.useCallback(u=>{o({...n,value:u.currentTarget.valueAsNumber})},[n,o]),l=a.jsx(wt,{defaultValue:n==null?void 0:n.currency,data:zF,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:i});return a.jsx(ae,{type:"number",name:e.name,label:e.label,placeholder:e.placeholder??"Value",defaultValue:((c=n==null?void 0:n.value)==null?void 0:c.toString())??"USD",leftSection:a.jsx(q7,{size:14}),rightSection:l,rightSectionWidth:92,onChange:s})}function UF(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(as,{name:e.name+".start",placeholder:"Start",defaultValue:t==null?void 0:t.start,onChange:o=>r({...t,start:o})}),a.jsx(as,{name:e.name+".end",placeholder:"End",defaultValue:t==null?void 0:t.end,onChange:o=>r({...t,end:o})})]})}function ls(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(wt,{style:{width:80},"data-testid":e.name+"-comparator",defaultValue:t==null?void 0:t.comparator,data:["","<","<=",">=",">"],onChange:o=>r({...t,comparator:o.currentTarget.value})}),a.jsx(ae,{id:e.name,name:e.name,required:e.required,"data-autofocus":e.autoFocus,"data-testid":e.name+"-value",type:"number",placeholder:"Value",defaultValue:t==null?void 0:t.value,autoFocus:e.autoFocus,step:"any",onWheel:o=>{e.disableWheel&&o.currentTarget.blur()},onChange:o=>{r({...t,value:VF(o.currentTarget.value)})}}),a.jsx(ae,{placeholder:"Unit","data-testid":e.name+"-unit",defaultValue:t==null?void 0:t.unit,onChange:o=>r({...t,unit:o.currentTarget.value})})]})}function VF(e){if(e)return parseFloat(e)}function Xv(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ls,{name:e.name+"-low",defaultValue:t==null?void 0:t.low,onChange:o=>r({...t,low:o})}),a.jsx(ls,{name:e.name+"-high",defaultValue:t==null?void 0:t.high,onChange:o=>r({...t,high:o})})]})}function WF(e){const[t,n]=p.useState(e.defaultValue);function r(o){n(o),e.onChange&&e.onChange(o)}return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ls,{name:e.name+"-numerator",defaultValue:t==null?void 0:t.numerator,onChange:o=>r({...t,numerator:o})}),a.jsx(ls,{name:e.name+"-denominator",defaultValue:t==null?void 0:t.denominator,onChange:o=>r({...t,denominator:o})})]})}const HF={Device:"device-name",Observation:"code",User:"email:contains"},qF=["AccessPolicy","Account","ActivityDefinition","Bot","CapabilityStatement","CareTeam","ClientApplication","CodeSystem","CompartmentDefinition","ConceptMap","EffectEvidenceSynthesis","Endpoint","EventDefinition","Evidence","EvidenceVariable","ExampleScenario","GraphDefinition","Group","HealthcareService","ImplementationGuide","InsurancePlan","Library","Location","Measure","MedicinalProduct","MessageDefinition","NamingSystem","OperationDefinition","Organization","Patient","Person","PlanDefinition","Practitioner","Project","Questionnaire","RelatedPerson","ResearchDefinition","ResearchElementDefinition","RiskEvidenceSynthesis","SearchParameter","StructureDefinition","StructureMap","TerminologyCapabilities","TestScript","UserConfiguration","ValueSet"];function GF(e){return{value:ht(e),label:Do(e),resource:e}}function Qa(e){const t=ne(),{resourceType:n,searchCriteria:r}=e,[o,i]=p.useState(),s=ct(e.defaultValue,i),l=e.onChange,c=p.useCallback(async(d,f)=>{const h=KF(n),m=new URLSearchParams({[h]:d??"",_count:"10",...r});return await t.searchResources(n,m,{signal:f})},[t,n,r]),u=p.useCallback(d=>{l&&l(d[0])},[l]);return Nt(e.defaultValue)&&!o&&!s?null:a.jsx(Hv,{name:e.name,required:e.required,itemComponent:QF,defaultValue:s,placeholder:e.placeholder,maxValues:1,toOption:GF,loadOptions:c,onChange:u,clearable:!0})}const QF=p.forwardRef(({label:e,resource:t,...n},r)=>a.jsx("div",{ref:r,...n,children:a.jsxs(Y,{wrap:"nowrap",children:[a.jsx(Pi,{value:t}),a.jsxs("div",{children:[a.jsx(se,{children:e}),a.jsx(se,{size:"xs",c:"dimmed",children:t.birthDate})]})]})}));function KF(e){return HF[e]??(qF.includes(e)?"name":"_id")}function eh(e){const{onChange:t}=e,n=ne(),[r,o]=p.useState(e.defaultValue),[i,s]=p.useState(()=>YF(e.targetTypes)),[l,c]=p.useState(()=>XF(e.defaultValue,i)),u=p.useRef(new $P),d=p.useMemo(()=>(l==null?void 0:l.type)==="profile"?{...e.searchCriteria,_profile:l.value}:e.searchCriteria,[e.searchCriteria,l]);p.useEffect(()=>{let m=!1;const g=i==null?void 0:i.map(y=>{if(!ZF(y))return Promise.resolve(y);m=!0;const S=y.value,v=u.current.get(S);if(v)return v;const x=JF(n,y.value).then(b=>{const j={...y};return b?Nt(b.type)?(j.resourceType=b.type,j.name=b.name,j.title=b.title):(console.error(`StructureDefinition.type missing for ${y.value}`),j.error="StructureDefinition.type missing"):(console.error(`StructureDefinition not found for ${y.value}`),j.error="StructureDefinition not found"),j}).catch(b=>(console.error(b),{...y,error:b})),w=new Pr(x);return u.current.set(S,w),w});!g||!m||Promise.all(g).then(y=>{if(s(y),!l)return;const S=y.findIndex(v=>v.value===l.value||v.resourceType===l.resourceType);if(S===-1){console.debug(`defaultValue had unexpected resourceType: ${l.resourceType}`);return}c(y[S])}).catch(console.error)},[n,l,i]);const f=p.useCallback(m=>{const g=m?ft(m):void 0;o(g),t&&t(g)},[t]),h=p.useMemo(()=>i?i.map(m=>({value:m.value,label:m.type==="profile"?m.title??m.name??m.resourceType??m.value:m.value})):[],[i]);return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[i&&i.length>1&&a.jsx(wt,{"data-autofocus":e.autoFocus,"data-testid":"reference-input-resource-type-select",defaultValue:l==null?void 0:l.resourceType,autoFocus:e.autoFocus,onChange:m=>{const g=m.currentTarget.value,y=i.find(S=>S.value===g);c(y)},data:h}),!i&&a.jsx(Gv,{autoFocus:e.autoFocus,testId:"reference-input-resource-type-input",defaultValue:l==null?void 0:l.resourceType,onChange:m=>{c(m?{type:"resourceType",value:m,resourceType:m}:void 0)},name:e.name+"-resourceType",placeholder:"Resource Type"}),a.jsx(Qa,{resourceType:l==null?void 0:l.resourceType,name:e.name+"-id",required:e.required,placeholder:e.placeholder,defaultValue:r,searchCriteria:d,onChange:f})]})}function YF(e){if(!e||e.length===0||e.length===1&&e[0]==="Resource")return;const t=[];for(const n of e)n.includes("/")?t.push({type:"profile",value:n}):t.push({type:"resourceType",value:n,resourceType:n});return t}function XF(e,t){var r;const n=(r=e==null?void 0:e.reference)==null?void 0:r.split("/")[0];if(n){const o=t==null?void 0:t.find(i=>i.resourceType===n);return o||{type:"resourceType",value:n,resourceType:n}}if(t&&t.length>0)return t[0]}async function JF(e,t){const n=Cs(t);if(n)return{type:n.type,name:n.name,title:n.title};const r=`{
509
509
  StructureDefinitionList(url: "${t}", _sort: "_lastUpdated", _count: 1) {
510
510
  type,
511
511
  name,
@@ -513,7 +513,7 @@ Error generating stack: `+i.message+`
513
513
  }
514
514
  }`.replace(/\s+/g," ");return(await e.graphql(r)).data.StructureDefinitionList[0]}function ZF(e){return e.type==="profile"&&!(e!=null&&e.error)&&Ot(e.resourceType)}function gT({propertyDisplayName:e,onClick:t,testId:n}){const r=e?`Add ${e}`:"Add";return e?a.jsx(te,{title:r,size:"sm",color:"green.6",variant:"subtle","data-testid":n,leftSection:a.jsx(Od,{size:"1.25rem"}),onClick:t,children:r}):a.jsx(qt,{title:r,color:"green.6","data-testid":n,onClick:t,children:a.jsx(Od,{size:"1.25rem"})})}function yT({propertyDisplayName:e,onClick:t,testId:n}){return a.jsx(qt,{title:e?`Remove ${e}`:"Remove",color:"red.5","data-testid":n,variant:"subtle",onClick:t,children:a.jsx(Nd,{size:"1.25rem"})})}const e8="_indented_ldk1d_1",vT={indented:e8};function t8(e){var h,m;const{slice:t,property:n}=e,[r,o]=p.useState(e.defaultValue),i=((h=t.typeSchema)==null?void 0:h.elements)??t.elements,s=p.useContext(Jt),l=p.useMemo(()=>{var g;if(Nt(i))return Da({parentContext:s,elements:i,path:e.path,profileUrl:(g=t.typeSchema)==null?void 0:g.url})},[s,e.path,(m=t.typeSchema)==null?void 0:m.url,i]);function c(g){o(g),e.onChange&&e.onChange(g)}const u=t.min>0,d=Ot(t.elements),f=DP(t.name);return Zf(Jt.Provider,l,a.jsx(at,{title:f,description:t.definition,withAsterisk:u,fhirPath:`${n.path}:${t.name}`,testId:e.testId,children:a.jsxs(be,{className:d?vT.indented:void 0,children:[r.map((g,y)=>a.jsxs(Y,{wrap:"nowrap",children:[a.jsx("div",{style:{flexGrow:1},"data-testid":e.testId&&`${e.testId}-elements-${y}`,children:a.jsx(Jv,{elementDefinitionType:t.type[0],name:t.name,defaultValue:g,onChange:S=>{const v=[...r];v[y]=S,c(v)},outcome:e.outcome,min:t.min,max:t.max,binding:t.binding,path:e.path})}),r.length>t.min&&a.jsx(yT,{propertyDisplayName:f,testId:e.testId&&`${e.testId}-remove-${y}`,onClick:S=>{it(S);const v=[...r];v.splice(y,1),c(v)}})]},`${y}-${r.length}`)),r.length<t.max&&a.jsx(Y,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(gT,{propertyDisplayName:f,onClick:g=>{it(g);const y=[...r,void 0];c(y)},testId:e.testId&&`${e.testId}-add`})})]})}))}function n8(e){var v;const{property:t}=e,n=ne(),[r,o]=p.useState(!0),[i,s]=p.useState([]),[l]=p.useState(()=>Array.isArray(e.defaultValue)?e.defaultValue:[]),[c,u]=p.useState(()=>[l]),d=p.useContext(Jt),f=(v=t.type[0])==null?void 0:v.code;p.useEffect(()=>{lT({medplum:n,property:t}).then(x=>{s(x);const w=aT(l,x,t.slicing,d.profileUrl);r8(w,x),u(w),o(!1)}).catch(x=>{console.error(x),o(!1)})},[n,t,l,d.profileUrl,u]);function h(x,w){const b=[...c];if(b[w]=x,u(b),e.onChange){const j=b.flat().filter(E=>E!==void 0);e.onChange(j)}}if(r)return a.jsx("div",{children:"Loading..."});const m=i.length,g=c[m],y=!(e.hideNonSliceValues??(f==="Extension"&&i.length>0)),S=ss(t.path);return a.jsxs(be,{className:e.indent?vT.indented:void 0,children:[i.map((x,w)=>a.jsx(t8,{slice:x,path:e.path,property:t,defaultValue:c[w],onChange:b=>{h(b,w)},testId:`slice-${x.name}`},x.name)),y&&g.map((x,w)=>a.jsxs(Y,{wrap:"nowrap",style:{flexGrow:1},children:[a.jsx("div",{style:{flexGrow:1},children:a.jsx(Ka,{arrayElement:!0,property:e.property,name:e.name+"."+w,path:e.path,defaultValue:x,onChange:b=>{const j=[...g];j[w]=b,h(j,m)},defaultPropertyType:void 0,outcome:e.outcome})}),a.jsx(yT,{propertyDisplayName:S,testId:`nonsliced-remove-${w}`,onClick:b=>{it(b);const j=[...g];j.splice(w,1),h(j,m)}})]},`${w}-${g.length}`)),y&&c.flat().length<t.max&&a.jsx(Y,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(gT,{propertyDisplayName:S,onClick:x=>{it(x);const w=[...g];w.push(void 0),h(w,m)},testId:"nonsliced-add"})})]})}function r8(e,t){for(let n=0;n<t.length;n++){const r=t[n],o=e[n];for(;o.length<r.min;)o.push(void 0)}}function o8(e){const[t,n]=p.useState(!1),r=NS(),o=p.useRef(null),i={...e.styles};return t||(i.input||(i.input={}),i.input.WebkitTextSecurity="disc"),a.jsxs(rs,{gap:"xs",children:[a.jsx(ws,{...e,styles:{...i,root:{...i.root??{},flexGrow:1}},ref:o,autosize:!0,minRows:1,onFocus:()=>n(!0),onBlur:()=>n(!1)}),a.jsx(qt,{title:"Copy secret",onClick:()=>{var s;r.copy((s=o.current)==null?void 0:s.value),fe({color:"green",message:"Copied"})},children:a.jsx(KP,{})})]})}const i8=["sun","mon","tue","wed","thu","fri","sat"];function s8(e){const[t,n]=p.useState(e.defaultValue),[r,o]=p.useState(!1),i=p.useRef();return i.current=t,a.jsxs(a.Fragment,{children:[a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx("span",{children:TP(i.current)||"No repeat"}),a.jsx(te,{onClick:()=>o(!0),children:"Edit"})]}),a.jsx(a8,{visible:r,defaultValue:i.current,onOk:s=>{e.onChange&&e.onChange(s),n(s),o(!1)},onCancel:()=>o(!1)})]})}const gw={repeat:{period:1,periodUnit:"d"}};function a8(e){const[t,n]=p.useState(e.defaultValue||gw),r=p.useRef();r.current=t;function o(u){n({...r.current,event:[u]})}function i(u){n({...r.current,repeat:u})}function s(u){var d;i({...(d=r.current)==null?void 0:d.repeat,period:u})}function l(u){var d;i({...(d=r.current)==null?void 0:d.repeat,periodUnit:u})}function c(u){var d;i({...(d=r.current)==null?void 0:d.repeat,dayOfWeek:u})}return a.jsx(Dn,{title:"Timing",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>e.onCancel(),children:a.jsxs(be,{children:[a.jsx(at,{title:"Starts on",htmlFor:"timing-dialog-start",children:a.jsx(as,{name:"timing-dialog-start",onChange:u=>o(u)})}),a.jsx(Ac,{label:"Repeat",checked:!!t.repeat,onChange:u=>i(u.currentTarget.checked?gw.repeat:void 0)}),t.repeat&&a.jsxs(a.Fragment,{children:[a.jsx(at,{title:"Repeat every",htmlFor:"timing-dialog-period",children:a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(ae,{type:"number",step:1,id:"timing-dialog-period",name:"timing-dialog-period",defaultValue:t.repeat.period||1,onChange:u=>s(parseInt(u.currentTarget.value,10)||1)}),a.jsx(wt,{id:"timing-dialog-periodUnit",name:"timing-dialog-periodUnit",defaultValue:t.repeat.periodUnit,onChange:u=>l(u.currentTarget.value),data:[{label:"second",value:"s"},{label:"minute",value:"min"},{label:"hour",value:"h"},{label:"day",value:"d"},{label:"week",value:"wk"},{label:"month",value:"mo"},{label:"year",value:"a"}]})]})}),t.repeat.periodUnit==="wk"&&a.jsx(at,{title:"Repeat on",children:a.jsx(rc.Group,{multiple:!0,onChange:c,children:a.jsx(Y,{justify:"space-between",mt:"md",gap:"xs",children:i8.map(u=>a.jsx(rc,{value:u,size:"xs",radius:"xl",children:u.charAt(0).toUpperCase()},u))})})})]}),a.jsx(Y,{justify:"flex-end",children:a.jsx(te,{onClick:()=>e.onOk(t),children:"OK"})})]})})}function Ka(e){var l;const{property:t,name:n,onChange:r,defaultValue:o}=e,i=e.defaultPropertyType&&e.defaultPropertyType!=="undefined"?e.defaultPropertyType:t.type[0].code,s=t.type;if((t.isArray||t.max>1)&&!e.arrayElement){if(i===V.Attachment)return a.jsx(gF,{name:n,defaultValue:o,onChange:r});const c=((l=s[0])==null?void 0:l.code)!==V.Extension;return a.jsx(n8,{property:t,name:n,path:e.path,defaultValue:o,indent:c,onChange:r,outcome:e.outcome})}else return s.length>1?a.jsx(l8,{elementDefinitionTypes:s,...e}):a.jsx(Jv,{name:n,defaultValue:o,onChange:c=>{if(e.onChange){const u=e.name.replace("[x]",Vt(s[0].code));e.onChange(c,u)}},outcome:e.outcome,elementDefinitionType:s[0],min:t.min,max:t.min,binding:t.binding,path:e.path})}function l8(e){const t=e.elementDefinitionTypes;let n;e.defaultPropertyType&&(n=t.find(i=>i.code===e.defaultPropertyType)),n||(n=t[0]);const[r,o]=p.useState(n);return a.jsxs(Y,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(wt,{style:{width:"200px"},defaultValue:r.code,"data-testid":e.name&&e.name+"-selector",onChange:i=>{o(t.find(s=>s.code===i.currentTarget.value))},data:t.map(i=>({value:i.code,label:i.code}))}),a.jsx(Jv,{name:e.name,defaultValue:e.defaultValue,outcome:e.outcome,elementDefinitionType:r,onChange:i=>{e.onChange&&e.onChange(i,e.name.replace("[x]",Vt(r.code)))},min:e.property.min,max:e.property.max,binding:e.property.binding,path:e.property.path})]})}function Jv(e){const{name:t,onChange:n,outcome:r,binding:o,path:i}=e,s=e.min!==void 0&&e.min>0,l=e.elementDefinitionType.code,c=p.useContext(Jt),u=p.useMemo(()=>{if(!kv(l)||!Ot(e.defaultValue))return e.defaultValue;const f=Object.create(null);if(c.path===e.path)iw(f,c.elements);else{const h=ic(c.path,e.path);if(h===void 0)return e.defaultValue;iw(f,c.elements,h)}return Nt(f)?f:e.defaultValue},[l,c.path,c.elements,e.path,e.defaultValue]);if(!l)return a.jsx("div",{children:"Property type not specified "});const d={name:t,defaultValue:u,onChange:n,outcome:r,path:i};switch(l){case V.SystemString:case V.canonical:case V.string:case V.time:case V.uri:case V.url:return e.path==="Project.secret.value[x]"?a.jsx(o8,{id:t,name:t,"data-testid":t,defaultValue:u,required:s,onChange:f=>{e.onChange&&e.onChange(f.currentTarget.value)},error:ze(e.outcome,t)}):a.jsx(ae,{id:t,name:t,"data-testid":t,defaultValue:u,required:s,onChange:f=>{n&&n(f.currentTarget.value)},error:ze(r,t)});case V.date:return a.jsx(ae,{type:"date",id:t,name:t,"data-testid":t,defaultValue:u,required:s,onChange:f=>{n&&n(f.currentTarget.value)},error:ze(r,t)});case V.dateTime:case V.instant:return a.jsx(as,{name:t,defaultValue:u,onChange:n,outcome:r});case V.decimal:case V.integer:case V.positiveInt:case V.unsignedInt:return a.jsx(ae,{type:"number",step:l===V.decimal?"any":"1",id:t,name:t,"data-testid":t,defaultValue:u,required:s,onChange:f=>{n&&n(f.currentTarget.valueAsNumber)}});case V.code:return a.jsx(nT,{...d,binding:o==null?void 0:o.valueSet});case V.boolean:return a.jsx(gr,{id:t,name:t,"data-testid":t,defaultChecked:!!u,onChange:f=>{n&&n(f.currentTarget.checked)}});case V.base64Binary:case V.markdown:return a.jsx(ws,{id:t,spellCheck:l!==V.base64Binary,name:t,"data-testid":t,defaultValue:u,required:s,onChange:f=>{n&&n(f.currentTarget.value)}});case V.Address:return a.jsx(D7,{...d});case V.Annotation:return a.jsx(I7,{...d});case V.Attachment:return a.jsx(rT,{...d});case V.CodeableConcept:return a.jsx(kF,{binding:o==null?void 0:o.valueSet,...d});case V.Coding:return a.jsx(hT,{binding:o==null?void 0:o.valueSet,...d});case V.ContactDetail:return a.jsx(AF,{...d});case V.ContactPoint:return a.jsx(pT,{...d});case V.Extension:return a.jsx(LF,{...d,propertyType:e.elementDefinitionType});case V.HumanName:return a.jsx($F,{...d});case V.Identifier:return a.jsx(FF,{...d});case V.Money:return a.jsx(BF,{...d});case V.Period:return a.jsx(UF,{...d});case V.Duration:case V.Quantity:return a.jsx(ls,{...d});case V.Range:return a.jsx(Xv,{...d});case V.Ratio:return a.jsx(WF,{...d});case V.Reference:return a.jsx(eh,{...d,targetTypes:u8(e.elementDefinitionType)});case V.Timing:return a.jsx(s8,{...d});case V.Dosage:case V.UsageContext:default:return a.jsx(e0,{typeName:l,path:d.path,defaultValue:u,onChange:n,outcome:r})}}const c8=[`${WO}/fhir/StructureDefinition/`,"https://medplum.com/fhir/StructureDefinition/"];function u8(e){var t;return(t=e==null?void 0:e.targetProfile)==null?void 0:t.map(n=>{const r=c8.find(o=>n.startsWith(o));return r?n.slice(r.length):n})}const Zv=["extension","modifierExtension"],d8=["id",...oT].filter(e=>!Zv.includes(e));function f8(e){const[t,n]=p.useState(e.defaultValue??{}),r=p.useContext(Jt),o=p.useMemo(()=>h8(r.elements),[r.elements]);function i(l){n(l),e.onChange&&e.onChange(l)}const s={type:e.type,value:t};return a.jsx(be,{style:{flexGrow:1},"data-testid":e.testId,children:o.map(([l,c])=>{const[u,d]=EF(s,l,c),f=c.min!==void 0&&c.min>0,h=a.jsx(Ka,{property:c,name:l,path:e.path+"."+l,defaultValue:u,defaultPropertyType:d,onChange:(m,g)=>{i(fT({...t},l,g??l,c,m))},arrayElement:void 0,outcome:e.outcome},l);return e.type==="Extension"||Zv.includes(l)?h:c.type.length===1&&c.type[0].code==="boolean"?a.jsx(uT,{title:ss(l),description:c.description,htmlFor:l,fhirPath:c.path,withAsterisk:f,children:h},l):a.jsx(at,{title:ss(l),description:c.description,withAsterisk:f,htmlFor:l,outcome:e.outcome,fhirPath:c.path,children:h},l)})})}function h8(e){return Object.entries(e).filter(([n,r])=>{var o;return!Nt(r.type)||r.max===0||r.path.toLowerCase().endsWith("extension.url")&&r.fixed||Zv.includes(n)&&!Nt((o=r.slicing)==null?void 0:o.slices)||d8.includes(n)?!1:!(iT.includes(n)&&r.path.split(".").length===2||n.includes("."))})}function e0(e){const[t]=p.useState(()=>e.defaultValue??{}),n=p.useContext(Jt),r=e.profileUrl??(n==null?void 0:n.profileUrl),o=p.useMemo(()=>Wf(e.typeName,r),[e.typeName,r]),i=(o==null?void 0:o.type)??e.typeName,s=p.useMemo(()=>{if(o)return Da({parentContext:n,elements:o.elements,path:e.path,profileUrl:o.url})},[o,e.path,n]);return o?Zf(Jt.Provider,s,a.jsx(f8,{path:e.path,type:i,defaultValue:t,onChange:e.onChange,outcome:e.outcome})):a.jsxs("div",{children:[i," not implemented"]})}const p8="_root_1vii2_1",m8={root:p8};function qc(e){const{children:t,...n}=e;return a.jsx(Hy,{className:m8.root,...n,children:t})}const g8="_noteBody_10swh_1",y8="_noteCite_10swh_5",v8="_noteRoot_10swh_10",yw={noteBody:g8,noteCite:y8,noteRoot:v8};function xT({value:e}){return e?a.jsx(be,{justify:"flex-start",gap:"xs",children:e.map(t=>{var n;return t.text&&a.jsx(Uy,{classNames:{cite:yw.noteCite,root:yw.noteRoot},cite:((n=t.authorReference)==null?void 0:n.display)||t.authorString,icon:null,children:t.text},`note-${t.text}`)})}):null}function Ya(e){const{value:t,link:n,...r}=e,[o,i]=p.useState(),s=ct(t,i);let l;if(o&&!lP(o))l=`[${Te(o)}]`;else if(s)l=Do(s);else return null;return n?a.jsx(Fe,{to:t,...r,children:l}):a.jsx(se,{component:"span",...r,children:l})}function ma(e){return a.jsxs(Y,{gap:"xs",children:[a.jsx(Pi,{size:24,radius:12,value:e.value,link:e.link}),a.jsx(Ya,{value:e.value,link:e.link})]})}const x8={draft:"blue",active:"blue","on-hold":"yellow",revoked:"red",completed:"green","entered-in-error":"red",unknown:"gray",retired:"gray",registered:"blue",preliminary:"blue",final:"green",amended:"yellow",corrected:"yellow",cancelled:"red",requested:"blue",received:"blue",accepted:"blue",rejected:"red",ready:"blue","in-progress":"blue",failed:"red",proposed:"blue",pending:"blue",booked:"blue",arrived:"blue",fulfilled:"green",noshow:"red","checked-in":"blue",waitlist:"gray",routine:"gray",urgent:"red",asap:"red",stat:"red","not-done":"red",connected:"green",disconnected:"red"};function t0(e){return a.jsx(kc,{color:x8[e.status],children:e.status})}const w8="_table_pe9td_1",S8="_criticalRow_pe9td_12",b8="_noteBody_pe9td_23",C8="_noteCite_pe9td_27",E8="_noteRoot_pe9td_32",wT={table:w8,criticalRow:S8,noteBody:b8,noteCite:C8,noteRoot:E8};n0.defaultProps={hideObservationNotes:!1,hideSpecimenInfo:!1};function n0(e){var s;const t=ne(),n=ct(e.value),[r,o]=p.useState();if(p.useEffect(()=>{n!=null&&n.specimen&&Promise.allSettled(n.specimen.map(l=>t.readReference(l))).then(l=>l.filter(c=>c.status==="fulfilled").map(c=>c.value)).then(o).catch(console.error)},[t,n]),!n)return null;const i=(r==null?void 0:r.flatMap(l=>l.note||[]))||[];if(n.presentedForm&&n.presentedForm.length>0){const l=n.presentedForm[0];(s=l.contentType)!=null&&s.startsWith("text/plain")&&l.data&&i.push({text:window.atob(l.data)})}return a.jsxs(be,{children:[a.jsx(ue,{children:"Diagnostic Report"}),a.jsx(j8,{value:n}),r&&!e.hideSpecimenInfo&&P8(r),n.result&&a.jsx(T8,{hideObservationNotes:e.hideObservationNotes,value:n.result}),i.length>0&&a.jsx(xT,{value:i})]})}function j8({value:e}){var t,n;return a.jsxs(Y,{mt:"md",gap:30,children:[e.subject&&a.jsxs("div",{children:[a.jsx(se,{size:"xs",tt:"uppercase",c:"dimmed",children:"Subject"}),a.jsx(ma,{value:e.subject,link:!0})]}),(t=e.resultsInterpreter)==null?void 0:t.map(r=>a.jsxs("div",{children:[a.jsx(se,{size:"xs",tt:"uppercase",c:"dimmed",children:"Interpreter"}),a.jsx(ma,{value:r,link:!0})]},r.reference)),(n=e.performer)==null?void 0:n.map(r=>a.jsxs("div",{children:[a.jsx(se,{size:"xs",tt:"uppercase",c:"dimmed",children:"Performer"}),a.jsx(ma,{value:r,link:!0})]},r.reference)),e.issued&&a.jsxs("div",{children:[a.jsx(se,{size:"xs",tt:"uppercase",c:"dimmed",children:"Issued"}),a.jsx(se,{children:jn(e.issued)})]}),e.status&&a.jsxs("div",{children:[a.jsx(se,{size:"xs",tt:"uppercase",c:"dimmed",children:"Status"}),a.jsx(se,{children:Vt(e.status)})]})]})}function P8(e){return a.jsxs(be,{gap:"xs",children:[a.jsx(ue,{order:2,size:"h6",children:"Specimens"}),a.jsx(Cn,{type:"ordered",children:e==null?void 0:e.map(t=>{var n;return a.jsx(Cn.Item,{ml:"sm",children:a.jsxs(Y,{gap:20,children:[a.jsxs(Y,{gap:5,children:[a.jsx(se,{fw:500,children:"Collected:"})," ",jn((n=t.collection)==null?void 0:n.collectedDateTime)]}),a.jsxs(Y,{gap:5,children:[a.jsx(se,{fw:500,children:"Received:"})," ",jn(t.receivedTime)]})]})},`specimen-${t.id}`)})})]})}function T8(e){return a.jsxs("table",{className:wT.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Test"}),a.jsx("th",{children:"Value"}),a.jsx("th",{children:"Reference Range"}),a.jsx("th",{children:"Interpretation"}),a.jsx("th",{children:"Category"}),a.jsx("th",{children:"Performer"}),a.jsx("th",{children:"Status"})]})}),a.jsx("tbody",{children:a.jsx(ST,{value:e.value,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes})})]})}function ST(e){var t;return a.jsx(a.Fragment,{children:(t=e.value)==null?void 0:t.map(n=>a.jsx(k8,{value:n,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes},`obs-${Ps(n)?n.reference:n.id}`))})}function k8(e){var o,i;const t=ct(e.value);if(!t||(o=e.ancestorIds)!=null&&o.includes(t.id))return null;const n=!e.hideObservationNotes&&t.note,r=I8(t);return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:et({[wT.criticalRow]:r}),children:[a.jsx("td",{rowSpan:n?2:1,children:a.jsx(Fe,{to:t,children:a.jsx(io,{value:t.code})})}),a.jsx("td",{children:a.jsx(R8,{value:t})}),a.jsx("td",{children:a.jsx(D8,{value:t.referenceRange})}),a.jsx("td",{children:t.interpretation&&t.interpretation.length>0&&a.jsx(io,{value:t.interpretation[0]})}),a.jsx("td",{children:t.category&&t.category.length>0&&a.jsx(a.Fragment,{children:t.category.map(s=>a.jsx("div",{children:a.jsx(io,{value:s})},`category-${wi(s)}`))})}),a.jsx("td",{children:(i=t.performer)==null?void 0:i.map(s=>a.jsx(Ld,{value:s},s.reference))}),a.jsx("td",{children:t.status&&a.jsx(t0,{status:t.status})})]}),t.hasMember&&a.jsx(ST,{value:t.hasMember,ancestorIds:e.ancestorIds?[...e.ancestorIds,t.id]:[t.id],hideObservationNotes:e.hideObservationNotes}),n&&a.jsx("tr",{children:a.jsx("td",{colSpan:6,children:a.jsx(xT,{value:t.note})})})]})}function R8(e){const t=e.value;return a.jsx(a.Fragment,{children:kP(t)})}function D8(e){const t=e.value&&e.value.length>0&&e.value[0];return t?t.text?a.jsx(a.Fragment,{children:t.text}):a.jsx(Yv,{value:t}):null}function I8(e){var n,r,o,i;const t=(i=(o=(r=(n=e.interpretation)==null?void 0:n[0])==null?void 0:r.coding)==null?void 0:o[0])==null?void 0:i.code;return t==="AA"||t==="LL"||t==="HH"||t==="A"}const _8="_paper_1igaj_1",A8="_fill_1igaj_20",vw={paper:_8,fill:A8};function r0(e){const{width:t,fill:n,className:r,children:o,...i}=e,s=t?{maxWidth:t}:void 0;return a.jsx(zn,{className:et(vw.paper,n&&vw.fill,r),style:s,shadow:"sm",radius:"sm",withBorder:!0,...i,children:o})}var bT={},Gc={};Object.defineProperty(Gc,"__esModule",{value:!0});Gc.Pointer=void 0;function N8(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function O8(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var M8=function(){function e(t){t===void 0&&(t=[""]),this.tokens=t}return e.fromJSON=function(t){var n=t.split("/").map(N8);if(n[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(t));return new e(n)},e.prototype.toString=function(){return this.tokens.map(O8).join("/")},e.prototype.evaluate=function(t){for(var n=null,r="",o=t,i=1,s=this.tokens.length;i<s;i++)n=o,r=this.tokens[i],!(r=="__proto__"||r=="constructor"||r=="prototype")&&(o=(n||{})[r]);return{parent:n,key:r,value:o}},e.prototype.get=function(t){return this.evaluate(t).value},e.prototype.set=function(t,n){var r=this.evaluate(t);r.parent&&(r.parent[r.key]=n)},e.prototype.push=function(t){this.tokens.push(t)},e.prototype.add=function(t){var n=this.tokens.concat(String(t));return new e(n)},e}();Gc.Pointer=M8;var It={},o0={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.clone=e.objectType=e.hasOwnProperty=void 0,e.hasOwnProperty=Object.prototype.hasOwnProperty;function t(o){return o===void 0?"undefined":o===null?"null":Array.isArray(o)?"array":typeof o}e.objectType=t;function n(o){return o!=null&&typeof o=="object"}function r(o){if(!n(o))return o;if(o.constructor==Array){for(var i=o.length,s=new Array(i),l=0;l<i;l++)s[l]=r(o[l]);return s}if(o.constructor==Date){var c=new Date(+o);return c}var u={};for(var d in o)e.hasOwnProperty.call(o,d)&&(u[d]=r(o[d]));return u}e.clone=r})(o0);var bn={};Object.defineProperty(bn,"__esModule",{value:!0});bn.diffAny=bn.diffObjects=bn.diffArrays=bn.intersection=bn.subtract=bn.isDestructive=void 0;var uc=o0;function L8(e){var t=e.op;return t==="remove"||t==="replace"||t==="copy"||t==="move"}bn.isDestructive=L8;function _m(e,t){var n={};for(var r in e)uc.hasOwnProperty.call(e,r)&&e[r]!==void 0&&(n[r]=1);for(var o in t)uc.hasOwnProperty.call(t,o)&&t[o]!==void 0&&delete n[o];return Object.keys(n)}bn.subtract=_m;function CT(e){for(var t=e.length,n={},r=0;r<t;r++){var o=e[r];for(var i in o)uc.hasOwnProperty.call(o,i)&&o[i]!==void 0&&(n[i]=(n[i]||0)+1)}for(var i in n)n[i]<t&&delete n[i];return Object.keys(n)}bn.intersection=CT;function $8(e){return e.op==="add"}function F8(e){return e.op==="remove"}function ip(e,t){return{operations:e.operations.concat(t),cost:e.cost+1}}function ET(e,t,n,r){r===void 0&&(r=th);var o={"0,0":{operations:[],cost:0}};function i(d,f){var h="".concat(d,",").concat(f),m=o[h];if(m===void 0){if(d>0&&f>0&&!r(e[d-1],t[f-1],n.add(String(d-1))).length)m=i(d-1,f-1);else{var g=[];if(d>0){var y=i(d-1,f),S={op:"remove",index:d-1};g.push(ip(y,S))}if(f>0){var v=i(d,f-1),x={op:"add",index:d-1,value:t[f-1]};g.push(ip(v,x))}if(d>0&&f>0){var w=i(d-1,f-1),b={op:"replace",index:d-1,original:e[d-1],value:t[f-1]};g.push(ip(w,b))}var j=g.sort(function(E,P){return E.cost-P.cost})[0];m=j}o[h]=m}return m}var s=isNaN(e.length)||e.length<=0?0:e.length,l=isNaN(t.length)||t.length<=0?0:t.length,c=i(s,l).operations,u=c.reduce(function(d,f){var h=d[0],m=d[1];if($8(f)){var g=f.index+1+m,y=g<s+m?String(g):"-",S={op:f.op,path:n.add(y).toString(),value:f.value};return[h.concat(S),m+1]}else if(F8(f)){var S={op:f.op,path:n.add(String(f.index+m)).toString()};return[h.concat(S),m-1]}else{var v=n.add(String(f.index+m)),x=r(f.original,f.value,v);return[h.concat.apply(h,x),m]}},[[],0])[0];return u}bn.diffArrays=ET;function jT(e,t,n,r){r===void 0&&(r=th);var o=[];return _m(e,t).forEach(function(i){o.push({op:"remove",path:n.add(i).toString()})}),_m(t,e).forEach(function(i){o.push({op:"add",path:n.add(i).toString(),value:t[i]})}),CT([e,t]).forEach(function(i){o.push.apply(o,r(e[i],t[i],n.add(i)))}),o}bn.diffObjects=jT;function th(e,t,n,r){if(r===void 0&&(r=th),e===t)return[];var o=(0,uc.objectType)(e),i=(0,uc.objectType)(t);return o=="array"&&i=="array"?ET(e,t,n,r):o=="object"&&i=="object"?jT(e,t,n,r):[{op:"replace",path:n.toString(),value:t}]}bn.diffAny=th;var i0=j0&&j0.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(r[i]=o[i])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(It,"__esModule",{value:!0});It.apply=It.InvalidOperationError=It.test=It.copy=It.move=It.replace=It.remove=It.add=It.TestError=It.MissingError=void 0;var _o=Gc,s0=o0,z8=bn,so=function(e){i0(t,e);function t(n){var r=e.call(this,"Value required at path: ".concat(n))||this;return r.path=n,r.name="MissingError",r}return t}(Error);It.MissingError=so;var PT=function(e){i0(t,e);function t(n,r){var o=e.call(this,"Test failed: ".concat(n," != ").concat(r))||this;return o.actual=n,o.expected=r,o.name="TestError",o}return t}(Error);It.TestError=PT;function a0(e,t,n){if(Array.isArray(e))if(t=="-")e.push(n);else{var r=parseInt(t,10);e.splice(r,0,n)}else e[t]=n}function TT(e,t){if(Array.isArray(e)){var n=parseInt(t,10);e.splice(n,1)}else delete e[t]}function kT(e,t){var n=_o.Pointer.fromJSON(t.path).evaluate(e);return n.parent===void 0?new so(t.path):(a0(n.parent,n.key,(0,s0.clone)(t.value)),null)}It.add=kT;function RT(e,t){var n=_o.Pointer.fromJSON(t.path).evaluate(e);return n.value===void 0?new so(t.path):(TT(n.parent,n.key),null)}It.remove=RT;function DT(e,t){var n=_o.Pointer.fromJSON(t.path).evaluate(e);if(n.parent===null)return new so(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new so(t.path)}else if(n.value===void 0)return new so(t.path);return n.parent[n.key]=(0,s0.clone)(t.value),null}It.replace=DT;function IT(e,t){var n=_o.Pointer.fromJSON(t.from).evaluate(e);if(n.value===void 0)return new so(t.from);var r=_o.Pointer.fromJSON(t.path).evaluate(e);return r.parent===void 0?new so(t.path):(TT(n.parent,n.key),a0(r.parent,r.key,n.value),null)}It.move=IT;function _T(e,t){var n=_o.Pointer.fromJSON(t.from).evaluate(e);if(n.value===void 0)return new so(t.from);var r=_o.Pointer.fromJSON(t.path).evaluate(e);return r.parent===void 0?new so(t.path):(a0(r.parent,r.key,(0,s0.clone)(n.value)),null)}It.copy=_T;function AT(e,t){var n=_o.Pointer.fromJSON(t.path).evaluate(e);return(0,z8.diffAny)(n.value,t.value,new _o.Pointer).length?new PT(n.value,t.value):null}It.test=AT;var NT=function(e){i0(t,e);function t(n){var r=e.call(this,"Invalid operation: ".concat(n.op))||this;return r.operation=n,r.name="InvalidOperationError",r}return t}(Error);It.InvalidOperationError=NT;function B8(e,t){switch(t.op){case"add":return kT(e,t);case"remove":return RT(e,t);case"replace":return DT(e,t);case"move":return IT(e,t);case"copy":return _T(e,t);case"test":return AT(e,t)}return new NT(t)}It.apply=B8;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createTests=e.createPatch=e.applyPatch=e.Pointer=void 0;var t=Gc;Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}});var n=It,r=bn;function o(u,d){return d.map(function(f){return(0,n.apply)(u,f)})}e.applyPatch=o;function i(u){function d(f,h,m){var g=u(f,h,m);return Array.isArray(g)?g:(0,r.diffAny)(f,h,m,d)}return d}function s(u,d,f){var h=new t.Pointer;return(f?i(f):r.diffAny)(u,d,h)}e.createPatch=s;function l(u,d){var f=t.Pointer.fromJSON(d).evaluate(u);if(f!==void 0)return{op:"test",path:d,value:f.value}}function c(u,d){var f=new Array;return d.filter(r.isDestructive).forEach(function(h){var m=l(u,h.path);if(m&&f.push(m),"from"in h){var g=l(u,h.from);g&&f.push(g)}}),f}e.createTests=c})(bT);const U8="_root_w6lfx_1",V8="_removed_w6lfx_16",W8="_added_w6lfx_21",sp={root:U8,removed:V8,added:W8};function H8(e){const t=ne(),{original:n,revised:r}=e,[o,i]=p.useState(!1);p.useEffect(()=>{t.requestSchema(e.original.resourceType).then(()=>i(!0)).catch(console.log)},[t,e.original.resourceType]);const s=p.useMemo(()=>{if(!o)return null;const l=[lo(n)],c=[lo(r)],u=[],d=q8(bT.createPatch(n,r));for(const f of d){const h=f.path,m=G8(h),g=Q8(n.resourceType,m),y=f.op==="add"?void 0:lc(m,l),S=f.op==="remove"?void 0:lc(m,c);u.push({key:`op-${f.op}-${f.path}`,name:`${Vt(f.op)} ${m}`,path:(g==null?void 0:g.path)??n.resourceType+"."+m,property:g,originalValue:xw(g,y),revisedValue:xw(g,S)})}return u},[o,n,r]);return s?a.jsxs(le,{className:sp.root,children:[a.jsx(le.Thead,{children:a.jsxs(le.Tr,{children:[a.jsx(le.Th,{}),a.jsx(le.Th,{children:"Before"}),a.jsx(le.Th,{children:"After"})]})}),a.jsx(le.Tbody,{children:s.map(l=>a.jsxs(le.Tr,{children:[a.jsx(le.Td,{children:l.name}),a.jsx(le.Td,{className:sp.removed,children:l.originalValue&&a.jsx(Fr,{path:l.path,property:l.property,propertyType:l.originalValue.type,value:l.originalValue.value,ignoreMissingValues:!0})}),a.jsx(le.Td,{className:sp.added,children:l.revisedValue&&a.jsx(Fr,{path:l.path,property:l.property,propertyType:l.revisedValue.type,value:l.revisedValue.value,ignoreMissingValues:!0})})]},l.key))})]}):null}function q8(e){const t=[];for(const n of e){const{op:r,path:o}=n;if(o.startsWith("/meta/author")||o.startsWith("/meta/compartment")||o.startsWith("/meta/lastUpdated")||o.startsWith("/meta/versionId"))continue;const i=e.filter(l=>l.op===r&&l.path===o).length,s={op:r,path:o};i>1&&(r==="add"||r==="remove")&&/\/[0-9-]+$/.test(o)&&(s.op="replace",s.path=o.replace(/\/[^/]+$/,"")),t.some(l=>l.op===s.op&&l.path===s.path)||t.push(s)}return t}function G8(e){const t=e.split("/").filter(Boolean);let n="";for(let r=0;r<t.length;r++){const o=t[r];o==="-"?n+=".last()":/^\d+$/.test(o)?n+=`[${o}]`:(r>0&&(n+="."),n+=o)}return n.endsWith(".url")&&(n=n.replace(/\.url$/,"")),n}function Q8(e,t){var r;const n=Gf(e,{resourceType:"SearchParameter",base:[e],code:e+"."+t,expression:e+"."+t});return(r=n==null?void 0:n.elementDefinitions)==null?void 0:r[0]}function xw(e,t){return t&&{type:Array.isArray(t)?t[0].type:t.type,value:K8(t,!!(e!=null&&e.isArray))}}function K8(e,t){const n=jL(e).flatMap(r=>r.value);return t?n:n[0]}function l0(e){const{profileUrl:t}=e,n=ne(),r=ct(e.value),[o,i]=p.useState();return p.useEffect(()=>{if(r)if(t)n.requestProfileSchema(t,{expandProfile:!0}).then(()=>{const s=Cs(t);s?i(s.name):console.error(`Schema not found for ${t}`)}).catch(s=>{console.error("Error in requestProfileSchema",s)});else{const s=r.resourceType;n.requestSchema(s).then(()=>{i(s)}).catch(console.error)}},[n,t,r]),!o||!r?null:a.jsx($d,{path:r.resourceType,value:{type:o,value:e.forceUseInput?e.value:r},profileUrl:t,ignoreMissingValues:e.ignoreMissingValues})}function Y8(e){return a.jsx(qc,{children:e.children})}function cs(e){var c,u;const{resource:t,profile:n,padding:r,popupMenuItems:o,...i}=e,s=n??((c=t.meta)==null?void 0:c.author),l=e.dateTime??((u=t.meta)==null?void 0:u.lastUpdated);return a.jsxs(r0,{"data-testid":"timeline-item",fill:!0,...i,children:[a.jsxs(Y,{justify:"space-between",gap:8,mx:"xs",my:"sm",children:[a.jsx(Pi,{value:s,link:!0,size:"md"}),a.jsxs("div",{style:{flex:1},children:[a.jsx(se,{size:"sm",children:a.jsx(Ya,{c:"dark",fw:500,value:s,link:!0})}),a.jsxs(se,{size:"xs",children:[a.jsx(Fe,{c:"dimmed",to:e.resource,children:jn(l)}),a.jsx(se,{component:"span",c:"dimmed",mx:8,children:"·"}),a.jsx(Fe,{c:"dimmed",to:e.resource,children:e.resource.resourceType})]})]}),o&&a.jsxs(Z,{position:"bottom-end",shadow:"md",width:200,children:[a.jsx(Z.Target,{children:a.jsx(qt,{color:"gray",variant:"subtle",radius:"xl","aria-label":`Actions for ${ht(e.resource)}`,children:a.jsx(Q7,{})})}),o]})]}),a.jsxs(ZP,{children:[r&&a.jsx("div",{style:{padding:"0 16px 16px 16px"},children:e.children}),!r&&a.jsx(a.Fragment,{children:e.children})]})]})}function OT(e,t){e.sort((n,r)=>{const o=ww(n,t),i=ww(r,t);return o>i?1:o<i?-1:Sw(n,t)-Sw(r,t)})}function ww(e,t){if(!MT(e,t)){const n=e.priority;if(typeof n=="string")return{stat:4,asap:3,urgent:2}[n]??0}return 0}function Sw(e,t){var r;if(!MT(e,t)){if(e.resourceType==="Communication"&&e.sent)return new Date(e.sent).getTime();if((e.resourceType==="DiagnosticReport"||e.resourceType==="Media"||e.resourceType==="Observation")&&e.issued)return new Date(e.issued).getTime();if(e.resourceType==="DocumentReference"&&e.date)return new Date(e.date).getTime()}const n=(r=e.meta)==null?void 0:r.lastUpdated;return n?new Date(n).getTime():0}function MT(e,t){return!!t&&e.resourceType===t.resourceType&&e.id===t.id}const X8="_pinnedComment_5uxzi_2",J8={pinnedComment:X8};function nh(e){const t=ne(),n=Yf(),r=t.getProfile(),o=p.useRef(null),i=ct(e.value),[s,l]=p.useState(),[c,u]=p.useState([]),d=e.loadTimelineResources,f=p.useRef(c);f.current=c;const h=p.useCallback(I=>{OT(I,i),I.reverse(),u(I)},[i]),m=p.useCallback(I=>{const $=[];for(const N of I){if(N.status!=="fulfilled")continue;const L=N.value;if(L.type==="history"&&l(L),L.entry)for(const M of L.entry)$.push(M.resource)}h($)},[h]),g=p.useCallback(I=>h([...f.current,I]),[h]),y=p.useCallback(()=>{var N;let I,$;"resourceType"in e.value?(I=e.value.resourceType,$=e.value.id):[I,$]=(N=e.value.reference)==null?void 0:N.split("/"),d(t,I,$).then(m).catch(console.log)},[t,e.value,d,m]);p.useEffect(()=>y(),[y]);function S(I){!i||!e.createCommunication||t.createResource(e.createCommunication(i,r,I)).then($=>g($)).catch(console.log)}function v(I){!i||!e.createMedia||t.createResource(e.createMedia(i,r,I)).then($=>g($)).then(()=>El({id:"upload-notification",color:"teal",title:"Upload complete",message:"",icon:a.jsx(Jf,{size:16}),autoClose:2e3})).catch($=>El({id:"upload-notification",color:"red",title:"Upload error",message:Te($),icon:a.jsx(uw,{size:16}),autoClose:2e3}))}function x(I,$){return t.updateResource({...I,priority:$})}function w(I){x(I,"stat").then(y).catch(console.log)}function b(I){x(I,"routine").then(y).catch(console.log)}function j(I){n(`/${I.resourceType}/${I.id}`)}function E(I){n(`/${I.resourceType}/${I.id}/edit`)}function P(I){n(`/${I.resourceType}/${I.id}/delete`)}function T(I){var $;n(`/${I.resourceType}/${I.id}/_history/${($=I.meta)==null?void 0:$.versionId}`)}function D(){fe({id:"upload-notification",loading:!0,title:"Initializing upload...",message:"Please wait...",autoClose:!1,withCloseButton:!1})}function _(I){El({id:"upload-notification",loading:!0,title:"Uploading...",message:iz(I),autoClose:!1,withCloseButton:!1})}function O(I){El({id:"upload-notification",color:"red",title:"Upload error",message:Te(I),icon:a.jsx(uw,{size:16}),autoClose:2e3})}return i?a.jsxs(Y8,{children:[e.createCommunication&&a.jsx(r0,{children:a.jsx(We,{testid:"timeline-form",onSubmit:I=>{S(I.text);const $=o.current;$&&($.value="",$.focus())},children:a.jsxs(Y,{gap:"xs",wrap:"nowrap",style:{width:"100%"},children:[a.jsx(Pi,{value:r}),a.jsx(ae,{name:"text",ref:o,placeholder:"Add comment",style:{width:"100%",maxWidth:300}}),a.jsx(qt,{type:"submit",radius:"xl",color:"blue",variant:"filled",children:a.jsx(o6,{size:16})}),a.jsx(Kv,{securityContext:ft(i),onUpload:v,onUploadStart:D,onUploadProgress:_,onUploadError:O,children:I=>a.jsx(qt,{...I,radius:"xl",color:"blue",variant:"filled",children:a.jsx(Bv,{size:16})})})]})})}),c.map(I=>{var N;if(!I)return null;const $=`${I.resourceType}/${I.id}/${(N=I.meta)==null?void 0:N.versionId}`;if(I.resourceType===i.resourceType&&I.id===i.id)return a.jsx(Z8,{history:s,resource:I,onDetails:T},$);switch(I.resourceType){case"AuditEvent":return a.jsx(rz,{resource:I,onDetails:j},$);case"Communication":return a.jsx(tz,{resource:I,onPin:I.priority!=="stat"?w:void 0,onUnpin:I.priority==="stat"?b:void 0,onDetails:j,onEdit:E,onDelete:P},$);case"DiagnosticReport":return a.jsx(oz,{resource:I,onDetails:j,onEdit:E,onDelete:P},$);case"Media":return a.jsx(nz,{resource:I,onDetails:j,onEdit:E,onDelete:P},$);default:return a.jsx(cs,{resource:I,padding:!0,children:a.jsx(l0,{value:I,ignoreMissingValues:!0})},$)}})]}):a.jsx(on,{style:{width:"100%",height:"100%"},children:a.jsx(Vn,{})})}function _a(e){return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Label,{children:"Resource"}),e.onPin&&a.jsx(Z.Item,{leftSection:a.jsx(a6,{size:14}),onClick:()=>e.onPin(e.resource),"aria-label":`Pin ${ht(e.resource)}`,children:"Pin"}),e.onUnpin&&a.jsx(Z.Item,{leftSection:a.jsx(l6,{size:14}),onClick:()=>e.onUnpin(e.resource),"aria-label":`Unpin ${ht(e.resource)}`,children:"Unpin"}),e.onDetails&&a.jsx(Z.Item,{leftSection:a.jsx(e6,{size:14}),onClick:()=>e.onDetails(e.resource),"aria-label":`Details ${ht(e.resource)}`,children:"Details"}),e.onEdit&&a.jsx(Z.Item,{leftSection:a.jsx(K7,{size:14}),onClick:()=>e.onEdit(e.resource),"aria-label":`Edit ${ht(e.resource)}`,children:"Edit"}),e.onDelete&&a.jsxs(a.Fragment,{children:[a.jsx(Z.Divider,{}),a.jsx(Z.Label,{children:"Danger zone"}),a.jsx(Z.Item,{color:"red",leftSection:a.jsx(JP,{size:14}),onClick:()=>e.onDelete(e.resource),"aria-label":`Delete ${ht(e.resource)}`,children:"Delete"})]})]})}function Z8(e){const t=ez(e.history,e.resource);return t?a.jsx(cs,{resource:e.resource,padding:!0,popupMenuItems:a.jsx(_a,{...e}),children:a.jsx(H8,{original:t,revised:e.resource})}):a.jsxs(cs,{resource:e.resource,padding:!0,popupMenuItems:a.jsx(_a,{...e}),children:[a.jsx("h3",{children:"Created"}),a.jsx(l0,{value:e.resource,ignoreMissingValues:!0,forceUseInput:!0})]})}function ez(e,t){const n=e.entry,r=n.findIndex(o=>{var i,s,l;return((s=(i=o.resource)==null?void 0:i.meta)==null?void 0:s.versionId)===((l=t.meta)==null?void 0:l.versionId)});if(!(r>=n.length-1))return n[r+1].resource}function tz(e){var r,o;const n=!e.resource.priority||e.resource.priority==="routine"?void 0:J8.pinnedComment;return a.jsx(cs,{resource:e.resource,profile:e.resource.sender,dateTime:e.resource.sent,padding:!0,className:n,popupMenuItems:a.jsx(_a,{...e}),children:a.jsx("p",{children:(o=(r=e.resource.payload)==null?void 0:r[0])==null?void 0:o.contentString})})}function nz(e){var r;const t=(r=e.resource.content)==null?void 0:r.contentType,n=t&&!t.startsWith("image/")&&!t.startsWith("video/")&&t!=="application/pdf";return a.jsx(cs,{resource:e.resource,padding:!!n,popupMenuItems:a.jsx(_a,{...e}),children:a.jsx(Vc,{value:e.resource.content})})}function rz(e){return a.jsx(cs,{resource:e.resource,padding:!0,popupMenuItems:a.jsx(_a,{...e}),children:a.jsx(vr,{children:a.jsx("pre",{children:e.resource.outcomeDesc})})})}function oz(e){return a.jsx(cs,{resource:e.resource,padding:!0,popupMenuItems:a.jsx(_a,{...e}),children:a.jsx(n0,{value:e.resource})})}function iz(e){if(e.lengthComputable){const t=100*e.loaded/e.total;return`Uploaded: ${ap(e.loaded)} / ${ap(e.total)} ${t.toFixed(2)}%`}return`Uploaded: ${ap(e.loaded)}`}function ap(e){if(e===0)return"0.00 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)+" "+" KMGTP".charAt(t)+"B"}function sz(e){return a.jsx(nh,{value:e.resource,loadTimelineResources:async(t,n,r)=>{const o=`${n}/${r}`;return Promise.allSettled([t.readHistory(n,r),t.search("Task",{_filter:`based-on eq ${o} or focus eq ${o} or subject eq ${o}`,_count:100})])}})}function Se(e){const{children:t,...n}=e;return a.jsx(qc,{children:a.jsx(r0,{...n,children:t})})}function az(e){return a.jsx(nh,{value:e.encounter,loadTimelineResources:async(t,n,r)=>Promise.allSettled([t.readHistory("Encounter",r),t.search("Communication","encounter=Encounter/"+r),t.search("Media","encounter=Encounter/"+r)]),createCommunication:(t,n,r)=>({resourceType:"Communication",status:"completed",encounter:ft(t),subject:t.subject,sender:ft(n),sent:new Date().toISOString(),payload:[{contentString:r}]}),createMedia:(t,n,r)=>({resourceType:"Media",status:"completed",encounter:ft(t),subject:t.subject,operator:ft(n),issued:new Date().toISOString(),content:r})})}function lz(e){let t;try{t=y$(e.path,e.resource)}catch(n){return console.warn("FhirPathDisplay:",n),null}if(t.length>1)throw new Error(`Component "path" for "FhirPathDisplay" must resolve to a single element. Received ${t.length} elements [${JSON.stringify(t,null,2)}]`);return a.jsx(Fr,{value:t[0]||"",propertyType:e.propertyType})}function cz(e){return a.jsxs(Dn,{title:"Export",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:e.onCancel,children:[a.jsxs(W,{display:"flex",style:{justifyContent:"space-between"},children:[e.exportCsv&&a.jsx(bw,{text:"CSV",exportLogic:e.exportCsv,onCancel:e.onCancel}),e.exportTransactionBundle&&a.jsx(bw,{text:"Transaction Bundle",exportLogic:e.exportTransactionBundle,onCancel:e.onCancel})]}),a.jsx(se,{style:{marginTop:"10px",marginLeft:"2px"},children:"Limited to 1000 records"})]})}function bw(e){return a.jsx(te,{onClick:()=>{e.exportLogic(),e.onCancel()},children:`Export as ${e.text}`})}const uz={string:[ie.EQUALS,ie.NOT,ie.CONTAINS,ie.EXACT],fulltext:[ie.EQUALS,ie.NOT,ie.CONTAINS,ie.EXACT],token:[ie.EQUALS,ie.NOT],reference:[ie.EQUALS,ie.NOT],numeric:[ie.EQUALS,ie.NOT_EQUALS,ie.GREATER_THAN,ie.LESS_THAN,ie.GREATER_THAN_OR_EQUALS,ie.LESS_THAN_OR_EQUALS],quantity:[ie.EQUALS,ie.NOT_EQUALS,ie.GREATER_THAN,ie.LESS_THAN,ie.GREATER_THAN_OR_EQUALS,ie.LESS_THAN_OR_EQUALS],date:[ie.EQUALS,ie.NOT_EQUALS,ie.GREATER_THAN,ie.LESS_THAN,ie.GREATER_THAN_OR_EQUALS,ie.LESS_THAN_OR_EQUALS,ie.STARTS_AFTER,ie.ENDS_BEFORE,ie.APPROXIMATELY],datetime:[ie.EQUALS,ie.NOT_EQUALS,ie.GREATER_THAN,ie.LESS_THAN,ie.GREATER_THAN_OR_EQUALS,ie.LESS_THAN_OR_EQUALS,ie.STARTS_AFTER,ie.ENDS_BEFORE,ie.APPROXIMATELY]},dz={eq:"equals",ne:"not equals",gt:"greater than",lt:"less than",ge:"greater than or equals",le:"less than or equals",sa:"starts after",eb:"ends before",ap:"approximately",contains:"contains",exact:"exact",text:"text",not:"not",above:"above",below:"below",in:"in","not-in":"not in","of-type":"of type",missing:"missing",identifier:"identifier",iterate:"iterate"};function c0(e,t){return{...e,filters:t,offset:0,name:void 0}}function u0(e,t){return c0(e,(e.filters??[]).filter(n=>n.code!==t))}function rh(e,t,n,r,o){o&&(e=u0(e,t));const i=[];return e.filters&&i.push(...e.filters),i.push({code:t,operator:n,value:r??""}),c0(e,i)}function fz(e,t){if(!e.filters)return e;const n=[...e.filters];return n.splice(t,1),{...e,filters:n,name:void 0}}function hz(e,t){return d0(e,t,-1)}function pz(e,t){return d0(e,t,0)}function mz(e,t){return d0(e,t,1)}function d0(e,t,n){const r=new Date;r.setDate(r.getDate()+n),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setDate(o.getDate()+1),o.setTime(o.getTime()-1),h0(e,t,r,o)}function gz(e,t){return f0(e,t,-1)}function yz(e,t){return f0(e,t,0)}function vz(e,t){return f0(e,t,1)}function f0(e,t,n){const r=new Date;r.setMonth(r.getMonth()+n),r.setDate(1),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setMonth(o.getMonth()+1),o.setDate(1),o.setHours(0,0,0,0),o.setTime(o.getTime()-1),h0(e,t,r,o)}function xz(e,t){const n=new Date;return n.setMonth(0),n.setDate(1),n.setHours(0,0,0,0),h0(e,t,n,new Date)}function h0(e,t,n,r){return e=u0(e,t),e=Cw(e,t,ie.GREATER_THAN_OR_EQUALS,n),e=Cw(e,t,ie.LESS_THAN_OR_EQUALS,r),e}function Cw(e,t,n,r){return rh(e,t,n,r.toISOString())}function Ew(e,t,n=!0){return rh(e,t,ie.MISSING,n.toString())}function wz(e,t){return e.offset===t?e:{...e,offset:t,name:void 0}}function Sz(e,t){const n=e.count??Qf,r=(t-1)*n;return wz(e,r)}function bz(e,t,n){return t===Cz(e)&&n!==void 0&&n===Ez(e)?e:{...e,sortRules:[{code:t,descending:!!n}],name:void 0}}function Cz(e){const t=e.sortRules;if(!t||t.length===0)return;const n=t[0].code;return n.startsWith("-")?n.substr(1):n}function Ez(e){const t=e.sortRules;return!t||t.length===0?!1:!!t[0].descending}function jz(e){return uz[e.type]}function p0(e){return dz[e]??""}function Si(e){let t=e;return t.includes(".")&&(t=t.split(".").pop()),t==="versionId"?"Version ID":(t=t.replace("[x]",""),t=t.replace(/([A-Z])/g," $1"),t=t.replace(/[-_]/g," "),t=t.replace(/\s+/g," "),t=t.trim(),t.toLowerCase()==="id"?"ID":t.split(/\s/).map(Vt).join(" "))}function Pz(e,t){var r,o;const n=t.name;return n==="id"?e.id:n==="meta.versionId"?(r=e.meta)==null?void 0:r.versionId:n==="_lastUpdated"?jn((o=e.meta)==null?void 0:o.lastUpdated):t.elementDefinition&&`${e.resourceType}.${t.name}`===t.elementDefinition.path?Tz(e,t.elementDefinition):t.searchParams&&t.searchParams.length===1&&t.name===t.searchParams[0].code?kz(e,t.searchParams[0]):null}function Tz(e,t){var i,s,l;const n=((l=(s=(i=t.path)==null?void 0:i.split("."))==null?void 0:s.pop())==null?void 0:l.replaceAll("[x]",""))??"",[r,o]=Wc({type:e.resourceType,value:e},n);return r?a.jsx(Fr,{path:t.path,property:t,propertyType:o,value:r,maxWidth:200,ignoreMissingValues:!0,link:!1}):null}function kz(e,t){const n=lc(t.expression,[{type:e.resourceType,value:e}]);return!n||n.length===0?null:a.jsx(a.Fragment,{children:n.map((r,o)=>a.jsx(Fr,{propertyType:r.type,value:r.value,maxWidth:200,ignoreMissingValues:!0,link:!1},`${o}-${n.length}`))})}function Rz(e){const t=p.useRef(!1),[n,r]=p.useState({search:JSON.parse(tr(e.search))}),[o,i]=p.useState(!1);p.useEffect(()=>{r({search:e.search})},[e.search]);const s=p.useMemo(()=>{if(!e.visible)return[];const c=e.search.resourceType,u=pP(c),d=Rv(c);return Dz(u,d).sort((f,h)=>f.localeCompare(h)).map(f=>({value:f,label:Si(f)}))},[e.visible,e.search.resourceType]);if(!e.visible)return null;function l(c){r({search:{...n.search,fields:c}})}return a.jsx(Dn,{title:"Fields",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>{e.onCancel()},size:"auto",withOverlay:!0,closeOnClickOutside:!1,overlayProps:{onMouseDownCapture:()=>{t.current=o},onClick:()=>{t.current||e.onCancel(),t.current=!1},children:a.jsx("div",{"data-testid":"overlay-child"})},children:a.jsxs(be,{children:[a.jsx(Of,{style:{width:550},placeholder:"Select fields to display",data:s,value:n.search.fields??[],onChange:l,onDropdownOpen:()=>i(!0),onDropdownClose:()=>i(!1),maxDropdownHeight:"250px",clearButtonProps:{"aria-label":"Clear selection"},clearable:!0,searchable:!0}),a.jsx(Y,{justify:"flex-end",children:a.jsx(te,{onClick:()=>e.onOk(n.search),children:"OK"})})]})})}function Dz(e,t){const n=[],r=new Set,o=new Set;for(const i of Object.keys(e.elements))n.push(i),r.add(i.toLowerCase()),o.add(Si(i));if(t)for(const i of Object.keys(t)){const s=Si(i);!r.has(i)&&!o.has(s)&&(n.push(i),r.add(i),o.add(s))}return n}function LT(e){var o;const{resourceType:t,filter:n}=e,r=(o=Io.types[t].searchParams)==null?void 0:o[n.code];if(r){if(r.type==="reference"&&(n.operator===ie.EQUALS||n.operator===ie.NOT_EQUALS))return a.jsx(Ya,{value:{reference:n.value}});const i=Gf(t,r);if(n.code==="_lastUpdated"||i.type===Jo.DATETIME)return a.jsx(a.Fragment,{children:jn(n.value)})}return a.jsx(a.Fragment,{children:n.value})}function $T(e){const t=Gf(e.resourceType,e.searchParam),n="filter-value";switch(t.type){case Jo.REFERENCE:return a.jsx(eh,{name:n,defaultValue:e.defaultValue?{reference:e.defaultValue}:void 0,targetTypes:e.searchParam.target,autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(r.reference):e.onChange("")}});case Jo.BOOLEAN:return a.jsx(gr,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultChecked:e.defaultValue==="true",autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.checked.toString())});case Jo.DATE:return a.jsx(ae,{type:"date",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case Jo.DATETIME:return a.jsx(as,{name:n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:e.onChange});case Jo.NUMBER:return a.jsx(ae,{type:"number",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case Jo.QUANTITY:return a.jsx(ls,{name:n,defaultValue:Iz(e.defaultValue),autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(`${r.value}`):e.onChange("")}});default:return a.jsx(ae,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value),placeholder:"Search value"})}}function Iz(e){if(e){const[t,n,r]=e.split("|");if(t)return{value:parseFloat(t),system:n,unit:r}}}function _z(e){const[t,n]=p.useState(JSON.parse(tr(e.search))),[r,o]=p.useState(-1),i=p.useRef(t);i.current=t,p.useEffect(()=>{n(JSON.parse(tr(e.search)))},[e.search]);function s(d){n(rh(i.current,d.code,d.operator,d.value))}if(!e.visible)return null;const l=e.search.resourceType,c=Rv(l)??{},u=t.filters||[];return a.jsxs(Dn,{title:"Filters",closeButtonProps:{"aria-label":"Close"},size:900,opened:e.visible,onClose:e.onCancel,children:[a.jsx("div",{children:a.jsxs("table",{children:[a.jsxs("colgroup",{children:[a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:380}}),a.jsx("col",{style:{width:120}})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Field"}),a.jsx("th",{children:"Operation"}),a.jsx("th",{children:"Value"}),a.jsx("th",{children:"Actions"})]})}),a.jsxs("tbody",{children:[u.map((d,f)=>f===r?a.jsx(jw,{resourceType:l,searchParams:c,defaultValue:d,okText:"Save",onOk:h=>{const m=[...u];m[f]=h,n(c0(i.current,m)),o(-1)},onCancel:()=>o(-1)},`filter-${d.code}-${d.operator}-${d.value}-input`):a.jsx(Az,{resourceType:l,filter:d,onEdit:()=>o(f),onDelete:()=>n(fz(i.current,f))},`filter-${d.code}-${d.operator}-${d.value}-display`)),a.jsx(jw,{resourceType:l,searchParams:c,okText:"Add",onOk:s})]})]})}),a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{onClick:()=>e.onOk(i.current),children:"OK"})})]})}function Az(e){const{filter:t}=e;return a.jsxs("tr",{children:[a.jsx("td",{children:Si(t.code)}),a.jsx("td",{children:p0(t.operator)}),a.jsx("td",{children:a.jsx(LT,{resourceType:e.resourceType,filter:t})}),a.jsxs("td",{children:[a.jsx(te,{size:"compact-md",variant:"outline",onClick:e.onEdit,children:"Edit"}),a.jsx(te,{size:"compact-md",variant:"outline",onClick:e.onDelete,children:"Delete"})]})]})}function jw(e){const[t,n]=p.useState(e.defaultValue??{}),r=p.useRef(t);r.current=t;function o(u){n({...r.current,code:u})}function i(u){n({...r.current,operator:u})}function s(u){n({...r.current,value:u})}const l=e.searchParams[t.code],c=l&&jz(l);return a.jsxs("tr",{children:[a.jsx("td",{children:a.jsx(wt,{"data-testid":"filter-field",defaultValue:r.current.code,onChange:u=>o(u.currentTarget.value),data:["",...Object.keys(e.searchParams).map(u=>({value:u,label:Si(u)}))]})}),a.jsx("td",{children:c&&a.jsx(wt,{"data-testid":"filter-operation",defaultValue:t.operator,onChange:u=>i(u.currentTarget.value),data:["",...c.map(u=>({value:u,label:p0(u)}))]})}),a.jsx("td",{children:l&&t.operator&&a.jsx($T,{resourceType:e.resourceType,searchParam:l,defaultValue:t.value,onChange:s})}),a.jsxs("td",{children:[t.code&&t.operator&&a.jsx(te,{size:"compact-md",variant:"outline",onClick:()=>{e.onOk(r.current),n({})},children:e.okText}),e.onCancel&&a.jsx(te,{size:"compact-md",variant:"outline",onClick:e.onCancel,children:"Cancel"})]})]})}function Nz(e){const[t,n]=p.useState(e.defaultValue??"");if(!e.visible||!e.searchParam||!e.filter)return null;function r(){e.onOk({...e.filter,value:t})}return a.jsx(Dn,{title:e.title,size:"xl",opened:e.visible,onClose:e.onCancel,children:a.jsx(We,{onSubmit:r,children:a.jsxs(Kn,{children:[a.jsx(Kn.Col,{span:10,children:a.jsx($T,{resourceType:e.resourceType,searchParam:e.searchParam,defaultValue:t,autoFocus:!0,onChange:n})}),a.jsx(Kn.Col,{span:2,children:a.jsx(te,{onClick:r,fullWidth:!0,children:"OK"})})]})})})}function Oz(e){if(!e.searchParams)return null;function t(i,s){o(bz(e.search,i.code,s))}function n(i){o(u0(e.search,i.code))}function r(i,s){e.onPrompt(i,{code:i.code,operator:s,value:""})}function o(i){e.onChange(i)}return e.searchParams.length===1?a.jsx(Mz,{search:e.search,searchParam:e.searchParams[0],onSort:t,onPrompt:r,onChange:o,onClear:n}):a.jsx(Z.Dropdown,{children:e.searchParams.map(i=>a.jsx(Z.Item,{children:Si(i.code)},i.code))})}function Mz(e){switch(e.searchParam.type){case"date":return a.jsx(Lz,{...e});case"number":case"quantity":return a.jsx($z,{...e});case"reference":return a.jsx(Fz,{...e});case"string":return a.jsx(zz,{...e});case"token":case"uri":return a.jsx(Bz,{...e});default:return a.jsxs(a.Fragment,{children:["Unknown search param type: ",e.searchParam.type]})}}function Lz(e){const{searchParam:t}=e,n=t.code;return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Item,{leftSection:a.jsx(Uv,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Oldest to Newest"}),a.jsx(Z.Item,{leftSection:a.jsx(Vv,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Newest to Oldest"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Uc,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Equals..."}),a.jsx(Z.Item,{leftSection:a.jsx(Bc,{size:14}),onClick:()=>e.onPrompt(t,ie.NOT_EQUALS),children:"Does not equal..."}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(XP,{size:14}),onClick:()=>e.onPrompt(t,ie.ENDS_BEFORE),children:"Before..."}),a.jsx(Z.Item,{leftSection:a.jsx(YP,{size:14}),onClick:()=>e.onPrompt(t,ie.STARTS_AFTER),children:"After..."}),a.jsx(Z.Item,{leftSection:a.jsx(F7,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Between..."}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(mz(e.search,n)),children:"Tomorrow"}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(pz(e.search,n)),children:"Today"}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(hz(e.search,n)),children:"Yesterday"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(vz(e.search,n)),children:"Next Month"}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(yz(e.search,n)),children:"This Month"}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(gz(e.search,n)),children:"Last Month"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Ai,{size:14}),onClick:()=>e.onChange(xz(e.search,n)),children:"Year to date"}),a.jsx(Qc,{...e})]})}function $z(e){const{searchParam:t}=e;return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Item,{leftSection:a.jsx(Uv,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Smallest to Largest"}),a.jsx(Z.Item,{leftSection:a.jsx(Vv,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Largest to Smallest"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Uc,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Equals..."}),a.jsx(Z.Item,{leftSection:a.jsx(Bc,{size:14}),onClick:()=>e.onPrompt(t,ie.NOT_EQUALS),children:"Does not equal..."}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(YP,{size:14}),onClick:()=>e.onPrompt(t,ie.GREATER_THAN),children:"Greater than..."}),a.jsx(Z.Item,{leftSection:a.jsx(Dm,{size:14}),onClick:()=>e.onPrompt(t,ie.GREATER_THAN_OR_EQUALS),children:"Greater than or equal to..."}),a.jsx(Z.Item,{leftSection:a.jsx(XP,{size:14}),onClick:()=>e.onPrompt(t,ie.LESS_THAN),children:"Less than..."}),a.jsx(Z.Item,{leftSection:a.jsx(Dm,{size:14}),onClick:()=>e.onPrompt(t,ie.LESS_THAN_OR_EQUALS),children:"Less than or equal to..."}),a.jsx(Qc,{...e})]})}function Fz(e){const{searchParam:t}=e;return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Item,{leftSection:a.jsx(Uc,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Equals..."}),a.jsx(Z.Item,{leftSection:a.jsx(Bc,{size:14}),onClick:()=>e.onPrompt(t,ie.NOT),children:"Does not equal..."}),a.jsx(Qc,{...e})]})}function zz(e){const{searchParam:t}=e;return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Item,{leftSection:a.jsx(Uv,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort A to Z"}),a.jsx(Z.Item,{leftSection:a.jsx(Vv,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Z to A"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Uc,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Equals..."}),a.jsx(Z.Item,{leftSection:a.jsx(Bc,{size:14}),onClick:()=>e.onPrompt(t,ie.NOT),children:"Does not equal..."}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(U7,{size:14}),onClick:()=>e.onPrompt(t,ie.CONTAINS),children:"Contains..."}),a.jsx(Z.Item,{leftSection:a.jsx(B7,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Does not contain..."}),a.jsx(Qc,{...e})]})}function Bz(e){const{searchParam:t}=e;return a.jsxs(Z.Dropdown,{children:[a.jsx(Z.Item,{leftSection:a.jsx(Uc,{size:14}),onClick:()=>e.onPrompt(t,ie.EQUALS),children:"Equals..."}),a.jsx(Z.Item,{leftSection:a.jsx(Bc,{size:14}),onClick:()=>e.onPrompt(t,ie.NOT),children:"Does not equal..."}),a.jsx(Qc,{...e})]})}function Qc(e){const{searchParam:t}=e,n=t.code;return a.jsxs(a.Fragment,{children:[a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(L7,{size:14}),onClick:()=>e.onChange(Ew(e.search,n)),children:"Missing"}),a.jsx(Z.Item,{leftSection:a.jsx(M7,{size:14}),onClick:()=>e.onChange(Ew(e.search,n,!1)),children:"Not missing"}),a.jsx(Z.Divider,{}),a.jsx(Z.Item,{leftSection:a.jsx(Md,{size:14}),onClick:()=>e.onClear(t),children:"Clear filters"})]})}const Uz="_root_vlout_1",Vz="_table_vlout_8",Wz="_tr_vlout_12",Hz="_th_vlout_18",qz="_control_vlout_22",Gz="_icon_vlout_31",hl={root:Uz,table:Vz,tr:Wz,th:Hz,control:qz,icon:Gz};function Qz(e){const t=e.resourceType,n=[];for(const r of e.fields||["id","_lastUpdated"])n.push(Kz(t,r));return n}function Kz(e,t){var o;if(t==="_lastUpdated")return{name:"_lastUpdated",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_lastUpdated",name:"_lastUpdated",type:"date",expression:"Resource.meta.lastUpdated"}]};if(t==="meta.versionId")return{name:"meta.versionId",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_versionId",name:"_versionId",type:"token",expression:"Resource.meta.versionId"}]};const n=js(e,t),r=BL(e,t.toLowerCase());if(n&&r)return{name:t,elementDefinition:n,searchParams:[r]};if(n){const i=Rv(e);let s;if(i){const l=new RegExp(`${e}\\.${t.replaceAll("[x]","")}([^\\w-]|$)`);s=Object.values(i).filter(c=>!!c.expression&&l.test(c==null?void 0:c.expression)),s.length===0&&(s=void 0)}return{name:t,elementDefinition:n,searchParams:s}}if(r){const i=Gf(e,r);return{name:t,elementDefinition:(o=i.elementDefinitions)==null?void 0:o[0],searchParams:[r]}}return{name:t}}class Yz extends Event{constructor(t){super("change"),this.definition=t}}class Xz extends Event{constructor(t){super("load"),this.response=t}}class Fd extends Event{constructor(t,n){super("click"),this.resource=t,this.browserEvent=n}}function Jz(e){var N,L,M;const t=ne(),[n,r]=p.useState(),[o,i]=p.useState(),{search:s,onLoad:l}=e,[c,u]=p.useState({selected:{},fieldEditorVisible:!1,filterEditorVisible:!1,exportDialogVisible:!1,filterDialogVisible:!1}),d=p.useRef(c);d.current=c;const f=s.total??"accurate",h=p.useCallback(R=>{i(void 0),t.search(s.resourceType,ra({...s,total:f,fields:void 0}),R).then(k=>{u({...d.current,searchResponse:k}),l&&l(new Xz(k))}).catch(k=>{u({...d.current,searchResponse:void 0}),i(k)})},[t,s,f,l]),m=p.useCallback(()=>{u({...d.current,searchResponse:void 0}),h({cache:"reload"})},[h]);p.useEffect(()=>{h()},[h]);function g(R,k){R.stopPropagation();const q=R.target.checked,G={...d.current.selected};q?G[k]=!0:delete G[k],u({...d.current,selected:G})}function y(R){R.stopPropagation();const F=R.target.checked,q={},G=d.current.searchResponse;F&&(G!=null&&G.entry)&&G.entry.forEach(oe=>{var xe;(xe=oe.resource)!=null&&xe.id&&(q[oe.resource.id]=!0)}),u({...d.current,selected:q})}function S(){var k,F;const R=d.current;if(!((k=R.searchResponse)!=null&&k.entry)||R.searchResponse.entry.length===0)return!1;for(const q of R.searchResponse.entry)if((F=q.resource)!=null&&F.id&&!R.selected[q.resource.id])return!1;return!0}function v(R){e.onChange&&e.onChange(new Yz(R))}function x(R,k){if(eT(R.target)||R.button===2)return;it(R);const F=R.button===1||R.ctrlKey||R.metaKey;!F&&e.onClick&&e.onClick(new Fd(k,R)),F&&e.onAuxClick&&e.onAuxClick(new Fd(k,R))}function w(){return!!(e.onExport??e.onExportCsv??e.onExportTransactionBundle)}if(p.useEffect(()=>{r(e.search.resourceType),t.requestSchema(e.search.resourceType).catch(console.error).finally(()=>r(void 0))},[t,e.search.resourceType]),!hP(e.search.resourceType)||n===e.search.resourceType)return a.jsx(on,{style:{width:"100%",height:"100%"},children:a.jsx(Vn,{})});const b=e.checkboxesEnabled,j=Qz(s),E=s.resourceType,P=c.searchResponse,T=P==null?void 0:P.entry,D=T==null?void 0:T.map(R=>R.resource),_="subtle",O="gray",I=16,$=window.innerWidth<768;return a.jsxs("div",{className:hl.root,"data-testid":"search-control",children:[!e.hideToolbar&&a.jsxs(Y,{justify:"space-between",mb:"xl",children:[a.jsxs(Y,{gap:2,children:[a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx(H7,{size:I}),onClick:()=>u({...d.current,fieldEditorVisible:!0}),children:"Fields"}),a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx(X7,{size:I}),onClick:()=>u({...d.current,filterEditorVisible:!0}),children:"Filters"}),e.onNew&&a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx(Y7,{size:I}),onClick:e.onNew,children:"New..."}),!$&&w()&&a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx(x6,{size:I}),onClick:e.onExport?e.onExport:()=>u({...d.current,exportDialogVisible:!0}),children:"Export..."}),!$&&e.onDelete&&a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx(JP,{size:I}),onClick:()=>e.onDelete(Object.keys(c.selected)),children:"Delete..."}),!$&&e.onBulk&&a.jsx(te,{size:"compact-md",variant:_,color:O,leftSection:a.jsx($7,{size:I}),onClick:()=>e.onBulk(Object.keys(c.selected)),children:"Bulk..."})]}),a.jsxs(Y,{gap:2,children:[P&&a.jsxs(se,{size:"xs",c:"dimmed","data-testid":"count-display",children:[FT(s,P).toLocaleString(),"-",nB(s,P).toLocaleString(),P.total!==void 0&&` of ${s.total==="estimate"?"~":""}${(N=P.total)==null?void 0:N.toLocaleString()}`]}),a.jsx(qt,{variant:_,color:O,title:"Refresh",onClick:m,children:a.jsx(f6,{size:I})})]})]}),a.jsxs(le,{className:hl.table,children:[a.jsxs(le.Thead,{children:[a.jsxs(le.Tr,{children:[b&&a.jsx(le.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:S(),onChange:R=>y(R)})}),j.map(R=>a.jsx(le.Th,{children:a.jsxs(Z,{shadow:"md",width:240,position:"bottom-end",children:[a.jsx(Z.Target,{children:a.jsx(Jn,{className:hl.control,p:2,children:a.jsxs(Y,{justify:"space-between",wrap:"nowrap",children:[a.jsx(se,{fw:500,children:Si(R.name)}),a.jsx(on,{className:hl.icon,children:a.jsx(A7,{size:14,stroke:1.5})})]})})}),a.jsx(Oz,{search:e.search,searchParams:R.searchParams,onPrompt:(k,F)=>{u({...d.current,filterDialogVisible:!0,filterDialogSearchParam:k,filterDialogFilter:F})},onChange:k=>{v(k)}})]})},R.name))]}),!e.hideFilters&&a.jsxs(le.Tr,{children:[b&&a.jsx(le.Th,{}),j.map(R=>a.jsx(le.Th,{children:R.searchParams&&a.jsx(Zz,{resourceType:E,searchParams:R.searchParams,filters:e.search.filters})},R.name))]})]}),a.jsx(le.Tbody,{children:D==null?void 0:D.map(R=>R&&a.jsxs(le.Tr,{className:hl.tr,"data-testid":"search-control-row",onClick:k=>x(k,R),onAuxClick:k=>x(k,R),children:[b&&a.jsx(le.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${R.id}`,checked:!!c.selected[R.id],onChange:k=>g(k,R.id)})}),j.map(k=>a.jsx(le.Td,{children:Pz(R,k)},k.name))]},R.id))})]}),(D==null?void 0:D.length)===0&&a.jsx(qc,{children:a.jsx(on,{style:{height:150},children:a.jsx(se,{size:"xl",c:"dimmed",children:"No results"})})}),P&&a.jsx(on,{m:"md",p:"md",children:a.jsx(Ur,{value:eB(s),total:tB(s,P),onChange:R=>v(Sz(s,R)),getControlProps:R=>{switch(R){case"previous":return{"aria-label":"Previous page"};case"next":return{"aria-label":"Next page"};default:return{}}}})}),o&&a.jsx("div",{"data-testid":"search-error",children:a.jsx("pre",{style:{textAlign:"left"},children:JSON.stringify(o,void 0,2)})}),a.jsx(Rz,{search:e.search,visible:d.current.fieldEditorVisible,onOk:R=>{v(R),u({...d.current,fieldEditorVisible:!1})},onCancel:()=>{u({...d.current,fieldEditorVisible:!1})}}),a.jsx(_z,{search:e.search,visible:d.current.filterEditorVisible,onOk:R=>{v(R),u({...d.current,filterEditorVisible:!1})},onCancel:()=>{u({...d.current,filterEditorVisible:!1})}}),a.jsx(cz,{visible:d.current.exportDialogVisible,exportCsv:e.onExportCsv,exportTransactionBundle:e.onExportTransactionBundle,onCancel:()=>{u({...d.current,exportDialogVisible:!1})}}),a.jsx(Nz,{visible:d.current.filterDialogVisible,title:(L=c.filterDialogSearchParam)!=null&&L.code?Si(c.filterDialogSearchParam.code):"",resourceType:E,searchParam:c.filterDialogSearchParam,filter:c.filterDialogFilter,defaultValue:"",onOk:R=>{v(rh(e.search,R.code,R.operator,R.value)),u({...d.current,filterDialogVisible:!1})},onCancel:()=>{u({...d.current,filterDialogVisible:!1})}},(M=c.filterDialogSearchParam)==null?void 0:M.code)]})}const Kc=p.memo(Jz);function Zz(e){const t=(e.filters??[]).filter(n=>e.searchParams.find(r=>r.code===n.code));return t.length===0?a.jsx("span",{children:"no filters"}):a.jsx(a.Fragment,{children:t.map(n=>a.jsxs("div",{children:[p0(n.operator)," ",a.jsx(LT,{resourceType:e.resourceType,filter:n})]},`filter-${n.code}-${n.operator}-${n.value}`))})}function eB(e){return Math.floor((e.offset??0)/(e.count??Qf))+1}function tB(e,t){const n=e.count??Qf,r=zT(e,t);return Math.ceil(r/n)}function FT(e,t){return Math.min(zT(e,t),(e.offset??0)+1)}function nB(e,t){var n;return Math.max(FT(e,t)+(((n=t.entry)==null?void 0:n.length)??0)-1,0)}function zT(e,t){var r,o;let n=t.total;return n===void 0&&(n=(e.offset??0)+(((r=t.entry)==null?void 0:r.length)??0)+((o=t.link)!=null&&o.some(i=>i.relation==="next")?1:0)),n}function rB(e){const t=ne(),[n,r]=p.useState(!1),[o,i]=p.useState(),{query:s,fields:l}=e,[c,u]=p.useState(),[d,f]=p.useState({}),h=p.useRef();h.current=c;const m=p.useRef({});m.current=d,p.useEffect(()=>{i(void 0),t.graphql(s).then(u).catch(w=>i(lt(w)))},[t,s]);function g(w,b){w.stopPropagation();const E=w.target.checked,P={...m.current};E?P[b]=!0:delete P[b],f(P)}function y(w){var T;w.stopPropagation();const j=w.target.checked,E={},P=(T=h.current)==null?void 0:T.data.ResourceList;j&&P&&P.forEach(D=>{D.id&&(E[D.id]=!0)}),f(E)}function S(){var b;const w=(b=h.current)==null?void 0:b.data.ResourceList;if(!w||w.length===0)return!1;for(const j of w)if(j.id&&!m.current[j.id])return!1;return!0}function v(w,b){eT(w.target)||(it(w),w.button!==1&&e.onClick&&e.onClick(new Fd(b,w)),w.button===1&&e.onAuxClick&&e.onAuxClick(new Fd(b,w)))}if(p.useEffect(()=>{t.requestSchema(e.resourceType).then(()=>r(!0)).catch(console.log)},[t,e.resourceType]),!n)return a.jsx(Vn,{});const x=e.checkboxesEnabled;return a.jsxs("div",{onContextMenu:w=>it(w),"data-testid":"search-control",children:[a.jsxs(le,{children:[a.jsx(le.Thead,{children:a.jsxs(le.Tr,{children:[x&&a.jsx(le.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:S(),onChange:w=>y(w)})}),l.map(w=>a.jsx(le.Th,{children:w.name},w.name))]})}),a.jsx(le.Tbody,{children:c==null?void 0:c.data.ResourceList.map(w=>w&&a.jsxs(le.Tr,{"data-testid":"search-control-row",onClick:b=>v(b,w),onAuxClick:b=>v(b,w),children:[x&&a.jsx(le.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${w.id}`,checked:!!d[w.id],onChange:b=>g(b,w.id)})}),l.map(b=>a.jsx(le.Td,{children:a.jsx(lz,{propertyType:b.propertyType,path:b.fhirPath,resource:w})},b.name))]},w.id))})]}),(c==null?void 0:c.data.ResourceList.length)===0&&a.jsx("div",{"data-testid":"empty-search",children:"No results"}),o&&a.jsx("div",{"data-testid":"search-error",children:a.jsx("pre",{style:{textAlign:"left"},children:JSON.stringify(o,void 0,2)})}),e.onBulk&&a.jsx(te,{onClick:()=>e.onBulk(Object.keys(m.current)),children:"Bulk..."})]})}const oB=p.memo(rB);function Vr(e){return a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 491 491",style:{width:e.size,height:e.size},children:[a.jsx("title",{children:"Medplum Logo"}),a.jsx("path",{fill:e.fill??"#ad7136",d:"M282 67c6-16 16-29 29-40L289 0c-22 17-37 41-43 68l17 23 19-24z"}),a.jsx("path",{fill:e.fill??"#946af9",d:"M311 63c-17 0-33 4-48 11-16-7-32-11-49-11-87 0-158 96-158 214s71 214 158 214c17 0 33-4 49-11 15 7 31 11 48 11 87 0 158-96 158-214S398 63 311 63z"}),a.jsx("path",{fill:e.fill??"#7857c5",d:"M231 489l-17 2c-87 0-158-96-158-214S127 63 214 63l17 1c-39 12-70 102-70 213s31 201 70 212z"}),a.jsx("path",{fill:e.fill??"#40bc26",d:"M207 220a176 176 0 01-177 43A176 176 0 01251 43l1 5c17 59 2 125-45 172z"}),a.jsx("path",{fill:e.fill??"#33961e",d:"M252 48A421 421 0 0057 270l-27-7A176 176 0 01251 43l1 5z"})]})}function iB(e){const{group:t}=e;return a.jsx(zn,{withBorder:!0,radius:"md",p:"xs",display:"flex",style:{alignItems:"center",justifyContent:"center"},children:a.jsxs(Y,{children:[t.measureScore&&a.jsx(lB,{group:t}),!t.measureScore&&a.jsx(aB,{group:t})]})})}function sB(e){const{measure:t}=e;return a.jsxs(a.Fragment,{children:[a.jsx(se,{fz:"md",fw:500,mb:8,children:t.title}),a.jsx(se,{fz:"xs",c:"dimmed",mb:8,children:t.subtitle})]})}function aB(e){const{group:t}=e,n=t.population,r=n==null?void 0:n.find(c=>wi(c.code)==="numerator"),o=n==null?void 0:n.find(c=>wi(c.code)==="denominator"),i=r==null?void 0:r.count,s=o==null?void 0:o.count;if(s===0)return a.jsxs(W,{children:[a.jsx(ue,{order:3,children:"Not Applicable"}),a.jsx(se,{children:`Denominator: ${s}`})]});if(i===void 0||s===void 0)return a.jsxs(W,{children:[a.jsx(ue,{order:3,children:"Insufficient Data"}),a.jsx(se,{children:`Numerator: ${i}`}),a.jsx(se,{children:`Denominator: ${s}`})]});const l=i/s*100;return a.jsx(Bf,{size:120,thickness:12,roundCaps:!0,sections:[{value:l,color:BT(l)}],label:a.jsx(rs,{justify:"center",children:a.jsxs(se,{fw:700,fz:18,children:[i," / ",s]})})})}function lB(e){var r,o,i;const{group:t}=e,n=((r=t.measureScore)==null?void 0:r.unit)??((o=t.measureScore)==null?void 0:o.code);return a.jsx(a.Fragment,{children:n==="%"?a.jsx(Bf,{size:120,thickness:12,roundCaps:!0,sections:[{value:cB(t),color:BT(((i=t==null?void 0:t.measureScore)==null?void 0:i.value)??0)}],label:a.jsx(rs,{justify:"center",children:a.jsx(se,{fw:700,fz:18,children:a.jsx(cc,{value:t.measureScore})})})}):a.jsx(rs,{h:120,align:"center",children:a.jsx(ue,{order:3,children:a.jsx(cc,{value:t.measureScore})})})})}function cB(e){var r,o;const t=(r=e.measureScore)==null?void 0:r.value,n=(o=e.measureScore)==null?void 0:o.unit;return t?t<=1&&n==="%"?t*100:t:0}function BT(e){return e<=33?"red":e<=67?"yellow":"green"}function uB(e){var r;const t=ct(e.measureReport),[n]=k7("Measure",{url:t==null?void 0:t.measure});return t?a.jsxs(W,{children:[n&&a.jsx(sB,{measure:n}),a.jsx(dv,{cols:{base:3,sm:1},spacing:{base:"md",sm:"sm"},children:(r=t.group)==null?void 0:r.map((o,i)=>a.jsx(iB,{group:o},o.id??i))})]}):null}function Wr(e){var n;const t=((n=e.outcome)==null?void 0:n.issue)||e.issues;return!t||t.length===0?null:a.jsx(xs,{icon:a.jsx(zc,{size:16}),color:"red",children:t.map(r=>{var o;return a.jsx("div",{"data-testid":"text-field-error",children:uP(r)},(o=r.details)==null?void 0:o.text)})})}function dB(e){const t=p.useCallback((n,r,o)=>{const i=`${r}/${o}`,s=100;return Promise.allSettled([n.readHistory("Patient",o),n.search("Communication",{subject:i,_count:s}),n.search("Device",{patient:i,_count:s}),n.search("DeviceRequest",{patient:i,_count:s}),n.search("DiagnosticReport",{subject:i,_count:s}),n.search("Media",{subject:i,_count:s}),n.search("ServiceRequest",{subject:i,_count:s}),n.search("Task",{subject:i,_count:s})])},[]);return a.jsx(nh,{value:e.patient,loadTimelineResources:t,createCommunication:(n,r,o)=>({resourceType:"Communication",status:"completed",subject:ft(n),sender:ft(r),sent:new Date().toISOString(),payload:[{contentString:o}]}),createMedia:(n,r,o)=>({resourceType:"Media",status:"completed",subject:ft(n),operator:ft(r),issued:new Date().toISOString(),content:o})})}const fB="_section_14dzq_2",hB="_hovering_14dzq_11",pB="_editing_14dzq_15",mB="_bottomActions_14dzq_20",oa={section:fB,hovering:hB,editing:pB,bottomActions:mB};function gB(e){const t=ne(),n=ct(e.value),[r,o]=p.useState(!1),[i,s]=p.useState(),[l,c]=p.useState(),[u,d]=p.useState();function f(){c(void 0)}function h(){s(void 0)}const m=p.useRef();if(m.current=u,p.useEffect(()=>{t.requestSchema("PlanDefinition").then(()=>o(!0)).catch(console.log)},[t]),p.useEffect(()=>(d(bB(n??{resourceType:"PlanDefinition",status:"active"})),document.addEventListener("mouseover",f),document.addEventListener("click",h),()=>{document.removeEventListener("mouseover",f),document.removeEventListener("click",h)}),[n]),!r||!u)return null;function g(y,S){d({...m.current,[y]:S})}return a.jsx("div",{children:a.jsxs(We,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(u),children:[a.jsx(ae,{label:"Plan Title",defaultValue:u.title,onChange:y=>g("title",y.currentTarget.value)}),a.jsx(UT,{actions:u.action||[],selectedKey:i,setSelectedKey:s,hoverKey:l,setHoverKey:c,onChange:y=>g("action",y)}),a.jsx(te,{type:"submit",children:"Save"})]})})}function UT(e){const t=p.useRef();t.current=e.actions;function n(i){e.onChange(t.current.map(s=>s.id===i.id?i:s))}function r(i){e.onChange([...t.current,i]),e.setSelectedKey(i.id)}function o(i){e.onChange(t.current.filter(s=>s!==i))}return a.jsxs("div",{className:oa.section,children:[e.actions.map(i=>a.jsx("div",{children:a.jsx(yB,{action:i,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:n,onRemove:()=>o(i)})},i.id)),a.jsx("div",{className:oa.bottomActions,children:a.jsx(He,{href:"#",onClick:i=>{it(i),r({id:WT()})},children:"Add action"})})]})}function yB(e){const{action:t}=e,n=SB(t),r=e.selectedKey===e.action.id,o=e.hoverKey===e.action.id;function i(c){c.stopPropagation(),e.setSelectedKey(e.action.id)}function s(c){it(c),e.setHoverKey(e.action.id)}const l=et(oa.section,{[oa.editing]:r,[oa.hovering]:o&&!r});return a.jsxs("div",{"data-testid":t.id,className:l,onClick:i,onMouseOver:s,onFocus:s,children:[r?a.jsx(xB,{action:t,actionType:n,onChange:e.onChange,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onRemove:e.onRemove}):a.jsx(vB,{action:t,actionType:n}),a.jsx("div",{className:oa.bottomActions,children:a.jsx(He,{href:"#",onClick:c=>{c.preventDefault(),e.onRemove()},children:"Remove"})})]})}const Am={path:"PlanDefinition.action.timing[x]",min:0,max:1,description:"",isArray:!1,constraints:[],type:["dateTime","Period","Range","Timing"].map(e=>({code:e}))};function vB(e){const{action:t,actionType:n}=e,[r,o]=VT(t);return a.jsxs("div",{children:[a.jsxs("div",{children:[t.title||"Untitled"," ",n&&`(${n})`]}),t.definitionCanonical&&a.jsx("div",{children:a.jsx(Ld,{value:{reference:t.definitionCanonical}})}),r&&a.jsx("div",{children:a.jsx(Fr,{property:Am,propertyType:o,value:r})})]})}function xB(e){const{action:t}=e,[n,r]=p.useState(e.actionType);function o(i,s){e.onChange({...t,[i]:s})}return a.jsxs(be,{gap:"xl",children:[a.jsx(ae,{name:`actionTitle-${t.id}`,label:"Title",defaultValue:t.title,onChange:i=>o("title",i.currentTarget.value)}),a.jsx(ae,{name:`actionDescription-${t.id}`,label:"Description",defaultValue:t.description,onChange:i=>o("description",i.currentTarget.value)}),a.jsx(wt,{label:"Type of Action",description:"The type of the action to be performed.",name:`actionType-${t.id}`,defaultValue:n,onChange:i=>r(i.currentTarget.value),data:["","appointment","lab","questionnaire","task"]}),t.action&&t.action.length>0&&a.jsx(UT,{actions:t.action,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:i=>o("action",i)}),(()=>{switch(n){case"appointment":return a.jsx(Du,{title:"Appointment",description:"The subject must schedule an appointment from the schedule.",resourceType:"Schedule",action:t,onChange:e.onChange});case"lab":return a.jsx(Du,{title:"Lab",description:"The subject must complete the following lab panel.",resourceType:"ActivityDefinition",action:t,onChange:e.onChange});case"questionnaire":return a.jsx(Du,{title:"Questionnaire",description:"The subject must complete the selected questionnaire.",resourceType:"Questionnaire",action:t,onChange:e.onChange});case"task":return a.jsx(Du,{title:"Task",description:"The subject must complete the following task.",resourceType:"ActivityDefinition",action:t,onChange:e.onChange});default:return null}})(),a.jsx(at,{title:"Timing",description:"When the action should take place.",children:a.jsx(wB,{name:"timing-"+t.id,action:t,onChange:e.onChange})})]})}function Du(e){const{id:t,definitionCanonical:n}=e.action,r=n!=null&&n.startsWith(e.resourceType+"/")?{reference:n}:void 0;return a.jsx(Qa,{name:t,resourceType:e.resourceType,defaultValue:r,loadOnFocus:!0,onChange:o=>{o?e.onChange({...e.action,definitionCanonical:ht(o)}):e.onChange({...e.action,definitionCanonical:void 0})}})}function wB(e){const t=e.action,n="timing",[r,o]=VT(t);return a.jsx(Ka,{property:Am,name:"timing[x]",path:"PlanDefinition.timing[x]",defaultValue:r,defaultPropertyType:o,onChange:(i,s)=>{e.onChange(fT(t,n,s??n,Am,i))},outcome:void 0})}function SB(e){var t,n,r;if((t=e.definitionCanonical)!=null&&t.startsWith("Schedule"))return"appointment";if((n=e.definitionCanonical)!=null&&n.startsWith("Questionnaire/"))return"questionnaire";if((r=e.definitionCanonical)!=null&&r.startsWith("ActivityDefinition/"))return"task"}function VT(e){return Wc({type:"PlanDefinitionAction",value:e},"timing")}let lp=1;function WT(e){if(e){if(e.startsWith("id-")){const t=parseInt(e.substring(3),10);isNaN(t)||(lp=Math.max(lp,t+1))}return e}return"id-"+lp++}function bB(e){return{...e,action:HT(e.action)}}function HT(e){if(e)return e.map(t=>({...t,id:WT(t.id),action:HT(t.action)}))}var ut=(e=>(e.group="group",e.display="display",e.question="question",e.boolean="boolean",e.decimal="decimal",e.integer="integer",e.date="date",e.dateTime="dateTime",e.time="time",e.string="string",e.text="text",e.url="url",e.choice="choice",e.openChoice="open-choice",e.attachment="attachment",e.reference="reference",e.quantity="quantity",e))(ut||{});function CB(e){return e.type==="choice"||e.type==="open-choice"}function EB(e,t){if(!e.enableWhen)return!0;const n=e.enableBehavior??"any";for(const r of e.enableWhen){const o=qT(t,r.question);if(r.operator==="exists"&&!r.answerBoolean&&!(o!=null&&o.length)){if(n==="any")return!0;continue}const{anyMatch:i,allMatch:s}=TB(r,o,n);if(n==="any"&&i)return!0;if(n==="all"&&!s)return!1}return n!=="any"}function jB(e,t,n){return e.map(r=>{var s;const o=(s=n.answerOption)==null?void 0:s.find(l=>Es(l.valueCoding)===r||l[t]===r),i=Xt({type:"QuestionnaireItemAnswerOption",value:o},"value");return{[t]:i==null?void 0:i.value}})}function qT(e,t){if(e)for(const n of e){if(n.linkId===t)return n.answer;if(n.item){const r=qT(n.item,t);if(r)return r}}}function PB(e,t,n){if(n==="exists")return!!e===t.value;if(e){const r=n==="="||n==="!="?n==null?void 0:n.replace("=","~"):n,[{value:o}]=lc(`%actualAnswer ${r} %expectedAnswer`,[e],{"%actualAnswer":e,"%expectedAnswer":t});return o}else return!1}function TB(e,t,n){const r=t||[],o=Xt({type:"QuestionnaireItemEnableWhen",value:e},"answer[x]");let i=!1,s=!0;for(const l of r){const c=Xt({type:"QuestionnaireResponseItemAnswer",value:l},"value[x]"),{operator:u}=e;if(PB(c,o,u)?i=!0:s=!1,n==="any"&&i)break}return{anyMatch:i,allMatch:s}}function GT(e){var n,r;const t=Lc(e,"http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource");if(t){if(t.valueCode!==void 0)return[t.valueCode];if(t.valueCodeableConcept)return(r=(n=t.valueCodeableConcept)==null?void 0:n.coding)==null?void 0:r.map(o=>o.code)}}function cp(e,t){var o;const n=co(e);let r=Lc(n,"http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource");return!t||t.length===0?(r&&(n.extension=(o=n.extension)==null?void 0:o.filter(i=>i!==r)),n):(r||(n.extension||(n.extension=[]),r={url:"http://hl7.org/fhir/StructureDefinition/questionnaire-referenceResource"},n.extension.push(r)),t.length===1?(r.valueCode=t[0],delete r.valueCodeableConcept):(r.valueCodeableConcept={coding:t.map(i=>({code:i}))},delete r.valueCode),n)}function kB(e,t,n){const r=Lc(e,"http://hl7.org/fhir/StructureDefinition/questionnaire-referenceFilter");if(!(r!=null&&r.valueString))return;let o=r.valueString;t!=null&&t.reference&&(o=o.replaceAll("$subj",t.reference)),n!=null&&n.reference&&(o=o.replaceAll("$encounter",n.reference));const i={},s=o.split("&");for(const l of s){const[c,u]=PL(l,"=",2);i[c]=u}return i}function RB(e){return{resourceType:"QuestionnaireResponse",questionnaire:ht(e),item:QT(e.item),status:"in-progress"}}function QT(e){return(e==null?void 0:e.map(KT))??[]}function KT(e){var t;return{id:IB(),linkId:e.linkId,text:e.text,item:QT(e.item),answer:((t=e.initial)==null?void 0:t.map(_B))??[]}}let DB=1;function IB(){return"id-"+DB++}function _B(e){return{...e}}function AB(e){return e.value.display||e.value.reference||tr(e.value)}function NB(e){var n,r,o,i;const t=(n=e==null?void 0:e.item)==null?void 0:n[0];if(t){const s=Lc(t,"http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl");if(((i=(o=(r=s==null?void 0:s.valueCodeableConcept)==null?void 0:r.coding)==null?void 0:o[0])==null?void 0:i.code)==="page")return e.item.length}return 1}const YT=p.createContext({});function Nm(e){const t=p.useContext(YT),n=e.item,r=e.response;function o(u){var f,h,m,g;let d;Array.isArray(u)?d=u:e.index>=(((h=(f=e.response)==null?void 0:f.answer)==null?void 0:h.length)??0)?d=(((m=e.response)==null?void 0:m.answer)??[]).concat([u]):d=(((g=e.response)==null?void 0:g.answer)??[]).map((S,v)=>v===e.index?u:S)??[],e.onChange({id:r==null?void 0:r.id,linkId:r==null?void 0:r.linkId,text:n.text,answer:d})}const i=n.type;if(!i)return null;const s=n.linkId;if(!s)return null;const l=n.initial&&n.initial.length>0?n.initial[0]:void 0,c=m0(r,e.index)??Xt({type:"QuestionnaireItemInitial",value:l},"value");switch(i){case ut.display:return a.jsx("p",{children:e.item.text},e.item.linkId);case ut.boolean:return a.jsx(uT,{title:e.item.text,htmlFor:e.item.linkId,children:a.jsx(gr,{id:e.item.linkId,name:e.item.linkId,defaultChecked:c==null?void 0:c.value,onChange:u=>o({valueBoolean:u.currentTarget.checked})})},e.item.linkId);case ut.decimal:return a.jsx(ae,{type:"number",step:"any",id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueDecimal:u.currentTarget.valueAsNumber})});case ut.integer:return a.jsx(ae,{type:"number",step:1,id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueInteger:u.currentTarget.valueAsNumber})});case ut.date:return a.jsx(ae,{type:"date",id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueDate:u.currentTarget.value})});case ut.dateTime:return a.jsx(as,{name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueDateTime:u})});case ut.time:return a.jsx(ae,{type:"time",id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueTime:u.currentTarget.value})});case ut.string:case ut.url:return a.jsx(ae,{id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueString:u.currentTarget.value})});case ut.text:return a.jsx(ws,{id:s,name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueString:u.currentTarget.value})});case ut.attachment:return a.jsx(Y,{py:4,children:a.jsx(rT,{name:s,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueAttachment:u})})});case ut.reference:return a.jsx(eh,{name:s,required:n.required,targetTypes:GT(n),searchCriteria:kB(n,t.subject,t.encounter),defaultValue:c==null?void 0:c.value,onChange:u=>o({valueReference:u})});case ut.quantity:return a.jsx(ls,{name:s,required:n.required,defaultValue:c==null?void 0:c.value,onChange:u=>o({valueQuantity:u}),disableWheel:!0});case ut.choice:case ut.openChoice:return zB(n)&&!n.answerValueSet?a.jsx(OB,{name:s,item:n,initial:l,response:r,onChangeAnswer:u=>o(u)}):a.jsx(MB,{name:s,item:n,initial:l,response:r,onChangeAnswer:u=>o(u)});default:return null}}function OB(e){var c;const{name:t,item:n,initial:r,response:o}=e;if(!((c=n.answerOption)!=null&&c.length))return a.jsx(XT,{});const i=Xt({type:"QuestionnaireItemInitial",value:r},"value"),s=[""];for(const u of n.answerOption){const d=Xt({type:"QuestionnaireItemAnswerOption",value:u},"value");s.push(Pw(d))}const l=m0(o)??i;if(n.repeats){const{propertyName:u,data:d}=BB(e.item),f=$B(o);return a.jsx(Of,{data:d,placeholder:"Select items",searchable:!0,defaultValue:f||[Pw(i)],onChange:h=>{const m=jB(h,u,n);e.onChangeAnswer(m)}})}return a.jsx(wt,{id:t,name:t,onChange:u=>{const d=u.currentTarget.selectedIndex;if(d===0){e.onChangeAnswer({});return}const f=n.answerOption[d-1],h=Xt({type:"QuestionnaireItemAnswerOption",value:f},"value"),m="value"+Vt(h.type);e.onChangeAnswer({[m]:h.value})},defaultValue:Es(l==null?void 0:l.value)||(l==null?void 0:l.value),data:s})}function MB(e){var s;const{name:t,item:n,initial:r,onChangeAnswer:o,response:i}=e;return!((s=n.answerOption)!=null&&s.length)&&!n.answerValueSet?a.jsx(XT,{}):n.answerValueSet?a.jsx(hT,{name:t,binding:n.answerValueSet,onChange:l=>o({valueCoding:l}),creatable:n.type===ut.openChoice}):a.jsx(LB,{name:(i==null?void 0:i.id)??t,item:n,initial:r,response:i,onChangeAnswer:o})}function LB(e){const{name:t,item:n,initial:r,onChangeAnswer:o,response:i}=e,s=js("QuestionnaireItemAnswerOption","value[x]"),l=Xt({type:"QuestionnaireItemInitial",value:r},"value"),c=[];let u;if(n.answerOption)for(let h=0;h<n.answerOption.length;h++){const m=n.answerOption[h],g=`${t}-option-${h}`,y=Xt({type:"QuestionnaireItemAnswerOption",value:m},"value");y!=null&&y.value&&(l&&tr(y)===tr(l)&&(u=g),c.push([g,y]))}const d=m0(i),f=FB(c,d);return a.jsx(oc.Group,{name:t,value:f??u,onChange:h=>{const m=c.find(g=>g[0]===h);if(m){const g=m[1],y="value"+Vt(g.type);o({[y]:g.value})}},children:c.map(([h,m])=>a.jsx(oc,{id:h,value:h,py:4,label:a.jsx(Fr,{property:s,propertyType:m.type,value:m.value})},h))})}function XT(){return a.jsx(ae,{disabled:!0,placeholder:"No Answers Defined"})}function JT(e){return Xt({type:"QuestionnaireItemAnswer",value:e},"value")}function m0(e,t=0){const n=e.answer;return JT((n==null?void 0:n[t])??{})}function $B(e){const t=e.answer;return t?t.map(r=>JT(r)).map(r=>Es(r==null?void 0:r.value)||(r==null?void 0:r.value)):[]}function FB(e,t){var n;return(n=e.find(r=>$c(r[1].value,t==null?void 0:t.value)))==null?void 0:n[0]}function Pw(e){if(e)return e.type==="CodeableConcept"?wi(e.value):e.type==="Coding"?Es(e.value):e.type==="Reference"?AB(e):e.value.toString()}function zB(e){var t;return!!((t=e.extension)!=null&&t.some(n=>{var r,o,i;return n.url==="http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl"&&((i=(o=(r=n.valueCodeableConcept)==null?void 0:r.coding)==null?void 0:o[0])==null?void 0:i.code)==="drop-down"}))}function BB(e){var i;if(((i=e.answerOption)==null?void 0:i.length)===0)return{propertyName:"",data:[]};const t=e.answerOption[0],n=Xt({type:"QuestionnaireItemAnswerOption",value:t},"value"),r="value"+Vt(n.type),o=(e.answerOption??[]).map(s=>({value:Tw(s,r),label:Tw(s,r)}));return{propertyName:r,data:o}}function Tw(e,t){var n;return Es(e.valueCoding)||((n=e[t])==null?void 0:n.toString())}const UB="_section_cpwxo_1",VB="_hovering_cpwxo_10",WB="_editing_cpwxo_14",HB="_questionBody_cpwxo_19",qB="_topActions_cpwxo_23",GB="_bottomActions_cpwxo_32",QB="_movementActions_cpwxo_43",KB="_movementIcons_cpwxo_55",YB="_columnAlignment_cpwxo_59",XB="_linkIdInput_cpwxo_64",JB="_typeSelect_cpwxo_69",ar={section:UB,hovering:VB,editing:WB,questionBody:HB,topActions:qB,bottomActions:GB,movementActions:QB,movementIcons:KB,columnAlignment:YB,linkIdInput:XB,typeSelect:JB};function ZB(e){const t=ne(),n=ct(e.questionnaire),[r,o]=p.useState(!1),[i,s]=p.useState(),[l,c]=p.useState(),[u,d]=p.useState();function f(){d(void 0)}function h(){c(void 0)}p.useEffect(()=>{t.requestSchema("Questionnaire").then(()=>o(!0)).catch(console.log)},[t]),p.useEffect(()=>(s(rU(n??{resourceType:"Questionnaire",status:"active"})),document.addEventListener("mouseover",f),document.addEventListener("click",h),()=>{document.removeEventListener("mouseover",f),document.removeEventListener("click",h)}),[n]);const m=(g,y)=>{s(g),e.autoSave&&!y&&e.onSubmit&&e.onSubmit(g)};return!r||!i?null:a.jsx("div",{children:a.jsxs(We,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(i),children:[a.jsx(ZT,{item:i,selectedKey:l,setSelectedKey:c,hoverKey:u,setHoverKey:d,onChange:m}),a.jsx(te,{type:"submit",children:"Save"})]})})}function ZT(e){var w;const t=e.item,n=e.item,r=Uo(e.item),o=r||n.type===ut.group,i=n.linkId??"[untitled]",s=e.selectedKey===e.item.id,l=e.hoverKey===e.item.id,c=p.useRef();c.current=e.item;function u(b){it(b),e.setSelectedKey(e.item.id)}function d(b){it(b),e.setHoverKey(e.item.id)}function f(b){var E;const j=c.current;e.onChange({...j,item:(E=j.item)==null?void 0:E.map(P=>P.id===b.id?b:P)})}function h(b,j){e.onChange({...e.item,item:[...e.item.item??[],b]},j)}function m(b){var j;e.onChange({...e.item,item:(j=e.item.item)==null?void 0:j.filter(E=>E!==b)})}function g(b,j){e.onChange({...c.current,[b]:j})}function y(b){e.onChange({...e.item,...b})}function S(b){var j;e.onChange({...e.item,item:(j=e.item.item)==null?void 0:j.map(E=>E===b?{...E,repeats:!E.repeats}:E)})}function v(b,j){const E=sU(e.item.item,b,j);e.onChange({...e.item,item:E})}const x=et(ar.section,{[ar.editing]:s,[ar.hovering]:l&&!s});return a.jsxs("div",{"data-testid":n.linkId,className:x,onClick:u,onMouseOver:d,onFocus:d,children:[a.jsx("div",{className:ar.questionBody,children:s?a.jsxs(a.Fragment,{children:[r&&a.jsx(ae,{size:"xl",defaultValue:t.title,onBlur:b=>g("title",b.currentTarget.value)}),!r&&a.jsx(ws,{autosize:!0,minRows:2,defaultValue:n.text,onBlur:b=>g("text",b.currentTarget.value)}),n.type==="reference"&&a.jsx(nU,{item:n,onChange:y}),CB(n)&&a.jsx(eU,{item:n,onChange:b=>y(b)})]}):a.jsxs(a.Fragment,{children:[t.title&&a.jsx(ue,{children:t.title}),n.text&&a.jsx("div",{children:n.text}),!o&&a.jsx(Nm,{item:n,index:0,onChange:()=>{},response:{linkId:n.linkId}})]})}),(w=n.item)==null?void 0:w.map((b,j)=>a.jsx("div",{children:a.jsx(ZT,{item:b,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,isFirst:j===0,isLast:j===(e.item.item??[]).length-1,setHoverKey:e.setHoverKey,onChange:f,onRemove:()=>m(b),onRepeatable:S,onMoveUp:()=>v(j,-1),onMoveDown:()=>v(j,1)})},b.id)),!o&&a.jsx("div",{className:ar.topActions,children:s?a.jsxs(a.Fragment,{children:[a.jsx(ae,{size:"xs",className:ar.linkIdInput,defaultValue:n.linkId,onBlur:b=>g("linkId",b.currentTarget.value)}),!o&&a.jsx(wt,{size:"xs",className:ar.typeSelect,defaultValue:n.type,onChange:b=>g("type",b.currentTarget.value),data:[{value:"display",label:"Display"},{value:"boolean",label:"Boolean"},{value:"decimal",label:"Decimal"},{value:"integer",label:"Integer"},{value:"date",label:"Date"},{value:"dateTime",label:"Date/Time"},{value:"time",label:"Time"},{value:"string",label:"String"},{value:"text",label:"Text"},{value:"url",label:"URL"},{value:"choice",label:"Choice"},{value:"open-choice",label:"Open Choice"},{value:"attachment",label:"Attachment"},{value:"reference",label:"Reference"},{value:"quantity",label:"Quantity"}]})]}):a.jsx("div",{children:i})}),!r&&a.jsx(W,{className:ar.movementActions,children:a.jsxs(W,{className:ar.columnAlignment,children:[!e.isFirst&&a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),e.onMoveUp&&e.onMoveUp()},children:a.jsx(O7,{"data-testid":"up-button",size:15,className:ar.movementIcons})}),!e.isLast&&a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),e.onMoveDown&&e.onMoveDown()},children:a.jsx(N7,{"data-testid":"down-button",size:15,className:ar.movementIcons})})]})}),a.jsxs("div",{className:ar.bottomActions,children:[o&&a.jsxs(a.Fragment,{children:[a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),h({id:us(),linkId:Lm("q"),type:"string",text:"Question"})},children:"Add item"}),a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),h({id:us(),linkId:Lm("g"),type:"group",text:"Group"},!0)},children:"Add group"})]}),r&&a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),h(iU(),!0)},children:"Add Page"}),s&&!r&&a.jsxs(a.Fragment,{children:[a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),e.onRepeatable&&e.onRepeatable(n)},children:n.repeats?"Remove Repeatable":"Make Repeatable"}),a.jsx(He,{href:"#",onClick:b=>{b.preventDefault(),e.onRemove&&e.onRemove()},children:"Remove"})]})]})]})}function eU(e){const t=js("QuestionnaireItemAnswerOption","value[x]"),n=e.item.answerOption??[];return a.jsxs("div",{children:[e.item.answerValueSet!==void 0?a.jsx(ae,{placeholder:"Enter Value Set",defaultValue:e.item.answerValueSet,onChange:r=>e.onChange({...e.item,answerValueSet:r.target.value})}):a.jsx(tU,{options:n,property:t,item:e.item,onChange:e.onChange}),a.jsxs(W,{display:"flex",children:[a.jsx(He,{href:"#",onClick:r=>{it(r),e.onChange({...e.item,answerValueSet:void 0,answerOption:[...n,{id:us()}]})},children:"Add choice"}),a.jsx(Uf,{w:"lg"}),a.jsx(He,{href:"#",onClick:r=>{it(r),e.onChange({...e.item,answerOption:[],answerValueSet:""})},children:"Add value set"})]})]})}function tU(e){return a.jsx("div",{children:e.options.map(t=>{const[n,r]=Wc({type:"QuestionnaireItemAnswerOption",value:t},"value");return a.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",width:"80%"},children:[a.jsx("div",{children:a.jsx(Ka,{name:"value[x]",path:"Questionnaire.answerOption.value[x]",property:e.property,defaultPropertyType:r,defaultValue:n,onChange:(o,i)=>{const s=[...e.options],l=s.findIndex(c=>c.id===t.id);s[l]={id:t.id,[i]:o},e.onChange({...e.item,answerOption:s})},outcome:void 0},t.id)}),a.jsx("div",{children:a.jsx(He,{href:"#",onClick:o=>{it(o),e.onChange({...e.item,answerOption:e.options.filter(i=>i.id!==t.id)})},children:"Remove"})})]},t.id)})})}function nU(e){const t=GT(e.item)??[];return a.jsxs(a.Fragment,{children:[t.map((n,r)=>a.jsxs(Y,{children:[a.jsx(Gv,{name:"resourceType",placeholder:"Resource Type",defaultValue:n,onChange:o=>{e.onChange(cp(e.item,t.map(i=>i===n?o:i)))}}),a.jsx(He,{href:"#",onClick:o=>{it(o),e.onChange(cp(e.item,t.filter(i=>i!==n)))},children:"Remove"})]},`${n}-${r}`)),a.jsx(He,{href:"#",onClick:n=>{it(n),e.onChange(cp(e.item,[...t,""]))},children:"Add Resource Type"})]})}let Om=1,Mm=1;function Lm(e){return e+Om++}function us(){return"id-"+Mm++}function rU(e){return{...e,id:e.id||us(),item:ek(e.item)}}function ek(e){if(e)return e.forEach(t=>{var n,r;(n=t.id)!=null&&n.match(/^id-\d+$/)&&(Mm=Math.max(Mm,parseInt(t.id.substring(3),10)+1)),(r=t.linkId)!=null&&r.match(/^q\d+$/)&&(Om=Math.max(Om,parseInt(t.linkId.substring(1),10)+1))}),e.map(t=>({...t,id:t.id||us(),item:ek(t.item),answerOption:oU(t.answerOption)}))}function oU(e){if(e)return e.map(t=>({...t,id:t.id||us()}))}function iU(){return{id:us(),linkId:Lm("s"),type:"group",text:"New Page",extension:[{url:"http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",valueCodeableConcept:{coding:[{system:"http://hl7.org/fhir/questionnaire-item-control",code:"page"}]}}]}}function sU(e,t,n){const r=e??[],o=t+n;if(o<0||o>=r.length)return r;const i=[...r];return[i[t],i[o]]=[i[o],i[t]],i}function tk(e){const{item:t,response:n,onChange:r}=e,[o,i]=p.useState(aU(t,n??{linkId:t.linkId}));if(!e.checkForQuestionEnabled(t)||!n)return null;if(t.type===ut.display)return a.jsx("p",{children:t.text},t.linkId);const s=(t==null?void 0:t.repeats)&&t.type!==ut.choice&&t.type!==ut.openChoice;return t.type===ut.boolean?a.jsx(Nm,{item:t,response:n,onChange:l=>r([l]),index:0},t.linkId):a.jsxs(at,{htmlFor:e.item.linkId,title:e.item.text,withAsterisk:e.item.required,children:[[...Array(o)].map((l,c)=>a.jsx(Nm,{item:t,response:n,onChange:u=>r([u]),index:c},`${t.linkId}-${c}`)),s&&a.jsx(He,{onClick:()=>i(l=>l+1),children:"Add Item"})]},e.item.linkId)}function aU(e,t){if(e.type===ut.choice||e.type===ut.openChoice)return 1;const n=t.answer;return n!=null&&n.length?n.length:1}function nk(e){const[t,n]=p.useState(e.response);if(t.length===0)return null;function r(i,s){const l=t.map((c,u)=>u===s?i[0]:c);n(l),e.onChange(l)}function o(){const i=KT(e.item);n([...t,i])}return a.jsxs(a.Fragment,{children:[t.map((i,s)=>a.jsx(rk,{item:e.item,response:i,checkForQuestionEnabled:e.checkForQuestionEnabled,onChange:l=>r(l,s)},i.id)),e.item.repeats&&a.jsx(He,{onClick:o,children:`Add Group: ${e.item.text}`})]})}function rk(e){var i;const{response:t,checkForQuestionEnabled:n,onChange:r}=e;function o(s){var d;const l=(d=t.item)==null?void 0:d.map(f=>s.find(m=>m.id===f.id)??f),c=l==null?void 0:l.concat(s.slice(1)),u={...t,item:c};r([u])}return e.checkForQuestionEnabled(e.item)?a.jsxs("div",{children:[e.item.text&&a.jsx(ue,{order:3,mb:"md",children:e.item.text}),a.jsx(be,{children:(i=e.item.item)==null?void 0:i.map(s=>{var l,c,u;return s.type===ut.group?s.repeats?a.jsx(nk,{item:s,response:((l=t.item)==null?void 0:l.filter(d=>d.linkId===s.linkId))??[],checkForQuestionEnabled:n,onChange:o},s.linkId):a.jsx(rk,{item:s,checkForQuestionEnabled:n,response:((c=t.item)==null?void 0:c.find(d=>d.linkId===s.linkId))??{linkId:s.linkId},onChange:o},s.linkId):a.jsx(tk,{item:s,response:(u=t.item)==null?void 0:u.find(d=>d.linkId===s.linkId),onChange:o,checkForQuestionEnabled:n},s.linkId)})})]},e.item.linkId):null}function lU(e){const{items:t,response:n,activePage:r,onChange:o,nextStep:i,prevStep:s,numberOfPages:l,renderPages:c,submitButtonText:u,checkForQuestionEnabled:d}=e,f=t.map(h=>{var y;const m=((y=n==null?void 0:n.item)==null?void 0:y.filter(S=>S.linkId===h.linkId))??[],g=h.type===ut.group?a.jsx(nk,{item:h,response:m,onChange:o,checkForQuestionEnabled:d},h.linkId):a.jsx(tk,{item:h,response:m==null?void 0:m[0],onChange:o,checkForQuestionEnabled:d},h.linkId);return c?a.jsx(Ra.Step,{label:h.text,children:g},h.linkId):g});return a.jsxs(a.Fragment,{children:[c&&a.jsx(Ra,{active:r??0,allowNextStepsSelect:!1,p:6,children:f}),!c&&a.jsx(be,{children:f}),a.jsx(cU,{activePage:r??0,numberOfPages:l,nextStep:i,prevStep:s,submitButtonText:u})]})}function cU(e){const t=e.activePage>0,n=e.activePage<e.numberOfPages-1,r=e.activePage===e.numberOfPages-1;return a.jsxs(Y,{justify:"flex-end",mt:"xl",gap:"xs",children:[t&&a.jsx(te,{onClick:e.prevStep,children:"Back"}),n&&a.jsx(te,{onClick:o=>{o.currentTarget.closest("form").reportValidity()&&e.nextStep()},children:"Next"}),r&&a.jsx(te,{type:"submit",children:e.submitButtonText??"Submit"})]})}function ok(e){const t=ne(),n=t.getProfile(),[r,o]=p.useState(!1),i=ct(e.questionnaire),[s,l]=p.useState(),[c,u]=p.useState(0);p.useEffect(()=>{t.requestSchema("Questionnaire").then(()=>t.requestSchema("QuestionnaireResponse")).then(()=>o(!0)).catch(console.log)},[t]),p.useEffect(()=>{l(i?RB(i):void 0)},[i]);function d(y){const S=(s==null?void 0:s.item)??[],x={resourceType:"QuestionnaireResponse",status:"in-progress",item:ik(S,Array.isArray(y)?y:[y])};l(x)}function f(y){return EB(y,(s==null?void 0:s.item)??[])}if(!r||!i||!s)return null;const h=NB(i),m=()=>u(y=>y+1),g=()=>u(y=>y-1);return a.jsx(YT.Provider,{value:{subject:e.subject,encounter:e.encounter},children:a.jsxs(We,{testid:"questionnaire-form",onSubmit:()=>{e.onSubmit&&s&&e.onSubmit({...s,questionnaire:ht(i),subject:e.subject,source:ft(n),authored:new Date().toISOString(),status:"completed"})},children:[i.title&&a.jsx(ue,{children:i.title}),a.jsx(lU,{items:i.item??[],response:s,onChange:d,renderPages:h>1,activePage:c,numberOfPages:h,submitButtonText:e.submitButtonText,checkForQuestionEnabled:f,nextStep:m,prevStep:g})]})})}function uU(e,t){const n=ik(e.item??[],t.item??[]);return{...t,item:n.length>0?n:void 0,answer:t.answer&&t.answer.length>0?t.answer:e.answer}}function ik(e,t){const n=[],r=new Set;for(const o of e){const i=o.id,s=t.find(l=>l.id===i);s?(n.push(uU(o,s)),r.add(s.id)):n.push(o)}for(const o of t)r.has(o.id)||n.push(o);return n}const dU="_section_4m5it_1",fU={section:dU},hU=["gender","age","gestationalAge","context","appliesTo","category"],pU={definition:{resourceType:"ObservationDefinition",code:{text:""}},onSubmit:()=>{}};function mU(e){e=Object.assign(pU,e);const t=e.definition,[n,r]=p.useState([]),[o,i]=p.useState(1),[s,l]=p.useState(1);return p.useEffect(()=>{const g=vU(t,l);r(xU(g.qualifiedInterval||[],i))},[t]),a.jsxs(We,{testid:"reference-range-editor",onSubmit:c,children:[a.jsx(be,{children:n.map(g=>{var y;return a.jsx(gU,{unit:SU((y=t.quantitativeDetails)==null?void 0:y.unit),onChange:f,onAdd:h,onRemove:m,onRemoveGroup:d,intervalGroup:g},`group-${g.id}`)})}),a.jsx(qt,{title:"Add Group",variant:"subtle",size:"sm",onClick:g=>{it(g),u({id:`group-id-${o}`,filters:{},intervals:[]}),i(y=>y+1)},children:a.jsx(Od,{})}),a.jsx(Y,{justify:"flex-end",children:a.jsx(te,{type:"submit",children:"Save"})})]});function c(){const g=n.flatMap(y=>y.intervals).filter(y=>!bU(y));e.onSubmit({...t,qualifiedInterval:g})}function u(g){r(y=>[...y,g])}function d(g){r(y=>y.filter(S=>S.id!==g.id))}function f(g,y){r(S=>{S=[...S];const v=S.find(w=>w.id===g),x=v==null?void 0:v.intervals.findIndex(w=>w.id===y.id);return x!==void 0&&(v!=null&&v.intervals[x])&&(v.intervals[x]=y),S})}function h(g,y){y.id===void 0&&(y.id=`id-${s}`,l(S=>S+1)),r(S=>{S=[...S];const v=S.findIndex(x=>x.id===g);if(v!==-1){const x={...S[v]};y={...y,...x.filters},x.intervals=[...x.intervals,y],S[v]=x}return S})}function m(g,y){r(S=>{S=[...S];const v=S.find(x=>x.id===g);return v&&(v.intervals=v.intervals.filter(x=>x.id!==y.id)),S})}}function gU(e){const{intervalGroup:t,unit:n}=e;return a.jsx(qc,{"data-testid":t.id,className:fU.section,children:a.jsxs(be,{gap:"lg",children:[a.jsx(Y,{justify:"flex-end",children:a.jsx(qt,{title:"Remove Group",variant:"subtle","data-testid":`remove-group-button-${t.id}`,size:"sm",onClick:r=>{it(r),e.onRemoveGroup(t)},children:a.jsx(Nd,{})},`remove-group-button-${t.id}`)}),a.jsx(yU,{intervalGroup:t,onChange:e.onChange}),a.jsx(fn,{}),t.intervals.map(r=>a.jsxs(be,{gap:"xs",children:[a.jsxs(Y,{children:[a.jsx(ae,{"data-testid":`condition-${r.id}`,defaultValue:r.condition,label:"Condition: ",size:"sm",onChange:o=>{it(o),e.onChange(t.id,{...r,condition:o.currentTarget.value.trim()})}},`condition-${r.id}`),a.jsx(qt,{title:"Remove Interval",variant:"subtle",size:"sm","data-testid":`remove-interval-${r.id}`,onClick:o=>{it(o),e.onRemove(t.id,r)},children:a.jsx(Nd,{})},`remove-interval-${r.id}`)]}),a.jsx(Xv,{onChange:o=>{e.onChange(t.id,{...r,range:o})},name:`range-${r.id}`,defaultValue:r.range},`range-${r.id}`)]},`interval-${r.id}`)),a.jsx(qt,{title:"Add Interval",variant:"subtle",size:"sm",onClick:r=>{it(r),e.onAdd(t.id,{range:{low:{unit:n},high:{unit:n}}})},children:a.jsx(Od,{})})]})})}function yU(e){var r,o;const{intervalGroup:t,onChange:n}=e;t.filters.age||(t.filters.age={});for(const i of["low","high"])(r=t.filters.age[i])!=null&&r.unit||(t.filters.age[i]={...t.filters.age[i],unit:"years",system:"http://unitsofmeasure.org"});return a.jsxs(be,{style:{maxWidth:"50%"},children:[a.jsx(Y,{children:a.jsx(wt,{data:["","male","female"],label:"Gender:",defaultValue:t.filters.gender||"",onChange:i=>{for(const s of t.intervals){let l=i.currentTarget.value;l===""&&(l=void 0),n(t.id,{...s,gender:l})}}})}),a.jsxs(Y,{gap:"xs",children:[a.jsx(se,{component:"label",htmlFor:`div-age-${t.id}`,children:"Age:"}),a.jsx("div",{id:`div-age-${t.id}`,children:a.jsx(Xv,{name:`age-${t.id}`,defaultValue:t.filters.age,onChange:i=>{for(const s of t.intervals)n(t.id,{...s,age:i})}},`age-${t.id}`)})]}),a.jsx(wt,{data:["","pre-puberty","follicular","midcycle","luteal","postmenopausal"],label:"Endocrine:",defaultValue:((o=t.filters.context)==null?void 0:o.text)||"",onChange:i=>{for(const s of t.intervals){let l=i.currentTarget.value;l===""?(l=void 0,n(t.id,{...s,context:void 0})):n(t.id,{...s,context:{text:l,coding:[{code:l,system:"http://terminology.hl7.org/CodeSystem/referencerange-meaning"}]}})}}}),a.jsx(wt,{data:["","reference","critical","absolute"],label:"Category: ",defaultValue:t.filters.category,onChange:i=>{for(const s of t.intervals){const l=i.currentTarget.value;l===""?n(t.id,{...s,category:void 0}):n(t.id,{...s,category:l})}}})]})}function vU(e,t){const n=e.qualifiedInterval||[];let r=Math.max(...n.map(o=>{var s;const i=parseInt(((s=o.id)==null?void 0:s.substring(3))||"",10);return isNaN(i)?Number.NEGATIVE_INFINITY:i}))+1;return Number.isFinite(r)||(r=1),e={...e,qualifiedInterval:n.map(o=>({...o,id:o.id||`id-${r++}`}))},t(r),e}function xU(e,t){let n=1;const r={};for(const o of e){const i=wU(o);i in r||(r[i]={id:`group-id-${n++}`,filters:Object.fromEntries(hU.map(s=>[s,o[s]])),intervals:[]}),r[i].intervals.push(o)}return t(n),Object.values(r)}function wU(e){var n,r;return[`gender=${e.gender}`,`age=${sc(e.age)}`,`gestationalAge=${sc(e.gestationalAge)}`,`context=${(n=e.context)==null?void 0:n.text}`,`appliesTo=${(r=e.appliesTo)==null?void 0:r.map(o=>o.text).join("+")}`,`category=${e.category}`].join(":")}function SU(e){return e&&(EL(e,"http://unitsofmeasure.org")||e.text)}function bU(e){var t,n,r,o;return((n=(t=e.range)==null?void 0:t.low)==null?void 0:n.value)===void 0&&((o=(r=e.range)==null?void 0:r.high)==null?void 0:o.value)===void 0}function CU(e){var u;const t=ne(),n=ct(e.value),[r,o]=p.useState(!1),[i,s]=p.useState();if(p.useEffect(()=>{n&&!r&&(t.executeBatch(l(n)).then(s).catch(console.log),o(!0))},[t,n,r]),!n||!i)return null;return a.jsx(Kn,{children:(u=n.action)==null?void 0:u.map((d,f)=>{var y,S,v,x,w,b;const h=d.resource&&c(d.resource),m=(S=(y=h==null?void 0:h.input)==null?void 0:y[0])==null?void 0:S.valueReference,g=(x=(v=h==null?void 0:h.output)==null?void 0:v[0])==null?void 0:x.valueReference;return a.jsxs(p.Fragment,{children:[a.jsx(Kn.Col,{span:1,p:"md",children:(h==null?void 0:h.status)==="completed"?a.jsx(W7,{}):a.jsx(g6,{color:"gray"})}),a.jsxs(Kn.Col,{span:9,p:"xs",children:[a.jsx(se,{fw:500,children:d.title}),d.description&&a.jsx("div",{children:d.description}),a.jsxs("div",{children:["Last edited by ",a.jsx(Ya,{value:(w=h==null?void 0:h.meta)==null?void 0:w.author})," on ",jn((b=h==null?void 0:h.meta)==null?void 0:b.lastUpdated)]}),a.jsxs("div",{children:["Status: ",a.jsx(t0,{status:(h==null?void 0:h.status)||"unknown"})]})]}),a.jsxs(Kn.Col,{span:2,p:"md",children:[m&&!g&&a.jsx(te,{onClick:()=>e.onStart(h,m),children:"Start"}),m&&g&&a.jsx(te,{onClick:()=>e.onEdit(h,m,g),children:"Edit"})]})]},`action-${f}`)})});function l(d){var h;const f=[];if(d.action)for(const m of d.action)(h=m.resource)!=null&&h.reference&&f.push({request:{method:"GET",url:m.resource.reference}});return{resourceType:"Bundle",type:"batch",entry:f}}function c(d){for(const f of i==null?void 0:i.entry)if(f.resource&&d.reference===ht(f.resource))return f.resource}}function sk(e,t){const n=EU(e,t);return jU(n,e,t)}function EU(e,t){const n=e.length,r=t.length,o=n+r+1,i=1+2*o,s=i/2|0,l=new Array(i);l[s+1]={i:0,j:-1,prev:void 0,snake:!0};for(let c=0;c<o;c++){for(let u=-c;u<=c;u+=2){const d=s+u,f=d+1,h=d-1,m=l[f],g=l[h];let y,S=0;u===-c||u!==c&&g.i<m.i?(S=m.i,y=m):(S=g.i+1,y=g),l[h]=void 0;let v=S-u,x={i:S,j:v,prev:PU(y),snake:!1};for(;S<n&&v<r&&e[S]===t[v];)S++,v++;if(S>x.i&&(x={i:S,j:v,prev:x,snake:!0}),l[d]=x,S>=n&&v>=r)return l[d]}l[s+c-1]=void 0}}function jU(e,t,n){const r=[];let o=e;for(o.snake&&(o=o.prev);o!=null&&o.prev&&o.prev.j>=0;){const i=o.i,s=o.j;o=o.prev;const l=o.i,c=o.j,u={position:l,lines:t.slice(l,i)},d={position:c,lines:n.slice(c,s)};let f;u.lines.length===0&&d.lines.length>0?f="insert":u.lines.length>0&&d.lines.length===0?f="delete":f="change",r.push({original:u,revised:d,type:f}),o.snake&&(o=o.prev)}return r}function PU(e){return e&&!e.snake&&e.prev?e.prev:e}function TU(e){const t=e.entry.filter(r=>!!r.resource).map(r=>{var o;return{meta:(o=r.resource)==null?void 0:o.meta,lines:tr(r.resource,!0).match(/[^\r\n]+/g)}}).sort((r,o)=>r.meta.lastUpdated.localeCompare(o.meta.lastUpdated)),n=t[0].lines.map(r=>({id:t[0].meta.versionId,meta:t[0].meta,value:r,span:1}));return kU(n,t),RU(n),n}function kU(e,t){for(let n=1;n<t.length;n++){const r=sk(t[n-1].lines,t[n].lines);for(const o of r){const i=o.original.position,s=o.original.lines,l=o.revised.lines;if((o.type==="delete"||o.type==="change")&&e.splice(i,s.length),o.type==="insert"||o.type==="change")for(let c=0;c<o.revised.lines.length;c++)e.splice(i+c,0,{id:t[n].meta.versionId,meta:t[n].meta,value:l[c],span:1})}}}function RU(e){let t=0;for(;t<e.length;){let n=t;for(;n<e.length&&e[n].id===e[t].id;)e[n].span=-1,n++;e[t].span=n-t,t=n}}const DU="_container_1oj0p_1",IU="_root_1oj0p_5",_U="_startRow_1oj0p_20",AU="_normalRow_1oj0p_24",NU="_author_1oj0p_28",OU="_dateTime_1oj0p_32",MU="_lineNumber_1oj0p_37",LU="_line_1oj0p_37",$U="_pre_1oj0p_52",po={container:DU,root:IU,startRow:_U,normalRow:AU,author:NU,dateTime:OU,lineNumber:MU,line:LU,pre:$U};function FU(e,t){return`/${e.resourceType}/${e.id}/_history/${t}`}function zU(e){const t=Math.floor((Date.now()-Date.parse(e))/1e3),n=Math.floor(t/31536e3);if(n>0)return zs(n,"year");const r=Math.floor(t/2592e3);if(r>0)return zs(r,"month");const o=Math.floor(t/86400);if(o>0)return zs(o,"day");const i=Math.floor(t/3600);if(i>0)return zs(i,"hour");const s=Math.floor(t/60);return s>0?zs(s,"minute"):zs(t,"second")}function zs(e,t){return`${e} ${e===1?t:t+"s"} ago`}function BU(e){var s,l;const t=ne(),[n,r]=p.useState(e.history);if(p.useEffect(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),!n)return a.jsx("div",{children:"Loading..."});const o=(l=(s=n.entry)==null?void 0:s[0])==null?void 0:l.resource;if(!o)return null;const i=TU(n);return a.jsx("div",{className:po.container,children:a.jsx("table",{className:po.root,children:a.jsx("tbody",{children:i.map((c,u)=>a.jsxs("tr",{className:c.span>0?po.startRow:po.normalRow,children:[c.span>0&&a.jsxs(a.Fragment,{children:[a.jsx("td",{className:po.author,rowSpan:c.span,children:a.jsx(ma,{value:c.meta.author,link:!0})}),a.jsx("td",{className:po.dateTime,rowSpan:c.span,children:a.jsx(Fe,{to:FU(o,c.meta.versionId),children:zU(c.meta.lastUpdated)})})]}),a.jsx("td",{className:po.lineNumber,children:u+1}),a.jsx("td",{className:po.line,children:a.jsx("pre",{className:po.pre,children:c.value})})]},"row-"+u))})})})}const UU="_removed_mgz0k_2",VU="_added_mgz0k_7",kw={removed:UU,added:VU};function WU(e){let t=e.original,n=e.revised;e.ignoreMeta&&(t={...t,meta:void 0},n={...n,meta:void 0});const r=tr(t,!0).match(/[^\r\n]+/g),o=tr(n,!0).match(/[^\r\n]+/g),i=sk(r,o);return a.jsx("pre",{style:{color:"gray"},children:i.map((s,l)=>a.jsx(HU,{delta:s},"delta"+l))})}function HU(e){return a.jsxs(a.Fragment,{children:["...",a.jsx("br",{}),e.delta.original.lines.length>0&&a.jsx("div",{className:kw.removed,children:e.delta.original.lines.join(`
515
515
  `)}),e.delta.revised.lines.length>0&&a.jsx("div",{className:kw.added,children:e.delta.revised.lines.join(`
516
- `)}),"...",a.jsx("br",{})]})}function zd(e){const{outcome:t}=e,n=ne(),r=ct(e.defaultValue),[o,i]=p.useState(),[s,l]=p.useState();return p.useEffect(()=>{if(r)if(e.profileUrl){const c=e.profileUrl;n.requestProfileSchema(e.profileUrl,{expandProfile:!0}).then(()=>{const u=Cs(c);if(u){i(u.name);const d=C7(r,u);l(d)}else console.error(`Schema not found for ${c}`)}).catch(u=>{console.error("Error in requestProfileSchema",u)})}else{const c=e.schemaName??(r==null?void 0:r.resourceType);n.requestSchema(c).then(()=>{l(r),i(c)}).catch(console.log)}},[n,r,e.schemaName,e.profileUrl]),!o||!s?a.jsx("div",{children:"Loading..."}):a.jsxs("form",{noValidate:!0,autoComplete:"off",onSubmit:c=>{c.preventDefault(),e.onSubmit&&e.onSubmit(s)},children:[a.jsxs(be,{mb:"xl",children:[a.jsx(at,{title:"Resource Type",htmlFor:"resourceType",outcome:t,children:a.jsx(ae,{name:"resourceType",defaultValue:s.resourceType,disabled:!0})}),a.jsx(at,{title:"ID",htmlFor:"id",outcome:t,children:a.jsx(ae,{name:"id",defaultValue:s.id,disabled:!0})})]}),a.jsx(e0,{path:s.resourceType,typeName:o,defaultValue:s,outcome:t,onChange:l,profileUrl:e.profileUrl}),a.jsxs(Y,{justify:"flex-end",mt:"xl",children:[a.jsx(te,{type:"submit",children:"OK"}),e.onDelete&&a.jsx(te,{variant:"outline",color:"red",type:"button",onClick:()=>{e.onDelete(s)},children:"Delete"})]})]})}function qU(e){var o;const t=ne(),[n,r]=p.useState(e.history);return p.useEffect(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),n?a.jsxs(le,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[a.jsx(le.Thead,{children:a.jsxs(le.Tr,{children:[a.jsx(le.Th,{children:"Author"}),a.jsx(le.Th,{children:"Date"}),a.jsx(le.Th,{children:"Version"})]})}),a.jsx(le.Tbody,{children:(o=n.entry)==null?void 0:o.map((i,s)=>a.jsx(GU,{entry:i},"entry-"+s))})]}):a.jsx("div",{children:"Loading..."})}function GU(e){var r,o,i;const{response:t,resource:n}=e.entry;return n?a.jsxs(le.Tr,{children:[a.jsx(le.Td,{children:a.jsx(ma,{value:(r=n.meta)==null?void 0:r.author,link:!0})}),a.jsx(le.Td,{children:jn((o=n.meta)==null?void 0:o.lastUpdated)}),a.jsx(le.Td,{children:a.jsx(Fe,{to:QU(n),children:(i=n.meta)==null?void 0:i.versionId})})]}):a.jsx(le.Tr,{children:a.jsx(le.Td,{colSpan:3,children:Te(t==null?void 0:t.outcome)})})}function QU(e){var t;return`/${e.resourceType}/${e.id}/_history/${(t=e.meta)==null?void 0:t.versionId}`}function KU(e){return a.jsx(nh,{value:e.serviceRequest,loadTimelineResources:async(t,n,r)=>{const o=`${n}/${r}`,i=100;return Promise.allSettled([t.readHistory("ServiceRequest",r),t.search("Communication",{"based-on":o,_count:i}),t.search("DiagnosticReport",{"based-on":o,_count:i}),t.search("Media",{"based-on":o,_count:i}),t.search("DocumentReference",{related:o,_count:i}),t.search("Task",{_filter:`based-on eq ${o} or focus eq ${o} or subject eq ${o}`,_count:i})])},createCommunication:(t,n,r)=>({resourceType:"Communication",status:"completed",basedOn:[ft(t)],subject:t.subject,sender:ft(n),sent:new Date().toISOString(),payload:[{contentString:r}]}),createMedia:(t,n,r)=>({resourceType:"Media",status:"completed",basedOn:[ft(t)],subject:t.subject,operator:ft(n),issued:new Date().toISOString(),content:r})})}function YU(e){const t=ne(),{client:n,patient:r,encounter:o,children:i,...s}=e;function l(){t.createResource({resourceType:"SmartAppLaunch",patient:r,encounter:o}).then(c=>{const u=new URL(n.launchUri);u.searchParams.set("iss",t.getBaseUrl()+"fhir/R4"),u.searchParams.set("launch",c.id),window.location.assign(u.toString())}).catch(c=>fe({color:"red",message:Te(c),autoClose:!1}))}return a.jsx(He,{onClick:()=>l(),...s,children:i})}function ak(e){const t=ne(),[n,r]=p.useState();return a.jsxs(We,{style:{maxWidth:400},onSubmit:async o=>{try{e.handleAuthResponse(await t.startNewProject({login:e.login,projectName:o.projectName}))}catch(i){r(lt(i))}},children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Create project"})]}),a.jsxs(be,{gap:"xl",children:[a.jsx(ae,{name:"projectName",label:"Project Name",placeholder:"My Project",required:!0,autoFocus:!0,error:ze(n,"firstName")}),a.jsxs(se,{c:"dimmed",size:"xs",children:["By clicking submit you agree to the Medplum"," ",a.jsx(He,{href:"https://www.medplum.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://www.medplum.com/terms",children:"Terms of Service"}),"."]})]}),a.jsx(Y,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(te,{type:"submit",children:"Create project"})})]})}function lk(e,t){const n=document.getElementsByTagName("head")[0],r=document.createElement("script");r.async=!0,r.src=e,r.onload=t??null,n.appendChild(r)}function ck(e){const t=ne(),{googleClientId:n,handleGoogleCredential:r}=e,o=p.useRef(null),[i,s]=p.useState(typeof google<"u"),[l,c]=p.useState(!1),[u,d]=p.useState(!1);return p.useEffect(()=>{if(typeof google>"u"){lk("https://accounts.google.com/gsi/client",()=>s(!0));return}l||(google.accounts.id.initialize({client_id:n,callback:r}),c(!0)),o.current&&!u&&(google.accounts.id.renderButton(o.current,{}),d(!0))},[t,n,l,i,o,u,r]),n?a.jsx("div",{ref:o}):null}var XU={MEDPLUM_BASE_URL:"__MEDPLUM_BASE_URL__",MEDPLUM_CLIENT_ID:"__MEDPLUM_CLIENT_ID__",GOOGLE_CLIENT_ID:"__GOOGLE_CLIENT_ID__",RECAPTCHA_SITE_KEY:"__RECAPTCHA_SITE_KEY__",MEDPLUM_REGISTER_ENABLED:"__MEDPLUM_REGISTER_ENABLED__",MEDPLUM_VERSION:"3.0.12-787031d28",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function uk(e){var t;if(e)return e;if(typeof window<"u"){const n=window.location.protocol+"//"+window.location.host;if((((t=XU.GOOGLE_AUTH_ORIGINS)==null?void 0:t.split(","))??[]).includes(n))return"__GOOGLE_CLIENT_ID__"}}function dk(e){typeof grecaptcha>"u"&&lk("https://www.google.com/recaptcha/api.js?render="+e)}function fk(e){return new Promise((t,n)=>{grecaptcha.ready(async()=>{try{t(await grecaptcha.execute(e,{action:"submit"}))}catch(r){n(r)}})})}function JU(e){const t=uk(e.googleClientId),n=e.recaptchaSiteKey,r=ne(),[o,i]=p.useState(),s=Hc(o,void 0);return p.useEffect(()=>{n&&dk(n)},[n]),a.jsxs(We,{style:{maxWidth:400},onSubmit:async l=>{try{let c="";n&&(c=await fk(n)),e.handleAuthResponse(await r.startNewUser({projectId:e.projectId,clientId:e.clientId,firstName:l.firstName,lastName:l.lastName,email:l.email,password:l.password,remember:l.remember==="true",recaptchaSiteKey:n,recaptchaToken:c}))}catch(c){i(lt(c))}},children:[a.jsx(on,{style:{flexDirection:"column"},children:e.children}),a.jsx(Wr,{issues:s}),t&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{justify:"center",p:"xl",style:{height:70},children:a.jsx(ck,{googleClientId:t,handleGoogleCredential:async l=>{try{e.handleAuthResponse(await r.startGoogleLogin({googleClientId:l.clientId,googleCredential:l.credential,createUser:!0}))}catch(c){i(lt(c))}}})}),a.jsx(fn,{label:"or",labelPosition:"center",my:"lg"})]}),a.jsxs(be,{gap:"xl",children:[a.jsx(ae,{name:"firstName",type:"text",label:"First name",placeholder:"First name",required:!0,autoFocus:!0,error:ze(o,"firstName")}),a.jsx(ae,{name:"lastName",type:"text",label:"Last name",placeholder:"Last name",required:!0,error:ze(o,"lastName")}),a.jsx(ae,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,error:ze(o,"email")}),a.jsx(Nr,{name:"password",label:"Password",autoComplete:"off",required:!0,error:ze(o,"password")}),a.jsxs(se,{c:"dimmed",size:"xs",children:["By clicking submit you agree to the Medplum"," ",a.jsx(He,{href:"https://www.medplum.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://www.medplum.com/terms",children:"Terms of Service"}),"."]}),a.jsxs(se,{c:"dimmed",size:"xs",children:["This site is protected by reCAPTCHA and the Google"," ",a.jsx(He,{href:"https://policies.google.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://policies.google.com/terms",children:"Terms of Service"})," apply."]})]}),a.jsxs(Y,{justify:"space-between",mt:"xl",wrap:"nowrap",children:[a.jsx(gr,{name:"remember",label:"Remember me",size:"xs"}),a.jsx(te,{type:"submit",children:"Create account"})]})]})}function ZU(e){const{type:t,projectId:n,clientId:r,googleClientId:o,recaptchaSiteKey:i,onSuccess:s}=e,l=ne(),[c,u]=p.useState(),[d,f]=p.useState();p.useEffect(()=>{t==="patient"&&c&&l.startNewPatient({login:c,projectId:n}).then(m=>l.processCode(m.code)).then(()=>s()).catch(m=>f(lt(m)))},[l,t,n,c,s]);function h(m){m.code?l.processCode(m.code).then(()=>s()).catch(console.log):m.login&&u(m.login)}return a.jsxs(Se,{width:450,children:[d&&a.jsx("pre",{children:JSON.stringify(d,null,2)}),!c&&a.jsx(JU,{projectId:n,clientId:r,googleClientId:o,recaptchaSiteKey:i,handleAuthResponse:h,children:e.children}),c&&t==="project"&&a.jsx(ak,{login:c,handleAuthResponse:h})]})}function eV(e){const[t,n]=p.useState();return t?a.jsx(nV,{email:t,...e}):a.jsx(tV,{setEmail:n,...e})}function tV(e){const{setEmail:t,onRegister:n,handleAuthResponse:r,children:o,disableEmailAuth:i,...s}=e,l=ne(),c=!e.disableGoogleAuth&&uk(e.googleClientId),[u,d]=p.useState(),f=Hc(u,void 0),h=p.useCallback(async y=>{if(!y.authorizeUrl)return!1;const S=JSON.stringify({...await l.ensureCodeChallenge(s),domain:y.domain}),v=new URL(y.authorizeUrl);return v.searchParams.set("state",S),window.location.assign(v.toString()),!0},[l,s]),m=p.useCallback(async y=>{const S=await l.post("auth/method",{email:y.email});await h(S)||t(y.email)},[l,h,t]),g=p.useCallback(async y=>{try{const S=await l.startGoogleLogin({...s,googleCredential:y.credential});await h(S)||r(S)}catch(S){d(lt(S))}},[l,s,h,r]);return a.jsxs(We,{onSubmit:m,children:[a.jsx(on,{style:{flexDirection:"column"},children:o}),a.jsx(Wr,{issues:f}),c&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{justify:"center",p:"xl",style:{height:70},children:a.jsx(ck,{googleClientId:c,handleGoogleCredential:g})}),!i&&a.jsx(fn,{label:"or",labelPosition:"center",my:"lg"})]}),!i&&a.jsx(ae,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:ze(u,"email")}),a.jsxs(Y,{justify:"space-between",mt:"xl",gap:0,wrap:"nowrap",children:[a.jsx("div",{children:n&&a.jsx(He,{component:"button",type:"button",color:"dimmed",onClick:n,size:"xs",children:"Register"})}),!i&&a.jsx(te,{type:"submit",children:"Next"})]})]})}function nV(e){const{onForgotPassword:t,handleAuthResponse:n,children:r,...o}=e,i=ne(),[s,l]=p.useState(),c=Hc(s,void 0),u=p.useCallback(d=>{i.startLogin({...o,password:d.password,remember:d.remember==="on"}).then(n).catch(f=>l(lt(f)))},[i,o,n]);return a.jsxs(We,{style:{maxWidth:400},onSubmit:u,children:[a.jsx(on,{style:{flexDirection:"column"},children:r}),a.jsx(Wr,{issues:c}),a.jsx(be,{gap:"xl",children:a.jsx(Nr,{name:"password",label:"Password",autoComplete:"off",required:!0,autoFocus:!0,error:ze(s,"password")})}),a.jsxs(Y,{justify:"space-between",mt:"xl",gap:0,wrap:"nowrap",children:[t&&a.jsx(He,{component:"button",type:"button",c:"dimmed",onClick:t,size:"xs",children:"Forgot password"}),a.jsx(gr,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1}}),a.jsx(te,{type:"submit",children:"Sign in"})]})]})}function rV(e){const t=ne(),n=Tc(),[r,o]=p.useState(""),[i,s]=p.useState();function l(f){var h;return!!((h=f==null?void 0:f.toLowerCase())!=null&&h.includes(r.toLowerCase()))}function c(f){var h,m;return l((h=f.profile)==null?void 0:h.display)||l((m=f.project)==null?void 0:m.display)}function u(f){t.post("auth/profile",{login:e.login,profile:f}).then(e.handleAuthResponse).catch(h=>s(lt(h)))}const d=e.memberships.filter(c).slice(0,10).map(f=>a.jsx(Ee.Option,{value:f.id,children:a.jsx(oV,{...f})},f.id));return a.jsxs(be,{children:[a.jsxs(rs,{gap:"md",mb:"md",justify:"center",align:"center",direction:"column",wrap:"nowrap",children:[a.jsx(Vr,{size:32}),a.jsx(ue,{order:3,children:"Choose profile"})]}),a.jsx(Wr,{outcome:i}),a.jsxs(Ee,{store:n,onOptionSubmit:u,children:[a.jsx(Ee.EventsTarget,{children:a.jsx(ae,{placeholder:"Search",value:r,onChange:f=>{o(f.currentTarget.value),n.updateSelectedOptionIndex()}})}),a.jsx("div",{children:a.jsx(Ee.Options,{children:d.length>0?d:a.jsx(Ee.Empty,{children:"Nothing found..."})})})]})]})}function oV(e){var t,n;return a.jsxs(Y,{children:[a.jsx(os,{radius:"xl"}),a.jsxs("div",{children:[a.jsx(se,{fz:"sm",fw:500,children:(t=e.profile)==null?void 0:t.display}),a.jsx(se,{fz:"xs",opacity:.6,children:(n=e.project)==null?void 0:n.display})]})]})}function iV(e){const t=ne();return a.jsx(We,{style:{maxWidth:400},onSubmit:n=>{t.post("auth/scope",{login:e.login,scope:Object.keys(n).join(" ")}).then(e.handleAuthResponse).catch(console.log)},children:a.jsxs(be,{children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Choose scope"})]}),a.jsx(be,{children:(e.scope??"openid").split(" ").map(n=>a.jsx(gr,{id:n,name:n,label:n,defaultChecked:!0},n))}),a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{type:"submit",children:"Set scope"})})]})})}function sV(e){const t=ne(),[n,r]=p.useState();return a.jsx(We,{style:{maxWidth:400},onSubmit:o=>{r(void 0),t.post("auth/mfa/verify",{login:e.login,token:o.token}).then(e.handleAuthResponse).catch(i=>r(Te(i)))},children:a.jsxs(be,{children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Enter MFA code"})]}),n&&a.jsx(xs,{icon:a.jsx(zc,{size:16}),title:"Error",color:"red",children:n}),a.jsx(be,{children:a.jsx(ae,{name:"token",label:"MFA code",required:!0,autoFocus:!0})}),a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{type:"submit",children:"Submit code"})})]})})}function hk(e){const{login:t,chooseScopes:n,onSuccess:r,onForgotPassword:o,onRegister:i,onCode:s,...l}=e,c=ne(),[u,d]=p.useState(),f=p.useRef(!1),[h,m]=p.useState(!1),[g,y]=p.useState(),S=p.useCallback(w=>{s?s(w):c.processCode(w).then(()=>{r&&r()}).catch(b=>fe({color:"red",message:Te(b)}))},[c,s,r]),v=p.useCallback(w=>{m(!!w.mfaRequired),w.login&&d(w.login),w.memberships&&y(w.memberships),w.code&&(n?y(void 0):S(w.code))},[n,S]),x=p.useCallback(w=>{S(w.code)},[S]);return p.useEffect(()=>{t&&!f.current&&!u&&(f.current=!0,c.get("auth/login/"+t).then(v).catch(w=>fe({color:"red",message:Te(w)})))},[c,t,f,u,v]),a.jsx(Se,{width:450,px:"sm",py:"md",children:u?h?a.jsx(sV,{login:u,handleAuthResponse:v}):g?a.jsx(rV,{login:u,memberships:g,handleAuthResponse:v}):e.projectId==="new"?a.jsx(ak,{login:u,handleAuthResponse:v}):e.chooseScopes?a.jsx(iV,{login:u,scope:e.scope,handleAuthResponse:x}):a.jsx("div",{children:"Success"}):a.jsx(eV,{onForgotPassword:o,onRegister:i,handleAuthResponse:v,disableGoogleAuth:e.disableGoogleAuth,disableEmailAuth:e.disableEmailAuth,...l,children:e.children})})}var pk,Rw=bc;pk=Rw.createRoot,Rw.hydrateRoot;/**
516
+ `)}),"...",a.jsx("br",{})]})}function zd(e){const{outcome:t}=e,n=ne(),r=ct(e.defaultValue),[o,i]=p.useState(),[s,l]=p.useState();return p.useEffect(()=>{if(r)if(e.profileUrl){const c=e.profileUrl;n.requestProfileSchema(e.profileUrl,{expandProfile:!0}).then(()=>{const u=Cs(c);if(u){i(u.name);const d=C7(r,u);l(d)}else console.error(`Schema not found for ${c}`)}).catch(u=>{console.error("Error in requestProfileSchema",u)})}else{const c=e.schemaName??(r==null?void 0:r.resourceType);n.requestSchema(c).then(()=>{l(r),i(c)}).catch(console.log)}},[n,r,e.schemaName,e.profileUrl]),!o||!s?a.jsx("div",{children:"Loading..."}):a.jsxs("form",{noValidate:!0,autoComplete:"off",onSubmit:c=>{c.preventDefault(),e.onSubmit&&e.onSubmit(s)},children:[a.jsxs(be,{mb:"xl",children:[a.jsx(at,{title:"Resource Type",htmlFor:"resourceType",outcome:t,children:a.jsx(ae,{name:"resourceType",defaultValue:s.resourceType,disabled:!0})}),a.jsx(at,{title:"ID",htmlFor:"id",outcome:t,children:a.jsx(ae,{name:"id",defaultValue:s.id,disabled:!0})})]}),a.jsx(e0,{path:s.resourceType,typeName:o,defaultValue:s,outcome:t,onChange:l,profileUrl:e.profileUrl}),a.jsxs(Y,{justify:"flex-end",mt:"xl",children:[a.jsx(te,{type:"submit",children:"OK"}),e.onDelete&&a.jsx(te,{variant:"outline",color:"red",type:"button",onClick:()=>{e.onDelete(s)},children:"Delete"})]})]})}function qU(e){var o;const t=ne(),[n,r]=p.useState(e.history);return p.useEffect(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),n?a.jsxs(le,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[a.jsx(le.Thead,{children:a.jsxs(le.Tr,{children:[a.jsx(le.Th,{children:"Author"}),a.jsx(le.Th,{children:"Date"}),a.jsx(le.Th,{children:"Version"})]})}),a.jsx(le.Tbody,{children:(o=n.entry)==null?void 0:o.map((i,s)=>a.jsx(GU,{entry:i},"entry-"+s))})]}):a.jsx("div",{children:"Loading..."})}function GU(e){var r,o,i;const{response:t,resource:n}=e.entry;return n?a.jsxs(le.Tr,{children:[a.jsx(le.Td,{children:a.jsx(ma,{value:(r=n.meta)==null?void 0:r.author,link:!0})}),a.jsx(le.Td,{children:jn((o=n.meta)==null?void 0:o.lastUpdated)}),a.jsx(le.Td,{children:a.jsx(Fe,{to:QU(n),children:(i=n.meta)==null?void 0:i.versionId})})]}):a.jsx(le.Tr,{children:a.jsx(le.Td,{colSpan:3,children:Te(t==null?void 0:t.outcome)})})}function QU(e){var t;return`/${e.resourceType}/${e.id}/_history/${(t=e.meta)==null?void 0:t.versionId}`}function KU(e){return a.jsx(nh,{value:e.serviceRequest,loadTimelineResources:async(t,n,r)=>{const o=`${n}/${r}`,i=100;return Promise.allSettled([t.readHistory("ServiceRequest",r),t.search("Communication",{"based-on":o,_count:i}),t.search("DiagnosticReport",{"based-on":o,_count:i}),t.search("Media",{"based-on":o,_count:i}),t.search("DocumentReference",{related:o,_count:i}),t.search("Task",{_filter:`based-on eq ${o} or focus eq ${o} or subject eq ${o}`,_count:i})])},createCommunication:(t,n,r)=>({resourceType:"Communication",status:"completed",basedOn:[ft(t)],subject:t.subject,sender:ft(n),sent:new Date().toISOString(),payload:[{contentString:r}]}),createMedia:(t,n,r)=>({resourceType:"Media",status:"completed",basedOn:[ft(t)],subject:t.subject,operator:ft(n),issued:new Date().toISOString(),content:r})})}function YU(e){const t=ne(),{client:n,patient:r,encounter:o,children:i,...s}=e;function l(){t.createResource({resourceType:"SmartAppLaunch",patient:r,encounter:o}).then(c=>{const u=new URL(n.launchUri);u.searchParams.set("iss",t.getBaseUrl()+"fhir/R4"),u.searchParams.set("launch",c.id),window.location.assign(u.toString())}).catch(c=>fe({color:"red",message:Te(c),autoClose:!1}))}return a.jsx(He,{onClick:()=>l(),...s,children:i})}function ak(e){const t=ne(),[n,r]=p.useState();return a.jsxs(We,{style:{maxWidth:400},onSubmit:async o=>{try{e.handleAuthResponse(await t.startNewProject({login:e.login,projectName:o.projectName}))}catch(i){r(lt(i))}},children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Create project"})]}),a.jsxs(be,{gap:"xl",children:[a.jsx(ae,{name:"projectName",label:"Project Name",placeholder:"My Project",required:!0,autoFocus:!0,error:ze(n,"firstName")}),a.jsxs(se,{c:"dimmed",size:"xs",children:["By clicking submit you agree to the Medplum"," ",a.jsx(He,{href:"https://www.medplum.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://www.medplum.com/terms",children:"Terms of Service"}),"."]})]}),a.jsx(Y,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(te,{type:"submit",children:"Create project"})})]})}function lk(e,t){const n=document.getElementsByTagName("head")[0],r=document.createElement("script");r.async=!0,r.src=e,r.onload=t??null,n.appendChild(r)}function ck(e){const t=ne(),{googleClientId:n,handleGoogleCredential:r}=e,o=p.useRef(null),[i,s]=p.useState(typeof google<"u"),[l,c]=p.useState(!1),[u,d]=p.useState(!1);return p.useEffect(()=>{if(typeof google>"u"){lk("https://accounts.google.com/gsi/client",()=>s(!0));return}l||(google.accounts.id.initialize({client_id:n,callback:r}),c(!0)),o.current&&!u&&(google.accounts.id.renderButton(o.current,{}),d(!0))},[t,n,l,i,o,u,r]),n?a.jsx("div",{ref:o}):null}var XU={MEDPLUM_BASE_URL:"__MEDPLUM_BASE_URL__",MEDPLUM_CLIENT_ID:"__MEDPLUM_CLIENT_ID__",GOOGLE_CLIENT_ID:"__GOOGLE_CLIENT_ID__",RECAPTCHA_SITE_KEY:"__RECAPTCHA_SITE_KEY__",MEDPLUM_REGISTER_ENABLED:"__MEDPLUM_REGISTER_ENABLED__",MEDPLUM_VERSION:"3.0.13-ced876fb4",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};function uk(e){var t;if(e)return e;if(typeof window<"u"){const n=window.location.protocol+"//"+window.location.host;if((((t=XU.GOOGLE_AUTH_ORIGINS)==null?void 0:t.split(","))??[]).includes(n))return"__GOOGLE_CLIENT_ID__"}}function dk(e){typeof grecaptcha>"u"&&lk("https://www.google.com/recaptcha/api.js?render="+e)}function fk(e){return new Promise((t,n)=>{grecaptcha.ready(async()=>{try{t(await grecaptcha.execute(e,{action:"submit"}))}catch(r){n(r)}})})}function JU(e){const t=uk(e.googleClientId),n=e.recaptchaSiteKey,r=ne(),[o,i]=p.useState(),s=Hc(o,void 0);return p.useEffect(()=>{n&&dk(n)},[n]),a.jsxs(We,{style:{maxWidth:400},onSubmit:async l=>{try{let c="";n&&(c=await fk(n)),e.handleAuthResponse(await r.startNewUser({projectId:e.projectId,clientId:e.clientId,firstName:l.firstName,lastName:l.lastName,email:l.email,password:l.password,remember:l.remember==="true",recaptchaSiteKey:n,recaptchaToken:c}))}catch(c){i(lt(c))}},children:[a.jsx(on,{style:{flexDirection:"column"},children:e.children}),a.jsx(Wr,{issues:s}),t&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{justify:"center",p:"xl",style:{height:70},children:a.jsx(ck,{googleClientId:t,handleGoogleCredential:async l=>{try{e.handleAuthResponse(await r.startGoogleLogin({googleClientId:l.clientId,googleCredential:l.credential,createUser:!0}))}catch(c){i(lt(c))}}})}),a.jsx(fn,{label:"or",labelPosition:"center",my:"lg"})]}),a.jsxs(be,{gap:"xl",children:[a.jsx(ae,{name:"firstName",type:"text",label:"First name",placeholder:"First name",required:!0,autoFocus:!0,error:ze(o,"firstName")}),a.jsx(ae,{name:"lastName",type:"text",label:"Last name",placeholder:"Last name",required:!0,error:ze(o,"lastName")}),a.jsx(ae,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,error:ze(o,"email")}),a.jsx(Nr,{name:"password",label:"Password",autoComplete:"off",required:!0,error:ze(o,"password")}),a.jsxs(se,{c:"dimmed",size:"xs",children:["By clicking submit you agree to the Medplum"," ",a.jsx(He,{href:"https://www.medplum.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://www.medplum.com/terms",children:"Terms of Service"}),"."]}),a.jsxs(se,{c:"dimmed",size:"xs",children:["This site is protected by reCAPTCHA and the Google"," ",a.jsx(He,{href:"https://policies.google.com/privacy",children:"Privacy Policy"})," and ",a.jsx(He,{href:"https://policies.google.com/terms",children:"Terms of Service"})," apply."]})]}),a.jsxs(Y,{justify:"space-between",mt:"xl",wrap:"nowrap",children:[a.jsx(gr,{name:"remember",label:"Remember me",size:"xs"}),a.jsx(te,{type:"submit",children:"Create account"})]})]})}function ZU(e){const{type:t,projectId:n,clientId:r,googleClientId:o,recaptchaSiteKey:i,onSuccess:s}=e,l=ne(),[c,u]=p.useState(),[d,f]=p.useState();p.useEffect(()=>{t==="patient"&&c&&l.startNewPatient({login:c,projectId:n}).then(m=>l.processCode(m.code)).then(()=>s()).catch(m=>f(lt(m)))},[l,t,n,c,s]);function h(m){m.code?l.processCode(m.code).then(()=>s()).catch(console.log):m.login&&u(m.login)}return a.jsxs(Se,{width:450,children:[d&&a.jsx("pre",{children:JSON.stringify(d,null,2)}),!c&&a.jsx(JU,{projectId:n,clientId:r,googleClientId:o,recaptchaSiteKey:i,handleAuthResponse:h,children:e.children}),c&&t==="project"&&a.jsx(ak,{login:c,handleAuthResponse:h})]})}function eV(e){const[t,n]=p.useState();return t?a.jsx(nV,{email:t,...e}):a.jsx(tV,{setEmail:n,...e})}function tV(e){const{setEmail:t,onRegister:n,handleAuthResponse:r,children:o,disableEmailAuth:i,...s}=e,l=ne(),c=!e.disableGoogleAuth&&uk(e.googleClientId),[u,d]=p.useState(),f=Hc(u,void 0),h=p.useCallback(async y=>{if(!y.authorizeUrl)return!1;const S=JSON.stringify({...await l.ensureCodeChallenge(s),domain:y.domain}),v=new URL(y.authorizeUrl);return v.searchParams.set("state",S),window.location.assign(v.toString()),!0},[l,s]),m=p.useCallback(async y=>{const S=await l.post("auth/method",{email:y.email});await h(S)||t(y.email)},[l,h,t]),g=p.useCallback(async y=>{try{const S=await l.startGoogleLogin({...s,googleCredential:y.credential});await h(S)||r(S)}catch(S){d(lt(S))}},[l,s,h,r]);return a.jsxs(We,{onSubmit:m,children:[a.jsx(on,{style:{flexDirection:"column"},children:o}),a.jsx(Wr,{issues:f}),c&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{justify:"center",p:"xl",style:{height:70},children:a.jsx(ck,{googleClientId:c,handleGoogleCredential:g})}),!i&&a.jsx(fn,{label:"or",labelPosition:"center",my:"lg"})]}),!i&&a.jsx(ae,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:ze(u,"email")}),a.jsxs(Y,{justify:"space-between",mt:"xl",gap:0,wrap:"nowrap",children:[a.jsx("div",{children:n&&a.jsx(He,{component:"button",type:"button",color:"dimmed",onClick:n,size:"xs",children:"Register"})}),!i&&a.jsx(te,{type:"submit",children:"Next"})]})]})}function nV(e){const{onForgotPassword:t,handleAuthResponse:n,children:r,...o}=e,i=ne(),[s,l]=p.useState(),c=Hc(s,void 0),u=p.useCallback(d=>{i.startLogin({...o,password:d.password,remember:d.remember==="on"}).then(n).catch(f=>l(lt(f)))},[i,o,n]);return a.jsxs(We,{style:{maxWidth:400},onSubmit:u,children:[a.jsx(on,{style:{flexDirection:"column"},children:r}),a.jsx(Wr,{issues:c}),a.jsx(be,{gap:"xl",children:a.jsx(Nr,{name:"password",label:"Password",autoComplete:"off",required:!0,autoFocus:!0,error:ze(s,"password")})}),a.jsxs(Y,{justify:"space-between",mt:"xl",gap:0,wrap:"nowrap",children:[t&&a.jsx(He,{component:"button",type:"button",c:"dimmed",onClick:t,size:"xs",children:"Forgot password"}),a.jsx(gr,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1}}),a.jsx(te,{type:"submit",children:"Sign in"})]})]})}function rV(e){const t=ne(),n=Tc(),[r,o]=p.useState(""),[i,s]=p.useState();function l(f){var h;return!!((h=f==null?void 0:f.toLowerCase())!=null&&h.includes(r.toLowerCase()))}function c(f){var h,m;return l((h=f.profile)==null?void 0:h.display)||l((m=f.project)==null?void 0:m.display)}function u(f){t.post("auth/profile",{login:e.login,profile:f}).then(e.handleAuthResponse).catch(h=>s(lt(h)))}const d=e.memberships.filter(c).slice(0,10).map(f=>a.jsx(Ee.Option,{value:f.id,children:a.jsx(oV,{...f})},f.id));return a.jsxs(be,{children:[a.jsxs(rs,{gap:"md",mb:"md",justify:"center",align:"center",direction:"column",wrap:"nowrap",children:[a.jsx(Vr,{size:32}),a.jsx(ue,{order:3,children:"Choose profile"})]}),a.jsx(Wr,{outcome:i}),a.jsxs(Ee,{store:n,onOptionSubmit:u,children:[a.jsx(Ee.EventsTarget,{children:a.jsx(ae,{placeholder:"Search",value:r,onChange:f=>{o(f.currentTarget.value),n.updateSelectedOptionIndex()}})}),a.jsx("div",{children:a.jsx(Ee.Options,{children:d.length>0?d:a.jsx(Ee.Empty,{children:"Nothing found..."})})})]})]})}function oV(e){var t,n;return a.jsxs(Y,{children:[a.jsx(os,{radius:"xl"}),a.jsxs("div",{children:[a.jsx(se,{fz:"sm",fw:500,children:(t=e.profile)==null?void 0:t.display}),a.jsx(se,{fz:"xs",opacity:.6,children:(n=e.project)==null?void 0:n.display})]})]})}function iV(e){const t=ne();return a.jsx(We,{style:{maxWidth:400},onSubmit:n=>{t.post("auth/scope",{login:e.login,scope:Object.keys(n).join(" ")}).then(e.handleAuthResponse).catch(console.log)},children:a.jsxs(be,{children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Choose scope"})]}),a.jsx(be,{children:(e.scope??"openid").split(" ").map(n=>a.jsx(gr,{id:n,name:n,label:n,defaultChecked:!0},n))}),a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{type:"submit",children:"Set scope"})})]})})}function sV(e){const t=ne(),[n,r]=p.useState();return a.jsx(We,{style:{maxWidth:400},onSubmit:o=>{r(void 0),t.post("auth/mfa/verify",{login:e.login,token:o.token}).then(e.handleAuthResponse).catch(i=>r(Te(i)))},children:a.jsxs(be,{children:[a.jsxs(on,{style:{flexDirection:"column"},children:[a.jsx(Vr,{size:32}),a.jsx(ue,{children:"Enter MFA code"})]}),n&&a.jsx(xs,{icon:a.jsx(zc,{size:16}),title:"Error",color:"red",children:n}),a.jsx(be,{children:a.jsx(ae,{name:"token",label:"MFA code",required:!0,autoFocus:!0})}),a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{type:"submit",children:"Submit code"})})]})})}function hk(e){const{login:t,chooseScopes:n,onSuccess:r,onForgotPassword:o,onRegister:i,onCode:s,...l}=e,c=ne(),[u,d]=p.useState(),f=p.useRef(!1),[h,m]=p.useState(!1),[g,y]=p.useState(),S=p.useCallback(w=>{s?s(w):c.processCode(w).then(()=>{r&&r()}).catch(b=>fe({color:"red",message:Te(b)}))},[c,s,r]),v=p.useCallback(w=>{m(!!w.mfaRequired),w.login&&d(w.login),w.memberships&&y(w.memberships),w.code&&(n?y(void 0):S(w.code))},[n,S]),x=p.useCallback(w=>{S(w.code)},[S]);return p.useEffect(()=>{t&&!f.current&&!u&&(f.current=!0,c.get("auth/login/"+t).then(v).catch(w=>fe({color:"red",message:Te(w)})))},[c,t,f,u,v]),a.jsx(Se,{width:450,px:"sm",py:"md",children:u?h?a.jsx(sV,{login:u,handleAuthResponse:v}):g?a.jsx(rV,{login:u,memberships:g,handleAuthResponse:v}):e.projectId==="new"?a.jsx(ak,{login:u,handleAuthResponse:v}):e.chooseScopes?a.jsx(iV,{login:u,scope:e.scope,handleAuthResponse:x}):a.jsx("div",{children:"Success"}):a.jsx(eV,{onForgotPassword:o,onRegister:i,handleAuthResponse:v,disableGoogleAuth:e.disableGoogleAuth,disableEmailAuth:e.disableEmailAuth,...l,children:e.children})})}var pk,Rw=bc;pk=Rw.createRoot,Rw.hydrateRoot;/**
517
517
  * @remix-run/router v1.15.3
518
518
  *
519
519
  * Copyright (c) Remix Software Inc.
@@ -552,4 +552,4 @@ Error generating stack: `+i.message+`
552
552
  }
553
553
  ]
554
554
  }`,Pq="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 Tq(){const e=ne(),{id:t}=Xe(),[n,r]=p.useState(),[o,i]=p.useState(),[s,l]=p.useState(jq),[c,u]=p.useState(Pq),[d,f]=p.useState(Gt.FHIR_JSON),h=p.useRef(null),m=p.useRef(null),[g,y]=p.useState(!1);p.useEffect(()=>{e.readResource("Bot",t).then(async E=>{r(E),i(await kq(e,E))}).catch(E=>fe({color:"red",message:Te(E),autoClose:!1}))},[e,t]);const S=p.useCallback(()=>Xu(h.current,{command:"getValue"}),[]),v=p.useCallback(()=>Xu(h.current,{command:"getOutput"}),[]),x=p.useCallback(async()=>d===Gt.FHIR_JSON?JSON.parse(s):c,[d,s,c]),w=p.useCallback(async E=>{E.preventDefault(),E.stopPropagation(),y(!0);try{const P=await S(),T=await e.createAttachment(P,"index.ts","text/typescript"),D=[];n!=null&&n.sourceCode?D.push({op:"replace",path:"/sourceCode",value:T}):D.push({op:"add",path:"/sourceCode",value:T}),await e.patchResource("Bot",t,D),fe({color:"green",message:"Saved"})}catch(P){fe({color:"red",message:Te(P),autoClose:!1})}finally{y(!1)}},[e,t,n,S]),b=p.useCallback(async E=>{E.preventDefault(),E.stopPropagation(),y(!0);try{const P=await v();await e.post(e.fhirUrl("Bot",t,"$deploy"),{code:P}),fe({color:"green",message:"Deployed"})}catch(P){fe({color:"red",message:Te(P),autoClose:!1})}finally{y(!1)}},[e,t,v]),j=p.useCallback(async E=>{E.preventDefault(),E.stopPropagation(),y(!0);try{const P=await x(),T=await e.post(e.fhirUrl("Bot",t,"$execute"),P,d);await Xu(m.current,{command:"setValue",value:T}),fe({color:"green",message:"Success"})}catch(P){fe({color:"red",message:Te(P),autoClose:!1})}finally{y(!1)}},[e,t,x,d]);return!n||o===void 0?null:a.jsxs(Kn,{m:0,gutter:0,style:{overflow:"hidden"},children:[a.jsx(Kn.Col,{span:8,children:a.jsxs(zn,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",mih:400,children:[a.jsx(Eq,{iframeRef:h,language:"typescript",module:"commonjs",testId:"code-frame",defaultValue:o,minHeight:"528px"}),a.jsxs(Y,{justify:"flex-end",gap:"xs",children:[a.jsx(te,{type:"button",onClick:w,loading:g,leftSection:a.jsx(G7,{size:"1rem"}),children:"Save"}),a.jsx(te,{type:"button",onClick:b,loading:g,leftSection:a.jsx(Bv,{size:"1rem"}),children:"Deploy"}),a.jsx(te,{type:"button",onClick:j,loading:g,leftSection:a.jsx(c6,{size:"1rem"}),children:"Execute"})]})]})}),a.jsxs(Kn.Col,{span:4,children:[a.jsxs(zn,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",children:[a.jsx(wt,{data:[{label:"FHIR",value:Gt.FHIR_JSON},{label:"HL7",value:Gt.HL7_V2}],onChange:E=>f(E.currentTarget.value)}),d===Gt.FHIR_JSON?a.jsx(Va,{value:s,onChange:E=>l(E),autosize:!0,minRows:15}):a.jsx("textarea",{className:bq.hl7Input,value:c,onChange:E=>u(E.currentTarget.value),rows:15})]}),a.jsx(zn,{m:2,p:"xs",shadow:"md",children:a.jsx(Cq,{iframeRef:m,className:"medplum-bot-output-frame",testId:"output-frame",minHeight:"200px"})})]})]})}async function kq(e,t){var n,r,o;if((n=t.sourceCode)!=null&&n.url){const i=(o=(r=t.sourceCode.url)==null?void 0:r.split("/"))==null?void 0:o.find(jP);return(await e.download(e.fhirUrl("Binary",i))).text()}return t.code??""}function Ts(e){let t=e.meta;return t&&(t={...t,lastUpdated:void 0,versionId:void 0,author:void 0}),{...e,meta:t}}function Gk(e,t){var n,r;(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))}function Rq(e,t){var n,r;if((r=(n=e==null?void 0:e.meta)==null?void 0:n.profile)!=null&&r.includes(t)){const o=e.meta.profile.indexOf(t);e.meta.profile.splice(o,1)}}function Dq(){const e=ne(),{resourceType:t,id:n}=Xe(),r={reference:t+"/"+n},o=p.useCallback(i=>{e.updateResource(Ts(i)).then(()=>{fe({color:"green",message:"Success"})}).catch(s=>{fe({color:"red",message:Te(s),autoClose:!1})})},[e]);switch(t){case"PlanDefinition":return a.jsx(Se,{children:a.jsx(gB,{value:r,onSubmit:o})});case"Questionnaire":return a.jsx(Se,{children:a.jsx(ZB,{questionnaire:r,onSubmit:o})});default:return null}}function Iq(){const{resourceType:e,id:t}=Xe(),n=ct({reference:e+"/"+t}),r=Mt();return n?a.jsx(Se,{children:a.jsx(CU,{value:n,onStart:(o,i)=>r(`/forms/${Hf(i)}`),onEdit:(o,i,s)=>r(`/${s.reference}}`)})}):null}function _q(){const e=ne(),{resourceType:t,id:n}=Xe(),r=Mt();return a.jsxs(Se,{children:[a.jsxs("p",{children:["Are you sure you want to delete this ",t,"?"]}),a.jsx(te,{color:"red",onClick:()=>{e.deleteResource(t,n).then(()=>r(`/${t}`)).catch(o=>fe({color:"red",message:Te(o),autoClose:!1}))},children:"Delete"})]})}const Aq="_selectProfileBtn_tbaz6_1",Nq="_chevron_tbaz6_13",lS={selectProfileBtn:Aq,chevron:Nq};function Oq(){var c,u;const{resourceType:e,id:t}=Xe(),n=ct({reference:e+"/"+t}),[r,o]=p.useState(),i=Tc({onDropdownClose:()=>i.resetSelectedOption()}),s=p.useMemo(()=>{var d;if(Nt((d=n==null?void 0:n.meta)==null?void 0:d.profile))return[a.jsx(Ee.Option,{value:"",children:"None"},""),...n.meta.profile.map(f=>a.jsx(Ee.Option,{value:f,children:f},f))]},[(c=n==null?void 0:n.meta)==null?void 0:c.profile]);if(p.useEffect(()=>{var d,f;((f=(d=n==null?void 0:n.meta)==null?void 0:d.profile)==null?void 0:f.length)===1&&o(n.meta.profile[0])},[(u=n==null?void 0:n.meta)==null?void 0:u.profile]),!n)return null;let l;return Nt(s)&&(l=a.jsx(Y,{justify:"flex-end",children:a.jsxs(be,{align:"flex-end",gap:"xs",children:[a.jsxs(Ee,{store:i,width:250,position:"bottom-end",withinPortal:!1,onOptionSubmit:d=>{o(d),i.closeDropdown()},children:[a.jsx(Ee.Target,{children:a.jsx(Jn,{onClick:()=>i.toggleDropdown(),children:a.jsxs(Wy,{fw:"bold",fs:"sm",className:lS.selectProfileBtn,children:[a.jsx("span",{children:"Pick profile"}),a.jsx(QP,{stroke:1.5,className:lS.chevron})]})})}),a.jsx(Ee.Dropdown,{w:"max-content",children:a.jsx(Ee.Options,{children:s})})]}),a.jsx(W,{children:r?a.jsxs(a.Fragment,{children:[a.jsx(se,{span:!0,size:"sm",c:"dimmed",children:"Displaying profile: "}),a.jsx(se,{span:!0,size:"sm",children:r||"Nothing selected"})]}):a.jsx(se,{span:!0,size:"sm",c:"dimmed",children:"No profile displayed"})})]})})),a.jsx(Se,{children:a.jsxs(be,{gap:"xl",children:[l,a.jsx(l0,{value:n,profileUrl:r})]})})}function Mq(){const e=ne(),{resourceType:t,id:n}=Xe(),[r,o]=p.useState(),i=Mt(),[s,l]=p.useState();p.useEffect(()=>{e.readResource(t,n).then(d=>o(co(d))).catch(d=>{l(lt(d)),fe({color:"red",message:Te(d),autoClose:!1})})},[e,t,n]);const c=p.useCallback(d=>{l(void 0),e.updateResource(Ts(d)).then(()=>{i(`/${t}/${n}/details`),fe({color:"green",message:"Success"})}).catch(f=>{l(lt(f)),fe({color:"red",message:Te(f),autoClose:!1})})},[e,t,n,i]),u=p.useCallback(()=>i(`/${t}/${n}/delete`),[i,t,n]);return r?a.jsx(Se,{children:a.jsx(zd,{defaultValue:r,onSubmit:c,onDelete:u,outcome:s})}):null}function Qk(e,t){const n=ne(),r=Mt();return{defaultValue:{resourceType:e},handleSubmit:s=>{t&&t(void 0),n.createResource(s).then(l=>r("/"+l.resourceType+"/"+l.id)).catch(l=>{t&&t(lt(l)),fe({color:"red",message:Te(l),autoClose:!1,styles:{description:{whiteSpace:"pre-line"}}})})}}}function Kk({resource:e,currentProfile:t,onChange:n}){const r=e.resourceType,o=ne(),[i,s]=p.useState();return p.useEffect(()=>{o.searchResources("StructureDefinition",{type:r,derivation:"constraint",_count:50}).then(l=>{s(l.filter(TF))}).catch(console.error)},[o,n,r]),a.jsx(Ge,{value:t==null?void 0:t.url,onChange:l=>{const c=i==null?void 0:i.find(u=>u.url===l);c&&n(c)},children:a.jsx(Ge.List,{children:i==null?void 0:i.map(l=>{var d,f;const c=(f=(d=e.meta)==null?void 0:d.profile)==null?void 0:f.includes(l.url),u=c?"This profile is present in this resource's meta.profile property.":"This profile is not included in this resource's meta.profile property.";return a.jsx(Ge.Tab,{value:l.url,title:u,rightSection:c&&a.jsx(Sv,{variant:"outline",color:"green",size:"xs",style:{borderStyle:"none"},children:a.jsx(S6,{size:"90%"})}),children:l.title||l.name},l.url)})})})}function mp(){const{resourceType:e}=Xe(),t=Wo(),[n,r]=p.useState(),{defaultValue:o,handleSubmit:i}=Qk(e,r),[s,l]=p.useState(),c=t.pathname.toLowerCase().endsWith("profiles"),u=p.useCallback(d=>{const f=Ts(d);s&&Gk(f,s.url),i(f)},[s,i]);return c?a.jsx(Se,{children:a.jsxs(be,{children:[a.jsx(Kk,{resource:o,currentProfile:s,onChange:l}),s?a.jsx(zd,{defaultValue:o,onSubmit:u,outcome:n,profileUrl:s.url},s.url):a.jsx(se,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})}):a.jsx(Se,{children:a.jsx(zd,{defaultValue:o,onSubmit:i,outcome:n})})}function Lq(){const e=ne(),{resourceType:t,id:n}=Xe(),r=e.readHistory(t,n).read();return a.jsx(Se,{children:a.jsx(qU,{history:r})})}function $q(){const{resourceType:e}=Xe(),[t,n]=p.useState(),{defaultValue:r,handleSubmit:o}=Qk(e,n),i=p.useCallback(s=>{o(JSON.parse(s["new-resource"]))},[o]);return a.jsxs(Se,{children:[t&&a.jsx(Wr,{outcome:t}),a.jsxs(We,{onSubmit:i,children:[a.jsx(Va,{name:"new-resource","data-testid":"create-resource-json",autosize:!0,minRows:24,defaultValue:tr(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),a.jsx(Y,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(te,{type:"submit",children:"OK"})})]})]})}function Fq(){const e=ne(),{resourceType:t,id:n}=Xe(),r=ct({reference:t+"/"+n}),o=Mt(),[i,s]=p.useState(),l=p.useCallback(c=>{e.updateResource(Ts(JSON.parse(c.resource))).then(()=>{s(void 0),o(`/${t}/${n}/details`),fe({color:"green",message:"Success"})}).catch(u=>{fe({color:"red",message:Te(u),autoClose:!1})})},[e,t,n,o]);return r?a.jsxs(Se,{children:[i&&a.jsx(Wr,{outcome:i}),a.jsxs(We,{onSubmit:l,children:[a.jsx(Va,{name:"resource","data-testid":"resource-json",autosize:!0,minRows:24,defaultValue:tr(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),a.jsx(Y,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(te,{type:"submit",children:"OK"})})]})]}):null}function zq(){const{resourceType:e,id:t}=Xe();return ct({reference:e+"/"+t})?a.jsxs(Se,{children:[a.jsxs(xs,{icon:a.jsx(zc,{size:16}),mb:"xl",children:["This is just a preview! Access your form here:",a.jsx("br",{}),a.jsx(He,{href:`/forms/${t}`,children:`/forms/${t}`})]}),a.jsx(ok,{questionnaire:{reference:e+"/"+t},onSubmit:()=>alert("You submitted the preview")})]}):null}function Bq(){const e=ne(),{resourceType:t,id:n}=Xe(),[r,o]=p.useState(),[i,s]=p.useState();return p.useEffect(()=>{e.readResource(t,n).then(l=>o(co(l))).catch(l=>{fe({color:"red",message:Te(l)})})},[e,t,n]),r?a.jsxs(Se,{children:[a.jsxs(ue,{order:2,children:["Available ",t," profiles"]}),a.jsx(be,{children:a.jsxs(a.Fragment,{children:[a.jsx(Kk,{resource:r,currentProfile:i,onChange:s}),i?a.jsx(Uq,{profile:i,resource:r,onResourceUpdated:l=>o(l)},i.url):a.jsx(se,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})})]}):null}const Uq=({profile:e,resource:t,onResourceUpdated:n})=>{const r=ne(),[o,i]=p.useState(),[s,l]=p.useState(()=>{var u,d;return(d=(u=t.meta)==null?void 0:u.profile)==null?void 0:d.includes(e.url)}),c=p.useCallback(u=>{i(void 0);const d=Ts(u);s?Gk(d,e.url):Rq(d,e.url),r.updateResource(d).then(f=>{n(f),fe({color:"green",message:"Success"})}).catch(f=>{i(lt(f)),fe({color:"red",message:Te(f),autoClose:!1})})},[r,e.url,n,s]);return a.jsxs(be,{children:[a.jsx(Ac,{size:"md",checked:s,label:`Conform resource to ${e.title}`,onChange:u=>l(u.currentTarget.checked),"data-testid":"profile-toggle"}),s?a.jsx(zd,{profileUrl:e.url,defaultValue:t,onSubmit:c,outcome:o}):a.jsx("form",{noValidate:!0,onSubmit:u=>{u.preventDefault(),c(t)},children:a.jsx(Y,{justify:"flex-end",mt:"xl",children:a.jsx(te,{type:"submit",children:"OK"})})})]})};function Vq(){const e=ne(),{id:t}=Xe(),[n,r]=p.useState(),[o,i]=p.useState(0),s=e.searchResources("Subscription","status=active&_count=100").read().filter(c=>Wq(c,t));function l(){n&&e.createResource({resourceType:"Subscription",status:"active",reason:`Connect bot ${n.name} to questionnaire responses`,criteria:"QuestionnaireResponse?questionnaire=Questionnaire/"+t,channel:{type:"rest-hook",endpoint:ht(n)}}).then(()=>{r(void 0),i(Date.now()),e.invalidateSearches("Subscription"),fe({color:"green",message:"Success"})}).catch(c=>fe({color:"red",message:Te(c),autoClose:!1}))}return a.jsxs(Se,{children:[a.jsx(ue,{children:"Bots"}),s.length===0&&a.jsx("p",{children:"No bots found."}),s.map(c=>{var u;return a.jsxs("div",{children:[a.jsx("h3",{children:a.jsx(Ya,{value:{reference:(u=c.channel)==null?void 0:u.endpoint},link:!0})}),a.jsxs("p",{children:["Criteria: ",c.criteria]})]},c.id)}),a.jsx("hr",{}),a.jsx(ue,{children:"Connect to bot"}),a.jsxs(Y,{children:[a.jsx(Qa,{name:"bot",resourceType:"Bot",onChange:c=>r(c)}),a.jsx(te,{onClick:l,children:"Connect"})]}),a.jsx("div",{style:{display:"none"},children:o})]})}function Wq(e,t){var o;const n=e.criteria||"",r=((o=e.channel)==null?void 0:o.endpoint)||"";return n.startsWith("QuestionnaireResponse?")&&n.includes(t)&&r.startsWith("Bot/")}function Hq(){const{id:e}=Xe(),t=Mt(),[n,r]=p.useState({resourceType:"QuestionnaireResponse",filters:[{code:"questionnaire",operator:ie.EQUALS,value:"Questionnaire/"+e}],fields:["id","_lastUpdated"]});return a.jsx(Se,{children:a.jsx(Kc,{search:n,onClick:o=>t(`/${o.resource.resourceType}/${o.resource.id}`),onChange:o=>r(o.definition),hideFilters:!0,hideToolbar:!0})})}function qq(){const e=ne(),{resourceType:t,id:n}=Xe(),r=ct({reference:t+"/"+n}),o=p.useCallback(i=>{e.updateResource(Ts(i)).then(()=>{fe({color:"green",message:"Success"})}).catch(s=>{fe({color:"red",message:Te(s),autoClose:!1})})},[e]);return r?a.jsx(Se,{children:a.jsx(mU,{onSubmit:o,definition:r})}):null}function Gq(){const{resourceType:e,id:t}=Xe(),n=ct({reference:e+"/"+t});return n?a.jsx(Se,{children:e==="MeasureReport"?a.jsx(uB,{measureReport:n}):a.jsx(n0,{value:n})}):null}const Qq="_container_1ue98_1",Kq="_entry_1ue98_14",Yq="_active_1ue98_21",gp={container:Qq,entry:Kq,active:Yq};function Xq(e){const t=ne(),n=ct(e.value),[r,o]=p.useState();return p.useEffect(()=>{if(!n)return;const i=C0(n);if(!i)return;const s="reference"in i?i.reference:ht(i);t.search("ServiceRequest","subject="+s).then(l=>{const u=l.entry.map(d=>d.resource);OT(u),u.reverse(),o(u)}).catch(l=>fe({color:"red",message:Te(l),autoClose:!1}))},[t,n]),r?a.jsx("div",{"data-testid":"quick-service-requests",className:gp.container,children:r.map(i=>{var s,l,c,u,d,f,h;return a.jsxs("div",{className:et(gp.entry,{[gp.active]:i.id===(n==null?void 0:n.id)}),children:[a.jsx("p",{children:a.jsx(Fe,{to:i,children:Jq(i)})}),((l=(s=i.category)==null?void 0:s[0])==null?void 0:l.text)&&a.jsx("p",{children:(c=i.category[0])==null?void 0:c.text}),((f=(d=(u=i.code)==null?void 0:u.coding)==null?void 0:d[0])==null?void 0:f.code)&&a.jsx("p",{children:(h=i.code.coding[0])==null?void 0:h.code}),a.jsx("p",{children:Zq(i)})]},i.id)})}):null}function Jq(e){if(e.identifier){for(const t of e.identifier)if(t.value)return t.value}return e.id||""}function Zq(e){var t;return e.authoredOn?e.authoredOn.substring(0,10):(t=e.meta)!=null&&t.lastUpdated?e.meta.lastUpdated.substring(0,10):""}const eG="_container_1l2dh_1",tG={container:eG};function nG(e){var o,i,s,l;const t=ct(e.valueSet);if(!t)return null;const n=[""],r=(l=(s=(i=(o=t.compose)==null?void 0:o.include)==null?void 0:i[0])==null?void 0:s.concept)==null?void 0:l.map(c=>c.code);return r&&n.push(...r),e.defaultValue&&!n.includes(e.defaultValue)&&n.push(e.defaultValue),a.jsx("div",{className:tG.container,children:a.jsx(wt,{defaultValue:e.defaultValue,onChange:c=>e.onChange(c.currentTarget.value),data:n})})}function rG(e){var n,r;const t=ct(e.specimen);return t?a.jsxs(Ie,{children:[a.jsxs(Ie.Entry,{children:[a.jsx(Ie.Key,{children:"Type"}),a.jsx(Ie.Value,{children:"Specimen"})]}),a.jsxs(Ie.Entry,{children:[a.jsx(Ie.Key,{children:"Collected"}),a.jsx(Ie.Value,{children:jn((n=t.collection)==null?void 0:n.collectedDateTime)})]}),a.jsxs(Ie.Entry,{children:[a.jsx(Ie.Key,{children:"Specimen Age"}),a.jsx(Ie.Value,{children:oG(t)})]}),(r=t.collection)!=null&&r.collectedDateTime&&t.receivedTime?a.jsxs(Ie.Entry,{children:[a.jsx(Ie.Key,{children:"Specimen Stability"}),a.jsx(Ie.Value,{children:iG(t)})]}):a.jsx(a.Fragment,{})]}):null}function oG(e){var o;const t=(o=e.collection)==null?void 0:o.collectedDateTime;if(!t)return;const n=new Date(t);return Yk(Xk(n,new Date))}function iG(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(Xk(t,n))}function Yk(e){return e.toString().padStart(3,"0")+"D"}function Xk(e,t){const n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function sG(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"),t}const aG=["Profiles"];function lG(){var w,b,j,E,P,T,D;const e=ne(),{resourceType:t,id:n}=Xe(),r={reference:t+"/"+n},o=Mt(),[i,s]=p.useState(),l=ct(r,s),c=sG(t),[u,d]=p.useState(()=>{const _=window.location.pathname.split("/").pop();return _&&c.map(O=>O.toLowerCase()).includes(_)?_:c[0].toLowerCase()}),f=kt();async function h(){var I,$;const O=($=(I=(await e.readHistory(t,n)).entry)==null?void 0:I.find(N=>!!N.resource))==null?void 0:$.resource;O?m(O):fe({color:"red",message:"No history to restore",autoClose:!1})}function m(_){e.updateResource(Ts(_)).then(()=>{s(void 0),fe({color:"green",message:"Success"})}).catch(O=>{fe({color:"red",message:Te(O),autoClose:!1})})}if(i)return eM(i)?a.jsxs(Se,{children:[a.jsx(ue,{children:"Deleted"}),a.jsx("p",{children:"The resource was deleted."}),a.jsx(te,{color:"red",onClick:h,children:"Restore"})]}):a.jsx(Wr,{outcome:i});function g(_){_||(_=c[0].toLowerCase()),d(_),o(`/${t}/${n}/${_}`)}function y(_){const O=l,I=O.orderDetail||[];I.length===0&&I.push({}),I[0].text!==_&&(I[0].text=_,m({...O,orderDetail:I}))}const S=l&&C0(l),v=l&&AH(l),x=(j=(b=(w=e.getUserConfiguration())==null?void 0:w.option)==null?void 0:b.find(_=>_.id==="statusValueSet"))==null?void 0:j.valueString;return a.jsxs(a.Fragment,{children:[(l==null?void 0:l.resourceType)==="ServiceRequest"&&x&&a.jsx(nG,{valueSet:{reference:x},defaultValue:(P=(E=l.orderDetail)==null?void 0:E[0])==null?void 0:P.text,onChange:y},ht(l)+"-"+((D=(T=l.orderDetail)==null?void 0:T[0])==null?void 0:D.text)),l&&a.jsx(Xq,{value:l}),l&&a.jsxs(zn,{children:[S&&a.jsx(Vk,{patient:S}),v&&a.jsx(rG,{specimen:v}),t!=="Patient"&&a.jsx(Wk,{resource:r}),a.jsx(vr,{children:a.jsx(Ge,{value:u.toLowerCase(),onChange:g,children:a.jsx(Ge.List,{style:{whiteSpace:"nowrap",flexWrap:"nowrap"},children:c.map(_=>a.jsx(Ge.Tab,{value:_.toLowerCase(),children:aG.includes(_)?a.jsxs(Y,{gap:"xs",wrap:"nowrap",children:[_,a.jsx(kc,{color:f.primaryColor,size:"sm",children:"Beta"})]}):_},_))})})})]}),a.jsx(v0,{})]})}function cS(){var v,x,w,b;const e=Mt(),{resourceType:t,id:n,versionId:r,tab:o}=Xe(),i=ne(),[s,l]=p.useState(!0),[c,u]=p.useState(),[d,f]=p.useState();if(p.useEffect(()=>{f(void 0),l(!0),i.readHistory(t,n).then(j=>u(j)).then(()=>l(!1)).catch(j=>{f(j),l(!1)})},[i,t,n]),s)return a.jsx($r,{});if(!c)return a.jsxs(Se,{children:[a.jsx(ue,{children:"Resource not found"}),a.jsx(Fe,{to:`/${t}`,children:"Return to search page"})]});const h=c.entry,m=h.findIndex(j=>{var E,P;return((P=(E=j.resource)==null?void 0:E.meta)==null?void 0:P.versionId)===r});if(m===-1)return a.jsxs(Se,{children:[a.jsx(ue,{children:"Version not found"}),a.jsx(Fe,{to:`/${t}/${n}`,children:"Return to resource"})]});const g=h[m].resource,y=m<h.length-1?h[m+1].resource:void 0,S="diff";return a.jsx(a.Fragment,{children:a.jsxs(Ge,{value:o||S,onChange:j=>e(`/${t}/${n}/_history/${r}/${j||S}`),children:[a.jsxs(zn,{children:[a.jsx(qc,{fluid:!0,p:"md",children:a.jsx(se,{children:`${t} ${n}`})}),a.jsxs(Ge.List,{children:[a.jsx(Ge.Tab,{value:"diff",children:"Diff"}),a.jsx(Ge.Tab,{value:"raw",children:"Raw"})]})]}),a.jsxs(Se,{children:[d&&a.jsx("pre",{"data-testid":"error",children:JSON.stringify(d,void 0,2)}),a.jsx(Ge.Panel,{value:"diff",children:y?a.jsxs(a.Fragment,{children:[a.jsxs("ul",{children:[a.jsxs("li",{children:["Current: ",(v=g.meta)==null?void 0:v.versionId]}),a.jsxs("li",{children:["Previous:"," ",a.jsx(Fe,{to:`/${t}/${n}/_history/${(x=y.meta)==null?void 0:x.versionId}`,children:(w=y.meta)==null?void 0:w.versionId})]})]}),a.jsx(WU,{original:y,revised:g})]}):a.jsxs(a.Fragment,{children:[a.jsxs("ul",{children:[a.jsxs("li",{children:["Current: ",(b=g.meta)==null?void 0:b.versionId]}),a.jsx("li",{children:"Previous: (none)"})]}),a.jsx("pre",{children:JSON.stringify(g,void 0,2)})]})}),a.jsx(Ge.Panel,{value:"raw",children:a.jsx("pre",{children:JSON.stringify(g,void 0,2)})})]})]})})}function cG(){const{resourceType:e,id:t}=Xe(),n=Mt(),[r,o]=p.useState({resourceType:"Subscription",filters:[{code:"url",operator:ie.EQUALS,value:`${e}/${t}`}],fields:["id","criteria","status","_lastUpdated"]});return a.jsx(Se,{children:a.jsx(Kc,{search:r,onClick:i=>n(`/${i.resource.resourceType}/${i.resource.id}`),onChange:i=>o(i.definition),hideFilters:!0})})}function uS(){const{resourceType:e,id:t}=Xe(),n={reference:e+"/"+t};switch(e){case"Encounter":return a.jsx(az,{encounter:n});case"Patient":return a.jsx(dB,{patient:n});case"ServiceRequest":return a.jsx(KU,{serviceRequest:n});default:return a.jsx(sz,{resource:n})}}function uG(){const e=ne(),{id:t}=Xe(),n=p.useMemo(()=>({reference:"Agent/"+t}),[t]),[r,o]=p.useState(!1),[i,s]=p.useState(),[l,c]=p.useState(),[u,d]=p.useState(),[f,h]=p.useState(!1),m=p.useCallback(()=>{o(!0),e.get(e.fhirUrl("Agent",t,"$status"),{cache:"reload"}).then(S=>{var v,x,w,b;s((x=(v=S.parameter)==null?void 0:v.find(j=>j.name==="status"))==null?void 0:x.valueCode),c((b=(w=S.parameter)==null?void 0:w.find(j=>j.name==="lastUpdated"))==null?void 0:b.valueInstant)}).catch(S=>y(Te(S))).finally(()=>o(!1))},[e,t]),g=p.useCallback(S=>{const v=S.ip;v&&(h(!0),e.pushToAgent(n,v,"PING",Gt.PING,!0).then(x=>d(x)).catch(x=>y(Te(x))).finally(()=>h(!1)))},[e,n]);function y(S){fe({color:"red",title:"Error",message:S,autoClose:!1})}return a.jsxs(Se,{children:[a.jsx(ue,{order:1,children:"Agent Tools"}),a.jsxs("div",{style:{marginBottom:10},children:["Agent: ",a.jsx(Ya,{value:n,link:!0})]}),a.jsx(fn,{my:"lg"}),a.jsx(ue,{order:2,children:"Agent Status"}),a.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."}),a.jsx(te,{onClick:m,loading:r,children:"Get Status"}),!r&&i&&a.jsx(le,{children:a.jsxs(le.Tbody,{children:[a.jsxs(le.Tr,{children:[a.jsx(le.Td,{children:"Status"}),a.jsx(le.Td,{children:a.jsx(t0,{status:i})})]}),a.jsxs(le.Tr,{children:[a.jsx(le.Td,{children:"Last Updated"}),a.jsx(le.Td,{children:jn(l)})]})]})}),a.jsx(fn,{my:"lg"}),a.jsx(ue,{order:2,children:"Ping from Agent"}),a.jsx("p",{children:"Send a ping command from the agent to an IP address. Use this tool to troubleshoot local network connectivity."}),a.jsx(We,{onSubmit:g,children:a.jsx(ae,{id:"ip",name:"ip",placeholder:"IP Address",rightSection:a.jsx(qt,{size:24,radius:"xl",variant:"filled",type:"submit","aria-label":"Ping",loading:f,children:a.jsx(p6,{style:{width:"1rem",height:"1rem"},stroke:1.5})})})}),!f&&u&&a.jsxs(a.Fragment,{children:[a.jsx(ue,{order:5,mt:"sm",mb:0,children:"Last Ping"}),a.jsx("pre",{children:u})]})]})}function dG(){return a.jsx(hW,{children:a.jsxs(he,{errorElement:a.jsx(TH,{}),children:[a.jsx(he,{path:"/signin",element:a.jsx(XH,{})}),a.jsx(he,{path:"/oauth",element:a.jsx(qH,{})}),a.jsx(he,{path:"/resetpassword",element:a.jsx(QH,{})}),a.jsx(he,{path:"/setpassword/:id/:secret",element:a.jsx(YH,{})}),a.jsx(he,{path:"/register",element:a.jsx(GH,{})}),a.jsx(he,{path:"/changepassword",element:a.jsx(EH,{})}),a.jsx(he,{path:"/security",element:a.jsx(KH,{})}),a.jsx(he,{path:"/mfa",element:a.jsx(HH,{})}),a.jsx(he,{path:"/batch",element:a.jsx(bH,{})}),a.jsx(he,{path:"/bulk/:resourceType",element:a.jsx(CH,{})}),a.jsx(he,{path:"/smart",element:a.jsx(JH,{})}),a.jsx(he,{path:"/forms/:id",element:a.jsx(OH,{})}),a.jsx(he,{path:"/admin/super",element:a.jsx(dq,{})}),a.jsx(he,{path:"/admin/config",element:a.jsx(aq,{})}),a.jsxs(he,{path:"/admin",element:a.jsx(lq,{}),children:[a.jsx(he,{path:"patients",element:a.jsx(sq,{})}),a.jsx(he,{path:"bots/new",element:a.jsx(tq,{})}),a.jsx(he,{path:"bots",element:a.jsx(ZH,{})}),a.jsx(he,{path:"clients/new",element:a.jsx(nq,{})}),a.jsx(he,{path:"clients",element:a.jsx(eq,{})}),a.jsx(he,{path:"details",element:a.jsx(iS,{})}),a.jsx(he,{path:"invite",element:a.jsx(iq,{})}),a.jsx(he,{path:"users",element:a.jsx(fq,{})}),a.jsx(he,{path:"project",element:a.jsx(iS,{})}),a.jsx(he,{path:"secrets",element:a.jsx(cq,{})}),a.jsx(he,{path:"sites",element:a.jsx(uq,{})}),a.jsx(he,{path:"members/:membershipId",element:a.jsx(oq,{})})]}),a.jsx(he,{path:"/lab/assays",element:a.jsx(hq,{})}),a.jsx(he,{path:"/lab/panels",element:a.jsx(pq,{})}),a.jsx(he,{path:"/:resourceType/:id/_history/:versionId/:tab",element:a.jsx(cS,{})}),a.jsx(he,{path:"/:resourceType/:id/_history/:versionId",element:a.jsx(cS,{})}),a.jsxs(he,{path:"/:resourceType/new",element:a.jsx(PH,{}),children:[a.jsx(he,{index:!0,element:a.jsx(mp,{})}),a.jsx(he,{path:"form",element:a.jsx(mp,{})}),a.jsx(he,{path:"json",element:a.jsx($q,{})}),a.jsx(he,{path:"profiles",element:a.jsx(mp,{})})]}),a.jsxs(he,{path:"/:resourceType/:id",element:a.jsx(lG,{}),children:[a.jsx(he,{index:!0,element:a.jsx(uS,{})}),a.jsx(he,{path:"apply",element:a.jsx(gq,{})}),a.jsx(he,{path:"apps",element:a.jsx(yq,{})}),a.jsx(he,{path:"event",element:a.jsx(xq,{})}),a.jsx(he,{path:"blame",element:a.jsx(wq,{})}),a.jsx(he,{path:"bots",element:a.jsx(Vq,{})}),a.jsx(he,{path:"builder",element:a.jsx(Dq,{})}),a.jsx(he,{path:"checklist",element:a.jsx(Iq,{})}),a.jsx(he,{path:"delete",element:a.jsx(_q,{})}),a.jsx(he,{path:"details",element:a.jsx(Oq,{})}),a.jsx(he,{path:"edit",element:a.jsx(Mq,{})}),a.jsx(he,{path:"editor",element:a.jsx(Tq,{})}),a.jsx(he,{path:"history",element:a.jsx(Lq,{})}),a.jsx(he,{path:"json",element:a.jsx(Fq,{})}),a.jsx(he,{path:"preview",element:a.jsx(zq,{})}),a.jsx(he,{path:"responses",element:a.jsx(Hq,{})}),a.jsx(he,{path:"report",element:a.jsx(Gq,{})}),a.jsx(he,{path:"ranges",element:a.jsx(qq,{})}),a.jsx(he,{path:"subscriptions",element:a.jsx(cG,{})}),a.jsx(he,{path:"timeline",element:a.jsx(uS,{})}),a.jsx(he,{path:"tools",element:a.jsx(uG,{})}),a.jsx(he,{path:"profiles",element:a.jsx(Bq,{})})]}),a.jsx(he,{path:"/:resourceType",element:a.jsx(oS,{})}),a.jsx(he,{path:"/",element:a.jsx(oS,{})})]})})}function fG(){const e=ne(),t=e.getUserConfiguration(),n=Wo(),[r]=x0();return e.isLoading()?a.jsx($r,{}):a.jsx(dF,{logo:a.jsx(Vr,{size:24}),pathname:n.pathname,searchParams:r,version:l7,menus:hG(t),displayAddBookmark:!!(t!=null&&t.id),children:a.jsx(p.Suspense,{fallback:a.jsx($r,{}),children:a.jsx(dG,{})})})}function hG(e){var n;const t=((n=e==null?void 0:e.menu)==null?void 0:n.map(r=>{var o;return{title:r.title,links:((o=r.link)==null?void 0:o.map(i=>({label:i.name,href:i.target,icon:pG(i.target)})))||[]}}))||[];return t.push({title:"Settings",links:[{label:"Security",href:"/security",icon:a.jsx(n6,{})}]}),t}const dS={Patient:y6,Practitioner:Z7,Organization:V7,ServiceRequest:d6,DiagnosticReport:h6,Questionnaire:J7,admin:z7,AccessPolicy:t6,Subscription:w6,batch:s6,Observation:i6};function pG(e){try{const t=new URL(e,"https://app.medplum.com").pathname.split("/")[1];if(t in dS){const n=dS[t];return a.jsx(n,{})}}catch{}return a.jsx(Uf,{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 mG(){const e=Zc(),t=new BP({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=yW([{path:"*",element:a.jsx(fG,{})}]),o=s=>r.navigate(s);pk(document.getElementById("root")).render(a.jsx(p.StrictMode,{children:a.jsx(P7,{medplum:t,navigate:o,children:a.jsxs(qS,{theme:n,children:[a.jsx(Bo,{position:"bottom-right"}),a.jsx(PW,{router:r})]})})}))}mG().catch(console.error);
555
- //# sourceMappingURL=index-BO3wit9F.js.map
555
+ //# sourceMappingURL=index-CCNbdJIG.js.map