From 7c74431fcf9080e3fa278c1f3d99d6d3e85f5a93 Mon Sep 17 00:00:00 2001 From: Suriyakumarvijayanayagam Date: Sat, 19 Sep 2026 15:29:15 +0530 Subject: [PATCH] Loya says 'sign in again' instead of 'session expired' --- .../dist/assets/{index-DKxK1S8I.js => index-C-oYbwC6.js} | 2 +- desktop/frontend/dist/index.html | 2 +- desktop/frontend/src/views/Assistant.jsx | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) rename desktop/frontend/dist/assets/{index-DKxK1S8I.js => index-C-oYbwC6.js} (95%) diff --git a/desktop/frontend/dist/assets/index-DKxK1S8I.js b/desktop/frontend/dist/assets/index-C-oYbwC6.js similarity index 95% rename from desktop/frontend/dist/assets/index-DKxK1S8I.js rename to desktop/frontend/dist/assets/index-C-oYbwC6.js index 8ccff04..72cdbb2 100644 --- a/desktop/frontend/dist/assets/index-DKxK1S8I.js +++ b/desktop/frontend/dist/assets/index-C-oYbwC6.js @@ -37,4 +37,4 @@ `+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Tl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?En(e):""}function nd(e){switch(e.tag){case 5:return En(e.type);case 16:return En("Lazy");case 13:return En("Suspense");case 19:return En("SuspenseList");case 0:case 2:case 15:return e=Ml(e.type,!1),e;case 11:return e=Ml(e.type.render,!1),e;case 1:return e=Ml(e.type,!0),e;default:return""}}function si(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case At:return"Fragment";case Ut:return"Portal";case ri:return"Profiler";case ns:return"StrictMode";case li:return"Suspense";case ii:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ka:return(e.displayName||"Context")+".Consumer";case ja:return(e._context.displayName||"Context")+".Provider";case rs:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ls:return t=e.displayName||null,t!==null?t:si(e.type)||"Memo";case nt:t=e._payload,e=e._init;try{return si(e(t))}catch{}}return null}function rd(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return si(t);case 8:return t===ns?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function vt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Na(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ld(e){var t=Na(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function dr(e){e._valueTracker||(e._valueTracker=ld(e))}function Ca(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Na(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ar(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function oi(e,t){var n=t.checked;return Q({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Js(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=vt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ea(e,t){t=t.checked,t!=null&&ts(e,"checked",t,!1)}function ai(e,t){Ea(e,t);var n=vt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ui(e,t.type,n):t.hasOwnProperty("defaultValue")&&ui(e,t.type,vt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function qs(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ui(e,t,n){(t!=="number"||Ar(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _n=Array.isArray;function Jt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=fr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function An(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ln={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},id=["Webkit","ms","Moz","O"];Object.keys(Ln).forEach(function(e){id.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ln[t]=Ln[e]})});function La(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ln.hasOwnProperty(e)&&Ln[e]?(""+t).trim():t+"px"}function Ta(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=La(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var sd=Q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function fi(e,t){if(t){if(sd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function pi(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var hi=null;function is(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var mi=null,qt=null,bt=null;function to(e){if(e=ir(e)){if(typeof mi!="function")throw Error(j(280));var t=e.stateNode;t&&(t=ml(t),mi(e.stateNode,e.type,t))}}function Ma(e){qt?bt?bt.push(e):bt=[e]:qt=e}function Ra(){if(qt){var e=qt,t=bt;if(bt=qt=null,to(e),t)for(e=0;e>>=0,e===0?32:31-(gd(e)/yd|0)|0}var pr=64,hr=4194304;function Pn(e){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:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Wr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Pn(a):(i&=o,i!==0&&(r=Pn(i)))}else o=n&~l,o!==0?r=Pn(o):i!==0&&(r=Pn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function rr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Fe(t),e[t]=n}function kd(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Mn),co=" ",fo=!1;function ba(e,t){switch(e){case"keyup":return Zd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function eu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bt=!1;function qd(e,t){switch(e){case"compositionend":return eu(t);case"keypress":return t.which!==32?null:(fo=!0,co);case"textInput":return e=t.data,e===co&&fo?null:e;default:return null}}function bd(e,t){if(Bt)return e==="compositionend"||!ps&&ba(e,t)?(e=Ja(),Tr=cs=st=null,Bt=!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}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=vo(n)}}function lu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?lu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function iu(){for(var e=window,t=Ar();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ar(e.document)}return t}function hs(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")}function uf(e){var t=iu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&lu(n.ownerDocument.documentElement,n)){if(r!==null&&hs(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=go(n,i);var o=go(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Vt=null,ji=null,Dn=null,ki=!1;function yo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ki||Vt==null||Vt!==Ar(r)||(r=Vt,"selectionStart"in r&&hs(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}),Dn&&Kn(Dn,r)||(Dn=r,r=Yr(ji,"onSelect"),0Qt||(e.current=Pi[Qt],Pi[Qt]=null,Qt--)}function I(e,t){Qt++,Pi[Qt]=e.current,e.current=t}var gt={},ae=xt(gt),me=xt(!1),Lt=gt;function on(e,t){var n=e.type.contextTypes;if(!n)return gt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ve(e){return e=e.childContextTypes,e!=null}function Xr(){A(me),A(ae)}function Co(e,t,n){if(ae.current!==gt)throw Error(j(168));I(ae,t),I(me,n)}function hu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,rd(e)||"Unknown",l));return Q({},n,r)}function Zr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||gt,Lt=ae.current,I(ae,e),I(me,me.current),!0}function Eo(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=hu(e,t,Lt),r.__reactInternalMemoizedMergedChildContext=e,A(me),A(ae),I(ae,e)):A(me),I(me,n)}var Ke=null,vl=!1,Kl=!1;function mu(e){Ke===null?Ke=[e]:Ke.push(e)}function jf(e){vl=!0,mu(e)}function wt(){if(!Kl&&Ke!==null){Kl=!0;var e=0,t=F;try{var n=Ke;for(F=1;e>=o,l-=o,Ye=1<<32-Fe(t)+l|n<_?(V=S,S=null):V=S.sibling;var M=h(f,S,m[_],y);if(M===null){S===null&&(S=V);break}e&&S&&M.alternate===null&&t(f,S),d=i(M,d,_),N===null?k=M:N.sibling=M,N=M,S=V}if(_===m.length)return n(f,S),B&&St(f,_),k;if(S===null){for(;__?(V=S,S=null):V=S.sibling;var Te=h(f,S,M.value,y);if(Te===null){S===null&&(S=V);break}e&&S&&Te.alternate===null&&t(f,S),d=i(Te,d,_),N===null?k=Te:N.sibling=Te,N=Te,S=V}if(M.done)return n(f,S),B&&St(f,_),k;if(S===null){for(;!M.done;_++,M=m.next())M=v(f,M.value,y),M!==null&&(d=i(M,d,_),N===null?k=M:N.sibling=M,N=M);return B&&St(f,_),k}for(S=r(f,S);!M.done;_++,M=m.next())M=g(S,f,_,M.value,y),M!==null&&(e&&M.alternate!==null&&S.delete(M.key===null?_:M.key),d=i(M,d,_),N===null?k=M:N.sibling=M,N=M);return e&&S.forEach(function(vn){return t(f,vn)}),B&&St(f,_),k}function z(f,d,m,y){if(typeof m=="object"&&m!==null&&m.type===At&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case cr:e:{for(var k=m.key,N=d;N!==null;){if(N.key===k){if(k=m.type,k===At){if(N.tag===7){n(f,N.sibling),d=l(N,m.props.children),d.return=f,f=d;break e}}else if(N.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===nt&&zo(k)===N.type){n(f,N.sibling),d=l(N,m.props),d.ref=Sn(f,N,m),d.return=f,f=d;break e}n(f,N);break}else t(f,N);N=N.sibling}m.type===At?(d=zt(m.props.children,f.mode,y,m.key),d.return=f,f=d):(y=Ur(m.type,m.key,m.props,null,f.mode,y),y.ref=Sn(f,d,m),y.return=f,f=y)}return o(f);case Ut:e:{for(N=m.key;d!==null;){if(d.key===N)if(d.tag===4&&d.stateNode.containerInfo===m.containerInfo&&d.stateNode.implementation===m.implementation){n(f,d.sibling),d=l(d,m.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ei(m,f.mode,y),d.return=f,f=d}return o(f);case nt:return N=m._init,z(f,d,N(m._payload),y)}if(_n(m))return w(f,d,m,y);if(yn(m))return x(f,d,m,y);jr(f,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,m),d.return=f,f=d):(n(f,d),d=bl(m,f.mode,y),d.return=f,f=d),o(f)):n(f,d)}return z}var un=xu(!0),wu=xu(!1),br=xt(null),el=null,Gt=null,ys=null;function xs(){ys=Gt=el=null}function ws(e){var t=br.current;A(br),e._currentValue=t}function Ti(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tn(e,t){el=e,ys=Gt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(he=!0),e.firstContext=null)}function ze(e){var t=e._currentValue;if(ys!==e)if(e={context:e,memoizedValue:t,next:null},Gt===null){if(el===null)throw Error(j(308));Gt=e,el.dependencies={lanes:0,firstContext:e}}else Gt=Gt.next=e;return t}var Et=null;function js(e){Et===null?Et=[e]:Et.push(e)}function ju(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,js(t)):(n.next=l.next,l.next=n),t.interleaved=n,qe(e,r)}function qe(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var rt=!1;function ks(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ku(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Xe(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ft(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,D&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,qe(e,n)}return l=r.interleaved,l===null?(t.next=t,js(r)):(t.next=l.next,l.next=t),r.interleaved=t,qe(e,n)}function Rr(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,os(e,n)}}function Lo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function tl(e,t,n,r){var l=e.updateQueue;rt=!1;var i=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,o===null?i=c:o.next=c,o=u;var p=e.alternate;p!==null&&(p=p.updateQueue,a=p.lastBaseUpdate,a!==o&&(a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=u))}if(i!==null){var v=l.baseState;o=0,p=c=u=null,a=i;do{var h=a.lane,g=a.eventTime;if((r&h)===h){p!==null&&(p=p.next={eventTime:g,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var w=e,x=a;switch(h=t,g=n,x.tag){case 1:if(w=x.payload,typeof w=="function"){v=w.call(g,v,h);break e}v=w;break e;case 3:w.flags=w.flags&-65537|128;case 0:if(w=x.payload,h=typeof w=="function"?w.call(g,v,h):w,h==null)break e;v=Q({},v,h);break e;case 2:rt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[a]:h.push(a))}else g={eventTime:g,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},p===null?(c=p=g,u=v):p=p.next=g,o|=h;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;h=a,a=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(p===null&&(u=v),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=p,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Rt|=o,e.lanes=o,e.memoizedState=v}}function To(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Gl.transition;Gl.transition={};try{e(!1),t()}finally{F=n,Gl.transition=r}}function Uu(){return Le().memoizedState}function Cf(e,t,n){var r=ht(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Au(e))Bu(t,n);else if(n=ju(e,t,n,r),n!==null){var l=ce();Ie(n,e,r,l),Vu(n,t,r)}}function Ef(e,t,n){var r=ht(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Au(e))Bu(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,a=i(o,n);if(l.hasEagerState=!0,l.eagerState=a,$e(a,o)){var u=t.interleaved;u===null?(l.next=l,js(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=ju(e,t,l,r),n!==null&&(l=ce(),Ie(n,e,r,l),Vu(n,t,r))}}function Au(e){var t=e.alternate;return e===W||t!==null&&t===W}function Bu(e,t){On=rl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Vu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,os(e,n)}}var ll={readContext:ze,useCallback:ie,useContext:ie,useEffect:ie,useImperativeHandle:ie,useInsertionEffect:ie,useLayoutEffect:ie,useMemo:ie,useReducer:ie,useRef:ie,useState:ie,useDebugValue:ie,useDeferredValue:ie,useTransition:ie,useMutableSource:ie,useSyncExternalStore:ie,useId:ie,unstable_isNewReconciler:!1},_f={readContext:ze,useCallback:function(e,t){return Be().memoizedState=[e,t===void 0?null:t],e},useContext:ze,useEffect:Ro,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Or(4194308,4,Du.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Or(4194308,4,e,t)},useInsertionEffect:function(e,t){return Or(4,2,e,t)},useMemo:function(e,t){var n=Be();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Be();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Cf.bind(null,W,e),[r.memoizedState,e]},useRef:function(e){var t=Be();return e={current:e},t.memoizedState=e},useState:Mo,useDebugValue:Ls,useDeferredValue:function(e){return Be().memoizedState=e},useTransition:function(){var e=Mo(!1),t=e[0];return e=Nf.bind(null,e[1]),Be().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=W,l=Be();if(B){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),ee===null)throw Error(j(349));Mt&30||Eu(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Ro(Pu.bind(null,r,i,e),[e]),r.flags|=2048,er(9,_u.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Be(),t=ee.identifierPrefix;if(B){var n=Ge,r=Ye;n=(r&~(1<<32-Fe(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qn++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ve]=t,e[Xn]=r,qu(e,t,!1,!1),t.stateNode=e;e:{switch(o=pi(n,r),n){case"dialog":U("cancel",e),U("close",e),l=r;break;case"iframe":case"object":case"embed":U("load",e),l=r;break;case"video":case"audio":for(l=0;lfn&&(t.flags|=128,r=!0,Nn(i,!1),t.lanes=4194304)}else{if(!r)if(e=nl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!B)return se(t),null}else 2*G()-i.renderingStartTime>fn&&n!==1073741824&&(t.flags|=128,r=!0,Nn(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=G(),t.sibling=null,n=H.current,I(H,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return Fs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?xe&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Of(e,t){switch(vs(t),t.tag){case 1:return ve(t.type)&&Xr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cn(),A(me),A(ae),Cs(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ns(t),null;case 13:if(A(H),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));an()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return A(H),null;case 4:return cn(),null;case 10:return ws(t.type._context),null;case 22:case 23:return Fs(),null;case 24:return null;default:return null}}var Sr=!1,oe=!1,Ff=typeof WeakSet=="function"?WeakSet:Set,C=null;function Xt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){K(e,t,r)}else n.current=null}function Ai(e,t,n){try{n()}catch(r){K(e,t,r)}}var Wo=!1;function If(e,t){if(Si=Qr,e=iu(),hs(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,p=0,v=e,h=null;t:for(;;){for(var g;v!==n||l!==0&&v.nodeType!==3||(a=o+l),v!==i||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(g=v.firstChild)!==null;)h=v,v=g;for(;;){if(v===e)break t;if(h===n&&++c===l&&(a=o),h===i&&++p===r&&(u=o),(g=v.nextSibling)!==null)break;v=h,h=v.parentNode}v=g}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ni={focusedElem:e,selectionRange:n},Qr=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var x=w.memoizedProps,z=w.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?x:Re(t.type,x),z);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(y){K(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return w=Wo,Wo=!1,w}function Fn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Ai(t,n,i)}l=l.next}while(l!==r)}}function xl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Bi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function tc(e){var t=e.alternate;t!==null&&(e.alternate=null,tc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ve],delete t[Xn],delete t[_i],delete t[xf],delete t[wf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function nc(e){return e.tag===5||e.tag===3||e.tag===4}function Qo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Vi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gr));else if(r!==4&&(e=e.child,e!==null))for(Vi(e,t,n),e=e.sibling;e!==null;)Vi(e,t,n),e=e.sibling}function Hi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Hi(e,t,n),e=e.sibling;e!==null;)Hi(e,t,n),e=e.sibling}var ne=null,De=!1;function tt(e,t,n){for(n=n.child;n!==null;)rc(e,t,n),n=n.sibling}function rc(e,t,n){if(He&&typeof He.onCommitFiberUnmount=="function")try{He.onCommitFiberUnmount(dl,n)}catch{}switch(n.tag){case 5:oe||Xt(n,t);case 6:var r=ne,l=De;ne=null,tt(e,t,n),ne=r,De=l,ne!==null&&(De?(e=ne,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ne.removeChild(n.stateNode));break;case 18:ne!==null&&(De?(e=ne,n=n.stateNode,e.nodeType===8?Ql(e.parentNode,n):e.nodeType===1&&Ql(e,n),Wn(e)):Ql(ne,n.stateNode));break;case 4:r=ne,l=De,ne=n.stateNode.containerInfo,De=!0,tt(e,t,n),ne=r,De=l;break;case 0:case 11:case 14:case 15:if(!oe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Ai(n,t,o),l=l.next}while(l!==r)}tt(e,t,n);break;case 1:if(!oe&&(Xt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){K(n,t,a)}tt(e,t,n);break;case 21:tt(e,t,n);break;case 22:n.mode&1?(oe=(r=oe)||n.memoizedState!==null,tt(e,t,n),oe=r):tt(e,t,n);break;default:tt(e,t,n)}}function Ko(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ff),t.forEach(function(r){var l=Kf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Me(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~i}if(r=l,r=G()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Uf(r/1960))-r,10e?16:e,ot===null)var r=!1;else{if(e=ot,ot=null,ol=0,D&6)throw Error(j(331));var l=D;for(D|=4,C=e.current;C!==null;){var i=C,o=i.child;if(C.flags&16){var a=i.deletions;if(a!==null){for(var u=0;uG()-Ds?Pt(e,0):Rs|=n),ge(e,t)}function dc(e,t){t===0&&(e.mode&1?(t=hr,hr<<=1,!(hr&130023424)&&(hr=4194304)):t=1);var n=ce();e=qe(e,t),e!==null&&(rr(e,t,n),ge(e,n))}function Qf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),dc(e,n)}function Kf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),dc(e,n)}var fc;fc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||me.current)he=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return he=!1,Rf(e,t,n);he=!!(e.flags&131072)}else he=!1,B&&t.flags&1048576&&vu(t,qr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fr(e,t),e=t.pendingProps;var l=on(t,ae.current);tn(t,n),l=_s(null,t,r,e,l,n);var i=Ps();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ve(r)?(i=!0,Zr(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,ks(t),l.updater=yl,t.stateNode=l,l._reactInternals=t,Ri(t,r,e,n),t=Fi(null,t,r,!0,i,n)):(t.tag=0,B&&i&&ms(t),ue(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Gf(r),e=Re(r,e),l){case 0:t=Oi(null,t,r,e,n);break e;case 1:t=Bo(null,t,r,e,n);break e;case 11:t=Uo(null,t,r,e,n);break e;case 14:t=Ao(null,t,r,Re(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Oi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Bo(e,t,r,l,n);case 3:e:{if(Xu(t),e===null)throw Error(j(387));r=t.pendingProps,i=t.memoizedState,l=i.element,ku(e,t),tl(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=dn(Error(j(423)),t),t=Vo(e,t,r,n,l);break e}else if(r!==l){l=dn(Error(j(424)),t),t=Vo(e,t,r,n,l);break e}else for(we=dt(t.stateNode.containerInfo.firstChild),je=t,B=!0,Oe=null,n=wu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(an(),r===l){t=be(e,t,n);break e}ue(e,t,r,n)}t=t.child}return t;case 5:return Su(t),e===null&&Li(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,o=l.children,Ci(r,l)?o=null:i!==null&&Ci(r,i)&&(t.flags|=32),Gu(e,t),ue(e,t,o,n),t.child;case 6:return e===null&&Li(t),null;case 13:return Zu(e,t,n);case 4:return Ss(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=un(t,null,r,n):ue(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Uo(e,t,r,l,n);case 7:return ue(e,t,t.pendingProps,n),t.child;case 8:return ue(e,t,t.pendingProps.children,n),t.child;case 12:return ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,o=l.value,I(br,r._currentValue),r._currentValue=o,i!==null)if($e(i.value,o)){if(i.children===l.children&&!me.current){t=be(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Xe(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ti(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(j(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Ti(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}ue(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,tn(t,n),l=ze(l),r=r(l),t.flags|=1,ue(e,t,r,n),t.child;case 14:return r=t.type,l=Re(r,t.pendingProps),l=Re(r.type,l),Ao(e,t,r,l,n);case 15:return Ku(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Fr(e,t),t.tag=1,ve(r)?(e=!0,Zr(t)):e=!1,tn(t,n),Hu(t,r,l),Ri(t,r,l,n),Fi(null,t,r,!0,e,n);case 19:return Ju(e,t,n);case 22:return Yu(e,t,n)}throw Error(j(156,t.tag))};function pc(e,t){return Aa(e,t)}function Yf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _e(e,t,n,r){return new Yf(e,t,n,r)}function $s(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gf(e){if(typeof e=="function")return $s(e)?1:0;if(e!=null){if(e=e.$$typeof,e===rs)return 11;if(e===ls)return 14}return 2}function mt(e,t){var n=e.alternate;return n===null?(n=_e(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ur(e,t,n,r,l,i){var o=2;if(r=e,typeof e=="function")$s(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case At:return zt(n.children,l,i,t);case ns:o=8,l|=8;break;case ri:return e=_e(12,n,t,l|2),e.elementType=ri,e.lanes=i,e;case li:return e=_e(13,n,t,l),e.elementType=li,e.lanes=i,e;case ii:return e=_e(19,n,t,l),e.elementType=ii,e.lanes=i,e;case Sa:return jl(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ja:o=10;break e;case ka:o=9;break e;case rs:o=11;break e;case ls:o=14;break e;case nt:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=_e(o,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function zt(e,t,n,r){return e=_e(7,e,r,t),e.lanes=n,e}function jl(e,t,n,r){return e=_e(22,e,r,t),e.elementType=Sa,e.lanes=n,e.stateNode={isHidden:!1},e}function bl(e,t,n){return e=_e(6,e,null,t),e.lanes=n,e}function ei(e,t,n){return t=_e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Xf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dl(0),this.expirationTimes=Dl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Us(e,t,n,r,l,i,o,a,u){return e=new Xf(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=_e(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ks(i),e}function Zf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gc)}catch(e){console.error(e)}}gc(),ga.exports=Se;var tp=ga.exports,yc,ea=tp;yc=ea.createRoot,ea.hydrateRoot;const xc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},np=()=>!!xc();async function O(e,...t){const n=xc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const $={session:()=>O("Session"),login:(e,t)=>O("Login",e,t),logout:()=>O("Logout"),claim:e=>O("Claim",e),runStandalone:()=>O("RunStandalone"),engineStatus:()=>O("EngineStatus"),startEngine:()=>O("StartEngine"),stopEngine:()=>O("StopEngine"),cameras:()=>O("Cameras"),testCamera:e=>O("TestCamera",e),saveCamera:(e,t)=>O("SaveCamera",e,t),deleteCamera:e=>O("DeleteCamera",e),startPlacement:(e,t)=>O("StartPlacementCheck",e,t),placementResult:e=>O("PlacementResult",e),streamURL:e=>O("StreamURL",e),live:()=>O("Live"),pipelineStatus:()=>O("PipelineStatus"),localIdentities:e=>O("LocalIdentities",e),localSightings:e=>O("LocalSightings",e),footfall:(e,t,n)=>O("Footfall",e,t,n),sites:()=>O("Sites"),visitorHistory:(e,t)=>O("VisitorHistory",e,t),visitorPhoto:e=>O("VisitorPhoto",e),forgetCustomer:e=>O("ForgetCustomer",e),sales:(e,t)=>O("Sales",e,t),customers:(e,t)=>O("Customers",e,t),saveProfile:e=>O("SaveProfile",e),ask:e=>O("Ask",e),recordPurchase:(e,t,n,r)=>O("RecordPurchase",e,t,n,r)};function ye(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function Ot(e,t,n=[]){const[r,l]=P.useState(null),[i,o]=P.useState(null),[a,u]=P.useState(!0),c=P.useRef(!0),p=P.useRef(!1),v=P.useCallback(async()=>{if(!p.current){p.current=!0;try{const h=await e();if(!c.current)return;l(h),o(null)}catch(h){c.current&&o(ye(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return P.useEffect(()=>{if(c.current=!0,v(),!t)return()=>{c.current=!1};const h=setInterval(v,t);return()=>{c.current=!1,clearInterval(h)}},[v,t]),{data:r,error:i,loading:a,reload:v}}function rp(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ta(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleDateString([],{day:"numeric",month:"short"})}const ti={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"};function te({size:e,children:t,...n}){return s.jsx("svg",{...ti,...n,width:e??ti.width,height:e??ti.height,children:t})}const lp=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),s.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),ip=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),s.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),s.jsx("path",{d:"M16.5 6.2a3.2 3.2 0 0 1 0 6.1M18 19.5a6 6 0 0 0-1.6-4"})]}),sp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),s.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),op=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),s.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),na=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Hs=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),wc=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),jc=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),ap=e=>s.jsx(te,{...e,children:s.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Ue=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M12 4.6 21 19.4H3z"}),s.jsx("path",{d:"M12 10v4.1"}),s.jsx("path",{d:"M12 17.1v.01"})]}),ra=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),up=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 .3 9.4z"})}),kc=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35 6.2 6.2 0 0 1 2-3.2M10.6 5.2A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 1.9 7.6"}),s.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),cp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M10.2 13.8a3.6 3.6 0 0 0 5.2 0l2.8-2.8a3.7 3.7 0 0 0-5.2-5.2l-1.3 1.3"}),s.jsx("path",{d:"M13.8 10.2a3.6 3.6 0 0 0-5.2 0l-2.8 2.8a3.7 3.7 0 0 0 5.2 5.2l1.3-1.3"})]}),dp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),s.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),fp=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),Sc=e=>s.jsxs(te,{...e,strokeWidth:"1.2",children:[s.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),s.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),s.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),Nc=e=>s.jsxs(te,{...e,strokeWidth:"1.2",children:[s.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),s.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),rn=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function pp({onDone:e}){const[t,n]=P.useState(""),[r,l]=P.useState(""),[i,o]=P.useState(!1),[a,u]=P.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await $.login(t.trim(),r))}catch(v){u(ye(v))}finally{o(!1)}}return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:"Behavision"}),s.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),s.jsxs("form",{onSubmit:c,children:[a&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),a]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Email"}),s.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Password"}),s.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),s.jsx("button",{className:"btn primary",disabled:i||!t||!r,children:i?"Signing in…":"Sign in"})]}),s.jsx("p",{className:"foot",children:"Signing in downloads this store's recognition models and connects it to your account. Nothing is sent until a camera is set up."})]})})}function la({onDone:e,onCancel:t}){const[n,r]=P.useState(""),[l,i]=P.useState(null),[o,a]=P.useState(null),[u,c]=P.useState(!1);async function p(h){h.preventDefault(),i("claim"),a(null);try{e(await $.claim(n))}catch(g){a(ye(g))}finally{i(null)}}async function v(){i("alone"),a(null);try{e(await $.runStandalone())}catch(h){a(ye(h))}finally{i(null)}}return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:t?"Link to head office":"Set up this PC"}),s.jsx("p",{className:"lead",children:"Type the installation code for this shop. You only do this once."}),s.jsxs("form",{onSubmit:p,children:[o&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),o]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Installation code"}),s.jsx("input",{value:n,autoFocus:!0,required:!0,placeholder:"ABCDEF-123456-GHIJKL-789012",autoComplete:"off",spellCheck:"false",style:{textTransform:"uppercase",letterSpacing:".06em"},onChange:h=>r(h.target.value)})]}),s.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),s.jsx("p",{className:"foot",children:"The code works once. Ask whoever manages your shops for it — they can create one from the Behavision platform, under the shop."}),s.jsx("div",{className:"alt",children:t?s.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):u?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"note",children:"This PC will watch its cameras and recognise returning customers on its own. Nothing is sent anywhere. You can link it to head office later without losing anything recorded here."}),s.jsx("button",{type:"button",className:"btn",disabled:!!l,onClick:v,children:l==="alone"?"Setting up…":"Use this PC on its own"})]}):s.jsx("button",{type:"button",className:"linkbtn",onClick:()=>c(!0),children:"No head office — set this PC up on its own"})})]})})}function Cc(){var p,v;const{data:e,error:t}=Ot(()=>$.live(),3e3),{data:n}=Ot(()=>$.pipelineStatus(),5e3),r=((p=e==null?void 0:e.stats)==null?void 0:p.cameras)??[],l=((v=e==null?void 0:e.stats)==null?void 0:v.gallery)??{},i=(e==null?void 0:e.events)??[],o=r.reduce((h,g)=>{var x,z;const w=(z=(x=g==null?void 0:g.pipeline)==null?void 0:x.best_quality)==null?void 0:z.fraction_below_gate;return typeof w=="number"&&w>h?w:h},0),a=r.filter(h=>h.connected).length,u=i.filter(h=>h.type==="person.new"||h.type==="person.seen"),c=gp(u[0]);return s.jsxs("div",{className:"page",children:[s.jsxs("header",{children:[s.jsx("h2",{children:"Live"}),s.jsx("p",{children:"Who is in the shop, and whether it is reaching head office."})]}),t&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),t]}),s.jsx(vp,{pipe:n,cameras:r,up:a}),s.jsxs("div",{className:"panel arrivals-panel",children:[s.jsxs("div",{className:"panelhead",children:[s.jsx("h3",{children:"Who just walked in"}),u.length>0&&s.jsxs("span",{className:"note",children:[u.length," today"]})]}),s.jsx("div",{className:"panelbody flush",children:u.length===0?s.jsxs("div",{className:"empty",children:[s.jsx(Nc,{size:34}),s.jsx("b",{children:"Nobody yet"}),s.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):s.jsx("div",{className:"arrivals",children:u.slice(0,30).map((h,g)=>s.jsx(hp,{e:h,fresh:g===0&&c},`${h.ts}-${g}`))})})]}),s.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[s.jsx(Er,{k:"People known",v:l.identities??"—"}),s.jsx(Er,{k:"Sightings",v:l.sightings??"—"}),s.jsx(Er,{k:"Cameras live",v:r.length?`${a}/${r.length}`:"—",tone:r.length?a===0?"bad":a.5?"bad":o>.2?"warn":"ok",s:o>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function hp({e,fresh:t}){var o,a,u,c,p,v;const n=e.type==="person.new",r=((o=e.data)==null?void 0:o.label)||"Unrecognised",l=[(a=e.data)==null?void 0:a.gender,((u=e.data)==null?void 0:u.age)??((c=e.data)==null?void 0:c.age_range),(p=e.data)==null?void 0:p.emotion].filter(Boolean),i=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return s.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[s.jsx("div",{className:"avatar",children:mp(r)}),s.jsxs("div",{className:"who",children:[s.jsx("div",{className:"name",children:r}),s.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&s.jsxs(s.Fragment,{children:[" · ",l.join(", ")]}),i!==null&&!n&&s.jsxs(s.Fragment,{children:[" · match ",i.toFixed(2)]})]})]}),s.jsxs("div",{className:"right",children:[s.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),s.jsx("span",{className:"when",children:rp(e.ts)})]})]})}function mp(e){var r;const t=/^Visitor (\d+)$/.exec(String(e).trim());if(t)return t[1];const n=String(e).trim().split(/\s+/).filter(Boolean);return n.length?(n[0][0]+(((r=n[1])==null?void 0:r[0])??"")).toUpperCase():"?"}function vp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return s.jsxs("div",{className:"statusbar",children:[s.jsxs("span",{className:"item",children:[s.jsx("i",{className:"dot ok"}),s.jsx("b",{children:"Running on this PC only"})]}),s.jsx("span",{className:"sep"}),s.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),s.jsx("span",{className:"grow"}),s.jsxs("span",{className:"item note",children:[s.jsx(ra,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",i=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return s.jsxs("div",{className:"statusbar",children:[s.jsxs("span",{className:"item",children:[e.broker_up?s.jsx(up,{size:15}):s.jsx(kc,{size:15}),s.jsx("i",{className:`dot ${l}`}),s.jsx("b",{children:i})]}),s.jsx("span",{className:"sep"}),s.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&s.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&s.jsxs("span",{className:"item note bad",children:[s.jsx(Ue,{size:14}),e.dropped," lost — this PC was offline too long"]}),s.jsx("span",{className:"grow"}),s.jsxs("span",{className:"item note",children:[s.jsx(ra,{size:14}),n," of ",t.length," cameras"]})]})}function Er({k:e,v:t,s:n,tone:r}){return s.jsxs("div",{className:`metric ${r??""}`,children:[s.jsx("div",{className:"metric-k",children:e}),s.jsx("div",{className:"metric-v",children:t}),n&&s.jsx("div",{className:"metric-s",children:n})]})}function gp(e){const[t,n]=P.useState(!1),r=P.useRef(null);return P.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const i=setTimeout(()=>n(!1),1200);return()=>clearTimeout(i)},[e==null?void 0:e.ts]),t}function yp(e){const[t,n]=P.useState(null);return P.useEffect(()=>{let r=!0;return n(null),$.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function xp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?s.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):s.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:s.jsx("span",{children:wp(t,n)})})}function wp(e,t){const n=/^Visitor (\d+)$/.exec(String(e||"").trim());if(n)return n[1];const r=/^V-(\d+)$/.exec(String(t||""));return r?r[1]:String(e||"").split(/\s+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?"}function jp({customer:e}){const{data:t,error:n,loading:r}=Ot(()=>$.visitorHistory(e.id,50),0,[e.id]);if(r)return s.jsx("p",{className:"note",children:"Loading visits…"});if(n)return s.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?s.jsx("p",{className:"note",children:"No recorded visits yet."}):s.jsx("ul",{className:"timeline",children:l.map(i=>s.jsxs("li",{children:[s.jsx("span",{className:"when",children:kp(i.occurred_at)}),s.jsxs("span",{className:"where",children:[i.site||"this store",i.camera_id?s.jsxs("span",{className:"note",children:[" · ",i.camera_id]}):null]}),i.is_new_visitor&&s.jsx("span",{className:"tag new",children:"first visit"})]},i.id))})}function kp(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function Sp({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,i]=P.useState(""),[o,a]=P.useState(!1),[u,c]=P.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await $.forgetCustomer(e.id),n()}catch(h){c(ye(h)),a(!1)}}return s.jsxs("div",{className:"confirm",children:[s.jsxs("h4",{children:["Erase ",r,"?"]}),s.jsxs("div",{className:"cols",children:[s.jsxs("div",{children:[s.jsx("p",{className:"lbl bad",children:"Deleted for good"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Their face data — they will not be recognised again"}),s.jsx("li",{children:"Their photo"}),s.jsx("li",{children:"Their name, phone, email and notes"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"lbl",children:"Kept"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),s.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),s.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&s.jsx("div",{className:"err",children:u}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Type ",s.jsx("b",{children:r})," to confirm"]}),s.jsx("input",{value:l,onChange:h=>i(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),s.jsxs("div",{className:"row",children:[s.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),s.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function Np({customer:e,session:t,onClose:n,onSaved:r}){var N;const[l,i]=P.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=P.useState({amount:"",items:"",notes:""}),[u,c]=P.useState(!1),[p,v]=P.useState(null),[h,g]=P.useState(!1),[w,x]=P.useState(null),z=yp(e.id),f=w??z,d=(N=t==null?void 0:t.user)==null?void 0:N.role,m=["admin","owner","manager"].includes(d),y=S=>_=>i({...l,[S]:_.target.value});async function k(S){S.preventDefault(),c(!0),v(null);try{await $.saveProfile({visitor_id:e.id,...l});const _=parseFloat(o.amount);if(!isNaN(_)&&_>0){const V=o.items.split(",").map(M=>M.trim()).filter(Boolean);await $.recordPurchase(e.id,_,V,o.notes)}r()}catch(_){v(ye(_))}finally{c(!1)}}return s.jsx("div",{className:"drawer",onMouseDown:S=>S.target===S.currentTarget&&n(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead who",children:[s.jsx(xp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>x({available:!1,reason:"The photo could not be loaded."})}),s.jsxs("div",{className:"grow",children:[s.jsx("h2",{children:e.full_name||e.label}),s.jsxs("p",{className:"note",children:[e.visit_count," visit",e.visit_count===1?"":"s",e.last_seen_at&&` · last seen ${new Date(e.last_seen_at).toLocaleDateString()}`,f&&!f.available&&f.reason&&` · ${f.reason}`]})]}),s.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),s.jsxs("form",{className:"sheetbody",onSubmit:k,children:[p&&s.jsx("div",{className:"err",children:p}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Customer details"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Full name"}),s.jsx("input",{value:l.full_name,onChange:y("full_name"),autoFocus:!0})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Phone"}),s.jsx("input",{value:l.phone,onChange:y("phone"),inputMode:"tel"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Email"}),s.jsx("input",{value:l.email,onChange:y("email"),type:"email"})]})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Gender"}),s.jsxs("select",{value:l.gender,onChange:y("gender"),children:[s.jsx("option",{value:"",children:"Not recorded"}),s.jsx("option",{children:"Female"}),s.jsx("option",{children:"Male"}),s.jsx("option",{children:"Other"})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Date of birth"}),s.jsx("input",{type:"date",value:l.date_of_birth,onChange:y("date_of_birth")})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Notes"}),s.jsx("textarea",{value:l.notes,onChange:y("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Purchase (optional)"}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Amount"}),s.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:S=>a({...o,amount:S.target.value})})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Items"}),s.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:S=>a({...o,items:S.target.value})})]})]}),s.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Consent"}),s.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:S=>i({...l,consent:S.target.checked})}),s.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),s.jsx("p",{className:"note",style:{marginTop:10},children:"Recorded with the date and who collected it. They can withdraw it at any time, which erases their face data."})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Visits"}),s.jsx(jp,{customer:e})]}),s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&s.jsxs("section",{className:"formsection dangerzone",children:[s.jsx("h4",{children:"At the customer's request"}),h?s.jsx(Sp,{customer:e,onCancel:()=>g(!1),onDone:r}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"note",children:"Erase this person's face data, photo and details. Their past visits stay in your footfall figures, without their name."}),s.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function Cp({session:e}){const[t,n]=P.useState(""),[r,l]=P.useState(null),{data:i,error:o,reload:a}=Ot(()=>$.customers(t,200),3e4,[t]),u=i??[],c=u.filter(p=>p.has_profile).length;return s.jsxs("div",{className:"page",children:[s.jsxs("header",{className:"pagehead",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Customers"}),s.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),s.jsxs("label",{className:"search",children:[s.jsx(op,{size:15}),s.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),o]}),s.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[s.jsx(_r,{k:"Known people",v:u.length||"—"}),s.jsx(_r,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),s.jsx(_r,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),s.jsx(_r,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),s.jsx("div",{className:"panel",children:u.length===0?s.jsxs("div",{className:"empty tall",children:[s.jsx(Nc,{size:34}),s.jsx("b",{children:"No customers yet"}),s.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):s.jsx("div",{className:"tablewrap",children:s.jsxs("table",{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Customer"}),s.jsx("th",{children:"Phone"}),s.jsx("th",{className:"num",children:"Visits"}),s.jsx("th",{children:"First seen"}),s.jsx("th",{children:"Last seen"}),s.jsx("th",{children:"Details"})]})}),s.jsx("tbody",{children:u.map(p=>s.jsxs("tr",{className:"click",onClick:()=>l(p),children:[s.jsxs("td",{children:[p.full_name||s.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&s.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),s.jsx("td",{className:"mono",children:p.phone||"—"}),s.jsx("td",{className:"num",children:p.visit_count}),s.jsx("td",{children:ta(p.first_seen_at)}),s.jsx("td",{children:ta(p.last_seen_at)}),s.jsx("td",{children:p.has_profile?s.jsxs("span",{className:"pill ok",children:[s.jsx("i",{className:"dot ok"}),"captured"]}):s.jsxs("span",{className:"pill warn",children:[s.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&s.jsx(Np,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function _r({k:e,v:t,s:n}){return s.jsxs("div",{className:"metric",children:[s.jsx("div",{className:"metric-k",children:e}),s.jsx("div",{className:"metric-v",children:t}),n&&s.jsx("div",{className:"metric-s",children:n})]})}const ln=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],ia=e=>ln.find(t=>t.id===e)||ln[ln.length-1],Gi={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280};function Ep(){const{data:e,error:t,reload:n}=Ot(()=>$.cameras(),8e3),[r,l]=P.useState(null),[i,o]=P.useState(null),a=e??[],u=Pp(a);async function c(p){if(confirm(`Remove ${p.id}? Recognition from it stops immediately.`))try{await $.deleteCamera(p.id),n()}catch(v){alert(ye(v))}}return s.jsxs("div",{className:"page",children:[s.jsxs("header",{className:"pagehead",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Cameras"}),s.jsx("p",{children:"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),s.jsxs("button",{className:"btn primary",onClick:()=>l({...Gi}),children:[s.jsx(na,{size:15}),"Add camera"]})]}),t&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),t]}),a.length===0?s.jsx("div",{className:"panel",children:s.jsxs("div",{className:"empty tall",children:[s.jsx(Sc,{size:40}),s.jsx("b",{children:"No cameras yet"}),s.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),s.jsxs("button",{className:"btn primary",onClick:()=>l({...Gi}),children:[s.jsx(na,{size:15}),"Add your first camera"]})]})}):s.jsx("div",{className:"camgrid",children:a.map(p=>s.jsx(_p,{cam:p,stream:u[p.id],onEdit:()=>l(p),onCheck:()=>o(p.id),onRemove:()=>c(p)},p.id))}),r&&s.jsx(zp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),i&&s.jsx(Lp,{id:i,onClose:()=>o(null)})]})}function _p({cam:e,stream:t,onEdit:n,onCheck:r,onRemove:l}){const i=e.connected===void 0?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:o}=Ot(()=>$.placementResult(e.id),15e3,[e.id]),a=!o||o.running||!o.verdict||o.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:o.verdict==="good"?{tone:"seen",label:"Proven",text:o.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:o.headline||"Move the camera and check again."};return s.jsxs("article",{className:"camcard",children:[s.jsxs("div",{className:"camview",children:[t?s.jsx("img",{src:t,alt:e.id}):s.jsx("div",{className:"placeholder",children:s.jsx(Sc,{size:34})}),s.jsxs("span",{className:`pill ${i.tone==="idle"?"":i.tone} over`,children:[s.jsx("i",{className:`dot ${i.tone}`}),i.label]})]}),s.jsxs("div",{className:"cambody",children:[s.jsxs("div",{className:"camtitle",children:[s.jsxs("div",{children:[s.jsx("h3",{children:e.id}),s.jsxs("span",{className:"mono note",children:[e.host||e.url,e.path?` · ${e.path}`:""]})]}),s.jsxs("div",{className:"camactions",children:[s.jsx("button",{className:"btn sm",onClick:n,children:"Edit"}),s.jsx("button",{className:"btn sm danger",onClick:l,children:"Remove"})]})]}),s.jsxs("div",{className:"camproof",children:[s.jsx("span",{className:`tag ${a.tone}`,children:a.label}),s.jsx("span",{className:"note",children:a.text}),s.jsxs("button",{className:`btn sm ${a.tone==="seen"?"":"primary"}`,onClick:r,children:[s.jsx(jc,{size:13}),a.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Pp(e){const[t,n]=P.useState({});return P.useEffect(()=>{let r=!0;const l=e.filter(i=>!(i.id in t));if(l.length)return(async()=>{const i={};for(const o of l)try{i[o.id]=await $.streamURL(o.id)}catch{i[o.id]=""}r&&n(o=>({...o,...i}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function zp({cam:e,onClose:t,onSaved:n}){const r=!e.id,[l,i]=P.useState({...Gi,...e,password:"",path:e.path||(r?ln[0].path:"")}),[o,a]=P.useState(r?ln[0].id:"manual"),[u,c]=P.useState(null),[p,v]=P.useState(null),[h,g]=P.useState(null),w=y=>k=>i({...l,[y]:k.target.value});function x(y){const k=ia(y.target.value);a(k.id),i(N=>({...N,path:k.path||N.path}))}function z(){const y={};for(const[k,N]of Object.entries(l))N===""||N===null||N===void 0||(y[k]=k==="port"||k==="max_width"?Number(N):N);return y}async function f(){v("test"),g(null),c(null);try{c(await $.testCamera(z()))}catch(y){g(ye(y))}finally{v(null)}}async function d(y){y.preventDefault(),v("save"),g(null);try{await $.saveCamera(r?"":e.id,z()),n()}catch(k){g(ye(k))}finally{v(null)}}const m=ia(o);return s.jsx("div",{className:"drawer",onMouseDown:y=>y.target===y.currentTarget&&t(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead",children:[s.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("form",{className:"sheetbody",onSubmit:d,autoComplete:"off",children:[s.jsx("p",{className:"lead",children:"Three things from the camera: its address, its make, and its password. Test before you save — a wrong address is the most common mistake."}),h&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),h]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"The camera"}),r&&s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Name"}),s.jsx("input",{value:l.id,onChange:w("id"),placeholder:"entrance",required:!0,autoFocus:!0}),s.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Address"}),s.jsx("input",{value:l.host,onChange:w("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),s.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),s.jsxs("label",{className:"field narrow",children:[s.jsx("span",{children:"Port"}),s.jsx("input",{value:l.port,onChange:w("port"),inputMode:"numeric"})]})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"The stream"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Make of camera"}),s.jsx("select",{value:o,onChange:x,children:ln.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))}),m.note&&s.jsx("em",{className:"hint",children:m.note})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Stream path"}),s.jsx("input",{className:"mono",value:l.path,onChange:w("path"),placeholder:"/Streaming/Channels/101"}),s.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Sign-in to the camera"}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Username"}),s.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:w("username"),placeholder:"admin"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Password"}),s.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:w("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),u&&(u.ok?s.jsxs("div",{className:"testresult ok",children:[s.jsx(wc,{size:16}),s.jsxs("div",{children:[s.jsxs("b",{children:["Connected — ",u.width,"×",u.height,u.codec?` · ${String(u.codec).toUpperCase()}`:""]}),u.snapshot&&s.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${u.snapshot}`})]})]}):s.jsxs("div",{className:"testresult bad",children:[s.jsx(Ue,{size:16}),s.jsxs("div",{children:[s.jsx("b",{children:"Could not connect"}),s.jsx("span",{children:u.error})]})]})),s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{type:"button",className:"btn",onClick:f,disabled:!!p||!l.host,children:p==="test"?"Connecting…":"Test connection"}),s.jsx("button",{className:"btn primary",disabled:!!p||!l.id||!l.host,children:p==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Lp({id:e,onClose:t}){var p,v;const[n,r]=P.useState({verdict:"starting",advice:[]}),[l,i]=P.useState(null),o=P.useRef(null);P.useEffect(()=>{let h=!0;return(async()=>{try{r(await $.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await $.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&i(ye(g))}},1e3)}catch(g){h&&i(ye(g))}})(),()=>{h=!1,clearInterval(o.current)}},[e]);const a={good:"ok",marginal:"warn",poor:"bad",artifact:"bad",no_faces:"warn",inconclusive:"warn",no_completed_passes:"warn"}[n.verdict],u=n.seconds?Math.min(100,n.elapsed/n.seconds*100):0,c=n.running||n.verdict==="starting";return s.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead",children:[s.jsxs("h2",{children:["Check placement · ",e]}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("div",{className:"sheetbody",children:[l&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),l]}),s.jsxs("ol",{className:"steps",children:[s.jsxs("li",{className:c?"now":"done",children:[s.jsx("b",{children:"Walk past the camera"}),s.jsx("span",{children:"The way a customer would — in through the door, not looking at the lens. Two or three times, for about 25 seconds."}),c&&s.jsx("div",{className:"progress",children:s.jsx("div",{style:{width:`${u}%`}})})]}),s.jsxs("li",{className:c?"":"now",children:[s.jsx("b",{children:"Behavision judges what it saw"}),s.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),s.jsxs("div",{className:`verdict ${a??""}`,children:[s.jsxs("div",{className:"verdict-head",children:[c?s.jsx("span",{className:"spinner"}):a==="ok"?s.jsx(wc,{size:18}):s.jsx(Ue,{size:18}),s.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&s.jsx("ul",{children:n.advice.map((h,g)=>s.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&s.jsxs("p",{className:"note",children:[n.quality.n," face",n.quality.n===1?"":"s"," seen · median quality ",n.quality.p50," ·"," ",Math.round((n.quality.fraction_below_gate??0)*100),"% too poor to use"]})]}),!c&&s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{className:"btn",onClick:t,children:"Close"}),s.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),$.startPlacement(e,25).then(r).catch(h=>i(ye(h)))},children:"Run again"})]})]})]})})}const Tp=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Mp({session:e,onClose:t}){const[n,r]=P.useState([]),[l,i]=P.useState(""),[o,a]=P.useState(!1),[u,c]=P.useState(null),p=P.useRef(null),v=e==null?void 0:e.standalone;P.useEffect(()=>{var g;(g=p.current)==null||g.scrollTo({top:1e9,behavior:"smooth"})},[n,o]);async function h(g){const w=(g??l).trim();if(!w||o)return;const x=[...n,{role:"user",text:w}];r(x),i(""),a(!0),c(null);try{const z=await $.ask(x.map(f=>({role:f.role,text:f.text})));r([...x,{role:"assistant",text:z.text,used:z.used??[]}])}catch(z){c(ye(z)),r(n),i(w)}finally{a(!1)}}return s.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[s.jsxs("header",{className:"helperhead",children:[s.jsx("img",{src:rn,alt:""}),s.jsxs("div",{children:[s.jsx("b",{children:"Loya"}),s.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("div",{className:"helperbody",ref:p,children:[v&&s.jsxs("div",{className:"helpernote",children:[s.jsx(kc,{size:16}),s.jsxs("div",{children:[s.jsx("b",{children:"This PC runs on its own"}),s.jsx("span",{children:"Loya lives at head office. Link this PC to a shop to talk to her; the basics are below."})]})]}),n.length===0&&s.jsxs("div",{className:"helperintro",children:[s.jsx("div",{className:"turn assistant",children:s.jsxs("div",{className:"bubble",children:[Rp(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),s.jsx("div",{className:"chips",children:Tp.map(g=>s.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&s.jsx(Dp,{})]}),n.map((g,w)=>{var x;return s.jsxs("div",{className:`turn ${g.role}`,children:[s.jsx("div",{className:"bubble",children:g.text}),((x=g.used)==null?void 0:x.length)>0&&s.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},w)}),o&&s.jsx("div",{className:"turn assistant",children:s.jsxs("div",{className:"bubble thinking",children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{})]})}),u&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),u]})]}),s.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[s.jsx("input",{value:l,onChange:g=>i(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),s.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:s.jsx(fp,{size:16})})]})]})}function Rp(e){var l,i;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(i=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:i.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function Dp(){return s.jsxs("dl",{className:"quickhelp",children:[s.jsx("dt",{children:"Adding a camera"}),s.jsx("dd",{children:"Cameras → Add camera. The address is on a label on the camera; pick the make and the stream path fills itself in. Test, then save."}),s.jsx("dt",{children:"Proving it works"}),s.jsx("dd",{children:"Press Check placement and walk past the camera like a customer for 25 seconds. Only “good” means it can recognise faces — otherwise move it to head height, facing the way people approach."}),s.jsx("dt",{children:"Nothing showing on Live"}),s.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),s.jsx("dt",{children:"Linking to head office later"}),s.jsx("dd",{children:"Use the link button at the bottom of the sidebar and type an installation code from head office. Nothing recorded here is lost."})]})}const Op=[{id:"live",label:"Live",Glyph:lp,View:Cc},{id:"customers",label:"Customers",Glyph:ip,View:Cp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:sp,View:Ep}];function Fp(){var h,g,w;const[e,t]=P.useState(null),[n,r]=P.useState("live"),[l,i]=P.useState(!0),[o,a]=P.useState(!1),[u,c]=P.useState(!1);if(P.useEffect(()=>{let x=!0;const z=async()=>{try{const d=await $.session();x&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{x&&t(null)}x&&i(!1)};z();const f=setInterval(z,8e3);return()=>{x=!1,clearInterval(f)}},[]),!np())return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:"Behavision"}),s.jsx("p",{className:"lead",children:"This is the Behavision window running outside the app, so it has no connection to the recognition engine. Launch the Behavision application instead."})]})});if(l)return s.jsx("div",{className:"login",children:s.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return s.jsx(la,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return s.jsx(pp,{onDone:t});const p=Op.filter(x=>!x.cloud||!e.standalone),v=((h=p.find(x=>x.id===n))==null?void 0:h.View)??Cc;return o?s.jsx(la,{onDone:x=>{a(!1),t(x)},onCancel:()=>a(!1)}):s.jsxs("div",{className:"shell",children:[s.jsxs("aside",{className:"side",children:[s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsxs("div",{className:"id",children:[s.jsx("h1",{children:"Behavision"}),s.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),s.jsx("nav",{className:"nav",children:p.map(({id:x,label:z,Glyph:f})=>s.jsxs("button",{onClick:()=>r(x),"aria-current":x===n?"page":void 0,children:[s.jsx(f,{size:17}),z]},x))}),s.jsx(Ip,{}),s.jsx("div",{className:"who",children:e.standalone?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id",children:[s.jsx("b",{children:"On its own"}),s.jsx("span",{children:"No head office"})]}),s.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:s.jsx(cp,{size:15})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id",children:[s.jsx("b",{children:"Signed in"}),s.jsx("span",{children:(w=e.user)==null?void 0:w.email})]}),s.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await $.logout()),children:s.jsx(dp,{size:15})})]})})]}),s.jsxs("main",{className:"main",children:[s.jsx(v,{session:e}),!u&&s.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[s.jsx("img",{src:rn,alt:""}),s.jsx("span",{children:"Loya"})]})]}),u&&s.jsx(Mp,{session:e,onClose:()=>c(!1)})]})}function Ip(){const{data:e,reload:t}=Ot(()=>$.engineStatus(),5e3),[n,r]=P.useState(!1),l=e??{state:"stopped"},i=P.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(ye(h))}finally{r(!1),t()}},[t]),o=l.state==="running",a=Object.values(l.cameras??{}),u=a.filter(Boolean).length;let c="idle",p="Stopped";return!o&&l.reachable?(c="warn",p="Running outside the app"):l.state==="failed"||l.state==="backoff"?(c="bad",p="Not running"):o&&!l.reachable?(c="warn",p="Starting…"):o&&a.length===0?(c="warn",p="No cameras"):o&&u===0?(c="bad",p="No camera connected"):o&&ui($.startEngine),children:[s.jsx(jc,{size:13}),"Start"]}),s.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>i($.stopEngine),children:[s.jsx(ap,{size:13}),"Stop"]})]})]})}yc(document.getElementById("root")).render(s.jsx(Hc.StrictMode,{children:s.jsx(Fp,{})})); +`+i.stack}return{value:e,source:t,stack:l,digest:null}}function Jl(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Di(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Lf=typeof WeakMap=="function"?WeakMap:Map;function Wu(e,t,n){n=Xe(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){sl||(sl=!0,Wi=r),Di(e,t)},n}function Qu(e,t,n){n=Xe(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){Di(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Di(e,t),typeof r!="function"&&(pt===null?pt=new Set([this]):pt.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function Fo(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Lf;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=Wf.bind(null,e,t,n),t.then(e,e))}function Io(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function $o(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Xe(-1,1),t.tag=2,ft(n,t,1))),n.lanes|=1),e)}var Tf=et.ReactCurrentOwner,he=!1;function ue(e,t,n,r){t.child=e===null?wu(t,null,n,r):un(t,e.child,n,r)}function Uo(e,t,n,r,l){n=n.render;var i=t.ref;return tn(t,l),r=_s(e,t,n,r,i,l),n=Ps(),e!==null&&!he?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,be(e,t,l)):(B&&n&&ms(t),t.flags|=1,ue(e,t,r,l),t.child)}function Ao(e,t,n,r,l){if(e===null){var i=n.type;return typeof i=="function"&&!$s(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,Ku(e,t,i,r,l)):(e=Ur(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&l)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:Kn,n(o,r)&&e.ref===t.ref)return be(e,t,l)}return t.flags|=1,e=mt(i,r),e.ref=t.ref,e.return=t,t.child=e}function Ku(e,t,n,r,l){if(e!==null){var i=e.memoizedProps;if(Kn(i,r)&&e.ref===t.ref)if(he=!1,t.pendingProps=r=i,(e.lanes&l)!==0)e.flags&131072&&(he=!0);else return t.lanes=e.lanes,be(e,t,l)}return Oi(e,t,n,r,l)}function Yu(e,t,n){var r=t.pendingProps,l=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},I(Zt,xe),xe|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,I(Zt,xe),xe|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,I(Zt,xe),xe|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,I(Zt,xe),xe|=r;return ue(e,t,l,n),t.child}function Gu(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Oi(e,t,n,r,l){var i=ve(n)?Lt:ae.current;return i=on(t,i),tn(t,l),n=_s(e,t,n,r,i,l),r=Ps(),e!==null&&!he?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,be(e,t,l)):(B&&r&&ms(t),t.flags|=1,ue(e,t,n,l),t.child)}function Bo(e,t,n,r,l){if(ve(n)){var i=!0;Zr(t)}else i=!1;if(tn(t,l),t.stateNode===null)Fr(e,t),Hu(t,n,r),Ri(t,n,r,l),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var u=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=ze(c):(c=ve(n)?Lt:ae.current,c=on(t,c));var p=n.getDerivedStateFromProps,v=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function";v||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||u!==c)&&Oo(t,o,r,c),rt=!1;var h=t.memoizedState;o.state=h,tl(t,r,o,l),u=t.memoizedState,a!==r||h!==u||me.current||rt?(typeof p=="function"&&(Mi(t,n,p,r),u=t.memoizedState),(a=rt||Do(t,n,a,r,h,u,c))?(v||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),o.props=r,o.state=u,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,ku(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:Re(t.type,a),o.props=c,v=t.pendingProps,h=o.context,u=n.contextType,typeof u=="object"&&u!==null?u=ze(u):(u=ve(n)?Lt:ae.current,u=on(t,u));var g=n.getDerivedStateFromProps;(p=typeof g=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==v||h!==u)&&Oo(t,o,r,u),rt=!1,h=t.memoizedState,o.state=h,tl(t,r,o,l);var w=t.memoizedState;a!==v||h!==w||me.current||rt?(typeof g=="function"&&(Mi(t,n,g,r),w=t.memoizedState),(c=rt||Do(t,n,c,r,h,w,u)||!1)?(p||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,w,u),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,w,u)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),o.props=r,o.state=w,o.context=u,r=c):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Fi(e,t,n,r,i,l)}function Fi(e,t,n,r,l,i){Gu(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return l&&Eo(t,n,!1),be(e,t,i);r=t.stateNode,Tf.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=un(t,e.child,null,i),t.child=un(t,null,a,i)):ue(e,t,a,i),t.memoizedState=r.state,l&&Eo(t,n,!0),t.child}function Xu(e){var t=e.stateNode;t.pendingContext?Co(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Co(e,t.context,!1),Ss(e,t.containerInfo)}function Vo(e,t,n,r,l){return an(),gs(l),t.flags|=256,ue(e,t,n,r),t.child}var Ii={dehydrated:null,treeContext:null,retryLane:0};function $i(e){return{baseLanes:e,cachePool:null,transitions:null}}function Zu(e,t,n){var r=t.pendingProps,l=H.current,i=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(l&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),I(H,l&1),e===null)return Li(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=jl(o,r,0,null),e=zt(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=$i(n),t.memoizedState=Ii,e):Ts(t,o));if(l=e.memoizedState,l!==null&&(a=l.dehydrated,a!==null))return Mf(e,t,o,r,a,l,n);if(i){i=r.fallback,o=t.mode,l=e.child,a=l.sibling;var u={mode:"hidden",children:r.children};return!(o&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=mt(l,u),r.subtreeFlags=l.subtreeFlags&14680064),a!==null?i=mt(a,i):(i=zt(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?$i(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=Ii,r}return i=e.child,e=i.sibling,r=mt(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ts(e,t){return t=jl({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function kr(e,t,n,r){return r!==null&&gs(r),un(t,e.child,null,n),e=Ts(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Mf(e,t,n,r,l,i,o){if(n)return t.flags&256?(t.flags&=-257,r=Jl(Error(j(422))),kr(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,l=t.mode,r=jl({mode:"visible",children:r.children},l,0,null),i=zt(i,l,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&un(t,e.child,null,o),t.child.memoizedState=$i(o),t.memoizedState=Ii,i);if(!(t.mode&1))return kr(e,t,o,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(j(419)),r=Jl(i,r,void 0),kr(e,t,o,r)}if(a=(o&e.childLanes)!==0,he||a){if(r=ee,r!==null){switch(o&-o){case 4:l=2;break;case 16:l=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|o)?0:l,l!==0&&l!==i.retryLane&&(i.retryLane=l,qe(e,l),Ie(r,e,l,-1))}return Is(),r=Jl(Error(j(421))),kr(e,t,o,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=Qf.bind(null,e),l._reactRetry=t,null):(e=i.treeContext,we=dt(l.nextSibling),je=t,B=!0,Oe=null,e!==null&&(Ce[Ee++]=Ye,Ce[Ee++]=Ge,Ce[Ee++]=Tt,Ye=e.id,Ge=e.overflow,Tt=t),t=Ts(t,r.children),t.flags|=4096,t)}function Ho(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ti(e.return,t,n)}function ql(e,t,n,r,l){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=l)}function Ju(e,t,n){var r=t.pendingProps,l=r.revealOrder,i=r.tail;if(ue(e,t,r.children,n),r=H.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ho(e,n,t);else if(e.tag===19)Ho(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(I(H,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(n=t.child,l=null;n!==null;)e=n.alternate,e!==null&&nl(e)===null&&(l=n),n=n.sibling;n=l,n===null?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),ql(t,!1,l,n,i);break;case"backwards":for(n=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&nl(e)===null){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}ql(t,!0,n,null,i);break;case"together":ql(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Fr(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function be(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Rt|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(j(153));if(t.child!==null){for(e=t.child,n=mt(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=mt(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Rf(e,t,n){switch(t.tag){case 3:Xu(t),an();break;case 5:Su(t);break;case 1:ve(t.type)&&Zr(t);break;case 4:Ss(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;I(br,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(I(H,H.current&1),t.flags|=128,null):n&t.child.childLanes?Zu(e,t,n):(I(H,H.current&1),e=be(e,t,n),e!==null?e.sibling:null);I(H,H.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Ju(e,t,n);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),I(H,H.current),r)break;return null;case 22:case 23:return t.lanes=0,Yu(e,t,n)}return be(e,t,n)}var qu,Ui,bu,ec;qu=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Ui=function(){};bu=function(e,t,n,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,_t(We.current);var i=null;switch(n){case"input":l=oi(e,l),r=oi(e,r),i=[];break;case"select":l=Q({},l,{value:void 0}),r=Q({},r,{value:void 0}),i=[];break;case"textarea":l=ci(e,l),r=ci(e,r),i=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Gr)}fi(n,r);var o;n=null;for(c in l)if(!r.hasOwnProperty(c)&&l.hasOwnProperty(c)&&l[c]!=null)if(c==="style"){var a=l[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Un.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in r){var u=r[c];if(a=l!=null?l[c]:void 0,r.hasOwnProperty(c)&&u!==a&&(u!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||u&&u.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in u)u.hasOwnProperty(o)&&a[o]!==u[o]&&(n||(n={}),n[o]=u[o])}else n||(i||(i=[]),i.push(c,n)),n=u;else c==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,a=a?a.__html:void 0,u!=null&&a!==u&&(i=i||[]).push(c,u)):c==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(c,""+u):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Un.hasOwnProperty(c)?(u!=null&&c==="onScroll"&&U("scroll",e),i||a===u||(i=[])):(i=i||[]).push(c,u))}n&&(i=i||[]).push("style",n);var c=i;(t.updateQueue=c)&&(t.flags|=4)}};ec=function(e,t,n,r){n!==r&&(t.flags|=4)};function Nn(e,t){if(!B)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function se(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Df(e,t,n){var r=t.pendingProps;switch(vs(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return se(t),null;case 1:return ve(t.type)&&Xr(),se(t),null;case 3:return r=t.stateNode,cn(),A(me),A(ae),Cs(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(wr(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Oe!==null&&(Yi(Oe),Oe=null))),Ui(e,t),se(t),null;case 5:Ns(t);var l=_t(Jn.current);if(n=t.type,e!==null&&t.stateNode!=null)bu(e,t,n,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(j(166));return se(t),null}if(e=_t(We.current),wr(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ve]=t,r[Xn]=i,e=(t.mode&1)!==0,n){case"dialog":U("cancel",r),U("close",r);break;case"iframe":case"object":case"embed":U("load",r);break;case"video":case"audio":for(l=0;l<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[Ve]=t,e[Xn]=r,qu(e,t,!1,!1),t.stateNode=e;e:{switch(o=pi(n,r),n){case"dialog":U("cancel",e),U("close",e),l=r;break;case"iframe":case"object":case"embed":U("load",e),l=r;break;case"video":case"audio":for(l=0;lfn&&(t.flags|=128,r=!0,Nn(i,!1),t.lanes=4194304)}else{if(!r)if(e=nl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!B)return se(t),null}else 2*G()-i.renderingStartTime>fn&&n!==1073741824&&(t.flags|=128,r=!0,Nn(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=G(),t.sibling=null,n=H.current,I(H,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return Fs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?xe&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Of(e,t){switch(vs(t),t.tag){case 1:return ve(t.type)&&Xr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cn(),A(me),A(ae),Cs(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ns(t),null;case 13:if(A(H),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));an()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return A(H),null;case 4:return cn(),null;case 10:return ws(t.type._context),null;case 22:case 23:return Fs(),null;case 24:return null;default:return null}}var Sr=!1,oe=!1,Ff=typeof WeakSet=="function"?WeakSet:Set,C=null;function Xt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){K(e,t,r)}else n.current=null}function Ai(e,t,n){try{n()}catch(r){K(e,t,r)}}var Wo=!1;function If(e,t){if(Si=Qr,e=iu(),hs(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,c=0,p=0,v=e,h=null;t:for(;;){for(var g;v!==n||l!==0&&v.nodeType!==3||(a=o+l),v!==i||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(g=v.firstChild)!==null;)h=v,v=g;for(;;){if(v===e)break t;if(h===n&&++c===l&&(a=o),h===i&&++p===r&&(u=o),(g=v.nextSibling)!==null)break;v=h,h=v.parentNode}v=g}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ni={focusedElem:e,selectionRange:n},Qr=!1,C=t;C!==null;)if(t=C,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,C=e;else for(;C!==null;){t=C;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var x=w.memoizedProps,z=w.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?x:Re(t.type,x),z);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(y){K(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return w=Wo,Wo=!1,w}function Fn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Ai(t,n,i)}l=l.next}while(l!==r)}}function xl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Bi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function tc(e){var t=e.alternate;t!==null&&(e.alternate=null,tc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ve],delete t[Xn],delete t[_i],delete t[xf],delete t[wf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function nc(e){return e.tag===5||e.tag===3||e.tag===4}function Qo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||nc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Vi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Gr));else if(r!==4&&(e=e.child,e!==null))for(Vi(e,t,n),e=e.sibling;e!==null;)Vi(e,t,n),e=e.sibling}function Hi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Hi(e,t,n),e=e.sibling;e!==null;)Hi(e,t,n),e=e.sibling}var ne=null,De=!1;function tt(e,t,n){for(n=n.child;n!==null;)rc(e,t,n),n=n.sibling}function rc(e,t,n){if(He&&typeof He.onCommitFiberUnmount=="function")try{He.onCommitFiberUnmount(dl,n)}catch{}switch(n.tag){case 5:oe||Xt(n,t);case 6:var r=ne,l=De;ne=null,tt(e,t,n),ne=r,De=l,ne!==null&&(De?(e=ne,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ne.removeChild(n.stateNode));break;case 18:ne!==null&&(De?(e=ne,n=n.stateNode,e.nodeType===8?Ql(e.parentNode,n):e.nodeType===1&&Ql(e,n),Wn(e)):Ql(ne,n.stateNode));break;case 4:r=ne,l=De,ne=n.stateNode.containerInfo,De=!0,tt(e,t,n),ne=r,De=l;break;case 0:case 11:case 14:case 15:if(!oe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Ai(n,t,o),l=l.next}while(l!==r)}tt(e,t,n);break;case 1:if(!oe&&(Xt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){K(n,t,a)}tt(e,t,n);break;case 21:tt(e,t,n);break;case 22:n.mode&1?(oe=(r=oe)||n.memoizedState!==null,tt(e,t,n),oe=r):tt(e,t,n);break;default:tt(e,t,n)}}function Ko(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ff),t.forEach(function(r){var l=Kf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Me(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~i}if(r=l,r=G()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Uf(r/1960))-r,10e?16:e,ot===null)var r=!1;else{if(e=ot,ot=null,ol=0,D&6)throw Error(j(331));var l=D;for(D|=4,C=e.current;C!==null;){var i=C,o=i.child;if(C.flags&16){var a=i.deletions;if(a!==null){for(var u=0;uG()-Ds?Pt(e,0):Rs|=n),ge(e,t)}function dc(e,t){t===0&&(e.mode&1?(t=hr,hr<<=1,!(hr&130023424)&&(hr=4194304)):t=1);var n=ce();e=qe(e,t),e!==null&&(rr(e,t,n),ge(e,n))}function Qf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),dc(e,n)}function Kf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),dc(e,n)}var fc;fc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||me.current)he=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return he=!1,Rf(e,t,n);he=!!(e.flags&131072)}else he=!1,B&&t.flags&1048576&&vu(t,qr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fr(e,t),e=t.pendingProps;var l=on(t,ae.current);tn(t,n),l=_s(null,t,r,e,l,n);var i=Ps();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ve(r)?(i=!0,Zr(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,ks(t),l.updater=yl,t.stateNode=l,l._reactInternals=t,Ri(t,r,e,n),t=Fi(null,t,r,!0,i,n)):(t.tag=0,B&&i&&ms(t),ue(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Gf(r),e=Re(r,e),l){case 0:t=Oi(null,t,r,e,n);break e;case 1:t=Bo(null,t,r,e,n);break e;case 11:t=Uo(null,t,r,e,n);break e;case 14:t=Ao(null,t,r,Re(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Oi(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Bo(e,t,r,l,n);case 3:e:{if(Xu(t),e===null)throw Error(j(387));r=t.pendingProps,i=t.memoizedState,l=i.element,ku(e,t),tl(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=dn(Error(j(423)),t),t=Vo(e,t,r,n,l);break e}else if(r!==l){l=dn(Error(j(424)),t),t=Vo(e,t,r,n,l);break e}else for(we=dt(t.stateNode.containerInfo.firstChild),je=t,B=!0,Oe=null,n=wu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(an(),r===l){t=be(e,t,n);break e}ue(e,t,r,n)}t=t.child}return t;case 5:return Su(t),e===null&&Li(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,o=l.children,Ci(r,l)?o=null:i!==null&&Ci(r,i)&&(t.flags|=32),Gu(e,t),ue(e,t,o,n),t.child;case 6:return e===null&&Li(t),null;case 13:return Zu(e,t,n);case 4:return Ss(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=un(t,null,r,n):ue(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Uo(e,t,r,l,n);case 7:return ue(e,t,t.pendingProps,n),t.child;case 8:return ue(e,t,t.pendingProps.children,n),t.child;case 12:return ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,o=l.value,I(br,r._currentValue),r._currentValue=o,i!==null)if($e(i.value,o)){if(i.children===l.children&&!me.current){t=be(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=Xe(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ti(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(j(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Ti(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}ue(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,tn(t,n),l=ze(l),r=r(l),t.flags|=1,ue(e,t,r,n),t.child;case 14:return r=t.type,l=Re(r,t.pendingProps),l=Re(r.type,l),Ao(e,t,r,l,n);case 15:return Ku(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Re(r,l),Fr(e,t),t.tag=1,ve(r)?(e=!0,Zr(t)):e=!1,tn(t,n),Hu(t,r,l),Ri(t,r,l,n),Fi(null,t,r,!0,e,n);case 19:return Ju(e,t,n);case 22:return Yu(e,t,n)}throw Error(j(156,t.tag))};function pc(e,t){return Aa(e,t)}function Yf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _e(e,t,n,r){return new Yf(e,t,n,r)}function $s(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gf(e){if(typeof e=="function")return $s(e)?1:0;if(e!=null){if(e=e.$$typeof,e===rs)return 11;if(e===ls)return 14}return 2}function mt(e,t){var n=e.alternate;return n===null?(n=_e(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ur(e,t,n,r,l,i){var o=2;if(r=e,typeof e=="function")$s(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case At:return zt(n.children,l,i,t);case ns:o=8,l|=8;break;case ri:return e=_e(12,n,t,l|2),e.elementType=ri,e.lanes=i,e;case li:return e=_e(13,n,t,l),e.elementType=li,e.lanes=i,e;case ii:return e=_e(19,n,t,l),e.elementType=ii,e.lanes=i,e;case Sa:return jl(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ja:o=10;break e;case ka:o=9;break e;case rs:o=11;break e;case ls:o=14;break e;case nt:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=_e(o,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function zt(e,t,n,r){return e=_e(7,e,r,t),e.lanes=n,e}function jl(e,t,n,r){return e=_e(22,e,r,t),e.elementType=Sa,e.lanes=n,e.stateNode={isHidden:!1},e}function bl(e,t,n){return e=_e(6,e,null,t),e.lanes=n,e}function ei(e,t,n){return t=_e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Xf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Dl(0),this.expirationTimes=Dl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Us(e,t,n,r,l,i,o,a,u){return e=new Xf(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=_e(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ks(i),e}function Zf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gc)}catch(e){console.error(e)}}gc(),ga.exports=Se;var tp=ga.exports,yc,ea=tp;yc=ea.createRoot,ea.hydrateRoot;const xc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},np=()=>!!xc();async function O(e,...t){const n=xc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const $={session:()=>O("Session"),login:(e,t)=>O("Login",e,t),logout:()=>O("Logout"),claim:e=>O("Claim",e),runStandalone:()=>O("RunStandalone"),engineStatus:()=>O("EngineStatus"),startEngine:()=>O("StartEngine"),stopEngine:()=>O("StopEngine"),cameras:()=>O("Cameras"),testCamera:e=>O("TestCamera",e),saveCamera:(e,t)=>O("SaveCamera",e,t),deleteCamera:e=>O("DeleteCamera",e),startPlacement:(e,t)=>O("StartPlacementCheck",e,t),placementResult:e=>O("PlacementResult",e),streamURL:e=>O("StreamURL",e),live:()=>O("Live"),pipelineStatus:()=>O("PipelineStatus"),localIdentities:e=>O("LocalIdentities",e),localSightings:e=>O("LocalSightings",e),footfall:(e,t,n)=>O("Footfall",e,t,n),sites:()=>O("Sites"),visitorHistory:(e,t)=>O("VisitorHistory",e,t),visitorPhoto:e=>O("VisitorPhoto",e),forgetCustomer:e=>O("ForgetCustomer",e),sales:(e,t)=>O("Sales",e,t),customers:(e,t)=>O("Customers",e,t),saveProfile:e=>O("SaveProfile",e),ask:e=>O("Ask",e),recordPurchase:(e,t,n,r)=>O("RecordPurchase",e,t,n,r)};function ye(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function Ot(e,t,n=[]){const[r,l]=P.useState(null),[i,o]=P.useState(null),[a,u]=P.useState(!0),c=P.useRef(!0),p=P.useRef(!1),v=P.useCallback(async()=>{if(!p.current){p.current=!0;try{const h=await e();if(!c.current)return;l(h),o(null)}catch(h){c.current&&o(ye(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return P.useEffect(()=>{if(c.current=!0,v(),!t)return()=>{c.current=!1};const h=setInterval(v,t);return()=>{c.current=!1,clearInterval(h)}},[v,t]),{data:r,error:i,loading:a,reload:v}}function rp(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ta(e){if(!e)return"—";const t=typeof e=="number"?new Date(e*1e3):new Date(e);return isNaN(t)?"—":t.toLocaleDateString([],{day:"numeric",month:"short"})}const ti={width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"};function te({size:e,children:t,...n}){return s.jsx("svg",{...ti,...n,width:e??ti.width,height:e??ti.height,children:t})}const lp=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),s.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),ip=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),s.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),s.jsx("path",{d:"M16.5 6.2a3.2 3.2 0 0 1 0 6.1M18 19.5a6 6 0 0 0-1.6-4"})]}),sp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),s.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),op=e=>s.jsxs(te,{...e,children:[s.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),s.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),na=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Hs=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),wc=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),jc=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),ap=e=>s.jsx(te,{...e,children:s.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Ue=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M12 4.6 21 19.4H3z"}),s.jsx("path",{d:"M12 10v4.1"}),s.jsx("path",{d:"M12 17.1v.01"})]}),ra=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),up=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 .3 9.4z"})}),kc=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M7.2 18.4a4.2 4.2 0 0 1-.6-8.35 6.2 6.2 0 0 1 2-3.2M10.6 5.2A6.2 6.2 0 0 1 18.4 9a4.2 4.2 0 0 1 1.9 7.6"}),s.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),cp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M10.2 13.8a3.6 3.6 0 0 0 5.2 0l2.8-2.8a3.7 3.7 0 0 0-5.2-5.2l-1.3 1.3"}),s.jsx("path",{d:"M13.8 10.2a3.6 3.6 0 0 0-5.2 0l-2.8 2.8a3.7 3.7 0 0 0 5.2 5.2l1.3-1.3"})]}),dp=e=>s.jsxs(te,{...e,children:[s.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),s.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),fp=e=>s.jsx(te,{...e,children:s.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),Sc=e=>s.jsxs(te,{...e,strokeWidth:"1.2",children:[s.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),s.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),s.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),Nc=e=>s.jsxs(te,{...e,strokeWidth:"1.2",children:[s.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),s.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),rn=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function pp({onDone:e}){const[t,n]=P.useState(""),[r,l]=P.useState(""),[i,o]=P.useState(!1),[a,u]=P.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await $.login(t.trim(),r))}catch(v){u(ye(v))}finally{o(!1)}}return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:"Behavision"}),s.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),s.jsxs("form",{onSubmit:c,children:[a&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),a]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Email"}),s.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Password"}),s.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),s.jsx("button",{className:"btn primary",disabled:i||!t||!r,children:i?"Signing in…":"Sign in"})]}),s.jsx("p",{className:"foot",children:"Signing in downloads this store's recognition models and connects it to your account. Nothing is sent until a camera is set up."})]})})}function la({onDone:e,onCancel:t}){const[n,r]=P.useState(""),[l,i]=P.useState(null),[o,a]=P.useState(null),[u,c]=P.useState(!1);async function p(h){h.preventDefault(),i("claim"),a(null);try{e(await $.claim(n))}catch(g){a(ye(g))}finally{i(null)}}async function v(){i("alone"),a(null);try{e(await $.runStandalone())}catch(h){a(ye(h))}finally{i(null)}}return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:t?"Link to head office":"Set up this PC"}),s.jsx("p",{className:"lead",children:"Type the installation code for this shop. You only do this once."}),s.jsxs("form",{onSubmit:p,children:[o&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),o]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Installation code"}),s.jsx("input",{value:n,autoFocus:!0,required:!0,placeholder:"ABCDEF-123456-GHIJKL-789012",autoComplete:"off",spellCheck:"false",style:{textTransform:"uppercase",letterSpacing:".06em"},onChange:h=>r(h.target.value)})]}),s.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),s.jsx("p",{className:"foot",children:"The code works once. Ask whoever manages your shops for it — they can create one from the Behavision platform, under the shop."}),s.jsx("div",{className:"alt",children:t?s.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):u?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"note",children:"This PC will watch its cameras and recognise returning customers on its own. Nothing is sent anywhere. You can link it to head office later without losing anything recorded here."}),s.jsx("button",{type:"button",className:"btn",disabled:!!l,onClick:v,children:l==="alone"?"Setting up…":"Use this PC on its own"})]}):s.jsx("button",{type:"button",className:"linkbtn",onClick:()=>c(!0),children:"No head office — set this PC up on its own"})})]})})}function Cc(){var p,v;const{data:e,error:t}=Ot(()=>$.live(),3e3),{data:n}=Ot(()=>$.pipelineStatus(),5e3),r=((p=e==null?void 0:e.stats)==null?void 0:p.cameras)??[],l=((v=e==null?void 0:e.stats)==null?void 0:v.gallery)??{},i=(e==null?void 0:e.events)??[],o=r.reduce((h,g)=>{var x,z;const w=(z=(x=g==null?void 0:g.pipeline)==null?void 0:x.best_quality)==null?void 0:z.fraction_below_gate;return typeof w=="number"&&w>h?w:h},0),a=r.filter(h=>h.connected).length,u=i.filter(h=>h.type==="person.new"||h.type==="person.seen"),c=gp(u[0]);return s.jsxs("div",{className:"page",children:[s.jsxs("header",{children:[s.jsx("h2",{children:"Live"}),s.jsx("p",{children:"Who is in the shop, and whether it is reaching head office."})]}),t&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),t]}),s.jsx(vp,{pipe:n,cameras:r,up:a}),s.jsxs("div",{className:"panel arrivals-panel",children:[s.jsxs("div",{className:"panelhead",children:[s.jsx("h3",{children:"Who just walked in"}),u.length>0&&s.jsxs("span",{className:"note",children:[u.length," today"]})]}),s.jsx("div",{className:"panelbody flush",children:u.length===0?s.jsxs("div",{className:"empty",children:[s.jsx(Nc,{size:34}),s.jsx("b",{children:"Nobody yet"}),s.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):s.jsx("div",{className:"arrivals",children:u.slice(0,30).map((h,g)=>s.jsx(hp,{e:h,fresh:g===0&&c},`${h.ts}-${g}`))})})]}),s.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[s.jsx(Er,{k:"People known",v:l.identities??"—"}),s.jsx(Er,{k:"Sightings",v:l.sightings??"—"}),s.jsx(Er,{k:"Cameras live",v:r.length?`${a}/${r.length}`:"—",tone:r.length?a===0?"bad":a.5?"bad":o>.2?"warn":"ok",s:o>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function hp({e,fresh:t}){var o,a,u,c,p,v;const n=e.type==="person.new",r=((o=e.data)==null?void 0:o.label)||"Unrecognised",l=[(a=e.data)==null?void 0:a.gender,((u=e.data)==null?void 0:u.age)??((c=e.data)==null?void 0:c.age_range),(p=e.data)==null?void 0:p.emotion].filter(Boolean),i=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return s.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[s.jsx("div",{className:"avatar",children:mp(r)}),s.jsxs("div",{className:"who",children:[s.jsx("div",{className:"name",children:r}),s.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&s.jsxs(s.Fragment,{children:[" · ",l.join(", ")]}),i!==null&&!n&&s.jsxs(s.Fragment,{children:[" · match ",i.toFixed(2)]})]})]}),s.jsxs("div",{className:"right",children:[s.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),s.jsx("span",{className:"when",children:rp(e.ts)})]})]})}function mp(e){var r;const t=/^Visitor (\d+)$/.exec(String(e).trim());if(t)return t[1];const n=String(e).trim().split(/\s+/).filter(Boolean);return n.length?(n[0][0]+(((r=n[1])==null?void 0:r[0])??"")).toUpperCase():"?"}function vp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return s.jsxs("div",{className:"statusbar",children:[s.jsxs("span",{className:"item",children:[s.jsx("i",{className:"dot ok"}),s.jsx("b",{children:"Running on this PC only"})]}),s.jsx("span",{className:"sep"}),s.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),s.jsx("span",{className:"grow"}),s.jsxs("span",{className:"item note",children:[s.jsx(ra,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",i=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return s.jsxs("div",{className:"statusbar",children:[s.jsxs("span",{className:"item",children:[e.broker_up?s.jsx(up,{size:15}):s.jsx(kc,{size:15}),s.jsx("i",{className:`dot ${l}`}),s.jsx("b",{children:i})]}),s.jsx("span",{className:"sep"}),s.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&s.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&s.jsxs("span",{className:"item note bad",children:[s.jsx(Ue,{size:14}),e.dropped," lost — this PC was offline too long"]}),s.jsx("span",{className:"grow"}),s.jsxs("span",{className:"item note",children:[s.jsx(ra,{size:14}),n," of ",t.length," cameras"]})]})}function Er({k:e,v:t,s:n,tone:r}){return s.jsxs("div",{className:`metric ${r??""}`,children:[s.jsx("div",{className:"metric-k",children:e}),s.jsx("div",{className:"metric-v",children:t}),n&&s.jsx("div",{className:"metric-s",children:n})]})}function gp(e){const[t,n]=P.useState(!1),r=P.useRef(null);return P.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const i=setTimeout(()=>n(!1),1200);return()=>clearTimeout(i)},[e==null?void 0:e.ts]),t}function yp(e){const[t,n]=P.useState(null);return P.useEffect(()=>{let r=!0;return n(null),$.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function xp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?s.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):s.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:s.jsx("span",{children:wp(t,n)})})}function wp(e,t){const n=/^Visitor (\d+)$/.exec(String(e||"").trim());if(n)return n[1];const r=/^V-(\d+)$/.exec(String(t||""));return r?r[1]:String(e||"").split(/\s+/).filter(Boolean).slice(0,2).map(l=>l[0].toUpperCase()).join("")||"?"}function jp({customer:e}){const{data:t,error:n,loading:r}=Ot(()=>$.visitorHistory(e.id,50),0,[e.id]);if(r)return s.jsx("p",{className:"note",children:"Loading visits…"});if(n)return s.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?s.jsx("p",{className:"note",children:"No recorded visits yet."}):s.jsx("ul",{className:"timeline",children:l.map(i=>s.jsxs("li",{children:[s.jsx("span",{className:"when",children:kp(i.occurred_at)}),s.jsxs("span",{className:"where",children:[i.site||"this store",i.camera_id?s.jsxs("span",{className:"note",children:[" · ",i.camera_id]}):null]}),i.is_new_visitor&&s.jsx("span",{className:"tag new",children:"first visit"})]},i.id))})}function kp(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function Sp({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,i]=P.useState(""),[o,a]=P.useState(!1),[u,c]=P.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await $.forgetCustomer(e.id),n()}catch(h){c(ye(h)),a(!1)}}return s.jsxs("div",{className:"confirm",children:[s.jsxs("h4",{children:["Erase ",r,"?"]}),s.jsxs("div",{className:"cols",children:[s.jsxs("div",{children:[s.jsx("p",{className:"lbl bad",children:"Deleted for good"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Their face data — they will not be recognised again"}),s.jsx("li",{children:"Their photo"}),s.jsx("li",{children:"Their name, phone, email and notes"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"lbl",children:"Kept"}),s.jsxs("ul",{children:[s.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),s.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),s.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&s.jsx("div",{className:"err",children:u}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Type ",s.jsx("b",{children:r})," to confirm"]}),s.jsx("input",{value:l,onChange:h=>i(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),s.jsxs("div",{className:"row",children:[s.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),s.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function Np({customer:e,session:t,onClose:n,onSaved:r}){var N;const[l,i]=P.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=P.useState({amount:"",items:"",notes:""}),[u,c]=P.useState(!1),[p,v]=P.useState(null),[h,g]=P.useState(!1),[w,x]=P.useState(null),z=yp(e.id),f=w??z,d=(N=t==null?void 0:t.user)==null?void 0:N.role,m=["admin","owner","manager"].includes(d),y=S=>_=>i({...l,[S]:_.target.value});async function k(S){S.preventDefault(),c(!0),v(null);try{await $.saveProfile({visitor_id:e.id,...l});const _=parseFloat(o.amount);if(!isNaN(_)&&_>0){const V=o.items.split(",").map(M=>M.trim()).filter(Boolean);await $.recordPurchase(e.id,_,V,o.notes)}r()}catch(_){v(ye(_))}finally{c(!1)}}return s.jsx("div",{className:"drawer",onMouseDown:S=>S.target===S.currentTarget&&n(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead who",children:[s.jsx(xp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>x({available:!1,reason:"The photo could not be loaded."})}),s.jsxs("div",{className:"grow",children:[s.jsx("h2",{children:e.full_name||e.label}),s.jsxs("p",{className:"note",children:[e.visit_count," visit",e.visit_count===1?"":"s",e.last_seen_at&&` · last seen ${new Date(e.last_seen_at).toLocaleDateString()}`,f&&!f.available&&f.reason&&` · ${f.reason}`]})]}),s.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),s.jsxs("form",{className:"sheetbody",onSubmit:k,children:[p&&s.jsx("div",{className:"err",children:p}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Customer details"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Full name"}),s.jsx("input",{value:l.full_name,onChange:y("full_name"),autoFocus:!0})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Phone"}),s.jsx("input",{value:l.phone,onChange:y("phone"),inputMode:"tel"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Email"}),s.jsx("input",{value:l.email,onChange:y("email"),type:"email"})]})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Gender"}),s.jsxs("select",{value:l.gender,onChange:y("gender"),children:[s.jsx("option",{value:"",children:"Not recorded"}),s.jsx("option",{children:"Female"}),s.jsx("option",{children:"Male"}),s.jsx("option",{children:"Other"})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Date of birth"}),s.jsx("input",{type:"date",value:l.date_of_birth,onChange:y("date_of_birth")})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Notes"}),s.jsx("textarea",{value:l.notes,onChange:y("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Purchase (optional)"}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Amount"}),s.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:S=>a({...o,amount:S.target.value})})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Items"}),s.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:S=>a({...o,items:S.target.value})})]})]}),s.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Consent"}),s.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[s.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:S=>i({...l,consent:S.target.checked})}),s.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),s.jsx("p",{className:"note",style:{marginTop:10},children:"Recorded with the date and who collected it. They can withdraw it at any time, which erases their face data."})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Visits"}),s.jsx(jp,{customer:e})]}),s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),s.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&s.jsxs("section",{className:"formsection dangerzone",children:[s.jsx("h4",{children:"At the customer's request"}),h?s.jsx(Sp,{customer:e,onCancel:()=>g(!1),onDone:r}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"note",children:"Erase this person's face data, photo and details. Their past visits stay in your footfall figures, without their name."}),s.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function Cp({session:e}){const[t,n]=P.useState(""),[r,l]=P.useState(null),{data:i,error:o,reload:a}=Ot(()=>$.customers(t,200),3e4,[t]),u=i??[],c=u.filter(p=>p.has_profile).length;return s.jsxs("div",{className:"page",children:[s.jsxs("header",{className:"pagehead",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Customers"}),s.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),s.jsxs("label",{className:"search",children:[s.jsx(op,{size:15}),s.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),o]}),s.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[s.jsx(_r,{k:"Known people",v:u.length||"—"}),s.jsx(_r,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),s.jsx(_r,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),s.jsx(_r,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),s.jsx("div",{className:"panel",children:u.length===0?s.jsxs("div",{className:"empty tall",children:[s.jsx(Nc,{size:34}),s.jsx("b",{children:"No customers yet"}),s.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):s.jsx("div",{className:"tablewrap",children:s.jsxs("table",{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Customer"}),s.jsx("th",{children:"Phone"}),s.jsx("th",{className:"num",children:"Visits"}),s.jsx("th",{children:"First seen"}),s.jsx("th",{children:"Last seen"}),s.jsx("th",{children:"Details"})]})}),s.jsx("tbody",{children:u.map(p=>s.jsxs("tr",{className:"click",onClick:()=>l(p),children:[s.jsxs("td",{children:[p.full_name||s.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&s.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),s.jsx("td",{className:"mono",children:p.phone||"—"}),s.jsx("td",{className:"num",children:p.visit_count}),s.jsx("td",{children:ta(p.first_seen_at)}),s.jsx("td",{children:ta(p.last_seen_at)}),s.jsx("td",{children:p.has_profile?s.jsxs("span",{className:"pill ok",children:[s.jsx("i",{className:"dot ok"}),"captured"]}):s.jsxs("span",{className:"pill warn",children:[s.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&s.jsx(Np,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function _r({k:e,v:t,s:n}){return s.jsxs("div",{className:"metric",children:[s.jsx("div",{className:"metric-k",children:e}),s.jsx("div",{className:"metric-v",children:t}),n&&s.jsx("div",{className:"metric-s",children:n})]})}const ln=[{id:"hikvision",label:"Hikvision",path:"/Streaming/Channels/101",note:"Channel 1, main stream. Use /Streaming/Channels/102 for the lower-quality sub stream."},{id:"dahua",label:"Dahua",path:"/cam/realmonitor?channel=1&subtype=0",note:"Channel 1, main stream. subtype=1 is the sub stream."},{id:"cpplus",label:"CP Plus",path:"/cam/realmonitor?channel=1&subtype=0",note:"CP Plus cameras use the Dahua stream path."},{id:"uniview",label:"Uniview",path:"/media/video1",note:"Some older Uniview models use /video1 instead."},{id:"tplink",label:"TP-Link / Tapo",path:"/stream1",note:"Tapo cameras need a separate camera account created in the Tapo app — your Tapo login will not work."},{id:"reolink",label:"Reolink",path:"/h264Preview_01_main",note:"Use /h264Preview_01_sub for the lower-quality stream."},{id:"amcrest",label:"Amcrest",path:"/cam/realmonitor?channel=1&subtype=0",note:"Amcrest cameras use the Dahua stream path."},{id:"axis",label:"Axis",path:"/axis-media/media.amp",note:""},{id:"onvif",label:"Other (ONVIF)",path:"/onvif1",note:"Many generic cameras answer here. If it does not work, look for “RTSP” in the camera’s own app."},{id:"manual",label:"I know the path",path:"",note:""}],ia=e=>ln.find(t=>t.id===e)||ln[ln.length-1],Gi={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280};function Ep(){const{data:e,error:t,reload:n}=Ot(()=>$.cameras(),8e3),[r,l]=P.useState(null),[i,o]=P.useState(null),a=e??[],u=Pp(a);async function c(p){if(confirm(`Remove ${p.id}? Recognition from it stops immediately.`))try{await $.deleteCamera(p.id),n()}catch(v){alert(ye(v))}}return s.jsxs("div",{className:"page",children:[s.jsxs("header",{className:"pagehead",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Cameras"}),s.jsx("p",{children:"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),s.jsxs("button",{className:"btn primary",onClick:()=>l({...Gi}),children:[s.jsx(na,{size:15}),"Add camera"]})]}),t&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),t]}),a.length===0?s.jsx("div",{className:"panel",children:s.jsxs("div",{className:"empty tall",children:[s.jsx(Sc,{size:40}),s.jsx("b",{children:"No cameras yet"}),s.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),s.jsxs("button",{className:"btn primary",onClick:()=>l({...Gi}),children:[s.jsx(na,{size:15}),"Add your first camera"]})]})}):s.jsx("div",{className:"camgrid",children:a.map(p=>s.jsx(_p,{cam:p,stream:u[p.id],onEdit:()=>l(p),onCheck:()=>o(p.id),onRemove:()=>c(p)},p.id))}),r&&s.jsx(zp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),i&&s.jsx(Lp,{id:i,onClose:()=>o(null)})]})}function _p({cam:e,stream:t,onEdit:n,onCheck:r,onRemove:l}){const i=e.connected===void 0?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:o}=Ot(()=>$.placementResult(e.id),15e3,[e.id]),a=!o||o.running||!o.verdict||o.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:o.verdict==="good"?{tone:"seen",label:"Proven",text:o.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:o.headline||"Move the camera and check again."};return s.jsxs("article",{className:"camcard",children:[s.jsxs("div",{className:"camview",children:[t?s.jsx("img",{src:t,alt:e.id}):s.jsx("div",{className:"placeholder",children:s.jsx(Sc,{size:34})}),s.jsxs("span",{className:`pill ${i.tone==="idle"?"":i.tone} over`,children:[s.jsx("i",{className:`dot ${i.tone}`}),i.label]})]}),s.jsxs("div",{className:"cambody",children:[s.jsxs("div",{className:"camtitle",children:[s.jsxs("div",{children:[s.jsx("h3",{children:e.id}),s.jsxs("span",{className:"mono note",children:[e.host||e.url,e.path?` · ${e.path}`:""]})]}),s.jsxs("div",{className:"camactions",children:[s.jsx("button",{className:"btn sm",onClick:n,children:"Edit"}),s.jsx("button",{className:"btn sm danger",onClick:l,children:"Remove"})]})]}),s.jsxs("div",{className:"camproof",children:[s.jsx("span",{className:`tag ${a.tone}`,children:a.label}),s.jsx("span",{className:"note",children:a.text}),s.jsxs("button",{className:`btn sm ${a.tone==="seen"?"":"primary"}`,onClick:r,children:[s.jsx(jc,{size:13}),a.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Pp(e){const[t,n]=P.useState({});return P.useEffect(()=>{let r=!0;const l=e.filter(i=>!(i.id in t));if(l.length)return(async()=>{const i={};for(const o of l)try{i[o.id]=await $.streamURL(o.id)}catch{i[o.id]=""}r&&n(o=>({...o,...i}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function zp({cam:e,onClose:t,onSaved:n}){const r=!e.id,[l,i]=P.useState({...Gi,...e,password:"",path:e.path||(r?ln[0].path:"")}),[o,a]=P.useState(r?ln[0].id:"manual"),[u,c]=P.useState(null),[p,v]=P.useState(null),[h,g]=P.useState(null),w=y=>k=>i({...l,[y]:k.target.value});function x(y){const k=ia(y.target.value);a(k.id),i(N=>({...N,path:k.path||N.path}))}function z(){const y={};for(const[k,N]of Object.entries(l))N===""||N===null||N===void 0||(y[k]=k==="port"||k==="max_width"?Number(N):N);return y}async function f(){v("test"),g(null),c(null);try{c(await $.testCamera(z()))}catch(y){g(ye(y))}finally{v(null)}}async function d(y){y.preventDefault(),v("save"),g(null);try{await $.saveCamera(r?"":e.id,z()),n()}catch(k){g(ye(k))}finally{v(null)}}const m=ia(o);return s.jsx("div",{className:"drawer",onMouseDown:y=>y.target===y.currentTarget&&t(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead",children:[s.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("form",{className:"sheetbody",onSubmit:d,autoComplete:"off",children:[s.jsx("p",{className:"lead",children:"Three things from the camera: its address, its make, and its password. Test before you save — a wrong address is the most common mistake."}),h&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),h]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"The camera"}),r&&s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Name"}),s.jsx("input",{value:l.id,onChange:w("id"),placeholder:"entrance",required:!0,autoFocus:!0}),s.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Address"}),s.jsx("input",{value:l.host,onChange:w("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),s.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),s.jsxs("label",{className:"field narrow",children:[s.jsx("span",{children:"Port"}),s.jsx("input",{value:l.port,onChange:w("port"),inputMode:"numeric"})]})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"The stream"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Make of camera"}),s.jsx("select",{value:o,onChange:x,children:ln.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))}),m.note&&s.jsx("em",{className:"hint",children:m.note})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Stream path"}),s.jsx("input",{className:"mono",value:l.path,onChange:w("path"),placeholder:"/Streaming/Channels/101"}),s.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),s.jsxs("section",{className:"formsection",children:[s.jsx("h4",{children:"Sign-in to the camera"}),s.jsxs("div",{className:"fieldrow",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Username"}),s.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:w("username"),placeholder:"admin"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{children:"Password"}),s.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:w("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),u&&(u.ok?s.jsxs("div",{className:"testresult ok",children:[s.jsx(wc,{size:16}),s.jsxs("div",{children:[s.jsxs("b",{children:["Connected — ",u.width,"×",u.height,u.codec?` · ${String(u.codec).toUpperCase()}`:""]}),u.snapshot&&s.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${u.snapshot}`})]})]}):s.jsxs("div",{className:"testresult bad",children:[s.jsx(Ue,{size:16}),s.jsxs("div",{children:[s.jsx("b",{children:"Could not connect"}),s.jsx("span",{children:u.error})]})]})),s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{type:"button",className:"btn",onClick:f,disabled:!!p||!l.host,children:p==="test"?"Connecting…":"Test connection"}),s.jsx("button",{className:"btn primary",disabled:!!p||!l.id||!l.host,children:p==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Lp({id:e,onClose:t}){var p,v;const[n,r]=P.useState({verdict:"starting",advice:[]}),[l,i]=P.useState(null),o=P.useRef(null);P.useEffect(()=>{let h=!0;return(async()=>{try{r(await $.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await $.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&i(ye(g))}},1e3)}catch(g){h&&i(ye(g))}})(),()=>{h=!1,clearInterval(o.current)}},[e]);const a={good:"ok",marginal:"warn",poor:"bad",artifact:"bad",no_faces:"warn",inconclusive:"warn",no_completed_passes:"warn"}[n.verdict],u=n.seconds?Math.min(100,n.elapsed/n.seconds*100):0,c=n.running||n.verdict==="starting";return s.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:s.jsxs("div",{className:"sheet",children:[s.jsxs("div",{className:"sheethead",children:[s.jsxs("h2",{children:["Check placement · ",e]}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("div",{className:"sheetbody",children:[l&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),l]}),s.jsxs("ol",{className:"steps",children:[s.jsxs("li",{className:c?"now":"done",children:[s.jsx("b",{children:"Walk past the camera"}),s.jsx("span",{children:"The way a customer would — in through the door, not looking at the lens. Two or three times, for about 25 seconds."}),c&&s.jsx("div",{className:"progress",children:s.jsx("div",{style:{width:`${u}%`}})})]}),s.jsxs("li",{className:c?"":"now",children:[s.jsx("b",{children:"Behavision judges what it saw"}),s.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),s.jsxs("div",{className:`verdict ${a??""}`,children:[s.jsxs("div",{className:"verdict-head",children:[c?s.jsx("span",{className:"spinner"}):a==="ok"?s.jsx(wc,{size:18}):s.jsx(Ue,{size:18}),s.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&s.jsx("ul",{children:n.advice.map((h,g)=>s.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&s.jsxs("p",{className:"note",children:[n.quality.n," face",n.quality.n===1?"":"s"," seen · median quality ",n.quality.p50," ·"," ",Math.round((n.quality.fraction_below_gate??0)*100),"% too poor to use"]})]}),!c&&s.jsxs("div",{className:"sheetactions",children:[s.jsx("button",{className:"btn",onClick:t,children:"Close"}),s.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),$.startPlacement(e,25).then(r).catch(h=>i(ye(h)))},children:"Run again"})]})]})]})})}const Tp=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Mp({session:e,onClose:t}){const[n,r]=P.useState([]),[l,i]=P.useState(""),[o,a]=P.useState(!1),[u,c]=P.useState(null),p=P.useRef(null),v=e==null?void 0:e.standalone;P.useEffect(()=>{var g;(g=p.current)==null||g.scrollTo({top:1e9,behavior:"smooth"})},[n,o]);async function h(g){const w=(g??l).trim();if(!w||o)return;const x=[...n,{role:"user",text:w}];r(x),i(""),a(!0),c(null);try{const z=await $.ask(x.map(f=>({role:f.role,text:f.text})));r([...x,{role:"assistant",text:z.text,used:z.used??[]}])}catch(z){const f=ye(z);c(/session expired|unauthori[sz]ed/i.test(f)?"You’re signed out of head office, so I can’t look anything up. Sign in again and ask me once more.":f),r(n),i(w)}finally{a(!1)}}return s.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[s.jsxs("header",{className:"helperhead",children:[s.jsx("img",{src:rn,alt:""}),s.jsxs("div",{children:[s.jsx("b",{children:"Loya"}),s.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),s.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:s.jsx(Hs,{size:16})})]}),s.jsxs("div",{className:"helperbody",ref:p,children:[v&&s.jsxs("div",{className:"helpernote",children:[s.jsx(kc,{size:16}),s.jsxs("div",{children:[s.jsx("b",{children:"This PC runs on its own"}),s.jsx("span",{children:"Loya lives at head office. Link this PC to a shop to talk to her; the basics are below."})]})]}),n.length===0&&s.jsxs("div",{className:"helperintro",children:[s.jsx("div",{className:"turn assistant",children:s.jsxs("div",{className:"bubble",children:[Rp(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),s.jsx("div",{className:"chips",children:Tp.map(g=>s.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&s.jsx(Dp,{})]}),n.map((g,w)=>{var x;return s.jsxs("div",{className:`turn ${g.role}`,children:[s.jsx("div",{className:"bubble",children:g.text}),((x=g.used)==null?void 0:x.length)>0&&s.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},w)}),o&&s.jsx("div",{className:"turn assistant",children:s.jsxs("div",{className:"bubble thinking",children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{})]})}),u&&s.jsxs("div",{className:"err",children:[s.jsx(Ue,{size:15}),u]})]}),s.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[s.jsx("input",{value:l,onChange:g=>i(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),s.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:s.jsx(fp,{size:16})})]})]})}function Rp(e){var l,i;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(i=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:i.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function Dp(){return s.jsxs("dl",{className:"quickhelp",children:[s.jsx("dt",{children:"Adding a camera"}),s.jsx("dd",{children:"Cameras → Add camera. The address is on a label on the camera; pick the make and the stream path fills itself in. Test, then save."}),s.jsx("dt",{children:"Proving it works"}),s.jsx("dd",{children:"Press Check placement and walk past the camera like a customer for 25 seconds. Only “good” means it can recognise faces — otherwise move it to head height, facing the way people approach."}),s.jsx("dt",{children:"Nothing showing on Live"}),s.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),s.jsx("dt",{children:"Linking to head office later"}),s.jsx("dd",{children:"Use the link button at the bottom of the sidebar and type an installation code from head office. Nothing recorded here is lost."})]})}const Op=[{id:"live",label:"Live",Glyph:lp,View:Cc},{id:"customers",label:"Customers",Glyph:ip,View:Cp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:sp,View:Ep}];function Fp(){var h,g,w;const[e,t]=P.useState(null),[n,r]=P.useState("live"),[l,i]=P.useState(!0),[o,a]=P.useState(!1),[u,c]=P.useState(!1);if(P.useEffect(()=>{let x=!0;const z=async()=>{try{const d=await $.session();x&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{x&&t(null)}x&&i(!1)};z();const f=setInterval(z,8e3);return()=>{x=!1,clearInterval(f)}},[]),!np())return s.jsx("div",{className:"login",children:s.jsxs("div",{className:"box",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsx("h1",{children:"Behavision"}),s.jsx("p",{className:"lead",children:"This is the Behavision window running outside the app, so it has no connection to the recognition engine. Launch the Behavision application instead."})]})});if(l)return s.jsx("div",{className:"login",children:s.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return s.jsx(la,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return s.jsx(pp,{onDone:t});const p=Op.filter(x=>!x.cloud||!e.standalone),v=((h=p.find(x=>x.id===n))==null?void 0:h.View)??Cc;return o?s.jsx(la,{onDone:x=>{a(!1),t(x)},onCancel:()=>a(!1)}):s.jsxs("div",{className:"shell",children:[s.jsxs("aside",{className:"side",children:[s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"mark",children:s.jsx("img",{src:rn,alt:""})}),s.jsxs("div",{className:"id",children:[s.jsx("h1",{children:"Behavision"}),s.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),s.jsx("nav",{className:"nav",children:p.map(({id:x,label:z,Glyph:f})=>s.jsxs("button",{onClick:()=>r(x),"aria-current":x===n?"page":void 0,children:[s.jsx(f,{size:17}),z]},x))}),s.jsx(Ip,{}),s.jsx("div",{className:"who",children:e.standalone?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id",children:[s.jsx("b",{children:"On its own"}),s.jsx("span",{children:"No head office"})]}),s.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:s.jsx(cp,{size:15})})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"id",children:[s.jsx("b",{children:"Signed in"}),s.jsx("span",{children:(w=e.user)==null?void 0:w.email})]}),s.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await $.logout()),children:s.jsx(dp,{size:15})})]})})]}),s.jsxs("main",{className:"main",children:[s.jsx(v,{session:e}),!u&&s.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[s.jsx("img",{src:rn,alt:""}),s.jsx("span",{children:"Loya"})]})]}),u&&s.jsx(Mp,{session:e,onClose:()=>c(!1)})]})}function Ip(){const{data:e,reload:t}=Ot(()=>$.engineStatus(),5e3),[n,r]=P.useState(!1),l=e??{state:"stopped"},i=P.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(ye(h))}finally{r(!1),t()}},[t]),o=l.state==="running",a=Object.values(l.cameras??{}),u=a.filter(Boolean).length;let c="idle",p="Stopped";return!o&&l.reachable?(c="warn",p="Running outside the app"):l.state==="failed"||l.state==="backoff"?(c="bad",p="Not running"):o&&!l.reachable?(c="warn",p="Starting…"):o&&a.length===0?(c="warn",p="No cameras"):o&&u===0?(c="bad",p="No camera connected"):o&&ui($.startEngine),children:[s.jsx(jc,{size:13}),"Start"]}),s.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>i($.stopEngine),children:[s.jsx(ap,{size:13}),"Stop"]})]})]})}yc(document.getElementById("root")).render(s.jsx(Hc.StrictMode,{children:s.jsx(Fp,{})})); diff --git a/desktop/frontend/dist/index.html b/desktop/frontend/dist/index.html index 008679f..0079196 100644 --- a/desktop/frontend/dist/index.html +++ b/desktop/frontend/dist/index.html @@ -4,7 +4,7 @@ Behavision - + diff --git a/desktop/frontend/src/views/Assistant.jsx b/desktop/frontend/src/views/Assistant.jsx index df672ca..6f11645 100644 --- a/desktop/frontend/src/views/Assistant.jsx +++ b/desktop/frontend/src/views/Assistant.jsx @@ -36,7 +36,12 @@ export default function Assistant({ session, onClose }) { const a = await api.ask(history.map(t => ({ role: t.role, text: t.text }))) setTurns([...history, { role: 'assistant', text: a.text, used: a.used ?? [] }]) } catch (e) { - setError(message(e)) + const m = message(e) + // Her only failure that is not hers: the login is gone. Say what to do, + // not "session expired" - the shell returns to Login within seconds. + setError(/session expired|unauthori[sz]ed/i.test(m) + ? 'You’re signed out of head office, so I can’t look anything up. Sign in again and ask me once more.' + : m) setTurns(turns) // the question stays in the box, not in the transcript setDraft(q) } finally { setBusy(false) }