var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports);(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var t=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function ee(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var te=ee.prototype=new b;te.constructor=ee,_(te,y.prototype),te.isPureReactComponent=!0;var ne=Array.isArray;function re(){}var x={H:null,A:null,T:null,S:null},ie=Object.prototype.hasOwnProperty;function S(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ae(e,t){return S(e.type,t,e.props)}function C(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function oe(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var se=/\/+/g;function ce(e,t){return typeof e==`object`&&e&&e.key!=null?oe(``+e.key):t.toString(36)}function w(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(re,re):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function le(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,le(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ce(e,0):a,ne(o)?(i=``,c!=null&&(i=c.replace(se,`$&/`)+`/`),le(o,r,i,``,function(e){return e})):o!=null&&(C(o)&&(o=ae(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(se,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ne(e))for(var u=0;u{n.exports=t()})),r=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function ee(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,te||(te=!0,ae());else{var t=n(l);t!==null&&se(ee,t.startTime-e)}}}var te=!1,ne=-1,re=5,x=-1;function ie(){return g?!0:!(e.unstable_now()-xt&&ie());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(ee,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ae():te=!1}}}var ae;if(typeof y==`function`)ae=function(){y(S)};else if(typeof MessageChannel<`u`){var C=new MessageChannel,oe=C.port2;C.port1.onmessage=S,ae=function(){oe.postMessage(null)}}else ae=function(){_(S,0)};function se(t,n){ne=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(ne),ne=-1):h=!0,se(ee,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,te||(te=!0,ae()))),r},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),i=e(((e,t)=>{t.exports=r()})),a=e((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=a()})),s=e((e=>{var t=i(),r=n(),a=o();function s(e){var t=`https://react.dev/errors/`+e;if(1Se||(e.current=xe[Se],xe[Se]=null,Se--)}function P(e,t){Se++,xe[Se]=e.current,e.current=t}var we=Ce(null),Te=Ce(null),Ee=Ce(null),De=Ce(null);function Oe(e,t){switch(P(Ee,t),P(Te,e),P(we,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}N(we),P(we,e)}function ke(){N(we),N(Te),N(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,P(De,e)),t=we.current;var n=dp(t,e.type);t!==n&&(P(Te,e),P(we,n))}function je(e){Te.current===e&&(N(we),N(Te)),De.current===e&&(N(De),sh._currentValue=be)}var F,Me;function I(e){if(F===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||``,Me=-1)`:-1i||c[r]!==l[i]){var u=` `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ne=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?I(n):``}function Fe(e,t){switch(e.tag){case 26:case 27:case 5:return I(e.type);case 16:return I(`Lazy`);case 13:return e.child!==t&&t!==null?I(`Suspense Fallback`):I(`Suspense`);case 19:return I(`SuspenseList`);case 0:case 15:return Pe(e.type,!1);case 11:return Pe(e.type.render,!1);case 1:return Pe(e.type,!0);case 31:return I(`Activity`);case 30:return I(`ViewTransition`);default:return``}}function L(e){try{var t=``,n=null;do t+=Fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var R=Object.prototype.hasOwnProperty,Ie=t.unstable_scheduleCallback,Le=t.unstable_cancelCallback,Re=t.unstable_shouldYield,ze=t.unstable_requestPaint,Be=t.unstable_now,Ve=t.unstable_getCurrentPriorityLevel,He=t.unstable_ImmediatePriority,Ue=t.unstable_UserBlockingPriority,We=t.unstable_NormalPriority,Ge=t.unstable_LowPriority,Ke=t.unstable_IdlePriority,qe=t.log,Je=t.unstable_setDisableYieldValue,Ye=null,Xe=null;function Ze(e){if(typeof qe==`function`&&Je(e),Xe&&typeof Xe.setStrictMode==`function`)try{Xe.setStrictMode(Ye,e)}catch{}}var Qe=Math.clz32?Math.clz32:tt,$e=Math.log,et=Math.LN2;function tt(e){return e>>>=0,e===0?32:31-($e(e)/et|0)|0}var nt=256,rt=262144,it=4194304;function at(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ot(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=at(n))):i=at(o):i=at(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=at(n))):i=at(o)):i=at(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function st(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ct(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function ft(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function pt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=fr),hr=` `,gr=!1;function _r(e,t){switch(e){case`keyup`:return ur.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function vr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var yr=!1;function br(e,t){switch(e){case`compositionend`:return vr(t);case`keypress`:return t.which===32?(gr=!0,hr):null;case`textInput`:return e=t.data,e===hr&&gr?null:e;default:return null}}function xr(e,t){if(yr)return e===`compositionend`||!dr&&_r(e,t)?(e=Nn(),Mn=jn=An=null,yr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Wr(n)}}function Kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ur(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ur(e.document)}return t}function Jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Yr=Dn&&`documentMode`in document&&11>=document.documentMode,Xr=null,Zr=null,Qr=null,$r=!1;function ei(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$r||Xr==null||Xr!==Ur(r)||(r=Xr,`selectionStart`in r&&Jr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Qr&&Hr(Qr,r)||(Qr=r,r=Jf(Zr,`onSelect`),0>=o,i-=o,Xi=1<<32-Qe(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),V&&Qi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),o=a(y,o,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),V&&Qi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return V&&Qi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),o=a(v,o,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),V&&Qi(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===se&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case C:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===se){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),so(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===me&&eo(l)===r.type){n(e,r.sibling),c=i(r,a.props),so(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===se?(c=Li(a.props.children,e.mode,c,a.key),so(c,a),c.return=e,e=c):(c=Ii(a.type,a.key,a.props,null,e.mode,c),so(c,a),c.return=e,e=c)}return o(e);case oe:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Bi(a,e.mode,c),c.return=e,e=c}return o(e);case me:return a=eo(a),_(e,r,a,c)}if(A(a))return h(e,r,a,c);if(k(a)){if(l=k(a),typeof l!=`function`)throw Error(s(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,oo(a),c);if(a.$$typeof===ue)return _(e,r,Ta(e,a),c);co(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Ri(a,e.mode,c),c.return=e,e=c),o(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ja||t===Xa)throw t;var a=Mi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,K&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ki(e),Oi(e,null,n),t}return Ti(e,r,t,n),ki(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ht(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=za;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Y&f)===f:(r&f)===f){f!==0&&f===Ra&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=S({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),od|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(s(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=j.T,s={};s.types=o===null?null:o.types,j.T=s,uc(e,!1,t,n);try{var c=i(),l=j.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?lc(e,t,Ha(c,r),jd(e)):lc(e,t,r,jd(e))}catch(n){lc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{M.p=a,o!==null&&s.types!==null&&(o.types=s.types),j.T=o}}function $s(){}function ec(e,t,n,r){if(e.tag!==5)throw Error(s(476));var i=tc(e).queue;Qs(e,i,t,be,n===null?$s:function(){return nc(e),n(r)})}function tc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:be,baseState:be,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ds,lastRenderedState:be},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ds,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function nc(e){var t=tc(e);t.next===null&&(t=e.alternate.memoizedState),lc(e,t.next.queue,{},jd())}function rc(){return wa(sh)}function ic(){return os().memoizedState}function ac(){return os().memoizedState}function oc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=go(n);var r=_o(t,e,n);r!==null&&(Pd(r,t,n),vo(r,t,n)),t={cache:ja()},e.payload=t;return}t=t.return}}function sc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},dc(e)?fc(t,n):(n=Ei(e,t,n,r),n!==null&&(Pd(n,e,r),pc(n,t,r)))}function cc(e,t,n){lc(e,t,n,jd())}function lc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(dc(e))fc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Vr(s,o))return Ti(e,t,i,0),q===null&&wi(),!1}catch{}if(n=Ei(e,t,i,r),n!==null)return Pd(n,e,r),pc(n,t,r),!0}return!1}function uc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},dc(e)){if(t)throw Error(s(479))}else t=Ei(e,n,r,2),t!==null&&Pd(t,e,2)}function dc(e){var t=e.alternate;return e===H||t!==null&&t===H}function fc(e,t){Wo=Uo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function pc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ht(e,n)}}var mc={readContext:wa,use:ls,useCallback:Xo,useContext:Xo,useEffect:Xo,useImperativeHandle:Xo,useLayoutEffect:Xo,useInsertionEffect:Xo,useMemo:Xo,useReducer:Xo,useRef:Xo,useState:Xo,useDebugValue:Xo,useDeferredValue:Xo,useTransition:Xo,useSyncExternalStore:Xo,useId:Xo,useHostTransitionStatus:Xo,useFormState:Xo,useActionState:Xo,useOptimistic:Xo,useMemoCache:Xo,useCacheRefresh:Xo,useEffectEvent:Xo},hc={readContext:wa,use:ls,useCallback:function(e,t){return as().memoizedState=[e,t===void 0?null:t],e},useContext:wa,useEffect:zs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ls(4194308,4,Gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ls(4194308,4,e,t)},useInsertionEffect:function(e,t){Ls(4,2,e,t)},useMemo:function(e,t){var n=as();t=t===void 0?null:t;var r=e();if(Go){Ze(!0);try{e()}finally{Ze(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=as();if(n!==void 0){var i=n(t);if(Go){Ze(!0);try{n(t)}finally{Ze(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=sc.bind(null,H,e),[r.memoizedState,e]},useRef:function(e){var t=as();return e={current:e},t.memoizedState=e},useState:function(e){e=xs(e);var t=e.queue,n=cc.bind(null,H,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:qs,useDeferredValue:function(e,t){return Xs(as(),e,t)},useTransition:function(){var e=xs(!1);return e=Qs.bind(null,H,e.queue,!0,!1),as().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=H,i=as();if(V){if(n===void 0)throw Error(s(407));n=n()}else{if(n=t(),q===null)throw Error(s(349));Y&127||gs(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,zs(vs.bind(null,r,a,e),[e]),r.flags|=2048,Fs(9,{destroy:void 0},_s.bind(null,r,a,n,t),null),n},useId:function(){var e=as(),t=q.identifierPrefix;if(V){var n=Zi,r=Xi;n=(r&~(1<<32-Qe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ko++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?o.createElement(`select`,{is:r.is}):o.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?o.createElement(i,{is:r.is}):o.createElement(i)}}a[St]=t,a[Ct]=r;a:for(o=t.child;o!==null;){if(o.tag===5||o.tag===6)a.appendChild(o.stateNode);else if(o.tag!==4&&o.tag!==27&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break a;for(;o.sibling===null;){if(o.return===null||o.return===t)break a;o=o.return}o.sibling.return=o.return,o=o.sibling}t.stateNode=a;a:switch(np(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&pl(t)}}return W(t),t.subtreeFlags&=-33554433,ml(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&pl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(s(166));if(e=Ee.current,ua(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ra,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[St]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||sa(t,!0)}else e=lp(e).createTextNode(r),e[St]=t,t.stateNode=e}return W(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ua(t),n!==null){if(e===null){if(!r)throw Error(s(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(s(557));e[St]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),e=!1}else n=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(s(558))}return W(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ua(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(s(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(s(317));i[St]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),i=!1}else i=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),gl(t,t.updateQueue),W(t),null);case 4:return ke(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,W(t),null;case 10:return va(t.type),W(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return W(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)_l(r,!1);else{if(ad!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Bo(e),a!==null){for(t.flags|=128,_l(r,!1),e=a.updateQueue,t.updateQueue=e,gl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Fi(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),V&&Qi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Be()>gd&&(t.flags|=128,i=!0,_l(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Bo(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,gl(t,e),_l(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!V)return W(t),null}else 2*Be()-r.renderingStartTime>gd&&n!==536870912&&(t.flags|=128,i=!0,_l(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Be(),e.sibling=null,a=Lo.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||V?Ro(t,a):(n=a,P(Ao,t),P(Lo,n),jo===null&&(jo=t)),V&&Qi(t,r.treeForkCount),e}return W(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(W(t),t.subtreeFlags&6&&(t.flags|=8192)):W(t),n=t.updateQueue,n!==null&&gl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&N(Wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),va(Aa),W(t),null;case 25:return null;case 30:return t.flags|=33554432,W(t),null}throw Error(s(156,t.tag))}function yl(e,t){switch(ta(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return va(Aa),ke(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return je(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(s(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ke(),null;case 10:return va(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&N(Wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return va(Aa),null;case 25:return null;default:return null}}function bl(e,t){switch(ta(t),t.tag){case 3:va(Aa),ke();break;case 26:case 27:case 5:je(t);break;case 4:ke();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:va(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&N(Wa);break;case 24:va(Aa)}}function xl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Sl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function Cl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){Z(e,e.return,t)}}}function wl(e,t,n){n.props=Sc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Tl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=_i(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);h(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function El(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Dl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[St]=e,It(r),t=r;break a;case`link`:if(a=Gm(`link`,`href`,i).get(t+(n.href||``))){for(o=0;og&&(o=g,g=h,h=o);var _=Gr(s,h),v=Gr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,j.T=null,n=wd,wd=null;var a=bd,o=Sd;if(yd=0,xd=bd=null,Sd=0,K&6)throw Error(s(331));var c=K;if(K|=4,Yu(a.current),Vu(a,a.current,o,n),K=c,Df(0,!1),Xe&&typeof Xe.onPostCommitFiberRoot==`function`)try{Xe.onPostCommitFiberRoot(Ye,a)}catch{}return!0}finally{M.p=i,j.T=r,uf(e,t)}}function pf(e,t,n){t=Hi(n,t),t=Oc(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(ft(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(vd===null||!vd.has(r))){e=Hi(n,e),n=kc(2),r=_o(t,n,2),r!==null&&(Ac(n,r,t,e),ft(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new $u;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(rd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,q===e&&(Y&n)===n&&(ad===4||ad===3&&(Y&62914560)===Y&&300>Be()-md?K&2?cd|=n:Vd(e,0):cd|=n,ud===Y&&(ud=0)),Ef(e)}function gf(e,t){t===0&&(t=ut()),e=Di(e,t),e!==null&&(ft(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(s(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Ie(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Qe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Y,a=ot(r,r===q?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||st(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Be(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}yd!==0&&yd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=nn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),It(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+nn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+nn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+nn(n.imageSizes)+`"]`)):i+=`[href="`+nn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=S({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[At]=!0,o.onload=o.onerror=function(){Lt(o)}),It(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+nn(r)+`"][href="`+nn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=S({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),It(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Ft(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=S({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);It(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Ft(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=S({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),It(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Ft(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=S({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),It(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=Ee.current)?bm(i):null;if(!i)throw Error(s(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Ft(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var a=Ft(i).hoistableStyles,o=a.get(e);if(o||(i=i.ownerDocument||i,o={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,o),(a=i.querySelector(Fm(e)))?a._p||(o.instance=a,o.state.loading=5):(a=vm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,a)),Lm(i,e,a,o.state))),t&&r===null)throw Error(s(528,``));return o}if(t&&r!==null)throw Error(s(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Ft(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(s(444,e))}}function Pm(e){return`href="`+nn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[At]){r.loading=1;return}}else t=e.createElement(`link`),t[At]=!0,t.onload=t.onerror=Lt.bind(null,t),np(t,`link`,n),It(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+nn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+nn(n.href)+`"]`);if(r)return t.instance=r,It(r),r;var i=S({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),It(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var a=e.querySelector(Fm(i));if(a)return t.state.loading|=4,t.instance=a,It(a),a;r=Im(n),(i=vm.get(i))&&Hm(r,i),a=(e.ownerDocument||e).createElement(`link`),It(a);var o=a;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),t.state.loading|=4,Vm(a,n.precedence,e),t.instance=a;case`script`:return a=Rm(n.src),(i=e.querySelector(zm(a)))?(t.instance=i,It(i),i):(r=n,(i=vm.get(a))&&(r=S({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),It(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(s(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,It(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),It(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=s()})),l=n(),u=c(),d=/\{[^{}]+\}/g,f=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function p(){return Math.random().toString(36).slice(2,11)}function m(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=f()?c:void 0,t=ne(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:m=r,Request:h=n,headers:g,params:_={},parseAs:re=`json`,querySerializer:x,bodySerializer:ie=a??b,pathSerializer:S,body:ae,middleware:C=[],...oe}=d||{},se=t;f&&(se=ne(f)??t);let ce=typeof i==`function`?i:v(i);x&&(ce=typeof x==`function`?x:v({...typeof i==`object`?i:{},...x}));let w=S||o||y,le=ae===void 0?void 0:ie(ae,te(s,g,_.header)),ue=te(le===void 0||le instanceof FormData?{}:{"Content-Type":`application/json`},s,g,_.header),de=[...u,...C],fe={redirect:`follow`,...l,...oe,body:le,headers:ue},T,pe,me=new h(ee(e,{baseUrl:se,params:_,querySerializer:ce,pathSerializer:w}),fe),E;for(let e in oe)e in me||(me[e]=oe[e]);if(de.length){T=p(),pe=Object.freeze({baseUrl:se,fetch:m,parseAs:re,querySerializer:ce,bodySerializer:ie,pathSerializer:w});for(let t of de)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:me,schemaPath:e,params:_,options:pe,id:T});if(n){if(n instanceof h)me=n;else if(n instanceof Response){E=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}}if(!E){try{E=await m(me,c)}catch(t){let n=t;if(de.length)for(let t=de.length-1;t>=0;t--){let r=de[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:me,error:n,schemaPath:e,params:_,options:pe,id:T});if(t){if(t instanceof Response){n=void 0,E=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(de.length)for(let t=de.length-1;t>=0;t--){let n=de[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:me,response:E,schemaPath:e,params:_,options:pe,id:T});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);E=t}}}}let he=E.headers.get(`Content-Length`);if(E.status===204||me.method===`HEAD`||he===`0`&&!E.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return E.ok?{data:void 0,response:E}:{error:void 0,response:E};if(E.ok)return{data:await(async()=>{if(re===`stream`)return E.body;if(re===`json`&&!he){let e=await E.text();return e?JSON.parse(e):void 0}return await E[re]()})(),response:E};let ge=await E.text();try{ge=JSON.parse(ge)}catch{}return{error:ge,response:E}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function h(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function g(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(h(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function _(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(h(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function v(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(_(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else typeof i==`object`?n.push(g(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1})):n.push(h(r,i,e))}}return n.join(`&`)}}function y(e,t){let n=e;for(let r of e.match(d)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];n=Array.isArray(o)?n.replace(r,_(e,o,{style:a,explode:i})):typeof o==`object`?n.replace(r,g(e,o,{style:a,explode:i})):a===`matrix`?n.replace(r,`;${h(e,o)}`):n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function b(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function ee(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function te(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function ne(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var re=`https://dev.zentiti.ai`,x=`sp.admin.session`,ie=(()=>{try{return JSON.parse(sessionStorage.getItem(x)??`null`)}catch{return null}})(),S=new Set,ae={get:()=>ie,set(e){ie=e;try{e?sessionStorage.setItem(x,JSON.stringify(e)):sessionStorage.removeItem(x)}catch{}S.forEach(e=>e())},subscribe(e){return S.add(e),()=>void S.delete(e)}},C=m({baseUrl:re}),oe=null;async function se(){let e=ie;if(!e)return null;let t=await fetch(`${re}/api/v1/public/auth/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refreshToken:e.refreshToken})}).catch(()=>null);if(!t?.ok)return ae.set(null),null;let n=await t.json();return ae.set({accessToken:n.accessToken,refreshToken:n.refreshToken}),n.accessToken}var ce=new Map;C.use({onRequest({request:e,id:t}){return ie&&e.headers.set(`Authorization`,`Bearer ${ie.accessToken}`),e.headers.set(`X-Platform`,`web-admin`),ce.set(t,e.clone()),e},async onResponse({response:e,id:t}){let n=ce.get(t);if(ce.delete(t),e.status!==401||!n)return e;let r=await e.clone().json().catch(()=>null);if(r?.code!==`TOKEN_EXPIRED`)return r?.code===`UNAUTHENTICATED`&&ie&&ae.set(null),e;oe??=se().finally(()=>oe=null);let i=await oe;if(!i)return e;let a=new Request(n);return a.headers.set(`Authorization`,`Bearer ${i}`),fetch(a)}});async function w(e){let{data:t,error:n,response:r}=await e;if(n!==void 0||!r.ok)throw n??{code:`INTERNAL_ERROR`,status:r.status};return t}var le=()=>crypto.randomUUID();function ue(e){return typeof e==`object`&&!!e&&typeof e.code==`string`}function de(e){return e instanceof TypeError?`Can't reach the Serv Plus API. Check your connection, or that the API is running.`:ue(e)?e.code===`FORBIDDEN`?`Your roles don't allow this action.`:e.errors?.length?e.errors.map(e=>`${e.field}: ${e.message}`).join(` · `):e.detail??e.title??e.code:e instanceof Error?e.message:`Something went wrong.`}async function fe(e,t){let n=new URLSearchParams(Object.entries(t).filter(([,e])=>e)),r=await fetch(`${re}/api/v1/admin/reports/${encodeURIComponent(e)}?${n}`,{headers:{Accept:`text/csv`,Authorization:`Bearer ${ie?.accessToken??``}`}});if(!r.ok)throw await r.json().catch(()=>({code:`INTERNAL_ERROR`,status:r.status}));let i=URL.createObjectURL(await r.blob());Object.assign(document.createElement(`a`),{href:i,download:`${e}_${t.from}_${t.to}.csv`}).click(),URL.revokeObjectURL(i)}var T=(e,...t)=>t.some(t=>e.permissions?.includes(t)),pe,me=e=>void(pe=e),E=()=>pe&&T(pe,`zone.manage`)?w(C.GET(`/api/v1/admin/cities`)):Promise.resolve([]),he=()=>pe&&T(pe,`catalog.manage`)?w(C.GET(`/api/v1/admin/categories`)):Promise.resolve([]),ge=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),D=e(((e,t)=>{t.exports=ge()}))(),_e=`Asia/Kolkata`;function O(e,t=`INR`){return e==null?``:new Intl.NumberFormat(`en-IN`,{style:`currency`,currency:t,minimumFractionDigits:e%100?2:0}).format(e/100)}function k(e){return e?new Intl.DateTimeFormat(`en-IN`,{day:`numeric`,month:`short`,hour:`numeric`,minute:`2-digit`,timeZone:_e}).format(new Date(e)):``}function ve(e){return e?new Intl.DateTimeFormat(`en-IN`,{day:`numeric`,month:`short`,year:`numeric`,timeZone:e.length<=10?`UTC`:_e}).format(new Date(e)):``}function ye(e=0){let t=new Date(Date.now()+e*864e5);return new Intl.DateTimeFormat(`en-CA`,{timeZone:_e}).format(t)}function A(e){if(!e)return``;if(/\s/.test(e))return e;let t=e.toLowerCase().replace(/[_.]/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var j=e=>e?e.slice(0,8):``,M={subscribe:e=>(window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)),get:()=>window.location.hash.replace(/^#\/?/,``)};function be(){return(0,l.useSyncExternalStore)(M.subscribe,M.get).split(`?`)[0].split(`/`).filter(Boolean).map(decodeURIComponent)}var xe=()=>new URLSearchParams(window.location.hash.split(`?`)[1]??``),Se=e=>window.location.hash=`/`+e.replace(/^\//,``),Ce=e=>`#/`+e.replace(/^\//,``);function N(e,t){let[n,r]=(0,l.useState)({loading:!0}),i=(0,l.useRef)(0),a=(0,l.useCallback)(()=>{let t=++i.current;r(e=>({...e,loading:!0})),e().then(e=>t===i.current&&r({data:e,loading:!1}),e=>t===i.current&&r({error:e,loading:!1}))},t);return(0,l.useEffect)(a,[a]),{...n,reload:a}}function P(e,t){let[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(),[o,s]=(0,l.useState)(),[c,u]=(0,l.useState)(!0),d=(0,l.useRef)(0),f=(0,l.useCallback)(t=>{let n=++d.current;u(!0),e(t).then(e=>{n===d.current&&(r(n=>t?[...n??[],...e.items??[]]:e.items??[]),a(e.nextCursor??void 0),s(void 0),u(!1))},e=>n===d.current&&(s(e),u(!1)))},t);return(0,l.useEffect)(()=>f(),[f]),{rows:n,error:o,loading:c,more:i?()=>f(i):void 0,reload:()=>f()}}var we=[],Te=new Set;function Ee(e,t=`ok`){let n={id:Date.now()+Math.random(),text:e,tone:t};we=[...we,n],Te.forEach(e=>e()),setTimeout(()=>{we=we.filter(e=>e!==n),Te.forEach(e=>e())},4500)}function De(){let e=(0,l.useSyncExternalStore)(e=>(Te.add(e),()=>void Te.delete(e)),()=>we);return(0,D.jsx)(`div`,{className:`toasts`,role:`status`,"aria-live":`polite`,children:e.map(e=>(0,D.jsx)(`div`,{className:`toast ${e.tone}`,children:e.text},e.id))})}function Oe(){let[e,t]=(0,l.useState)(!1),[n,r]=(0,l.useState)();return{busy:e,error:n,run:(0,l.useCallback)(async(e,n)=>{t(!0),r(void 0);try{return await e(),n&&Ee(n),!0}catch(e){return r(de(e)),!1}finally{t(!1)}},[]),clear:()=>r(void 0)}}function ke({title:e,sub:t,actions:n,children:r}){return(0,l.useEffect)(()=>void(document.title=`${e} · Serv Plus Ops`),[e]),(0,D.jsxs)(`section`,{className:`page`,children:[(0,D.jsxs)(`header`,{className:`page-head`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h1`,{children:e}),t&&(0,D.jsx)(`p`,{className:`sub`,children:t})]}),n&&(0,D.jsx)(`div`,{className:`actions`,children:n})]}),r]})}function Ae({title:e,aside:t,children:n,flush:r}){return(0,D.jsxs)(`div`,{className:`panel${r?` flush`:``}`,children:[(e||t)&&(0,D.jsxs)(`div`,{className:`panel-head`,children:[(0,D.jsx)(`h2`,{children:e}),t]}),n]})}var je={ACTIVE:`ok`,COMPLETED:`ok`,APPROVED:`ok`,PAID:`ok`,RESOLVED:`ok`,CLOSED:`mute`,PUBLISHED:`ok`,SUCCEEDED:`ok`,CAPTURED:`ok`,ASSIGNED:`info`,EN_ROUTE:`info`,ARRIVED:`info`,IN_PROGRESS:`info`,CONFIRMED:`info`,MATCHING:`info`,PROCESSING:`info`,PENDING:`warn`,OPEN:`warn`,DRAFT:`mute`,PENDING_APPROVAL:`warn`,PROPOSED:`warn`,AWAITING_CUSTOMER:`warn`,SUBMITTED:`warn`,PENDING_VERIFICATION:`warn`,ONBOARDING:`warn`,HIGH:`warn`,UNFULFILLED:`danger`,ESCALATED:`danger`,URGENT:`danger`,FAILED:`danger`,REJECTED:`danger`,SUSPENDED:`danger`,DISABLED:`danger`,CANCELLED:`mute`,INACTIVE:`mute`,EXPIRED:`mute`,RETIRED:`mute`,LOW:`mute`,NORMAL:`mute`};function F({value:e}){return e?(0,D.jsx)(`span`,{className:`status ${je[e]??`mute`}`,children:A(e)}):null}function Me({children:e=`No data`}){return(0,D.jsx)(`div`,{className:`empty`,children:e})}function I({error:e}){return e?(0,D.jsx)(`div`,{className:`error-line`,role:`alert`,children:typeof e==`string`?e:de(e)}):null}function Ne(){return(0,D.jsx)(`div`,{className:`loading`,"aria-busy":`true`,children:`Loading…`})}function Pe({cols:e,rows:t,rowKey:n,onOpen:r,loading:i,error:a,more:o,selected:s}){let c=(0,l.useRef)(null),u=(e,t)=>{let n=e.currentTarget;e.key===`Enter`&&r?r(t):e.key===`j`||e.key===`ArrowDown`?(n.nextElementSibling?.focus(),e.preventDefault()):(e.key===`k`||e.key===`ArrowUp`)&&(n.previousElementSibling?.focus(),e.preventDefault())};return(0,D.jsxs)(`div`,{className:`table-wrap`,children:[(0,D.jsx)(I,{error:a}),(0,D.jsxs)(`table`,{className:`table`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsx)(`tr`,{children:e.map(e=>(0,D.jsx)(`th`,{className:e.num?`num`:void 0,style:e.width?{width:e.width}:void 0,children:e.label},e.key))})}),(0,D.jsx)(`tbody`,{ref:c,children:t?.map(t=>(0,D.jsx)(`tr`,{tabIndex:r?0:void 0,className:`${r?`clickable`:``}${s===n(t)?` selected`:``}`,onClick:r?()=>r(t):void 0,onKeyDown:r?e=>u(e,t):void 0,children:e.map(e=>(0,D.jsx)(`td`,{className:[e.num&&`num`,e.mono&&`mono`].filter(Boolean).join(` `)||void 0,children:e.render(t)},e.key))},n(t)))})]}),!t&&i&&(0,D.jsx)(Ne,{}),t&&t.length===0&&!i&&(0,D.jsx)(Me,{}),o&&(0,D.jsx)(`button`,{className:`btn ghost more`,onClick:o,disabled:i,children:i?`Loading…`:`Load more`})]})}function Fe({title:e,sub:t,onClose:n,children:r,wide:i}){let a=(0,l.useRef)(null),o=(0,l.useRef)(n);return o.current=n,(0,l.useEffect)(()=>{let e=document.activeElement;a.current?.focus();let t=e=>e.key===`Escape`&&!document.querySelector(`.dialog`)&&o.current();return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t),e?.isConnected&&e.focus()}},[]),(0,D.jsx)(`div`,{className:`drawer-scrim`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,D.jsxs)(`aside`,{className:`drawer${i?` wide`:``}`,ref:a,tabIndex:-1,role:`dialog`,"aria-modal":`true`,children:[(0,D.jsxs)(`header`,{className:`drawer-head`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{children:e}),t&&(0,D.jsx)(`div`,{className:`sub`,children:t})]}),(0,D.jsx)(`button`,{className:`icon-btn`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsx)(`div`,{className:`drawer-body`,children:r})]})})}function L({title:e,children:t,submit:n=`Save`,tone:r,onSubmit:i,onClose:a,note:o}){let s=Oe(),c=(0,l.useRef)(null),u=(0,l.useRef)(a);return u.current=a,(0,l.useEffect)(()=>{(c.current?.querySelector(`input,select,textarea`))?.focus();let e=e=>e.key===`Escape`&&u.current();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,D.jsx)(`div`,{className:`dialog-scrim`,children:(0,D.jsxs)(`form`,{ref:c,className:`dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":e,onSubmit:async e=>{e.preventDefault(),await s.run(i)&&a()},children:[(0,D.jsx)(`h2`,{children:e}),o&&(0,D.jsx)(`p`,{className:`note`,children:o}),(0,D.jsx)(`div`,{className:`dialog-body`,children:t}),(0,D.jsx)(I,{error:s.error}),(0,D.jsxs)(`footer`,{children:[(0,D.jsx)(`button`,{type:`button`,className:`btn ghost`,onClick:a,children:`Cancel`}),(0,D.jsx)(`button`,{type:`submit`,className:`btn ${r===`danger`?`danger`:`primary`}`,disabled:s.busy,children:s.busy?`Working…`:n})]})]})})}function R({label:e,hint:t,children:n,wide:r}){return(0,D.jsxs)(`label`,{className:`field${r?` wide`:``}`,children:[(0,D.jsx)(`span`,{className:`field-label`,children:e}),n,t&&(0,D.jsx)(`span`,{className:`hint`,children:t})]})}function Ie({items:e}){return(0,D.jsx)(`dl`,{className:`facts`,children:e.map(([e,t])=>(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`dt`,{children:e}),(0,D.jsx)(`dd`,{children:t===``||t==null||t===!1?(0,D.jsx)(`span`,{className:`faint`,children:`—`}):t})]},e))})}function Le(){let[e,t]=(0,l.useState)(null);return{value:e,open:e=>t(e),close:(0,l.useCallback)(()=>t(null),[])}}function Re({value:e,onChange:t,required:n=!0}){return(0,D.jsx)(R,{label:`Reason`,hint:`Saved to the audit log.`,children:(0,D.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),required:n,maxLength:500})})}var ze=e=>e?e.replace(/^([A-Z][A-Z_]+)/,e=>A(e)):``;async function Be(e,t,n){let r=new Date(n).getTime(),i=new Date(r-864e5).toISOString().slice(0,10),a=new Date(r+864e5).toISOString().slice(0,10);try{let n=(await w(C.GET(`/api/v1/admin/bookings`,{params:{query:{status:t,from:i,to:a,limit:100}}}))).items?.find(t=>t.bookingRef===e);n?.id?Se(`bookings/${n.id}`):Ee(`${e} not found in the bookings list`,`danger`)}catch(e){Ee(de(e),`danger`)}}var Ve=[`CONFIRMED`,`MATCHING`,`UNFULFILLED`,`ASSIGNED`,`EN_ROUTE`,`ARRIVED`,`IN_PROGRESS`,`COMPLETED`,`CANCELLED`];function He(){let e=N(()=>E(),[]),[t,n]=(0,l.useState)(``),r=N(()=>w(C.GET(`/api/v1/admin/ops/live`,{params:{query:{cityId:t||void 0}}})),[t]),i=N(()=>w(C.GET(`/api/v1/admin/ops/alerts`)),[]),[a,o]=(0,l.useState)(new Date);(0,l.useEffect)(()=>{let e=setInterval(()=>{r.reload(),i.reload(),o(new Date)},3e4);return()=>clearInterval(e)},[r.reload,i.reload]);let s=r.data,c=s?.today??{},u=[...Ve.filter(e=>e in c),...Object.keys(c).filter(e=>!Ve.includes(e))],d=i.data?.filter(e=>e.firing)??[],f=i.data?.filter(e=>!e.firing)??[];return(0,D.jsxs)(ke,{title:`Live board`,sub:(0,D.jsxs)(D.Fragment,{children:[`Refreshes every 30 s · last `,a.toLocaleTimeString(`en-IN`,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})]}),actions:(0,D.jsxs)(D.Fragment,{children:[e.data&&e.data.length>0&&(0,D.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),"aria-label":`City`,children:[(0,D.jsx)(`option`,{value:``,children:`All cities`}),e.data.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>(r.reload(),i.reload(),o(new Date)),children:`Refresh`})]}),children:[(0,D.jsx)(I,{error:r.error}),!s&&r.loading?(0,D.jsx)(Ne,{}):s&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`strip`,children:[(0,D.jsxs)(`div`,{className:`stat lead`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Pros online`}),(0,D.jsx)(`span`,{className:`stat-value`,children:s.onlinePros??``})]}),(0,D.jsxs)(`div`,{className:`stat-group`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Today's bookings by status`}),u.length===0?(0,D.jsx)(`span`,{className:`faint`,children:`No bookings with a slot today`}):(0,D.jsx)(`div`,{className:`stat-row`,children:u.map(e=>(0,D.jsxs)(`a`,{className:`stat small`,href:`#/bookings?status=${e}`,children:[(0,D.jsx)(`span`,{className:`stat-value`,children:c[e]}),(0,D.jsx)(F,{value:e})]},e))})]})]}),(0,D.jsxs)(`div`,{className:`grid-2`,children:[(0,D.jsx)(Ae,{title:(0,D.jsxs)(D.Fragment,{children:[`Needs a pro `,(0,D.jsx)(`span`,{className:`count`,children:s.unmatched?.length??``})]}),flush:!0,children:(0,D.jsx)(Ue,{rows:s.unmatched,empty:`Every upcoming booking has a pro`})}),(0,D.jsx)(Ae,{title:(0,D.jsxs)(D.Fragment,{children:[`Running late `,(0,D.jsx)(`span`,{className:`count`,children:s.lateArrivals?.length??``})]}),flush:!0,children:(0,D.jsx)(Ue,{rows:s.lateArrivals,empty:`No pro is more than 15 minutes late`})})]}),(0,D.jsx)(Ae,{title:(0,D.jsxs)(D.Fragment,{children:[`Open high-priority cases `,(0,D.jsx)(`span`,{className:`count`,children:s.openIncidents?.length??``})]}),flush:!0,children:(0,D.jsx)(Pe,{rows:s.openIncidents,rowKey:e=>e.caseRef,onOpen:e=>Se(`cases?ref=${e.caseRef}`),cols:[{key:`ref`,label:`Case`,render:e=>e.caseRef,mono:!0,width:170},{key:`pri`,label:`Priority`,render:e=>(0,D.jsx)(F,{value:e.priority}),width:110},{key:`type`,label:`Issue`,render:e=>A(e.issueType)},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status})},{key:`at`,label:`Opened`,render:e=>k(e.createdAt),width:140}]})})]}),(0,D.jsxs)(Ae,{title:`System signals`,aside:(0,D.jsx)(`span`,{className:`faint`,children:i.data?`${d.length} firing of ${i.data.length}`:``}),children:[(0,D.jsx)(I,{error:i.error}),i.data&&i.data.length===0&&(0,D.jsx)(Me,{}),(0,D.jsx)(`ul`,{className:`alerts`,children:[...d,...f].map(e=>(0,D.jsxs)(`li`,{className:e.firing?`firing`:void 0,children:[(0,D.jsx)(`span`,{className:`alert-dot`,"aria-hidden":!0}),(0,D.jsx)(`strong`,{children:A(e.code)}),(0,D.jsx)(`span`,{className:`faint`,children:e.detail}),(0,D.jsxs)(`span`,{className:`alert-val`,children:[Array.isArray(e.value)?e.value.join(`, `)||``:e.value==null?``:String(e.value),e.threshold!=null&&(0,D.jsxs)(`span`,{className:`faint`,children:[` / limit `,String(e.threshold)]})]})]},e.code))})]})]})}function Ue({rows:e,empty:t}){return e&&e.length===0?(0,D.jsx)(Me,{children:t}):(0,D.jsx)(Pe,{rows:e,rowKey:e=>e.bookingRef,onOpen:e=>Be(e.bookingRef,e.status,e.slotStart),cols:[{key:`ref`,label:`Booking`,render:e=>e.bookingRef,mono:!0},{key:`slot`,label:`Slot`,render:e=>k(e.slotStart)},{key:`skill`,label:`Skill`,render:e=>A(e.requiredSkill)},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status})}]})}var We=[`CONFIRMED`,`MATCHING`,`UNFULFILLED`,`ASSIGNED`,`EN_ROUTE`,`ARRIVED`,`IN_PROGRESS`,`COMPLETED`,`CANCELLED`];function Ge({me:e}){let t=be(),n=xe(),r=n.get(`status`)??``,i=n.get(`from`)??``,a=n.get(`to`)??``,o=(e,t)=>{let n=xe();t?n.set(e,t):n.delete(e),Se(`bookings${n.size?`?`+n:``}`)},s=P(e=>w(C.GET(`/api/v1/admin/bookings`,{params:{query:{status:r||void 0,from:i||void 0,to:a||void 0,cursor:e,limit:50}}})),[r,i,a]),c=t[1],l=n.size?`?`+n:``;return(0,D.jsxs)(ke,{title:`Bookings`,sub:`By slot time, newest first. Without dates: the last 7 days to 30 days ahead.`,children:[(0,D.jsxs)(`div`,{className:`filters`,role:`search`,children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:r,onChange:e=>o(`status`,e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Any`}),We.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))]})}),(0,D.jsx)(R,{label:`Slot from`,children:(0,D.jsx)(`input`,{type:`date`,value:i,onChange:e=>o(`from`,e.target.value)})}),(0,D.jsx)(R,{label:`Slot to`,children:(0,D.jsx)(`input`,{type:`date`,value:a,onChange:e=>o(`to`,e.target.value)})}),(r||i||a)&&(0,D.jsx)(`button`,{className:`btn ghost`,onClick:()=>Se(`bookings`),children:`Clear`})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:s.rows,loading:s.loading,error:s.error,more:s.more,selected:c,rowKey:e=>e.id,onOpen:e=>Se(`bookings/${e.id}${l}`),cols:[{key:`ref`,label:`Booking`,render:e=>e.bookingRef,mono:!0,width:170},{key:`svc`,label:`Service`,render:e=>e.serviceLabel},{key:`slot`,label:`Slot`,render:e=>k(e.slotStart),width:150},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:130},{key:`tot`,label:`Total`,render:e=>O(e.totalMinor,e.currency),num:!0,width:110}]})}),c&&(0,D.jsx)(Ke,{id:c,me:e,onClose:()=>Se(`bookings${l}`),onChanged:s.reload})]})}function Ke({id:e,me:t,onClose:n,onChanged:r}){let i=N(()=>w(C.GET(`/api/v1/admin/bookings/{id}`,{params:{path:{id:e}}})),[e]),a=N(()=>w(C.GET(`/api/v1/admin/bookings/{id}/timeline`,{params:{path:{id:e}}})),[e]),o=N(()=>w(C.GET(`/api/v1/admin/bookings/{id}/offers`,{params:{path:{id:e}}})),[e]),s=N(()=>T(t,`professional.view`)?w(C.GET(`/api/v1/admin/professionals`,{params:{query:{limit:100}}})):Promise.resolve(void 0),[]),c=e=>s.data?.items?.find(t=>t.id===e)?.displayName??j(e),l=Le(),u=()=>(i.reload(),a.reload(),o.reload(),r?.()),d=i.data,f=d?.address??{},p=[`line1`,`line2`,`locality`,`cityName`,`pincode`].map(e=>f[e]).filter(Boolean).join(`, `),m=d&&![`COMPLETED`,`CANCELLED`].includes(d.status??``);return(0,D.jsxs)(Fe,{title:d?.bookingRef??`Booking`,sub:d&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(F,{value:d.status}),` · `,d.serviceLabel]}),onClose:n,wide:!0,children:[(0,D.jsx)(I,{error:i.error}),d?(0,D.jsxs)(D.Fragment,{children:[m&&(0,D.jsxs)(`div`,{className:`toolbar`,children:[T(t,`booking.assign.manual`)&&(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>l.open(`assign`),children:`Assign pro`}),T(t,`booking.assign.manual`)&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>l.open(`rematch`),children:`Re-run matching`}),T(t,`booking.reschedule.any`)&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>l.open(`reschedule`),children:`Reschedule`}),T(t,`booking.state.override`)&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>l.open(`presence`),children:`Presence exception`}),T(t,`booking.cancel.any`)&&(0,D.jsx)(`button`,{className:`btn danger-ghost`,onClick:()=>l.open(`cancel`),children:`Cancel booking`})]}),(0,D.jsx)(Ie,{items:[[`Slot`,d.slotStart&&`${k(d.slotStart)} – ${new Date(d.slotEnd).toLocaleTimeString(`en-IN`,{hour:`numeric`,minute:`2-digit`,timeZone:`Asia/Kolkata`})}`],[`Professional`,d.professional?.displayName&&(0,D.jsxs)(`a`,{href:`#/professionals/${d.professional.id}`,children:[d.professional.displayName,d.professional.ratingCount?(0,D.jsxs)(`span`,{className:`faint`,children:[` · ★ `,d.professional.ratingAvg?.toFixed(1),` (`,d.professional.ratingCount,`)`]}):null]})],[`Address`,p],[`Payment`,A(d.paymentMode)],[`Total`,O(d.totalMinor,d.currency)],[`Customer notes`,d.customerNotes]]}),(0,D.jsx)(`h3`,{className:`section`,children:`Lines`}),d.lines?.length?(0,D.jsx)(`table`,{className:`table mini`,children:(0,D.jsx)(`tbody`,{children:d.lines.map((e,t)=>(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{className:`faint`,style:{width:90},children:A(e.kind)}),(0,D.jsxs)(`td`,{children:[e.label,e.quantity&&e.quantity>1?` × ${e.quantity}`:``]}),(0,D.jsx)(`td`,{className:`num`,children:O(e.totalMinor,d.currency)})]},t))})}):(0,D.jsx)(Me,{})]}):i.loading&&(0,D.jsx)(Ne,{}),(0,D.jsx)(`h3`,{className:`section`,children:`Timeline`}),(0,D.jsx)(I,{error:a.error}),a.data&&a.data.length===0&&(0,D.jsx)(Me,{}),(0,D.jsx)(`ol`,{className:`timeline`,children:a.data?.map((e,t)=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`time`,{children:k(e.at)}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:e.from?(0,D.jsxs)(D.Fragment,{children:[A(e.from),` → `,A(e.to)]}):A(e.to)}),(0,D.jsxs)(`span`,{className:`faint`,children:[` · `,A(e.actorType),e.reason?` · ${ze(e.reason)}`:``]})]})]},t))}),(0,D.jsx)(`h3`,{className:`section`,children:`Offers`}),(0,D.jsx)(I,{error:o.error}),o.data&&o.data.length===0?(0,D.jsx)(Me,{children:`No offers sent`}):o.data&&(0,D.jsxs)(`table`,{className:`table mini`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{children:`Round`}),(0,D.jsx)(`th`,{children:`Pro`}),(0,D.jsx)(`th`,{children:`Status`}),(0,D.jsx)(`th`,{className:`num`,children:`Score`}),(0,D.jsx)(`th`,{children:`Offered`})]})}),(0,D.jsx)(`tbody`,{children:o.data.map(e=>(0,D.jsxs)(`tr`,{title:e.scoreBreakdown?Object.entries(e.scoreBreakdown).map(([e,t])=>`${e} ${t}`).join(` · `):void 0,children:[(0,D.jsx)(`td`,{className:`num`,children:e.roundNo}),(0,D.jsx)(`td`,{children:(0,D.jsx)(`a`,{href:`#/professionals/${e.professionalId}`,children:c(e.professionalId)})}),(0,D.jsxs)(`td`,{children:[(0,D.jsx)(F,{value:e.status}),e.declineReason&&(0,D.jsxs)(`span`,{className:`faint`,children:[` · `,A(e.declineReason)]})]}),(0,D.jsx)(`td`,{className:`num`,children:e.score?.toFixed(2)}),(0,D.jsx)(`td`,{children:k(e.offeredAt)})]},e.offerId))})]}),l.value===`assign`&&(0,D.jsx)(Je,{id:e,onClose:l.close,onDone:u}),l.value===`rematch`&&(0,D.jsx)(qe,{title:`Re-run matching`,submit:`Re-run`,onClose:l.close,send:t=>w(C.POST(`/api/v1/admin/bookings/{id}/rematch`,{params:{path:{id:e}},body:{reason:t}})).then(u)}),l.value===`presence`&&(0,D.jsx)(qe,{title:`Presence exception`,submit:`Record exception`,note:`Lets the pro start without the on-site presence check.`,onClose:l.close,send:t=>w(C.POST(`/api/v1/admin/bookings/{id}/presence-exception`,{params:{path:{id:e}},body:{reason:t}})).then(u)}),l.value===`cancel`&&(0,D.jsx)(qe,{title:`Cancel ${d?.bookingRef??`booking`}`,submit:`Cancel booking`,tone:`danger`,note:`Ops cancellation. The customer is refunded under the cancellation policy.`,onClose:l.close,send:t=>w(C.POST(`/api/v1/admin/bookings/{id}/cancel`,{params:{path:{id:e}},body:{reason:t}})).then(u)}),l.value===`reschedule`&&(0,D.jsx)(Ye,{id:e,onClose:l.close,onDone:u})]})}function qe({title:e,submit:t,note:n,tone:r,send:i,onClose:a}){let[o,s]=(0,l.useState)(``);return(0,D.jsx)(L,{title:e,submit:t,note:n,tone:r,onClose:a,onSubmit:()=>i(o),children:(0,D.jsx)(Re,{value:o,onChange:s})})}function Je({id:e,onClose:t,onDone:n}){let r=N(()=>w(C.GET(`/api/v1/admin/professionals`,{params:{query:{status:`ACTIVE`,limit:100}}})),[]),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``),d=(r.data?.items??[]).filter(e=>`${e.displayName} ${e.skills?.join(` `)}`.toLowerCase().includes(c.toLowerCase()));return(0,D.jsxs)(L,{title:`Assign a professional`,submit:`Assign`,onClose:t,note:`Skips matching. The pro gets the job straight away.`,onSubmit:()=>w(C.POST(`/api/v1/admin/bookings/{id}/assign`,{params:{path:{id:e}},body:{professionalId:i,reason:o}})).then(n),children:[(0,D.jsx)(R,{label:`Find`,children:(0,D.jsx)(`input`,{value:c,onChange:e=>u(e.target.value),placeholder:`Name or skill`})}),(0,D.jsx)(I,{error:r.error}),(0,D.jsxs)(`div`,{className:`pick-list`,role:`radiogroup`,"aria-label":`Professional`,children:[r.loading&&!r.data&&(0,D.jsx)(Ne,{}),r.data&&d.length===0&&(0,D.jsx)(Me,{children:`No active professional matches`}),d.map(e=>(0,D.jsxs)(`label`,{className:i===e.id?`on`:void 0,children:[(0,D.jsx)(`input`,{type:`radio`,name:`pro`,value:e.id,checked:i===e.id,onChange:()=>a(e.id),required:!0}),(0,D.jsxs)(`span`,{className:`pick-main`,children:[(0,D.jsx)(`strong`,{children:e.displayName}),(0,D.jsx)(`span`,{className:`faint`,children:e.skills?.map(A).join(`, `)})]}),(0,D.jsx)(`span`,{className:`status ${e.online?`ok`:`mute`}`,children:e.online?`Online`:`Offline`})]},e.id))]}),(0,D.jsx)(Re,{value:o,onChange:s})]})}function Ye({id:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Reschedule`,submit:`Move booking`,onClose:t,onSubmit:()=>w(C.POST(`/api/v1/admin/bookings/{id}/reschedule`,{params:{path:{id:e}},body:{newSlotStart:new Date(`${r}:00+05:30`).toISOString(),reason:a}})).then(n),children:[(0,D.jsx)(R,{label:`New slot start (IST)`,children:(0,D.jsx)(`input`,{type:`datetime-local`,value:r,onChange:e=>i(e.target.value),required:!0,step:1800})}),(0,D.jsx)(Re,{value:a,onChange:o})]})}var Xe=e=>e.split(` `).map(e=>e.trim()).filter(Boolean),Ze=e=>e.trim()===``?void 0:Math.round(Number(e)*100);function Qe({me:e}){let t=be(),n=N(()=>w(C.GET(`/api/v1/admin/categories`)),[]),[r,i]=(0,l.useState)(``),a=N(()=>w(C.GET(`/api/v1/admin/services`,{params:{query:{categoryId:r||void 0}}})),[r]),o=Le(),s=e=>n.data?.find(t=>t.id===e)?.name??``,c=t[1];return(0,D.jsxs)(ke,{title:`Services`,sub:`Categories and the services customers book. Edits apply to new checkouts.`,actions:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`btn`,onClick:()=>o.open({kind:`newCat`}),children:`New category`}),T(e,`price.manage`)&&(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>o.open({kind:`newSvc`}),children:`New service`})]}),children:[(0,D.jsxs)(`div`,{className:`split`,children:[(0,D.jsxs)(Ae,{title:`Categories`,flush:!0,children:[(0,D.jsx)(I,{error:n.error}),!n.data&&n.loading&&(0,D.jsx)(Ne,{}),(0,D.jsxs)(`ul`,{className:`nav-list`,children:[(0,D.jsx)(`li`,{children:(0,D.jsx)(`button`,{className:r===``?`on`:void 0,onClick:()=>i(``),children:`All categories`})}),n.data?.map(e=>(0,D.jsxs)(`li`,{children:[(0,D.jsxs)(`button`,{className:r===e.id?`on`:void 0,onClick:()=>i(e.id),children:[(0,D.jsx)(`span`,{children:e.name}),e.status!==`ACTIVE`&&(0,D.jsx)(F,{value:e.status})]}),(0,D.jsx)(`button`,{className:`icon-btn`,"aria-label":`Edit ${e.name}`,onClick:()=>o.open({kind:`editCat`,c:e}),children:`✎`})]},e.id))]})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:a.data,loading:a.loading,error:a.error,selected:c,rowKey:e=>e.id,onOpen:e=>Se(`catalog/${e.id}`),cols:[{key:`name`,label:`Service`,render:e=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsx)(`div`,{className:`faint mono`,children:e.slug})]})},{key:`cat`,label:`Category`,render:e=>s(e.categoryId)},{key:`price`,label:`Base price`,render:e=>(0,D.jsxs)(D.Fragment,{children:[e.priceType!==`FIXED`&&(0,D.jsxs)(`span`,{className:`faint`,children:[A(e.priceType),` `]}),O(e.basePriceMinor,e.currency)]}),num:!0},{key:`dur`,label:`Duration`,render:e=>e.baseDurationMin==null?``:`${e.baseDurationMin} min`,num:!0},{key:`zones`,label:`Zones`,render:e=>e.zones?e.zones.filter(e=>e.status===`ACTIVE`).length:``,num:!0},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status})}]})})]}),c&&(0,D.jsx)(nt,{id:c,cats:n.data??[],onClose:()=>Se(`catalog`),onChanged:a.reload}),o.value?.kind===`newCat`&&(0,D.jsx)($e,{onClose:o.close,onDone:n.reload}),o.value?.kind===`editCat`&&(0,D.jsx)($e,{c:o.value.c,onClose:o.close,onDone:n.reload}),o.value?.kind===`newSvc`&&(0,D.jsx)(tt,{cats:n.data??[],onClose:o.close,onDone:e=>(a.reload(),Se(`catalog/${e.id}`))})]})}function $e({c:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(e?.name??``),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(String(e?.sortOrder??``)),[u,d]=(0,l.useState)(e?.status??`ACTIVE`),[f,p]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:e?`Edit ${e.name}`:`New category`,onClose:t,onSubmit:()=>w(e?C.PUT(`/api/v1/admin/categories/{id}`,{params:{path:{id:e.id}},body:{name:r,sortOrder:Number(s),status:u,version:e.version,reason:f}}):C.POST(`/api/v1/admin/categories`,{body:{slug:a,name:r,sortOrder:Number(s)}})).then(n),children:[(0,D.jsx)(R,{label:`Name`,children:(0,D.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),required:!0,maxLength:80})}),!e&&(0,D.jsx)(R,{label:`Slug`,hint:`Lower case and dashes; used in app links.`,children:(0,D.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),required:!0,pattern:`[a-z0-9-]+`})}),(0,D.jsx)(R,{label:`Sort order`,children:(0,D.jsx)(`input`,{type:`number`,value:s,onChange:e=>c(e.target.value),required:!0,min:0})}),e&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,D.jsx)(`option`,{children:`ACTIVE`}),(0,D.jsx)(`option`,{children:`INACTIVE`})]})}),(0,D.jsx)(Re,{value:f,onChange:p})]})]})}function et(e){return{categoryId:e.categoryId,slug:e.slug,name:e.name,description:e.description,inclusions:e.inclusions,exclusions:e.exclusions,requirements:e.requirements,synonyms:e.synonyms,priceType:e.priceType,basePriceMinor:e.basePriceMinor,currency:e.currency,baseDurationMin:e.baseDurationMin,instantEligible:e.instantEligible,requiredSkill:e.requiredSkill,warrantyDays:e.warrantyDays,variants:e.variants,addons:e.addons,checklist:e.checklist}}function tt({s:e,cats:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)({categoryId:e?.categoryId??t[0]?.id??``,slug:e?.slug??``,name:e?.name??``,description:e?.description??``,priceType:e?.priceType??`FIXED`,price:e?.basePriceMinor==null?``:String(e.basePriceMinor/100),duration:String(e?.baseDurationMin??``),skill:e?.requiredSkill??``,warranty:String(e?.warrantyDays??`0`),instant:e?.instantEligible??!1,inclusions:(e?.inclusions??[]).join(` `),exclusions:(e?.exclusions??[]).join(` `)}),[o,s]=(0,l.useState)(``),c=e=>t=>a({...i,[e]:t.target.type===`checkbox`?t.target.checked:t.target.value}),u=()=>({...e?et(e):{currency:`INR`},categoryId:i.categoryId,slug:i.slug,name:i.name,description:i.description,priceType:i.priceType,basePriceMinor:Ze(i.price),baseDurationMin:Number(i.duration),requiredSkill:i.skill,warrantyDays:Number(i.warranty),instantEligible:i.instant,inclusions:Xe(i.inclusions),exclusions:Xe(i.exclusions)});return(0,D.jsxs)(L,{title:e?`Edit ${e.name}`:`New service`,note:e?void 0:`Created as a draft. Publish it once zones are set.`,onClose:n,onSubmit:()=>w(e?C.PUT(`/api/v1/admin/services/{id}`,{params:{path:{id:e.id}},body:{service:u(),version:e.version,reason:o}}):C.POST(`/api/v1/admin/services`,{body:u()})).then(r),children:[(0,D.jsxs)(`div`,{className:`form-grid`,children:[(0,D.jsx)(R,{label:`Category`,children:(0,D.jsx)(`select`,{value:i.categoryId,onChange:c(`categoryId`),required:!0,children:t.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,D.jsx)(R,{label:`Slug`,children:(0,D.jsx)(`input`,{value:i.slug,onChange:c(`slug`),required:!0,pattern:`[a-z0-9-]+`})}),(0,D.jsx)(R,{label:`Name`,wide:!0,children:(0,D.jsx)(`input`,{value:i.name,onChange:c(`name`),required:!0,maxLength:120})}),(0,D.jsx)(R,{label:`Description`,wide:!0,children:(0,D.jsx)(`textarea`,{rows:2,value:i.description,onChange:c(`description`)})}),(0,D.jsx)(R,{label:`Price type`,children:(0,D.jsx)(`select`,{value:i.priceType,onChange:c(`priceType`),children:[`FIXED`,`STARTING_FROM`,`INSPECTION`].map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})}),(0,D.jsx)(R,{label:`Base price (₹)`,children:(0,D.jsx)(`input`,{type:`number`,step:`0.01`,min:0,value:i.price,onChange:c(`price`),required:!0})}),(0,D.jsx)(R,{label:`Duration (min)`,children:(0,D.jsx)(`input`,{type:`number`,min:5,step:5,value:i.duration,onChange:c(`duration`),required:!0})}),(0,D.jsx)(R,{label:`Warranty (days)`,children:(0,D.jsx)(`input`,{type:`number`,min:0,value:i.warranty,onChange:c(`warranty`),required:!0})}),(0,D.jsx)(R,{label:`Required skill`,children:(0,D.jsx)(`input`,{value:i.skill,onChange:c(`skill`),required:!0,pattern:`[A-Z_]+`,title:`Upper case with underscores, e.g. AC_TECHNICIAN`})}),(0,D.jsxs)(`label`,{className:`check`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:i.instant,onChange:c(`instant`)}),` Instant booking allowed`]}),(0,D.jsx)(R,{label:`Included (one per line)`,wide:!0,children:(0,D.jsx)(`textarea`,{rows:3,value:i.inclusions,onChange:c(`inclusions`)})}),(0,D.jsx)(R,{label:`Not included (one per line)`,wide:!0,children:(0,D.jsx)(`textarea`,{rows:2,value:i.exclusions,onChange:c(`exclusions`)})})]}),e&&(0,D.jsx)(Re,{value:o,onChange:s})]})}function nt({id:e,cats:t,onClose:n,onChanged:r}){let i=N(()=>w(C.GET(`/api/v1/admin/services/{id}`,{params:{path:{id:e}}})),[e]),a=Le(),o=Oe(),s=i.data,c=()=>(i.reload(),r());return(0,D.jsxs)(Fe,{title:s?.name??`Service`,sub:s&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(F,{value:s.status}),` · `,(0,D.jsx)(`span`,{className:`mono`,children:s.slug}),` · v`,s.version]}),onClose:n,wide:!0,children:[(0,D.jsx)(I,{error:i.error??o.error}),s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`toolbar`,children:[(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>a.open(`edit`),children:`Edit`}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open(`zones`),children:`Zones`}),s.status!==`ACTIVE`&&(0,D.jsx)(`button`,{className:`btn`,disabled:o.busy,onClick:()=>o.run(()=>w(C.POST(`/api/v1/admin/services/{id}/publish`,{params:{path:{id:e}}})).then(c),`Service published`),children:`Publish`}),s.status===`ACTIVE`&&(0,D.jsx)(`button`,{className:`btn danger-ghost`,onClick:()=>a.open(`deactivate`),children:`Deactivate`})]}),(0,D.jsx)(Ie,{items:[[`Category`,t.find(e=>e.id===s.categoryId)?.name],[`Price`,(0,D.jsxs)(D.Fragment,{children:[A(s.priceType),` · `,O(s.basePriceMinor,s.currency)]})],[`Duration`,s.baseDurationMin!=null&&`${s.baseDurationMin} min`],[`Required skill`,A(s.requiredSkill)],[`Warranty`,s.warrantyDays?`${s.warrantyDays} days`:`None`],[`Instant`,s.instantEligible?`Yes`:`No`],[`Description`,s.description]]}),(0,D.jsxs)(`div`,{className:`grid-2 tight`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Included`}),s.inclusions?.length?(0,D.jsx)(`ul`,{className:`bullets`,children:s.inclusions.map(e=>(0,D.jsx)(`li`,{children:e},e))}):(0,D.jsx)(Me,{})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Not included`}),s.exclusions?.length?(0,D.jsx)(`ul`,{className:`bullets`,children:s.exclusions.map(e=>(0,D.jsx)(`li`,{children:e},e))}):(0,D.jsx)(Me,{})]})]}),(0,D.jsx)(`h3`,{className:`section`,children:`Variants`}),s.variants?.length?(0,D.jsx)(`table`,{className:`table mini`,children:(0,D.jsx)(`tbody`,{children:s.variants.map(e=>(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{className:`faint`,children:e.groupLabel}),(0,D.jsxs)(`td`,{children:[e.name,e.isDefault&&(0,D.jsx)(`span`,{className:`faint`,children:` · default`})]}),(0,D.jsx)(`td`,{className:`num`,children:e.priceDeltaMinor?`+${O(e.priceDeltaMinor)}`:``}),(0,D.jsx)(`td`,{className:`num`,children:e.durationDeltaMin?`+${e.durationDeltaMin} min`:``})]},e.id))})}):(0,D.jsx)(Me,{}),(0,D.jsx)(`h3`,{className:`section`,children:`Add-ons`}),s.addons?.length?(0,D.jsx)(`table`,{className:`table mini`,children:(0,D.jsx)(`tbody`,{children:s.addons.map(e=>(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{children:e.name}),(0,D.jsx)(`td`,{className:`num`,children:O(e.priceMinor)}),(0,D.jsx)(`td`,{className:`num`,children:e.durationMin==null?``:`${e.durationMin} min`}),(0,D.jsx)(`td`,{className:`faint`,children:e.allowedAsExtraWork?`Also as extra work`:``})]},e.id))})}):(0,D.jsx)(Me,{}),(0,D.jsx)(`h3`,{className:`section`,children:`Job checklist`}),s.checklist?.length?(0,D.jsx)(`ul`,{className:`bullets`,children:s.checklist.map(e=>(0,D.jsxs)(`li`,{children:[e.label,(0,D.jsxs)(`span`,{className:`faint`,children:[e.required?` · required`:``,e.evidenceRequired?` · photo`:``]})]},e.code))}):(0,D.jsx)(Me,{})]}):i.loading&&(0,D.jsx)(Ne,{}),s&&a.value===`edit`&&(0,D.jsx)(tt,{s,cats:t,onClose:a.close,onDone:c}),s&&a.value===`zones`&&(0,D.jsx)(it,{s,onClose:a.close,onDone:c}),s&&a.value===`deactivate`&&(0,D.jsx)(rt,{id:e,onClose:a.close,onDone:c})]})}function rt({id:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(``);return(0,D.jsx)(L,{title:`Deactivate service`,tone:`danger`,submit:`Deactivate`,note:`Customers stop seeing it. Existing bookings are kept.`,onClose:t,onSubmit:()=>w(C.POST(`/api/v1/admin/services/{id}/deactivate`,{params:{path:{id:e}},body:{reason:r}})).then(n),children:(0,D.jsx)(Re,{value:r,onChange:i})})}function it({s:e,onClose:t,onDone:n}){let r=N(async()=>{let e=await E();return(await Promise.all(e.map(e=>w(C.GET(`/api/v1/admin/cities/{cityId}/zones`,{params:{path:{cityId:e.id}}})).then(t=>t.map(t=>({...t,city:e.name})))))).flat()},[]),[i,a]=(0,l.useState)(()=>Object.fromEntries((e.zones??[]).map(e=>[e.zoneId,{on:e.status===`ACTIVE`,price:e.priceOverrideMinor==null?``:String(e.priceOverrideMinor/100)}])));return(0,D.jsxs)(L,{title:`Zones for ${e.name}`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/services/{id}/zones`,{params:{path:{id:e.id}},body:Object.entries(i).map(([e,t])=>({zoneId:e,active:t.on,priceOverrideMinor:Ze(t.price)}))})).then(n),children:[(0,D.jsx)(I,{error:r.error}),r.data?r.data.length===0?(0,D.jsx)(Me,{}):(0,D.jsxs)(`table`,{className:`table mini`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{children:`Zone`}),(0,D.jsx)(`th`,{children:`City`}),(0,D.jsx)(`th`,{children:`Runs here`}),(0,D.jsx)(`th`,{className:`num`,children:`Price override (₹)`})]})}),(0,D.jsx)(`tbody`,{children:r.data.map(e=>{let t=i[e.id]??{on:!1,price:``},n=n=>a({...i,[e.id]:{...t,...n}});return(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{children:e.name}),(0,D.jsx)(`td`,{className:`faint`,children:e.city}),(0,D.jsx)(`td`,{children:(0,D.jsx)(`input`,{type:`checkbox`,"aria-label":`Runs in ${e.name}`,checked:t.on,onChange:e=>n({on:e.target.checked})})}),(0,D.jsx)(`td`,{className:`num`,children:(0,D.jsx)(`input`,{className:`narrow`,type:`number`,step:`0.01`,min:0,placeholder:`Base`,value:t.price,onChange:e=>n({price:e.target.value})})})]},e.id)})})]}):(0,D.jsx)(Ne,{})]})}function at(){let e=N(()=>w(C.GET(`/api/v1/admin/cities`)),[]),[t,n]=(0,l.useState)(),r=e.data?.find(e=>e.id===t)??e.data?.[0],i=N(()=>r?w(C.GET(`/api/v1/admin/cities/{cityId}/zones`,{params:{path:{cityId:r.id}}})):Promise.resolve(void 0),[r?.id]),a=Le();return(0,D.jsxs)(ke,{title:`Cities & zones`,sub:`Where customers can book. A zone is a service area drawn as a polygon.`,actions:(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open({kind:`city`}),children:`New city`}),children:[(0,D.jsxs)(`div`,{className:`split`,children:[(0,D.jsxs)(Ae,{title:`Cities`,flush:!0,children:[(0,D.jsx)(I,{error:e.error}),!e.data&&(0,D.jsx)(Ne,{}),e.data?.length===0&&(0,D.jsx)(Me,{}),(0,D.jsx)(`ul`,{className:`nav-list`,children:e.data?.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(`button`,{className:r?.id===e.id?`on`:void 0,onClick:()=>n(e.id),children:[(0,D.jsx)(`span`,{children:e.name}),(0,D.jsx)(`span`,{className:`faint`,children:e.timeZone})]})},e.id))})]}),(0,D.jsx)(Ae,{title:r?`Zones in ${r.name}`:`Zones`,aside:r&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open({kind:`zone`}),children:`New zone`}),flush:!0,children:(0,D.jsx)(Pe,{rows:i.data,loading:i.loading,error:i.error,rowKey:e=>e.id,cols:[{key:`n`,label:`Zone`,render:e=>(0,D.jsx)(`strong`,{children:e.name})},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:110},{key:`pins`,label:`Pincodes`,render:e=>e.pincodes?.length?e.pincodes.join(`, `):(0,D.jsx)(`span`,{className:`faint`,children:`None`})},{key:`v`,label:`Version`,render:e=>e.version,num:!0,width:80},{key:`a`,label:``,width:180,render:e=>(0,D.jsxs)(`span`,{className:`row-actions`,children:[(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>a.open({kind:`edit`,z:e}),children:`Edit`}),(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>a.open({kind:`pins`,z:e}),children:`Pincodes`})]})}]})})]}),a.value?.kind===`city`&&(0,D.jsx)(ot,{onClose:a.close,onDone:e.reload}),a.value?.kind===`zone`&&r&&(0,D.jsx)(st,{cityId:r.id,onClose:a.close,onDone:i.reload}),a.value?.kind===`edit`&&(0,D.jsx)(st,{z:a.value.z,onClose:a.close,onDone:i.reload}),a.value?.kind===`pins`&&(0,D.jsx)(ct,{z:a.value.z,onClose:a.close,onDone:i.reload})]})}function ot({onClose:e,onDone:t}){let[n,r]=(0,l.useState)({name:``,countryCode:`IN`,timeZone:`Asia/Kolkata`,currency:`INR`,locale:`en-IN`}),i=e=>t=>r({...n,[e]:t.target.value});return(0,D.jsx)(L,{title:`New city`,onClose:e,onSubmit:()=>w(C.POST(`/api/v1/admin/cities`,{body:n})).then(t),children:(0,D.jsxs)(`div`,{className:`form-grid`,children:[(0,D.jsx)(R,{label:`Name`,wide:!0,children:(0,D.jsx)(`input`,{value:n.name,onChange:i(`name`),required:!0})}),(0,D.jsx)(R,{label:`Country code`,children:(0,D.jsx)(`input`,{value:n.countryCode,onChange:i(`countryCode`),required:!0,maxLength:2})}),(0,D.jsx)(R,{label:`Time zone`,children:(0,D.jsx)(`input`,{value:n.timeZone,onChange:i(`timeZone`),required:!0})}),(0,D.jsx)(R,{label:`Currency`,children:(0,D.jsx)(`input`,{value:n.currency,onChange:i(`currency`),required:!0,maxLength:3})}),(0,D.jsx)(R,{label:`Locale`,children:(0,D.jsx)(`input`,{value:n.locale,onChange:i(`locale`),required:!0})})]})})}function st({cityId:e,z:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(t?.name??``),[o,s]=(0,l.useState)(t?.areaGeoJson??``),[c,u]=(0,l.useState)(t?.status??`ACTIVE`),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:t?`Edit ${t.name}`:`New zone`,onClose:n,onSubmit:()=>w(t?C.PUT(`/api/v1/admin/zones/{id}`,{params:{path:{id:t.id}},body:{name:i,areaGeoJson:o===t.areaGeoJson?void 0:o,status:c,version:t.version,allowOverlap:d,reason:p}}):C.POST(`/api/v1/admin/cities/{cityId}/zones`,{params:{path:{cityId:e}},body:{name:i,areaGeoJson:o,allowOverlap:d}})).then(r),children:[(0,D.jsx)(R,{label:`Name`,children:(0,D.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Area (GeoJSON polygon)`,hint:`Longitude, latitude pairs; the ring must close.`,children:(0,D.jsx)(`textarea`,{className:`mono`,rows:5,value:o,onChange:e=>s(e.target.value),required:!t})}),t&&(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:c,onChange:e=>u(e.target.value),children:[(0,D.jsx)(`option`,{children:`ACTIVE`}),(0,D.jsx)(`option`,{children:`INACTIVE`})]})}),(0,D.jsxs)(`label`,{className:`check`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),` Allow overlap with another zone`]}),t&&(0,D.jsx)(Re,{value:p,onChange:m})]})}function ct({z:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)((e.pincodes??[]).join(`, `));return(0,D.jsx)(L,{title:`Pincodes for ${e.name}`,note:`Replaces the list. Used when an address's map point falls outside every zone polygon.`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/zones/{id}/pincodes`,{params:{path:{id:e.id}},body:{pincodes:r.split(/[\s,]+/).filter(Boolean)}})).then(n),children:(0,D.jsx)(R,{label:`Pincodes`,hint:`Comma or space separated.`,children:(0,D.jsx)(`textarea`,{rows:4,value:r,onChange:e=>i(e.target.value)})})})}var lt=[`CANCELLATION`,`WARRANTY`,`TERMS`,`PRIVACY`];function ut(){let[e,t]=(0,l.useState)(`CANCELLATION`),n=N(()=>w(C.GET(`/api/v1/admin/policy-documents`,{params:{query:{kind:e}}})),[e]),[r,i]=(0,l.useState)(),[a,o]=(0,l.useState)(),s=Oe();return(0,D.jsxs)(ke,{title:`Policy documents`,sub:`Versioned policy texts. Publishing a draft makes it the version in force.`,actions:(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>o(`new`),children:`New version`}),children:[(0,D.jsx)(`div`,{className:`tabs`,role:`tablist`,children:lt.map(n=>(0,D.jsx)(`button`,{role:`tab`,"aria-selected":e===n,className:e===n?`on`:void 0,onClick:()=>t(n),children:A(n)},n))}),(0,D.jsx)(I,{error:s.error}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:n.data,loading:n.loading,error:n.error,rowKey:e=>e.id,onOpen:i,cols:[{key:`v`,label:`Version`,render:e=>`v${e.version}`,width:90},{key:`t`,label:`Title`,render:e=>e.title},{key:`s`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:130},{key:`e`,label:`In force from`,render:e=>k(e.effectiveFrom),width:160}]})}),r&&(0,D.jsxs)(Fe,{title:`${r.title} · v${r.version}`,sub:(0,D.jsx)(F,{value:r.status}),onClose:()=>i(void 0),wide:!0,children:[(0,D.jsxs)(`div`,{className:`toolbar`,children:[r.status===`DRAFT`&&(0,D.jsx)(`button`,{className:`btn primary`,disabled:s.busy,onClick:()=>s.run(()=>w(C.POST(`/api/v1/admin/policy-documents/{id}/publish`,{params:{path:{id:r.id}}})).then(()=>(n.reload(),i(void 0))),`Version published`),children:`Publish this version`}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>(o(r),i(void 0)),children:`Start a new version from this`})]}),r.rules&&Object.keys(r.rules).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Rules`}),(0,D.jsx)(`pre`,{className:`code-block`,children:JSON.stringify(r.rules,null,2)})]}),(0,D.jsx)(`h3`,{className:`section`,children:`Text`}),(0,D.jsx)(`pre`,{className:`prose`,children:r.bodyMd})]}),a&&(0,D.jsx)(dt,{kind:e,from:a===`new`?void 0:a,onClose:()=>o(void 0),onDone:n.reload})]})}function dt({kind:e,from:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(t?.title??``),[o,s]=(0,l.useState)(t?.bodyMd??``),[c,u]=(0,l.useState)(t?.rules?JSON.stringify(t.rules,null,2):``);return(0,D.jsxs)(L,{title:`New ${A(e).toLowerCase()} version`,note:`Saved as a draft.`,submit:`Save draft`,onClose:n,onSubmit:async()=>{let t;try{t=c.trim()?JSON.parse(c):void 0}catch{throw{code:`VALIDATION_FAILED`,status:400,detail:`Rules must be valid JSON`}}await w(C.POST(`/api/v1/admin/policy-documents`,{body:{kind:e,title:i,bodyMd:o,rules:t}})),r()},children:[(0,D.jsx)(R,{label:`Title`,children:(0,D.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Text (Markdown)`,children:(0,D.jsx)(`textarea`,{rows:10,value:o,onChange:e=>s(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Rules (JSON, optional)`,hint:`Machine-read rules, e.g. cancellation fee windows.`,children:(0,D.jsx)(`textarea`,{className:`mono`,rows:5,value:c,onChange:e=>u(e.target.value)})})]})}var ft=[`OPEN`,`IN_PROGRESS`,`AWAITING_CUSTOMER`,`ESCALATED`,`RESOLVED`,`CLOSED`],pt=[`URGENT`,`HIGH`,`NORMAL`,`LOW`],mt={OPEN:[`IN_PROGRESS`,`RESOLVED`],IN_PROGRESS:[`AWAITING_CUSTOMER`,`RESOLVED`],AWAITING_CUSTOMER:[`IN_PROGRESS`,`RESOLVED`],ESCALATED:[`IN_PROGRESS`,`RESOLVED`],RESOLVED:[`CLOSED`,`IN_PROGRESS`],CLOSED:[]},ht=[`REFUND`,`CREDIT`,`REDO_SERVICE`,`WARRANTY_REPAIR`,`PRO_ACTION`,`NO_ACTION`];function gt({me:e}){let t=be(),n=xe(),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),s=n.get(`ref`)??``,c=P(e=>w(C.GET(`/api/v1/admin/cases`,{params:{query:{status:r||void 0,priority:a||void 0,cursor:e,limit:50}}})),[r,a]),u=s?c.rows?.filter(e=>e.caseRef===s):c.rows,d=t[1];return(0,D.jsxs)(ke,{title:`Cases`,sub:`Customer and pro issues. Oldest urgent first is the usual order of work.`,children:[(0,D.jsxs)(`div`,{className:`filters`,role:`search`,children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Any`}),ft.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))]})}),(0,D.jsx)(R,{label:`Priority`,children:(0,D.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Any`}),pt.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))]})}),s&&(0,D.jsxs)(`span`,{className:`chip`,children:[`Case `,s,` `,(0,D.jsx)(`button`,{className:`link`,onClick:()=>Se(`cases`),children:`clear`})]})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:u,loading:c.loading,error:c.error,more:s?void 0:c.more,selected:d,rowKey:e=>e.id,onOpen:e=>Se(`cases/${e.id}`),cols:[{key:`ref`,label:`Case`,render:e=>e.caseRef,mono:!0,width:160},{key:`pri`,label:`Priority`,render:e=>(0,D.jsx)(F,{value:e.priority}),width:100},{key:`type`,label:`Issue`,render:e=>A(e.issueType),width:110},{key:`sum`,label:`Summary`,render:e=>(0,D.jsx)(`span`,{className:`clip`,children:e.summary})},{key:`bk`,label:`Booking`,render:e=>e.bookingRef,mono:!0,width:160},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:150},{key:`at`,label:`Opened`,render:e=>k(e.createdAt),width:130}]})}),d&&(0,D.jsx)(_t,{id:d,me:e,onClose:()=>Se(`cases`),onChanged:c.reload})]})}function _t({id:e,me:t,onClose:n,onChanged:r}){let i=N(()=>w(C.GET(`/api/v1/admin/cases/{id}`,{params:{path:{id:e}}})),[e]),a=Le(),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(`INTERNAL`),[d,f]=(0,l.useState)(),p=()=>(i.reload(),r()),m=i.data?.kase,h=i.data,g=m?.status===`CLOSED`;async function _(t){t.preventDefault();try{await w(C.POST(`/api/v1/admin/cases/{id}/messages`,{params:{path:{id:e}},body:{visibility:c,body:o}})),s(``),f(void 0),i.reload()}catch(e){f(e)}}return(0,D.jsxs)(Fe,{title:m?`${m.caseRef} · ${A(m.issueType)}`:`Case`,sub:m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(F,{value:m.status}),` · `,(0,D.jsx)(F,{value:m.priority}),` · opened `,k(m.createdAt)]}),onClose:n,wide:!0,children:[(0,D.jsx)(I,{error:i.error}),!h||!m?i.loading&&(0,D.jsx)(Ne,{}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`toolbar`,children:[!g&&(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>a.open(`decide`),children:`Record decision`}),!g&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open(`status`),children:`Change status`}),T(t,`support.case.escalate`)&&[`OPEN`,`IN_PROGRESS`].includes(m.status??``)&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open(`escalate`),children:`Escalate`}),m.issueType===`WARRANTY`&&T(t,`warranty.claim.decide`)&&(0,D.jsx)(`button`,{className:`btn`,onClick:()=>a.open(`warranty`),children:`Decide warranty claim`})]}),(0,D.jsx)(Ie,{items:[[`Summary`,m.summary],[`Booking`,m.bookingId&&(0,D.jsx)(`a`,{href:`#/bookings/${m.bookingId}`,className:`mono`,children:m.bookingRef})],[`Customer phone`,h.customerPhone&&(0,D.jsxs)(D.Fragment,{children:[h.customerPhone,h.phoneMasked&&(0,D.jsx)(`span`,{className:`faint`,children:` · masked`})]})],[`Owner`,m.ownerStaffId&&(0,D.jsx)(`span`,{className:`mono`,children:j(m.ownerStaffId)})],[`Resolved`,k(m.resolvedAt)]]}),(0,D.jsxs)(`div`,{className:`grid-2 tight`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Conversation`}),h.messages?.length===0&&(0,D.jsx)(Me,{children:`No messages`}),(0,D.jsx)(`ol`,{className:`thread`,children:h.messages?.map(e=>(0,D.jsxs)(`li`,{className:e.visibility===`INTERNAL`?`internal`:e.authorRole===`STAFF`?`staff`:void 0,children:[(0,D.jsxs)(`div`,{className:`meta`,children:[A(e.authorRole),e.visibility===`INTERNAL`&&` · internal note`,` · `,k(e.createdAt)]}),(0,D.jsx)(`div`,{children:e.body}),e.attachmentUrls&&e.attachmentUrls.length>0&&(0,D.jsxs)(`div`,{className:`faint`,children:[e.attachmentUrls.length,` attachment`,e.attachmentUrls.length>1?`s`:``]})]},e.id))}),!g&&(0,D.jsxs)(`form`,{className:`composer`,onSubmit:_,children:[(0,D.jsx)(`textarea`,{rows:3,value:o,onChange:e=>s(e.target.value),placeholder:c===`INTERNAL`?`Note for staff only`:`Reply to the customer`,required:!0,onKeyDown:e=>e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&e.currentTarget.form?.requestSubmit()}),(0,D.jsxs)(`div`,{className:`composer-row`,children:[(0,D.jsx)(`div`,{className:`seg`,role:`radiogroup`,"aria-label":`Visibility`,children:[`INTERNAL`,`PUBLIC`].map(e=>(0,D.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":c===e,className:c===e?`on`:void 0,onClick:()=>u(e),children:e===`INTERNAL`?`Internal note`:`To customer`},e))}),(0,D.jsxs)(`button`,{className:`btn primary`,children:[`Send `,(0,D.jsx)(`kbd`,{children:`Ctrl ↵`})]})]}),(0,D.jsx)(I,{error:d})]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Decisions`}),h.decisions?.length===0?(0,D.jsx)(Me,{children:`None yet`}):(0,D.jsx)(`ul`,{className:`plain`,children:h.decisions?.map(e=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`strong`,{children:A(e.decision)}),` `,O(e.amountMinor),` `,(0,D.jsxs)(`span`,{className:`faint`,children:[`· `,k(e.createdAt),e.note?` · ${e.note}`:``]})]},e.id))}),(0,D.jsx)(`h3`,{className:`section`,children:`Payments`}),h.payments?.length===0?(0,D.jsx)(Me,{}):(0,D.jsx)(`table`,{className:`table mini`,children:(0,D.jsx)(`tbody`,{children:h.payments?.map(e=>(0,D.jsxs)(`tr`,{children:[(0,D.jsxs)(`td`,{children:[A(e.purpose),(0,D.jsx)(`div`,{className:`faint`,children:A(e.method??e.mode)})]}),(0,D.jsx)(`td`,{children:(0,D.jsx)(F,{value:e.status})}),(0,D.jsx)(`td`,{className:`num`,children:O(e.amountMinor,e.currency)}),(0,D.jsx)(`td`,{children:T(t,`remedy.propose`)&&e.status===`CAPTURED`&&(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>a.open({refund:e.paymentId}),children:`Refund`})})]},e.paymentId))})}),(0,D.jsx)(`h3`,{className:`section`,children:`Refunds`}),h.refunds?.length===0?(0,D.jsx)(Me,{}):(0,D.jsx)(`ul`,{className:`plain`,children:h.refunds?.map(e=>(0,D.jsxs)(`li`,{children:[O(e.amountMinor),` `,(0,D.jsx)(F,{value:e.status}),` `,(0,D.jsxs)(`span`,{className:`faint`,children:[`· `,A(e.reasonCode),` · `,k(e.createdAt)]})]},e.id))}),(0,D.jsx)(`h3`,{className:`section`,children:`Credits`}),h.credits?.length===0?(0,D.jsx)(Me,{}):(0,D.jsx)(`ul`,{className:`plain`,children:h.credits?.map(e=>(0,D.jsxs)(`li`,{children:[O(e.amountMinor,e.currency),` `,(0,D.jsxs)(`span`,{className:`faint`,children:[`· `,A(e.reasonCode),e.expiresAt?` · expires ${k(e.expiresAt)}`:``]})]},e.id))})]})]}),(0,D.jsx)(`h3`,{className:`section`,children:`Booking timeline`}),h.timeline?.length===0&&(0,D.jsx)(Me,{}),(0,D.jsx)(`ol`,{className:`timeline`,children:h.timeline?.map((e,t)=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(`time`,{children:k(e.at)}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:e.from?(0,D.jsxs)(D.Fragment,{children:[A(e.from),` → `,A(e.to)]}):A(e.to)}),(0,D.jsxs)(`span`,{className:`faint`,children:[` · `,A(e.actorType),e.reason?` · ${ze(e.reason)}`:``]})]})]},t))}),h.evidence&&h.evidence.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Job evidence`}),(0,D.jsx)(`ul`,{className:`plain`,children:h.evidence.map((e,t)=>(0,D.jsxs)(`li`,{children:[A(e.stage),` · `,e.itemCode,` `,(0,D.jsxs)(`span`,{className:`faint`,children:[`· `,k(e.capturedAt)]})]},t))})]}),h.chat&&h.chat.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`h3`,{className:`section`,children:`Customer–pro chat`}),(0,D.jsx)(`ol`,{className:`thread compact`,children:h.chat.map((e,t)=>(0,D.jsxs)(`li`,{children:[(0,D.jsxs)(`div`,{className:`meta`,children:[A(e.senderRole),` · `,k(e.at)]}),(0,D.jsx)(`div`,{children:e.body})]},t))})]})]}),m&&a.value===`status`&&(0,D.jsx)(vt,{k:m,onClose:a.close,onDone:p}),m&&a.value===`decide`&&(0,D.jsx)(yt,{id:e,onClose:a.close,onDone:p}),m&&a.value===`escalate`&&(0,D.jsx)(bt,{id:e,onClose:a.close,onDone:p}),m&&a.value===`warranty`&&(0,D.jsx)(xt,{onClose:a.close,onDone:p}),m&&typeof a.value==`object`&&a.value&&(0,D.jsx)(St,{paymentId:a.value.refund,onClose:a.close,onDone:p})]})}function vt({k:e,onClose:t,onDone:n}){let r=mt[e.status??``]??[],[i,a]=(0,l.useState)(r[0]??``),[o,s]=(0,l.useState)(e.priority??`NORMAL`);return(0,D.jsxs)(L,{title:`Change status`,onClose:t,onSubmit:()=>w(C.PATCH(`/api/v1/admin/cases/{id}`,{params:{path:{id:e.id}},body:{status:i||void 0,priority:o,version:e.version}})).then(n),children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,D.jsxs)(`option`,{value:``,children:[`Keep `,A(e.status)]}),r.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))]})}),(0,D.jsx)(R,{label:`Priority`,children:(0,D.jsx)(`select`,{value:o,onChange:e=>s(e.target.value),children:pt.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})})]})}function yt({id:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(`NO_ACTION`),[a,o]=(0,l.useState)(``),[s,c]=(0,l.useState)(``),u=r===`REFUND`||r===`CREDIT`;return(0,D.jsxs)(L,{title:`Record decision`,onClose:t,note:r===`REFUND`?`Proposes a refund on the booking payment; finance approves it.`:r===`CREDIT`?`Grants wallet credit to the customer now.`:void 0,onSubmit:()=>w(C.POST(`/api/v1/admin/cases/{id}/decisions`,{params:{path:{id:e}},body:{decision:r,amountMinor:u?Math.round(Number(a)*100):void 0,note:s}})).then(n),children:[(0,D.jsx)(R,{label:`Decision`,children:(0,D.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:ht.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})}),u&&(0,D.jsx)(R,{label:`Amount (₹)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,step:`0.01`,value:a,onChange:e=>o(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Note`,children:(0,D.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),required:!0,maxLength:2e3})})]})}function bt({id:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(``);return(0,D.jsx)(L,{title:`Escalate case`,submit:`Escalate`,onClose:t,onSubmit:()=>w(C.POST(`/api/v1/admin/cases/{id}/escalate`,{params:{path:{id:e}},body:{note:r}})).then(n),children:(0,D.jsx)(R,{label:`Why`,children:(0,D.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),required:!0,maxLength:2e3})})})}function xt({onClose:e,onDone:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(!0),[o,s]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Decide warranty claim`,onClose:e,note:`The API doesn't return the claim ID with the case yet; ask engineering for it until that lands.`,onSubmit:()=>w(C.POST(`/api/v1/admin/warranty-claims/{id}/decision`,{params:{path:{id:n.trim()}},body:{approve:i,note:o}})).then(t),children:[(0,D.jsx)(R,{label:`Claim ID`,children:(0,D.jsx)(`input`,{className:`mono`,value:n,onChange:e=>r(e.target.value),required:!0,pattern:`[0-9a-fA-F-]{36}`})}),(0,D.jsxs)(`div`,{className:`seg`,role:`radiogroup`,"aria-label":`Decision`,children:[(0,D.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i,className:i?`on`:void 0,onClick:()=>a(!0),children:`Approve`}),(0,D.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":!i,className:i?void 0:`on`,onClick:()=>a(!1),children:`Reject`})]}),(0,D.jsx)(R,{label:i?`Note`:`Reason sent to the customer`,children:(0,D.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),required:!0})})]})}function St({paymentId:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(`SERVICE_ISSUE`),[s,c]=(0,l.useState)(``),[u]=(0,l.useState)(le);return(0,D.jsxs)(L,{title:`Propose refund`,note:`Goes to finance for approval.`,onClose:t,onSubmit:()=>w(C.POST(`/api/v1/admin/refunds`,{params:{header:{"Idempotency-Key":u}},body:{paymentId:e,amountMinor:Math.round(Number(r)*100),reasonCode:a,note:s}})).then(n),children:[(0,D.jsx)(R,{label:`Amount (₹)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,step:`0.01`,value:r,onChange:e=>i(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Reason code`,children:(0,D.jsx)(`input`,{value:a,onChange:e=>o(e.target.value.toUpperCase()),required:!0,pattern:`[A-Z_]+`})}),(0,D.jsx)(R,{label:`Note`,children:(0,D.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),required:!0})})]})}var Ct=[`REQUESTED`,`APPROVED`,`PROCESSING`,`SUCCEEDED`,`FAILED`,`REJECTED`];function wt({me:e}){let[t,n]=(0,l.useState)(`REQUESTED`),r=P(e=>w(C.GET(`/api/v1/admin/refunds`,{params:{query:{status:t||void 0,cursor:e,limit:50}}})),[t]),i=Le(),a=T(e,`refund.approve`);return(0,D.jsxs)(ke,{title:`Refunds`,sub:`Proposed by support, approved by finance. Approved refunds go to the payment gateway within a minute.`,children:[(0,D.jsxs)(`div`,{className:`tabs`,role:`tablist`,children:[Ct.map(e=>(0,D.jsx)(`button`,{role:`tab`,"aria-selected":t===e,className:t===e?`on`:void 0,onClick:()=>n(e),children:A(e)},e)),(0,D.jsx)(`button`,{role:`tab`,"aria-selected":t===``,className:t===``?`on`:void 0,onClick:()=>n(``),children:`All`})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:r.rows,loading:r.loading,error:r.error,more:r.more,rowKey:e=>e.id,cols:[{key:`at`,label:`Requested`,render:e=>k(e.createdAt),width:130},{key:`amt`,label:`Amount`,render:e=>O(e.amountMinor),num:!0,width:110},{key:`rc`,label:`Reason`,render:e=>(0,D.jsxs)(D.Fragment,{children:[A(e.reasonCode),e.note&&(0,D.jsx)(`div`,{className:`faint clip`,children:e.note})]})},{key:`src`,label:`Source`,render:e=>A(e.source),width:140},{key:`bk`,label:`Booking`,render:e=>e.bookingId&&(0,D.jsx)(`a`,{className:`mono`,href:`#/bookings/${e.bookingId}`,children:j(e.bookingId)}),width:100},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:120},{key:`a`,label:``,width:170,render:t=>a&&t.status===`REQUESTED`&&(0,D.jsxs)(`span`,{className:`row-actions`,children:[(0,D.jsx)(`button`,{className:`btn small primary`,disabled:t.requestedBy===e.id,title:t.requestedBy===e.id?`You proposed this refund; another finance admin approves it`:void 0,onClick:()=>i.open({r:t,approve:!0}),children:`Approve`}),(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>i.open({r:t,approve:!1}),children:`Reject`})]})}]})}),i.value&&(0,D.jsx)(Tt,{...i.value,onClose:i.close,onDone:r.reload})]})}function Tt({r:e,approve:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(``),[o]=(0,l.useState)(le);return(0,D.jsx)(L,{title:`${t?`Approve`:`Reject`} refund of ${O(e.amountMinor)}`,submit:t?`Approve`:`Reject`,tone:t?void 0:`danger`,onClose:n,onSubmit:()=>w(C.POST(`/api/v1/admin/refunds/{id}/decision`,{params:{path:{id:e.id},header:{"Idempotency-Key":o}},body:{decision:t?`APPROVE`:`REJECT`,note:i}})).then(r),children:(0,D.jsx)(R,{label:`Note`,children:(0,D.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),required:!0})})})}function Et({me:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(),a=P(t=>T(e,`audit.view`)?w(C.GET(`/api/v1/admin/audit`,{params:{query:{action:`CREDIT_GRANTED`,cursor:t,limit:50}}})):Promise.resolve({items:void 0}),[r]);return(0,D.jsxs)(ke,{title:`Credits`,sub:`Wallet credit a customer spends on a later booking.`,actions:(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>n(!0),children:`Grant credit`}),children:[(0,D.jsxs)(Ae,{children:[(0,D.jsxs)(`p`,{children:[`The usual way to grant credit is a `,(0,D.jsx)(`strong`,{children:`Credit`}),` decision on a case: it ties the credit to the booking and the customer without looking anything up. Use `,(0,D.jsx)(`em`,{children:`Grant credit`}),` here for goodwill outside a case.`]}),(0,D.jsx)(`p`,{className:`faint`,children:`The API can't look up a customer yet, so a grant here needs the customer ID.`}),r&&(0,D.jsxs)(`p`,{children:[`Last grant: `,(0,D.jsx)(`span`,{className:`mono`,children:r})]})]}),T(e,`audit.view`)&&(0,D.jsx)(Ae,{title:`Grants`,flush:!0,children:(0,D.jsx)(Pe,{rows:a.rows,loading:a.loading,error:a.error,more:a.more,rowKey:e=>e.id,cols:[{key:`at`,label:`When`,render:e=>k(e.at),width:140},{key:`amt`,label:`Amount`,render:e=>O(e.after?.amountMinor),num:!0,width:100},{key:`rc`,label:`Reason code`,render:e=>A(e.after?.reasonCode),width:150},{key:`cust`,label:`Customer`,render:e=>j(e.entityId),mono:!0,width:100},{key:`note`,label:`Note`,render:e=>(0,D.jsx)(`span`,{className:`clip`,children:e.reason})},{key:`by`,label:`By`,render:e=>e.actorRoles?.map(A).join(`, `)}]})}),t&&(0,D.jsx)(Dt,{onClose:()=>n(!1),onDone:i})]})}function Dt({onClose:e,onDone:t}){let[n,r]=(0,l.useState)({customerId:``,amount:``,reasonCode:`GOODWILL`,bookingId:``,note:``}),i=e=>t=>r({...n,[e]:t.target.value}),[a]=(0,l.useState)(le);return(0,D.jsxs)(L,{title:`Grant credit`,onClose:e,onSubmit:async()=>{let e=await w(C.POST(`/api/v1/admin/credits`,{params:{header:{"Idempotency-Key":a}},body:{customerId:n.customerId.trim(),amountMinor:Math.round(Number(n.amount)*100),reasonCode:n.reasonCode,bookingId:n.bookingId.trim()||void 0,note:n.note}}));t(`${O(e.amountMinor,e.currency)} · ${e.reasonCode}${e.expiresAt?` · expires ${k(e.expiresAt)}`:``}`)},children:[(0,D.jsx)(R,{label:`Customer ID`,children:(0,D.jsx)(`input`,{className:`mono`,value:n.customerId,onChange:i(`customerId`),required:!0,pattern:`[0-9a-fA-F-]{36}`})}),(0,D.jsx)(R,{label:`Amount (₹)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,step:`0.01`,value:n.amount,onChange:i(`amount`),required:!0})}),(0,D.jsx)(R,{label:`Reason code`,children:(0,D.jsx)(`input`,{value:n.reasonCode,onChange:i(`reasonCode`),required:!0,maxLength:40})}),(0,D.jsx)(R,{label:`Booking ID (optional)`,children:(0,D.jsx)(`input`,{className:`mono`,value:n.bookingId,onChange:i(`bookingId`),pattern:`[0-9a-fA-F-]{36}`})}),(0,D.jsx)(Re,{value:n.note,onChange:e=>r({...n,note:e})})]})}function Ot({me:e}){let t=P(e=>w(C.GET(`/api/v1/admin/settlements`,{params:{query:{cursor:e,limit:50}}})),[]),n=N(()=>w(C.GET(`/api/v1/admin/finance/ledger-check`)),[]),[r,i]=(0,l.useState)(),[a,o]=(0,l.useState)(!1),s=T(e,`settlement.manage`),c=n.data;return(0,D.jsxs)(ke,{title:`Settlements`,sub:`Payout batches to professionals. A batch collects available earnings up to its period end.`,actions:s&&(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>o(!0),children:`New batch`}),children:[(0,D.jsxs)(Ae,{title:`Ledger check`,aside:(0,D.jsx)(`button`,{className:`btn small`,onClick:n.reload,children:`Re-run`}),children:[(0,D.jsx)(I,{error:n.error}),c?(0,D.jsxs)(`div`,{className:`strip inline`,children:[(0,D.jsxs)(`div`,{className:`stat ${c.unbalancedTransactions?`bad`:``}`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Unbalanced transactions`}),(0,D.jsx)(`span`,{className:`stat-value`,children:c.unbalancedTransactions??``})]}),(0,D.jsxs)(`div`,{className:`stat`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Pro payable balance`}),(0,D.jsx)(`span`,{className:`stat-value`,children:O(c.proPayableBalanceMinor)})]}),(0,D.jsxs)(`div`,{className:`stat`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Unpaid earnings`}),(0,D.jsx)(`span`,{className:`stat-value`,children:O(c.unpaidEarningsMinor)})]}),(0,D.jsxs)(`div`,{className:`stat ${c.payableMatchesEarnings===!1?`bad`:``}`,children:[(0,D.jsx)(`span`,{className:`stat-label`,children:`Payable matches earnings`}),(0,D.jsx)(`span`,{className:`stat-value`,children:c.payableMatchesEarnings==null?``:c.payableMatchesEarnings?`Yes`:`No`})]})]}):n.loading&&(0,D.jsx)(Ne,{})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:t.rows,loading:t.loading,error:t.error,more:t.more,rowKey:e=>e.id,selected:r,onOpen:e=>i(e.id),cols:[{key:`ref`,label:`Batch`,render:e=>e.batchRef,mono:!0,width:170},{key:`pe`,label:`Period end`,render:e=>ve(e.periodEnd),width:130},{key:`tot`,label:`Total`,render:e=>O(e.totalMinor),num:!0,width:120},{key:`pros`,label:`Pros`,render:e=>e.lines?.length??``,num:!0,width:70},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:120},{key:`c`,label:`Created`,render:e=>k(e.createdAt),width:140},{key:`p`,label:`Paid`,render:e=>k(e.paidAt),width:140}]})}),r&&(0,D.jsx)(kt,{id:r,manage:s,onClose:()=>i(void 0),onChanged:()=>(t.reload(),n.reload())}),a&&(0,D.jsx)(At,{onClose:()=>o(!1),onDone:e=>(t.reload(),i(e.id))})]})}function kt({id:e,manage:t,onClose:n,onChanged:r}){let i=N(()=>w(C.GET(`/api/v1/admin/settlements/{id}`,{params:{path:{id:e}}})),[e]),a=Oe(),[o]=(0,l.useState)(le),s=i.data,c=()=>(i.reload(),r());return(0,D.jsxs)(Fe,{title:s?.batchRef??`Batch`,sub:s&&(0,D.jsx)(F,{value:s.status}),onClose:n,children:[(0,D.jsx)(I,{error:i.error??a.error}),s?(0,D.jsxs)(D.Fragment,{children:[t&&s.status===`DRAFT`&&(0,D.jsxs)(`div`,{className:`toolbar`,children:[(0,D.jsx)(`button`,{className:`btn primary`,disabled:a.busy,onClick:()=>a.run(()=>w(C.POST(`/api/v1/admin/settlements/{id}/approve`,{params:{path:{id:e},header:{"Idempotency-Key":o}}})).then(c),`Batch approved`),children:`Approve payout`}),(0,D.jsx)(`button`,{className:`btn danger-ghost`,disabled:a.busy,onClick:()=>a.run(()=>w(C.POST(`/api/v1/admin/settlements/{id}/cancel`,{params:{path:{id:e}}})).then(c),`Batch cancelled`),children:`Cancel batch`})]}),(0,D.jsx)(Ie,{items:[[`Period end`,ve(s.periodEnd)],[`Total`,O(s.totalMinor)],[`Created`,k(s.createdAt)],[`Created by`,s.createdBy&&(0,D.jsx)(`span`,{className:`mono`,children:j(s.createdBy)})],[`Approved by`,s.approvedBy&&(0,D.jsx)(`span`,{className:`mono`,children:j(s.approvedBy)})],[`Paid`,k(s.paidAt)]]}),(0,D.jsx)(`h3`,{className:`section`,children:`Lines`}),s.lines?.length?(0,D.jsxs)(`table`,{className:`table mini`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{children:`Professional`}),(0,D.jsx)(`th`,{className:`num`,children:`Earnings`}),(0,D.jsx)(`th`,{className:`num`,children:`Amount`})]})}),(0,D.jsx)(`tbody`,{children:s.lines.map(e=>(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`td`,{children:(0,D.jsx)(`a`,{className:`mono`,href:`#/professionals/${e.professionalId}`,children:j(e.professionalId)})}),(0,D.jsx)(`td`,{className:`num`,children:e.earningCount}),(0,D.jsx)(`td`,{className:`num`,children:O(e.amountMinor)})]},e.professionalId))})]}):(0,D.jsx)(Me,{})]}):i.loading&&(0,D.jsx)(Ne,{})]})}function At({onClose:e,onDone:t}){let[n,r]=(0,l.useState)(ye(-1));return(0,D.jsx)(L,{title:`New settlement batch`,note:`Collects every available earning up to and including this date.`,submit:`Create draft`,onClose:e,onSubmit:()=>w(C.POST(`/api/v1/admin/settlements`,{body:{periodEnd:n}})).then(t),children:(0,D.jsx)(R,{label:`Period end`,children:(0,D.jsx)(`input`,{type:`date`,value:n,max:ye(),onChange:e=>r(e.target.value),required:!0})})})}function jt(){let e=P(e=>w(C.GET(`/api/v1/admin/coupons`,{params:{query:{cursor:e,limit:50}}})),[]),t=Le();return(0,D.jsxs)(ke,{title:`Coupons & tax`,sub:`Discount codes customers enter at checkout, and the tax rates applied to bookings.`,actions:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`button`,{className:`btn`,onClick:()=>t.open(`tax`),children:`Add tax rate`}),(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>t.open(`coupon`),children:`New coupon`})]}),children:[(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:e.rows,loading:e.loading,error:e.error,more:e.more,rowKey:e=>e.id,onOpen:e=>t.open({c:e}),cols:[{key:`code`,label:`Code`,render:e=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`strong`,{className:`mono`,children:e.code}),(0,D.jsx)(`div`,{className:`faint`,children:e.description})]})},{key:`off`,label:`Discount`,render:e=>e.discountType===`PERCENT`?`${(e.percentOffBps??0)/100}% off${e.maxDiscountMinor?` up to ${O(e.maxDiscountMinor)}`:``}`:`${O(e.amountOffMinor)} off`},{key:`min`,label:`Min order`,render:e=>e.minOrderMinor?O(e.minOrderMinor):``,num:!0},{key:`used`,label:`Used`,render:e=>(0,D.jsxs)(D.Fragment,{children:[e.redeemedCount??``,e.totalLimit!=null&&(0,D.jsxs)(`span`,{className:`faint`,children:[` / `,e.totalLimit]})]}),num:!0},{key:`rules`,label:`Rules`,render:e=>[e.firstOrderOnly&&`First order`,e.perCustomerLimit&&`${e.perCustomerLimit} per customer`].filter(Boolean).join(` · `)},{key:`valid`,label:`Valid`,render:e=>`${ve(e.validFrom)} – ${ve(e.validTo)}`},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:100}]})}),t.value===`coupon`&&(0,D.jsx)(Nt,{onClose:t.close,onDone:e.reload}),t.value===`tax`&&(0,D.jsx)(Pt,{onClose:t.close}),typeof t.value==`object`&&t.value&&(0,D.jsx)(Mt,{c:t.value.c,onClose:t.close,onDone:e.reload})]})}function Mt({c:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(e.status===`ACTIVE`?`PAUSED`:`ACTIVE`),[a,o]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Coupon ${e.code}`,submit:`Change status`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/coupons/{id}/status`,{params:{path:{id:e.id}},body:{status:r,reason:a}})).then(n),children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:[`ACTIVE`,`PAUSED`,`EXPIRED`].map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})}),(0,D.jsx)(Re,{value:a,onChange:o})]})}function Nt({onClose:e,onDone:t}){let[n,r]=(0,l.useState)({code:``,description:``,discountType:`PERCENT`,percent:``,amount:``,max:``,min:``,validFrom:ye(),validTo:ye(30),totalLimit:``,perCustomerLimit:`1`,firstOrderOnly:!1}),i=e=>t=>r({...n,[e]:t.target.type===`checkbox`?t.target.checked:t.target.value}),a=e=>e?Math.round(Number(e)*100):void 0,o=e=>e?Number(e):void 0,s=n.discountType===`PERCENT`;return(0,D.jsx)(L,{title:`New coupon`,onClose:e,onSubmit:()=>w(C.POST(`/api/v1/admin/coupons`,{body:{code:n.code.trim().toUpperCase(),description:n.description,discountType:n.discountType,percentOffBps:s?Math.round(Number(n.percent)*100):void 0,amountOffMinor:s?void 0:a(n.amount),maxDiscountMinor:s?a(n.max):void 0,minOrderMinor:a(n.min),validFrom:new Date(`${n.validFrom}T00:00:00+05:30`).toISOString(),validTo:new Date(`${n.validTo}T23:59:59+05:30`).toISOString(),totalLimit:o(n.totalLimit),perCustomerLimit:o(n.perCustomerLimit),firstOrderOnly:n.firstOrderOnly}})).then(t),children:(0,D.jsxs)(`div`,{className:`form-grid`,children:[(0,D.jsx)(R,{label:`Code`,children:(0,D.jsx)(`input`,{className:`mono`,value:n.code,onChange:i(`code`),required:!0,pattern:`[A-Za-z0-9]{3,20}`})}),(0,D.jsx)(R,{label:`Type`,children:(0,D.jsxs)(`select`,{value:n.discountType,onChange:i(`discountType`),children:[(0,D.jsx)(`option`,{value:`PERCENT`,children:`Percent`}),(0,D.jsx)(`option`,{value:`FLAT`,children:`Flat amount`})]})}),(0,D.jsx)(R,{label:`Description`,wide:!0,children:(0,D.jsx)(`input`,{value:n.description,onChange:i(`description`),required:!0})}),s?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(R,{label:`Percent off`,children:(0,D.jsx)(`input`,{type:`number`,min:1,max:100,step:`0.01`,value:n.percent,onChange:i(`percent`),required:!0})}),(0,D.jsx)(R,{label:`Cap (₹, optional)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,value:n.max,onChange:i(`max`)})})]}):(0,D.jsx)(R,{label:`Amount off (₹)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,value:n.amount,onChange:i(`amount`),required:!0})}),(0,D.jsx)(R,{label:`Min order (₹, optional)`,children:(0,D.jsx)(`input`,{type:`number`,min:0,value:n.min,onChange:i(`min`)})}),(0,D.jsx)(R,{label:`Valid from`,children:(0,D.jsx)(`input`,{type:`date`,value:n.validFrom,onChange:i(`validFrom`),required:!0})}),(0,D.jsx)(R,{label:`Valid to`,children:(0,D.jsx)(`input`,{type:`date`,value:n.validTo,onChange:i(`validTo`),required:!0})}),(0,D.jsx)(R,{label:`Total uses (optional)`,children:(0,D.jsx)(`input`,{type:`number`,min:1,value:n.totalLimit,onChange:i(`totalLimit`)})}),(0,D.jsx)(R,{label:`Uses per customer`,children:(0,D.jsx)(`input`,{type:`number`,min:1,value:n.perCustomerLimit,onChange:i(`perCustomerLimit`)})}),(0,D.jsxs)(`label`,{className:`check`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:n.firstOrderOnly,onChange:i(`firstOrderOnly`)}),` First order only`]})]})})}function Pt({onClose:e}){let t=N(()=>E(),[]),n=N(()=>he(),[]),[r,i]=(0,l.useState)({cityId:``,categoryId:``,name:`GST`,rate:`18`,from:ye(1)}),[a,o]=(0,l.useState)(``),s=e=>t=>i({...r,[e]:t.target.value});return(0,D.jsxs)(L,{title:`Add tax rate`,note:`Applies to checkouts from the date given. Existing rates can't be listed from the console yet.`,onClose:e,onSubmit:()=>w(C.POST(`/api/v1/admin/tax-rates`,{body:{cityId:r.cityId||void 0,categoryId:r.categoryId||void 0,name:r.name,rateBps:Math.round(Number(r.rate)*100),effectiveFrom:new Date(`${r.from}T00:00:00+05:30`).toISOString(),reason:a}})).then(()=>Ee(`Tax rate added`)),children:[(0,D.jsxs)(`div`,{className:`form-grid`,children:[(0,D.jsx)(R,{label:`City`,children:(0,D.jsxs)(`select`,{value:r.cityId,onChange:s(`cityId`),children:[(0,D.jsx)(`option`,{value:``,children:`All cities`}),t.data?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(R,{label:`Category`,children:(0,D.jsxs)(`select`,{value:r.categoryId,onChange:s(`categoryId`),children:[(0,D.jsx)(`option`,{value:``,children:`All categories`}),n.data?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(R,{label:`Name`,children:(0,D.jsx)(`input`,{value:r.name,onChange:s(`name`),required:!0})}),(0,D.jsx)(R,{label:`Rate (%)`,children:(0,D.jsx)(`input`,{type:`number`,min:0,max:100,step:`0.01`,value:r.rate,onChange:s(`rate`),required:!0})}),(0,D.jsx)(R,{label:`Effective from`,children:(0,D.jsx)(`input`,{type:`date`,value:r.from,onChange:s(`from`),required:!0})})]}),(0,D.jsx)(Re,{value:a,onChange:o})]})}var Ft=[`APPLIED`,`VERIFIED`,`ACTIVE`,`SUSPENDED`,`OFFBOARDED`];function It(){return N(async()=>{let e=await E();return(await Promise.all(e.map(e=>w(C.GET(`/api/v1/admin/cities/{cityId}/zones`,{params:{path:{cityId:e.id}}})).then(t=>t.map(t=>({...t,city:e.name})))))).flat()},[])}function Lt({me:e}){let t=be(),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),o=It(),s=P(e=>w(C.GET(`/api/v1/admin/professionals`,{params:{query:{status:n||void 0,zoneId:i||void 0,cursor:e,limit:50}}})),[n,i]),c=e=>o.data?.find(t=>t.id===e)?.name??j(e),u=t[1];return(0,D.jsxs)(ke,{title:`Professionals`,sub:`Verification, skills, service zones and daily capacity.`,children:[(0,D.jsxs)(`div`,{className:`filters`,role:`search`,children:[(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Any`}),Ft.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))]})}),o.data&&o.data.length>0&&(0,D.jsx)(R,{label:`Zone`,children:(0,D.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Any`}),o.data.map(e=>(0,D.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.city]},e.id))]})})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:s.rows,loading:s.loading,error:s.error,more:s.more,rowKey:e=>e.id,selected:u,onOpen:e=>Se(`professionals/${e.id}`),cols:[{key:`n`,label:`Name`,render:e=>(0,D.jsx)(`strong`,{children:e.displayName})},{key:`sk`,label:`Skills`,render:e=>e.skills?.map(A).join(`, `)},{key:`z`,label:`Zones`,render:e=>e.zones?.map(c).join(`, `)},{key:`max`,label:`Max jobs/day`,render:e=>e.maxJobsPerDay??``,num:!0,width:110},{key:`on`,label:`Presence`,render:e=>e.online==null?``:(0,D.jsx)(`span`,{className:`status ${e.online?`ok`:`mute`}`,children:e.online?`Online`:`Offline`}),width:100},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:120}]})}),u&&(0,D.jsx)(Rt,{id:u,me:e,zones:o.data,onClose:()=>Se(`professionals`),onChanged:s.reload})]})}function Rt({id:e,me:t,zones:n,onClose:r,onChanged:i}){let a=N(()=>w(C.GET(`/api/v1/admin/professionals/{id}`,{params:{path:{id:e}}})),[e]),o=Le(),s=T(t,`professional.verify`),c=a.data,l=()=>(a.reload(),i());return(0,D.jsxs)(Fe,{title:c?.displayName??`Professional`,sub:c&&(0,D.jsx)(F,{value:c.status}),onClose:r,children:[(0,D.jsx)(I,{error:a.error}),c?(0,D.jsxs)(D.Fragment,{children:[s&&(0,D.jsxs)(`div`,{className:`toolbar`,children:[(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>o.open(`status`),children:`Change status`}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>o.open(`skills`),children:`Skills`}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>o.open(`zones`),children:`Zones`}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>o.open(`max`),children:`Daily capacity`})]}),(0,D.jsx)(Ie,{items:[[`Presence`,c.online==null?``:c.online?`Online`:`Offline`],[`Skills`,c.skills?.map(A).join(`, `)],[`Zones`,c.zones?.map(e=>{let t=n?.find(t=>t.id===e);return t?`${t.name} · ${t.city}`:j(e)}).join(`; `)],[`Max jobs a day`,c.maxJobsPerDay],[`Bio`,c.bio],[`ID`,(0,D.jsx)(`span`,{className:`mono`,children:c.id})]]})]}):a.loading&&(0,D.jsx)(Ne,{}),c&&o.value===`status`&&(0,D.jsx)(zt,{p:c,onClose:o.close,onDone:l}),c&&o.value===`skills`&&(0,D.jsx)(Bt,{p:c,onClose:o.close,onDone:l}),c&&o.value===`zones`&&(0,D.jsx)(Vt,{p:c,zones:n??[],onClose:o.close,onDone:l}),c&&o.value===`max`&&(0,D.jsx)(Ht,{p:c,onClose:o.close,onDone:l})]})}function zt({p:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(e.status===`ACTIVE`?`SUSPENDED`:`ACTIVE`),[a,o]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Status for ${e.displayName}`,onClose:t,tone:r===`SUSPENDED`||r===`OFFBOARDED`?`danger`:void 0,onSubmit:()=>w(C.POST(`/api/v1/admin/professionals/{id}/status`,{params:{path:{id:e.id}},body:{status:r,reason:a}})).then(n),children:[(0,D.jsx)(R,{label:`New status`,children:(0,D.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:Ft.filter(t=>t!==e.status).map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})}),(0,D.jsx)(Re,{value:a,onChange:o})]})}function Bt({p:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)((e.skills??[]).join(`, `)),[a,o]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Skills`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/professionals/{id}/skills`,{params:{path:{id:e.id}},body:{skills:r.split(/[\s,]+/).filter(Boolean).map(e=>e.toUpperCase()),reason:a}})).then(n),children:[(0,D.jsx)(R,{label:`Skills`,hint:`Codes matched against each service's required skill, e.g. AC_TECHNICIAN, DEEP_CLEANING.`,children:(0,D.jsx)(`input`,{className:`mono`,value:r,onChange:e=>i(e.target.value)})}),(0,D.jsx)(Re,{value:a,onChange:o})]})}function Vt({p:e,zones:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(new Set(e.zones??[])),[o,s]=(0,l.useState)(``),c=e=>a(t=>t.has(e)?(t.delete(e),new Set(t)):new Set(t.add(e)));return(0,D.jsxs)(L,{title:`Service zones`,onClose:n,onSubmit:()=>w(C.PUT(`/api/v1/admin/professionals/{id}/zones`,{params:{path:{id:e.id}},body:{zoneIds:[...i],reason:o}})).then(r),children:[t.length===0?(0,D.jsx)(`p`,{className:`faint`,children:`Zone names need the zone.manage permission.`}):(0,D.jsx)(`div`,{className:`pick-list`,children:t.map(e=>(0,D.jsxs)(`label`,{className:i.has(e.id)?`on`:void 0,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:i.has(e.id),onChange:()=>c(e.id)}),(0,D.jsxs)(`span`,{className:`pick-main`,children:[(0,D.jsx)(`strong`,{children:e.name}),(0,D.jsx)(`span`,{className:`faint`,children:e.city})]})]},e.id))}),(0,D.jsx)(Re,{value:o,onChange:s})]})}function Ht({p:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(String(e.maxJobsPerDay??``)),[a,o]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Daily capacity`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/professionals/{id}/max-jobs`,{params:{path:{id:e.id}},body:{maxJobsPerDay:Number(r),reason:a}})).then(n),children:[(0,D.jsx)(R,{label:`Max jobs a day`,children:(0,D.jsx)(`input`,{type:`number`,min:1,max:20,value:r,onChange:e=>i(e.target.value),required:!0})}),(0,D.jsx)(Re,{value:a,onChange:o})]})}function Ut({me:e}){let t=N(()=>E(),[]),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),o=N(()=>w(C.GET(`/api/v1/admin/settings`,{params:{query:{cityId:n||void 0}}})),[n]),[s,c]=(0,l.useState)(),u=o.data?.filter(e=>`${e.key} ${e.description}`.toLowerCase().includes(i.toLowerCase()));return(0,D.jsxs)(ke,{title:`Settings`,sub:`Numbers the platform runs on. A city value overrides the global one; unset keys use the built-in default.`,children:[(0,D.jsxs)(`div`,{className:`filters`,role:`search`,children:[(0,D.jsx)(R,{label:`Scope`,children:(0,D.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Global`}),t.data?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(R,{label:`Find`,children:(0,D.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`Key or description`})})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:u,loading:o.loading,error:o.error,rowKey:e=>e.key,onOpen:c,cols:[{key:`k`,label:`Key`,render:e=>e.key,mono:!0,width:300},{key:`d`,label:`Meaning`,render:e=>e.description},{key:`v`,label:`Value`,render:e=>e.value==null?``:e.key?.endsWith(`_minor`)?O(e.value):e.value.toLocaleString(`en-IN`),num:!0,width:110},{key:`s`,label:`Source`,render:e=>A(e.source),width:100}]})}),s&&(0,D.jsx)(Wt,{s,cityId:n,cityName:t.data?.find(e=>e.id===n)?.name,me:e,onClose:()=>c(void 0),onDone:o.reload})]})}function Wt({s:e,cityId:t,cityName:n,me:r,onClose:i,onDone:a}){let[o,s]=(0,l.useState)(String(e.value??``)),[c,u]=(0,l.useState)(``),d=t?e.source===`CITY`:e.source===`GLOBAL`;return(0,D.jsxs)(L,{title:e.key,note:(0,D.jsxs)(D.Fragment,{children:[e.description,`. Saving sets the `,n?`${n} value`:`global value`,`.`,!T(r,`policy.manage`)&&` Your role can change settlement keys only.`]}),onClose:i,onSubmit:()=>w(C.PUT(`/api/v1/admin/settings/{key}`,{params:{path:{key:e.key}},body:{value:Number(o),version:d?e.version:void 0,cityId:t||void 0,reason:c}})).then(a),children:[(0,D.jsx)(R,{label:`Value`,children:(0,D.jsx)(`input`,{type:`number`,value:o,onChange:e=>s(e.target.value),required:!0})}),(0,D.jsx)(Re,{value:c,onChange:u})]})}function Gt(){let e=N(()=>w(C.GET(`/api/v1/admin/notification-templates`)),[]),[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(),a=e.data?.filter(e=>`${e.code} ${e.channel} ${e.body}`.toLowerCase().includes(t.toLowerCase()));return(0,D.jsxs)(ke,{title:`Notifications`,sub:`Message text per event and channel. {{placeholders}} are filled in when sent.`,children:[(0,D.jsx)(`div`,{className:`filters`,role:`search`,children:(0,D.jsx)(R,{label:`Find`,children:(0,D.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`Event, channel or text`})})}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:a,loading:e.loading,error:e.error,rowKey:e=>`${e.code}|${e.channel}|${e.locale}`,onOpen:i,cols:[{key:`c`,label:`Event`,render:e=>e.code,mono:!0,width:230},{key:`ch`,label:`Channel`,render:e=>A(e.channel),width:90},{key:`l`,label:`Locale`,render:e=>e.locale,width:70},{key:`b`,label:`Text`,render:e=>(0,D.jsxs)(D.Fragment,{children:[e.subject&&(0,D.jsxs)(`strong`,{children:[e.subject,` · `]}),(0,D.jsx)(`span`,{className:`clip`,children:e.body})]})},{key:`s`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:90},{key:`u`,label:`Updated`,render:e=>k(e.updatedAt),width:130}]})}),r&&(0,D.jsx)(z,{t:r,onClose:()=>i(void 0),onDone:e.reload})]})}function z({t:e,onClose:t,onDone:n}){let[r,i]=(0,l.useState)(e.subject??``),[a,o]=(0,l.useState)(e.body??``),[s,c]=(0,l.useState)(e.status??`ACTIVE`),[u,d]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`${e.code} · ${A(e.channel)}`,onClose:t,onSubmit:()=>w(C.PUT(`/api/v1/admin/notification-templates`,{body:{code:e.code,channel:e.channel,locale:e.locale,subject:r||void 0,body:a,status:s,reason:u}})).then(n),children:[e.channel!==`SMS`&&(0,D.jsx)(R,{label:`Subject`,children:(0,D.jsx)(`input`,{value:r,onChange:e=>i(e.target.value)})}),(0,D.jsx)(R,{label:`Text`,hint:e.channel===`SMS`?`${a.length} characters`:void 0,children:(0,D.jsx)(`textarea`,{rows:4,value:a,onChange:e=>o(e.target.value),required:!0})}),(0,D.jsx)(R,{label:`Status`,children:(0,D.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,D.jsx)(`option`,{children:`ACTIVE`}),(0,D.jsx)(`option`,{children:`INACTIVE`})]})}),(0,D.jsx)(Re,{value:u,onChange:d})]})}var Kt=[`funnel`,`fulfilment`,`cancellations`,`refunds`,`quality`,`utilization`],qt=/_minor/;function Jt(){let e=N(()=>E(),[]),[t,n]=(0,l.useState)(`fulfilment`),[r,i]=(0,l.useState)(ye(-30)),[a,o]=(0,l.useState)(ye()),[s,c]=(0,l.useState)(``),u=N(()=>w(C.GET(`/api/v1/admin/reports/{report}`,{params:{path:{report:t},query:{from:r,to:a,cityId:s||void 0}}})),[t,r,a,s]),d=u.data,f=(e,t)=>t==null?``:qt.test(e??``)?new Intl.NumberFormat(`en-IN`,{style:`currency`,currency:`INR`}).format(Number(t)/100):Number(t).toLocaleString(`en-IN`);return(0,D.jsxs)(ke,{title:`Reports`,sub:`Date range is by city time, both days included, one year at most.`,actions:(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>fe(t,{from:r,to:a,cityId:s}).catch(e=>Ee(de(e),`danger`)),children:`Download CSV`}),children:[(0,D.jsx)(`div`,{className:`tabs`,role:`tablist`,children:Kt.map(e=>(0,D.jsx)(`button`,{role:`tab`,"aria-selected":t===e,className:t===e?`on`:void 0,onClick:()=>n(e),children:A(e)},e))}),(0,D.jsxs)(`div`,{className:`filters`,role:`search`,children:[(0,D.jsx)(R,{label:`From`,children:(0,D.jsx)(`input`,{type:`date`,value:r,max:a,onChange:e=>i(e.target.value)})}),(0,D.jsx)(R,{label:`To`,children:(0,D.jsx)(`input`,{type:`date`,value:a,min:r,onChange:e=>o(e.target.value)})}),(0,D.jsx)(R,{label:`City`,children:(0,D.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`All cities`}),e.data?.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:d?.rows,loading:u.loading,error:u.error,rowKey:e=>`${e.metric}|${e.dimension}`,cols:[{key:`m`,label:`Metric`,render:e=>A(e.metric)},{key:`d`,label:`Breakdown`,render:e=>e.dimension&&/^[0-9a-f-]{36}$/.test(e.dimension)?(0,D.jsx)(`a`,{className:`mono`,href:`#/professionals/${e.dimension}`,children:j(e.dimension)}):A(e.dimension)},{key:`v`,label:`Value`,render:e=>f(e.metric,e.value),num:!0,width:160}]})})]})}function Yt(){be();let e=xe(),[t,n]=(0,l.useState)({entityType:e.get(`entityType`)??``,entityId:e.get(`entityId`)??``,actorId:``,action:``}),[r,i]=(0,l.useState)(t),a=P(e=>w(C.GET(`/api/v1/admin/audit`,{params:{query:{...Object.fromEntries(Object.entries(r).filter(([,e])=>e.trim())),cursor:e,limit:50}}})),[r]),[o,s]=(0,l.useState)(),c=e=>r=>n({...t,[e]:r.target.value});return(0,D.jsxs)(ke,{title:`Audit log`,sub:`Every staff and system change, newest first. Read-only.`,children:[(0,D.jsxs)(`form`,{className:`filters`,role:`search`,onSubmit:e=>(e.preventDefault(),i({...t,action:t.action.trim().toUpperCase(),entityType:t.entityType.trim().toUpperCase()})),children:[(0,D.jsx)(R,{label:`Action`,children:(0,D.jsx)(`input`,{className:`mono`,value:t.action,onChange:c(`action`),placeholder:`e.g. BOOKING_ASSIGNED`})}),(0,D.jsx)(R,{label:`Entity type`,children:(0,D.jsx)(`input`,{className:`mono`,value:t.entityType,onChange:c(`entityType`),placeholder:`e.g. BOOKING`})}),(0,D.jsx)(R,{label:`Entity ID`,children:(0,D.jsx)(`input`,{className:`mono`,value:t.entityId,onChange:c(`entityId`)})}),(0,D.jsx)(R,{label:`Actor ID`,children:(0,D.jsx)(`input`,{className:`mono`,value:t.actorId,onChange:c(`actorId`)})}),(0,D.jsx)(`button`,{className:`btn`,children:`Apply`})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsxs)(`div`,{className:`table-wrap`,children:[(0,D.jsx)(I,{error:a.error}),(0,D.jsxs)(`table`,{className:`table`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{style:{width:130},children:`When`}),(0,D.jsx)(`th`,{children:`Action`}),(0,D.jsx)(`th`,{children:`Entity`}),(0,D.jsx)(`th`,{children:`Actor`}),(0,D.jsx)(`th`,{children:`Reason`}),(0,D.jsx)(`th`,{style:{width:70},children:`Via`})]})}),(0,D.jsx)(`tbody`,{children:a.rows?.map(e=>(0,D.jsxs)(l.Fragment,{children:[(0,D.jsxs)(`tr`,{tabIndex:0,className:`clickable${o===e.id?` selected`:``}`,onClick:()=>s(o===e.id?void 0:e.id),onKeyDown:t=>t.key===`Enter`&&s(o===e.id?void 0:e.id),"aria-expanded":o===e.id,children:[(0,D.jsx)(`td`,{children:k(e.at)}),(0,D.jsx)(`td`,{className:`mono`,children:e.action}),(0,D.jsxs)(`td`,{children:[(0,D.jsx)(`span`,{className:`faint`,children:A(e.entityType)}),` `,(0,D.jsx)(`span`,{className:`mono`,children:j(e.entityId)})]}),(0,D.jsxs)(`td`,{children:[A(e.actorType),e.actorRoles?.length?(0,D.jsxs)(`span`,{className:`faint`,children:[` · `,e.actorRoles.map(A).join(`, `)]}):null]}),(0,D.jsx)(`td`,{className:`clip`,children:e.reason}),(0,D.jsx)(`td`,{className:`faint`,children:A(e.sourceChannel)})]}),o===e.id&&(0,D.jsx)(`tr`,{className:`detail-row`,children:(0,D.jsx)(`td`,{colSpan:6,children:(0,D.jsxs)(`div`,{className:`diff`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h4`,{children:`Before`}),e.before?(0,D.jsx)(`pre`,{children:JSON.stringify(e.before,null,2)}):(0,D.jsx)(`span`,{className:`faint`,children:`—`})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h4`,{children:`After`}),e.after?(0,D.jsx)(`pre`,{children:JSON.stringify(e.after,null,2)}):(0,D.jsx)(`span`,{className:`faint`,children:`—`})]}),(0,D.jsxs)(`div`,{className:`faint mono small`,children:[`entity `,e.entityId,(0,D.jsx)(`br`,{}),`actor `,e.actorUserId??`—`,(0,D.jsx)(`br`,{}),`request `,e.requestId??`—`]})]})})})]},e.id))})]}),!a.rows&&a.loading&&(0,D.jsx)(Ne,{}),a.rows?.length===0&&(0,D.jsx)(Me,{}),a.more&&(0,D.jsx)(`button`,{className:`btn ghost more`,onClick:a.more,disabled:a.loading,children:`Load more`})]})})]})}var Xt=[`SUPPORT_AGENT`,`OPS_MANAGER`,`CATALOG_ADMIN`,`FINANCE_ADMIN`,`SYSTEM_ADMIN`];function Zt({me:e}){let t=N(()=>w(C.GET(`/api/v1/admin/staff`)),[]),n=N(()=>E(),[]),r=Le(),[i,a]=(0,l.useState)(),o=e=>e?n.data?.find(t=>t.id===e)?.name??j(e):``;return(0,D.jsxs)(ke,{title:`Staff & roles`,sub:`Who can use this console and what each role may do.`,actions:(0,D.jsx)(`button`,{className:`btn primary`,onClick:()=>r.open({k:`new`}),children:`Add staff`}),children:[i&&(0,D.jsxs)(`div`,{className:`callout`,role:`alert`,children:[(0,D.jsxs)(`div`,{children:[`Temporary password for `,(0,D.jsx)(`strong`,{children:i.email}),`: `,(0,D.jsx)(`code`,{className:`secret`,children:i.pw}),(0,D.jsx)(`div`,{className:`faint`,children:`Shown once. Pass it on in person; they must set their own at next sign-in.`})]}),(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>a(void 0),children:`Done`})]}),(0,D.jsx)(Ae,{flush:!0,children:(0,D.jsx)(Pe,{rows:t.data,loading:t.loading,error:t.error,rowKey:e=>e.id,cols:[{key:`e`,label:`Email`,render:t=>(0,D.jsxs)(D.Fragment,{children:[t.email,t.id===e.id&&(0,D.jsx)(`span`,{className:`faint`,children:` · you`})]})},{key:`p`,label:`Phone`,render:e=>e.phoneMasked,mono:!0,width:140},{key:`r`,label:`Roles`,render:e=>(0,D.jsx)(`span`,{className:`roles-cell`,children:e.roles?.length?e.roles.map(t=>(0,D.jsxs)(`span`,{className:`chip`,children:[A(t.role),t.cityId&&(0,D.jsxs)(`span`,{className:`faint`,children:[` · `,o(t.cityId)]}),e.status===`ACTIVE`&&(0,D.jsx)(`button`,{className:`chip-x`,"aria-label":`Remove ${A(t.role)}`,onClick:()=>r.open({k:`revoke`,s:e,a:t.assignmentId,role:t.role}),children:`×`})]},t.assignmentId)):(0,D.jsx)(`span`,{className:`faint`,children:`No roles`})})},{key:`st`,label:`Status`,render:e=>(0,D.jsx)(F,{value:e.status}),width:100},{key:`a`,label:``,width:250,render:t=>t.status===`ACTIVE`&&(0,D.jsxs)(`span`,{className:`row-actions`,children:[(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>r.open({k:`grant`,s:t}),children:`Grant role`}),(0,D.jsx)(`button`,{className:`btn small`,onClick:()=>r.open({k:`reset`,s:t}),children:`Reset password`}),t.id!==e.id&&(0,D.jsx)(`button`,{className:`btn small danger-ghost`,onClick:()=>r.open({k:`disable`,s:t}),children:`Disable`})]})}]})}),r.value?.k===`new`&&(0,D.jsx)($t,{onClose:r.close,onDone:t.reload}),r.value?.k===`grant`&&(0,D.jsx)(en,{s:r.value.s,cities:n.data??[],onClose:r.close,onDone:t.reload}),r.value?.k===`revoke`&&(()=>{let e=r.value;return(0,D.jsx)(Qt,{title:`Remove ${A(e.role)} from ${e.s.email}`,submit:`Remove role`,danger:!0,onClose:r.close,send:n=>w(C.DELETE(`/api/v1/admin/staff/{id}/roles/{assignmentId}`,{params:{path:{id:e.s.id,assignmentId:e.a}},body:{reason:n}})).then(t.reload)})})(),r.value?.k===`disable`&&(()=>{let e=r.value.s;return(0,D.jsx)(Qt,{title:`Disable ${e.email}`,submit:`Disable account`,danger:!0,note:`Signs them out everywhere. Can't be undone from the console.`,onClose:r.close,send:n=>w(C.POST(`/api/v1/admin/staff/{id}/disable`,{params:{path:{id:e.id}},body:{reason:n}})).then(t.reload)})})(),r.value?.k===`reset`&&(()=>{let e=r.value.s;return(0,D.jsx)(Qt,{title:`Reset password for ${e.email}`,submit:`Reset`,note:`Ends their sessions and issues a temporary password.`,onClose:r.close,send:t=>w(C.POST(`/api/v1/admin/staff/{id}/password-reset`,{params:{path:{id:e.id}},body:{reason:t}})).then(t=>a({email:e.email,pw:t.temporaryPassword??``}))})})()]})}function Qt({title:e,submit:t,note:n,danger:r,send:i,onClose:a}){let[o,s]=(0,l.useState)(``);return(0,D.jsx)(L,{title:e,submit:t,note:n,tone:r?`danger`:void 0,onClose:a,onSubmit:()=>i(o),children:(0,D.jsx)(Re,{value:o,onChange:s})})}function $t({onClose:e,onDone:t}){let[n,r]=(0,l.useState)({email:``,phone:`+91`,password:``}),i=e=>t=>r({...n,[e]:t.target.value});return(0,D.jsxs)(L,{title:`Add staff`,note:`They get no access until you grant a role.`,onClose:e,onSubmit:()=>w(C.POST(`/api/v1/admin/staff`,{body:n})).then(t),children:[(0,D.jsx)(R,{label:`Work email`,children:(0,D.jsx)(`input`,{type:`email`,value:n.email,onChange:i(`email`),required:!0,autoComplete:`off`})}),(0,D.jsx)(R,{label:`Phone`,hint:`Receives the sign-in code.`,children:(0,D.jsx)(`input`,{type:`tel`,value:n.phone,onChange:i(`phone`),required:!0,pattern:`\\+[0-9]{10,15}`})}),(0,D.jsx)(R,{label:`Initial password`,hint:`At least 12 characters.`,children:(0,D.jsx)(`input`,{type:`password`,value:n.password,onChange:i(`password`),required:!0,minLength:12,autoComplete:`new-password`})})]})}function en({s:e,cities:t,onClose:n,onDone:r}){let[i,a]=(0,l.useState)(`SUPPORT_AGENT`),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(``);return(0,D.jsxs)(L,{title:`Grant a role to ${e.email}`,onClose:n,onSubmit:()=>w(C.POST(`/api/v1/admin/staff/{id}/roles`,{params:{path:{id:e.id}},body:{role:i,cityId:o||void 0,reason:c}})).then(r),children:[(0,D.jsx)(R,{label:`Role`,children:(0,D.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),children:Xt.map(e=>(0,D.jsx)(`option`,{value:e,children:A(e)},e))})}),(0,D.jsx)(R,{label:`City`,hint:`Limits region-scoped permissions to one city.`,children:(0,D.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`All cities`}),t.map(e=>(0,D.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,D.jsx)(Re,{value:c,onChange:u})]})}var tn=[{group:`Operate`,path:`live`,label:`Live board`,any:[`ops.live.view`],screen:()=>(0,D.jsx)(He,{})},{group:`Operate`,path:`bookings`,label:`Bookings`,any:[`booking.view.any`],screen:e=>(0,D.jsx)(Ge,{me:e})},{group:`Operate`,path:`cases`,label:`Cases`,any:[`support.case.manage`],screen:e=>(0,D.jsx)(gt,{me:e})},{group:`Operate`,path:`professionals`,label:`Professionals`,any:[`professional.view`],screen:e=>(0,D.jsx)(Lt,{me:e})},{group:`Money`,path:`refunds`,label:`Refunds`,any:[`finance.view`],screen:e=>(0,D.jsx)(wt,{me:e})},{group:`Money`,path:`credits`,label:`Credits`,any:[`credit.issue`],screen:e=>(0,D.jsx)(Et,{me:e})},{group:`Money`,path:`settlements`,label:`Settlements`,any:[`finance.view`],screen:e=>(0,D.jsx)(Ot,{me:e})},{group:`Money`,path:`coupons`,label:`Coupons & tax`,any:[`price.manage`],screen:()=>(0,D.jsx)(jt,{})},{group:`Catalog`,path:`catalog`,label:`Services`,any:[`catalog.manage`],screen:e=>(0,D.jsx)(Qe,{me:e})},{group:`Catalog`,path:`geography`,label:`Cities & zones`,any:[`zone.manage`],screen:()=>(0,D.jsx)(at,{})},{group:`Catalog`,path:`policies`,label:`Policy documents`,any:[`catalog.manage`],screen:()=>(0,D.jsx)(ut,{})},{group:`Platform`,path:`settings`,label:`Settings`,any:[`policy.manage`,`settlement.manage`],screen:e=>(0,D.jsx)(Ut,{me:e})},{group:`Platform`,path:`templates`,label:`Notifications`,any:[`policy.manage`],screen:()=>(0,D.jsx)(Gt,{})},{group:`Platform`,path:`reports`,label:`Reports`,any:[`report.view`],screen:()=>(0,D.jsx)(Jt,{})},{group:`Platform`,path:`audit`,label:`Audit log`,any:[`audit.view`],screen:()=>(0,D.jsx)(Yt,{})},{group:`Platform`,path:`staff`,label:`Staff & roles`,any:[`user.manage`],screen:e=>(0,D.jsx)(Zt,{me:e})}];function nn(){let e=(0,l.useSyncExternalStore)(ae.subscribe,ae.get);return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(rn,{},e.refreshToken):(0,D.jsx)(cn,{}),(0,D.jsx)(De,{})]})}function rn(){let e=N(()=>w(C.GET(`/api/v1/admin/me`)),[]);return e.error?(0,D.jsxs)(`div`,{className:`center`,children:[(0,D.jsx)(I,{error:e.error}),(0,D.jsx)(`button`,{className:`btn`,onClick:()=>ae.set(null),children:`Sign in again`})]}):e.data?(me(e.data),e.data.permissions?.length?(0,D.jsx)(an,{me:e.data}):(0,D.jsx)(ln,{email:e.data.email})):(0,D.jsx)(`div`,{className:`center`,children:(0,D.jsx)(Ne,{})})}function an({me:e}){let t=be(),n=(0,l.useMemo)(()=>tn.filter(t=>T(e,...t.any)),[e]),[r,i]=(0,l.useState)(!1),a=n.find(e=>e.path===t[0]);(0,l.useEffect)(()=>{!a&&n[0]&&Se(n[0].path)},[a,n]),(0,l.useEffect)(()=>{let e=e=>{let t=/INPUT|TEXTAREA|SELECT/.test(e.target.tagName);(e.key===`k`&&(e.ctrlKey||e.metaKey)||e.key===`/`&&!t)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let o=[...new Set(n.map(e=>e.group))];return(0,D.jsxs)(`div`,{className:`shell`,children:[(0,D.jsx)(`a`,{className:`skip`,href:`#main`,onClick:e=>(e.preventDefault(),document.getElementById(`main`)?.focus()),children:`Skip to content`}),(0,D.jsxs)(`nav`,{className:`rail`,"aria-label":`Main`,children:[(0,D.jsxs)(`div`,{className:`brand`,children:[(0,D.jsx)(`span`,{className:`mark`,"aria-hidden":!0}),(0,D.jsx)(`span`,{children:`Serv Plus`}),(0,D.jsx)(`em`,{children:`Ops`})]}),(0,D.jsxs)(`button`,{className:`jump`,onClick:()=>i(!0),children:[(0,D.jsx)(`span`,{children:`Jump to…`}),(0,D.jsx)(`kbd`,{children:`Ctrl K`})]}),o.map(e=>(0,D.jsxs)(`div`,{className:`rail-group`,children:[(0,D.jsx)(`div`,{className:`rail-label`,children:e}),n.filter(t=>t.group===e).map(e=>(0,D.jsx)(`a`,{href:Ce(e.path),className:e===a?`on`:void 0,"aria-current":e===a?`page`:void 0,children:e.label},e.path))]},e)),(0,D.jsxs)(`div`,{className:`rail-foot`,children:[(0,D.jsx)(`div`,{className:`who`,title:e.email,children:e.email}),(0,D.jsx)(`div`,{className:`roles`,children:e.roles?.map(e=>e.role?.replace(/_/g,` `).toLowerCase()).join(` · `)}),(0,D.jsx)(`button`,{className:`link`,onClick:on,children:`Sign out`})]})]}),(0,D.jsxs)(`header`,{className:`topbar`,children:[(0,D.jsxs)(`div`,{className:`brand`,children:[(0,D.jsx)(`span`,{className:`mark`,"aria-hidden":!0}),(0,D.jsx)(`span`,{children:`Serv Plus`})]}),(0,D.jsxs)(`button`,{className:`btn small`,onClick:()=>i(!0),children:[a?.label??`Menu`,` ▾`]}),(0,D.jsx)(`button`,{className:`link`,onClick:on,children:`Sign out`})]}),(0,D.jsx)(`main`,{id:`main`,tabIndex:-1,children:a?a.screen(e):n.length===0?(0,D.jsx)(`div`,{className:`center`,children:`Your roles don't include any console screens.`}):null}),r&&(0,D.jsx)(sn,{menu:n,onClose:()=>i(!1)})]})}async function on(){let e=ae.get();e&&await C.POST(`/api/v1/public/auth/logout`,{body:{refreshToken:e.refreshToken}}).catch(()=>null),ae.set(null),Se(``)}function sn({menu:e,onClose:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(0),o=e.filter(e=>`${e.group} ${e.label}`.toLowerCase().includes(n.toLowerCase())),s=e=>e&&(Se(e.path),t());return(0,D.jsx)(`div`,{className:`dialog-scrim`,onMouseDown:e=>e.target===e.currentTarget&&t(),children:(0,D.jsxs)(`div`,{className:`palette`,role:`dialog`,"aria-label":`Jump to screen`,children:[(0,D.jsx)(`input`,{autoFocus:!0,placeholder:`Jump to a screen`,value:n,onChange:e=>(r(e.target.value),a(0)),onKeyDown:e=>{e.key===`Escape`&&t(),e.key===`ArrowDown`&&(e.preventDefault(),a(e=>Math.min(e+1,o.length-1))),e.key===`ArrowUp`&&(e.preventDefault(),a(e=>Math.max(e-1,0))),e.key===`Enter`&&s(o[i])}}),(0,D.jsxs)(`ul`,{children:[o.map((e,t)=>(0,D.jsxs)(`li`,{className:t===i?`on`:void 0,onMouseEnter:()=>a(t),onClick:()=>s(e),children:[(0,D.jsx)(`span`,{children:e.label}),(0,D.jsx)(`small`,{children:e.group})]},e.path)),o.length===0&&(0,D.jsx)(`li`,{className:`faint`,children:`No screen matches`})]})]})})}function cn(){let[e,t]=(0,l.useState)(null),[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(``),[c,u]=(0,l.useState)(!1),[d,f]=(0,l.useState)();(0,l.useEffect)(()=>void(document.title=`Sign in · Serv Plus Ops`),[]),(0,l.useEffect)(()=>void(e&&document.querySelector(`input.code`)?.focus()),[e]);async function p(e){e.preventDefault(),u(!0),f(void 0);try{let e=await w(C.POST(`/api/v1/public/auth/staff/login`,{body:{email:n.trim(),password:i}}));t({challengeId:e.challengeId,expiresAt:e.expiresAt})}catch(e){f(de(e))}finally{u(!1)}}async function m(t){if(t.preventDefault(),e){u(!0),f(void 0);try{let t=await w(C.POST(`/api/v1/public/auth/staff/verify`,{body:{challengeId:e.challengeId,code:o.trim(),deviceLabel:`admin-web`}}));a(``),ae.set({accessToken:t.accessToken,refreshToken:t.refreshToken})}catch(e){f(de(e))}finally{u(!1)}}}return(0,D.jsxs)(`div`,{className:`login`,children:[(0,D.jsxs)(`div`,{className:`login-side`,"aria-hidden":!0,children:[(0,D.jsxs)(`div`,{className:`brand big`,children:[(0,D.jsx)(`span`,{className:`mark`}),(0,D.jsx)(`span`,{children:`Serv Plus`})]}),(0,D.jsx)(`p`,{children:`Operations console`})]}),(0,D.jsx)(`div`,{className:`login-main`,children:e?(0,D.jsxs)(`form`,{onSubmit:m,className:`login-form`,children:[(0,D.jsx)(`h1`,{children:`Enter the code`}),(0,D.jsxs)(`p`,{className:`sub`,children:[`We sent a 6-digit code to the phone on `,n,`.`]}),(0,D.jsx)(R,{label:`Code`,children:(0,D.jsx)(`input`,{inputMode:`numeric`,autoComplete:`one-time-code`,pattern:`\\d{6}`,maxLength:6,className:`code`,value:o,onChange:e=>s(e.target.value.replace(/\D/g,``)),required:!0})}),(0,D.jsx)(I,{error:d}),(0,D.jsx)(`button`,{className:`btn primary block`,disabled:c||o.length!==6,children:c?`Verifying…`:`Sign in`}),(0,D.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>(t(null),s(``),f(void 0)),children:`Use a different account`})]}):(0,D.jsxs)(`form`,{onSubmit:p,className:`login-form`,children:[(0,D.jsx)(`h1`,{children:`Sign in`}),(0,D.jsx)(`p`,{className:`sub`,children:`Staff accounts only. A code goes to the phone on your account next.`}),(0,D.jsx)(R,{label:`Work email`,children:(0,D.jsx)(`input`,{type:`email`,autoComplete:`username`,value:n,onChange:e=>r(e.target.value),required:!0,autoFocus:!0})}),(0,D.jsx)(R,{label:`Password`,children:(0,D.jsx)(`input`,{type:`password`,autoComplete:`current-password`,value:i,onChange:e=>a(e.target.value),required:!0})}),(0,D.jsx)(I,{error:d}),(0,D.jsx)(`button`,{className:`btn primary block`,disabled:c,children:c?`Checking…`:`Continue`})]})})]})}function ln({email:e}){let[t,n]=(0,l.useState)(``),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)();return(0,D.jsx)(`div`,{className:`login`,children:(0,D.jsx)(`div`,{className:`login-main`,children:(0,D.jsxs)(`form`,{className:`login-form`,onSubmit:async e=>{e.preventDefault();try{await w(C.POST(`/api/v1/admin/me/password`,{body:{currentPassword:t,newPassword:r}})),ae.set(null)}catch(e){o(de(e))}},children:[(0,D.jsx)(`h1`,{children:`Set your password`}),(0,D.jsxs)(`p`,{className:`sub`,children:[e,`: your password was reset. Choose a new one, then sign in again.`]}),(0,D.jsx)(R,{label:`Temporary password`,children:(0,D.jsx)(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),required:!0,autoComplete:`current-password`})}),(0,D.jsx)(R,{label:`New password`,children:(0,D.jsx)(`input`,{type:`password`,value:r,onChange:e=>i(e.target.value),required:!0,minLength:12,autoComplete:`new-password`})}),(0,D.jsx)(I,{error:a}),(0,D.jsx)(`button`,{className:`btn primary block`,children:`Save and sign in again`}),(0,D.jsx)(`button`,{type:`button`,className:`link`,onClick:on,children:`Sign out`})]})})})}(0,u.createRoot)(document.getElementById(`root`)).render((0,D.jsx)(l.StrictMode,{children:(0,D.jsx)(nn,{})}));