From b296e8a74a2840f03f5a7fc95eed23fbcae8e22d Mon Sep 17 00:00:00 2001 From: Suriyakumarvijayanayagam Date: Wed, 30 Sep 2026 18:18:57 +0530 Subject: [PATCH] A demo does not need a tunnel; it needs the laptop's own camera Asked after the mobile-internet question: could a VPN let the office cameras be shown in the demo. Three jobs get confused there and only one needs one. Seeing the estate from anywhere already works and needs nothing - viewer mode plus LiveHub is exactly that, outbound, no installation and no credential. Demonstrating recognition is better done on the demo machine's own camera. `webcam: 0` picks a capture index instead of building an RTSP URL and the engine has supported it since the first version: CameraStore round-trips it, source() returns the index, safe_url() reports webcam:0, and POST /api/cameras {"id":"laptop","webcam":0} has always worked. No screen offered it - the same gap this repo already records for the customer record and per-camera tuning. It is now an option in the make picker, and it is the strongest demo available: real faces, in the room, depending on no network. A demo pointed at a camera in another building depends on two internet connections and a tunnel staying up while somebody is talking. The address and the index are alternatives, not extras: source() takes the webcam first, so a half-typed host left behind would make the saved camera describe two things and use one. The scan, the path and the camera password are hidden for a local camera because none of them mean anything. A tunnel is still right for one case - running the engine on a remote machine against the office's own cameras - and still wrong for the product: it is per-site infrastructure on every shop PC, and it gives head office network-level access into a customer's LAN, where today we can read a camera's picture and nothing else. Also: installing httpx took the suite from 239 passed to 271. The HTTP tests importorskip it so a bare checkout runs, which means the number at the bottom of a run is not the number of tests that exist. Added to the dev extra. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01KGcjxF1cNLcuwc3DAPcnfj --- CLAUDE.md | 57 ++++++++++++ .../frontend/dist/assets/index-6LYbNlbD.js | 40 -------- .../frontend/dist/assets/index-DSNu_2FW.js | 40 ++++++++ desktop/frontend/dist/index.html | 2 +- desktop/frontend/src/views/Cameras.jsx | 91 +++++++++++++------ pyproject.toml | 6 +- tests/test_api_cameras.py | 39 ++++++++ 7 files changed, 205 insertions(+), 70 deletions(-) delete mode 100644 desktop/frontend/dist/assets/index-6LYbNlbD.js create mode 100644 desktop/frontend/dist/assets/index-DSNu_2FW.js diff --git a/CLAUDE.md b/CLAUDE.md index 38083ce..693fd82 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -3745,3 +3745,60 @@ rule as `artifact` against `no_faces`, and `stale` against `not_connecting`: message exists to fix. - **With no network at all it still names the cause** and drops the comparison, rather than claiming to know which network this machine is on. + +## A tunnel for the demo: when it is the right answer, and when it is not + +Asked after the mobile-internet question: *"what if we created a secure tunnel +or vpn, then the cameras in our office can be shown in the demo version too?"* + +Three different jobs get confused here, and only one of them needs a tunnel. + +**Seeing the estate from anywhere already works and needs nothing.** Viewer +mode plus `LiveHub` is exactly this: the shop PC pushes frames outbound and any +signed-in app sees them, from mobile data, a hotel or a customer's office. A +VPN would add an installation, a credential and a moving part to something that +already works with none of them. + +**Demonstrating recognition is better done on the demo machine's own camera.** +`webcam: 0` picks a capture index instead of building an RTSP URL, and the +engine has supported it since the first version — `CameraStore` round-trips it, +`source()` returns the index, `safe_url()` reports `webcam:0`, and +`POST /api/cameras {"id":"laptop","webcam":0}` has always worked. **No screen +offered it**, which is the same gap this file already records for the customer +record and for per-camera tuning: the API could, the UI could not reach it. + +It is now an option in the make picker, and it is the strongest demo available: +real faces, in the room, instant, depending on no network at all. A demo +pointed at a camera in another building depends on two internet connections and +a tunnel staying up while somebody is talking. + +**The one case a tunnel genuinely answers** is running the engine on a remote +machine against the office's own cameras — LAN access to `192.168.1.121` from +somewhere that is not that LAN. A mesh VPN (Tailscale and similar) does that +honestly: a subnet router at the office, the client on the demo machine, and +the address works unchanged. Free at this scale, no port forwarding, no +exposed camera. Worth using for our *own* office when that is really the goal. + +**It is still the wrong answer for the product**, and the reasons are not about +difficulty: + +- It is per-site infrastructure — an account, a node, a key — on every shop PC + we ship, to replace something that already works over ordinary HTTPS. +- It gives head office **network-level access into a customer's LAN**. The + current design can read a camera's picture; a VPN can reach the customer's + till, their router and everything else on that network. That is a far larger + thing to be trusted with, and a far larger thing to have breached. +- The failure modes are worse and less legible: a tunnel that is down looks + like a camera that is down. + +So: tunnel for our own office if we want the engine running remotely; nothing +at all for showing customers their shops; the laptop's own camera for showing +anybody what the product does. + +### And the suite was quietly 32 tests smaller than it looked + +Installing `httpx` to check the webcam path took the engine suite from **239 +passed to 271**. `tests/test_api_cameras.py` and its siblings begin with +`pytest.importorskip("httpx")` so a bare checkout still runs — deliberate, and +it means the number at the bottom of a run is not the number of tests that +exist. `pip install -e .[dev]` is the opt-in. diff --git a/desktop/frontend/dist/assets/index-6LYbNlbD.js b/desktop/frontend/dist/assets/index-6LYbNlbD.js deleted file mode 100644 index 23449f9..0000000 --- a/desktop/frontend/dist/assets/index-6LYbNlbD.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Lc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ca={exports:{}},dl={},da={exports:{}},D={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var nr=Symbol.for("react.element"),Tc=Symbol.for("react.portal"),Mc=Symbol.for("react.fragment"),Rc=Symbol.for("react.strict_mode"),Dc=Symbol.for("react.profiler"),Oc=Symbol.for("react.provider"),Fc=Symbol.for("react.context"),Ic=Symbol.for("react.forward_ref"),$c=Symbol.for("react.suspense"),Uc=Symbol.for("react.memo"),Ac=Symbol.for("react.lazy"),Xi=Symbol.iterator;function Bc(e){return e===null||typeof e!="object"?null:(e=Xi&&e[Xi]||e["@@iterator"],typeof e=="function"?e:null)}var fa={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},pa=Object.assign,ha={};function pn(e,t,n){this.props=e,this.context=t,this.refs=ha,this.updater=n||fa}pn.prototype.isReactComponent={};pn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};pn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ma(){}ma.prototype=pn.prototype;function qs(e,t,n){this.props=e,this.context=t,this.refs=ha,this.updater=n||fa}var bs=qs.prototype=new ma;bs.constructor=qs;pa(bs,pn.prototype);bs.isPureReactComponent=!0;var Zi=Array.isArray,va=Object.prototype.hasOwnProperty,ei={current:null},ga={key:!0,ref:!0,__self:!0,__source:!0};function ya(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)va.call(t,r)&&!ga.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,ee=P[G];if(0>>1;Gl(zl,R))Ntl(ar,zl)?(P[G]=ar,P[Nt]=R,G=Nt):(P[G]=zl,P[St]=R,G=St);else if(Ntl(ar,R))P[G]=ar,P[Nt]=R,G=Nt;else break e}}return M}function l(P,M){var R=P.sortIndex-M.sortIndex;return R!==0?R:P.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],p=1,v=null,h=3,g=!1,w=!1,y=!1,T=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(P){for(var M=n(c);M!==null;){if(M.callback===null)r(c);else if(M.startTime<=P)r(c),M.sortIndex=M.expirationTime,t(u,M);else break;M=n(c)}}function x(P){if(y=!1,m(P),!w)if(n(u)!==null)w=!0,_l(S);else{var M=n(c);M!==null&&Pl(x,M.startTime-P)}}function S(P,M){w=!1,y&&(y=!1,f(_),_=-1),g=!0;var R=h;try{for(m(M),v=n(u);v!==null&&(!(v.expirationTime>M)||P&&!V());){var G=v.callback;if(typeof G=="function"){v.callback=null,h=v.priorityLevel;var ee=G(v.expirationTime<=M);M=e.unstable_now(),typeof ee=="function"?v.callback=ee:v===n(u)&&r(u),m(M)}else r(u);v=n(u)}if(v!==null)var or=!0;else{var St=n(c);St!==null&&Pl(x,St.startTime-M),or=!1}return or}finally{v=null,h=R,g=!1}}var E=!1,k=null,_=-1,z=5,L=-1;function V(){return!(e.unstable_now()-LP||125G?(P.sortIndex=R,t(c,P),n(u)===null&&P===n(c)&&(y?(f(_),_=-1):y=!0,Pl(x,R-G))):(P.sortIndex=ee,t(u,P),w||g||(w=!0,_l(S))),P},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(P){var M=h;return function(){var R=h;h=M;try{return P.apply(this,arguments)}finally{h=R}}}})(Sa);ka.exports=Sa;var bc=ka.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var ed=C,Ne=bc;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rs=Object.prototype.hasOwnProperty,td=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,qi={},bi={};function nd(e){return rs.call(bi,e)?!0:rs.call(qi,e)?!1:td.test(e)?bi[e]=!0:(qi[e]=!0,!1)}function rd(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ld(e,t,n,r){if(t===null||typeof t>"u"||rd(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function he(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){se[e]=new he(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];se[t]=new he(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){se[e]=new he(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){se[e]=new he(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){se[e]=new he(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){se[e]=new he(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){se[e]=new he(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){se[e]=new he(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){se[e]=new he(e,5,!1,e.toLowerCase(),null,!1,!1)});var ni=/[\-:]([a-z])/g;function ri(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ni,ri);se[t]=new he(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ni,ri);se[t]=new he(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ni,ri);se[t]=new he(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){se[e]=new he(e,1,!1,e.toLowerCase(),null,!1,!1)});se.xlinkHref=new he("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){se[e]=new he(e,1,!1,e.toLowerCase(),null,!0,!0)});function li(e,t,n,r){var l=se.hasOwnProperty(t)?se[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` -`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Ml=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?En(e):""}function sd(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=Rl(e.type,!1),e;case 11:return e=Rl(e.type.render,!1),e;case 1:return e=Rl(e.type,!0),e;default:return""}}function os(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 Bt:return"Fragment";case At:return"Portal";case ls:return"Profiler";case si:return"StrictMode";case ss:return"Suspense";case is:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ea:return(e.displayName||"Context")+".Consumer";case Ca:return(e._context.displayName||"Context")+".Provider";case ii:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case oi:return t=e.displayName||null,t!==null?t:os(e.type)||"Memo";case rt:t=e._payload,e=e._init;try{return os(e(t))}catch{}}return null}function id(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 os(t);case 8:return t===si?"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 yt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Pa(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function od(e){var t=Pa(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,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.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=od(e))}function za(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Pa(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Br(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 as(e,t){var n=t.checked;return K({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function to(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=yt(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 La(e,t){t=t.checked,t!=null&&li(e,"checked",t,!1)}function us(e,t){La(e,t);var n=yt(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")?cs(e,t.type,n):t.hasOwnProperty("defaultValue")&&cs(e,t.type,yt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function no(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 cs(e,t,n){(t!=="number"||Br(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _n=Array.isArray;function qt(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},ad=["Webkit","ms","Moz","O"];Object.keys(Ln).forEach(function(e){ad.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ln[t]=Ln[e]})});function Da(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 Oa(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Da(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var ud=K({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 ps(e,t){if(t){if(ud[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 hs(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 ms=null;function ai(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var vs=null,bt=null,en=null;function so(e){if(e=sr(e)){if(typeof vs!="function")throw Error(j(280));var t=e.stateNode;t&&(t=vl(t),vs(e.stateNode,e.type,t))}}function Fa(e){bt?en?en.push(e):en=[e]:bt=e}function Ia(){if(bt){var e=bt,t=en;if(en=bt=null,so(e),t)for(e=0;e>>=0,e===0?32:31-(wd(e)/jd|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 Qr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Pn(a):(s&=o,s!==0&&(r=Pn(s)))}else o=n&~l,o!==0?r=Pn(o):s!==0&&(r=Pn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&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-Ie(t),e[t]=n}function Cd(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),mo=" ",vo=!1;function ru(e,t){switch(e){case"keyup":return bd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Vt=!1;function tf(e,t){switch(e){case"compositionend":return lu(t);case"keypress":return t.which!==32?null:(vo=!0,mo);case"textInput":return e=t.data,e===mo&&vo?null:e;default:return null}}function nf(e,t){if(Vt)return e==="compositionend"||!vi&&ru(e,t)?(e=tu(),Mr=pi=ot=null,Vt=!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=wo(n)}}function au(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?au(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function uu(){for(var e=window,t=Br();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Br(e.document)}return t}function gi(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 ff(e){var t=uu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&au(n.ownerDocument.documentElement,n)){if(r!==null&&gi(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,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=jo(n,s);var o=jo(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(),s>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,Wt=null,ks=null,Dn=null,Ss=!1;function ko(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ss||Wt==null||Wt!==Br(r)||(r=Wt,"selectionStart"in r&&gi(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=Gr(ks,"onSelect"),0Kt||(e.current=zs[Kt],zs[Kt]=null,Kt--)}function U(e,t){Kt++,zs[Kt]=e.current,e.current=t}var xt={},ue=jt(xt),ge=jt(!1),Mt=xt;function on(e,t){var n=e.type.contextTypes;if(!n)return xt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function ye(e){return e=e.childContextTypes,e!=null}function Zr(){B(ge),B(ue)}function zo(e,t,n){if(ue.current!==xt)throw Error(j(168));U(ue,t),U(ge,n)}function yu(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,id(e)||"Unknown",l));return K({},n,r)}function Jr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xt,Mt=ue.current,U(ue,e),U(ge,ge.current),!0}function Lo(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=yu(e,t,Mt),r.__reactInternalMemoizedMergedChildContext=e,B(ge),B(ue),U(ue,e)):B(ge),U(ge,n)}var Ke=null,gl=!1,Yl=!1;function xu(e){Ke===null?Ke=[e]:Ke.push(e)}function Nf(e){gl=!0,xu(e)}function kt(){if(!Yl&&Ke!==null){Yl=!0;var e=0,t=$;try{var n=Ke;for($=1;e>=o,l-=o,Ye=1<<32-Ie(t)+l|n<_?(z=k,k=null):z=k.sibling;var L=h(f,k,m[_],x);if(L===null){k===null&&(k=z);break}e&&k&&L.alternate===null&&t(f,k),d=s(L,d,_),E===null?S=L:E.sibling=L,E=L,k=z}if(_===m.length)return n(f,k),W&&Ct(f,_),S;if(k===null){for(;__?(z=k,k=null):z=k.sibling;var V=h(f,k,L.value,x);if(V===null){k===null&&(k=z);break}e&&k&&V.alternate===null&&t(f,k),d=s(V,d,_),E===null?S=V:E.sibling=V,E=V,k=z}if(L.done)return n(f,k),W&&Ct(f,_),S;if(k===null){for(;!L.done;_++,L=m.next())L=v(f,L.value,x),L!==null&&(d=s(L,d,_),E===null?S=L:E.sibling=L,E=L);return W&&Ct(f,_),S}for(k=r(f,k);!L.done;_++,L=m.next())L=g(k,f,_,L.value,x),L!==null&&(e&&L.alternate!==null&&k.delete(L.key===null?_:L.key),d=s(L,d,_),E===null?S=L:E.sibling=L,E=L);return e&&k.forEach(function(vn){return t(f,vn)}),W&&Ct(f,_),S}function T(f,d,m,x){if(typeof m=="object"&&m!==null&&m.type===Bt&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case cr:e:{for(var S=m.key,E=d;E!==null;){if(E.key===S){if(S=m.type,S===Bt){if(E.tag===7){n(f,E.sibling),d=l(E,m.props.children),d.return=f,f=d;break e}}else if(E.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===rt&&Ro(S)===E.type){n(f,E.sibling),d=l(E,m.props),d.ref=Sn(f,E,m),d.return=f,f=d;break e}n(f,E);break}else t(f,E);E=E.sibling}m.type===Bt?(d=Tt(m.props.children,f.mode,x,m.key),d.return=f,f=d):(x=Ar(m.type,m.key,m.props,null,f.mode,x),x.ref=Sn(f,d,m),x.return=f,f=x)}return o(f);case At:e:{for(E=m.key;d!==null;){if(d.key===E)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=ts(m,f.mode,x),d.return=f,f=d}return o(f);case rt:return E=m._init,T(f,d,E(m._payload),x)}if(_n(m))return w(f,d,m,x);if(yn(m))return y(f,d,m,x);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=es(m,f.mode,x),d.return=f,f=d),o(f)):n(f,d)}return T}var un=Su(!0),Nu=Su(!1),el=jt(null),tl=null,Xt=null,ji=null;function ki(){ji=Xt=tl=null}function Si(e){var t=el.current;B(el),e._currentValue=t}function Ms(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 nn(e,t){tl=e,ji=Xt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ve=!0),e.firstContext=null)}function Te(e){var t=e._currentValue;if(ji!==e)if(e={context:e,memoizedValue:t,next:null},Xt===null){if(tl===null)throw Error(j(308));Xt=e,tl.dependencies={lanes:0,firstContext:e}}else Xt=Xt.next=e;return t}var Pt=null;function Ni(e){Pt===null?Pt=[e]:Pt.push(e)}function Cu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ni(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 lt=!1;function Ci(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Eu(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 pt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,O&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,Ni(r)):(t.next=l.next,l.next=t),r.interleaved=t,qe(e,n)}function Dr(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,ci(e,n)}}function Do(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=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};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,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 nl(e,t,n,r){var l=e.updateQueue;lt=!1;var s=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?s=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(s!==null){var v=l.baseState;o=0,p=c=u=null,a=s;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,y=a;switch(h=t,g=n,y.tag){case 1:if(w=y.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=y.payload,h=typeof w=="function"?w.call(g,v,h):w,h==null)break e;v=K({},v,h);break e;case 2:lt=!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 s===null&&(l.shared.lanes=0);Ot|=o,e.lanes=o,e.memoizedState=v}}function Oo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Xl.transition;Xl.transition={};try{e(!1),t()}finally{$=n,Xl.transition=r}}function Wu(){return Me().memoizedState}function Pf(e,t,n){var r=mt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Hu(e))Qu(t,n);else if(n=Cu(e,t,n,r),n!==null){var l=de();$e(n,e,r,l),Ku(n,t,r)}}function zf(e,t,n){var r=mt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Hu(e))Qu(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,Ue(a,o)){var u=t.interleaved;u===null?(l.next=l,Ni(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Cu(e,t,l,r),n!==null&&(l=de(),$e(n,e,r,l),Ku(n,t,r))}}function Hu(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Qu(e,t){On=ll=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ku(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ci(e,n)}}var sl={readContext:Te,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},Lf={readContext:Te,useCallback:function(e,t){return Be().memoizedState=[e,t===void 0?null:t],e},useContext:Te,useEffect:Io,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fr(4194308,4,$u.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fr(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fr(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=Pf.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=Be();return e={current:e},t.memoizedState=e},useState:Fo,useDebugValue:Ri,useDeferredValue:function(e){return Be().memoizedState=e},useTransition:function(){var e=Fo(!1),t=e[0];return e=_f.bind(null,e[1]),Be().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Q,l=Be();if(W){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),ne===null)throw Error(j(349));Dt&30||Lu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,Io(Mu.bind(null,r,s,e),[e]),r.flags|=2048,er(9,Tu.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Be(),t=ne.identifierPrefix;if(W){var n=Ge,r=Ye;n=(r&~(1<<32-Ie(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,nc(e,t,!1,!1),t.stateNode=e;e:{switch(o=hs(n,r),n){case"dialog":A("cancel",e),A("close",e),l=r;break;case"iframe":case"object":case"embed":A("load",e),l=r;break;case"video":case"audio":for(l=0;lfn&&(t.flags|=128,r=!0,Nn(s,!1),t.lanes=4194304)}else{if(!r)if(e=rl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!W)return oe(t),null}else 2*X()-s.renderingStartTime>fn&&n!==1073741824&&(t.flags|=128,r=!0,Nn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=X(),t.sibling=null,n=H.current,U(H,r?n&1|2:n&1),t):(oe(t),null);case 22:case 23:return Ui(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?we&1073741824&&(oe(t),t.subtreeFlags&6&&(t.flags|=8192)):oe(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function $f(e,t){switch(xi(t),t.tag){case 1:return ye(t.type)&&Zr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return cn(),B(ge),B(ue),Pi(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return _i(t),null;case 13:if(B(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 B(H),null;case 4:return cn(),null;case 10:return Si(t.type._context),null;case 22:case 23:return Ui(),null;case 24:return null;default:return null}}var Sr=!1,ae=!1,Uf=typeof WeakSet=="function"?WeakSet:Set,N=null;function Zt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Y(e,t,r)}else n.current=null}function Bs(e,t,n){try{n()}catch(r){Y(e,t,r)}}var Go=!1;function Af(e,t){if(Ns=Kr,e=uu(),gi(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,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.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!==s||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===s&&++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(Cs={focusedElem:e,selectionRange:n},Kr=!1,N=t;N!==null;)if(t=N,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,N=e;else for(;N!==null;){t=N;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 y=w.memoizedProps,T=w.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?y:De(t.type,y),T);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(x){Y(t,t.return,x)}if(e=t.sibling,e!==null){e.return=t.return,N=e;break}N=t.return}return w=Go,Go=!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 s=l.destroy;l.destroy=void 0,s!==void 0&&Bs(t,n,s)}l=l.next}while(l!==r)}}function wl(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 Vs(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 sc(e){var t=e.alternate;t!==null&&(e.alternate=null,sc(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[Ps],delete t[kf],delete t[Sf])),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 ic(e){return e.tag===5||e.tag===3||e.tag===4}function Xo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ic(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 Ws(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=Xr));else if(r!==4&&(e=e.child,e!==null))for(Ws(e,t,n),e=e.sibling;e!==null;)Ws(e,t,n),e=e.sibling}function Hs(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(Hs(e,t,n),e=e.sibling;e!==null;)Hs(e,t,n),e=e.sibling}var re=null,Oe=!1;function nt(e,t,n){for(n=n.child;n!==null;)oc(e,t,n),n=n.sibling}function oc(e,t,n){if(We&&typeof We.onCommitFiberUnmount=="function")try{We.onCommitFiberUnmount(fl,n)}catch{}switch(n.tag){case 5:ae||Zt(n,t);case 6:var r=re,l=Oe;re=null,nt(e,t,n),re=r,Oe=l,re!==null&&(Oe?(e=re,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):re.removeChild(n.stateNode));break;case 18:re!==null&&(Oe?(e=re,n=n.stateNode,e.nodeType===8?Kl(e.parentNode,n):e.nodeType===1&&Kl(e,n),Hn(e)):Kl(re,n.stateNode));break;case 4:r=re,l=Oe,re=n.stateNode.containerInfo,Oe=!0,nt(e,t,n),re=r,Oe=l;break;case 0:case 11:case 14:case 15:if(!ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Bs(n,t,o),l=l.next}while(l!==r)}nt(e,t,n);break;case 1:if(!ae&&(Zt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Y(n,t,a)}nt(e,t,n);break;case 21:nt(e,t,n);break;case 22:n.mode&1?(ae=(r=ae)||n.memoizedState!==null,nt(e,t,n),ae=r):nt(e,t,n);break;default:nt(e,t,n)}}function Zo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Uf),t.forEach(function(r){var l=Xf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Re(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=X()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Vf(r/1960))-r,10e?16:e,at===null)var r=!1;else{if(e=at,at=null,al=0,O&6)throw Error(j(331));var l=O;for(O|=4,N=e.current;N!==null;){var s=N,o=s.child;if(N.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uX()-Ii?Lt(e,0):Fi|=n),xe(e,t)}function mc(e,t){t===0&&(e.mode&1?(t=hr,hr<<=1,!(hr&130023424)&&(hr=4194304)):t=1);var n=de();e=qe(e,t),e!==null&&(rr(e,t,n),xe(e,n))}function Gf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),mc(e,n)}function Xf(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),mc(e,n)}var vc;vc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ge.current)ve=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ve=!1,Ff(e,t,n);ve=!!(e.flags&131072)}else ve=!1,W&&t.flags&1048576&&wu(t,br,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ir(e,t),e=t.pendingProps;var l=on(t,ue.current);nn(t,n),l=Li(null,t,r,e,l,n);var s=Ti();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,ye(r)?(s=!0,Jr(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ci(t),l.updater=xl,t.stateNode=l,l._reactInternals=t,Ds(t,r,e,n),t=Is(null,t,r,!0,s,n)):(t.tag=0,W&&s&&yi(t),ce(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ir(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Jf(r),e=De(r,e),l){case 0:t=Fs(null,t,r,e,n);break e;case 1:t=Qo(null,t,r,e,n);break e;case 11:t=Wo(null,t,r,e,n);break e;case 14:t=Ho(null,t,r,De(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:De(r,l),Fs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:De(r,l),Qo(e,t,r,l,n);case 3:e:{if(bu(t),e===null)throw Error(j(387));r=t.pendingProps,s=t.memoizedState,l=s.element,Eu(e,t),nl(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=dn(Error(j(423)),t),t=Ko(e,t,r,n,l);break e}else if(r!==l){l=dn(Error(j(424)),t),t=Ko(e,t,r,n,l);break e}else for(je=ft(t.stateNode.containerInfo.firstChild),ke=t,W=!0,Fe=null,n=Nu(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}ce(e,t,r,n)}t=t.child}return t;case 5:return _u(t),e===null&&Ts(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Es(r,l)?o=null:s!==null&&Es(r,s)&&(t.flags|=32),qu(e,t),ce(e,t,o,n),t.child;case 6:return e===null&&Ts(t),null;case 13:return ec(e,t,n);case 4:return Ei(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=un(t,null,r,n):ce(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:De(r,l),Wo(e,t,r,l,n);case 7:return ce(e,t,t.pendingProps,n),t.child;case 8:return ce(e,t,t.pendingProps.children,n),t.child;case 12:return ce(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,U(el,r._currentValue),r._currentValue=o,s!==null)if(Ue(s.value,o)){if(s.children===l.children&&!ge.current){t=be(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=Xe(-1,n&-n),u.tag=2;var c=s.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}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Ms(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(j(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Ms(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}ce(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,nn(t,n),l=Te(l),r=r(l),t.flags|=1,ce(e,t,r,n),t.child;case 14:return r=t.type,l=De(r,t.pendingProps),l=De(r.type,l),Ho(e,t,r,l,n);case 15:return Zu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:De(r,l),Ir(e,t),t.tag=1,ye(r)?(e=!0,Jr(t)):e=!1,nn(t,n),Yu(t,r,l),Ds(t,r,l,n),Is(null,t,r,!0,e,n);case 19:return tc(e,t,n);case 22:return Ju(e,t,n)}throw Error(j(156,t.tag))};function gc(e,t){return Ha(e,t)}function Zf(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 ze(e,t,n,r){return new Zf(e,t,n,r)}function Bi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jf(e){if(typeof e=="function")return Bi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ii)return 11;if(e===oi)return 14}return 2}function vt(e,t){var n=e.alternate;return n===null?(n=ze(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 Ar(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Bi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Bt:return Tt(n.children,l,s,t);case si:o=8,l|=8;break;case ls:return e=ze(12,n,t,l|2),e.elementType=ls,e.lanes=s,e;case ss:return e=ze(13,n,t,l),e.elementType=ss,e.lanes=s,e;case is:return e=ze(19,n,t,l),e.elementType=is,e.lanes=s,e;case _a:return kl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ca:o=10;break e;case Ea:o=9;break e;case ii:o=11;break e;case oi:o=14;break e;case rt:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=ze(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Tt(e,t,n,r){return e=ze(7,e,r,t),e.lanes=n,e}function kl(e,t,n,r){return e=ze(22,e,r,t),e.elementType=_a,e.lanes=n,e.stateNode={isHidden:!1},e}function es(e,t,n){return e=ze(6,e,null,t),e.lanes=n,e}function ts(e,t,n){return t=ze(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function qf(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=Ol(0),this.expirationTimes=Ol(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ol(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Vi(e,t,n,r,l,s,o,a,u){return e=new qf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=ze(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ci(s),e}function bf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jc)}catch(e){console.error(e)}}jc(),ja.exports=Ce;var lp=ja.exports,kc,la=lp;kc=la.createRoot,la.hydrateRoot;const Sc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},sp=()=>!!Sc();async function F(e,...t){const n=Sc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const I={session:()=>F("Session"),login:(e,t)=>F("Login",e,t),logout:()=>F("Logout"),claim:e=>F("Claim",e),runStandalone:()=>F("RunStandalone"),engineStatus:()=>F("EngineStatus"),startEngine:()=>F("StartEngine"),stopEngine:()=>F("StopEngine"),cameras:()=>F("Cameras"),testCamera:e=>F("TestCamera",e),discoverCameras:()=>F("DiscoverCameras"),saveCamera:(e,t)=>F("SaveCamera",e,t),deleteCamera:e=>F("DeleteCamera",e),startPlacement:(e,t)=>F("StartPlacementCheck",e,t),placementResult:e=>F("PlacementResult",e),streamURL:e=>F("StreamURL",e),remoteStreamURL:e=>F("RemoteStreamURL",e),live:()=>F("Live"),pipelineStatus:()=>F("PipelineStatus"),localIdentities:e=>F("LocalIdentities",e),localSightings:e=>F("LocalSightings",e),footfall:(e,t,n)=>F("Footfall",e,t,n),sites:()=>F("Sites"),visitorHistory:(e,t)=>F("VisitorHistory",e,t),visitorPhoto:e=>F("VisitorPhoto",e),forgetCustomer:e=>F("ForgetCustomer",e),sales:(e,t)=>F("Sales",e,t),customers:(e,t)=>F("Customers",e,t),saveProfile:e=>F("SaveProfile",e),ask:e=>F("Ask",e),recordPurchase:(e,t,n,r)=>F("RecordPurchase",e,t,n,r)};function fe(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function et(e,t,n=[]){const[r,l]=C.useState(null),[s,o]=C.useState(null),[a,u]=C.useState(!0),c=C.useRef(!0),p=C.useRef(!1),v=C.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(fe(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return C.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:s,loading:a,reload:v}}function ip(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 sa(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 ns={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 J({size:e,children:t,...n}){return i.jsx("svg",{...ns,...n,width:e??ns.width,height:e??ns.height,children:t})}const op=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),i.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),ap=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),i.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),i.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"})]}),up=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),Nc=e=>i.jsxs(J,{...e,children:[i.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),i.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),ia=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Ki=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),Xs=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),Zs=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),cp=e=>i.jsx(J,{...e,children:i.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Se=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M12 4.6 21 19.4H3z"}),i.jsx("path",{d:"M12 10v4.1"}),i.jsx("path",{d:"M12 17.1v.01"})]}),oa=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),Yi=e=>i.jsx(J,{...e,children:i.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"})}),Cc=e=>i.jsxs(J,{...e,children:[i.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"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),dp=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M12 3.8 19.4 6.6v5.2c0 4.2-3 7.4-7.4 8.4-4.4-1-7.4-4.2-7.4-8.4V6.6z"})}),fp=e=>i.jsxs(J,{...e,children:[i.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"}),i.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"})]}),pp=e=>i.jsxs(J,{...e,children:[i.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),i.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),aa=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M14.6 5.6 8 12l6.6 6.4"})}),hp=e=>i.jsx(J,{...e,children:i.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),Ec=e=>i.jsxs(J,{...e,strokeWidth:"1.2",children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),_c=e=>i.jsxs(J,{...e,strokeWidth:"1.2",children:[i.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),i.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),gt=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function mp({onDone:e}){const[t,n]=C.useState(""),[r,l]=C.useState(""),[s,o]=C.useState(!1),[a,u]=C.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await I.login(t.trim(),r))}catch(v){u(fe(v))}finally{o(!1)}}return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),i.jsxs("form",{onSubmit:c,children:[a&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),a]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:s||!t||!r,children:s?"Signing in…":"Sign in"})]}),i.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 ua({onDone:e,onCancel:t}){const[n,r]=C.useState(""),[l,s]=C.useState(null),[o,a]=C.useState(null);async function u(h){h.preventDefault(),s("claim"),a(null);try{e(await I.claim(n))}catch(g){a(fe(g))}finally{s(null)}}async function c(){s("alone"),a(null);try{e(await I.runStandalone())}catch(h){a(fe(h))}finally{s(null)}}const[p,v]=C.useState(t?"code":null);return p===null?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box wide",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsx("h1",{children:"Welcome to Behavision"}),i.jsx("p",{className:"lead",children:"This PC will watch your shop’s cameras and recognise returning customers. First, one question: is this shop managed from a head office?"}),i.jsxs("div",{className:"choices",children:[i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("code"),children:[i.jsx(Yi,{size:22}),i.jsx("b",{children:"Yes — I have an installation code"}),i.jsxs("span",{children:["Head office gave you a code like ",i.jsx("em",{children:"ABCDEF-123456-…"}),". This PC joins that shop and gets its cameras from there."]})]}),i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("alone"),children:[i.jsx(dp,{size:22}),i.jsx("b",{children:"No — set up on this PC only"}),i.jsx("span",{children:"Cameras, customers and recognition stay on this PC. Nothing is sent anywhere. You can link to a head office later."})]})]})]})}):p==="alone"?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsx("h1",{children:"On this PC only"}),i.jsx("p",{className:"lead",children:"Behavision will run entirely here. Next you’ll add your camera — it can find it on the network for you — and walk past it once so it can prove it works."}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),o]}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!l,onClick:c,children:l==="alone"?"Setting up…":"Continue"}),i.jsx("div",{className:"alt",children:i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(aa,{size:14})," Back"]})})]})}):i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsx("h1",{children:t?"Link to head office":"Join your shop"}),i.jsx("p",{className:"lead",children:"Type the installation code head office gave you. It works once, and this PC becomes that shop."}),i.jsxs("form",{onSubmit:u,children:[o&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),o]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Installation code"}),i.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)})]}),i.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),i.jsxs("p",{className:"foot",children:["Don’t have one? Whoever runs head office creates it under the shop: ",i.jsx("em",{children:"Shops → the shop → Set up a shop PC"}),"."]}),i.jsx("div",{className:"alt",children:t?i.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(aa,{size:14})," Back"]})})]})})}function Pc({onNavigate:e}){var h,g,w,y;const{data:t,error:n}=et(()=>I.live(),3e3),{data:r}=et(()=>I.pipelineStatus(),5e3),l=((h=t==null?void 0:t.stats)==null?void 0:h.cameras)??[],s=((g=t==null?void 0:t.stats)==null?void 0:g.gallery)??{},o=(t==null?void 0:t.events)??[],a=(t==null?void 0:t.viewing)===!0,u=a?((w=t==null?void 0:t.stats)==null?void 0:w.fraction_below_gate)??0:l.reduce((T,f)=>{var m,x;const d=(x=(m=f==null?void 0:f.pipeline)==null?void 0:m.best_quality)==null?void 0:x.fraction_below_gate;return typeof d=="number"&&d>T?d:T},0),c=a?((y=t==null?void 0:t.stats)==null?void 0:y.cameras_up)??0:l.filter(T=>T.connected).length,p=o.filter(T=>T.type==="person.new"||T.type==="person.seen"),v=wp(p[0]);return i.jsxs("div",{className:"page",children:[i.jsxs("header",{children:[i.jsx("h2",{children:"Live"}),i.jsx("p",{children:a?"Your shops, as head office sees them.":"Who is in the shop, and whether it is reaching head office."})]}),n&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),n]}),a&&i.jsxs("div",{className:"viewing",children:[i.jsx(Yi,{size:15}),i.jsxs("span",{children:[i.jsx("b",{children:"Viewing your shops from here."})," This computer is not watching any cameras itself — everything below is what your shop PCs reported. To recognise people on this machine, it has to be on the same network as a camera."]})]}),i.jsx(xp,{pipe:r,cameras:l,up:c}),!a&&i.jsx(vp,{cameras:l,arrivals:p,onNavigate:e}),i.jsxs("div",{className:"panel arrivals-panel",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Who just walked in"}),p.length>0&&i.jsxs("span",{className:"note",children:[p.length," today"]})]}),i.jsx("div",{className:"panelbody flush",children:p.length===0?i.jsxs("div",{className:"empty",children:[i.jsx(_c,{size:34}),i.jsx("b",{children:"Nobody yet"}),i.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):i.jsx("div",{className:"arrivals",children:p.slice(0,30).map((T,f)=>i.jsx(gp,{e:T,fresh:f===0&&v},`${T.ts}-${f}`))})})]}),i.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[i.jsx(Er,{k:"People known",v:s.identities??"—"}),i.jsx(Er,{k:"Sightings",v:s.sightings??"—"}),i.jsx(Er,{k:"Cameras live",v:l.length?`${c}/${l.length}`:"—",tone:l.length?c===0?"bad":c.5?"bad":u>.2?"warn":"ok",s:u>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function vp({cameras:e,arrivals:t,onNavigate:n}){const{data:r}=et(()=>I.engineStatus(),4e3),[l,s]=C.useState(()=>{try{return localStorage.getItem("bv.gettingStarted")==="done"}catch{return!1}}),o=e.length>0,a=e.some(w=>w.connected),{data:u}=et(async()=>{const w={};for(const y of e)try{w[y.camera_id]=await I.placementResult(y.camera_id)}catch{}return w},1e4,[e.map(w=>w.camera_id).join("|")]),c=Object.values(u??{}).some(w=>w&&!w.running&&w.verdict==="good"),p=t.length>0;if(l||p)return null;const v=!!(r!=null&&r.reachable&&(r!=null&&r.recognition_model)),h=r==null?void 0:r.progress,g=[{done:v,now:!v,title:v?`Recognition ready (${r.recognition_model})`:h?`Downloading ${h.what}… ${h.percent}%`:"Starting recognition…",text:v?null:"First start downloads about 275 MB of recognition models. A few minutes on a normal connection; nothing to do meanwhile."},{done:o&&a,now:v&&!(o&&a),title:o?a?"Camera connected":"Camera added — not connecting yet":"Add your camera",text:o?a?null:"Check its password and stream path under Cameras → Edit.":"Behavision can find it on the network; you type only its password.",action:o?null:{label:"Add camera",go:"cameras"}},{done:c,now:o&&a&&!c,title:c?"Camera proven — it can recognise faces":"Walk past the camera",text:c?null:"Run Check placement and walk past like a customer for 25 seconds. Only a “good” verdict means it will recognise people.",action:o&&a&&!c?{label:"Check placement",go:"cameras"}:null}];return i.jsxs("section",{className:"panel starter",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Getting started"}),i.jsx("button",{className:"btn sm ghost",onClick:()=>{try{localStorage.setItem("bv.gettingStarted","done")}catch{}s(!0)},children:"Hide"})]}),i.jsx("ol",{className:"steps compact",children:g.map((w,y)=>i.jsxs("li",{className:w.done?"done":w.now?"now":"",children:[i.jsx("b",{children:w.title}),w.text&&i.jsx("span",{children:w.text}),w.action&&i.jsx("button",{className:"btn sm primary",onClick:()=>n==null?void 0:n(w.action.go),children:w.action.label})]},y))}),i.jsx("p",{className:"note",children:"The moment a customer is recognised, this list goes away."})]})}function gp({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),s=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return i.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[i.jsx("div",{className:"avatar",children:yp(r)}),i.jsxs("div",{className:"who",children:[i.jsx("div",{className:"name",children:r}),i.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&i.jsxs(i.Fragment,{children:[" · ",l.join(", ")]}),s!==null&&!n&&i.jsxs(i.Fragment,{children:[" · match ",s.toFixed(2)]})]})]}),i.jsxs("div",{className:"right",children:[i.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),i.jsx("span",{className:"when",children:ip(e.ts)})]})]})}function yp(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 xp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[i.jsx("i",{className:"dot ok"}),i.jsx("b",{children:"Running on this PC only"})]}),i.jsx("span",{className:"sep"}),i.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(oa,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",s=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[e.broker_up?i.jsx(Yi,{size:15}):i.jsx(Cc,{size:15}),i.jsx("i",{className:`dot ${l}`}),i.jsx("b",{children:s})]}),i.jsx("span",{className:"sep"}),i.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&i.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&i.jsxs("span",{className:"item note bad",children:[i.jsx(Se,{size:14}),e.dropped," lost — this PC was offline too long"]}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(oa,{size:14}),n," of ",t.length," cameras"]})]})}function Er({k:e,v:t,s:n,tone:r}){return i.jsxs("div",{className:`metric ${r??""}`,children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}function wp(e){const[t,n]=C.useState(!1),r=C.useRef(null);return C.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const s=setTimeout(()=>n(!1),1200);return()=>clearTimeout(s)},[e==null?void 0:e.ts]),t}function jp(e){const[t,n]=C.useState(null);return C.useEffect(()=>{let r=!0;return n(null),I.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function kp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?i.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):i.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:i.jsx("span",{children:Sp(t,n)})})}function Sp(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 Np({customer:e}){const{data:t,error:n,loading:r}=et(()=>I.visitorHistory(e.id,50),0,[e.id]);if(r)return i.jsx("p",{className:"note",children:"Loading visits…"});if(n)return i.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?i.jsx("p",{className:"note",children:"No recorded visits yet."}):i.jsx("ul",{className:"timeline",children:l.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"when",children:Cp(s.occurred_at)}),i.jsxs("span",{className:"where",children:[s.site||"this store",s.camera_id?i.jsxs("span",{className:"note",children:[" · ",s.camera_id]}):null]}),s.is_new_visitor&&i.jsx("span",{className:"tag new",children:"first visit"})]},s.id))})}function Cp(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function Ep({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,s]=C.useState(""),[o,a]=C.useState(!1),[u,c]=C.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await I.forgetCustomer(e.id),n()}catch(h){c(fe(h)),a(!1)}}return i.jsxs("div",{className:"confirm",children:[i.jsxs("h4",{children:["Erase ",r,"?"]}),i.jsxs("div",{className:"cols",children:[i.jsxs("div",{children:[i.jsx("p",{className:"lbl bad",children:"Deleted for good"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Their face data — they will not be recognised again"}),i.jsx("li",{children:"Their photo"}),i.jsx("li",{children:"Their name, phone, email and notes"})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"lbl",children:"Kept"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),i.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),i.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&i.jsx("div",{className:"err",children:u}),i.jsxs("label",{className:"field",children:[i.jsxs("span",{children:["Type ",i.jsx("b",{children:r})," to confirm"]}),i.jsx("input",{value:l,onChange:h=>s(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),i.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function _p({customer:e,session:t,onClose:n,onSaved:r}){var E;const[l,s]=C.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=C.useState({amount:"",items:"",notes:""}),[u,c]=C.useState(!1),[p,v]=C.useState(null),[h,g]=C.useState(!1),[w,y]=C.useState(null),T=jp(e.id),f=w??T,d=(E=t==null?void 0:t.user)==null?void 0:E.role,m=["admin","owner","manager"].includes(d),x=k=>_=>s({...l,[k]:_.target.value});async function S(k){k.preventDefault(),c(!0),v(null);try{await I.saveProfile({visitor_id:e.id,...l});const _=parseFloat(o.amount);if(!isNaN(_)&&_>0){const z=o.items.split(",").map(L=>L.trim()).filter(Boolean);await I.recordPurchase(e.id,_,z,o.notes)}r()}catch(_){v(fe(_))}finally{c(!1)}}return i.jsx("div",{className:"drawer",onMouseDown:k=>k.target===k.currentTarget&&n(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead who",children:[i.jsx(kp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>y({available:!1,reason:"The photo could not be loaded."})}),i.jsxs("div",{className:"grow",children:[i.jsx("h2",{children:e.full_name||e.label}),i.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}`]})]}),i.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),i.jsxs("form",{className:"sheetbody",onSubmit:S,children:[p&&i.jsx("div",{className:"err",children:p}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Customer details"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Full name"}),i.jsx("input",{value:l.full_name,onChange:x("full_name"),autoFocus:!0})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Phone"}),i.jsx("input",{value:l.phone,onChange:x("phone"),inputMode:"tel"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{value:l.email,onChange:x("email"),type:"email"})]})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Gender"}),i.jsxs("select",{value:l.gender,onChange:x("gender"),children:[i.jsx("option",{value:"",children:"Not recorded"}),i.jsx("option",{children:"Female"}),i.jsx("option",{children:"Male"}),i.jsx("option",{children:"Other"})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Date of birth"}),i.jsx("input",{type:"date",value:l.date_of_birth,onChange:x("date_of_birth")})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Notes"}),i.jsx("textarea",{value:l.notes,onChange:x("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Purchase (optional)"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Amount"}),i.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:k=>a({...o,amount:k.target.value})})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Items"}),i.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:k=>a({...o,items:k.target.value})})]})]}),i.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Consent"}),i.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:k=>s({...l,consent:k.target.checked})}),i.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),i.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."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Visits"}),i.jsx(Np,{customer:e})]}),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&i.jsxs("section",{className:"formsection dangerzone",children:[i.jsx("h4",{children:"At the customer's request"}),h?i.jsx(Ep,{customer:e,onCancel:()=>g(!1),onDone:r}):i.jsxs(i.Fragment,{children:[i.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."}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function Pp({session:e}){const[t,n]=C.useState(""),[r,l]=C.useState(null),{data:s,error:o,reload:a}=et(()=>I.customers(t,200),3e4,[t]),u=s??[],c=u.filter(p=>p.has_profile).length;return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Customers"}),i.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),i.jsxs("label",{className:"search",children:[i.jsx(Nc,{size:15}),i.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),o]}),i.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[i.jsx(_r,{k:"Known people",v:u.length||"—"}),i.jsx(_r,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),i.jsx(_r,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),i.jsx(_r,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),i.jsx("div",{className:"panel",children:u.length===0?i.jsxs("div",{className:"empty tall",children:[i.jsx(_c,{size:34}),i.jsx("b",{children:"No customers yet"}),i.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Customer"}),i.jsx("th",{children:"Phone"}),i.jsx("th",{className:"num",children:"Visits"}),i.jsx("th",{children:"First seen"}),i.jsx("th",{children:"Last seen"}),i.jsx("th",{children:"Details"})]})}),i.jsx("tbody",{children:u.map(p=>i.jsxs("tr",{className:"click",onClick:()=>l(p),children:[i.jsxs("td",{children:[p.full_name||i.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&i.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),i.jsx("td",{className:"mono",children:p.phone||"—"}),i.jsx("td",{className:"num",children:p.visit_count}),i.jsx("td",{children:sa(p.first_seen_at)}),i.jsx("td",{children:sa(p.last_seen_at)}),i.jsx("td",{children:p.has_profile?i.jsxs("span",{className:"pill ok",children:[i.jsx("i",{className:"dot ok"}),"captured"]}):i.jsxs("span",{className:"pill warn",children:[i.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&i.jsx(_p,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function _r({k:e,v:t,s:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.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:""}],Pr=e=>ln.find(t=>t.id===e)||ln[ln.length-1],Js={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280};function zp(){const{data:e,error:t,reload:n}=et(()=>I.cameras(),8e3),[r,l]=C.useState(null),[s,o]=C.useState(null),a=e??[],u=a.some(y=>y.remote),c=Tp(u?[]:a),[p,v]=C.useState(null),[h,g]=C.useState("");C.useEffect(()=>{let y=!0;if(!p){g("");return}return I.remoteStreamURL(p).then(T=>{y&&g(T||"")}).catch(()=>{y&&g("")}),()=>{y=!1}},[p]);async function w(y){if(confirm(`Remove ${y.id}? Recognition from it stops immediately.`))try{await I.deleteCamera(y.id),n()}catch(T){alert(fe(T))}}return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Cameras"}),i.jsx("p",{children:u?"The cameras across your shops, as the shop computers last reported them.":"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),!u&&i.jsxs("button",{className:"btn primary",onClick:()=>l({...Js}),children:[i.jsx(ia,{size:15}),"Add camera"]})]}),u&&i.jsxs("div",{className:"viewing",children:[i.jsx("b",{children:"Viewing your shops from here."})," These cameras are wired to the shop computers, so they are set up and checked there. Each tile shows that camera's most recent frame; ",i.jsx("b",{children:"Watch live"})," asks the shop computer to send video for as long as you are looking."]}),t&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),t]}),a.length===0?i.jsx("div",{className:"panel",children:i.jsxs("div",{className:"empty tall",children:[i.jsx(Ec,{size:40}),i.jsx("b",{children:"No cameras yet"}),i.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),i.jsxs("button",{className:"btn primary",onClick:()=>l({...Js}),children:[i.jsx(ia,{size:15}),"Add your first camera"]})]})}):i.jsx("div",{className:"camgrid",children:a.map(y=>i.jsx(Lp,{cam:y,stream:p===y.id?h:c[y.id],watching:p===y.id,onWatch:()=>v(p===y.id?null:y.id),onEdit:()=>l(y),onCheck:()=>o(y.id),onRemove:()=>w(y)},y.id))}),r&&i.jsx(Mp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),s&&i.jsx(Rp,{id:s,onClose:()=>o(null)})]})}function Lp({cam:e,stream:t,watching:n,onWatch:r,onEdit:l,onCheck:s,onRemove:o}){var v,h,g;const a=e.remote?{connected:{tone:"ok",label:"Connected"},not_connecting:{tone:"bad",label:"Not connecting"},stale:{tone:"warn",label:"Not reporting"}}[e.state]||{tone:"idle",label:"Waiting for the shop computer"}:e.connected===void 0||e.connected===null?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:u}=et(()=>e.remote?Promise.resolve(null):I.placementResult(e.id),15e3,[e.id]),c=!u||u.running||!u.verdict||u.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:u.verdict==="good"?{tone:"seen",label:"Proven",text:u.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:u.headline||"Move the camera and check again."},p=(v=e.snapshot)!=null&&v.available?e.snapshot.url:"";return i.jsxs("article",{className:"camcard",children:[i.jsxs("div",{className:"camview",children:[t||p?i.jsx("img",{src:t||p,alt:e.id}):i.jsx("div",{className:"placeholder",children:i.jsx(Ec,{size:34})}),i.jsxs("span",{className:`pill ${a.tone==="idle"?"":a.tone} over`,children:[i.jsx("i",{className:`dot ${a.tone}`}),a.label]}),e.remote&&i.jsxs("button",{className:`btn sm watch ${n?"on":""}`,onClick:r,children:[i.jsx(Zs,{size:13}),n?"Stop watching":"Watch live"]})]}),i.jsxs("div",{className:"cambody",children:[i.jsxs("div",{className:"camtitle",children:[i.jsxs("div",{children:[i.jsx("h3",{children:e.label||e.camera_id||e.id}),i.jsx("span",{className:"mono note",children:e.remote?e.site||e.site_slug||"":`${e.host||e.url}${e.path?` · ${e.path}`:""}`})]}),!e.remote&&i.jsxs("div",{className:"camactions",children:[i.jsx("button",{className:"btn sm",onClick:l,children:"Edit"}),i.jsx("button",{className:"btn sm danger",onClick:o,children:"Remove"})]})]}),e.remote?i.jsx("div",{className:"camproof",children:i.jsx("span",{className:"note",children:e.state_note?e.state_note:n?"Live from the shop computer. It uploads only while you watch.":(h=e.snapshot)!=null&&h.available?"Last picture from the shop computer. Watch live to see it now.":((g=e.snapshot)==null?void 0:g.reason)||"No picture yet from the shop computer."})}):i.jsxs("div",{className:"camproof",children:[i.jsx("span",{className:`tag ${c.tone}`,children:c.label}),i.jsx("span",{className:"note",children:c.text}),i.jsxs("button",{className:`btn sm ${c.tone==="seen"?"":"primary"}`,onClick:s,children:[i.jsx(Zs,{size:13}),c.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Tp(e){const[t,n]=C.useState({});return C.useEffect(()=>{let r=!0;const l=e.filter(s=>!(s.id in t));if(l.length)return(async()=>{const s={};for(const o of l)try{s[o.id]=await I.streamURL(o.id)}catch{s[o.id]=""}r&&n(o=>({...o,...s}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function Mp({cam:e,onClose:t,onSaved:n}){var _;const r=!e.id,[l,s]=C.useState({...Js,...e,password:"",path:e.path||(r?ln[0].path:"")}),[o,a]=C.useState(r?ln[0].id:"manual"),[u,c]=C.useState(null),[p,v]=C.useState(null),[h,g]=C.useState(null),w=z=>L=>s({...l,[z]:L.target.value});function y(z){const L=Pr(z.target.value);a(L.id),s(V=>({...V,path:L.path||V.path}))}function T(){const z={};for(const[L,V]of Object.entries(l))V===""||V===null||V===void 0||(z[L]=L==="port"||L==="max_width"?Number(V):V);return z}async function f(){v("test"),g(null),c(null);try{c(await I.testCamera(T()))}catch(z){g(fe(z))}finally{v(null)}}async function d(z){z.preventDefault(),v("save"),g(null);try{await I.saveCamera(r?"":e.id,T()),n()}catch(L){g(fe(L))}finally{v(null)}}const m=Pr(o),[x,S]=C.useState(null);async function E(){S("busy");try{S(await I.discoverCameras())}catch(z){S({error:fe(z)})}}function k(z){const L=z.make?Pr(z.make):null;s(V=>({...V,host:z.host,path:(L==null?void 0:L.path)||V.path,id:V.id||""})),L&&a(L.id),c(null)}return i.jsx("div",{className:"drawer",onMouseDown:z=>z.target===z.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Ki,{size:16})})]}),i.jsxs("form",{className:"sheetbody",onSubmit:d,autoComplete:"off",children:[i.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&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),h]}),r&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Find it"}),x===null&&i.jsxs("div",{className:"finder",children:[i.jsx("p",{children:"Behavision can look for cameras on this shop’s network."}),i.jsxs("button",{type:"button",className:"btn primary",onClick:E,children:[i.jsx(Nc,{size:14}),"Find cameras on this network"]})]}),x==="busy"&&i.jsxs("div",{className:"finder busy",children:[i.jsx("span",{className:"spinner"}),"Looking on the network… a few seconds."]}),(x==null?void 0:x.error)&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),x.error]}),(x==null?void 0:x.cameras)&&(x.cameras.length===0?i.jsxs("div",{className:"finder",children:[i.jsxs("p",{children:["Nothing answered on ",((_=x.networks)==null?void 0:_.join(", "))||"this network",". The camera may be on a different network, switched off, or not yet connected — check its cable and power, then try again. You can still type its address below."]}),i.jsx("button",{type:"button",className:"btn",onClick:E,children:"Try again"})]}):i.jsxs("ul",{className:"foundlist",children:[x.cameras.map(z=>i.jsx("li",{className:l.host===z.host?"picked":"",children:i.jsxs("button",{type:"button",onClick:()=>k(z),children:[i.jsx("span",{className:"mono",children:z.host}),i.jsx("span",{className:"what",children:z.name||(z.rtsp?"Streams video (RTSP)":"Answers ONVIF")}),z.make&&i.jsx("span",{className:"tag seen",children:Pr(z.make).label}),l.host===z.host&&i.jsx(Xs,{size:16})]})},z.host)),i.jsx("li",{className:"rescan",children:i.jsx("button",{type:"button",className:"btn sm",onClick:E,children:"Scan again"})})]}))]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The camera"}),r&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l.id,onChange:w("id"),placeholder:"entrance",required:!0,autoFocus:!0}),i.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Address"}),i.jsx("input",{value:l.host,onChange:w("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),i.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Port"}),i.jsx("input",{value:l.port,onChange:w("port"),inputMode:"numeric"})]})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The stream"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Make of camera"}),i.jsx("select",{value:o,onChange:y,children:ln.map(z=>i.jsx("option",{value:z.id,children:z.label},z.id))}),m.note&&i.jsx("em",{className:"hint",children:m.note})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Stream path"}),i.jsx("input",{className:"mono",value:l.path,onChange:w("path"),placeholder:"/Streaming/Channels/101"}),i.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Sign-in to the camera"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Username"}),i.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:w("username"),placeholder:"admin"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:w("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),u&&(u.ok?i.jsxs("div",{className:"testresult ok",children:[i.jsx(Xs,{size:16}),i.jsxs("div",{children:[i.jsxs("b",{children:["Connected — ",u.width,"×",u.height,u.codec?` · ${String(u.codec).toUpperCase()}`:""]}),u.snapshot&&i.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${u.snapshot}`})]})]}):i.jsxs("div",{className:"testresult bad",children:[i.jsx(Se,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"Could not connect"}),i.jsx("span",{children:u.error})]})]})),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:f,disabled:!!p||!l.host,children:p==="test"?"Connecting…":"Test connection"}),i.jsx("button",{className:"btn primary",disabled:!!p||!l.id||!l.host,children:p==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Rp({id:e,onClose:t}){var p,v;const[n,r]=C.useState({verdict:"starting",advice:[]}),[l,s]=C.useState(null),o=C.useRef(null);C.useEffect(()=>{let h=!0;return(async()=>{try{r(await I.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await I.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&s(fe(g))}},1e3)}catch(g){h&&s(fe(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 i.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsxs("h2",{children:["Check placement · ",e]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Ki,{size:16})})]}),i.jsxs("div",{className:"sheetbody",children:[l&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),l]}),i.jsxs("ol",{className:"steps",children:[i.jsxs("li",{className:c?"now":"done",children:[i.jsx("b",{children:"Walk past the camera"}),i.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&&i.jsx("div",{className:"progress",children:i.jsx("div",{style:{width:`${u}%`}})})]}),i.jsxs("li",{className:c?"":"now",children:[i.jsx("b",{children:"Behavision judges what it saw"}),i.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),i.jsxs("div",{className:`verdict ${a??""}`,children:[i.jsxs("div",{className:"verdict-head",children:[c?i.jsx("span",{className:"spinner"}):a==="ok"?i.jsx(Xs,{size:18}):i.jsx(Se,{size:18}),i.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&i.jsx("ul",{children:n.advice.map((h,g)=>i.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&i.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&&i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{className:"btn",onClick:t,children:"Close"}),i.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),I.startPlacement(e,25).then(r).catch(h=>s(fe(h)))},children:"Run again"})]})]})]})})}const Dp=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Op({session:e,onClose:t}){const[n,r]=C.useState([]),[l,s]=C.useState(""),[o,a]=C.useState(!1),[u,c]=C.useState(null),p=C.useRef(null),v=e==null?void 0:e.standalone;C.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 y=[...n,{role:"user",text:w}];r(y),s(""),a(!0),c(null);try{const T=await I.ask(y.map(f=>({role:f.role,text:f.text})));r([...y,{role:"assistant",text:T.text,used:T.used??[]}])}catch(T){const f=fe(T);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),s(w)}finally{a(!1)}}return i.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[i.jsxs("header",{className:"helperhead",children:[i.jsx("img",{src:gt,alt:""}),i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Ki,{size:16})})]}),i.jsxs("div",{className:"helperbody",ref:p,children:[v&&i.jsxs("div",{className:"helpernote",children:[i.jsx(Cc,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"This PC runs on its own"}),i.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&&i.jsxs("div",{className:"helperintro",children:[i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble",children:[Fp(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),i.jsx("div",{className:"chips",children:Dp.map(g=>i.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&i.jsx(Ip,{})]}),n.map((g,w)=>{var y;return i.jsxs("div",{className:`turn ${g.role}`,children:[i.jsx("div",{className:"bubble",children:g.text}),((y=g.used)==null?void 0:y.length)>0&&i.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},w)}),o&&i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble thinking",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})}),u&&i.jsxs("div",{className:"err",children:[i.jsx(Se,{size:15}),u]})]}),i.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[i.jsx("input",{value:l,onChange:g=>s(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),i.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:i.jsx(hp,{size:16})})]})]})}function Fp(e){var l,s;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(s=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:s.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function Ip(){return i.jsxs("dl",{className:"quickhelp",children:[i.jsx("dt",{children:"Adding a camera"}),i.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."}),i.jsx("dt",{children:"Proving it works"}),i.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."}),i.jsx("dt",{children:"Nothing showing on Live"}),i.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),i.jsx("dt",{children:"Linking to head office later"}),i.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 $p=[{id:"live",label:"Live",Glyph:op,View:Pc},{id:"customers",label:"Customers",Glyph:ap,View:Pp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:up,View:zp}];function Up(){var h,g,w;const[e,t]=C.useState(null),[n,r]=C.useState("live"),[l,s]=C.useState(!0),[o,a]=C.useState(!1),[u,c]=C.useState(!1);if(C.useEffect(()=>{let y=!0;const T=async()=>{try{const d=await I.session();y&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{y&&t(null)}y&&s(!1)};T();const f=setInterval(T,8e3);return()=>{y=!1,clearInterval(f)}},[]),!sp())return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.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 i.jsx("div",{className:"login",children:i.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return i.jsx(ua,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return i.jsx(mp,{onDone:t});const p=$p.filter(y=>!y.cloud||!e.standalone),v=((h=p.find(y=>y.id===n))==null?void 0:h.View)??Pc;return o?i.jsx(ua,{onDone:y=>{a(!1),t(y)},onCancel:()=>a(!1)}):i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"side",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:gt,alt:""})}),i.jsxs("div",{className:"id",children:[i.jsx("h1",{children:"Behavision"}),i.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),i.jsx("nav",{className:"nav",children:p.map(({id:y,label:T,Glyph:f})=>i.jsxs("button",{onClick:()=>r(y),"aria-current":y===n?"page":void 0,children:[i.jsx(f,{size:17}),T]},y))}),i.jsx(Ap,{}),i.jsx("div",{className:"who",children:e.standalone?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"On its own"}),i.jsx("span",{children:"No head office"})]}),i.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:i.jsx(fp,{size:15})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"Signed in"}),i.jsx("span",{children:(w=e.user)==null?void 0:w.email})]}),i.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await I.logout()),children:i.jsx(pp,{size:15})})]})})]}),i.jsxs("main",{className:"main",children:[i.jsx(v,{session:e,onNavigate:r}),!u&&i.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[i.jsx("img",{src:gt,alt:""}),i.jsx("span",{children:"Loya"})]})]}),u&&i.jsx(Op,{session:e,onClose:()=>c(!1)})]})}function Ap(){const{data:e,reload:t}=et(()=>I.engineStatus(),5e3),[n,r]=C.useState(!1),l=e??{state:"stopped"},s=C.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(fe(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&&l.progress?(c="warn",p=`Downloading ${l.progress.what}… ${l.progress.percent}%`):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&&us(I.startEngine),children:[i.jsx(Zs,{size:13}),"Start"]}),i.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>s(I.stopEngine),children:[i.jsx(cp,{size:13}),"Stop"]})]})]})}kc(document.getElementById("root")).render(i.jsx(Kc.StrictMode,{children:i.jsx(Up,{})})); diff --git a/desktop/frontend/dist/assets/index-DSNu_2FW.js b/desktop/frontend/dist/assets/index-DSNu_2FW.js new file mode 100644 index 0000000..1153fa5 --- /dev/null +++ b/desktop/frontend/dist/assets/index-DSNu_2FW.js @@ -0,0 +1,40 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var da={exports:{}},pl={},fa={exports:{}},D={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var lr=Symbol.for("react.element"),Mc=Symbol.for("react.portal"),Rc=Symbol.for("react.fragment"),Dc=Symbol.for("react.strict_mode"),Oc=Symbol.for("react.profiler"),Fc=Symbol.for("react.provider"),Ic=Symbol.for("react.context"),$c=Symbol.for("react.forward_ref"),Uc=Symbol.for("react.suspense"),Ac=Symbol.for("react.memo"),Bc=Symbol.for("react.lazy"),Zi=Symbol.iterator;function Vc(e){return e===null||typeof e!="object"?null:(e=Zi&&e[Zi]||e["@@iterator"],typeof e=="function"?e:null)}var pa={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},ha=Object.assign,ma={};function vn(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}vn.prototype.isReactComponent={};vn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};vn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function va(){}va.prototype=vn.prototype;function ei(e,t,n){this.props=e,this.context=t,this.refs=ma,this.updater=n||pa}var ti=ei.prototype=new va;ti.constructor=ei;ha(ti,vn.prototype);ti.isPureReactComponent=!0;var Ji=Array.isArray,ga=Object.prototype.hasOwnProperty,ni={current:null},ya={key:!0,ref:!0,__self:!0,__source:!0};function xa(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)ga.call(t,r)&&!ya.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,te=_[X];if(0>>1;Xl(Tl,R))_tl(cr,Tl)?(_[X]=cr,_[_t]=R,X=_t):(_[X]=Tl,_[Et]=R,X=Et);else if(_tl(cr,R))_[X]=cr,_[_t]=R,X=_t;else break e}}return T}function l(_,T){var R=_.sortIndex-T.sortIndex;return R!==0?R:_.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],c=[],p=1,v=null,h=3,g=!1,x=!1,y=!1,z=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(_){for(var T=n(c);T!==null;){if(T.callback===null)r(c);else if(T.startTime<=_)r(c),T.sortIndex=T.expirationTime,t(u,T);else break;T=n(c)}}function w(_){if(y=!1,m(_),!x)if(n(u)!==null)x=!0,zl(S);else{var T=n(c);T!==null&&Ll(w,T.startTime-_)}}function S(_,T){x=!1,y&&(y=!1,f(E),E=-1),g=!0;var R=h;try{for(m(T),v=n(u);v!==null&&(!(v.expirationTime>T)||_&&!ge());){var X=v.callback;if(typeof X=="function"){v.callback=null,h=v.priorityLevel;var te=X(v.expirationTime<=T);T=e.unstable_now(),typeof te=="function"?v.callback=te:v===n(u)&&r(u),m(T)}else r(u);v=n(u)}if(v!==null)var ur=!0;else{var Et=n(c);Et!==null&&Ll(w,Et.startTime-T),ur=!1}return ur}finally{v=null,h=R,g=!1}}var P=!1,k=null,E=-1,U=5,M=-1;function ge(){return!(e.unstable_now()-M_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(_){switch(h){case 1:case 2:case 3:var T=3;break;default:T=h}var R=h;h=T;try{return _()}finally{h=R}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,T){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var R=h;h=_;try{return T()}finally{h=R}},e.unstable_scheduleCallback=function(_,T,R){var X=e.unstable_now();switch(typeof R=="object"&&R!==null?(R=R.delay,R=typeof R=="number"&&0X?(_.sortIndex=R,t(c,_),n(u)===null&&_===n(c)&&(y?(f(E),E=-1):y=!0,Ll(w,R-X))):(_.sortIndex=te,t(u,_),x||g||(x=!0,zl(S))),_},e.unstable_shouldYield=ge,e.unstable_wrapCallback=function(_){var T=h;return function(){var R=h;h=T;try{return _.apply(this,arguments)}finally{h=R}}}})(Na);Sa.exports=Na;var ed=Sa.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var td=N,_e=ed;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ss=Object.prototype.hasOwnProperty,nd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bi={},eo={};function rd(e){return ss.call(eo,e)?!0:ss.call(bi,e)?!1:nd.test(e)?eo[e]=!0:(bi[e]=!0,!1)}function ld(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sd(e,t,n,r){if(t===null||typeof t>"u"||ld(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ve(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ie={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ie[e]=new ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ie[t]=new ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ie[e]=new ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ie[e]=new ve(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ie[e]=new ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ie[e]=new ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ie[e]=new ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ie[e]=new ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ie[e]=new ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var li=/[\-:]([a-z])/g;function si(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(li,si);ie[t]=new ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ie[e]=new ve(e,1,!1,e.toLowerCase(),null,!1,!1)});ie.xlinkHref=new ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ie[e]=new ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function ii(e,t,n,r){var l=ie.hasOwnProperty(t)?ie[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` +`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Dl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Pn(e):""}function id(e){switch(e.tag){case 5:return Pn(e.type);case 16:return Pn("Lazy");case 13:return Pn("Suspense");case 19:return Pn("SuspenseList");case 0:case 2:case 15:return e=Ol(e.type,!1),e;case 11:return e=Ol(e.type.render,!1),e;case 1:return e=Ol(e.type,!0),e;default:return""}}function us(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 Ht:return"Fragment";case Wt:return"Portal";case is:return"Profiler";case oi:return"StrictMode";case os:return"Suspense";case as:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case _a:return(e.displayName||"Context")+".Consumer";case Ea:return(e._context.displayName||"Context")+".Provider";case ai:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ui:return t=e.displayName||null,t!==null?t:us(e.type)||"Memo";case it:t=e._payload,e=e._init;try{return us(e(t))}catch{}}return null}function od(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 us(t);case 8:return t===oi?"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 jt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function za(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ad(e){var t=za(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,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.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 pr(e){e._valueTracker||(e._valueTracker=ad(e))}function La(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=za(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Wr(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 cs(e,t){var n=t.checked;return Y({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function no(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=jt(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 Ta(e,t){t=t.checked,t!=null&&ii(e,"checked",t,!1)}function ds(e,t){Ta(e,t);var n=jt(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")?fs(e,t.type,n):t.hasOwnProperty("defaultValue")&&fs(e,t.type,jt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ro(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 fs(e,t,n){(t!=="number"||Wr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zn=Array.isArray;function tn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=hr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Vn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Mn={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},ud=["Webkit","ms","Moz","O"];Object.keys(Mn).forEach(function(e){ud.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Mn[t]=Mn[e]})});function Oa(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Mn.hasOwnProperty(e)&&Mn[e]?(""+t).trim():t+"px"}function Fa(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Oa(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var cd=Y({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 ms(e,t){if(t){if(cd[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 vs(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 gs=null;function ci(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ys=null,nn=null,rn=null;function io(e){if(e=or(e)){if(typeof ys!="function")throw Error(j(280));var t=e.stateNode;t&&(t=yl(t),ys(e.stateNode,e.type,t))}}function Ia(e){nn?rn?rn.push(e):rn=[e]:nn=e}function $a(){if(nn){var e=nn,t=rn;if(rn=nn=null,io(e),t)for(e=0;e>>=0,e===0?32:31-(jd(e)/kd|0)|0}var mr=64,vr=4194304;function Ln(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 Yr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Ln(a):(s&=o,s!==0&&(r=Ln(s)))}else o=n&~l,o!==0?r=Ln(o):s!==0&&(r=Ln(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&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 sr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ae(t),e[t]=n}function Ed(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=Dn),vo=" ",go=!1;function lu(e,t){switch(e){case"keyup":return ef.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function su(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Qt=!1;function nf(e,t){switch(e){case"compositionend":return su(t);case"keypress":return t.which!==32?null:(go=!0,vo);case"textInput":return e=t.data,e===vo&&go?null:e;default:return null}}function rf(e,t){if(Qt)return e==="compositionend"||!yi&&lu(e,t)?(e=nu(),Dr=mi=ct=null,Qt=!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=jo(n)}}function uu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?uu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function cu(){for(var e=window,t=Wr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Wr(e.document)}return t}function xi(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 pf(e){var t=cu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&uu(n.ownerDocument.documentElement,n)){if(r!==null&&xi(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,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=ko(n,s);var o=ko(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(),s>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,Kt=null,Ns=null,Fn=null,Cs=!1;function So(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Cs||Kt==null||Kt!==Wr(r)||(r=Kt,"selectionStart"in r&&xi(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}),Fn&&Gn(Fn,r)||(Fn=r,r=Zr(Ns,"onSelect"),0Xt||(e.current=Ts[Xt],Ts[Xt]=null,Xt--)}function A(e,t){Xt++,Ts[Xt]=e.current,e.current=t}var kt={},ce=Nt(kt),we=Nt(!1),Ot=kt;function cn(e,t){var n=e.type.contextTypes;if(!n)return kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function je(e){return e=e.childContextTypes,e!=null}function qr(){W(we),W(ce)}function Lo(e,t,n){if(ce.current!==kt)throw Error(j(168));A(ce,t),A(we,n)}function xu(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,od(e)||"Unknown",l));return Y({},n,r)}function br(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kt,Ot=ce.current,A(ce,e),A(we,we.current),!0}function To(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=xu(e,t,Ot),r.__reactInternalMemoizedMergedChildContext=e,W(we),W(ce),A(ce,e)):W(we),A(we,n)}var Xe=null,xl=!1,Xl=!1;function wu(e){Xe===null?Xe=[e]:Xe.push(e)}function Cf(e){xl=!0,wu(e)}function Ct(){if(!Xl&&Xe!==null){Xl=!0;var e=0,t=$;try{var n=Xe;for($=1;e>=o,l-=o,Ze=1<<32-Ae(t)+l|n<E?(U=k,k=null):U=k.sibling;var M=h(f,k,m[E],w);if(M===null){k===null&&(k=U);break}e&&k&&M.alternate===null&&t(f,k),d=s(M,d,E),P===null?S=M:P.sibling=M,P=M,k=U}if(E===m.length)return n(f,k),H&&Pt(f,E),S;if(k===null){for(;EE?(U=k,k=null):U=k.sibling;var ge=h(f,k,M.value,w);if(ge===null){k===null&&(k=U);break}e&&k&&ge.alternate===null&&t(f,k),d=s(ge,d,E),P===null?S=ge:P.sibling=ge,P=ge,k=U}if(M.done)return n(f,k),H&&Pt(f,E),S;if(k===null){for(;!M.done;E++,M=m.next())M=v(f,M.value,w),M!==null&&(d=s(M,d,E),P===null?S=M:P.sibling=M,P=M);return H&&Pt(f,E),S}for(k=r(f,k);!M.done;E++,M=m.next())M=g(k,f,E,M.value,w),M!==null&&(e&&M.alternate!==null&&k.delete(M.key===null?E:M.key),d=s(M,d,E),P===null?S=M:P.sibling=M,P=M);return e&&k.forEach(function(L){return t(f,L)}),H&&Pt(f,E),S}function z(f,d,m,w){if(typeof m=="object"&&m!==null&&m.type===Ht&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case fr:e:{for(var S=m.key,P=d;P!==null;){if(P.key===S){if(S=m.type,S===Ht){if(P.tag===7){n(f,P.sibling),d=l(P,m.props.children),d.return=f,f=d;break e}}else if(P.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===it&&Do(S)===P.type){n(f,P.sibling),d=l(P,m.props),d.ref=Nn(f,P,m),d.return=f,f=d;break e}n(f,P);break}else t(f,P);P=P.sibling}m.type===Ht?(d=Dt(m.props.children,f.mode,w,m.key),d.return=f,f=d):(w=Vr(m.type,m.key,m.props,null,f.mode,w),w.ref=Nn(f,d,m),w.return=f,f=w)}return o(f);case Wt:e:{for(P=m.key;d!==null;){if(d.key===P)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=rs(m,f.mode,w),d.return=f,f=d}return o(f);case it:return P=m._init,z(f,d,P(m._payload),w)}if(zn(m))return x(f,d,m,w);if(xn(m))return y(f,d,m,w);Sr(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=ns(m,f.mode,w),d.return=f,f=d),o(f)):n(f,d)}return z}var fn=Nu(!0),Cu=Nu(!1),nl=Nt(null),rl=null,qt=null,Si=null;function Ni(){Si=qt=rl=null}function Ci(e){var t=nl.current;W(nl),e._currentValue=t}function Ds(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 sn(e,t){rl=e,Si=qt=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(xe=!0),e.firstContext=null)}function De(e){var t=e._currentValue;if(Si!==e)if(e={context:e,memoizedValue:t,next:null},qt===null){if(rl===null)throw Error(j(308));qt=e,rl.dependencies={lanes:0,firstContext:e}}else qt=qt.next=e;return t}var Tt=null;function Ei(e){Tt===null?Tt=[e]:Tt.push(e)}function Eu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ei(t)):(n.next=l.next,l.next=n),t.interleaved=n,tt(e,r)}function tt(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 ot=!1;function _i(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _u(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 qe(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,O&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,tt(e,n)}return l=r.interleaved,l===null?(t.next=t,Ei(r)):(t.next=l.next,l.next=t),r.interleaved=t,tt(e,n)}function Fr(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,fi(e,n)}}function Oo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=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};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,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 ll(e,t,n,r){var l=e.updateQueue;ot=!1;var s=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?s=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(s!==null){var v=l.baseState;o=0,p=c=u=null,a=s;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 x=e,y=a;switch(h=t,g=n,y.tag){case 1:if(x=y.payload,typeof x=="function"){v=x.call(g,v,h);break e}v=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=y.payload,h=typeof x=="function"?x.call(g,v,h):x,h==null)break e;v=Y({},v,h);break e;case 2:ot=!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 s===null&&(l.shared.lanes=0);$t|=o,e.lanes=o,e.memoizedState=v}}function Fo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Jl.transition;Jl.transition={};try{e(!1),t()}finally{$=n,Jl.transition=r}}function Hu(){return Oe().memoizedState}function zf(e,t,n){var r=yt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Qu(e))Ku(t,n);else if(n=Eu(e,t,n,r),n!==null){var l=pe();Be(n,e,r,l),Yu(n,t,r)}}function Lf(e,t,n){var r=yt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qu(e))Ku(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,Ve(a,o)){var u=t.interleaved;u===null?(l.next=l,Ei(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Eu(e,t,l,r),n!==null&&(l=pe(),Be(n,e,r,l),Yu(n,t,r))}}function Qu(e){var t=e.alternate;return e===K||t!==null&&t===K}function Ku(e,t){In=il=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Yu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,fi(e,n)}}var ol={readContext:De,useCallback:oe,useContext:oe,useEffect:oe,useImperativeHandle:oe,useInsertionEffect:oe,useLayoutEffect:oe,useMemo:oe,useReducer:oe,useRef:oe,useState:oe,useDebugValue:oe,useDeferredValue:oe,useTransition:oe,useMutableSource:oe,useSyncExternalStore:oe,useId:oe,unstable_isNewReconciler:!1},Tf={readContext:De,useCallback:function(e,t){return He().memoizedState=[e,t===void 0?null:t],e},useContext:De,useEffect:$o,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,$r(4194308,4,Uu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $r(4194308,4,e,t)},useInsertionEffect:function(e,t){return $r(4,2,e,t)},useMemo:function(e,t){var n=He();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=He();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=zf.bind(null,K,e),[r.memoizedState,e]},useRef:function(e){var t=He();return e={current:e},t.memoizedState=e},useState:Io,useDebugValue:Oi,useDeferredValue:function(e){return He().memoizedState=e},useTransition:function(){var e=Io(!1),t=e[0];return e=Pf.bind(null,e[1]),He().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=K,l=He();if(H){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),re===null)throw Error(j(349));It&30||Tu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,$o(Ru.bind(null,r,s,e),[e]),r.flags|=2048,nr(9,Mu.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=He(),t=re.identifierPrefix;if(H){var n=Je,r=Ze;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=er++,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[Qe]=t,e[Jn]=r,rc(e,t,!1,!1),t.stateNode=e;e:{switch(o=vs(n,r),n){case"dialog":V("cancel",e),V("close",e),l=r;break;case"iframe":case"object":case"embed":V("load",e),l=r;break;case"video":case"audio":for(l=0;lmn&&(t.flags|=128,r=!0,Cn(s,!1),t.lanes=4194304)}else{if(!r)if(e=sl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Cn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!H)return ae(t),null}else 2*Z()-s.renderingStartTime>mn&&n!==1073741824&&(t.flags|=128,r=!0,Cn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Z(),t.sibling=null,n=Q.current,A(Q,r?n&1|2:n&1),t):(ae(t),null);case 22:case 23:return Bi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Se&1073741824&&(ae(t),t.subtreeFlags&6&&(t.flags|=8192)):ae(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function Uf(e,t){switch(ji(t),t.tag){case 1:return je(t.type)&&qr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pn(),W(we),W(ce),Li(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return zi(t),null;case 13:if(W(Q),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(Q),null;case 4:return pn(),null;case 10:return Ci(t.type._context),null;case 22:case 23:return Bi(),null;case 24:return null;default:return null}}var Cr=!1,ue=!1,Af=typeof WeakSet=="function"?WeakSet:Set,C=null;function bt(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){G(e,t,r)}else n.current=null}function Ws(e,t,n){try{n()}catch(r){G(e,t,r)}}var Xo=!1;function Bf(e,t){if(Es=Gr,e=cu(),xi(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,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.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!==s||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===s&&++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(_s={focusedElem:e,selectionRange:n},Gr=!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 x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var y=x.memoizedProps,z=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?y:Ie(t.type,y),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(w){G(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,C=e;break}C=t.return}return x=Xo,Xo=!1,x}function $n(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 s=l.destroy;l.destroy=void 0,s!==void 0&&Ws(t,n,s)}l=l.next}while(l!==r)}}function kl(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 Hs(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 ic(e){var t=e.alternate;t!==null&&(e.alternate=null,ic(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Qe],delete t[Jn],delete t[Ls],delete t[Sf],delete t[Nf])),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 oc(e){return e.tag===5||e.tag===3||e.tag===4}function Zo(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||oc(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 Qs(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=Jr));else if(r!==4&&(e=e.child,e!==null))for(Qs(e,t,n),e=e.sibling;e!==null;)Qs(e,t,n),e=e.sibling}function Ks(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(Ks(e,t,n),e=e.sibling;e!==null;)Ks(e,t,n),e=e.sibling}var le=null,$e=!1;function st(e,t,n){for(n=n.child;n!==null;)ac(e,t,n),n=n.sibling}function ac(e,t,n){if(Ke&&typeof Ke.onCommitFiberUnmount=="function")try{Ke.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:ue||bt(n,t);case 6:var r=le,l=$e;le=null,st(e,t,n),le=r,$e=l,le!==null&&($e?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&($e?(e=le,n=n.stateNode,e.nodeType===8?Gl(e.parentNode,n):e.nodeType===1&&Gl(e,n),Kn(e)):Gl(le,n.stateNode));break;case 4:r=le,l=$e,le=n.stateNode.containerInfo,$e=!0,st(e,t,n),le=r,$e=l;break;case 0:case 11:case 14:case 15:if(!ue&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Ws(n,t,o),l=l.next}while(l!==r)}st(e,t,n);break;case 1:if(!ue&&(bt(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){G(n,t,a)}st(e,t,n);break;case 21:st(e,t,n);break;case 22:n.mode&1?(ue=(r=ue)||n.memoizedState!==null,st(e,t,n),ue=r):st(e,t,n);break;default:st(e,t,n)}}function Jo(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Af),t.forEach(function(r){var l=Zf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Fe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Wf(r/1960))-r,10e?16:e,dt===null)var r=!1;else{if(e=dt,dt=null,cl=0,O&6)throw Error(j(331));var l=O;for(O|=4,C=e.current;C!==null;){var s=C,o=s.child;if(C.flags&16){var a=s.deletions;if(a!==null){for(var u=0;uZ()-Ui?Rt(e,0):$i|=n),ke(e,t)}function vc(e,t){t===0&&(e.mode&1?(t=vr,vr<<=1,!(vr&130023424)&&(vr=4194304)):t=1);var n=pe();e=tt(e,t),e!==null&&(sr(e,t,n),ke(e,n))}function Xf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vc(e,n)}function Zf(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),vc(e,n)}var gc;gc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||we.current)xe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return xe=!1,If(e,t,n);xe=!!(e.flags&131072)}else xe=!1,H&&t.flags&1048576&&ju(t,tl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ur(e,t),e=t.pendingProps;var l=cn(t,ce.current);sn(t,n),l=Mi(null,t,r,e,l,n);var s=Ri();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,je(r)?(s=!0,br(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,_i(t),l.updater=jl,t.stateNode=l,l._reactInternals=t,Fs(t,r,e,n),t=Us(null,t,r,!0,s,n)):(t.tag=0,H&&s&&wi(t),fe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ur(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=qf(r),e=Ie(r,e),l){case 0:t=$s(null,t,r,e,n);break e;case 1:t=Ko(null,t,r,e,n);break e;case 11:t=Ho(null,t,r,e,n);break e;case 14:t=Qo(null,t,r,Ie(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:Ie(r,l),$s(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ko(e,t,r,l,n);case 3:e:{if(ec(t),e===null)throw Error(j(387));r=t.pendingProps,s=t.memoizedState,l=s.element,_u(e,t),ll(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=hn(Error(j(423)),t),t=Yo(e,t,r,n,l);break e}else if(r!==l){l=hn(Error(j(424)),t),t=Yo(e,t,r,n,l);break e}else for(Ne=mt(t.stateNode.containerInfo.firstChild),Ce=t,H=!0,Ue=null,n=Cu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(dn(),r===l){t=nt(e,t,n);break e}fe(e,t,r,n)}t=t.child}return t;case 5:return Pu(t),e===null&&Rs(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Ps(r,l)?o=null:s!==null&&Ps(r,s)&&(t.flags|=32),bu(e,t),fe(e,t,o,n),t.child;case 6:return e===null&&Rs(t),null;case 13:return tc(e,t,n);case 4:return Pi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=fn(t,null,r,n):fe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ho(e,t,r,l,n);case 7:return fe(e,t,t.pendingProps,n),t.child;case 8:return fe(e,t,t.pendingProps.children,n),t.child;case 12:return fe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,A(nl,r._currentValue),r._currentValue=o,s!==null)if(Ve(s.value,o)){if(s.children===l.children&&!we.current){t=nt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=qe(-1,n&-n),u.tag=2;var c=s.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}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Ds(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(j(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Ds(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}fe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,sn(t,n),l=De(l),r=r(l),t.flags|=1,fe(e,t,r,n),t.child;case 14:return r=t.type,l=Ie(r,t.pendingProps),l=Ie(r.type,l),Qo(e,t,r,l,n);case 15:return Ju(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ie(r,l),Ur(e,t),t.tag=1,je(r)?(e=!0,br(t)):e=!1,sn(t,n),Gu(t,r,l),Fs(t,r,l,n),Us(null,t,r,!0,e,n);case 19:return nc(e,t,n);case 22:return qu(e,t,n)}throw Error(j(156,t.tag))};function yc(e,t){return Qa(e,t)}function Jf(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 Me(e,t,n,r){return new Jf(e,t,n,r)}function Wi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qf(e){if(typeof e=="function")return Wi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ai)return 11;if(e===ui)return 14}return 2}function xt(e,t){var n=e.alternate;return n===null?(n=Me(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 Vr(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")Wi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Ht:return Dt(n.children,l,s,t);case oi:o=8,l|=8;break;case is:return e=Me(12,n,t,l|2),e.elementType=is,e.lanes=s,e;case os:return e=Me(13,n,t,l),e.elementType=os,e.lanes=s,e;case as:return e=Me(19,n,t,l),e.elementType=as,e.lanes=s,e;case Pa:return Nl(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ea:o=10;break e;case _a:o=9;break e;case ai:o=11;break e;case ui:o=14;break e;case it:o=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=Me(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Dt(e,t,n,r){return e=Me(7,e,r,t),e.lanes=n,e}function Nl(e,t,n,r){return e=Me(22,e,r,t),e.elementType=Pa,e.lanes=n,e.stateNode={isHidden:!1},e}function ns(e,t,n){return e=Me(6,e,null,t),e.lanes=n,e}function rs(e,t,n){return t=Me(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bf(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=Il(0),this.expirationTimes=Il(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Il(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Hi(e,t,n,r,l,s,o,a,u){return e=new bf(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Me(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_i(s),e}function ep(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kc)}catch(e){console.error(e)}}kc(),ka.exports=Pe;var sp=ka.exports,Sc,sa=sp;Sc=sa.createRoot,sa.hydrateRoot;const Nc=()=>{var e,t;return(t=(e=window==null?void 0:window.go)==null?void 0:e.main)==null?void 0:t.App},ip=()=>!!Nc();async function F(e,...t){const n=Nc();if(!n||typeof n[e]!="function")throw new Error(`${e} is unavailable — run this inside the Behavision app`);return n[e](...t)}const I={session:()=>F("Session"),login:(e,t)=>F("Login",e,t),logout:()=>F("Logout"),claim:e=>F("Claim",e),runStandalone:()=>F("RunStandalone"),engineStatus:()=>F("EngineStatus"),startEngine:()=>F("StartEngine"),stopEngine:()=>F("StopEngine"),cameras:()=>F("Cameras"),testCamera:e=>F("TestCamera",e),discoverCameras:()=>F("DiscoverCameras"),saveCamera:(e,t)=>F("SaveCamera",e,t),deleteCamera:e=>F("DeleteCamera",e),startPlacement:(e,t)=>F("StartPlacementCheck",e,t),placementResult:e=>F("PlacementResult",e),streamURL:e=>F("StreamURL",e),remoteStreamURL:e=>F("RemoteStreamURL",e),live:()=>F("Live"),pipelineStatus:()=>F("PipelineStatus"),localIdentities:e=>F("LocalIdentities",e),localSightings:e=>F("LocalSightings",e),footfall:(e,t,n)=>F("Footfall",e,t,n),sites:()=>F("Sites"),visitorHistory:(e,t)=>F("VisitorHistory",e,t),visitorPhoto:e=>F("VisitorPhoto",e),forgetCustomer:e=>F("ForgetCustomer",e),sales:(e,t)=>F("Sales",e,t),customers:(e,t)=>F("Customers",e,t),saveProfile:e=>F("SaveProfile",e),ask:e=>F("Ask",e),recordPurchase:(e,t,n,r)=>F("RecordPurchase",e,t,n,r)};function he(e){return e?typeof e=="string"?e:e.message||String(e):"Something went wrong."}function rt(e,t,n=[]){const[r,l]=N.useState(null),[s,o]=N.useState(null),[a,u]=N.useState(!0),c=N.useRef(!0),p=N.useRef(!1),v=N.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(he(h))}finally{p.current=!1,c.current&&u(!1)}}},n);return N.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:s,loading:a,reload:v}}function op(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 ia(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 ls={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 q({size:e,children:t,...n}){return i.jsx("svg",{...ls,...n,width:e??ls.width,height:e??ls.height,children:t})}const ap=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),i.jsx("path",{d:"M5.6 5.6a9 9 0 0 0 0 12.8M18.4 18.4a9 9 0 0 0 0-12.8"})]}),up=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"9",cy:"8.5",r:"3.2"}),i.jsx("path",{d:"M2.8 19.5a6.4 6.4 0 0 1 12.4 0"}),i.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"})]}),cp=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"})]}),Cc=e=>i.jsxs(q,{...e,children:[i.jsx("circle",{cx:"11",cy:"11",r:"6.4"}),i.jsx("path",{d:"M15.8 15.8 20.5 20.5"})]}),oa=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M12 5.5v13M5.5 12h13"})}),Gi=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M6.5 6.5l11 11M17.5 6.5l-11 11"})}),Js=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M5 12.8l4.4 4.2L19 7"})}),qs=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M8 5.6v12.8L18.5 12z"})}),dp=e=>i.jsx(q,{...e,children:i.jsx("rect",{x:"7",y:"7",width:"10",height:"10",rx:"1.6"})}),Ee=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M12 4.6 21 19.4H3z"}),i.jsx("path",{d:"M12 10v4.1"}),i.jsx("path",{d:"M12 17.1v.01"})]}),aa=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M5 19.4v-4.2M10.3 19.4v-7.6M15.7 19.4v-11M21 19.4V4.6"})}),Xi=e=>i.jsx(q,{...e,children:i.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"})}),Ec=e=>i.jsxs(q,{...e,children:[i.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"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),fp=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M12 3.8 19.4 6.6v5.2c0 4.2-3 7.4-7.4 8.4-4.4-1-7.4-4.2-7.4-8.4V6.6z"})}),pp=e=>i.jsxs(q,{...e,children:[i.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"}),i.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"})]}),hp=e=>i.jsxs(q,{...e,children:[i.jsx("path",{d:"M14.4 7.6V5.4H4.6v13.2h9.8v-2.2"}),i.jsx("path",{d:"M10 12h9.4M16.4 8.8 19.8 12l-3.4 3.2"})]}),ua=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M14.6 5.6 8 12l6.6 6.4"})}),mp=e=>i.jsx(q,{...e,children:i.jsx("path",{d:"M9.4 5.6 16 12l-6.6 6.4"})}),_c=e=>i.jsxs(q,{...e,strokeWidth:"1.2",children:[i.jsx("path",{d:"M3 8.5h3.4L8 6h8l1.6 2.5H21v10.2H3z"}),i.jsx("circle",{cx:"12",cy:"13.2",r:"3.1"}),i.jsx("path",{d:"M3.6 3.6l16.8 16.8"})]}),Pc=e=>i.jsxs(q,{...e,strokeWidth:"1.2",children:[i.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),i.jsx("path",{d:"M5.4 20a6.8 6.8 0 0 1 13.2 0"})]}),wt=""+new URL("loyaly-mark-Ch-P3VSF.png",import.meta.url).href;function vp({onDone:e}){const[t,n]=N.useState(""),[r,l]=N.useState(""),[s,o]=N.useState(!1),[a,u]=N.useState(null);async function c(p){p.preventDefault(),o(!0),u(null);try{e(await I.login(t.trim(),r))}catch(v){u(he(v))}finally{o(!1)}}return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.jsx("p",{className:"lead",children:"Sign in to connect this PC to your store."}),i.jsxs("form",{onSubmit:c,children:[a&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),a]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{type:"email",value:t,autoComplete:"username",required:!0,autoFocus:!0,onChange:p=>n(p.target.value)})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:r,autoComplete:"current-password",required:!0,onChange:p=>l(p.target.value)})]}),i.jsx("button",{className:"btn primary",disabled:s||!t||!r,children:s?"Signing in…":"Sign in"})]}),i.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 ca({onDone:e,onCancel:t}){const[n,r]=N.useState(""),[l,s]=N.useState(null),[o,a]=N.useState(null);async function u(h){h.preventDefault(),s("claim"),a(null);try{e(await I.claim(n))}catch(g){a(he(g))}finally{s(null)}}async function c(){s("alone"),a(null);try{e(await I.runStandalone())}catch(h){a(he(h))}finally{s(null)}}const[p,v]=N.useState(t?"code":null);return p===null?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box wide",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Welcome to Behavision"}),i.jsx("p",{className:"lead",children:"This PC will watch your shop’s cameras and recognise returning customers. First, one question: is this shop managed from a head office?"}),i.jsxs("div",{className:"choices",children:[i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("code"),children:[i.jsx(Xi,{size:22}),i.jsx("b",{children:"Yes — I have an installation code"}),i.jsxs("span",{children:["Head office gave you a code like ",i.jsx("em",{children:"ABCDEF-123456-…"}),". This PC joins that shop and gets its cameras from there."]})]}),i.jsxs("button",{type:"button",className:"choice",onClick:()=>v("alone"),children:[i.jsx(fp,{size:22}),i.jsx("b",{children:"No — set up on this PC only"}),i.jsx("span",{children:"Cameras, customers and recognition stay on this PC. Nothing is sent anywhere. You can link to a head office later."})]})]})]})}):p==="alone"?i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"On this PC only"}),i.jsx("p",{className:"lead",children:"Behavision will run entirely here. Next you’ll add your camera — it can find it on the network for you — and walk past it once so it can prove it works."}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsx("button",{type:"button",className:"btn primary",disabled:!!l,onClick:c,children:l==="alone"?"Setting up…":"Continue"}),i.jsx("div",{className:"alt",children:i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ua,{size:14})," Back"]})})]})}):i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:t?"Link to head office":"Join your shop"}),i.jsx("p",{className:"lead",children:"Type the installation code head office gave you. It works once, and this PC becomes that shop."}),i.jsxs("form",{onSubmit:u,children:[o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Installation code"}),i.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)})]}),i.jsx("button",{className:"btn primary",disabled:!!l||n.trim().length<6,children:l==="claim"?"Linking…":"Link this PC"})]}),i.jsxs("p",{className:"foot",children:["Don’t have one? Whoever runs head office creates it under the shop: ",i.jsx("em",{children:"Shops → the shop → Set up a shop PC"}),"."]}),i.jsx("div",{className:"alt",children:t?i.jsx("button",{type:"button",className:"linkbtn",onClick:t,children:"Not now — go back"}):i.jsxs("button",{type:"button",className:"linkbtn",onClick:()=>v(null),children:[i.jsx(ua,{size:14})," Back"]})})]})})}function zc({onNavigate:e}){var h,g,x,y;const{data:t,error:n}=rt(()=>I.live(),3e3),{data:r}=rt(()=>I.pipelineStatus(),5e3),l=((h=t==null?void 0:t.stats)==null?void 0:h.cameras)??[],s=((g=t==null?void 0:t.stats)==null?void 0:g.gallery)??{},o=(t==null?void 0:t.events)??[],a=(t==null?void 0:t.viewing)===!0,u=a?((x=t==null?void 0:t.stats)==null?void 0:x.fraction_below_gate)??0:l.reduce((z,f)=>{var m,w;const d=(w=(m=f==null?void 0:f.pipeline)==null?void 0:m.best_quality)==null?void 0:w.fraction_below_gate;return typeof d=="number"&&d>z?d:z},0),c=a?((y=t==null?void 0:t.stats)==null?void 0:y.cameras_up)??0:l.filter(z=>z.connected).length,p=o.filter(z=>z.type==="person.new"||z.type==="person.seen"),v=jp(p[0]);return i.jsxs("div",{className:"page",children:[i.jsxs("header",{children:[i.jsx("h2",{children:"Live"}),i.jsx("p",{children:a?"Your shops, as head office sees them.":"Who is in the shop, and whether it is reaching head office."})]}),n&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),n]}),a&&i.jsxs("div",{className:"viewing",children:[i.jsx(Xi,{size:15}),i.jsxs("span",{children:[i.jsx("b",{children:"Viewing your shops from here."})," This computer is not watching any cameras itself — everything below is what your shop PCs reported. To recognise people on this machine, it has to be on the same network as a camera."]})]}),i.jsx(wp,{pipe:r,cameras:l,up:c}),!a&&i.jsx(gp,{cameras:l,arrivals:p,onNavigate:e}),i.jsxs("div",{className:"panel arrivals-panel",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Who just walked in"}),p.length>0&&i.jsxs("span",{className:"note",children:[p.length," today"]})]}),i.jsx("div",{className:"panelbody flush",children:p.length===0?i.jsxs("div",{className:"empty",children:[i.jsx(Pc,{size:34}),i.jsx("b",{children:"Nobody yet"}),i.jsx("p",{children:"Customers appear here the moment a camera recognises a face."})]}):i.jsx("div",{className:"arrivals",children:p.slice(0,30).map((z,f)=>i.jsx(yp,{e:z,fresh:f===0&&v},`${z.ts}-${f}`))})})]}),i.jsxs("div",{className:"metrics",style:{marginTop:"var(--sp-4)"},children:[i.jsx(Pr,{k:"People known",v:s.identities??"—"}),i.jsx(Pr,{k:"Sightings",v:s.sightings??"—"}),i.jsx(Pr,{k:"Cameras live",v:l.length?`${c}/${l.length}`:"—",tone:l.length?c===0?"bad":c.5?"bad":u>.2?"warn":"ok",s:u>.5?"Most visitors are being missed — move the camera":"Share of faces below the enrolment gate"})]})]})}function gp({cameras:e,arrivals:t,onNavigate:n}){const{data:r}=rt(()=>I.engineStatus(),4e3),[l,s]=N.useState(()=>{try{return localStorage.getItem("bv.gettingStarted")==="done"}catch{return!1}}),o=e.length>0,a=e.some(x=>x.connected),{data:u}=rt(async()=>{const x={};for(const y of e)try{x[y.camera_id]=await I.placementResult(y.camera_id)}catch{}return x},1e4,[e.map(x=>x.camera_id).join("|")]),c=Object.values(u??{}).some(x=>x&&!x.running&&x.verdict==="good"),p=t.length>0;if(l||p)return null;const v=!!(r!=null&&r.reachable&&(r!=null&&r.recognition_model)),h=r==null?void 0:r.progress,g=[{done:v,now:!v,title:v?`Recognition ready (${r.recognition_model})`:h?`Downloading ${h.what}… ${h.percent}%`:"Starting recognition…",text:v?null:"First start downloads about 275 MB of recognition models. A few minutes on a normal connection; nothing to do meanwhile."},{done:o&&a,now:v&&!(o&&a),title:o?a?"Camera connected":"Camera added — not connecting yet":"Add your camera",text:o?a?null:"Check its password and stream path under Cameras → Edit.":"Behavision can find it on the network; you type only its password.",action:o?null:{label:"Add camera",go:"cameras"}},{done:c,now:o&&a&&!c,title:c?"Camera proven — it can recognise faces":"Walk past the camera",text:c?null:"Run Check placement and walk past like a customer for 25 seconds. Only a “good” verdict means it will recognise people.",action:o&&a&&!c?{label:"Check placement",go:"cameras"}:null}];return i.jsxs("section",{className:"panel starter",children:[i.jsxs("div",{className:"panelhead",children:[i.jsx("h3",{children:"Getting started"}),i.jsx("button",{className:"btn sm ghost",onClick:()=>{try{localStorage.setItem("bv.gettingStarted","done")}catch{}s(!0)},children:"Hide"})]}),i.jsx("ol",{className:"steps compact",children:g.map((x,y)=>i.jsxs("li",{className:x.done?"done":x.now?"now":"",children:[i.jsx("b",{children:x.title}),x.text&&i.jsx("span",{children:x.text}),x.action&&i.jsx("button",{className:"btn sm primary",onClick:()=>n==null?void 0:n(x.action.go),children:x.action.label})]},y))}),i.jsx("p",{className:"note",children:"The moment a customer is recognised, this list goes away."})]})}function yp({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),s=typeof((v=e.data)==null?void 0:v.similarity)=="number"?e.data.similarity:null;return i.jsxs("article",{className:`arrival ${n?"is-new":"is-seen"} ${t?"fresh":""}`,children:[i.jsx("div",{className:"avatar",children:xp(r)}),i.jsxs("div",{className:"who",children:[i.jsx("div",{className:"name",children:r}),i.jsxs("div",{className:"meta",children:[e.camera_id,l.length>0&&i.jsxs(i.Fragment,{children:[" · ",l.join(", ")]}),s!==null&&!n&&i.jsxs(i.Fragment,{children:[" · match ",s.toFixed(2)]})]})]}),i.jsxs("div",{className:"right",children:[i.jsx("span",{className:`tag ${n?"new":"seen"}`,children:n?"new":"returning"}),i.jsx("span",{className:"when",children:op(e.ts)})]})]})}function xp(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 wp({pipe:e,cameras:t,up:n}){if(!e)return null;if(e.standalone)return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[i.jsx("i",{className:"dot ok"}),i.jsx("b",{children:"Running on this PC only"})]}),i.jsx("span",{className:"sep"}),i.jsx("span",{className:"item note",children:"Recognition and customers stay here."}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(aa,{size:14}),n," of ",t.length," cameras"]})]});const r=e.claimed&&!e.broker_up,l=e.claimed?e.broker_up?"ok":"bad":"idle",s=e.claimed?e.broker_up?"Sending to head office":"Offline — saving locally":"Not linked to head office";return i.jsxs("div",{className:"statusbar",children:[i.jsxs("span",{className:"item",children:[e.broker_up?i.jsx(Xi,{size:15}):i.jsx(Ec,{size:15}),i.jsx("i",{className:`dot ${l}`}),i.jsx("b",{children:s})]}),i.jsx("span",{className:"sep"}),i.jsxs("span",{className:"item note",children:[e.accepted," recorded today"]}),e.queued>0&&i.jsxs("span",{className:`item note ${r?"warn":""}`,children:[e.queued," waiting to send"]}),e.dropped>0&&i.jsxs("span",{className:"item note bad",children:[i.jsx(Ee,{size:14}),e.dropped," lost — this PC was offline too long"]}),i.jsx("span",{className:"grow"}),i.jsxs("span",{className:"item note",children:[i.jsx(aa,{size:14}),n," of ",t.length," cameras"]})]})}function Pr({k:e,v:t,s:n,tone:r}){return i.jsxs("div",{className:`metric ${r??""}`,children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}function jp(e){const[t,n]=N.useState(!1),r=N.useRef(null);return N.useEffect(()=>{if(!e||e.ts===r.current)return;const l=r.current===null;if(r.current=e.ts,l)return;n(!0);const s=setTimeout(()=>n(!1),1200);return()=>clearTimeout(s)},[e==null?void 0:e.ts]),t}function kp(e){const[t,n]=N.useState(null);return N.useEffect(()=>{let r=!0;return n(null),I.visitorPhoto(e).then(l=>{r&&n(l)}).catch(()=>{r&&n({available:!1,reason:""})}),()=>{r=!1}},[e]),t}function Sp({photo:e,name:t,customerRef:n,onBroken:r}){return e!=null&&e.available?i.jsx("img",{className:"avatar",src:e.url,alt:`Photo of ${t}`,onError:r}):i.jsx("div",{className:"avatar none",role:"img","aria-label":`No photo of ${t}`,children:i.jsx("span",{children:Np(t,n)})})}function Np(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 Cp({customer:e}){const{data:t,error:n,loading:r}=rt(()=>I.visitorHistory(e.id,50),0,[e.id]);if(r)return i.jsx("p",{className:"note",children:"Loading visits…"});if(n)return i.jsxs("p",{className:"note",children:["Could not load visits: ",n]});const l=t??[];return l.length===0?i.jsx("p",{className:"note",children:"No recorded visits yet."}):i.jsx("ul",{className:"timeline",children:l.map(s=>i.jsxs("li",{children:[i.jsx("span",{className:"when",children:Ep(s.occurred_at)}),i.jsxs("span",{className:"where",children:[s.site||"this store",s.camera_id?i.jsxs("span",{className:"note",children:[" · ",s.camera_id]}):null]}),s.is_new_visitor&&i.jsx("span",{className:"tag new",children:"first visit"})]},s.id))})}function Ep(e){const t=new Date(e);return isNaN(t)?"—":t.toLocaleString([],{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function _p({customer:e,onCancel:t,onDone:n}){const r=e.full_name||e.label,[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=l.trim().toLowerCase()===r.trim().toLowerCase();async function v(){a(!0),c(null);try{await I.forgetCustomer(e.id),n()}catch(h){c(he(h)),a(!1)}}return i.jsxs("div",{className:"confirm",children:[i.jsxs("h4",{children:["Erase ",r,"?"]}),i.jsxs("div",{className:"cols",children:[i.jsxs("div",{children:[i.jsx("p",{className:"lbl bad",children:"Deleted for good"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Their face data — they will not be recognised again"}),i.jsx("li",{children:"Their photo"}),i.jsx("li",{children:"Their name, phone, email and notes"})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"lbl",children:"Kept"}),i.jsxs("ul",{children:[i.jsx("li",{children:"Past visits, with their name removed — your footfall figures do not change"}),i.jsx("li",{children:"The consent record, marked withdrawn, as proof of what was agreed"})]})]})]}),i.jsx("p",{className:"note",children:"This cannot be undone. If they come back they will be recorded as a new customer."}),u&&i.jsx("div",{className:"err",children:u}),i.jsxs("label",{className:"field",children:[i.jsxs("span",{children:["Type ",i.jsx("b",{children:r})," to confirm"]}),i.jsx("input",{value:l,onChange:h=>s(h.target.value),autoFocus:!0,autoComplete:"off",spellCheck:"false","aria-label":`Type ${r} to confirm erasure`})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{type:"button",className:"btn danger",disabled:!p||o,onClick:v,children:o?"Erasing…":"Erase permanently"}),i.jsx("button",{type:"button",className:"btn",onClick:t,disabled:o,children:"Cancel"})]})]})}function Pp({customer:e,session:t,onClose:n,onSaved:r}){var P;const[l,s]=N.useState({full_name:e.full_name??"",phone:e.phone??"",email:e.email??"",gender:"",date_of_birth:"",notes:"",consent:e.has_consent??!1}),[o,a]=N.useState({amount:"",items:"",notes:""}),[u,c]=N.useState(!1),[p,v]=N.useState(null),[h,g]=N.useState(!1),[x,y]=N.useState(null),z=kp(e.id),f=x??z,d=(P=t==null?void 0:t.user)==null?void 0:P.role,m=["admin","owner","manager"].includes(d),w=k=>E=>s({...l,[k]:E.target.value});async function S(k){k.preventDefault(),c(!0),v(null);try{await I.saveProfile({visitor_id:e.id,...l});const E=parseFloat(o.amount);if(!isNaN(E)&&E>0){const U=o.items.split(",").map(M=>M.trim()).filter(Boolean);await I.recordPurchase(e.id,E,U,o.notes)}r()}catch(E){v(he(E))}finally{c(!1)}}return i.jsx("div",{className:"drawer",onMouseDown:k=>k.target===k.currentTarget&&n(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead who",children:[i.jsx(Sp,{photo:f,name:e.full_name||e.label,customerRef:e.ref,onBroken:()=>y({available:!1,reason:"The photo could not be loaded."})}),i.jsxs("div",{className:"grow",children:[i.jsx("h2",{children:e.full_name||e.label}),i.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}`]})]}),i.jsx("button",{type:"button",className:"close",onClick:n,"aria-label":"Close",children:"✕"})]}),i.jsxs("form",{className:"sheetbody",onSubmit:S,children:[p&&i.jsx("div",{className:"err",children:p}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Customer details"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Full name"}),i.jsx("input",{value:l.full_name,onChange:w("full_name"),autoFocus:!0})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Phone"}),i.jsx("input",{value:l.phone,onChange:w("phone"),inputMode:"tel"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Email"}),i.jsx("input",{value:l.email,onChange:w("email"),type:"email"})]})]}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Gender"}),i.jsxs("select",{value:l.gender,onChange:w("gender"),children:[i.jsx("option",{value:"",children:"Not recorded"}),i.jsx("option",{children:"Female"}),i.jsx("option",{children:"Male"}),i.jsx("option",{children:"Other"})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Date of birth"}),i.jsx("input",{type:"date",value:l.date_of_birth,onChange:w("date_of_birth")})]})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Notes"}),i.jsx("textarea",{value:l.notes,onChange:w("notes"),placeholder:"Preferences, sizes, anything worth remembering"})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Purchase (optional)"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Amount"}),i.jsx("input",{value:o.amount,inputMode:"decimal",placeholder:"0.00",onChange:k=>a({...o,amount:k.target.value})})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Items"}),i.jsx("input",{value:o.items,placeholder:"shirt, belt",onChange:k=>a({...o,items:k.target.value})})]})]}),i.jsx("p",{className:"note",children:"Leave the amount blank if they did not buy anything — a visit without a sale is still worth recording."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Consent"}),i.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",fontSize:13,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:l.consent,style:{marginTop:3},onChange:k=>s({...l,consent:k.target.checked})}),i.jsx("span",{children:"This customer agreed to us keeping their details and recognising them on future visits."})]}),i.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."})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Visits"}),i.jsx(Cp,{customer:e})]}),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:n,children:"Cancel"}),i.jsx("button",{className:"btn primary",disabled:u,children:u?"Saving…":"Save"})]}),m&&i.jsxs("section",{className:"formsection dangerzone",children:[i.jsx("h4",{children:"At the customer's request"}),h?i.jsx(_p,{customer:e,onCancel:()=>g(!1),onDone:r}):i.jsxs(i.Fragment,{children:[i.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."}),i.jsx("button",{type:"button",className:"btn danger",onClick:()=>g(!0),children:"Erase this customer…"})]})]})]})]})})}function zp({session:e}){const[t,n]=N.useState(""),[r,l]=N.useState(null),{data:s,error:o,reload:a}=rt(()=>I.customers(t,200),3e4,[t]),u=s??[],c=u.filter(p=>p.has_profile).length;return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Customers"}),i.jsx("p",{children:"Everyone this business has recognised. Fill in details once and they are known at every store."})]}),i.jsxs("label",{className:"search",children:[i.jsx(Cc,{size:15}),i.jsx("input",{placeholder:"Search by name or phone",value:t,onChange:p=>n(p.target.value)})]})]}),o&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),o]}),i.jsxs("div",{className:"metrics",style:{marginBottom:"var(--sp-4)"},children:[i.jsx(zr,{k:"Known people",v:u.length||"—"}),i.jsx(zr,{k:"With details",v:c||"—",s:u.length?`${Math.round(100*c/u.length)}% captured`:null}),i.jsx(zr,{k:"Returning",v:u.filter(p=>p.visit_count>1).length||"—"}),i.jsx(zr,{k:"With consent",v:u.filter(p=>p.has_consent).length||"—"})]}),i.jsx("div",{className:"panel",children:u.length===0?i.jsxs("div",{className:"empty tall",children:[i.jsx(Pc,{size:34}),i.jsx("b",{children:"No customers yet"}),i.jsx("p",{children:"They appear here the first time a camera recognises them. Click one to add a name and phone number."})]}):i.jsx("div",{className:"tablewrap",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Customer"}),i.jsx("th",{children:"Phone"}),i.jsx("th",{className:"num",children:"Visits"}),i.jsx("th",{children:"First seen"}),i.jsx("th",{children:"Last seen"}),i.jsx("th",{children:"Details"})]})}),i.jsx("tbody",{children:u.map(p=>i.jsxs("tr",{className:"click",onClick:()=>l(p),children:[i.jsxs("td",{children:[p.full_name||i.jsx("span",{className:"note",children:p.label}),p.full_name&&p.ref&&i.jsxs("span",{className:"note",children:[" · ",p.ref]})]}),i.jsx("td",{className:"mono",children:p.phone||"—"}),i.jsx("td",{className:"num",children:p.visit_count}),i.jsx("td",{children:ia(p.first_seen_at)}),i.jsx("td",{children:ia(p.last_seen_at)}),i.jsx("td",{children:p.has_profile?i.jsxs("span",{className:"pill ok",children:[i.jsx("i",{className:"dot ok"}),"captured"]}):i.jsxs("span",{className:"pill warn",children:[i.jsx("i",{className:"dot warn"}),"needed"]})})]},p.id))})]})})}),r&&i.jsx(Pp,{customer:r,session:e,onClose:()=>l(null),onSaved:()=>{l(null),a()}})]})}function zr({k:e,v:t,s:n}){return i.jsxs("div",{className:"metric",children:[i.jsx("div",{className:"metric-k",children:e}),i.jsx("div",{className:"metric-v",children:t}),n&&i.jsx("div",{className:"metric-s",children:n})]})}const an=[{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:""}],Lr=e=>an.find(t=>t.id===e)||an[an.length-1],bs={id:"",host:"",port:554,path:"",username:"",password:"",max_width:1280},_n="webcam";function Lp(){const{data:e,error:t,reload:n}=rt(()=>I.cameras(),8e3),[r,l]=N.useState(null),[s,o]=N.useState(null),a=e??[],u=a.some(y=>y.remote),c=Mp(u?[]:a),[p,v]=N.useState(null),[h,g]=N.useState("");N.useEffect(()=>{let y=!0;if(!p){g("");return}return I.remoteStreamURL(p).then(z=>{y&&g(z||"")}).catch(()=>{y&&g("")}),()=>{y=!1}},[p]);async function x(y){if(confirm(`Remove ${y.id}? Recognition from it stops immediately.`))try{await I.deleteCamera(y.id),n()}catch(z){alert(he(z))}}return i.jsxs("div",{className:"page",children:[i.jsxs("header",{className:"pagehead",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Cameras"}),i.jsx("p",{children:u?"The cameras across your shops, as the shop computers last reported them.":"Add a camera, then prove it can see faces with a walk-past. Only then is it working."})]}),!u&&i.jsxs("button",{className:"btn primary",onClick:()=>l({...bs}),children:[i.jsx(oa,{size:15}),"Add camera"]})]}),u&&i.jsxs("div",{className:"viewing",children:[i.jsx("b",{children:"Viewing your shops from here."})," These cameras are wired to the shop computers, so they are set up and checked there. Each tile shows that camera's most recent frame; ",i.jsx("b",{children:"Watch live"})," asks the shop computer to send video for as long as you are looking."]}),t&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),t]}),a.length===0?i.jsx("div",{className:"panel",children:i.jsxs("div",{className:"empty tall",children:[i.jsx(_c,{size:40}),i.jsx("b",{children:"No cameras yet"}),i.jsx("p",{children:"Add the camera by its address. Most cameras print it on a label underneath, or show it in their own app."}),i.jsxs("button",{className:"btn primary",onClick:()=>l({...bs}),children:[i.jsx(oa,{size:15}),"Add your first camera"]})]})}):i.jsx("div",{className:"camgrid",children:a.map(y=>i.jsx(Tp,{cam:y,stream:p===y.id?h:c[y.id],watching:p===y.id,onWatch:()=>v(p===y.id?null:y.id),onEdit:()=>l(y),onCheck:()=>o(y.id),onRemove:()=>x(y)},y.id))}),r&&i.jsx(Rp,{cam:r,onClose:()=>l(null),onSaved:()=>{l(null),n()}}),s&&i.jsx(Dp,{id:s,onClose:()=>o(null)})]})}function Tp({cam:e,stream:t,watching:n,onWatch:r,onEdit:l,onCheck:s,onRemove:o}){var v,h,g;const a=e.remote?{connected:{tone:"ok",label:"Connected"},not_connecting:{tone:"bad",label:"Not connecting"},stale:{tone:"warn",label:"Not reporting"}}[e.state]||{tone:"idle",label:"Waiting for the shop computer"}:e.connected===void 0||e.connected===null?{tone:"idle",label:"Engine stopped"}:e.connected?{tone:"ok",label:"Connected"}:{tone:"bad",label:"Not connecting"},{data:u}=rt(()=>e.remote?Promise.resolve(null):I.placementResult(e.id),15e3,[e.id]),c=!u||u.running||!u.verdict||u.verdict==="starting"?{tone:"miss",label:"Not yet proven",text:"Walk past it once and Behavision will tell you if the placement works."}:u.verdict==="good"?{tone:"seen",label:"Proven",text:u.headline||"Faces recognised on a walk-past."}:{tone:"miss",label:"Not proven",text:u.headline||"Move the camera and check again."},p=(v=e.snapshot)!=null&&v.available?e.snapshot.url:"";return i.jsxs("article",{className:"camcard",children:[i.jsxs("div",{className:"camview",children:[t||p?i.jsx("img",{src:t||p,alt:e.id}):i.jsx("div",{className:"placeholder",children:i.jsx(_c,{size:34})}),i.jsxs("span",{className:`pill ${a.tone==="idle"?"":a.tone} over`,children:[i.jsx("i",{className:`dot ${a.tone}`}),a.label]}),e.remote&&i.jsxs("button",{className:`btn sm watch ${n?"on":""}`,onClick:r,children:[i.jsx(qs,{size:13}),n?"Stop watching":"Watch live"]})]}),i.jsxs("div",{className:"cambody",children:[i.jsxs("div",{className:"camtitle",children:[i.jsxs("div",{children:[i.jsx("h3",{children:e.label||e.camera_id||e.id}),i.jsx("span",{className:"mono note",children:e.remote?e.site||e.site_slug||"":`${e.host||e.url}${e.path?` · ${e.path}`:""}`})]}),!e.remote&&i.jsxs("div",{className:"camactions",children:[i.jsx("button",{className:"btn sm",onClick:l,children:"Edit"}),i.jsx("button",{className:"btn sm danger",onClick:o,children:"Remove"})]})]}),e.remote?i.jsx("div",{className:"camproof",children:i.jsx("span",{className:"note",children:e.state_note?e.state_note:n?"Live from the shop computer. It uploads only while you watch.":(h=e.snapshot)!=null&&h.available?"Last picture from the shop computer. Watch live to see it now.":((g=e.snapshot)==null?void 0:g.reason)||"No picture yet from the shop computer."})}):i.jsxs("div",{className:"camproof",children:[i.jsx("span",{className:`tag ${c.tone}`,children:c.label}),i.jsx("span",{className:"note",children:c.text}),i.jsxs("button",{className:`btn sm ${c.tone==="seen"?"":"primary"}`,onClick:s,children:[i.jsx(qs,{size:13}),c.tone==="seen"?"Check again":"Check placement"]})]})]})]})}function Mp(e){const[t,n]=N.useState({});return N.useEffect(()=>{let r=!0;const l=e.filter(s=>!(s.id in t));if(l.length)return(async()=>{const s={};for(const o of l)try{s[o.id]=await I.streamURL(o.id)}catch{s[o.id]=""}r&&n(o=>({...o,...s}))})(),()=>{r=!1}},[e.map(r=>r.id).join("|")]),t}function Rp({cam:e,onClose:t,onSaved:n}){var ge;const r=!e.id,[l,s]=N.useState({...bs,...e,password:"",path:e.path||(r?an[0].path:"")}),[o,a]=N.useState(r?an[0].id:e.webcam!=null?_n:"manual"),[u,c]=N.useState(e.webcam!=null?String(e.webcam):"0"),p=o===_n,[v,h]=N.useState(null),[g,x]=N.useState(null),[y,z]=N.useState(null),f=L=>B=>s({...l,[L]:B.target.value});function d(L){if(L.target.value===_n){a(_n),h(null);return}const B=Lr(L.target.value);a(B.id),s(de=>({...de,path:B.path||de.path}))}function m(){const L={};for(const[B,de]of Object.entries(l))de===""||de===null||de===void 0||(L[B]=B==="port"||B==="max_width"?Number(de):de);if(p){for(const B of["host","path","username","password"])delete L[B];L.webcam=Number(u)||0}return L}async function w(){x("test"),z(null),h(null);try{h(await I.testCamera(m()))}catch(L){z(he(L))}finally{x(null)}}async function S(L){L.preventDefault(),x("save"),z(null);try{await I.saveCamera(r?"":e.id,m()),n()}catch(B){z(he(B))}finally{x(null)}}const P=Lr(o),[k,E]=N.useState(null);async function U(){E("busy");try{E(await I.discoverCameras())}catch(L){E({error:he(L)})}}function M(L){const B=L.make?Lr(L.make):null;s(de=>({...de,host:L.host,path:(B==null?void 0:B.path)||de.path,id:de.id||""})),B&&a(B.id),h(null)}return i.jsx("div",{className:"drawer",onMouseDown:L=>L.target===L.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsx("h2",{children:r?"Add a camera":`Edit ${e.id}`}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("form",{className:"sheetbody",onSubmit:S,autoComplete:"off",children:[i.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."}),y&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),y]}),r&&!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Find it"}),k===null&&i.jsxs("div",{className:"finder",children:[i.jsx("p",{children:"Behavision can look for cameras on this shop’s network."}),i.jsxs("button",{type:"button",className:"btn primary",onClick:U,children:[i.jsx(Cc,{size:14}),"Find cameras on this network"]})]}),k==="busy"&&i.jsxs("div",{className:"finder busy",children:[i.jsx("span",{className:"spinner"}),"Looking on the network… a few seconds."]}),(k==null?void 0:k.error)&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),k.error]}),(k==null?void 0:k.cameras)&&(k.cameras.length===0?i.jsxs("div",{className:"finder",children:[i.jsxs("p",{children:["Nothing answered on ",((ge=k.networks)==null?void 0:ge.join(", "))||"this network",". The camera may be on a different network, switched off, or not yet connected — check its cable and power, then try again. You can still type its address below."]}),i.jsx("button",{type:"button",className:"btn",onClick:U,children:"Try again"})]}):i.jsxs("ul",{className:"foundlist",children:[k.cameras.map(L=>i.jsx("li",{className:l.host===L.host?"picked":"",children:i.jsxs("button",{type:"button",onClick:()=>M(L),children:[i.jsx("span",{className:"mono",children:L.host}),i.jsx("span",{className:"what",children:L.name||(L.rtsp?"Streams video (RTSP)":"Answers ONVIF")}),L.make&&i.jsx("span",{className:"tag seen",children:Lr(L.make).label}),l.host===L.host&&i.jsx(Js,{size:16})]})},L.host)),i.jsx("li",{className:"rescan",children:i.jsx("button",{type:"button",className:"btn sm",onClick:U,children:"Scan again"})})]}))]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The camera"}),r&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Name"}),i.jsx("input",{value:l.id,onChange:f("id"),placeholder:"entrance",required:!0,autoFocus:!0}),i.jsx("em",{className:"hint",children:"Short, no spaces. It names this camera everywhere and cannot be changed later."})]}),p?i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Camera number"}),i.jsx("input",{value:u,onChange:L=>{c(L.target.value),h(null)},inputMode:"numeric"}),i.jsx("em",{className:"hint",children:"0 is the built-in camera. Try 1 if a second one is plugged in."})]}):i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Address"}),i.jsx("input",{value:l.host,onChange:f("host"),placeholder:"192.168.1.20",inputMode:"decimal"}),i.jsx("em",{className:"hint",children:"On a label on the camera, or in its own app under “network”."})]}),i.jsxs("label",{className:"field narrow",children:[i.jsx("span",{children:"Port"}),i.jsx("input",{value:l.port,onChange:f("port"),inputMode:"numeric"})]})]})]}),i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"The stream"}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Make of camera"}),i.jsxs("select",{value:o,onChange:d,children:[an.map(L=>i.jsx("option",{value:L.id,children:L.label},L.id)),i.jsx("option",{value:_n,children:"This computer’s own camera"})]}),p?i.jsx("em",{className:"hint",children:"Recognition runs on this computer’s built-in or plugged-in camera. Nothing on the network is involved."}):P.note&&i.jsx("em",{className:"hint",children:P.note})]}),!p&&i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Stream path"}),i.jsx("input",{className:"mono",value:l.path,onChange:f("path"),placeholder:"/Streaming/Channels/101"}),i.jsx("em",{className:"hint",children:"Filled in from the make. Change it only if the camera’s own app says something else."})]})]}),!p&&i.jsxs("section",{className:"formsection",children:[i.jsx("h4",{children:"Sign-in to the camera"}),i.jsxs("div",{className:"fieldrow",children:[i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Username"}),i.jsx("input",{name:"rtsp-account",autoComplete:"off",value:l.username,onChange:f("username"),placeholder:"admin"})]}),i.jsxs("label",{className:"field",children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",name:"rtsp-secret",autoComplete:"new-password",value:l.password,onChange:f("password"),placeholder:e.has_password?"(unchanged)":""})]})]})]}),v&&(v.ok?i.jsxs("div",{className:"testresult ok",children:[i.jsx(Js,{size:16}),i.jsxs("div",{children:[i.jsxs("b",{children:["Connected — ",v.width,"×",v.height,v.codec?` · ${String(v.codec).toUpperCase()}`:""]}),v.snapshot&&i.jsx("img",{alt:"Camera preview",src:`data:image/jpeg;base64,${v.snapshot}`})]})]}):i.jsxs("div",{className:"testresult bad",children:[i.jsx(Ee,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"Could not connect"}),i.jsx("span",{children:v.error})]})]})),i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{type:"button",className:"btn",onClick:w,disabled:!!g||!l.host,children:g==="test"?"Connecting…":"Test connection"}),i.jsx("button",{className:"btn primary",disabled:!!g||!l.id||!l.host,children:g==="save"?"Saving…":r?"Add camera":"Save changes"})]})]})]})})}function Dp({id:e,onClose:t}){var p,v;const[n,r]=N.useState({verdict:"starting",advice:[]}),[l,s]=N.useState(null),o=N.useRef(null);N.useEffect(()=>{let h=!0;return(async()=>{try{r(await I.startPlacement(e,25)),o.current=setInterval(async()=>{try{const g=await I.placementResult(e);if(!h)return;r(g),g.running||clearInterval(o.current)}catch(g){h&&s(he(g))}},1e3)}catch(g){h&&s(he(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 i.jsx("div",{className:"drawer",onMouseDown:h=>h.target===h.currentTarget&&t(),children:i.jsxs("div",{className:"sheet",children:[i.jsxs("div",{className:"sheethead",children:[i.jsxs("h2",{children:["Check placement · ",e]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("div",{className:"sheetbody",children:[l&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),l]}),i.jsxs("ol",{className:"steps",children:[i.jsxs("li",{className:c?"now":"done",children:[i.jsx("b",{children:"Walk past the camera"}),i.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&&i.jsx("div",{className:"progress",children:i.jsx("div",{style:{width:`${u}%`}})})]}),i.jsxs("li",{className:c?"":"now",children:[i.jsx("b",{children:"Behavision judges what it saw"}),i.jsx("span",{children:"Not “were the frames sharp”, but “did a person walking past produce a face worth recognising”."})]})]}),i.jsxs("div",{className:`verdict ${a??""}`,children:[i.jsxs("div",{className:"verdict-head",children:[c?i.jsx("span",{className:"spinner"}):a==="ok"?i.jsx(Js,{size:18}):i.jsx(Ee,{size:18}),i.jsx("b",{children:n.headline||"Watching…"})]}),((p=n.advice)==null?void 0:p.length)>0&&i.jsx("ul",{children:n.advice.map((h,g)=>i.jsx("li",{children:h},g))}),((v=n.quality)==null?void 0:v.n)>0&&i.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&&i.jsxs("div",{className:"sheetactions",children:[i.jsx("button",{className:"btn",onClick:t,children:"Close"}),i.jsx("button",{className:"btn primary",onClick:()=>{r({verdict:"starting",advice:[]}),I.startPlacement(e,25).then(r).catch(h=>s(he(h)))},children:"Run again"})]})]})]})})}const Op=["Is my shop working right now?","How do I add my camera?","Why has nobody been recognised today?","Who came in this morning?"];function Fp({session:e,onClose:t}){const[n,r]=N.useState([]),[l,s]=N.useState(""),[o,a]=N.useState(!1),[u,c]=N.useState(null),p=N.useRef(null),v=e==null?void 0:e.standalone;N.useEffect(()=>{var g;(g=p.current)==null||g.scrollTo({top:1e9,behavior:"smooth"})},[n,o]);async function h(g){const x=(g??l).trim();if(!x||o)return;const y=[...n,{role:"user",text:x}];r(y),s(""),a(!0),c(null);try{const z=await I.ask(y.map(f=>({role:f.role,text:f.text})));r([...y,{role:"assistant",text:z.text,used:z.used??[]}])}catch(z){const f=he(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),s(x)}finally{a(!1)}}return i.jsxs("aside",{className:"helper",role:"dialog","aria-label":"Loya",children:[i.jsxs("header",{className:"helperhead",children:[i.jsx("img",{src:wt,alt:""}),i.jsxs("div",{children:[i.jsx("b",{children:"Loya"}),i.jsx("span",{children:"Your Behavision buddy — knows your cameras, your customers and your numbers."})]}),i.jsx("button",{className:"close",onClick:t,"aria-label":"Close",children:i.jsx(Gi,{size:16})})]}),i.jsxs("div",{className:"helperbody",ref:p,children:[v&&i.jsxs("div",{className:"helpernote",children:[i.jsx(Ec,{size:16}),i.jsxs("div",{children:[i.jsx("b",{children:"This PC runs on its own"}),i.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&&i.jsxs("div",{className:"helperintro",children:[i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble",children:[Ip(e)," Ask me anything about ",(e==null?void 0:e.site_name)||"this shop"," — what’s happening now, or how to set something up."]})}),i.jsx("div",{className:"chips",children:Op.map(g=>i.jsx("button",{className:"chip",onClick:()=>h(g),disabled:o||v,children:g},g))}),v&&i.jsx($p,{})]}),n.map((g,x)=>{var y;return i.jsxs("div",{className:`turn ${g.role}`,children:[i.jsx("div",{className:"bubble",children:g.text}),((y=g.used)==null?void 0:y.length)>0&&i.jsxs("span",{className:"used",children:["Looked at: ",g.used.join(", ")]})]},x)}),o&&i.jsx("div",{className:"turn assistant",children:i.jsxs("div",{className:"bubble thinking",children:[i.jsx("span",{}),i.jsx("span",{}),i.jsx("span",{})]})}),u&&i.jsxs("div",{className:"err",children:[i.jsx(Ee,{size:15}),u]})]}),i.jsxs("form",{className:"helperask",onSubmit:g=>{g.preventDefault(),h()},children:[i.jsx("input",{value:l,onChange:g=>s(g.target.value),disabled:o||v,placeholder:v?"Link this PC to head office to talk to Loya":"Ask Loya…"}),i.jsx("button",{className:"btn primary",disabled:o||v||!l.trim(),"aria-label":"Ask",children:i.jsx(mp,{size:16})})]})]})}function Ip(e){var l,s;const t=new Date().getHours(),n=t<12?"Morning":t<17?"Afternoon":"Evening",r=(s=(l=e==null?void 0:e.user)==null?void 0:l.full_name)==null?void 0:s.split(" ")[0];return r?`${n}, ${r}.`:`${n}.`}function $p(){return i.jsxs("dl",{className:"quickhelp",children:[i.jsx("dt",{children:"Adding a camera"}),i.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."}),i.jsx("dt",{children:"Proving it works"}),i.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."}),i.jsx("dt",{children:"Nothing showing on Live"}),i.jsx("dd",{children:"Check the camera is Connected and Proven. A camera aimed from above or the side streams fine and recognises nobody."}),i.jsx("dt",{children:"Linking to head office later"}),i.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 Up=[{id:"live",label:"Live",Glyph:ap,View:zc},{id:"customers",label:"Customers",Glyph:up,View:zp,cloud:!0},{id:"cameras",label:"Cameras",Glyph:cp,View:Lp}];function Ap(){var h,g,x;const[e,t]=N.useState(null),[n,r]=N.useState("live"),[l,s]=N.useState(!0),[o,a]=N.useState(!1),[u,c]=N.useState(!1);if(N.useEffect(()=>{let y=!0;const z=async()=>{try{const d=await I.session();y&&t(m=>JSON.stringify(m)===JSON.stringify(d)?m:d)}catch{y&&t(null)}y&&s(!1)};z();const f=setInterval(z,8e3);return()=>{y=!1,clearInterval(f)}},[]),!ip())return i.jsx("div",{className:"login",children:i.jsxs("div",{className:"box",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsx("h1",{children:"Behavision"}),i.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 i.jsx("div",{className:"login",children:i.jsx("p",{className:"note",children:"Starting…"})});if(!(e!=null&&e.claimed)&&!(e!=null&&e.standalone))return i.jsx(ca,{onDone:t});if(!(e!=null&&e.standalone)&&!(e!=null&&e.logged_in))return i.jsx(vp,{onDone:t});const p=Up.filter(y=>!y.cloud||!e.standalone),v=((h=p.find(y=>y.id===n))==null?void 0:h.View)??zc;return o?i.jsx(ca,{onDone:y=>{a(!1),t(y)},onCancel:()=>a(!1)}):i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"side",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"mark",children:i.jsx("img",{src:wt,alt:""})}),i.jsxs("div",{className:"id",children:[i.jsx("h1",{children:"Behavision"}),i.jsx("p",{children:e.site_name||((g=e.user)==null?void 0:g.client_name)||"This shop"})]})]}),i.jsx("nav",{className:"nav",children:p.map(({id:y,label:z,Glyph:f})=>i.jsxs("button",{onClick:()=>r(y),"aria-current":y===n?"page":void 0,children:[i.jsx(f,{size:17}),z]},y))}),i.jsx(Bp,{}),i.jsx("div",{className:"who",children:e.standalone?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"On its own"}),i.jsx("span",{children:"No head office"})]}),i.jsx("button",{className:"btn sm icon",title:"Link to head office",onClick:()=>a(!0),children:i.jsx(pp,{size:15})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"id",children:[i.jsx("b",{children:"Signed in"}),i.jsx("span",{children:(x=e.user)==null?void 0:x.email})]}),i.jsx("button",{className:"btn sm icon",title:"Sign out",onClick:async()=>t(await I.logout()),children:i.jsx(hp,{size:15})})]})})]}),i.jsxs("main",{className:"main",children:[i.jsx(v,{session:e,onNavigate:r}),!u&&i.jsxs("button",{className:"loya-fab",onClick:()=>c(!0),"aria-label":"Ask Loya",title:"Ask Loya",children:[i.jsx("img",{src:wt,alt:""}),i.jsx("span",{children:"Loya"})]})]}),u&&i.jsx(Fp,{session:e,onClose:()=>c(!1)})]})}function Bp(){const{data:e,reload:t}=rt(()=>I.engineStatus(),5e3),[n,r]=N.useState(!1),l=e??{state:"stopped"},s=N.useCallback(async v=>{r(!0);try{await v()}catch(h){alert(he(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&&l.progress?(c="warn",p=`Downloading ${l.progress.what}… ${l.progress.percent}%`):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&&us(I.startEngine),children:[i.jsx(qs,{size:13}),"Start"]}),i.jsxs("button",{className:"btn sm",disabled:n||!o,onClick:()=>s(I.stopEngine),children:[i.jsx(dp,{size:13}),"Stop"]})]})]})}Sc(document.getElementById("root")).render(i.jsx(Yc.StrictMode,{children:i.jsx(Ap,{})})); diff --git a/desktop/frontend/dist/index.html b/desktop/frontend/dist/index.html index d9313f2..8322aa2 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/Cameras.jsx b/desktop/frontend/src/views/Cameras.jsx index f74482f..a786a15 100644 --- a/desktop/frontend/src/views/Cameras.jsx +++ b/desktop/frontend/src/views/Cameras.jsx @@ -14,6 +14,18 @@ import { MAKES, makeById } from '../../../../shared/cameraMakes.js' // signed off through. const BLANK = { id: '', host: '', port: 554, path: '', username: '', password: '', max_width: 1280 } +// "This computer's own camera" - a webcam or a built-in FaceTime camera. +// +// The engine has supported it since the first version (`webcam: 0` picks a +// capture index instead of building an RTSP URL) and no screen has ever +// offered it: another case of the API being able to do something the UI +// could not reach. It matters most for the thing it was missing from, which +// is showing the product to somebody. A laptop's own camera gives real +// recognition, of real faces, in the room, depending on no network at all - +// where pointing a demo machine at a camera in another building depends on +// two internet connections and a tunnel staying up while you talk. +const WEBCAM = 'webcam' + export default function Cameras() { const { data, error, reload } = usePolled(() => api.cameras(), 8000) const [editing, setEditing] = useState(null) @@ -190,7 +202,9 @@ function useStreamURLs(cams) { function CameraSheet({ cam, onClose, onSaved }) { const isNew = !cam.id const [f, setF] = useState({ ...BLANK, ...cam, password: '', path: cam.path || (isNew ? MAKES[0].path : '') }) - const [make, setMake] = useState(isNew ? MAKES[0].id : 'manual') + const [make, setMake] = useState(isNew ? MAKES[0].id : (cam.webcam != null ? WEBCAM : 'manual')) + const [index, setIndex] = useState(cam.webcam != null ? String(cam.webcam) : '0') + const local = make === WEBCAM const [test, setTest] = useState(null) const [busy, setBusy] = useState(null) const [error, setError] = useState(null) @@ -199,6 +213,7 @@ function CameraSheet({ cam, onClose, onSaved }) { // Only overwrite the path when the preset has one, so choosing "I know the // path" does not wipe what the installer already typed. function chooseMake(e) { + if (e.target.value === WEBCAM) { setMake(WEBCAM); setTest(null); return } const m = makeById(e.target.value) setMake(m.id) setF(prev => ({ ...prev, path: m.path || prev.path })) @@ -212,6 +227,14 @@ function CameraSheet({ cam, onClose, onSaved }) { if (v === '' || v === null || v === undefined) continue out[k] = (k === 'port' || k === 'max_width') ? Number(v) : v } + if (local) { + // An address and a webcam index are alternatives, not extras: the + // engine's source() takes the webcam first, so leaving a half-typed + // host behind would make the saved camera describe two different + // things and only one of them would be used. + for (const k of ['host', 'path', 'username', 'password']) delete out[k] + out.webcam = Number(index) || 0 + } return out } @@ -259,7 +282,7 @@ function CameraSheet({ cam, onClose, onSaved }) {

Three things from the camera: its address, its make, and its password. Test before you save — a wrong address is the most common mistake.

{error &&
{error}
} - {isNew && ( + {isNew && !local && (

Find it

{scan === null && ( @@ -301,15 +324,20 @@ function CameraSheet({ cam, onClose, onSaved }) { Short, no spaces. It names this camera everywhere and cannot be changed later. )} -
- - -
+ {local + ? + :
+ + +
}
@@ -317,27 +345,34 @@ function CameraSheet({ cam, onClose, onSaved }) { - + {!local && ( + + )}
-
-

Sign-in to the camera

-
- - -
-
+ {!local && ( +
+

Sign-in to the camera

+
+ + +
+
+ )} {test && ( test.ok diff --git a/pyproject.toml b/pyproject.toml index 5ee3058..d79e73a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,11 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["pytest>=8.0"] +# httpx is test-only and never ships in the wheel. The HTTP tests begin with +# `pytest.importorskip("httpx")` so a bare checkout still runs - which is +# right, and has a cost worth knowing: without it the suite reports 239 passed +# and quietly SKIPS 32 API tests. `pip install -e .[dev]` is how to get them. +dev = ["pytest>=8.0", "httpx>=0.27"] [tool.setuptools.packages.find] include = ["behavision*"] diff --git a/tests/test_api_cameras.py b/tests/test_api_cameras.py index 9766a9c..da54476 100644 --- a/tests/test_api_cameras.py +++ b/tests/test_api_cameras.py @@ -225,3 +225,42 @@ def test_an_inverted_per_camera_pair_is_rejected_not_stored(client): tuning={"enroll_threshold": 0.8, "match_threshold": 0.5}) assert r.status_code == 400 assert c.get("/api/cameras").json() == [] + + +# "This computer's own camera" — the demo case, and a capability the engine +# has always had with nothing able to reach it. +# +# It matters most for showing the product to somebody. A laptop's own camera +# gives real recognition, of real faces, in the room, depending on no network +# at all — where pointing a demo machine at a camera in another building +# depends on two internet connections and a tunnel staying up while you talk. +def test_this_computers_own_camera_can_be_added(client): + c, eng = client + r = c.post("/api/cameras", json={"id": "laptop", "webcam": 0}) + assert r.status_code == 201, r.text + assert "laptop" in eng.workers + + cam = next(x for x in c.get("/api/cameras").json() if x["id"] == "laptop") + # Returned, or the form cannot tell a webcam camera from a half-filled + # RTSP one when somebody opens it to edit. + assert cam["webcam"] == 0 + assert eng.camera_store.get("laptop").source() == 0 + + +def test_a_second_camera_index_is_kept(client): + """0 is the built-in one; a plugged-in camera is usually 1. An index + silently coerced to 0 would open the wrong camera and look like the + setting had no effect.""" + c, eng = client + assert c.post("/api/cameras", json={"id": "usb", "webcam": 1}).status_code == 201 + assert eng.camera_store.get("usb").source() == 1 + + +def test_a_webcam_camera_survives_a_reload(client, tmp_path): + """It has to be on disk, not only in the running engine: a demo that + forgets its camera when the app restarts is worse than no demo.""" + c, _ = client + c.post("/api/cameras", json={"id": "laptop", "webcam": 0}) + again = CameraStore(tmp_path / "cameras.json").get("laptop") + assert again.source() == 0 + assert again.safe_url() == "webcam:0"